SO3Engine
|
represents a physics world. More...
#include <OgreNewt_World.h>
Public Types | |
enum | SolverModelMode { SM_EXACT = 0 , SM_FASTEST = 1 , SM_MEDIUM = 4 , SM_SLOW = 8 , SM_RIDICULUS = 16 } |
physics solver mode. More... | |
enum | FrictionModelMode { FM_EXACT = 0 , FM_ADAPTIVE = 1 } |
friction solver mode. More... | |
enum | PlatformArchitecture { PF_DETERMINISTIC_UNOPTIMIZED = 0 , PF_COMMON_OPTIMIZED = 1 , PF_BEST_POSSIBLE = 2 } |
platform mode More... | |
typedef std::function< void(OgreNewt::Body *, int threadIndex)> | LeaveWorldCallback |
leave world callback. | |
Public Member Functions | |
World (Ogre::Real desiredFps=100.0f, int maxUpdatesPerFrames=5, Ogre::String name="main") | |
Constructor, creates the world and gives it a name. | |
~World () | |
Standard Destructor, destroys the world. | |
CustomTriggerController * | CreateController (const dMatrix &matrix, NewtonCollision *const convexShape) |
void | DestroyController (CustomTriggerController *const controller) |
void | setPreListener (std::string name, void *const listenerUserData, NewtonWorldUpdateListenerCallback update) |
void | setpostListener (std::string name, void *const listenerUserData, NewtonWorldUpdateListenerCallback update) |
int | update (Ogre::Real t_step) |
update the world by the specified time_step. | |
void | invalidateCache () |
invalidate internal cache | |
void | setUpdateFPS (Ogre::Real desiredFps, int maxUpdatesPerFrames) |
set simulation frames per and max updated per updates | |
Ogre::Real | getUpdateFPS () const |
returns desired update frames per second | |
void | setDefaultLinearDamping (Ogre::Real defaultLinearDamping) |
sets default linear damping | |
Ogre::Real | getDefaultLinearDamping () const |
return default linear damping | |
void | setDefaultAngularDamping (Ogre::Vector3 defaultAngularDamping) |
sets default angular damping | |
Ogre::Vector3 | getDefaultAngularDamping () const |
return default angular damping | |
NewtonWorld * | getNewtonWorld () const |
retrieves a pointer to the NewtonWorld | |
const MaterialID * | getDefaultMaterialID () const |
get the default materialID object. | |
void | destroyAllBodies () |
remove all bodies from the world. | |
void | setSolverModel (int model) |
set the physics solver model | |
void | setFrictionModel (int model) |
set the physics friction model | |
void | setPlatformArchitecture (int mode) |
specify a specific architecture to use for physics calculations. | |
int | getPlatformArchitecture (Ogre::String &description) |
get the architecture used for physics calculations. | |
int | getBodyCount () const |
get the number of bodies in the simulation. | |
int | getConstraintCount () const |
get the number of constaints in the simulation | |
void | setMultithreadSolverOnSingleIsland (int mode) |
multithread settings | |
int | getMultithreadSolverOnSingleIsland () const |
get multithread settings | |
void | setThreadCount (int threads) |
set the number of threads for the physics simulation to use, don't do this while world update | |
int | getThreadCount () const |
get the number of threads the simulation is using. | |
void | criticalSectionLock () const |
notify an entrance to a critical section of code. | |
void | criticalSectionUnlock () const |
notify the exit of a critical section of code. | |
void | waitForUpdateToFinish () const |
void | setMinimumFrameRate (Ogre::Real frame) |
set minimum framerate | |
int | getVersion () const |
get the Newton SDK version. | |
Body * | getFirstBody () const |
to iterate through all bodies call this function and then use body->getNext() | |
const BodyInAABBIterator & | getBodyInAABBIterator () const |
get a bodyInAABBIterator for this world | |
Debugger & | getDebugger () const |
get the debugger for this world | |
Static Public Member Functions | |
static void | setAllocators (NewtonAllocMemory newtonAlloc, NewtonFreeMemory newtonFree) |
Set the newton world allocators,. | |
Protected Types | |
typedef std::vector< OgreNewt::Body * > | BodyVector |
typedef std::vector< BodyVector > | BodyVectorVector |
Protected Attributes | |
int | m_maxTicksPerFrames |
Ogre::Real | m_timestep |
Ogre::Real | m_invTimestep |
Ogre::Real | m_timeAcumulator |
Ogre::Real | m_updateFPS |
Ogre::Vector3 | m_defaultAngularDamping |
Ogre::Real | m_defaultLinearDamping |
NewtonWorld * | m_world |
MaterialID * | m_defaultMatID |
BodyInAABBIterator | m_bodyInAABBIterator |
WorldTriggerManager * | m_triggerManager |
Debugger * | m_debugger |
represents a physics world.
this class represents a NewtonWorld, which is the basic space in which physics elements can exist. It can have various Rigid Bodies, connected by joints, and other constraints.
Definition at line 141 of file OgreNewt_World.h.
|
protected |
Definition at line 408 of file OgreNewt_World.h.
|
protected |
Definition at line 409 of file OgreNewt_World.h.
typedef std::function<void(OgreNewt::Body*, int threadIndex)> OgreNewt::World::LeaveWorldCallback |
leave world callback.
this function is called when a body leaves the OgreNewt::World. you can use this to destroy bodies that have left the scene, or re-position them, reflect them, do whatever you want.
callback binding to member classes is exactly the same as the various callbacks for the Body class.
Definition at line 193 of file OgreNewt_World.h.
friction solver mode.
like the physics solver mode, these options allow you to reduce the accuracy of the friction model in exchange for speed.
Enumerator | |
---|---|
FM_EXACT | exact friction model (default). |
FM_ADAPTIVE | adaptive friction mode. (faster but less accurate) |
Definition at line 163 of file OgreNewt_World.h.
platform mode
This function allows the application to configure the Newton to take advantage for specific hardware architecture in the same platform.
PF_DETERMINISTIC_UNOPTIMIZED = 0 - force the hardware lower common denominator for the running platform. PF_OPTIMIZED = 1 - will try to use common floating point enhancement like spacial instruction set on the specific architecture. This mode made lead to result that differ from mode 1 and 2 as the accumulation round off errors maybe different. PF_BEST_POSSIBLE = 2 - the engine will try to use the best possible hardware setting found in the current platform this is the default configuration. This mode made lead to result that differ from mode 1 and 2 as the accumulation round off errors maybe different.
The only hardware mode guarantee to work is mode 0. all other are only hints to the engine, for example setting mode 1 will take not effect on CPUs without specially floating point instructions set.
Enumerator | |
---|---|
PF_DETERMINISTIC_UNOPTIMIZED | |
PF_COMMON_OPTIMIZED | |
PF_BEST_POSSIBLE |
Definition at line 179 of file OgreNewt_World.h.
physics solver mode.
you can adjust the accuracy of the solver (and therefore the speed of the solver) using these, or a simple int >= 2. a value >= 2 represents the number of passes you want the engine to take when attempting to reconcile joints.
Definition at line 150 of file OgreNewt_World.h.
OgreNewt::World::World | ( | Ogre::Real | desiredFps = 100.0f , |
int | maxUpdatesPerFrames = 5 , |
||
Ogre::String | name = "main" |
||
) |
Constructor, creates the world and gives it a name.
The name can later be used to get world reference using OgreNewt::World::get(name)
Definition at line 34 of file OgreNewt_World.cpp.
OgreNewt::World::~World | ( | ) |
Standard Destructor, destroys the world.
Definition at line 61 of file OgreNewt_World.cpp.
CustomTriggerController * OgreNewt::World::CreateController | ( | const dMatrix & | matrix, |
NewtonCollision *const | convexShape | ||
) |
Definition at line 82 of file OgreNewt_World.cpp.
|
inline |
notify an entrance to a critical section of code.
Definition at line 356 of file OgreNewt_World.h.
|
inline |
notify the exit of a critical section of code.
Definition at line 359 of file OgreNewt_World.h.
|
inline |
remove all bodies from the world.
destroys all Rigid Bodies and Joints in the world. the bodies are properly deleted, so don't try and access any pointers you have lying around!
Definition at line 297 of file OgreNewt_World.h.
void OgreNewt::World::DestroyController | ( | CustomTriggerController *const | controller | ) |
Definition at line 90 of file OgreNewt_World.cpp.
|
inline |
get the number of bodies in the simulation.
returns the number of bodies in the simulation.
Definition at line 338 of file OgreNewt_World.h.
|
inline |
get a bodyInAABBIterator for this world
Definition at line 379 of file OgreNewt_World.h.
|
inline |
get the number of constaints in the simulation
Definition at line 341 of file OgreNewt_World.h.
|
inline |
get the debugger for this world
the debugger needs to be initialized (Debugger::init(...) ) in order to work correctly
Definition at line 385 of file OgreNewt_World.h.
|
inline |
return default angular damping
Definition at line 277 of file OgreNewt_World.h.
|
inline |
return default linear damping
Definition at line 261 of file OgreNewt_World.h.
|
inline |
get the default materialID object.
when you create a world, a default material is created, which is by default applied to all new rigid bodies. you might need this pointer when assigning material callbacks, etc.
Definition at line 291 of file OgreNewt_World.h.
Body * OgreNewt::World::getFirstBody | ( | ) | const |
to iterate through all bodies call this function and then use body->getNext()
Definition at line 191 of file OgreNewt_World.cpp.
|
inline |
get multithread settings
Definition at line 347 of file OgreNewt_World.h.
|
inline |
retrieves a pointer to the NewtonWorld
in most cases you shouldn't need this... but in case you want to implement something not yet in the library, you can use this to get a pointer to the NewtonWorld object.
Definition at line 284 of file OgreNewt_World.h.
|
inline |
get the architecture used for physics calculations.
description | returns a description-string for the currently used mode |
Definition at line 332 of file OgreNewt_World.h.
|
inline |
get the number of threads the simulation is using.
Definition at line 353 of file OgreNewt_World.h.
|
inline |
returns desired update frames per second
Definition at line 245 of file OgreNewt_World.h.
|
inline |
get the Newton SDK version.
Definition at line 368 of file OgreNewt_World.h.
|
inline |
invalidate internal cache
this function completely resets the cache that Newton uses to improve simulation performance. This is useful for situations where you have reset the simulation to a previous point in time, or reset all bodies, and do not want the state of the world from the previous frame affecting the next frame.
Definition at line 232 of file OgreNewt_World.h.
|
static |
Set the newton world allocators,.
Is is no necessary to call this function allocations default to malloc and free but if an application
then it must call this once before the creation of any Newton world
Definition at line 124 of file OgreNewt_World.cpp.
|
inline |
sets default angular damping
default damping is used when creating new bodies and changing this applies only to bodies created after calling this method. default damping is also timestep-dependant, the value you set here is for 60fps and scales down if using larger physics update rate.
defaultLinearDamping | Ogre::Real default linear damping to use |
Definition at line 271 of file OgreNewt_World.h.
|
inline |
sets default linear damping
default damping is used when creating new bodies and changing this applies only to bodies created after calling this method. default damping is also timestep-dependant, the value you set here is for 60fps and scales down if using larger physics update rate.
defaultLinearDamping | Ogre::Real default linear damping to use |
Definition at line 255 of file OgreNewt_World.h.
|
inline |
set the physics friction model
setting the friction model allows sacrificing accuracy and realism for speed, good for games, etc. for a more detailed description of how to use this function, see the Newton documentation.
model | int representing friction model. you can also pass the enum values I've included. |
Definition at line 313 of file OgreNewt_World.h.
|
inline |
set minimum framerate
Definition at line 364 of file OgreNewt_World.h.
|
inline |
multithread settings
Definition at line 344 of file OgreNewt_World.h.
|
inline |
specify a specific architecture to use for physics calculations.
Setting to a specific architecture can allow for deterministic physics calculations on systems with different cpus, which is particularly useful for multiplayer systems where deterministic physics are absolutely vital.
Definition at line 320 of file OgreNewt_World.h.
void OgreNewt::World::setpostListener | ( | std::string | name, |
void *const | listenerUserData, | ||
NewtonWorldUpdateListenerCallback | update | ||
) |
Definition at line 100 of file OgreNewt_World.cpp.
void OgreNewt::World::setPreListener | ( | std::string | name, |
void *const | listenerUserData, | ||
NewtonWorldUpdateListenerCallback | update | ||
) |
Definition at line 95 of file OgreNewt_World.cpp.
void OgreNewt::World::setSolverModel | ( | int | model | ) |
set the physics solver model
setting the solver model allows sacrificing accuracy and realism for speed, good for games, etc. for a more detailed description of how to use this function, see the Newton documentation.
model | int representing the physics model. you can also pass the enum values I've included. |
Definition at line 200 of file OgreNewt_World.cpp.
void OgreNewt::World::setThreadCount | ( | int | threads | ) |
set the number of threads for the physics simulation to use, don't do this while world update
Definition at line 129 of file OgreNewt_World.cpp.
void OgreNewt::World::setUpdateFPS | ( | Ogre::Real | desiredFps, |
int | maxUpdatesPerFrames | ||
) |
set simulation frames per and max updated per updates
this function set the update rate of the simulation plus the maximum number of update per frame the simulation can execute in order to catch up.
Definition at line 105 of file OgreNewt_World.cpp.
int OgreNewt::World::update | ( | Ogre::Real | t_step | ) |
update the world by the specified time_step.
this function is clamped between values representing fps [60,600]. if you pass a smaller value, it is internally clamped to 60fps. likewise a value higher than 600fps is treated as 600fs.
t_step | Real value representing the time elapsed in seconds. |
Definition at line 135 of file OgreNewt_World.cpp.
|
inline |
Definition at line 361 of file OgreNewt_World.h.
|
protected |
Definition at line 406 of file OgreNewt_World.h.
|
mutableprotected |
Definition at line 412 of file OgreNewt_World.h.
|
protected |
Definition at line 400 of file OgreNewt_World.h.
|
protected |
Definition at line 401 of file OgreNewt_World.h.
|
protected |
Definition at line 404 of file OgreNewt_World.h.
|
protected |
Definition at line 396 of file OgreNewt_World.h.
|
protected |
Definition at line 394 of file OgreNewt_World.h.
|
protected |
Definition at line 397 of file OgreNewt_World.h.
|
protected |
Definition at line 395 of file OgreNewt_World.h.
|
protected |
Definition at line 411 of file OgreNewt_World.h.
|
protected |
Definition at line 398 of file OgreNewt_World.h.
|
protected |
Definition at line 403 of file OgreNewt_World.h.