Skip to content

Commit

Permalink
Main: SceneManager - add Static Geometry collection access (#2987)
Browse files Browse the repository at this point in the history
Added access to the full map of names to StaticGeometry held by the SceneManager. (fixes #113)
  • Loading branch information
DrDub authored Dec 14, 2023
1 parent 721d0fb commit fd921a4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions OgreMain/include/Ogre.i
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,10 @@ SHARED_PTR(HardwarePixelBuffer);
typedef pointer_category category;
static const char* type_name() { return "Ogre::Camera"; }
};
template<> struct traits<Ogre::StaticGeometry> {
typedef pointer_category category;
static const char* type_name() { return "Ogre::StaticGeometry"; }
};
}
%}
#endif
Expand Down Expand Up @@ -884,6 +888,7 @@ SHARED_PTR(Mesh);
%newobject Ogre::SceneManager::createRayQuery(const Ray&);
%rename(SceneManager_Listener) Ogre::SceneManager::Listener;
%template(MovableObjectMap) std::map<std::string, Ogre::MovableObject*>;
%template(StaticGeometryMap) std::map<std::string, Ogre::StaticGeometry*>;
%template(CameraMap) std::map<std::string, Ogre::Camera*>;
%include "OgreSceneManager.h"
%include "OgreDefaultDebugDrawer.h"
Expand Down
6 changes: 4 additions & 2 deletions OgreMain/include/OgreSceneManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ namespace Ogre {
typedef std::map<String, Camera* > CameraList;
typedef std::map<String, Animation*> AnimationList;
typedef std::map<String, MovableObject*> MovableObjectMap;
typedef std::map<String, StaticGeometry* > StaticGeometryMap;
private:
HardwareVertexBufferPtr mInstanceBuffer;

Expand All @@ -421,8 +422,7 @@ namespace Ogre {
/// Queue of objects for rendering
std::unique_ptr<RenderQueue> mRenderQueue;

typedef std::map<String, StaticGeometry* > StaticGeometryList;
StaticGeometryList mStaticGeometryList;
StaticGeometryMap mStaticGeometryList;

typedef std::map<String, InstanceManager*> InstanceManagerMap;
InstanceManagerMap mInstanceManagerMap;
Expand Down Expand Up @@ -2979,6 +2979,8 @@ namespace Ogre {
StaticGeometry* getStaticGeometry(const String& name) const;
/** Returns whether a static geometry instance with the given name exists. */
bool hasStaticGeometry(const String& name) const;
/** Returns all static geometry instances with names. */
const StaticGeometryMap* getStaticGeometryCollection() const;
/** Remove & destroy a StaticGeometry instance. */
void destroyStaticGeometry(StaticGeometry* geom);
/** Remove & destroy a StaticGeometry instance. */
Expand Down
10 changes: 8 additions & 2 deletions OgreMain/src/OgreSceneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2948,7 +2948,7 @@ StaticGeometry* SceneManager::createStaticGeometry(const String& name)
//---------------------------------------------------------------------
StaticGeometry* SceneManager::getStaticGeometry(const String& name) const
{
StaticGeometryList::const_iterator i = mStaticGeometryList.find(name);
StaticGeometryMap::const_iterator i = mStaticGeometryList.find(name);
if (i == mStaticGeometryList.end())
{
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
Expand All @@ -2963,6 +2963,12 @@ bool SceneManager::hasStaticGeometry(const String& name) const
return (mStaticGeometryList.find(name) != mStaticGeometryList.end());
}

//-----------------------------------------------------------------------
const SceneManager::StaticGeometryMap* SceneManager:: getStaticGeometryCollection() const
{
return &mStaticGeometryList;
}

//---------------------------------------------------------------------
void SceneManager::destroyStaticGeometry(StaticGeometry* geom)
{
Expand All @@ -2971,7 +2977,7 @@ void SceneManager::destroyStaticGeometry(StaticGeometry* geom)
//---------------------------------------------------------------------
void SceneManager::destroyStaticGeometry(const String& name)
{
StaticGeometryList::iterator i = mStaticGeometryList.find(name);
StaticGeometryMap::iterator i = mStaticGeometryList.find(name);
if (i != mStaticGeometryList.end())
{
OGRE_DELETE i->second;
Expand Down

0 comments on commit fd921a4

Please sign in to comment.