28#ifndef __InstanceManager_H__
29#define __InstanceManager_H__
160 size_t instancesPerBatch,
unsigned short subMeshIdx,
bool useBoneMatrixLookup =
false);
312 InstanceBatchMap::const_iterator it =
mInstanceBatches.find( materialName );
317 "Material " + materialName +
" cannot be found.",
"InstanceManager::getInstanceBatchIterator");
Concrete IteratorWrapper for const access to the underlying key-value container.
Concrete IteratorWrapper for const access to the underlying container.
InstanceBatch forms part of the new Instancing system This is an abstract class that must be derived ...
'New' rendering operation using vertex buffers.
Manages the organisation and rendering of a 'scene' i.e.
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
#define OGRE_EXCEPT(code, desc, src)
RenderOperation mSharedRenderOperation
bool getSetting(BatchSettingId id, const String &materialName) const
If settings for the given material didn't exist, default value is returned.
InstanceBatchIterator getInstanceBatchIterator(const String &materialName) const
Get non-updateable iterator over instance batches for given material.
size_t mMaxLookupTableInstances
void applySettingToBatches(BatchSettingId id, bool value, const InstanceBatchVec &container)
void setInstancesPerBatch(size_t instancesPerBatch)
Raises an exception if trying to change it after creating the first InstancedEntity.
SceneManager * getSceneManager() const
size_t getMaxOrBestNumInstancesPerBatch(String materialName, size_t suggestedSize, uint16 flags)
Calculates the maximum (or the best amount, depending on flags) of instances per batch given the sugg...
bool setting[NUM_SETTINGS]
map< String, InstanceBatchVec >::type InstanceBatchMap
SceneManager * mSceneManager
InstancingTechnique getInstancingTechnique() const
virtual ~InstanceManager()
vector< InstanceBatch * >::type InstanceBatchVec
void _addDirtyBatch(InstanceBatch *dirtyBatch)
Called by an InstanceBatch when it requests their bounds to be updated for proper culling.
size_t mInstancesPerBatch
InstanceBatchVec mDirtyBatches
ConstMapIterator< InstanceBatchMap > InstanceBatchMapIterator
InstanceBatch * getFreeBatch(const String &materialName)
Finds a batch with at least one free instanced entity we can use.
void _updateDirtyBatches(void)
Called by SceneManager when we told it we have at least one dirty batch.
BatchSettingId
Values to be used in setSetting() & BatchSettings::setting.
void setMaxLookupTableInstances(size_t maxLookupTableInstances)
Sets the size of the lookup table for techniques supporting bone lookup table.
void cleanupEmptyBatches(void)
This function can be useful to improve CPU speed after having too many instances created,...
InstanceBatch * buildNewBatch(const String &materialName, bool firstTime)
Called when batches are fully exhausted (can't return more instances) so a new batch is created.
ConstVectorIterator< InstanceBatchVec > InstanceBatchIterator
BatchSettingsMap mBatchSettings
const String & getName() const
InstanceBatchMapIterator getInstanceBatchMapIterator(void) const
Get non-updateable iterator over instance batches per material.
InstanceBatchMap mInstanceBatches
void defragmentBatches(bool optimizeCull, vector< InstancedEntity * >::type &entities, vector< Ogre::Vector4 >::type &usedParams, InstanceBatchVec &fragmentedBatches)
void setNumCustomParams(unsigned char numCustomParams)
Sets the number of custom parameters per instance.
void setBatchesAsStaticAndUpdate(bool bStatic)
Tells this batch to stop updating animations, positions, rotations, and display all it's active insta...
InstanceManager(const String &customName, SceneManager *sceneManager, const String &meshName, const String &groupName, InstancingTechnique instancingTechnique, uint16 instancingFlags, size_t instancesPerBatch, unsigned short subMeshIdx, bool useBoneMatrixLookup=false)
unsigned char getNumCustomParams() const
unsigned short mSubMeshIdx
void unshareVertices(const Ogre::MeshPtr &mesh)
Called when we you use a mesh which has shared vertices, the function creates separate vertex/index b...
InstancedEntity * createInstancedEntity(const String &materialName)
Creates an InstancedEntity based on an existing InstanceManager (.
bool hasSettings(const String &materialName) const
Returns true if settings were already created for the given material name.
InstancingTechnique mInstancingTechnique
unsigned char mNumCustomParams
void defragmentBatches(bool optimizeCulling)
After creating many entities (which turns in many batches) and then removing entities that are in the...
map< String, BatchSettings >::type BatchSettingsMap
void setSetting(BatchSettingId id, bool enabled, const String &materialName=StringUtil::BLANK)
Applies a setting for all batches using the same material_ existing ones and those that will be creat...
@ CAST_SHADOWS
Makes all batches from same material cast shadows.
@ SHOW_BOUNDINGBOX
Makes each batch to display it's bounding box. Useful for debugging or profiling.
@ HWInstancingBasic
Needs SM 3.0+ and HW instancing support.
@ InstancingTechniquesCount
@ TextureVTF
Needs Vertex Texture Fetch & SM 3.0+.
@ HWInstancingVTF
Needs SM 3.0+, HW instancing support & VTF.
@ ShaderBased
Any SM 2.0+.
SharedPtr< Mesh > MeshPtr
GeneralAllocatedObject FactoryAlloc
std::map< K, V, P, A > type