Kaynağa Gözat

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

enn0x 15 yıl önce
ebeveyn
işleme
082e0781ac

+ 34 - 0
panda/src/physx/physxContactPair.cxx

@@ -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

+ 2 - 0
panda/src/physx/physxContactPair.h

@@ -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;