From 76c3f1268b48439bf9c9ff41f2105959ea8fc25f Mon Sep 17 00:00:00 2001 From: enn0x Date: Mon, 28 Jun 2010 18:22:19 +0000 Subject: [PATCH] Fixed bug with internal debug names getting lost. --- panda/src/physx/physxActor.I | 6 +++++- panda/src/physx/physxActor.cxx | 8 ++++--- panda/src/physx/physxActor.h | 1 + panda/src/physx/physxActorDesc.I | 4 +++- panda/src/physx/physxActorDesc.cxx | 4 +++- panda/src/physx/physxActorDesc.h | 1 + panda/src/physx/physxBoxForceFieldShape.I | 1 + panda/src/physx/physxBoxShape.I | 1 + panda/src/physx/physxBoxShapeDesc.I | 3 ++- panda/src/physx/physxCapsuleForceFieldShape.I | 1 + panda/src/physx/physxCapsuleShape.I | 1 + panda/src/physx/physxCapsuleShapeDesc.I | 3 ++- panda/src/physx/physxCloth.I | 11 +++++++++- panda/src/physx/physxCloth.cxx | 5 ++++- panda/src/physx/physxCloth.h | 1 + panda/src/physx/physxClothDesc.I | 4 +++- panda/src/physx/physxClothDesc.cxx | 4 +++- panda/src/physx/physxClothDesc.h | 4 +--- panda/src/physx/physxConvexForceFieldShape.I | 1 + panda/src/physx/physxConvexShape.I | 1 + panda/src/physx/physxConvexShapeDesc.I | 3 ++- panda/src/physx/physxCylindricalJoint.I | 1 + panda/src/physx/physxD6Joint.I | 1 + panda/src/physx/physxDistanceJoint.I | 1 + panda/src/physx/physxFixedJoint.I | 1 + panda/src/physx/physxForceField.I | 2 ++ panda/src/physx/physxForceField.cxx | 6 ++++-- panda/src/physx/physxForceField.h | 1 + panda/src/physx/physxForceFieldDesc.I | 3 ++- panda/src/physx/physxForceFieldDesc.cxx | 4 +++- panda/src/physx/physxForceFieldDesc.h | 2 ++ panda/src/physx/physxForceFieldShape.I | 5 ++++- panda/src/physx/physxForceFieldShape.cxx | 5 ++++- panda/src/physx/physxForceFieldShape.h | 2 ++ panda/src/physx/physxForceFieldShapeDesc.I | 12 +++++++++++ panda/src/physx/physxForceFieldShapeDesc.cxx | 4 +++- panda/src/physx/physxForceFieldShapeDesc.h | 2 ++ panda/src/physx/physxForceFieldShapeGroup.I | 2 ++ panda/src/physx/physxForceFieldShapeGroup.cxx | 6 +++++- panda/src/physx/physxForceFieldShapeGroup.h | 1 + .../src/physx/physxForceFieldShapeGroupDesc.I | 3 ++- .../physx/physxForceFieldShapeGroupDesc.cxx | 4 +++- .../src/physx/physxForceFieldShapeGroupDesc.h | 1 + panda/src/physx/physxHeightFieldShape.I | 1 + panda/src/physx/physxHeightFieldShapeDesc.cxx | 2 +- panda/src/physx/physxJoint.I | 5 ++++- panda/src/physx/physxJoint.cxx | 5 ++++- panda/src/physx/physxJoint.h | 2 ++ panda/src/physx/physxJointDesc.I | 12 +++++++++++ panda/src/physx/physxJointDesc.cxx | 4 +++- panda/src/physx/physxJointDesc.h | 2 ++ panda/src/physx/physxPlaneShape.I | 1 + panda/src/physx/physxPlaneShapeDesc.I | 3 ++- panda/src/physx/physxPointInPlaneJoint.I | 1 + panda/src/physx/physxPointOnLineJoint.I | 1 + panda/src/physx/physxPrismaticJoint.I | 1 + panda/src/physx/physxPulleyJoint.I | 1 + panda/src/physx/physxScene.cxx | 21 ++++++++++++------- panda/src/physx/physxShape.I | 5 ++++- panda/src/physx/physxShape.cxx | 5 ++++- panda/src/physx/physxShape.h | 2 ++ panda/src/physx/physxShapeDesc.I | 12 +++++++++++ panda/src/physx/physxShapeDesc.cxx | 4 +++- panda/src/physx/physxShapeDesc.h | 2 ++ panda/src/physx/physxSphereForceFieldShape.I | 1 + panda/src/physx/physxSphereShape.I | 1 + panda/src/physx/physxSphereShapeDesc.I | 3 ++- panda/src/physx/physxSphericalJoint.I | 1 + panda/src/physx/physxTriangleMeshShape.I | 1 + panda/src/physx/physxTriangleMeshShapeDesc.I | 3 ++- panda/src/physx/physxWheelShape.I | 1 + panda/src/physx/physxWheelShapeDesc.cxx | 2 +- 72 files changed, 197 insertions(+), 45 deletions(-) diff --git a/panda/src/physx/physxActor.I b/panda/src/physx/physxActor.I index 8595c7bbdb..a4f2477c5a 100644 --- a/panda/src/physx/physxActor.I +++ b/panda/src/physx/physxActor.I @@ -22,6 +22,7 @@ INLINE PhysxActor:: PhysxActor() : PhysxObject() { + _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -32,6 +33,7 @@ PhysxActor() : PhysxObject() { INLINE PhysxActor:: ~PhysxActor() { + free(_name); } //////////////////////////////////////////////////////////////////// @@ -53,8 +55,10 @@ ls() const { INLINE void PhysxActor:: ls(ostream &out, int indent_level) const { + char *name = _name ? _name : ""; + indent(out, indent_level) << get_type().get_name() - << " " << get_name( ) + << " " << name << " (at 0x" << this << ")"; if (!_np.is_empty()) { diff --git a/panda/src/physx/physxActor.cxx b/panda/src/physx/physxActor.cxx index 513321807d..a588895bcb 100644 --- a/panda/src/physx/physxActor.cxx +++ b/panda/src/physx/physxActor.cxx @@ -41,8 +41,6 @@ link(NxActor *actorPtr) { NxU32 nShapes = _ptr->getNbShapes(); for (NxU32 i=0; i < nShapes; i++) { - if (shapes[i]->getName() == NULL) shapes[i]->setName(""); - PhysxShape *shape = PhysxShape::factory(shapes[i]->getType()); shape->link(shapes[i]); } @@ -137,7 +135,10 @@ void PhysxActor:: set_name(const char *name) { nassertv(_error_type == ET_ok); - _ptr->setName(name); + + free(_name); + _name = strdup(name); + _ptr->setName(_name); } //////////////////////////////////////////////////////////////////// @@ -400,6 +401,7 @@ create_shape(PhysxShapeDesc &desc) { nassertr(shapePtr, NULL); shape->link(shapePtr); + shape->set_name(desc.ptr()->name); return shape; } diff --git a/panda/src/physx/physxActor.h b/panda/src/physx/physxActor.h index 870b4b12c8..4d96d7144a 100644 --- a/panda/src/physx/physxActor.h +++ b/panda/src/physx/physxActor.h @@ -197,6 +197,7 @@ private: NxActor *_ptr; NodePath _np; PT(PhysxController) _controller; + char *_name; //////////////////////////////////////////////////////////////////// public: diff --git a/panda/src/physx/physxActorDesc.I b/panda/src/physx/physxActorDesc.I index 9cee85cf7c..0603a14382 100644 --- a/panda/src/physx/physxActorDesc.I +++ b/panda/src/physx/physxActorDesc.I @@ -22,7 +22,8 @@ INLINE PhysxActorDesc:: PhysxActorDesc() { - _desc.name = ""; + _name = NULL; + _desc.name = _name; } //////////////////////////////////////////////////////////////////// @@ -33,6 +34,7 @@ PhysxActorDesc() { INLINE PhysxActorDesc:: ~PhysxActorDesc() { + free(_name); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxActorDesc.cxx b/panda/src/physx/physxActorDesc.cxx index a29f07b3cd..c156e34a2b 100644 --- a/panda/src/physx/physxActorDesc.cxx +++ b/panda/src/physx/physxActorDesc.cxx @@ -36,7 +36,9 @@ add_shape(PhysxShapeDesc &desc) { void PhysxActorDesc:: set_name(const char *name) { - _desc.name = name; + free(_name); + _name = strdup(name); + _desc.name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxActorDesc.h b/panda/src/physx/physxActorDesc.h index d408012ab1..d8d9d97d64 100644 --- a/panda/src/physx/physxActorDesc.h +++ b/panda/src/physx/physxActorDesc.h @@ -54,6 +54,7 @@ PUBLISHED: public: NxActorDesc _desc; + char *_name; }; #include "physxActorDesc.I" diff --git a/panda/src/physx/physxBoxForceFieldShape.I b/panda/src/physx/physxBoxForceFieldShape.I index 2c6bbbafa0..b01d906f22 100644 --- a/panda/src/physx/physxBoxForceFieldShape.I +++ b/panda/src/physx/physxBoxForceFieldShape.I @@ -32,5 +32,6 @@ PhysxBoxForceFieldShape() : PhysxForceFieldShape() { INLINE PhysxBoxForceFieldShape:: ~PhysxBoxForceFieldShape() { + free(_name); } diff --git a/panda/src/physx/physxBoxShape.I b/panda/src/physx/physxBoxShape.I index 730f806b10..f57eecb7ff 100644 --- a/panda/src/physx/physxBoxShape.I +++ b/panda/src/physx/physxBoxShape.I @@ -32,5 +32,6 @@ PhysxBoxShape() : PhysxShape() { INLINE PhysxBoxShape:: ~PhysxBoxShape() { + free(_name); } diff --git a/panda/src/physx/physxBoxShapeDesc.I b/panda/src/physx/physxBoxShapeDesc.I index e2503a02c9..a473ae2c87 100644 --- a/panda/src/physx/physxBoxShapeDesc.I +++ b/panda/src/physx/physxBoxShapeDesc.I @@ -22,7 +22,7 @@ INLINE PhysxBoxShapeDesc:: PhysxBoxShapeDesc() : PhysxShapeDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxBoxShapeDesc:: set_to_default() { _desc.setToDefault(); + _desc.name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxCapsuleForceFieldShape.I b/panda/src/physx/physxCapsuleForceFieldShape.I index f4cc2b9a94..070009a8ab 100644 --- a/panda/src/physx/physxCapsuleForceFieldShape.I +++ b/panda/src/physx/physxCapsuleForceFieldShape.I @@ -32,5 +32,6 @@ PhysxCapsuleForceFieldShape() : PhysxForceFieldShape() { INLINE PhysxCapsuleForceFieldShape:: ~PhysxCapsuleForceFieldShape() { + free(_name); } diff --git a/panda/src/physx/physxCapsuleShape.I b/panda/src/physx/physxCapsuleShape.I index b24267e48a..61a3cd3df4 100644 --- a/panda/src/physx/physxCapsuleShape.I +++ b/panda/src/physx/physxCapsuleShape.I @@ -32,5 +32,6 @@ PhysxCapsuleShape() : PhysxShape() { INLINE PhysxCapsuleShape:: ~PhysxCapsuleShape() { + free(_name); } diff --git a/panda/src/physx/physxCapsuleShapeDesc.I b/panda/src/physx/physxCapsuleShapeDesc.I index e8980b4d18..e7038d9c3c 100644 --- a/panda/src/physx/physxCapsuleShapeDesc.I +++ b/panda/src/physx/physxCapsuleShapeDesc.I @@ -22,7 +22,7 @@ INLINE PhysxCapsuleShapeDesc:: PhysxCapsuleShapeDesc() : PhysxShapeDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxCapsuleShapeDesc:: set_to_default() { _desc.setToDefault(); + _desc.name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxCloth.I b/panda/src/physx/physxCloth.I index bb783f2226..6223948369 100644 --- a/panda/src/physx/physxCloth.I +++ b/panda/src/physx/physxCloth.I @@ -22,6 +22,7 @@ INLINE PhysxCloth:: PhysxCloth() : PhysxObject() { + _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -32,6 +33,7 @@ PhysxCloth() : PhysxObject() { INLINE PhysxCloth:: ~PhysxCloth() { + free(_name); } //////////////////////////////////////////////////////////////////// @@ -53,9 +55,16 @@ ls() const { INLINE void PhysxCloth:: ls(ostream &out, int indent_level) const { + char *name = _name ? _name : ""; + indent(out, indent_level) << get_type().get_name() + << " " << name << " (at 0x" << this << ")"; - //out << " N:0x" << _node; + + //if (_node) { + // " N:0x" << _node; + //} + out << "\n"; } diff --git a/panda/src/physx/physxCloth.cxx b/panda/src/physx/physxCloth.cxx index 37256ff662..67340de4d8 100644 --- a/panda/src/physx/physxCloth.cxx +++ b/panda/src/physx/physxCloth.cxx @@ -145,7 +145,10 @@ void PhysxCloth:: set_name(const char *name) { nassertv(_error_type == ET_ok); - _ptr->setName(name); + + free(_name); + _name = strdup(name); + _ptr->setName(_name); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxCloth.h b/panda/src/physx/physxCloth.h index 444eb80127..0664c5eae0 100644 --- a/panda/src/physx/physxCloth.h +++ b/panda/src/physx/physxCloth.h @@ -108,6 +108,7 @@ public: private: NxCloth *_ptr; PT(PhysxClothNode) _node; + char *_name; //////////////////////////////////////////////////////////////////// public: diff --git a/panda/src/physx/physxClothDesc.I b/panda/src/physx/physxClothDesc.I index 0fc310ff3d..33f75f625a 100644 --- a/panda/src/physx/physxClothDesc.I +++ b/panda/src/physx/physxClothDesc.I @@ -22,7 +22,8 @@ INLINE PhysxClothDesc:: PhysxClothDesc() { - _desc.name = ""; + _name = NULL; + _desc.name = _name; } //////////////////////////////////////////////////////////////////// @@ -33,6 +34,7 @@ PhysxClothDesc() { INLINE PhysxClothDesc:: ~PhysxClothDesc() { + free(_name); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxClothDesc.cxx b/panda/src/physx/physxClothDesc.cxx index d8931beb66..63064c14e6 100644 --- a/panda/src/physx/physxClothDesc.cxx +++ b/panda/src/physx/physxClothDesc.cxx @@ -24,7 +24,9 @@ void PhysxClothDesc:: set_name(const char *name) { - _desc.name = name; + free(_name); + _name = strdup(name); + _desc.name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxClothDesc.h b/panda/src/physx/physxClothDesc.h index 88615f0e89..c4dad0c3a7 100644 --- a/panda/src/physx/physxClothDesc.h +++ b/panda/src/physx/physxClothDesc.h @@ -68,11 +68,9 @@ PUBLISHED: unsigned int get_solver_iterations() const; bool get_flag(PhysxClothFlag flag) const; -public: - //void get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles); - public: NxClothDesc _desc; + char *_name; }; #include "physxClothDesc.I" diff --git a/panda/src/physx/physxConvexForceFieldShape.I b/panda/src/physx/physxConvexForceFieldShape.I index a38be7ee2e..61a854bc70 100644 --- a/panda/src/physx/physxConvexForceFieldShape.I +++ b/panda/src/physx/physxConvexForceFieldShape.I @@ -32,5 +32,6 @@ PhysxConvexForceFieldShape() : PhysxForceFieldShape() { INLINE PhysxConvexForceFieldShape:: ~PhysxConvexForceFieldShape() { + free(_name); } diff --git a/panda/src/physx/physxConvexShape.I b/panda/src/physx/physxConvexShape.I index db1dd53069..caf06ea9ae 100644 --- a/panda/src/physx/physxConvexShape.I +++ b/panda/src/physx/physxConvexShape.I @@ -32,5 +32,6 @@ PhysxConvexShape() : PhysxShape() { INLINE PhysxConvexShape:: ~PhysxConvexShape() { + free(_name); } diff --git a/panda/src/physx/physxConvexShapeDesc.I b/panda/src/physx/physxConvexShapeDesc.I index 735f65d2ea..c4b300ebcc 100644 --- a/panda/src/physx/physxConvexShapeDesc.I +++ b/panda/src/physx/physxConvexShapeDesc.I @@ -22,7 +22,7 @@ INLINE PhysxConvexShapeDesc:: PhysxConvexShapeDesc() : PhysxShapeDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxConvexShapeDesc:: set_to_default() { _desc.setToDefault(); + _desc.name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxCylindricalJoint.I b/panda/src/physx/physxCylindricalJoint.I index 5ec371bbe5..6ad30531fc 100644 --- a/panda/src/physx/physxCylindricalJoint.I +++ b/panda/src/physx/physxCylindricalJoint.I @@ -32,5 +32,6 @@ PhysxCylindricalJoint() : PhysxJoint() { INLINE PhysxCylindricalJoint:: ~PhysxCylindricalJoint() { + free(_name); } diff --git a/panda/src/physx/physxD6Joint.I b/panda/src/physx/physxD6Joint.I index 435bdfcbf3..e00079e69c 100644 --- a/panda/src/physx/physxD6Joint.I +++ b/panda/src/physx/physxD6Joint.I @@ -32,5 +32,6 @@ PhysxD6Joint() : PhysxJoint() { INLINE PhysxD6Joint:: ~PhysxD6Joint() { + free(_name); } diff --git a/panda/src/physx/physxDistanceJoint.I b/panda/src/physx/physxDistanceJoint.I index 05e07a807f..3318172a43 100644 --- a/panda/src/physx/physxDistanceJoint.I +++ b/panda/src/physx/physxDistanceJoint.I @@ -32,5 +32,6 @@ PhysxDistanceJoint() : PhysxJoint() { INLINE PhysxDistanceJoint:: ~PhysxDistanceJoint() { + free(_name); } diff --git a/panda/src/physx/physxFixedJoint.I b/panda/src/physx/physxFixedJoint.I index 489f30e98f..ea13cb3c76 100644 --- a/panda/src/physx/physxFixedJoint.I +++ b/panda/src/physx/physxFixedJoint.I @@ -32,5 +32,6 @@ PhysxFixedJoint() : PhysxJoint() { INLINE PhysxFixedJoint:: ~PhysxFixedJoint() { + free(_name); } diff --git a/panda/src/physx/physxForceField.I b/panda/src/physx/physxForceField.I index 8b480b4dde..3aff844847 100644 --- a/panda/src/physx/physxForceField.I +++ b/panda/src/physx/physxForceField.I @@ -22,6 +22,7 @@ INLINE PhysxForceField:: PhysxForceField() : PhysxObject() { + _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -32,6 +33,7 @@ PhysxForceField() : PhysxObject() { INLINE PhysxForceField:: ~PhysxForceField() { + free(_name); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceField.cxx b/panda/src/physx/physxForceField.cxx index 20c6980c3c..45593ad99c 100644 --- a/panda/src/physx/physxForceField.cxx +++ b/panda/src/physx/physxForceField.cxx @@ -38,7 +38,6 @@ link(NxForceField *materialPtr) { // Link include shape group PhysxForceFieldShapeGroup *group = new PhysxForceFieldShapeGroup(); group->link(&(_ptr->getIncludeShapeGroup())); - _ptr->getIncludeShapeGroup().setName(""); } //////////////////////////////////////////////////////////////////// @@ -85,7 +84,10 @@ void PhysxForceField:: set_name(const char *name) { nassertv(_error_type == ET_ok); - _ptr->setName(name); + + free(_name); + _name = strdup(name); + _ptr->setName(_name); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceField.h b/panda/src/physx/physxForceField.h index 1ca3756d36..04f9c646b5 100644 --- a/panda/src/physx/physxForceField.h +++ b/panda/src/physx/physxForceField.h @@ -68,6 +68,7 @@ public: private: NxForceField *_ptr; + char *_name; //////////////////////////////////////////////////////////////////// public: diff --git a/panda/src/physx/physxForceFieldDesc.I b/panda/src/physx/physxForceFieldDesc.I index 180138f2ad..34749747e2 100644 --- a/panda/src/physx/physxForceFieldDesc.I +++ b/panda/src/physx/physxForceFieldDesc.I @@ -22,7 +22,7 @@ INLINE PhysxForceFieldDesc:: PhysxForceFieldDesc() { - _desc.name = ""; + _desc.name = NULL; } //////////////////////////////////////////////////////////////////// @@ -33,6 +33,7 @@ PhysxForceFieldDesc() { INLINE PhysxForceFieldDesc:: ~PhysxForceFieldDesc() { + free(_name); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldDesc.cxx b/panda/src/physx/physxForceFieldDesc.cxx index 76f9aa10b5..3b608bc101 100644 --- a/panda/src/physx/physxForceFieldDesc.cxx +++ b/panda/src/physx/physxForceFieldDesc.cxx @@ -26,7 +26,9 @@ void PhysxForceFieldDesc:: set_name(const char *name) { - _desc.name = name; + free(_name); + _name = strdup(name); + _desc.name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldDesc.h b/panda/src/physx/physxForceFieldDesc.h index 599e7f5e44..1fcd3519d7 100644 --- a/panda/src/physx/physxForceFieldDesc.h +++ b/panda/src/physx/physxForceFieldDesc.h @@ -65,6 +65,8 @@ public: NxForceFieldDesc _desc; NxForceFieldLinearKernelDesc _kernel; + + char *_name; }; #include "physxForceFieldDesc.I" diff --git a/panda/src/physx/physxForceFieldShape.I b/panda/src/physx/physxForceFieldShape.I index 93d543476e..1272172336 100644 --- a/panda/src/physx/physxForceFieldShape.I +++ b/panda/src/physx/physxForceFieldShape.I @@ -22,6 +22,7 @@ INLINE PhysxForceFieldShape:: PhysxForceFieldShape() : PhysxObject() { + _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -43,8 +44,10 @@ ls() const { INLINE void PhysxForceFieldShape:: ls(ostream &out, int indent_level) const { + char *name = _name ? _name : ""; + indent(out, indent_level) << get_type().get_name() - << " " << get_name() + << " " << name << " (at 0x" << this << ")\n"; } diff --git a/panda/src/physx/physxForceFieldShape.cxx b/panda/src/physx/physxForceFieldShape.cxx index b25a747ca2..f010b735ab 100644 --- a/panda/src/physx/physxForceFieldShape.cxx +++ b/panda/src/physx/physxForceFieldShape.cxx @@ -104,7 +104,10 @@ void PhysxForceFieldShape:: set_name(const char *name) { nassertv(_error_type == ET_ok); - ptr()->setName(name); + + free(_name); + _name = strdup(name); + ptr()->setName(_name); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldShape.h b/panda/src/physx/physxForceFieldShape.h index 44f2a71aac..1edb161295 100644 --- a/panda/src/physx/physxForceFieldShape.h +++ b/panda/src/physx/physxForceFieldShape.h @@ -62,6 +62,8 @@ public: protected: INLINE PhysxForceFieldShape(); + char *_name; + //////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { diff --git a/panda/src/physx/physxForceFieldShapeDesc.I b/panda/src/physx/physxForceFieldShapeDesc.I index 70f596151d..c0320d4d28 100644 --- a/panda/src/physx/physxForceFieldShapeDesc.I +++ b/panda/src/physx/physxForceFieldShapeDesc.I @@ -22,5 +22,17 @@ INLINE PhysxForceFieldShapeDesc:: PhysxForceFieldShapeDesc() { + _name = NULL; +} + +//////////////////////////////////////////////////////////////////// +// Function: PhysxForceFieldShapeDesc::Destructor +// Access: Protected +// Description: +//////////////////////////////////////////////////////////////////// +INLINE PhysxForceFieldShapeDesc:: +~PhysxForceFieldShapeDesc() { + + free(_name); } diff --git a/panda/src/physx/physxForceFieldShapeDesc.cxx b/panda/src/physx/physxForceFieldShapeDesc.cxx index e235b218d8..0023f7b476 100644 --- a/panda/src/physx/physxForceFieldShapeDesc.cxx +++ b/panda/src/physx/physxForceFieldShapeDesc.cxx @@ -23,7 +23,9 @@ void PhysxForceFieldShapeDesc:: set_name(const char *name) { - ptr()->name = name; + free(_name); + _name = strdup(name); + ptr()->name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldShapeDesc.h b/panda/src/physx/physxForceFieldShapeDesc.h index a53a478579..01e2f77125 100644 --- a/panda/src/physx/physxForceFieldShapeDesc.h +++ b/panda/src/physx/physxForceFieldShapeDesc.h @@ -43,9 +43,11 @@ PUBLISHED: public: virtual NxForceFieldShapeDesc *ptr() const = 0; + char *_name; protected: INLINE PhysxForceFieldShapeDesc(); + INLINE ~PhysxForceFieldShapeDesc(); }; #include "physxForceFieldShapeDesc.I" diff --git a/panda/src/physx/physxForceFieldShapeGroup.I b/panda/src/physx/physxForceFieldShapeGroup.I index cfaa82c2ea..3f9a477291 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.I +++ b/panda/src/physx/physxForceFieldShapeGroup.I @@ -22,6 +22,7 @@ INLINE PhysxForceFieldShapeGroup:: PhysxForceFieldShapeGroup() : PhysxObject() { + _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -32,6 +33,7 @@ PhysxForceFieldShapeGroup() : PhysxObject() { INLINE PhysxForceFieldShapeGroup:: ~PhysxForceFieldShapeGroup() { + free(_name); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldShapeGroup.cxx b/panda/src/physx/physxForceFieldShapeGroup.cxx index 81e83511b7..eee5a73474 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.cxx +++ b/panda/src/physx/physxForceFieldShapeGroup.cxx @@ -142,7 +142,10 @@ void PhysxForceFieldShapeGroup:: set_name(const char *name) { nassertv(_error_type == ET_ok); - _ptr->setName(name); + + free(_name); + _name = strdup(name); + _ptr->setName(_name); } //////////////////////////////////////////////////////////////////// @@ -190,6 +193,7 @@ create_shape(PhysxForceFieldShapeDesc &desc) { nassertr(shapePtr, NULL); shape->link(shapePtr); + shape->set_name(desc.ptr()->name); return shape; } diff --git a/panda/src/physx/physxForceFieldShapeGroup.h b/panda/src/physx/physxForceFieldShapeGroup.h index e1ea418f6c..74949ffbca 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.h +++ b/panda/src/physx/physxForceFieldShapeGroup.h @@ -69,6 +69,7 @@ public: private: NxForceFieldShapeGroup *_ptr; + char *_name; //////////////////////////////////////////////////////////////////// public: diff --git a/panda/src/physx/physxForceFieldShapeGroupDesc.I b/panda/src/physx/physxForceFieldShapeGroupDesc.I index a8ee47c586..a47d4e15d9 100644 --- a/panda/src/physx/physxForceFieldShapeGroupDesc.I +++ b/panda/src/physx/physxForceFieldShapeGroupDesc.I @@ -22,7 +22,7 @@ INLINE PhysxForceFieldShapeGroupDesc:: PhysxForceFieldShapeGroupDesc() { - _desc.name = ""; + _desc.name = NULL; } //////////////////////////////////////////////////////////////////// @@ -33,6 +33,7 @@ PhysxForceFieldShapeGroupDesc() { INLINE PhysxForceFieldShapeGroupDesc:: ~PhysxForceFieldShapeGroupDesc() { + free(_name); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldShapeGroupDesc.cxx b/panda/src/physx/physxForceFieldShapeGroupDesc.cxx index ee4260538b..3ac55122b2 100644 --- a/panda/src/physx/physxForceFieldShapeGroupDesc.cxx +++ b/panda/src/physx/physxForceFieldShapeGroupDesc.cxx @@ -35,7 +35,9 @@ add_shape(PhysxForceFieldShapeDesc &desc) { void PhysxForceFieldShapeGroupDesc:: set_name(const char *name) { - _desc.name = name; + free(_name); + _name = strdup(name); + _desc.name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldShapeGroupDesc.h b/panda/src/physx/physxForceFieldShapeGroupDesc.h index 809b4da9e3..bda17d667d 100644 --- a/panda/src/physx/physxForceFieldShapeGroupDesc.h +++ b/panda/src/physx/physxForceFieldShapeGroupDesc.h @@ -45,6 +45,7 @@ PUBLISHED: public: NxForceFieldShapeGroupDesc _desc; + char *_name; }; #include "physxForceFieldShapeGroupDesc.I" diff --git a/panda/src/physx/physxHeightFieldShape.I b/panda/src/physx/physxHeightFieldShape.I index 3a6fd84560..801fdd0ad4 100644 --- a/panda/src/physx/physxHeightFieldShape.I +++ b/panda/src/physx/physxHeightFieldShape.I @@ -32,5 +32,6 @@ PhysxHeightFieldShape() : PhysxShape() { INLINE PhysxHeightFieldShape:: ~PhysxHeightFieldShape() { + free(_name); } diff --git a/panda/src/physx/physxHeightFieldShapeDesc.cxx b/panda/src/physx/physxHeightFieldShapeDesc.cxx index 07c53d68c3..a3e9406471 100644 --- a/panda/src/physx/physxHeightFieldShapeDesc.cxx +++ b/panda/src/physx/physxHeightFieldShapeDesc.cxx @@ -25,7 +25,7 @@ set_to_default() { _desc.setToDefault(); - _desc.name = ""; + _desc.name = _name; _desc.shapeFlags = NX_SF_FEATURE_INDICES | NX_SF_VISUALIZATION; _desc.meshFlags = NX_MESH_SMOOTH_SPHERE_COLLISIONS; diff --git a/panda/src/physx/physxJoint.I b/panda/src/physx/physxJoint.I index bc97ba65a9..8635a86b09 100644 --- a/panda/src/physx/physxJoint.I +++ b/panda/src/physx/physxJoint.I @@ -22,6 +22,7 @@ INLINE PhysxJoint:: PhysxJoint() : PhysxObject() { + _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -43,8 +44,10 @@ ls() const { INLINE void PhysxJoint:: ls(ostream &out, int indent_level) const { + char *name = _name ? _name : ""; + indent(out, indent_level) << get_type().get_name() - << " " << get_name( ) + << " " << name << " (at 0x" << this << ")"; NxActor *actorPtr[2]; diff --git a/panda/src/physx/physxJoint.cxx b/panda/src/physx/physxJoint.cxx index cc6f89dc2a..d59c3418ca 100644 --- a/panda/src/physx/physxJoint.cxx +++ b/panda/src/physx/physxJoint.cxx @@ -100,7 +100,10 @@ void PhysxJoint:: set_name(const char *name) { nassertv(_error_type == ET_ok); - ptr()->setName(name); + + free(_name); + _name = strdup(name); + ptr()->setName(_name); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxJoint.h b/panda/src/physx/physxJoint.h index bbdf669e95..51e04850e6 100644 --- a/panda/src/physx/physxJoint.h +++ b/panda/src/physx/physxJoint.h @@ -72,6 +72,8 @@ public: protected: INLINE PhysxJoint(); + char *_name; + //////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { diff --git a/panda/src/physx/physxJointDesc.I b/panda/src/physx/physxJointDesc.I index 2ada7ec510..cdc7065591 100644 --- a/panda/src/physx/physxJointDesc.I +++ b/panda/src/physx/physxJointDesc.I @@ -22,5 +22,17 @@ INLINE PhysxJointDesc:: PhysxJointDesc() { + _name = NULL; +} + +//////////////////////////////////////////////////////////////////// +// Function: PhysxJointDesc::Destructor +// Access: Protected +// Description: +//////////////////////////////////////////////////////////////////// +INLINE PhysxJointDesc:: +~PhysxJointDesc() { + + free(_name); } diff --git a/panda/src/physx/physxJointDesc.cxx b/panda/src/physx/physxJointDesc.cxx index 4d3aca8bc8..0113721161 100644 --- a/panda/src/physx/physxJointDesc.cxx +++ b/panda/src/physx/physxJointDesc.cxx @@ -23,7 +23,9 @@ void PhysxJointDesc:: set_name(const char *name) { - ptr()->name = name; + free(_name); + _name = strdup(name); + ptr()->name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxJointDesc.h b/panda/src/physx/physxJointDesc.h index c166a10b22..bdd6fea4a2 100644 --- a/panda/src/physx/physxJointDesc.h +++ b/panda/src/physx/physxJointDesc.h @@ -58,9 +58,11 @@ PUBLISHED: public: virtual NxJointDesc *ptr() const = 0; + char *_name; protected: INLINE PhysxJointDesc(); + INLINE ~PhysxJointDesc(); }; #include "physxJointDesc.I" diff --git a/panda/src/physx/physxPlaneShape.I b/panda/src/physx/physxPlaneShape.I index 96c529e972..702f1df453 100644 --- a/panda/src/physx/physxPlaneShape.I +++ b/panda/src/physx/physxPlaneShape.I @@ -32,5 +32,6 @@ PhysxPlaneShape() : PhysxShape() { INLINE PhysxPlaneShape:: ~PhysxPlaneShape() { + free(_name); } diff --git a/panda/src/physx/physxPlaneShapeDesc.I b/panda/src/physx/physxPlaneShapeDesc.I index 0ea6f87c32..3a44e587a8 100644 --- a/panda/src/physx/physxPlaneShapeDesc.I +++ b/panda/src/physx/physxPlaneShapeDesc.I @@ -22,7 +22,7 @@ INLINE PhysxPlaneShapeDesc:: PhysxPlaneShapeDesc() : PhysxShapeDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxPlaneShapeDesc:: set_to_default() { _desc.setToDefault(); + _desc.name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxPointInPlaneJoint.I b/panda/src/physx/physxPointInPlaneJoint.I index 4a60567141..f2b2c63670 100644 --- a/panda/src/physx/physxPointInPlaneJoint.I +++ b/panda/src/physx/physxPointInPlaneJoint.I @@ -32,5 +32,6 @@ PhysxPointInPlaneJoint() : PhysxJoint() { INLINE PhysxPointInPlaneJoint:: ~PhysxPointInPlaneJoint() { + free(_name); } diff --git a/panda/src/physx/physxPointOnLineJoint.I b/panda/src/physx/physxPointOnLineJoint.I index 836c1d0826..541ccf1704 100644 --- a/panda/src/physx/physxPointOnLineJoint.I +++ b/panda/src/physx/physxPointOnLineJoint.I @@ -32,5 +32,6 @@ PhysxPointOnLineJoint() : PhysxJoint() { INLINE PhysxPointOnLineJoint:: ~PhysxPointOnLineJoint() { + free(_name); } diff --git a/panda/src/physx/physxPrismaticJoint.I b/panda/src/physx/physxPrismaticJoint.I index 91d82dce03..d1127350c6 100644 --- a/panda/src/physx/physxPrismaticJoint.I +++ b/panda/src/physx/physxPrismaticJoint.I @@ -32,5 +32,6 @@ PhysxPrismaticJoint() : PhysxJoint() { INLINE PhysxPrismaticJoint:: ~PhysxPrismaticJoint() { + free(_name); } diff --git a/panda/src/physx/physxPulleyJoint.I b/panda/src/physx/physxPulleyJoint.I index b3104276ee..b4d12ca638 100644 --- a/panda/src/physx/physxPulleyJoint.I +++ b/panda/src/physx/physxPulleyJoint.I @@ -32,5 +32,6 @@ PhysxPulleyJoint() : PhysxJoint() { INLINE PhysxPulleyJoint:: ~PhysxPulleyJoint() { + free(_name); } diff --git a/panda/src/physx/physxScene.cxx b/panda/src/physx/physxScene.cxx index c2dad441d3..a85f9cb3ec 100644 --- a/panda/src/physx/physxScene.cxx +++ b/panda/src/physx/physxScene.cxx @@ -395,6 +395,11 @@ create_actor(PhysxActorDesc &desc) { nassertr(actorPtr, NULL); actor->link(actorPtr); + actor->set_name(desc._desc.name); + + for (unsigned int i=0; i < actor->get_num_shapes(); i++) { + actor->get_shape(i)->set_name(desc._desc.shapes[i]->name); + } return actor; } @@ -759,6 +764,7 @@ create_joint(PhysxJointDesc &desc) { nassertr(jointPtr, NULL); joint->link(jointPtr); + joint->set_name(desc.ptr()->name); return joint; } @@ -820,6 +826,11 @@ create_force_field(PhysxForceFieldDesc &desc) { nassertr(fieldPtr, NULL); field->link(fieldPtr); + field->set_name(desc._desc.name); + + for (unsigned int i=0; i < field->get_num_shape_groups(); i++) { + field->get_shape_group(i)->set_name(desc._desc.shapeGroups[i]->getName()); + } return field; } @@ -873,6 +884,7 @@ create_force_field_shape_group(PhysxForceFieldShapeGroupDesc &desc) { nassertr(groupPtr, NULL); group->link(groupPtr); + group->set_name(strdup(desc._desc.name)); return group; } @@ -928,14 +940,7 @@ create_cloth(PhysxClothDesc &desc) { nassertr(clothPtr, NULL); cloth->link(clothPtr); - - // TODO: - - // Allocate buffers in the cloth's geom node (PhysxMeshNode) - //NxU32 numVertices = 0; - //NxU32 numTriangles = 0; - //desc.get_mesh_numbers(numVertices, numTriangles); - //cloth->get_cloth_node()->allocate(numVertices, numTriangles, cloth); + cloth->set_name(desc._desc.name); return cloth; } diff --git a/panda/src/physx/physxShape.I b/panda/src/physx/physxShape.I index 7ec9355945..3af58bac76 100644 --- a/panda/src/physx/physxShape.I +++ b/panda/src/physx/physxShape.I @@ -22,6 +22,7 @@ INLINE PhysxShape:: PhysxShape() : PhysxObject() { + _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -43,8 +44,10 @@ ls() const { INLINE void PhysxShape:: ls(ostream &out, int indent_level) const { + char *name = _name ? _name : ""; + indent(out, indent_level) << get_type().get_name() - << " " << get_name() + << " " << name << " (at 0x" << this << ")\n"; } diff --git a/panda/src/physx/physxShape.cxx b/panda/src/physx/physxShape.cxx index 1a83d64f98..1abac2056e 100644 --- a/panda/src/physx/physxShape.cxx +++ b/panda/src/physx/physxShape.cxx @@ -111,7 +111,10 @@ void PhysxShape:: set_name(const char *name) { nassertv(_error_type == ET_ok); - ptr()->setName(name); + + free(_name); + _name = strdup(name); + ptr()->setName(_name); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxShape.h b/panda/src/physx/physxShape.h index 0768dc9728..e1923a82b9 100644 --- a/panda/src/physx/physxShape.h +++ b/panda/src/physx/physxShape.h @@ -86,6 +86,8 @@ public: protected: INLINE PhysxShape(); + char *_name; + //////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { diff --git a/panda/src/physx/physxShapeDesc.I b/panda/src/physx/physxShapeDesc.I index cbacdb803e..20aa3d79b4 100644 --- a/panda/src/physx/physxShapeDesc.I +++ b/panda/src/physx/physxShapeDesc.I @@ -22,5 +22,17 @@ INLINE PhysxShapeDesc:: PhysxShapeDesc() { + _name = NULL; +} + +//////////////////////////////////////////////////////////////////// +// Function: PhysxShapeDesc::Destructor +// Access: Protected +// Description: +//////////////////////////////////////////////////////////////////// +INLINE PhysxShapeDesc:: +~PhysxShapeDesc() { + + free(_name); } diff --git a/panda/src/physx/physxShapeDesc.cxx b/panda/src/physx/physxShapeDesc.cxx index 9f8b99aef7..45f6dcca5d 100644 --- a/panda/src/physx/physxShapeDesc.cxx +++ b/panda/src/physx/physxShapeDesc.cxx @@ -24,7 +24,9 @@ void PhysxShapeDesc:: set_name(const char *name) { - ptr()->name = name; + free(_name); + _name = strdup(name); + ptr()->name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxShapeDesc.h b/panda/src/physx/physxShapeDesc.h index db1325624d..6de11cbcf2 100644 --- a/panda/src/physx/physxShapeDesc.h +++ b/panda/src/physx/physxShapeDesc.h @@ -61,9 +61,11 @@ PUBLISHED: public: virtual NxShapeDesc *ptr() const = 0; + char *_name; protected: INLINE PhysxShapeDesc(); + INLINE ~PhysxShapeDesc(); }; #include "physxShapeDesc.I" diff --git a/panda/src/physx/physxSphereForceFieldShape.I b/panda/src/physx/physxSphereForceFieldShape.I index b31ee29b69..a82de68c61 100644 --- a/panda/src/physx/physxSphereForceFieldShape.I +++ b/panda/src/physx/physxSphereForceFieldShape.I @@ -32,5 +32,6 @@ PhysxSphereForceFieldShape() : PhysxForceFieldShape() { INLINE PhysxSphereForceFieldShape:: ~PhysxSphereForceFieldShape() { + free(_name); } diff --git a/panda/src/physx/physxSphereShape.I b/panda/src/physx/physxSphereShape.I index d01268c3e9..9fca388726 100644 --- a/panda/src/physx/physxSphereShape.I +++ b/panda/src/physx/physxSphereShape.I @@ -32,5 +32,6 @@ PhysxSphereShape() : PhysxShape() { INLINE PhysxSphereShape:: ~PhysxSphereShape() { + free(_name); } diff --git a/panda/src/physx/physxSphereShapeDesc.I b/panda/src/physx/physxSphereShapeDesc.I index 89f5f9beee..9fb3aca244 100644 --- a/panda/src/physx/physxSphereShapeDesc.I +++ b/panda/src/physx/physxSphereShapeDesc.I @@ -22,7 +22,7 @@ INLINE PhysxSphereShapeDesc:: PhysxSphereShapeDesc() : PhysxShapeDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxSphereShapeDesc:: set_to_default() { _desc.setToDefault(); + _desc.name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxSphericalJoint.I b/panda/src/physx/physxSphericalJoint.I index 271b869f63..5e7c3f0a20 100644 --- a/panda/src/physx/physxSphericalJoint.I +++ b/panda/src/physx/physxSphericalJoint.I @@ -32,5 +32,6 @@ PhysxSphericalJoint() : PhysxJoint() { INLINE PhysxSphericalJoint:: ~PhysxSphericalJoint() { + free(_name); } diff --git a/panda/src/physx/physxTriangleMeshShape.I b/panda/src/physx/physxTriangleMeshShape.I index a1244f15e5..333639c53a 100644 --- a/panda/src/physx/physxTriangleMeshShape.I +++ b/panda/src/physx/physxTriangleMeshShape.I @@ -32,5 +32,6 @@ PhysxTriangleMeshShape() : PhysxShape() { INLINE PhysxTriangleMeshShape:: ~PhysxTriangleMeshShape() { + free(_name); } diff --git a/panda/src/physx/physxTriangleMeshShapeDesc.I b/panda/src/physx/physxTriangleMeshShapeDesc.I index 8d00b0cc2e..49b6048e95 100644 --- a/panda/src/physx/physxTriangleMeshShapeDesc.I +++ b/panda/src/physx/physxTriangleMeshShapeDesc.I @@ -22,7 +22,7 @@ INLINE PhysxTriangleMeshShapeDesc:: PhysxTriangleMeshShapeDesc() : PhysxShapeDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxTriangleMeshShapeDesc:: set_to_default() { _desc.setToDefault(); + _desc.name = _name; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxWheelShape.I b/panda/src/physx/physxWheelShape.I index a8f0c6bfe1..4985e2608c 100644 --- a/panda/src/physx/physxWheelShape.I +++ b/panda/src/physx/physxWheelShape.I @@ -32,5 +32,6 @@ PhysxWheelShape() : PhysxShape() { INLINE PhysxWheelShape:: ~PhysxWheelShape() { + free(_name); } diff --git a/panda/src/physx/physxWheelShapeDesc.cxx b/panda/src/physx/physxWheelShapeDesc.cxx index b3d7658195..188ec487fb 100644 --- a/panda/src/physx/physxWheelShapeDesc.cxx +++ b/panda/src/physx/physxWheelShapeDesc.cxx @@ -24,7 +24,7 @@ set_to_default() { _desc.setToDefault(); - _desc.name = ""; + _desc.name = _name; _desc.localPose = PhysxManager::mat4_to_nxMat34(LMatrix4f::y_to_z_up_mat()); }