diff --git a/panda/src/physx/physxActor.I b/panda/src/physx/physxActor.I index c55a74c69b..44f09990b4 100644 --- a/panda/src/physx/physxActor.I +++ b/panda/src/physx/physxActor.I @@ -22,7 +22,6 @@ INLINE PhysxActor:: PhysxActor() : PhysxObject() { - _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -33,7 +32,6 @@ PhysxActor() : PhysxObject() { INLINE PhysxActor:: ~PhysxActor() { - free(_name); } //////////////////////////////////////////////////////////////////// @@ -55,10 +53,8 @@ ls() const { INLINE void PhysxActor:: ls(ostream &out, int indent_level) const { - const char *name = _name ? _name : ""; - indent(out, indent_level) << get_type().get_name() - << " " << name + << " " << _name << " (at 0x" << this << ")"; if (!_np.is_empty()) { diff --git a/panda/src/physx/physxActor.cxx b/panda/src/physx/physxActor.cxx index a588895bcb..816f3a80fc 100644 --- a/panda/src/physx/physxActor.cxx +++ b/panda/src/physx/physxActor.cxx @@ -33,6 +33,8 @@ link(NxActor *actorPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(actorPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_actors.add(this); @@ -136,9 +138,8 @@ set_name(const char *name) { nassertv(_error_type == ET_ok); - free(_name); - _name = strdup(name); - _ptr->setName(_name); + _name = name ? name : ""; + _ptr->setName(_name.c_str()); } //////////////////////////////////////////////////////////////////// @@ -401,7 +402,6 @@ 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 4d96d7144a..db1058fa48 100644 --- a/panda/src/physx/physxActor.h +++ b/panda/src/physx/physxActor.h @@ -197,7 +197,7 @@ private: NxActor *_ptr; NodePath _np; PT(PhysxController) _controller; - char *_name; + string _name; //////////////////////////////////////////////////////////////////// public: diff --git a/panda/src/physx/physxActorDesc.I b/panda/src/physx/physxActorDesc.I index 0603a14382..eaf347bb78 100644 --- a/panda/src/physx/physxActorDesc.I +++ b/panda/src/physx/physxActorDesc.I @@ -22,8 +22,7 @@ INLINE PhysxActorDesc:: PhysxActorDesc() { - _name = NULL; - _desc.name = _name; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -34,7 +33,6 @@ PhysxActorDesc() { INLINE PhysxActorDesc:: ~PhysxActorDesc() { - free(_name); } //////////////////////////////////////////////////////////////////// @@ -46,6 +44,7 @@ INLINE void PhysxActorDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxActorDesc.cxx b/panda/src/physx/physxActorDesc.cxx index c156e34a2b..326bcabb58 100644 --- a/panda/src/physx/physxActorDesc.cxx +++ b/panda/src/physx/physxActorDesc.cxx @@ -36,9 +36,8 @@ add_shape(PhysxShapeDesc &desc) { void PhysxActorDesc:: set_name(const char *name) { - free(_name); - _name = strdup(name); - _desc.name = _name; + _name = name ? name : ""; + _desc.name = _name.c_str(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxActorDesc.h b/panda/src/physx/physxActorDesc.h index d8d9d97d64..2515f042ab 100644 --- a/panda/src/physx/physxActorDesc.h +++ b/panda/src/physx/physxActorDesc.h @@ -54,7 +54,9 @@ PUBLISHED: public: NxActorDesc _desc; - char *_name; + +private: + string _name; }; #include "physxActorDesc.I" diff --git a/panda/src/physx/physxBoxForceFieldShape.I b/panda/src/physx/physxBoxForceFieldShape.I index b01d906f22..2c6bbbafa0 100644 --- a/panda/src/physx/physxBoxForceFieldShape.I +++ b/panda/src/physx/physxBoxForceFieldShape.I @@ -32,6 +32,5 @@ PhysxBoxForceFieldShape() : PhysxForceFieldShape() { INLINE PhysxBoxForceFieldShape:: ~PhysxBoxForceFieldShape() { - free(_name); } diff --git a/panda/src/physx/physxBoxForceFieldShape.cxx b/panda/src/physx/physxBoxForceFieldShape.cxx index ecea5ce0d7..d441871f23 100644 --- a/panda/src/physx/physxBoxForceFieldShape.cxx +++ b/panda/src/physx/physxBoxForceFieldShape.cxx @@ -30,6 +30,8 @@ link(NxForceFieldShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; group->_shapes.add(this); } diff --git a/panda/src/physx/physxBoxForceFieldShapeDesc.I b/panda/src/physx/physxBoxForceFieldShapeDesc.I index 168e2f47e4..8d72625fd7 100644 --- a/panda/src/physx/physxBoxForceFieldShapeDesc.I +++ b/panda/src/physx/physxBoxForceFieldShapeDesc.I @@ -22,7 +22,7 @@ INLINE PhysxBoxForceFieldShapeDesc:: PhysxBoxForceFieldShapeDesc() : PhysxForceFieldShapeDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxBoxForceFieldShapeDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxBoxShape.I b/panda/src/physx/physxBoxShape.I index f57eecb7ff..730f806b10 100644 --- a/panda/src/physx/physxBoxShape.I +++ b/panda/src/physx/physxBoxShape.I @@ -32,6 +32,5 @@ PhysxBoxShape() : PhysxShape() { INLINE PhysxBoxShape:: ~PhysxBoxShape() { - free(_name); } diff --git a/panda/src/physx/physxBoxShape.cxx b/panda/src/physx/physxBoxShape.cxx index 66972a4f8a..ac09e1b7e4 100644 --- a/panda/src/physx/physxBoxShape.cxx +++ b/panda/src/physx/physxBoxShape.cxx @@ -30,6 +30,8 @@ link(NxShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; actor->_shapes.add(this); } diff --git a/panda/src/physx/physxBoxShapeDesc.I b/panda/src/physx/physxBoxShapeDesc.I index a473ae2c87..447c7bad9a 100644 --- a/panda/src/physx/physxBoxShapeDesc.I +++ b/panda/src/physx/physxBoxShapeDesc.I @@ -44,7 +44,7 @@ INLINE void PhysxBoxShapeDesc:: set_to_default() { _desc.setToDefault(); - _desc.name = _name; + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxCapsuleForceFieldShape.I b/panda/src/physx/physxCapsuleForceFieldShape.I index 070009a8ab..f4cc2b9a94 100644 --- a/panda/src/physx/physxCapsuleForceFieldShape.I +++ b/panda/src/physx/physxCapsuleForceFieldShape.I @@ -32,6 +32,5 @@ PhysxCapsuleForceFieldShape() : PhysxForceFieldShape() { INLINE PhysxCapsuleForceFieldShape:: ~PhysxCapsuleForceFieldShape() { - free(_name); } diff --git a/panda/src/physx/physxCapsuleForceFieldShape.cxx b/panda/src/physx/physxCapsuleForceFieldShape.cxx index fc0f84b035..4f9cf1cec8 100644 --- a/panda/src/physx/physxCapsuleForceFieldShape.cxx +++ b/panda/src/physx/physxCapsuleForceFieldShape.cxx @@ -29,6 +29,8 @@ link(NxForceFieldShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; group->_shapes.add(this); } diff --git a/panda/src/physx/physxCapsuleForceFieldShapeDesc.I b/panda/src/physx/physxCapsuleForceFieldShapeDesc.I index 301345d4e0..794e8be649 100644 --- a/panda/src/physx/physxCapsuleForceFieldShapeDesc.I +++ b/panda/src/physx/physxCapsuleForceFieldShapeDesc.I @@ -22,7 +22,7 @@ INLINE PhysxCapsuleForceFieldShapeDesc:: PhysxCapsuleForceFieldShapeDesc() : PhysxForceFieldShapeDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxCapsuleForceFieldShapeDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxCapsuleShape.I b/panda/src/physx/physxCapsuleShape.I index 61a3cd3df4..b24267e48a 100644 --- a/panda/src/physx/physxCapsuleShape.I +++ b/panda/src/physx/physxCapsuleShape.I @@ -32,6 +32,5 @@ PhysxCapsuleShape() : PhysxShape() { INLINE PhysxCapsuleShape:: ~PhysxCapsuleShape() { - free(_name); } diff --git a/panda/src/physx/physxCapsuleShape.cxx b/panda/src/physx/physxCapsuleShape.cxx index 231d464300..bd8ca4c033 100644 --- a/panda/src/physx/physxCapsuleShape.cxx +++ b/panda/src/physx/physxCapsuleShape.cxx @@ -29,6 +29,8 @@ link(NxShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; actor->_shapes.add(this); } diff --git a/panda/src/physx/physxCapsuleShapeDesc.I b/panda/src/physx/physxCapsuleShapeDesc.I index e7038d9c3c..410872235d 100644 --- a/panda/src/physx/physxCapsuleShapeDesc.I +++ b/panda/src/physx/physxCapsuleShapeDesc.I @@ -44,7 +44,7 @@ INLINE void PhysxCapsuleShapeDesc:: set_to_default() { _desc.setToDefault(); - _desc.name = _name; + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxCloth.I b/panda/src/physx/physxCloth.I index f1ad23b9e9..4213f624b3 100644 --- a/panda/src/physx/physxCloth.I +++ b/panda/src/physx/physxCloth.I @@ -22,7 +22,6 @@ INLINE PhysxCloth:: PhysxCloth() : PhysxObject() { - _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -33,7 +32,6 @@ PhysxCloth() : PhysxObject() { INLINE PhysxCloth:: ~PhysxCloth() { - free(_name); } //////////////////////////////////////////////////////////////////// @@ -55,15 +53,13 @@ ls() const { INLINE void PhysxCloth:: ls(ostream &out, int indent_level) const { - const char *name = _name ? _name : ""; - indent(out, indent_level) << get_type().get_name() - << " " << name + << " " << _name << " (at 0x" << this << ")"; - //if (_node) { - // " N:0x" << _node; - //} + if (_node) { + out << " N:0x" << _node; + } out << "\n"; } diff --git a/panda/src/physx/physxCloth.cxx b/panda/src/physx/physxCloth.cxx index 67340de4d8..a18ae60876 100644 --- a/panda/src/physx/physxCloth.cxx +++ b/panda/src/physx/physxCloth.cxx @@ -29,13 +29,15 @@ TypeHandle PhysxCloth::_type_handle; // Description: //////////////////////////////////////////////////////////////////// void PhysxCloth:: -link(NxCloth *ptr) { +link(NxCloth *clothPtr) { // Link self - _ptr = ptr; + _ptr = clothPtr; _error_type = ET_ok; _ptr->userData = this; + set_name(clothPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_cloths.add(this); } @@ -146,9 +148,8 @@ set_name(const char *name) { nassertv(_error_type == ET_ok); - free(_name); - _name = strdup(name); - _ptr->setName(_name); + _name = name ? name : ""; + _ptr->setName(_name.c_str()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxCloth.h b/panda/src/physx/physxCloth.h index 0664c5eae0..126b7a4235 100644 --- a/panda/src/physx/physxCloth.h +++ b/panda/src/physx/physxCloth.h @@ -108,7 +108,7 @@ public: private: NxCloth *_ptr; PT(PhysxClothNode) _node; - char *_name; + string _name; //////////////////////////////////////////////////////////////////// public: diff --git a/panda/src/physx/physxClothDesc.I b/panda/src/physx/physxClothDesc.I index 33f75f625a..0472224947 100644 --- a/panda/src/physx/physxClothDesc.I +++ b/panda/src/physx/physxClothDesc.I @@ -22,8 +22,7 @@ INLINE PhysxClothDesc:: PhysxClothDesc() { - _name = NULL; - _desc.name = _name; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -34,7 +33,6 @@ PhysxClothDesc() { INLINE PhysxClothDesc:: ~PhysxClothDesc() { - free(_name); } //////////////////////////////////////////////////////////////////// @@ -46,6 +44,7 @@ INLINE void PhysxClothDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxClothDesc.cxx b/panda/src/physx/physxClothDesc.cxx index 63064c14e6..1dcf6be50d 100644 --- a/panda/src/physx/physxClothDesc.cxx +++ b/panda/src/physx/physxClothDesc.cxx @@ -24,9 +24,8 @@ void PhysxClothDesc:: set_name(const char *name) { - free(_name); - _name = strdup(name); - _desc.name = _name; + _name = name ? name : ""; + _desc.name = _name.c_str(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxClothDesc.h b/panda/src/physx/physxClothDesc.h index c4dad0c3a7..a0bfb0777a 100644 --- a/panda/src/physx/physxClothDesc.h +++ b/panda/src/physx/physxClothDesc.h @@ -70,7 +70,9 @@ PUBLISHED: public: NxClothDesc _desc; - char *_name; + +private: + string _name; }; #include "physxClothDesc.I" diff --git a/panda/src/physx/physxConvexForceFieldShape.I b/panda/src/physx/physxConvexForceFieldShape.I index 61a854bc70..a38be7ee2e 100644 --- a/panda/src/physx/physxConvexForceFieldShape.I +++ b/panda/src/physx/physxConvexForceFieldShape.I @@ -32,6 +32,5 @@ PhysxConvexForceFieldShape() : PhysxForceFieldShape() { INLINE PhysxConvexForceFieldShape:: ~PhysxConvexForceFieldShape() { - free(_name); } diff --git a/panda/src/physx/physxConvexForceFieldShape.cxx b/panda/src/physx/physxConvexForceFieldShape.cxx index 22c1d21cbe..8f6c409224 100644 --- a/panda/src/physx/physxConvexForceFieldShape.cxx +++ b/panda/src/physx/physxConvexForceFieldShape.cxx @@ -29,6 +29,8 @@ link(NxForceFieldShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; group->_shapes.add(this); } diff --git a/panda/src/physx/physxConvexForceFieldShapeDesc.I b/panda/src/physx/physxConvexForceFieldShapeDesc.I index 81e7b789ed..05d5c83f26 100644 --- a/panda/src/physx/physxConvexForceFieldShapeDesc.I +++ b/panda/src/physx/physxConvexForceFieldShapeDesc.I @@ -22,7 +22,7 @@ INLINE PhysxConvexForceFieldShapeDesc:: PhysxConvexForceFieldShapeDesc() : PhysxForceFieldShapeDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxConvexForceFieldShapeDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxConvexShape.I b/panda/src/physx/physxConvexShape.I index caf06ea9ae..db1dd53069 100644 --- a/panda/src/physx/physxConvexShape.I +++ b/panda/src/physx/physxConvexShape.I @@ -32,6 +32,5 @@ PhysxConvexShape() : PhysxShape() { INLINE PhysxConvexShape:: ~PhysxConvexShape() { - free(_name); } diff --git a/panda/src/physx/physxConvexShape.cxx b/panda/src/physx/physxConvexShape.cxx index c607375394..dcf6fcf257 100644 --- a/panda/src/physx/physxConvexShape.cxx +++ b/panda/src/physx/physxConvexShape.cxx @@ -29,6 +29,8 @@ link(NxShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; actor->_shapes.add(this); } diff --git a/panda/src/physx/physxConvexShapeDesc.I b/panda/src/physx/physxConvexShapeDesc.I index c4b300ebcc..e177f62c8a 100644 --- a/panda/src/physx/physxConvexShapeDesc.I +++ b/panda/src/physx/physxConvexShapeDesc.I @@ -44,7 +44,7 @@ INLINE void PhysxConvexShapeDesc:: set_to_default() { _desc.setToDefault(); - _desc.name = _name; + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxCylindricalJoint.I b/panda/src/physx/physxCylindricalJoint.I index 6ad30531fc..5ec371bbe5 100644 --- a/panda/src/physx/physxCylindricalJoint.I +++ b/panda/src/physx/physxCylindricalJoint.I @@ -32,6 +32,5 @@ PhysxCylindricalJoint() : PhysxJoint() { INLINE PhysxCylindricalJoint:: ~PhysxCylindricalJoint() { - free(_name); } diff --git a/panda/src/physx/physxCylindricalJoint.cxx b/panda/src/physx/physxCylindricalJoint.cxx index 826f1dffbb..1d07767583 100644 --- a/panda/src/physx/physxCylindricalJoint.cxx +++ b/panda/src/physx/physxCylindricalJoint.cxx @@ -29,6 +29,8 @@ link(NxJoint *jointPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(jointPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_joints.add(this); } diff --git a/panda/src/physx/physxCylindricalJointDesc.I b/panda/src/physx/physxCylindricalJointDesc.I index 864085af3a..45d07794b5 100644 --- a/panda/src/physx/physxCylindricalJointDesc.I +++ b/panda/src/physx/physxCylindricalJointDesc.I @@ -22,7 +22,7 @@ INLINE PhysxCylindricalJointDesc:: PhysxCylindricalJointDesc() : PhysxJointDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxCylindricalJointDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxD6Joint.I b/panda/src/physx/physxD6Joint.I index e00079e69c..435bdfcbf3 100644 --- a/panda/src/physx/physxD6Joint.I +++ b/panda/src/physx/physxD6Joint.I @@ -32,6 +32,5 @@ PhysxD6Joint() : PhysxJoint() { INLINE PhysxD6Joint:: ~PhysxD6Joint() { - free(_name); } diff --git a/panda/src/physx/physxD6Joint.cxx b/panda/src/physx/physxD6Joint.cxx index 5f832534d4..2459b20922 100644 --- a/panda/src/physx/physxD6Joint.cxx +++ b/panda/src/physx/physxD6Joint.cxx @@ -29,6 +29,8 @@ link(NxJoint *jointPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(jointPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_joints.add(this); } diff --git a/panda/src/physx/physxD6JointDesc.I b/panda/src/physx/physxD6JointDesc.I index 15015bf815..42adf17589 100644 --- a/panda/src/physx/physxD6JointDesc.I +++ b/panda/src/physx/physxD6JointDesc.I @@ -22,7 +22,7 @@ INLINE PhysxD6JointDesc:: PhysxD6JointDesc() : PhysxJointDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxD6JointDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxDistanceJoint.I b/panda/src/physx/physxDistanceJoint.I index 3318172a43..05e07a807f 100644 --- a/panda/src/physx/physxDistanceJoint.I +++ b/panda/src/physx/physxDistanceJoint.I @@ -32,6 +32,5 @@ PhysxDistanceJoint() : PhysxJoint() { INLINE PhysxDistanceJoint:: ~PhysxDistanceJoint() { - free(_name); } diff --git a/panda/src/physx/physxDistanceJoint.cxx b/panda/src/physx/physxDistanceJoint.cxx index ae868038e9..3be88b1551 100644 --- a/panda/src/physx/physxDistanceJoint.cxx +++ b/panda/src/physx/physxDistanceJoint.cxx @@ -29,6 +29,8 @@ link(NxJoint *jointPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(jointPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_joints.add(this); } diff --git a/panda/src/physx/physxDistanceJointDesc.I b/panda/src/physx/physxDistanceJointDesc.I index 6df3d51425..0dc92b97a6 100644 --- a/panda/src/physx/physxDistanceJointDesc.I +++ b/panda/src/physx/physxDistanceJointDesc.I @@ -22,7 +22,7 @@ INLINE PhysxDistanceJointDesc:: PhysxDistanceJointDesc() : PhysxJointDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxDistanceJointDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxFixedJoint.I b/panda/src/physx/physxFixedJoint.I index ea13cb3c76..489f30e98f 100644 --- a/panda/src/physx/physxFixedJoint.I +++ b/panda/src/physx/physxFixedJoint.I @@ -32,6 +32,5 @@ PhysxFixedJoint() : PhysxJoint() { INLINE PhysxFixedJoint:: ~PhysxFixedJoint() { - free(_name); } diff --git a/panda/src/physx/physxFixedJoint.cxx b/panda/src/physx/physxFixedJoint.cxx index 8cfe7c0cbf..538805c64f 100644 --- a/panda/src/physx/physxFixedJoint.cxx +++ b/panda/src/physx/physxFixedJoint.cxx @@ -29,6 +29,8 @@ link(NxJoint *jointPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(jointPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_joints.add(this); } diff --git a/panda/src/physx/physxFixedJointDesc.I b/panda/src/physx/physxFixedJointDesc.I index bf7b2b42c8..acf448375e 100644 --- a/panda/src/physx/physxFixedJointDesc.I +++ b/panda/src/physx/physxFixedJointDesc.I @@ -22,7 +22,7 @@ INLINE PhysxFixedJointDesc:: PhysxFixedJointDesc() : PhysxJointDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxFixedJointDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceField.I b/panda/src/physx/physxForceField.I index d589ecba35..4c2573ea40 100644 --- a/panda/src/physx/physxForceField.I +++ b/panda/src/physx/physxForceField.I @@ -22,7 +22,6 @@ INLINE PhysxForceField:: PhysxForceField() : PhysxObject() { - _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -33,7 +32,6 @@ PhysxForceField() : PhysxObject() { INLINE PhysxForceField:: ~PhysxForceField() { - free(_name); } //////////////////////////////////////////////////////////////////// @@ -55,10 +53,8 @@ ls() const { INLINE void PhysxForceField:: ls(ostream &out, int indent_level) const { - const char *name = _name ? _name : ""; - indent(out, indent_level) << get_type().get_name() - << " " << name + << " " << _name << " (at 0x" << this << ")\n"; } diff --git a/panda/src/physx/physxForceField.cxx b/panda/src/physx/physxForceField.cxx index 45593ad99c..44ccbe5859 100644 --- a/panda/src/physx/physxForceField.cxx +++ b/panda/src/physx/physxForceField.cxx @@ -25,13 +25,15 @@ TypeHandle PhysxForceField::_type_handle; // Description: //////////////////////////////////////////////////////////////////// void PhysxForceField:: -link(NxForceField *materialPtr) { +link(NxForceField *fieldPtr) { // Link self - _ptr = materialPtr; + _ptr = fieldPtr; _ptr->userData = this; _error_type = ET_ok; + set_name(fieldPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_forcefields.add(this); @@ -85,9 +87,8 @@ set_name(const char *name) { nassertv(_error_type == ET_ok); - free(_name); - _name = strdup(name); - _ptr->setName(_name); + _name = name ? name : ""; + _ptr->setName(_name.c_str()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceField.h b/panda/src/physx/physxForceField.h index 04f9c646b5..29b272e42c 100644 --- a/panda/src/physx/physxForceField.h +++ b/panda/src/physx/physxForceField.h @@ -68,7 +68,7 @@ public: private: NxForceField *_ptr; - char *_name; + string _name; //////////////////////////////////////////////////////////////////// public: diff --git a/panda/src/physx/physxForceFieldDesc.I b/panda/src/physx/physxForceFieldDesc.I index 34749747e2..49f5232c1c 100644 --- a/panda/src/physx/physxForceFieldDesc.I +++ b/panda/src/physx/physxForceFieldDesc.I @@ -22,7 +22,6 @@ INLINE PhysxForceFieldDesc:: PhysxForceFieldDesc() { - _desc.name = NULL; } //////////////////////////////////////////////////////////////////// @@ -33,7 +32,6 @@ PhysxForceFieldDesc() { INLINE PhysxForceFieldDesc:: ~PhysxForceFieldDesc() { - free(_name); } //////////////////////////////////////////////////////////////////// @@ -45,6 +43,7 @@ INLINE void PhysxForceFieldDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldDesc.cxx b/panda/src/physx/physxForceFieldDesc.cxx index 3b608bc101..da7a0d5213 100644 --- a/panda/src/physx/physxForceFieldDesc.cxx +++ b/panda/src/physx/physxForceFieldDesc.cxx @@ -26,9 +26,8 @@ void PhysxForceFieldDesc:: set_name(const char *name) { - free(_name); - _name = strdup(name); - _desc.name = _name; + _name = name ? name : ""; + _desc.name = _name.c_str(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldDesc.h b/panda/src/physx/physxForceFieldDesc.h index 1fcd3519d7..498555ef16 100644 --- a/panda/src/physx/physxForceFieldDesc.h +++ b/panda/src/physx/physxForceFieldDesc.h @@ -66,7 +66,8 @@ public: NxForceFieldDesc _desc; NxForceFieldLinearKernelDesc _kernel; - char *_name; +private: + string _name; }; #include "physxForceFieldDesc.I" diff --git a/panda/src/physx/physxForceFieldShape.I b/panda/src/physx/physxForceFieldShape.I index 2077036d77..9fa850d831 100644 --- a/panda/src/physx/physxForceFieldShape.I +++ b/panda/src/physx/physxForceFieldShape.I @@ -22,7 +22,6 @@ INLINE PhysxForceFieldShape:: PhysxForceFieldShape() : PhysxObject() { - _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -44,10 +43,8 @@ ls() const { INLINE void PhysxForceFieldShape:: ls(ostream &out, int indent_level) const { - const char *name = _name ? _name : ""; - indent(out, indent_level) << get_type().get_name() - << " " << name + << " " << _name << " (at 0x" << this << ")\n"; } diff --git a/panda/src/physx/physxForceFieldShape.cxx b/panda/src/physx/physxForceFieldShape.cxx index f010b735ab..01bfc23873 100644 --- a/panda/src/physx/physxForceFieldShape.cxx +++ b/panda/src/physx/physxForceFieldShape.cxx @@ -105,9 +105,8 @@ set_name(const char *name) { nassertv(_error_type == ET_ok); - free(_name); - _name = strdup(name); - ptr()->setName(_name); + _name = name ? name : ""; + ptr()->setName(_name.c_str()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldShape.h b/panda/src/physx/physxForceFieldShape.h index 1edb161295..afb727dc06 100644 --- a/panda/src/physx/physxForceFieldShape.h +++ b/panda/src/physx/physxForceFieldShape.h @@ -62,7 +62,8 @@ public: protected: INLINE PhysxForceFieldShape(); - char *_name; +private: + string _name; //////////////////////////////////////////////////////////////////// public: diff --git a/panda/src/physx/physxForceFieldShapeDesc.I b/panda/src/physx/physxForceFieldShapeDesc.I index c0320d4d28..21fe45e63c 100644 --- a/panda/src/physx/physxForceFieldShapeDesc.I +++ b/panda/src/physx/physxForceFieldShapeDesc.I @@ -22,7 +22,6 @@ INLINE PhysxForceFieldShapeDesc:: PhysxForceFieldShapeDesc() { - _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -33,6 +32,5 @@ PhysxForceFieldShapeDesc() { INLINE PhysxForceFieldShapeDesc:: ~PhysxForceFieldShapeDesc() { - free(_name); } diff --git a/panda/src/physx/physxForceFieldShapeDesc.cxx b/panda/src/physx/physxForceFieldShapeDesc.cxx index 0023f7b476..907be87762 100644 --- a/panda/src/physx/physxForceFieldShapeDesc.cxx +++ b/panda/src/physx/physxForceFieldShapeDesc.cxx @@ -23,9 +23,8 @@ void PhysxForceFieldShapeDesc:: set_name(const char *name) { - free(_name); - _name = strdup(name); - ptr()->name = _name; + _name = name ? name : ""; + ptr()->name = _name.c_str(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldShapeDesc.h b/panda/src/physx/physxForceFieldShapeDesc.h index 01e2f77125..4d0ac662cb 100644 --- a/panda/src/physx/physxForceFieldShapeDesc.h +++ b/panda/src/physx/physxForceFieldShapeDesc.h @@ -43,7 +43,9 @@ PUBLISHED: public: virtual NxForceFieldShapeDesc *ptr() const = 0; - char *_name; + +private: + string _name; protected: INLINE PhysxForceFieldShapeDesc(); diff --git a/panda/src/physx/physxForceFieldShapeGroup.I b/panda/src/physx/physxForceFieldShapeGroup.I index 5044cee77c..3c4b65453e 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.I +++ b/panda/src/physx/physxForceFieldShapeGroup.I @@ -22,7 +22,6 @@ INLINE PhysxForceFieldShapeGroup:: PhysxForceFieldShapeGroup() : PhysxObject() { - _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -33,7 +32,6 @@ PhysxForceFieldShapeGroup() : PhysxObject() { INLINE PhysxForceFieldShapeGroup:: ~PhysxForceFieldShapeGroup() { - free(_name); } //////////////////////////////////////////////////////////////////// @@ -55,10 +53,8 @@ ls() const { INLINE void PhysxForceFieldShapeGroup:: ls(ostream &out, int indent_level) const { - const char *name = _name ? _name : ""; - indent(out, indent_level) << get_type().get_name() - << " " << name + << " " << _name << " (at 0x" << this << ")\n"; _shapes.ls(out, indent_level); diff --git a/panda/src/physx/physxForceFieldShapeGroup.cxx b/panda/src/physx/physxForceFieldShapeGroup.cxx index eee5a73474..4393f9dfe0 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.cxx +++ b/panda/src/physx/physxForceFieldShapeGroup.cxx @@ -32,6 +32,8 @@ link(NxForceFieldShapeGroup *groupPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(groupPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_ffgroups.add(this); @@ -143,9 +145,8 @@ set_name(const char *name) { nassertv(_error_type == ET_ok); - free(_name); - _name = strdup(name); - _ptr->setName(_name); + _name = name ? name : ""; + _ptr->setName(_name.c_str()); } //////////////////////////////////////////////////////////////////// @@ -193,7 +194,6 @@ 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 74949ffbca..b8883926af 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.h +++ b/panda/src/physx/physxForceFieldShapeGroup.h @@ -69,7 +69,7 @@ public: private: NxForceFieldShapeGroup *_ptr; - char *_name; + string _name; //////////////////////////////////////////////////////////////////// public: diff --git a/panda/src/physx/physxForceFieldShapeGroupDesc.I b/panda/src/physx/physxForceFieldShapeGroupDesc.I index a47d4e15d9..b03655b0c6 100644 --- a/panda/src/physx/physxForceFieldShapeGroupDesc.I +++ b/panda/src/physx/physxForceFieldShapeGroupDesc.I @@ -22,7 +22,7 @@ INLINE PhysxForceFieldShapeGroupDesc:: PhysxForceFieldShapeGroupDesc() { - _desc.name = NULL; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -33,7 +33,6 @@ PhysxForceFieldShapeGroupDesc() { INLINE PhysxForceFieldShapeGroupDesc:: ~PhysxForceFieldShapeGroupDesc() { - free(_name); } //////////////////////////////////////////////////////////////////// @@ -45,6 +44,7 @@ INLINE void PhysxForceFieldShapeGroupDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldShapeGroupDesc.cxx b/panda/src/physx/physxForceFieldShapeGroupDesc.cxx index 3ac55122b2..ac3fa59c1c 100644 --- a/panda/src/physx/physxForceFieldShapeGroupDesc.cxx +++ b/panda/src/physx/physxForceFieldShapeGroupDesc.cxx @@ -35,9 +35,8 @@ add_shape(PhysxForceFieldShapeDesc &desc) { void PhysxForceFieldShapeGroupDesc:: set_name(const char *name) { - free(_name); - _name = strdup(name); - _desc.name = _name; + _name = name ? name : ""; + _desc.name = _name.c_str(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxForceFieldShapeGroupDesc.h b/panda/src/physx/physxForceFieldShapeGroupDesc.h index bda17d667d..5615eaea48 100644 --- a/panda/src/physx/physxForceFieldShapeGroupDesc.h +++ b/panda/src/physx/physxForceFieldShapeGroupDesc.h @@ -45,7 +45,9 @@ PUBLISHED: public: NxForceFieldShapeGroupDesc _desc; - char *_name; + +private: + string _name; }; #include "physxForceFieldShapeGroupDesc.I" diff --git a/panda/src/physx/physxHeightFieldShape.I b/panda/src/physx/physxHeightFieldShape.I index 801fdd0ad4..3a6fd84560 100644 --- a/panda/src/physx/physxHeightFieldShape.I +++ b/panda/src/physx/physxHeightFieldShape.I @@ -32,6 +32,5 @@ PhysxHeightFieldShape() : PhysxShape() { INLINE PhysxHeightFieldShape:: ~PhysxHeightFieldShape() { - free(_name); } diff --git a/panda/src/physx/physxHeightFieldShape.cxx b/panda/src/physx/physxHeightFieldShape.cxx index 71b5291533..b08e87f714 100644 --- a/panda/src/physx/physxHeightFieldShape.cxx +++ b/panda/src/physx/physxHeightFieldShape.cxx @@ -29,6 +29,8 @@ link(NxShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; actor->_shapes.add(this); } diff --git a/panda/src/physx/physxHeightFieldShapeDesc.cxx b/panda/src/physx/physxHeightFieldShapeDesc.cxx index a3e9406471..aa18776bf5 100644 --- a/panda/src/physx/physxHeightFieldShapeDesc.cxx +++ b/panda/src/physx/physxHeightFieldShapeDesc.cxx @@ -24,8 +24,7 @@ void PhysxHeightFieldShapeDesc:: set_to_default() { _desc.setToDefault(); - - _desc.name = _name; + set_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 06beb9e76c..a8301fbd28 100644 --- a/panda/src/physx/physxJoint.I +++ b/panda/src/physx/physxJoint.I @@ -22,7 +22,6 @@ INLINE PhysxJoint:: PhysxJoint() : PhysxObject() { - _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -44,10 +43,8 @@ ls() const { INLINE void PhysxJoint:: ls(ostream &out, int indent_level) const { - const char *name = _name ? _name : ""; - indent(out, indent_level) << get_type().get_name() - << " " << name + << " " << _name << " (at 0x" << this << ")"; NxActor *actorPtr[2]; diff --git a/panda/src/physx/physxJoint.cxx b/panda/src/physx/physxJoint.cxx index d59c3418ca..49a26ebd0e 100644 --- a/panda/src/physx/physxJoint.cxx +++ b/panda/src/physx/physxJoint.cxx @@ -101,9 +101,8 @@ set_name(const char *name) { nassertv(_error_type == ET_ok); - free(_name); - _name = strdup(name); - ptr()->setName(_name); + _name = name ? name : ""; + ptr()->setName(_name.c_str()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxJoint.h b/panda/src/physx/physxJoint.h index 51e04850e6..d465fda43a 100644 --- a/panda/src/physx/physxJoint.h +++ b/panda/src/physx/physxJoint.h @@ -72,7 +72,8 @@ public: protected: INLINE PhysxJoint(); - char *_name; +private: + string _name; //////////////////////////////////////////////////////////////////// public: diff --git a/panda/src/physx/physxJointDesc.I b/panda/src/physx/physxJointDesc.I index cdc7065591..df059a4e60 100644 --- a/panda/src/physx/physxJointDesc.I +++ b/panda/src/physx/physxJointDesc.I @@ -22,7 +22,6 @@ INLINE PhysxJointDesc:: PhysxJointDesc() { - _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -33,6 +32,5 @@ PhysxJointDesc() { INLINE PhysxJointDesc:: ~PhysxJointDesc() { - free(_name); } diff --git a/panda/src/physx/physxJointDesc.cxx b/panda/src/physx/physxJointDesc.cxx index 0113721161..811f489028 100644 --- a/panda/src/physx/physxJointDesc.cxx +++ b/panda/src/physx/physxJointDesc.cxx @@ -23,9 +23,8 @@ void PhysxJointDesc:: set_name(const char *name) { - free(_name); - _name = strdup(name); - ptr()->name = _name; + _name = name ? name : ""; + ptr()->name = _name.c_str(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxJointDesc.h b/panda/src/physx/physxJointDesc.h index bdd6fea4a2..4de32ff6c5 100644 --- a/panda/src/physx/physxJointDesc.h +++ b/panda/src/physx/physxJointDesc.h @@ -58,7 +58,9 @@ PUBLISHED: public: virtual NxJointDesc *ptr() const = 0; - char *_name; + +private: + string _name; protected: INLINE PhysxJointDesc(); diff --git a/panda/src/physx/physxPlaneShape.I b/panda/src/physx/physxPlaneShape.I index 702f1df453..96c529e972 100644 --- a/panda/src/physx/physxPlaneShape.I +++ b/panda/src/physx/physxPlaneShape.I @@ -32,6 +32,5 @@ PhysxPlaneShape() : PhysxShape() { INLINE PhysxPlaneShape:: ~PhysxPlaneShape() { - free(_name); } diff --git a/panda/src/physx/physxPlaneShape.cxx b/panda/src/physx/physxPlaneShape.cxx index 13ac3923a6..8d33fa8289 100644 --- a/panda/src/physx/physxPlaneShape.cxx +++ b/panda/src/physx/physxPlaneShape.cxx @@ -30,6 +30,8 @@ link(NxShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; actor->_shapes.add(this); } diff --git a/panda/src/physx/physxPlaneShapeDesc.I b/panda/src/physx/physxPlaneShapeDesc.I index 3a44e587a8..08b9d55460 100644 --- a/panda/src/physx/physxPlaneShapeDesc.I +++ b/panda/src/physx/physxPlaneShapeDesc.I @@ -44,7 +44,7 @@ INLINE void PhysxPlaneShapeDesc:: set_to_default() { _desc.setToDefault(); - _desc.name = _name; + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxPointInPlaneJoint.I b/panda/src/physx/physxPointInPlaneJoint.I index f2b2c63670..4a60567141 100644 --- a/panda/src/physx/physxPointInPlaneJoint.I +++ b/panda/src/physx/physxPointInPlaneJoint.I @@ -32,6 +32,5 @@ PhysxPointInPlaneJoint() : PhysxJoint() { INLINE PhysxPointInPlaneJoint:: ~PhysxPointInPlaneJoint() { - free(_name); } diff --git a/panda/src/physx/physxPointInPlaneJoint.cxx b/panda/src/physx/physxPointInPlaneJoint.cxx index f533ccb4ba..33f5299ab4 100644 --- a/panda/src/physx/physxPointInPlaneJoint.cxx +++ b/panda/src/physx/physxPointInPlaneJoint.cxx @@ -29,6 +29,8 @@ link(NxJoint *jointPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(jointPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_joints.add(this); } diff --git a/panda/src/physx/physxPointInPlaneJointDesc.I b/panda/src/physx/physxPointInPlaneJointDesc.I index 5d8d0f518e..fbb921a466 100644 --- a/panda/src/physx/physxPointInPlaneJointDesc.I +++ b/panda/src/physx/physxPointInPlaneJointDesc.I @@ -22,7 +22,7 @@ INLINE PhysxPointInPlaneJointDesc:: PhysxPointInPlaneJointDesc() : PhysxJointDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxPointInPlaneJointDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxPointOnLineJoint.I b/panda/src/physx/physxPointOnLineJoint.I index 541ccf1704..836c1d0826 100644 --- a/panda/src/physx/physxPointOnLineJoint.I +++ b/panda/src/physx/physxPointOnLineJoint.I @@ -32,6 +32,5 @@ PhysxPointOnLineJoint() : PhysxJoint() { INLINE PhysxPointOnLineJoint:: ~PhysxPointOnLineJoint() { - free(_name); } diff --git a/panda/src/physx/physxPointOnLineJoint.cxx b/panda/src/physx/physxPointOnLineJoint.cxx index 7d7be5b833..e0de51671a 100644 --- a/panda/src/physx/physxPointOnLineJoint.cxx +++ b/panda/src/physx/physxPointOnLineJoint.cxx @@ -29,6 +29,8 @@ link(NxJoint *jointPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(jointPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_joints.add(this); } diff --git a/panda/src/physx/physxPointOnLineJointDesc.I b/panda/src/physx/physxPointOnLineJointDesc.I index 7ac49734c3..6bac93e08d 100644 --- a/panda/src/physx/physxPointOnLineJointDesc.I +++ b/panda/src/physx/physxPointOnLineJointDesc.I @@ -22,7 +22,7 @@ INLINE PhysxPointOnLineJointDesc:: PhysxPointOnLineJointDesc() : PhysxJointDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxPointOnLineJointDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxPrismaticJoint.I b/panda/src/physx/physxPrismaticJoint.I index d1127350c6..91d82dce03 100644 --- a/panda/src/physx/physxPrismaticJoint.I +++ b/panda/src/physx/physxPrismaticJoint.I @@ -32,6 +32,5 @@ PhysxPrismaticJoint() : PhysxJoint() { INLINE PhysxPrismaticJoint:: ~PhysxPrismaticJoint() { - free(_name); } diff --git a/panda/src/physx/physxPrismaticJoint.cxx b/panda/src/physx/physxPrismaticJoint.cxx index 9d080c43af..0ee94f8955 100644 --- a/panda/src/physx/physxPrismaticJoint.cxx +++ b/panda/src/physx/physxPrismaticJoint.cxx @@ -29,6 +29,8 @@ link(NxJoint *jointPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(jointPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_joints.add(this); } diff --git a/panda/src/physx/physxPrismaticJointDesc.I b/panda/src/physx/physxPrismaticJointDesc.I index 86bf6fef74..39a2a52c72 100644 --- a/panda/src/physx/physxPrismaticJointDesc.I +++ b/panda/src/physx/physxPrismaticJointDesc.I @@ -22,7 +22,7 @@ INLINE PhysxPrismaticJointDesc:: PhysxPrismaticJointDesc() : PhysxJointDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxPrismaticJointDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxPulleyJoint.I b/panda/src/physx/physxPulleyJoint.I index b4d12ca638..b3104276ee 100644 --- a/panda/src/physx/physxPulleyJoint.I +++ b/panda/src/physx/physxPulleyJoint.I @@ -32,6 +32,5 @@ PhysxPulleyJoint() : PhysxJoint() { INLINE PhysxPulleyJoint:: ~PhysxPulleyJoint() { - free(_name); } diff --git a/panda/src/physx/physxPulleyJoint.cxx b/panda/src/physx/physxPulleyJoint.cxx index 41010ba6cc..5ec655bcb5 100644 --- a/panda/src/physx/physxPulleyJoint.cxx +++ b/panda/src/physx/physxPulleyJoint.cxx @@ -30,6 +30,8 @@ link(NxJoint *jointPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(jointPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_joints.add(this); } diff --git a/panda/src/physx/physxPulleyJointDesc.I b/panda/src/physx/physxPulleyJointDesc.I index bd6f03f155..56a340c908 100644 --- a/panda/src/physx/physxPulleyJointDesc.I +++ b/panda/src/physx/physxPulleyJointDesc.I @@ -22,7 +22,7 @@ INLINE PhysxPulleyJointDesc:: PhysxPulleyJointDesc() : PhysxJointDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxPulleyJointDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxRevoluteJoint.cxx b/panda/src/physx/physxRevoluteJoint.cxx index 3fa678aa63..5fdbe4d983 100644 --- a/panda/src/physx/physxRevoluteJoint.cxx +++ b/panda/src/physx/physxRevoluteJoint.cxx @@ -32,6 +32,8 @@ link(NxJoint *jointPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(jointPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_joints.add(this); } diff --git a/panda/src/physx/physxRevoluteJointDesc.I b/panda/src/physx/physxRevoluteJointDesc.I index 1da2807e9c..8b819f07c6 100644 --- a/panda/src/physx/physxRevoluteJointDesc.I +++ b/panda/src/physx/physxRevoluteJointDesc.I @@ -22,7 +22,7 @@ INLINE PhysxRevoluteJointDesc:: PhysxRevoluteJointDesc() : PhysxJointDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxRevoluteJointDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxScene.cxx b/panda/src/physx/physxScene.cxx index a85f9cb3ec..3d7f1dd12b 100644 --- a/panda/src/physx/physxScene.cxx +++ b/panda/src/physx/physxScene.cxx @@ -395,11 +395,6 @@ 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; } @@ -710,7 +705,7 @@ create_controller(PhysxControllerDesc &desc) { nassertr(controllerPtr, NULL); controller->link(controllerPtr); - controllerPtr->getActor()->setName(""); + controller->get_actor()->set_name(""); return controller; } @@ -764,7 +759,6 @@ create_joint(PhysxJointDesc &desc) { nassertr(jointPtr, NULL); joint->link(jointPtr); - joint->set_name(desc.ptr()->name); return joint; } @@ -826,11 +820,6 @@ 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; } @@ -884,7 +873,6 @@ create_force_field_shape_group(PhysxForceFieldShapeGroupDesc &desc) { nassertr(groupPtr, NULL); group->link(groupPtr); - group->set_name(strdup(desc._desc.name)); return group; } @@ -940,7 +928,6 @@ create_cloth(PhysxClothDesc &desc) { nassertr(clothPtr, NULL); cloth->link(clothPtr); - cloth->set_name(desc._desc.name); return cloth; } diff --git a/panda/src/physx/physxShape.I b/panda/src/physx/physxShape.I index 3a1b44bad2..2156726ebf 100644 --- a/panda/src/physx/physxShape.I +++ b/panda/src/physx/physxShape.I @@ -22,7 +22,6 @@ INLINE PhysxShape:: PhysxShape() : PhysxObject() { - _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -44,10 +43,8 @@ ls() const { INLINE void PhysxShape:: ls(ostream &out, int indent_level) const { - const char *name = _name ? _name : ""; - indent(out, indent_level) << get_type().get_name() - << " " << name + << " " << _name << " (at 0x" << this << ")\n"; } diff --git a/panda/src/physx/physxShape.cxx b/panda/src/physx/physxShape.cxx index 1abac2056e..4e60387a82 100644 --- a/panda/src/physx/physxShape.cxx +++ b/panda/src/physx/physxShape.cxx @@ -112,9 +112,8 @@ set_name(const char *name) { nassertv(_error_type == ET_ok); - free(_name); - _name = strdup(name); - ptr()->setName(_name); + _name = name ? name : ""; + ptr()->setName(_name.c_str()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxShape.h b/panda/src/physx/physxShape.h index e1923a82b9..87885a382a 100644 --- a/panda/src/physx/physxShape.h +++ b/panda/src/physx/physxShape.h @@ -86,7 +86,8 @@ public: protected: INLINE PhysxShape(); - char *_name; +private: + string _name; //////////////////////////////////////////////////////////////////// public: diff --git a/panda/src/physx/physxShapeDesc.I b/panda/src/physx/physxShapeDesc.I index 20aa3d79b4..9065cfa569 100644 --- a/panda/src/physx/physxShapeDesc.I +++ b/panda/src/physx/physxShapeDesc.I @@ -22,7 +22,6 @@ INLINE PhysxShapeDesc:: PhysxShapeDesc() { - _name = NULL; } //////////////////////////////////////////////////////////////////// @@ -33,6 +32,5 @@ PhysxShapeDesc() { INLINE PhysxShapeDesc:: ~PhysxShapeDesc() { - free(_name); } diff --git a/panda/src/physx/physxShapeDesc.cxx b/panda/src/physx/physxShapeDesc.cxx index 45f6dcca5d..f2369737ef 100644 --- a/panda/src/physx/physxShapeDesc.cxx +++ b/panda/src/physx/physxShapeDesc.cxx @@ -24,9 +24,8 @@ void PhysxShapeDesc:: set_name(const char *name) { - free(_name); - _name = strdup(name); - ptr()->name = _name; + _name = name ? name : ""; + ptr()->name = _name.c_str(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxShapeDesc.h b/panda/src/physx/physxShapeDesc.h index 6de11cbcf2..b411c4a641 100644 --- a/panda/src/physx/physxShapeDesc.h +++ b/panda/src/physx/physxShapeDesc.h @@ -61,7 +61,9 @@ PUBLISHED: public: virtual NxShapeDesc *ptr() const = 0; - char *_name; + +private: + string _name; protected: INLINE PhysxShapeDesc(); diff --git a/panda/src/physx/physxSphereForceFieldShape.I b/panda/src/physx/physxSphereForceFieldShape.I index a82de68c61..b31ee29b69 100644 --- a/panda/src/physx/physxSphereForceFieldShape.I +++ b/panda/src/physx/physxSphereForceFieldShape.I @@ -32,6 +32,5 @@ PhysxSphereForceFieldShape() : PhysxForceFieldShape() { INLINE PhysxSphereForceFieldShape:: ~PhysxSphereForceFieldShape() { - free(_name); } diff --git a/panda/src/physx/physxSphereForceFieldShape.cxx b/panda/src/physx/physxSphereForceFieldShape.cxx index c4e48a3f5f..e91b8402e2 100644 --- a/panda/src/physx/physxSphereForceFieldShape.cxx +++ b/panda/src/physx/physxSphereForceFieldShape.cxx @@ -29,6 +29,8 @@ link(NxForceFieldShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; group->_shapes.add(this); } diff --git a/panda/src/physx/physxSphereForceFieldShapeDesc.I b/panda/src/physx/physxSphereForceFieldShapeDesc.I index 6242acf5fe..33f6c6171f 100644 --- a/panda/src/physx/physxSphereForceFieldShapeDesc.I +++ b/panda/src/physx/physxSphereForceFieldShapeDesc.I @@ -22,7 +22,7 @@ INLINE PhysxSphereForceFieldShapeDesc:: PhysxSphereForceFieldShapeDesc() : PhysxForceFieldShapeDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxSphereForceFieldShapeDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxSphereShape.I b/panda/src/physx/physxSphereShape.I index 9fca388726..d01268c3e9 100644 --- a/panda/src/physx/physxSphereShape.I +++ b/panda/src/physx/physxSphereShape.I @@ -32,6 +32,5 @@ PhysxSphereShape() : PhysxShape() { INLINE PhysxSphereShape:: ~PhysxSphereShape() { - free(_name); } diff --git a/panda/src/physx/physxSphereShape.cxx b/panda/src/physx/physxSphereShape.cxx index afd4e2066f..427717f80b 100644 --- a/panda/src/physx/physxSphereShape.cxx +++ b/panda/src/physx/physxSphereShape.cxx @@ -29,6 +29,8 @@ link(NxShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; actor->_shapes.add(this); } diff --git a/panda/src/physx/physxSphereShapeDesc.I b/panda/src/physx/physxSphereShapeDesc.I index 9fb3aca244..832b5c2387 100644 --- a/panda/src/physx/physxSphereShapeDesc.I +++ b/panda/src/physx/physxSphereShapeDesc.I @@ -44,7 +44,7 @@ INLINE void PhysxSphereShapeDesc:: set_to_default() { _desc.setToDefault(); - _desc.name = _name; + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxSphericalJoint.I b/panda/src/physx/physxSphericalJoint.I index 5e7c3f0a20..271b869f63 100644 --- a/panda/src/physx/physxSphericalJoint.I +++ b/panda/src/physx/physxSphericalJoint.I @@ -32,6 +32,5 @@ PhysxSphericalJoint() : PhysxJoint() { INLINE PhysxSphericalJoint:: ~PhysxSphericalJoint() { - free(_name); } diff --git a/panda/src/physx/physxSphericalJoint.cxx b/panda/src/physx/physxSphericalJoint.cxx index ba571e1506..227f6c470c 100644 --- a/panda/src/physx/physxSphericalJoint.cxx +++ b/panda/src/physx/physxSphericalJoint.cxx @@ -29,6 +29,8 @@ link(NxJoint *jointPtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(jointPtr->getName()); + PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_joints.add(this); } diff --git a/panda/src/physx/physxSphericalJointDesc.I b/panda/src/physx/physxSphericalJointDesc.I index 864d771e38..ae192cf7a8 100644 --- a/panda/src/physx/physxSphericalJointDesc.I +++ b/panda/src/physx/physxSphericalJointDesc.I @@ -22,7 +22,7 @@ INLINE PhysxSphericalJointDesc:: PhysxSphericalJointDesc() : PhysxJointDesc() { - _desc.name = ""; + set_to_default(); } //////////////////////////////////////////////////////////////////// @@ -44,6 +44,7 @@ INLINE void PhysxSphericalJointDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxTriangleMeshShape.I b/panda/src/physx/physxTriangleMeshShape.I index 333639c53a..a1244f15e5 100644 --- a/panda/src/physx/physxTriangleMeshShape.I +++ b/panda/src/physx/physxTriangleMeshShape.I @@ -32,6 +32,5 @@ PhysxTriangleMeshShape() : PhysxShape() { INLINE PhysxTriangleMeshShape:: ~PhysxTriangleMeshShape() { - free(_name); } diff --git a/panda/src/physx/physxTriangleMeshShape.cxx b/panda/src/physx/physxTriangleMeshShape.cxx index ed9a9968ce..41e286fc28 100644 --- a/panda/src/physx/physxTriangleMeshShape.cxx +++ b/panda/src/physx/physxTriangleMeshShape.cxx @@ -29,6 +29,8 @@ link(NxShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; actor->_shapes.add(this); } diff --git a/panda/src/physx/physxTriangleMeshShapeDesc.I b/panda/src/physx/physxTriangleMeshShapeDesc.I index 49b6048e95..964f0519da 100644 --- a/panda/src/physx/physxTriangleMeshShapeDesc.I +++ b/panda/src/physx/physxTriangleMeshShapeDesc.I @@ -44,7 +44,7 @@ INLINE void PhysxTriangleMeshShapeDesc:: set_to_default() { _desc.setToDefault(); - _desc.name = _name; + set_name(""); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physx/physxWheelShape.I b/panda/src/physx/physxWheelShape.I index 4985e2608c..a8f0c6bfe1 100644 --- a/panda/src/physx/physxWheelShape.I +++ b/panda/src/physx/physxWheelShape.I @@ -32,6 +32,5 @@ PhysxWheelShape() : PhysxShape() { INLINE PhysxWheelShape:: ~PhysxWheelShape() { - free(_name); } diff --git a/panda/src/physx/physxWheelShape.cxx b/panda/src/physx/physxWheelShape.cxx index e9b7baaba1..10a6278870 100644 --- a/panda/src/physx/physxWheelShape.cxx +++ b/panda/src/physx/physxWheelShape.cxx @@ -30,6 +30,8 @@ link(NxShape *shapePtr) { _ptr->userData = this; _error_type = ET_ok; + set_name(shapePtr->getName()); + PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; actor->_shapes.add(this); } diff --git a/panda/src/physx/physxWheelShapeDesc.cxx b/panda/src/physx/physxWheelShapeDesc.cxx index 188ec487fb..776fd1e32b 100644 --- a/panda/src/physx/physxWheelShapeDesc.cxx +++ b/panda/src/physx/physxWheelShapeDesc.cxx @@ -23,8 +23,8 @@ void PhysxWheelShapeDesc:: set_to_default() { _desc.setToDefault(); + set_name(""); - _desc.name = _name; _desc.localPose = PhysxManager::mat4_to_nxMat34(LMatrix4f::y_to_z_up_mat()); }