11#ifndef _INCLUDE_OGRENEWT_WORLD
12#define _INCLUDE_OGRENEWT_WORLD
17#include "CustomTriggerManager.h"
39 TriggerCallback(CustomTriggerController*
const controller) :m_controller(controller)
50 virtual void OnEnter(NewtonBody*
const visitor)
53 m_EnterCallback(visitor);
56 virtual void OnInside(NewtonBody*
const visitor)
59 m_InsideCallback(visitor);
62 virtual void OnExit(NewtonBody*
const visitor)
65 m_ExitCallback(visitor);
69 template<
class c>
void setTriggerEnterCallback( std::function<
void(c*, NewtonBody*
const)> callback, c *instancedClassPointer )
71 setTriggerEnterCallback(std::bind(callback, instancedClassPointer, std::placeholders::_1));
75 template<
class c>
void setTriggerInsideCallback( std::function<
void(c*, NewtonBody*
const)> callback, c *instancedClassPointer )
77 setTriggerInsideCallback(std::bind(callback, instancedClassPointer, std::placeholders::_1));
81 template<
class c>
void setTriggerExitCallback( std::function<
void(c*, NewtonBody*
const)> callback, c *instancedClassPointer )
83 setTriggerExitCallback(std::bind(callback, instancedClassPointer, std::placeholders::_1));
96 CustomTriggerController*
CreateController(
const dMatrix& matrix, NewtonCollision*
const convexShape)
98 CustomTriggerController*
const controller = CreateTrigger (matrix, convexShape, NULL);
100 controller->SetUserData(forceCallback);
108 CustomTriggerManager::DestroyController(controller);
111 virtual void EventCallback(
const CustomTriggerController*
const me, TriggerEventType
event, NewtonBody*
const visitor)
const
124 callback->
OnExit(visitor);
181 PF_DETERMINISTIC_UNOPTIMIZED = 0,
182 PF_COMMON_OPTIMIZED = 1,
200 World(Ogre::Real desiredFps = 100.0f,
int maxUpdatesPerFrames = 5, Ogre::String name =
"main");
205 CustomTriggerController* CreateController(
const dMatrix& matrix, NewtonCollision*
const convexShape);
206 void DestroyController(CustomTriggerController*
const controller);
208 void setPreListener(std::string name,
void*
const listenerUserData, NewtonWorldUpdateListenerCallback update);
209 void setpostListener(std::string name,
void*
const listenerUserData, NewtonWorldUpdateListenerCallback update);
216 static void setAllocators (NewtonAllocMemory newtonAlloc, NewtonFreeMemory newtonFree);
225 int update( Ogre::Real t_step );
239 void setUpdateFPS(Ogre::Real desiredFps,
int maxUpdatesPerFrames);
305 void setSolverModel(
int model);
322 NewtonSetCurrentDevice (m_world, mode);
332 int getPlatformArchitecture(Ogre::String& description) {
char desc[265];
int mode = NewtonGetCurrentDevice(m_world); NewtonGetDeviceString(m_world, mode, desc,
sizeof(desc)); description = desc;
return mode;}
338 int getBodyCount()
const {
return NewtonWorldGetBodyCount( m_world ); }
350 void setThreadCount(
int threads);
371 Body* getFirstBody()
const;
375 MaterialGroupID* getFirstMaterialGroupID();
389 void addBodyUpdateNodeRequest( int threadIndex, OgreNewt::Body* body ) const ;
SCOL_EXPORT void SCOL_PTR_TYPE event
main class for all Rigid Bodies in the system.
Iterate through all bodies in a specific AABB in the world.
For viewing the Newton rigid bodies visually.
represents a physics world.
PlatformArchitecture
platform mode
void setPlatformArchitecture(int mode)
specify a specific architecture to use for physics calculations.
void setDefaultAngularDamping(Ogre::Vector3 defaultAngularDamping)
sets default angular damping
WorldTriggerManager * m_triggerManager
void setDefaultLinearDamping(Ogre::Real defaultLinearDamping)
sets default linear damping
FrictionModelMode
friction solver mode.
void criticalSectionUnlock() const
notify the exit of a critical section of code.
const MaterialID * getDefaultMaterialID() const
get the default materialID object.
MaterialID * m_defaultMatID
void setFrictionModel(int model)
set the physics friction model
Ogre::Vector3 m_defaultAngularDamping
void setMultithreadSolverOnSingleIsland(int mode)
multithread settings
Ogre::Real getUpdateFPS() const
returns desired update frames per second
BodyInAABBIterator m_bodyInAABBIterator
std::vector< BodyVector > BodyVectorVector
int getBodyCount() const
get the number of bodies in the simulation.
Debugger & getDebugger() const
get the debugger for this world
std::vector< OgreNewt::Body * > BodyVector
int getThreadCount() const
get the number of threads the simulation is using.
NewtonWorld * getNewtonWorld() const
retrieves a pointer to the NewtonWorld
SolverModelMode
physics solver mode.
void criticalSectionLock() const
notify an entrance to a critical section of code.
Ogre::Real m_timeAcumulator
std::function< void(OgreNewt::Body *, int threadIndex)> LeaveWorldCallback
leave world callback.
void destroyAllBodies()
remove all bodies from the world.
int getVersion() const
get the Newton SDK version.
Ogre::Vector3 getDefaultAngularDamping() const
return default angular damping
Ogre::Real getDefaultLinearDamping() const
return default linear damping
void setMinimumFrameRate(Ogre::Real frame)
set minimum framerate
int getMultithreadSolverOnSingleIsland() const
get multithread settings
int getConstraintCount() const
get the number of constaints in the simulation
void waitForUpdateToFinish() const
int getPlatformArchitecture(Ogre::String &description)
get the architecture used for physics calculations.
void invalidateCache()
invalidate internal cache
Ogre::Real m_defaultLinearDamping
const BodyInAABBIterator & getBodyInAABBIterator() const
get a bodyInAABBIterator for this world
virtual void OnEnter(NewtonBody *const visitor)
void setTriggerEnterCallback(std::function< void(c *, NewtonBody *const)> callback, c *instancedClassPointer)
virtual ~TriggerCallback()
virtual void OnExit(NewtonBody *const visitor)
void setTriggerExitCallback(std::function< void(c *, NewtonBody *const)> callback, c *instancedClassPointer)
void setTriggerInsideCallback(std::function< void(c *, NewtonBody *const)> callback, c *instancedClassPointer)
CustomTriggerController * m_controller
TriggerCallback(CustomTriggerController *const controller)
virtual void OnInside(NewtonBody *const visitor)
CustomTriggerController * CreateController(const dMatrix &matrix, NewtonCollision *const convexShape)
void DestroyController(CustomTriggerController *const controller)
std::function< void(NewtonBody *const visitor)> WorldTriggerInsideCallback
std::function< void(NewtonBody *const visitor)> WorldTriggerEnterCallback
std::function< void(NewtonBody *const visitor)> WorldTriggerExitCallback
virtual void EventCallback(const CustomTriggerController *const me, TriggerEventType event, NewtonBody *const visitor) const