#include <3DPhy.h>
Public Member Functions | |
C3DPhyOwner (osg::Group *pParentGroup, Physics::Space *pParentSpace) | |
void | addInScene (C3DPhy *p3DPhy) |
Adds immediatly a 3DPhy object into the owner (O(log(n))) and adds its 3D and physical parts to the appropriate 3D or physical scene. | |
void | addInSceneDelayed (C3DPhy *p3DPhy) |
Adds a 3DPhy object even during a locked operation by enqueing it; it will be added to the scene when calling doDelayed3DPhy(). | |
void | cancelDelayed3DPhys () |
Deletes all pending 3DPhys which are supposed to be added on next call to doDelayed3DPhy(). | |
void | markAsRemoved (C3DPhy *p3DPhy) |
Enqueues a 3DPhy (O(log(n))) so that it will be deleted (typically by the end of the physics frame). | |
void | markAsRemoved (C3DPhy *p3DPhy, Physics::Geom *pGeom) |
Enqueues a 3DPhy part to be deleted. | |
void | markAsRemoved (C3DPhy *p3DPhy, Physics::Space *pSpace) |
void | markAsRemoved (C3DPhy *p3DPhy, Physics::Joint *pJoint) |
void | markAsRemoved (C3DPhy *p3DPhy, Physics::Body *pAdditionalBody) |
bool | exists (C3DPhy *p3DPhy) |
Tests if a given 3D-Phy exists (O(log(n))) in this owner. If a 3D-Phy has been queued for deletion, id does not exist anymore in this owner, even if still allocated. | |
osg::Group * | getParentGroup () |
Physics::Space * | getParentSpace () |
void | detatch (C3DPhy *p3DPhy) |
Immediatly removes a 3D-Phy from the owner, but do not enques its 3D and physical parts to be deleted. You'll then must be careful about how to call this method : be sure you have this C3DPhy* reference counted or it could be deleted (as the owner dereference it when detatching or deleting) ! | |
void | doDelayed3DPhy () |
Effectively deletes (O(n)) all enqueued 3DPhys, but not their physical or 3D part (they are to be deleted on call of doDeletePhy() and doDeleteGfx()). | |
void | doDeletePhy () |
Effectively deletes (O(n)) all enqueued 3DPhys' geoms and joints. | |
void | doDeleteGfx () |
Effectively deletes (O(n)) all enqueued 3DPhys' models. | |
void | doNetworkClientRemove3DPhy (C3DPhy *p3DPhy) |
Immediatly removes a 3DPhy in response of a deletion from the networking system on the client. | |
virtual void | step (dReal stepSize) |
Steps all the 3D-Phy objects contained (O(n)). | |
void | createPhysicsDebugView (bool enable) |
Calls createPhysicsDebugView() on all 3D-Phy contained (but not on 3D-Phy added after the call). | |
void | clearBodyContactPos () |
"Close contact check" cleanup (removes all contact positions in each body). | |
const std::set< C3DPhy * > & | get3DPhys () const |
bool | isDeleting () |
Returns true during a call to doDelayed3DPhy(), doDeletePhy(), doDeleteGfx() or doNetworkClientRemove3DPhy(). | |
Protected Types | |
typedef std::set< C3DPhy * > | T3DPhySet |
typedef std::set< osg::ref_ptr < C3DPhy > > | T3DPhyToDeleteSet |
typedef std::vector < osg::ref_ptr< C3DPhy > > | T3DPhyToAdd |
typedef std::vector < osg::MatrixTransform * > | TNodesToDelete |
typedef std::vector < Physics::AbstractGeom * > | TGeomsToDelete |
typedef std::vector < Physics::Joint * > | TJointsToDelete |
typedef std::vector < Physics::Body * > | TBodiesToDelete |
Protected Member Functions | |
void | detatch_nodelete (C3DPhy *p3DPhy) |
Same as detach(), but does not delete the 3DPhy (calls osg::Referenced::unref_nodelete()). | |
void | addInSceneBase (C3DPhy *p3DPhy) |
virtual | ~C3DPhyOwner () |
Protected destructor forces the object to be deleted by being dereferenced. | |
Protected Attributes | |
bool | bIsDeleting |
osg::Group * | pParentGroup |
Physics::Space * | pParentSpace |
T3DPhySet | v3DPhys |
T3DPhyToDeleteSet | v3DPhyToDelete |
T3DPhyToAdd | v3DPhyToAdd |
TNodesToDelete | vNodesToDelete |
TGeomsToDelete | vGeomsToDelete |
TJointsToDelete | vJointsToDelete |
TBodiesToDelete | vBodiesToDelete |
It stores (not own) a parent group and a parent space, and can add to, or remove from them any C3DPhy given.
See if observer_ptr<> could be useful for the implementation of that class (ex: deallocate 3DPhy's if their parts have been deallocated ? Or if parent space/node have been deallocated ?).
Definition at line 476 of file 3DPhy.h.
typedef std::set<C3DPhy *> C3DPhyOwner::T3DPhySet [protected] |
typedef std::vector<osg::ref_ptr<C3DPhy> > C3DPhyOwner::T3DPhyToAdd [protected] |
typedef std::set<osg::ref_ptr<C3DPhy> > C3DPhyOwner::T3DPhyToDeleteSet [protected] |
typedef std::vector<Physics::Body *> C3DPhyOwner::TBodiesToDelete [protected] |
typedef std::vector<Physics::AbstractGeom *> C3DPhyOwner::TGeomsToDelete [protected] |
typedef std::vector<Physics::Joint *> C3DPhyOwner::TJointsToDelete [protected] |
typedef std::vector<osg::MatrixTransform *> C3DPhyOwner::TNodesToDelete [protected] |
C3DPhyOwner::C3DPhyOwner | ( | osg::Group * | pParentGroup, | |
Physics::Space * | pParentSpace | |||
) | [inline] |
virtual C3DPhyOwner::~C3DPhyOwner | ( | ) | [inline, protected, virtual] |
void C3DPhyOwner::addInScene | ( | C3DPhy * | p3DPhy | ) |
Adds immediatly a 3DPhy object into the owner (O(log(n))) and adds its 3D and physical parts to the appropriate 3D or physical scene.
Definition at line 833 of file 3DPhy.cpp.
References Physics::Space::add(), ASSERT, C3DPHY_LOCK_CHECK, C3DPhy::get3DPhyOwner(), pParentGroup, pParentSpace, C3DPhy::set3DPhyOwner(), THROW_TRACED_EXCEPTION, and v3DPhys.
Referenced by C3DPhy::C3DPhy(), doDelayed3DPhy(), and Ammo::hitBefore().
void C3DPhyOwner::addInSceneBase | ( | C3DPhy * | p3DPhy | ) | [protected] |
void C3DPhyOwner::addInSceneDelayed | ( | C3DPhy * | p3DPhy | ) | [inline] |
Adds a 3DPhy object even during a locked operation by enqueing it; it will be added to the scene when calling doDelayed3DPhy().
void C3DPhyOwner::cancelDelayed3DPhys | ( | ) | [inline] |
Deletes all pending 3DPhys which are supposed to be added on next call to doDelayed3DPhy().
void C3DPhyOwner::clearBodyContactPos | ( | ) | [inline] |
"Close contact check" cleanup (removes all contact positions in each body).
Definition at line 551 of file 3DPhy.h.
References C3DPhy::clearBodyContactPos().
void C3DPhyOwner::createPhysicsDebugView | ( | bool | enable | ) |
Calls createPhysicsDebugView() on all 3D-Phy contained (but not on 3D-Phy added after the call).
Definition at line 1055 of file 3DPhy.cpp.
References C3DPhy::createPhysicsDebugView(), and v3DPhys.
void C3DPhyOwner::detatch | ( | C3DPhy * | p3DPhy | ) |
Immediatly removes a 3D-Phy from the owner, but do not enques its 3D and physical parts to be deleted. You'll then must be careful about how to call this method : be sure you have this C3DPhy* reference counted or it could be deleted (as the owner dereference it when detatching or deleting) !
Definition at line 903 of file 3DPhy.cpp.
References ASSERT, C3DPhy::set3DPhyOwner(), and v3DPhys.
Referenced by doDelayed3DPhy().
void C3DPhyOwner::detatch_nodelete | ( | C3DPhy * | p3DPhy | ) | [protected] |
Same as detach(), but does not delete the 3DPhy (calls osg::Referenced::unref_nodelete()).
Definition at line 913 of file 3DPhy.cpp.
References ASSERT, C3DPhy::set3DPhyOwner(), and v3DPhys.
Referenced by doNetworkClientRemove3DPhy().
void C3DPhyOwner::doDelayed3DPhy | ( | ) |
Effectively deletes (O(n)) all enqueued 3DPhys, but not their physical or 3D part (they are to be deleted on call of doDeletePhy() and doDeleteGfx()).
Also adds 3DPhys enqueued by addInSceneDelayed(). The class supposes that 3D and physics parts can be deleted safely during this mehtod.
Definition at line 924 of file 3DPhy.cpp.
References addInScene(), ASSERT, bIsDeleting, C3DPHY_LOCK, C3DPHY_LOCK_CHECK, C3DPHY_UNLOCK, detatch(), C3DPhy::getModel(), C3DPhy::pModel_debug, v3DPhyToAdd, v3DPhyToDelete, C3DPhy::vAdditionalBodies, vBodiesToDelete, C3DPhy::vGeoms, vGeomsToDelete, C3DPhy::vJoints, vJointsToDelete, vNodesToDelete, and C3DPhy::vSpaces.
void C3DPhyOwner::doDeleteGfx | ( | ) |
Effectively deletes (O(n)) all enqueued 3DPhys' models.
The class supposes that 3D and physics parts can be deleted safely during this mehtod.
Definition at line 977 of file 3DPhy.cpp.
References ASSERT, bIsDeleting, C3DPHY_LOCK, C3DPHY_UNLOCK, pParentGroup, and vNodesToDelete.
void C3DPhyOwner::doDeletePhy | ( | ) |
Effectively deletes (O(n)) all enqueued 3DPhys' geoms and joints.
The class supposes that 3D and physics parts can be deleted safely during this mehtod.
Definition at line 997 of file 3DPhy.cpp.
References ASSERT, bIsDeleting, C3DPHY_LOCK, C3DPHY_UNLOCK, getParentSpace(), pParentSpace, Physics::Space::remove(), vBodiesToDelete, vGeomsToDelete, and vJointsToDelete.
void C3DPhyOwner::doNetworkClientRemove3DPhy | ( | C3DPhy * | p3DPhy | ) |
Immediatly removes a 3DPhy in response of a deletion from the networking system on the client.
This method is similar to what is done in doDelayed3DPhy(), in the way it enqueues 3DPhy's part to be deleted. However, it decreases the 3DPhy's reference count, but does not delete it, even if the reference count falls to 0.
Definition at line 1036 of file 3DPhy.cpp.
References bIsDeleting, C3DPHY_LOCK_CHECK, detatch_nodelete(), C3DPhy::getModel(), C3DPhy::pModel_debug, C3DPhy::vAdditionalBodies, vBodiesToDelete, C3DPhy::vGeoms, vGeomsToDelete, C3DPhy::vJoints, vJointsToDelete, vNodesToDelete, and C3DPhy::vSpaces.
bool C3DPhyOwner::exists | ( | C3DPhy * | p3DPhy | ) | [inline] |
Tests if a given 3D-Phy exists (O(log(n))) in this owner. If a 3D-Phy has been queued for deletion, id does not exist anymore in this owner, even if still allocated.
Definition at line 510 of file 3DPhy.h.
References ASSERT, and C3DPhy::p3DPhyOwner.
const std::set<C3DPhy *>& C3DPhyOwner::get3DPhys | ( | ) | const [inline] |
osg::Group* C3DPhyOwner::getParentGroup | ( | ) | [inline] |
Physics::Space* C3DPhyOwner::getParentSpace | ( | ) | [inline] |
bool C3DPhyOwner::isDeleting | ( | ) | [inline] |
Returns true during a call to doDelayed3DPhy(), doDeletePhy(), doDeleteGfx() or doNetworkClientRemove3DPhy().
The class supposes that 3D and physics parts can be deleted safely during these mehtods.
void C3DPhyOwner::markAsRemoved | ( | C3DPhy * | p3DPhy, | |
Physics::Body * | pAdditionalBody | |||
) |
Enqueues a 3DPhy part to be deleted.
Definition at line 892 of file 3DPhy.cpp.
References ASSERT, C3DPHY_LOCK_CHECK, C3DPhy::vAdditionalBodies, and vBodiesToDelete.
void C3DPhyOwner::markAsRemoved | ( | C3DPhy * | p3DPhy, | |
Physics::Joint * | pJoint | |||
) |
Enqueues a 3DPhy part to be deleted.
Definition at line 881 of file 3DPhy.cpp.
References ASSERT, C3DPHY_LOCK_CHECK, C3DPhy::vJoints, and vJointsToDelete.
void C3DPhyOwner::markAsRemoved | ( | C3DPhy * | p3DPhy, | |
Physics::Space * | pSpace | |||
) |
Enqueues a 3DPhy part to be deleted.
Definition at line 870 of file 3DPhy.cpp.
References ASSERT, C3DPHY_LOCK_CHECK, vGeomsToDelete, and C3DPhy::vSpaces.
void C3DPhyOwner::markAsRemoved | ( | C3DPhy * | p3DPhy, | |
Physics::Geom * | pGeom | |||
) |
Enqueues a 3DPhy part to be deleted.
Definition at line 859 of file 3DPhy.cpp.
References ASSERT, C3DPHY_LOCK_CHECK, C3DPhy::vGeoms, and vGeomsToDelete.
void C3DPhyOwner::markAsRemoved | ( | C3DPhy * | p3DPhy | ) |
Enqueues a 3DPhy (O(log(n))) so that it will be deleted (typically by the end of the physics frame).
Its physical and 3D parts will also be queued for deletion when the 3DPhy will be effectively destroyed. Be careful to delete ONLY 3DPhys that are in the given parent space and parent group. If a 3DPhy is already enqueued, it won't be twice. Please not that once enqueued, you must not change the 3DPhy's geoms, joints, bodies, spaces or model (the C3DPhyOwner keeps a copy of these pointers to remove them from the parent space and parent group).
Definition at line 851 of file 3DPhy.cpp.
References ASSERT, C3DPHY_LOCK_CHECK, and v3DPhyToDelete.
Referenced by C3DPhy::markAsRemoved(), and C3DPhy::onTTLZero().
virtual void C3DPhyOwner::step | ( | dReal | stepSize | ) | [inline, virtual] |
Steps all the 3D-Phy objects contained (O(n)).
Definition at line 545 of file 3DPhy.h.
References C3DPhy::step().
bool C3DPhyOwner::bIsDeleting [protected] |
Definition at line 563 of file 3DPhy.h.
Referenced by doDelayed3DPhy(), doDeleteGfx(), doDeletePhy(), and doNetworkClientRemove3DPhy().
osg::Group* C3DPhyOwner::pParentGroup [protected] |
Physics::Space* C3DPhyOwner::pParentSpace [protected] |
T3DPhySet C3DPhyOwner::v3DPhys [protected] |
Definition at line 569 of file 3DPhy.h.
Referenced by addInScene(), createPhysicsDebugView(), detatch(), and detatch_nodelete().
T3DPhyToAdd C3DPhyOwner::v3DPhyToAdd [protected] |
T3DPhyToDeleteSet C3DPhyOwner::v3DPhyToDelete [protected] |
TBodiesToDelete C3DPhyOwner::vBodiesToDelete [protected] |
Definition at line 582 of file 3DPhy.h.
Referenced by doDelayed3DPhy(), doDeletePhy(), doNetworkClientRemove3DPhy(), and markAsRemoved().
TGeomsToDelete C3DPhyOwner::vGeomsToDelete [protected] |
Definition at line 578 of file 3DPhy.h.
Referenced by doDelayed3DPhy(), doDeletePhy(), doNetworkClientRemove3DPhy(), and markAsRemoved().
TJointsToDelete C3DPhyOwner::vJointsToDelete [protected] |
Definition at line 580 of file 3DPhy.h.
Referenced by doDelayed3DPhy(), doDeletePhy(), doNetworkClientRemove3DPhy(), and markAsRemoved().
TNodesToDelete C3DPhyOwner::vNodesToDelete [protected] |
Definition at line 576 of file 3DPhy.h.
Referenced by doDelayed3DPhy(), doDeleteGfx(), and doNetworkClientRemove3DPhy().