reference manager for physics communication

This commit is contained in:
Erik Persson 2013-11-25 12:51:58 +01:00
parent 0db45bd63f
commit e2c90a467b
4 changed files with 62 additions and 0 deletions

View File

@ -170,6 +170,7 @@
<ClInclude Include="Level.h" /> <ClInclude Include="Level.h" />
<ClInclude Include="Object.h" /> <ClInclude Include="Object.h" />
<ClInclude Include="Player.h" /> <ClInclude Include="Player.h" />
<ClInclude Include="RefManager.h" />
<ClInclude Include="StaticObject.h" /> <ClInclude Include="StaticObject.h" />
<ClInclude Include="Weapon.h" /> <ClInclude Include="Weapon.h" />
</ItemGroup> </ItemGroup>
@ -180,6 +181,7 @@
<ClCompile Include="Level.cpp" /> <ClCompile Include="Level.cpp" />
<ClCompile Include="Object.cpp" /> <ClCompile Include="Object.cpp" />
<ClCompile Include="Player.cpp" /> <ClCompile Include="Player.cpp" />
<ClCompile Include="RefManager.cpp" />
<ClCompile Include="StaticObject.cpp" /> <ClCompile Include="StaticObject.cpp" />
<ClCompile Include="TestGLMain.cpp" /> <ClCompile Include="TestGLMain.cpp" />
<ClCompile Include="Weapon.cpp" /> <ClCompile Include="Weapon.cpp" />

View File

@ -39,6 +39,9 @@
<ClInclude Include="DynamicObject.h"> <ClInclude Include="DynamicObject.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="RefManager.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Game.cpp"> <ClCompile Include="Game.cpp">
@ -68,5 +71,8 @@
<ClCompile Include="TestGLMain.cpp"> <ClCompile Include="TestGLMain.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="RefManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,26 @@
#include "RefManager.h"
using namespace GameLogic;
typedef std::pair<Oyster::Physics::ICustomBody*, Object*> mapData;
RefManager::RefManager(void)
{
}
RefManager::~RefManager(void)
{
}
Object* RefManager::GetMap(Oyster::Physics::ICustomBody *body)
{
return mapper[body];
}
void RefManager::AddMapping(Oyster::Physics::ICustomBody *body, Object *obj)
{
mapper.insert(mapData(body,obj));
}

View File

@ -0,0 +1,28 @@
#ifndef REFMANAGER_H
#define REFMANAGER_H
#include<map>
#include "Object.h"
#include "PhysicsAPI.h"
namespace GameLogic
{
class RefManager
{
public:
RefManager(void);
~RefManager(void);
Object* GetMap(Oyster::Physics::ICustomBody *body);
void AddMapping(Oyster::Physics::ICustomBody *body, Object *obj);
private:
std::map<Oyster::Physics::ICustomBody*,Object*> mapper; //shall be pointer from physics that map to an object
};
}
#endif