C3DPhyOwner Class Reference

Class that owns 3D-Phy objects (but not its 3D and physical parts) and adds their parts to the appropriate 3D or physical scene. More...

#include <3DPhy.h>

Inheritance diagram for C3DPhyOwner:

Inheritance graph
[legend]

List of all members.

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::SpacegetParentSpace ()
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::SpacepParentSpace
T3DPhySet v3DPhys
T3DPhyToDeleteSet v3DPhyToDelete
T3DPhyToAdd v3DPhyToAdd
TNodesToDelete vNodesToDelete
TGeomsToDelete vGeomsToDelete
TJointsToDelete vJointsToDelete
TBodiesToDelete vBodiesToDelete


Detailed Description

Class that owns 3D-Phy objects (but not its 3D and physical parts) and adds their parts to the appropriate 3D or physical scene.

It stores (not own) a parent group and a parent space, and can add to, or remove from them any C3DPhy given.

Author:
Sukender
Version:
0.2.0
Todo:
Must be thread safe (But if addInScene / markAsRemoved / detatch are only be called by physics thread, it is not useful for these)

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.


Member Typedef Documentation

typedef std::set<C3DPhy *> C3DPhyOwner::T3DPhySet [protected]

Definition at line 568 of file 3DPhy.h.

typedef std::vector<osg::ref_ptr<C3DPhy> > C3DPhyOwner::T3DPhyToAdd [protected]

Definition at line 572 of file 3DPhy.h.

typedef std::set<osg::ref_ptr<C3DPhy> > C3DPhyOwner::T3DPhyToDeleteSet [protected]

Definition at line 570 of file 3DPhy.h.

typedef std::vector<Physics::Body *> C3DPhyOwner::TBodiesToDelete [protected]

Definition at line 581 of file 3DPhy.h.

typedef std::vector<Physics::AbstractGeom *> C3DPhyOwner::TGeomsToDelete [protected]

Definition at line 577 of file 3DPhy.h.

typedef std::vector<Physics::Joint *> C3DPhyOwner::TJointsToDelete [protected]

Definition at line 579 of file 3DPhy.h.

typedef std::vector<osg::MatrixTransform *> C3DPhyOwner::TNodesToDelete [protected]

Definition at line 575 of file 3DPhy.h.


Constructor & Destructor Documentation

C3DPhyOwner::C3DPhyOwner ( osg::Group *  pParentGroup,
Physics::Space pParentSpace 
) [inline]

Definition at line 478 of file 3DPhy.h.

virtual C3DPhyOwner::~C3DPhyOwner (  )  [inline, protected, virtual]

Protected destructor forces the object to be deleted by being dereferenced.

Also avoids the object from beeing created on the stack.

Definition at line 591 of file 3DPhy.h.


Member Function Documentation

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.

Warning:
Adding a 3DPhy during a locked operation (ex: processing deletion of pendind object) is impossible and will result in an assertion failure (in debug).
See also:
addInSceneDelayed() if you want to add something during a locked operation.

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().

See also:
Use preferably addInScene(), which is the standard way to add a 3DPhy, and which is faster.

Definition at line 490 of file 3DPhy.h.

void C3DPhyOwner::cancelDelayed3DPhys (  )  [inline]

Deletes all pending 3DPhys which are supposed to be added on next call to doDelayed3DPhy().

See also:
addInSceneDelayed(), doDelayed3DPhy().

Definition at line 493 of file 3DPhy.h.

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]

Definition at line 553 of file 3DPhy.h.

osg::Group* C3DPhyOwner::getParentGroup (  )  [inline]

Definition at line 522 of file 3DPhy.h.

Referenced by C3DPhy::createPhysicsDebugView().

Physics::Space* C3DPhyOwner::getParentSpace (  )  [inline]

Definition at line 523 of file 3DPhy.h.

Referenced by doDeletePhy().

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.

Definition at line 557 of file 3DPhy.h.

void C3DPhyOwner::markAsRemoved ( C3DPhy p3DPhy,
Physics::Body pAdditionalBody 
)

Enqueues a 3DPhy part to be deleted.

See also:
markAsRemoved(C3DPhy*)

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.

See also:
markAsRemoved(C3DPhy*)

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.

See also:
markAsRemoved(C3DPhy*)

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.

See also:
markAsRemoved(C3DPhy*)

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().


Member Data Documentation

bool C3DPhyOwner::bIsDeleting [protected]

Definition at line 563 of file 3DPhy.h.

Referenced by doDelayed3DPhy(), doDeleteGfx(), doDeletePhy(), and doNetworkClientRemove3DPhy().

osg::Group* C3DPhyOwner::pParentGroup [protected]

Definition at line 565 of file 3DPhy.h.

Referenced by addInScene(), and doDeleteGfx().

Definition at line 566 of file 3DPhy.h.

Referenced by addInScene(), and doDeletePhy().

Definition at line 569 of file 3DPhy.h.

Referenced by addInScene(), createPhysicsDebugView(), detatch(), and detatch_nodelete().

Definition at line 573 of file 3DPhy.h.

Referenced by doDelayed3DPhy().

Definition at line 571 of file 3DPhy.h.

Referenced by doDelayed3DPhy(), and markAsRemoved().

Definition at line 582 of file 3DPhy.h.

Referenced by doDelayed3DPhy(), doDeletePhy(), doNetworkClientRemove3DPhy(), and markAsRemoved().

Definition at line 578 of file 3DPhy.h.

Referenced by doDelayed3DPhy(), doDeletePhy(), doNetworkClientRemove3DPhy(), and markAsRemoved().

Definition at line 580 of file 3DPhy.h.

Referenced by doDelayed3DPhy(), doDeletePhy(), doNetworkClientRemove3DPhy(), and markAsRemoved().

Definition at line 576 of file 3DPhy.h.

Referenced by doDelayed3DPhy(), doDeleteGfx(), and doNetworkClientRemove3DPhy().


The documentation for this class was generated from the following files:

Generated on Sun Jan 17 11:39:26 2010 for PVLE (Pro-Vocation Light Engine) by  doxygen 1.5.9