OGRE 14.3
Object-Oriented Graphics Rendering Engine
Loading...
Searching...
No Matches
Ogre::InstanceManager Class Reference

This is the main starting point for the new instancing system. More...

#include <OgreInstanceManager.h>

+ Inheritance diagram for Ogre::InstanceManager:

Public Types

enum  BatchSettingId { CAST_SHADOWS = 0 , SHOW_BOUNDINGBOX , NUM_SETTINGS }
 Values to be used in setSetting() & BatchSettings::setting. More...
 
typedef ConstVectorIterator< InstanceBatchVec > InstanceBatchIterator
 
typedef ConstMapIterator< InstanceBatchMap > InstanceBatchMapIterator
 
enum  InstancingTechnique {
  ShaderBased , TextureVTF , HWInstancingBasic , HWInstancingVTF ,
  InstancingTechniquesCount
}
 

Public Member Functions

 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)
 
 ~InstanceManager ()
 
void _addDirtyBatch (InstanceBatch *dirtyBatch)
 Called by an InstanceBatch when it requests their bounds to be updated for proper culling.
 
void _updateDirtyBatches (void)
 Called by SceneManager when we told it we have at least one dirty batch.
 
void cleanupEmptyBatches (void)
 This function can be useful to improve CPU speed after having too many instances created, which where now removed, thus freeing many batches with zero used Instanced Entities However the batches aren't automatically removed from memory until the InstanceManager is destroyed, or this function is called.
 
InstancedEntitycreateInstancedEntity (const String &materialName)
 Creates an InstancedEntity.
 
void defragmentBatches (bool optimizeCulling)
 After creating many entities (which turns in many batches) and then removing entities that are in the middle of these batches, there might be many batches with many free entities.
 
InstanceBatchIterator getInstanceBatchIterator (const String &materialName) const
 Get non-updateable iterator over instance batches for given material.
 
InstanceBatchMapIterator getInstanceBatchMapIterator (void) const
 Get non-updateable iterator over instance batches per material.
 
InstancingTechnique getInstancingTechnique () const
 
size_t getMaxOrBestNumInstancesPerBatch (const String &materialName, size_t suggestedSize, uint16 flags)
 Calculates the maximum (or the best amount, depending on flags) of instances per batch given the suggested size for the technique this manager was created for.
 
const StringgetName () const
 
unsigned char getNumCustomParams () const
 
SceneManagergetSceneManager () const
 
bool getSetting (BatchSettingId id, const String &materialName) const
 If settings for the given material didn't exist, default value is returned.
 
bool hasSettings (const String &materialName) const
 Returns true if settings were already created for the given material name.
 
void setBatchesAsStaticAndUpdate (bool bStatic)
 Tells this batch to stop updating animations, positions, rotations, and display all it's active instances.
 
void setInstancesPerBatch (size_t instancesPerBatch)
 Raises an exception if trying to change it after creating the first InstancedEntity The actual value may be less if the technique doesn't support having so much.
 
void setMaxLookupTableInstances (size_t maxLookupTableInstances)
 Sets the size of the lookup table for techniques supporting bone lookup table.
 
void setNumCustomParams (unsigned char numCustomParams)
 Sets the number of custom parameters per instance.
 
void setSetting (BatchSettingId id, bool enabled, const String &materialName=BLANKSTRING)
 Applies a setting for all batches using the same material.
 

Detailed Description

This is the main starting point for the new instancing system.

Each InstanceManager can control one technique and one mesh, but it can manage multiple materials at the same time. SceneManager::createInstanceManager, which creates this InstanceManager. Each one must have a unique name. It's wasteless to create two InstanceManagers with the same mesh reference, instancing technique and instances per batch count. This class takes care of managing batches automatically, so that more are created when needed, and reuse existing ones as much as possible; thus the user doesn't have to worry of managing all those low level issues.

See also
InstanceBatch
InstancedEntity
Design discussion thread: http://www.ogre3d.org/forums/viewtopic.php?f=4&t=59902

The documentation for this class was generated from the following file: