Added 'is_deleted_a/b' methods to PhysxContactPair, to check if actors are already deleted and thus invalid

This commit is contained in:
enn0x 2010-06-28 21:24:03 +00:00
parent aec3ff0e3d
commit 082e0781ac
2 changed files with 36 additions and 0 deletions

View File

@ -28,6 +28,11 @@ TypeHandle PhysxContactPair::_type_handle;
PhysxActor *PhysxContactPair::
get_actor_a() const {
if (_pair.isDeletedActor[0]) {
physx_cat.warning() << "actor A has been deleted" << endl;
return NULL;
}
NxActor *actorPtr = _pair.actors[0];
return (actorPtr == NULL) ? NULL : (PhysxActor *)actorPtr->userData;
}
@ -41,10 +46,39 @@ get_actor_a() const {
PhysxActor *PhysxContactPair::
get_actor_b() const {
if (_pair.isDeletedActor[1]) {
physx_cat.warning() << "actor B has been deleted" << endl;
return NULL;
}
NxActor *actorPtr = _pair.actors[1];
return (actorPtr == NULL) ? NULL : (PhysxActor *)actorPtr->userData;
}
////////////////////////////////////////////////////////////////////
// Function: PhysxContactPair::is_deleted_a
// Access: Published
// Description: Returns true if the first of the two actors is
// deleted.
////////////////////////////////////////////////////////////////////
bool PhysxContactPair::
is_deleted_a() const {
return _pair.isDeletedActor[0];
}
////////////////////////////////////////////////////////////////////
// Function: PhysxContactPair::is_deleted_b
// Access: Published
// Description: Returns true if the second of the two actors is
// deleted.
////////////////////////////////////////////////////////////////////
bool PhysxContactPair::
is_deleted_b() const {
return _pair.isDeletedActor[1];
}
////////////////////////////////////////////////////////////////////
// Function: PhysxContactPair::get_sum_normal_force
// Access: Published

View File

@ -36,6 +36,8 @@ class EXPCL_PANDAPHYSX PhysxContactPair : public TypedReferenceCount {
PUBLISHED:
INLINE ~PhysxContactPair();
bool is_deleted_a() const;
bool is_deleted_b() const;
PhysxActor *get_actor_a() const;
PhysxActor *get_actor_b() const;
LVector3f get_sum_normal_force() const;