\hypertarget{class_ogre_1_1_instance_manager}{}\section{Ogre\+:\+:Instance\+Manager Class Reference}
\label{class_ogre_1_1_instance_manager}\index{Ogre\+::\+Instance\+Manager@{Ogre\+::\+Instance\+Manager}}


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




{\ttfamily \#include $<$Ogre\+Instance\+Manager.\+h$>$}



Inheritance diagram for Ogre\+:\+:Instance\+Manager\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=209pt]{class_ogre_1_1_instance_manager__inherit__graph}
\end{center}
\end{figure}
\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
enum \hyperlink{group___scene_ga7832eb9e2627f71382fefc7293482508}{Batch\+Setting\+Id} \{ \hyperlink{group___scene_gga7832eb9e2627f71382fefc7293482508a4fa34122dba5df1604cd9cd44ee1c519}{C\+A\+S\+T\+\_\+\+S\+H\+A\+D\+O\+WS} = 0, 
\hyperlink{group___scene_gga7832eb9e2627f71382fefc7293482508a5aa5845eaa01e5c54fc92fc74b2f4176}{S\+H\+O\+W\+\_\+\+B\+O\+U\+N\+D\+I\+N\+G\+B\+OX}, 
\hyperlink{group___scene_gga7832eb9e2627f71382fefc7293482508a93252cb20077bbc127c02d96f5d696f0}{N\+U\+M\+\_\+\+S\+E\+T\+T\+I\+N\+GS}
 \}\begin{DoxyCompactList}\small\item\em Values to be used in \hyperlink{group___scene_gacbaa392a89ee55cb80da7314d8ad9dfd}{set\+Setting()} \& Batch\+Settings\+::setting. \end{DoxyCompactList}
\item 
typedef \hyperlink{class_ogre_1_1_const_vector_iterator}{Const\+Vector\+Iterator}$<$ Instance\+Batch\+Vec $>$ \hyperlink{group___scene_ga81a850f3da3dc22baa6d8fbd68a1723f}{Instance\+Batch\+Iterator}
\item 
typedef \hyperlink{class_ogre_1_1_const_map_iterator}{Const\+Map\+Iterator}$<$ Instance\+Batch\+Map $>$ \hyperlink{group___scene_ga449864e9fe068c83c3955dfcc112a2d1}{Instance\+Batch\+Map\+Iterator}
\item 
enum \hyperlink{group___scene_ga98fb2a9ada779b56d48f74040e96a622}{Instancing\+Technique} \{ \newline
\hyperlink{group___scene_gga98fb2a9ada779b56d48f74040e96a622adfd14a6d905e8f639010dceb63fd6a99}{Shader\+Based}, 
\hyperlink{group___scene_gga98fb2a9ada779b56d48f74040e96a622aa936e137d1695cec1b763a270dc73a3e}{Texture\+V\+TF}, 
\hyperlink{group___scene_gga98fb2a9ada779b56d48f74040e96a622a20f1ebda9178d5f5f4ebe613f3432eac}{H\+W\+Instancing\+Basic}, 
\hyperlink{group___scene_gga98fb2a9ada779b56d48f74040e96a622ac1ad45db6c7bc954c0374c37c8ed1b0d}{H\+W\+Instancing\+V\+TF}, 
\newline
\hyperlink{group___scene_gga98fb2a9ada779b56d48f74040e96a622a3efbc531e529142ddfd5c7272a373ece}{Instancing\+Techniques\+Count}
 \}
\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{group___scene_gab31a5819d546d97995e9c5fc0f6dbe76}{Instance\+Manager} (const \hyperlink{namespace_ogre_af73bbdc8bed8a3e6fcd56bb8fa188c45}{String} \&custom\+Name, \hyperlink{class_ogre_1_1_scene_manager}{Scene\+Manager} $\ast$scene\+Manager, const \hyperlink{namespace_ogre_af73bbdc8bed8a3e6fcd56bb8fa188c45}{String} \&mesh\+Name, const \hyperlink{namespace_ogre_af73bbdc8bed8a3e6fcd56bb8fa188c45}{String} \&group\+Name, \hyperlink{group___scene_ga98fb2a9ada779b56d48f74040e96a622}{Instancing\+Technique} instancing\+Technique, \hyperlink{namespace_ogre_aa8263b218e7d187ad5ef03a73a6ad7fd}{uint16} instancing\+Flags, size\+\_\+t instances\+Per\+Batch, unsigned short sub\+Mesh\+Idx, bool use\+Bone\+Matrix\+Lookup=false)
\item 
\hyperlink{group___scene_gacc52c44d8afc077315a16f5f21e600d5}{$\sim$\+Instance\+Manager} ()
\item 
void \hyperlink{group___scene_ga395a8ce5c926625f1902d7f645d041fc}{\+\_\+add\+Dirty\+Batch} (\hyperlink{class_ogre_1_1_instance_batch}{Instance\+Batch} $\ast$dirty\+Batch)
\begin{DoxyCompactList}\small\item\em Called by an \hyperlink{class_ogre_1_1_instance_batch}{Instance\+Batch} when it requests their bounds to be updated for proper culling. \end{DoxyCompactList}\item 
void \hyperlink{group___scene_ga5a53a7786df59317f4b208b55bd3ec41}{\+\_\+update\+Dirty\+Batches} (void)
\begin{DoxyCompactList}\small\item\em Called by \hyperlink{class_ogre_1_1_scene_manager}{Scene\+Manager} when we told it we have at least one dirty batch. \end{DoxyCompactList}\item 
void \hyperlink{group___scene_ga78d1331b24a26e89d49b50c0293bdab2}{cleanup\+Empty\+Batches} (void)
\begin{DoxyCompactList}\small\item\em This function can be useful to improve C\+PU speed after having too many instances created, which where now removed, thus freeing many batches with zero used Instanced Entities However the batches aren\textquotesingle{}t automatically removed from memory until the \hyperlink{class_ogre_1_1_instance_manager}{Instance\+Manager} is destroyed, or this function is called. \end{DoxyCompactList}\item 
\hyperlink{class_ogre_1_1_instanced_entity}{Instanced\+Entity} $\ast$ \hyperlink{group___scene_ga5767c95dac43bbc3c80966c362e32b73}{create\+Instanced\+Entity} (const \hyperlink{namespace_ogre_af73bbdc8bed8a3e6fcd56bb8fa188c45}{String} \&material\+Name)
\begin{DoxyCompactList}\small\item\em Creates an \hyperlink{class_ogre_1_1_instanced_entity}{Instanced\+Entity} based on an existing \hyperlink{class_ogre_1_1_instance_manager}{Instance\+Manager} (. \end{DoxyCompactList}\item 
void \hyperlink{group___scene_gad95874d5f995a6b7b66707cb260a0a19}{defragment\+Batches} (bool optimize\+Culling)
\begin{DoxyCompactList}\small\item\em 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. \end{DoxyCompactList}\item 
\hyperlink{group___scene_ga81a850f3da3dc22baa6d8fbd68a1723f}{Instance\+Batch\+Iterator} \hyperlink{group___scene_ga12e1b31f34a7f3e232495f0acda251fb}{get\+Instance\+Batch\+Iterator} (const \hyperlink{namespace_ogre_af73bbdc8bed8a3e6fcd56bb8fa188c45}{String} \&material\+Name) const
\begin{DoxyCompactList}\small\item\em Get non-\/updateable iterator over instance batches for given material. \end{DoxyCompactList}\item 
\hyperlink{group___scene_ga449864e9fe068c83c3955dfcc112a2d1}{Instance\+Batch\+Map\+Iterator} \hyperlink{group___scene_ga9c99d92a8ca66ad3bb588466acd2a11f}{get\+Instance\+Batch\+Map\+Iterator} (void) const
\begin{DoxyCompactList}\small\item\em Get non-\/updateable iterator over instance batches per material. \end{DoxyCompactList}\item 
\hyperlink{group___scene_ga98fb2a9ada779b56d48f74040e96a622}{Instancing\+Technique} \hyperlink{group___scene_ga3833def00a12ea2b8653e47b0ff214f9}{get\+Instancing\+Technique} () const
\item 
size\+\_\+t \hyperlink{group___scene_gacee1be4e7b70a433b969571a55743361}{get\+Max\+Or\+Best\+Num\+Instances\+Per\+Batch} (const \hyperlink{namespace_ogre_af73bbdc8bed8a3e6fcd56bb8fa188c45}{String} \&material\+Name, size\+\_\+t suggested\+Size, \hyperlink{namespace_ogre_aa8263b218e7d187ad5ef03a73a6ad7fd}{uint16} flags)
\begin{DoxyCompactList}\small\item\em 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. \end{DoxyCompactList}\item 
const \hyperlink{namespace_ogre_af73bbdc8bed8a3e6fcd56bb8fa188c45}{String} \& \hyperlink{group___scene_gafdb1bb452fa33f35fbc13dab22b4ae94}{get\+Name} () const
\item 
unsigned char \hyperlink{group___scene_gac0675779ed2ecc6ab4148fd4e4437dcb}{get\+Num\+Custom\+Params} () const
\item 
\hyperlink{class_ogre_1_1_scene_manager}{Scene\+Manager} $\ast$ \hyperlink{group___scene_ga19847d04345ad5c63ef8f20a143a1f83}{get\+Scene\+Manager} () const
\item 
bool \hyperlink{group___scene_ga077f2d02db254970a65827b238d5bae9}{get\+Setting} (\hyperlink{group___scene_ga7832eb9e2627f71382fefc7293482508}{Batch\+Setting\+Id} id, const \hyperlink{namespace_ogre_af73bbdc8bed8a3e6fcd56bb8fa188c45}{String} \&material\+Name) const
\begin{DoxyCompactList}\small\item\em If settings for the given material didn\textquotesingle{}t exist, default value is returned. \end{DoxyCompactList}\item 
bool \hyperlink{group___scene_gacd6f5bed6147490ec59a41e570acd830}{has\+Settings} (const \hyperlink{namespace_ogre_af73bbdc8bed8a3e6fcd56bb8fa188c45}{String} \&material\+Name) const
\begin{DoxyCompactList}\small\item\em Returns true if settings were already created for the given material name. \end{DoxyCompactList}\item 
void \hyperlink{group___scene_gaadfa0ab4a3974108898a518a1f789961}{set\+Batches\+As\+Static\+And\+Update} (bool b\+Static)
\begin{DoxyCompactList}\small\item\em Tells this batch to stop updating animations, positions, rotations, and display all it\textquotesingle{}s active instances. \end{DoxyCompactList}\item 
void \hyperlink{group___scene_ga20c5c86323fe3d15f2531e88d8299b17}{set\+Instances\+Per\+Batch} (size\+\_\+t instances\+Per\+Batch)
\begin{DoxyCompactList}\small\item\em Raises an exception if trying to change it after creating the first \hyperlink{class_ogre_1_1_instanced_entity}{Instanced\+Entity}. \end{DoxyCompactList}\item 
void \hyperlink{group___scene_ga784eee0c3b16d9a661c39ad24459b0cb}{set\+Max\+Lookup\+Table\+Instances} (size\+\_\+t max\+Lookup\+Table\+Instances)
\begin{DoxyCompactList}\small\item\em Sets the size of the lookup table for techniques supporting bone lookup table. \end{DoxyCompactList}\item 
void \hyperlink{group___scene_gaad4652f49581a4867f14d50baa9e060d}{set\+Num\+Custom\+Params} (unsigned char num\+Custom\+Params)
\begin{DoxyCompactList}\small\item\em Sets the number of custom parameters per instance. \end{DoxyCompactList}\item 
void \hyperlink{group___scene_gacbaa392a89ee55cb80da7314d8ad9dfd}{set\+Setting} (\hyperlink{group___scene_ga7832eb9e2627f71382fefc7293482508}{Batch\+Setting\+Id} id, bool enabled, const \hyperlink{namespace_ogre_af73bbdc8bed8a3e6fcd56bb8fa188c45}{String} \&material\+Name=\hyperlink{group___general_gad842a4b416bd2f3245d2b44826a0aedc}{B\+L\+A\+N\+K\+S\+T\+R\+I\+NG})
\begin{DoxyCompactList}\small\item\em Applies a setting for all batches using the same material\+\_\+ existing ones and those that will be created in the future. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
This is the main starting point for the new instancing system. 

Each \hyperlink{class_ogre_1_1_instance_manager}{Instance\+Manager} can control one technique and one mesh, but it can manage multiple materials at the same time. \begin{DoxySeeAlso}{See also}
\hyperlink{class_ogre_1_1_scene_manager_af63c901b00fbf75746a00dad7e124065}{Scene\+Manager\+::create\+Instance\+Manager}, which creates this \hyperlink{class_ogre_1_1_instance_manager}{Instance\+Manager}. Each one must have a unique name. It\textquotesingle{}s wasteless to create two Instance\+Managers 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\textquotesingle{}t have to worry of managing all those low level issues. 

\hyperlink{class_ogre_1_1_instance_batch}{Instance\+Batch} \& 

Instance\+Entity for more information.
\end{DoxySeeAlso}
\begin{DoxyRemark}{Remarks}
Design discussion webpage\+: \href{http://www.ogre3d.org/forums/viewtopic.php?f=4&t=59902}{\tt http\+://www.\+ogre3d.\+org/forums/viewtopic.\+php?f=4\&t=59902} 
\end{DoxyRemark}
\begin{DoxyAuthor}{Author}
Matias N. Goldberg (\char`\"{}dark\+\_\+sylinc\char`\"{}) 
\end{DoxyAuthor}
\begin{DoxyVersion}{Version}
1.\+0 
\end{DoxyVersion}


The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
\hyperlink{_ogre_instance_manager_8h}{Ogre\+Instance\+Manager.\+h}\end{DoxyCompactItemize}
