28#ifndef __InstanceBatch_H__
29#define __InstanceBatch_H__
175 const String &batchName );
247 bool isBatchUnused(
void)
const {
return mUnusedEntities.size() == mInstancedEntities.size(); }
357 using Renderable::getUserAny;
358 using Renderable::setUserAny;
A 3D box aligned with the x/y/z axes.
A viewpoint from which the scene will be rendered.
InstanceBatch forms part of the new Instancing system This is an abstract class that must be derived ...
This is the main starting point for the new instancing system.
vector< unsignedshort >::type IndexMap
Abstract class defining a movable object in a scene.
'New' rendering operation using vertex buffers.
Class to manage the scene object rendering queue.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly.
Abstract class defining the interface all renderable objects must implement.
Defines a part of a complete mesh.
Class representing an approach to rendering this particular Material.
4-dimensional homogeneous vector.
virtual bool checkSubMeshCompatibility(const SubMesh *baseSubMesh)
Returns false on errors that would prevent building this batch from the given submesh.
InstanceBatch(InstanceManager *creator, MeshPtr &meshReference, const MaterialPtr &material, size_t instancesPerBatch, const Mesh::IndexMap *indexToBoneMap, const String &batchName)
CustomParamsVec mCustomParams
bool isBatchUnused(void) const
Returns true if it no instanced entity has been requested or all of them have been removed.
Mesh::IndexMap const * mIndexToBoneMap
Real getSquaredViewDepth(const Camera *cam) const
Returns the camera-relative squared depth of this renderable.
AxisAlignedBox mFullBoundingBox
This bbox contains all (visible) instanced entities.
virtual void setupIndices(const SubMesh *baseSubMesh)=0
InstancedEntityVec mInstancedEntities
void _markTransformSharingDirty()
Tells that the list of entity instances with shared transforms has changed.
Technique * getTechnique(void) const
Retrieves a pointer to the Material Technique this renderable object uses.
virtual InstancedEntity * generateInstancedEntity(size_t num)
Creates a new InstancedEntity instance.
vector< Vector4 >::type CustomParamsVec
virtual size_t calculateMaxNumInstances(const SubMesh *baseSubMesh, uint16 flags) const =0
Some techniques have a limit on how many instances can be done.
void _defragmentBatch(bool optimizeCulling, InstancedEntityVec &usedEntities, CustomParamsVec &usedParams)
bool mRemoveOwnIndexData
When true remove the memory of the IndexData we've created because no one else will.
Real mCachedCameraDist
Cached distance to last camera for getSquaredViewDepth.
const Vector4 & _getCustomParam(InstancedEntity *instancedEntity, unsigned char idx)
void defragmentBatchDoCull(InstancedEntityVec &usedEntities, CustomParamsVec &usedParams)
bool _supportsSkeletalAnimation() const
Returns true if this technique supports skeletal animation.
bool mTechnSupportsSkeletal
False if a technique doesn't support skeletal animation.
void _setCustomParam(InstancedEntity *instancedEntity, unsigned char idx, const Vector4 &newParam)
void defragmentBatchNoCull(InstancedEntityVec &usedEntities, CustomParamsVec &usedParams)
void removeInstancedEntity(InstancedEntity *instancedEntity)
Removes an InstancedEntity from the scene retrieved with getNewInstancedEntity, putting back into a q...
virtual void buildFrom(const SubMesh *baseSubMesh, const RenderOperation &renderOperation)
Instancing consumes significantly more GPU memory than regular rendering methods.
virtual void createAllInstancedEntities(void)
virtual void deleteUnusedInstancedEntities(void)
const MaterialPtr & getMaterial(void) const
Retrieves a weak reference to the material this renderable object uses.
void _defragmentBatchDiscard(void)
Real getBoundingRadius(void) const
Retrieves the radius of the origin-centered bounding sphere for this object.
virtual RenderOperation build(const SubMesh *baseSubMesh)
Constructs all the data needed to use this batch, as well as the InstanceEntities.
const String & getMovableType(void) const
Returns the type name of this object.
void _setInstancesPerBatch(size_t instancesPerBatch)
Raises an exception if trying to change it after being built.
virtual void deleteAllInstancedEntities(void)
InstancedEntity * createInstancedEntity()
Returns a pointer to a new InstancedEntity ready to use Note it's actually preallocated,...
InstancedEntityVec mUnusedEntities
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
bool mRemoveOwnVertexData
When true remove the memory of the VertexData we've created because no one else will.
const LightList & getLights(void) const
Gets a list of lights, ordered relative to how close they are to this renderable.
virtual void _boundsDirty(void)
Called by InstancedEntity(s) to tell us we need to update the bounds (we touch the SceneNode so the S...
virtual void _updateRenderQueue(RenderQueue *queue)
Internal method by which the movable object must add Renderable subclass instances to the rendering q...
virtual void setupVertices(const SubMesh *baseSubMesh)=0
const Mesh::IndexMap * _getIndexToBoneMap() const
virtual void setStaticAndUpdate(bool bStatic)
Tells this batch to stop updating animations, positions, rotations, and display all it's active insta...
const Ogre::MeshPtr & _getMeshReference(void) const
bool isBatchFull(void) const
const Camera * mCachedCamera
The camera for which the cached distance is valid.
size_t mInstancesPerBatch
void getRenderOperation(RenderOperation &op)
Gets the render operation required to send this object to the frame buffer.
InstanceManager * mCreator
void makeMatrixCameraRelative3x4(float *mat3x4, size_t numFloats)
Takes an array of 3x4 matrices and makes it camera relative.
void updateVisibility(void)
RenderOperation mRenderOperation
virtual bool useBoneWorldMatrices() const
Tells whether world bone matrices need to be calculated.
void _notifyCurrentCamera(Camera *cam)
Internal method to notify the object of the camera to be used for the next rendering operation.
void getInstancedEntitiesInUse(InstancedEntityVec &outEntities, CustomParamsVec &outParams)
Fills the input vector with the instances that are currently being used or were requested.
unsigned short mMaterialLodIndex
const AxisAlignedBox & getBoundingBox(void) const
Retrieves the local axis-aligned bounding box for this object.
bool mTransformSharingDirty
Tells that the list of entity instances with shared transforms has changed.
vector< InstancedEntity * >::type InstancedEntityVec
virtual bool isStatic() const
Returns true if this batch was set as static.
float Real
Software floating point type.