Fixed bug with internal debug names getting lost.

This commit is contained in:
enn0x 2010-06-28 18:22:19 +00:00
parent c5a67c5f63
commit 76c3f1268b
72 changed files with 197 additions and 45 deletions

View File

@ -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()) {

View File

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

View File

@ -197,6 +197,7 @@ private:
NxActor *_ptr;
NodePath _np;
PT(PhysxController) _controller;
char *_name;
////////////////////////////////////////////////////////////////////
public:

View File

@ -22,7 +22,8 @@
INLINE PhysxActorDesc::
PhysxActorDesc() {
_desc.name = "";
_name = NULL;
_desc.name = _name;
}
////////////////////////////////////////////////////////////////////
@ -33,6 +34,7 @@ PhysxActorDesc() {
INLINE PhysxActorDesc::
~PhysxActorDesc() {
free(_name);
}
////////////////////////////////////////////////////////////////////

View File

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

View File

@ -54,6 +54,7 @@ PUBLISHED:
public:
NxActorDesc _desc;
char *_name;
};
#include "physxActorDesc.I"

View File

@ -32,5 +32,6 @@ PhysxBoxForceFieldShape() : PhysxForceFieldShape() {
INLINE PhysxBoxForceFieldShape::
~PhysxBoxForceFieldShape() {
free(_name);
}

View File

@ -32,5 +32,6 @@ PhysxBoxShape() : PhysxShape() {
INLINE PhysxBoxShape::
~PhysxBoxShape() {
free(_name);
}

View File

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

View File

@ -32,5 +32,6 @@ PhysxCapsuleForceFieldShape() : PhysxForceFieldShape() {
INLINE PhysxCapsuleForceFieldShape::
~PhysxCapsuleForceFieldShape() {
free(_name);
}

View File

@ -32,5 +32,6 @@ PhysxCapsuleShape() : PhysxShape() {
INLINE PhysxCapsuleShape::
~PhysxCapsuleShape() {
free(_name);
}

View File

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

View File

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

View File

@ -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);
}
////////////////////////////////////////////////////////////////////

View File

@ -108,6 +108,7 @@ public:
private:
NxCloth *_ptr;
PT(PhysxClothNode) _node;
char *_name;
////////////////////////////////////////////////////////////////////
public:

View File

@ -22,7 +22,8 @@
INLINE PhysxClothDesc::
PhysxClothDesc() {
_desc.name = "";
_name = NULL;
_desc.name = _name;
}
////////////////////////////////////////////////////////////////////
@ -33,6 +34,7 @@ PhysxClothDesc() {
INLINE PhysxClothDesc::
~PhysxClothDesc() {
free(_name);
}
////////////////////////////////////////////////////////////////////

View File

@ -24,7 +24,9 @@
void PhysxClothDesc::
set_name(const char *name) {
_desc.name = name;
free(_name);
_name = strdup(name);
_desc.name = _name;
}
////////////////////////////////////////////////////////////////////

View File

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

View File

@ -32,5 +32,6 @@ PhysxConvexForceFieldShape() : PhysxForceFieldShape() {
INLINE PhysxConvexForceFieldShape::
~PhysxConvexForceFieldShape() {
free(_name);
}

View File

@ -32,5 +32,6 @@ PhysxConvexShape() : PhysxShape() {
INLINE PhysxConvexShape::
~PhysxConvexShape() {
free(_name);
}

View File

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

View File

@ -32,5 +32,6 @@ PhysxCylindricalJoint() : PhysxJoint() {
INLINE PhysxCylindricalJoint::
~PhysxCylindricalJoint() {
free(_name);
}

View File

@ -32,5 +32,6 @@ PhysxD6Joint() : PhysxJoint() {
INLINE PhysxD6Joint::
~PhysxD6Joint() {
free(_name);
}

View File

@ -32,5 +32,6 @@ PhysxDistanceJoint() : PhysxJoint() {
INLINE PhysxDistanceJoint::
~PhysxDistanceJoint() {
free(_name);
}

View File

@ -32,5 +32,6 @@ PhysxFixedJoint() : PhysxJoint() {
INLINE PhysxFixedJoint::
~PhysxFixedJoint() {
free(_name);
}

View File

@ -22,6 +22,7 @@
INLINE PhysxForceField::
PhysxForceField() : PhysxObject() {
_name = NULL;
}
////////////////////////////////////////////////////////////////////
@ -32,6 +33,7 @@ PhysxForceField() : PhysxObject() {
INLINE PhysxForceField::
~PhysxForceField() {
free(_name);
}
////////////////////////////////////////////////////////////////////

View File

@ -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);
}
////////////////////////////////////////////////////////////////////

View File

@ -68,6 +68,7 @@ public:
private:
NxForceField *_ptr;
char *_name;
////////////////////////////////////////////////////////////////////
public:

View File

@ -22,7 +22,7 @@
INLINE PhysxForceFieldDesc::
PhysxForceFieldDesc() {
_desc.name = "";
_desc.name = NULL;
}
////////////////////////////////////////////////////////////////////
@ -33,6 +33,7 @@ PhysxForceFieldDesc() {
INLINE PhysxForceFieldDesc::
~PhysxForceFieldDesc() {
free(_name);
}
////////////////////////////////////////////////////////////////////

View File

@ -26,7 +26,9 @@
void PhysxForceFieldDesc::
set_name(const char *name) {
_desc.name = name;
free(_name);
_name = strdup(name);
_desc.name = _name;
}
////////////////////////////////////////////////////////////////////

View File

@ -65,6 +65,8 @@ public:
NxForceFieldDesc _desc;
NxForceFieldLinearKernelDesc _kernel;
char *_name;
};
#include "physxForceFieldDesc.I"

View File

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

View File

@ -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);
}
////////////////////////////////////////////////////////////////////

View File

@ -62,6 +62,8 @@ public:
protected:
INLINE PhysxForceFieldShape();
char *_name;
////////////////////////////////////////////////////////////////////
public:
static TypeHandle get_class_type() {

View File

@ -22,5 +22,17 @@
INLINE PhysxForceFieldShapeDesc::
PhysxForceFieldShapeDesc() {
_name = NULL;
}
////////////////////////////////////////////////////////////////////
// Function: PhysxForceFieldShapeDesc::Destructor
// Access: Protected
// Description:
////////////////////////////////////////////////////////////////////
INLINE PhysxForceFieldShapeDesc::
~PhysxForceFieldShapeDesc() {
free(_name);
}

View File

@ -23,7 +23,9 @@
void PhysxForceFieldShapeDesc::
set_name(const char *name) {
ptr()->name = name;
free(_name);
_name = strdup(name);
ptr()->name = _name;
}
////////////////////////////////////////////////////////////////////

View File

@ -43,9 +43,11 @@ PUBLISHED:
public:
virtual NxForceFieldShapeDesc *ptr() const = 0;
char *_name;
protected:
INLINE PhysxForceFieldShapeDesc();
INLINE ~PhysxForceFieldShapeDesc();
};
#include "physxForceFieldShapeDesc.I"

View File

@ -22,6 +22,7 @@
INLINE PhysxForceFieldShapeGroup::
PhysxForceFieldShapeGroup() : PhysxObject() {
_name = NULL;
}
////////////////////////////////////////////////////////////////////
@ -32,6 +33,7 @@ PhysxForceFieldShapeGroup() : PhysxObject() {
INLINE PhysxForceFieldShapeGroup::
~PhysxForceFieldShapeGroup() {
free(_name);
}
////////////////////////////////////////////////////////////////////

View File

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

View File

@ -69,6 +69,7 @@ public:
private:
NxForceFieldShapeGroup *_ptr;
char *_name;
////////////////////////////////////////////////////////////////////
public:

View File

@ -22,7 +22,7 @@
INLINE PhysxForceFieldShapeGroupDesc::
PhysxForceFieldShapeGroupDesc() {
_desc.name = "";
_desc.name = NULL;
}
////////////////////////////////////////////////////////////////////
@ -33,6 +33,7 @@ PhysxForceFieldShapeGroupDesc() {
INLINE PhysxForceFieldShapeGroupDesc::
~PhysxForceFieldShapeGroupDesc() {
free(_name);
}
////////////////////////////////////////////////////////////////////

View File

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

View File

@ -45,6 +45,7 @@ PUBLISHED:
public:
NxForceFieldShapeGroupDesc _desc;
char *_name;
};
#include "physxForceFieldShapeGroupDesc.I"

View File

@ -32,5 +32,6 @@ PhysxHeightFieldShape() : PhysxShape() {
INLINE PhysxHeightFieldShape::
~PhysxHeightFieldShape() {
free(_name);
}

View File

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

View File

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

View File

@ -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);
}
////////////////////////////////////////////////////////////////////

View File

@ -72,6 +72,8 @@ public:
protected:
INLINE PhysxJoint();
char *_name;
////////////////////////////////////////////////////////////////////
public:
static TypeHandle get_class_type() {

View File

@ -22,5 +22,17 @@
INLINE PhysxJointDesc::
PhysxJointDesc() {
_name = NULL;
}
////////////////////////////////////////////////////////////////////
// Function: PhysxJointDesc::Destructor
// Access: Protected
// Description:
////////////////////////////////////////////////////////////////////
INLINE PhysxJointDesc::
~PhysxJointDesc() {
free(_name);
}

View File

@ -23,7 +23,9 @@
void PhysxJointDesc::
set_name(const char *name) {
ptr()->name = name;
free(_name);
_name = strdup(name);
ptr()->name = _name;
}
////////////////////////////////////////////////////////////////////

View File

@ -58,9 +58,11 @@ PUBLISHED:
public:
virtual NxJointDesc *ptr() const = 0;
char *_name;
protected:
INLINE PhysxJointDesc();
INLINE ~PhysxJointDesc();
};
#include "physxJointDesc.I"

View File

@ -32,5 +32,6 @@ PhysxPlaneShape() : PhysxShape() {
INLINE PhysxPlaneShape::
~PhysxPlaneShape() {
free(_name);
}

View File

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

View File

@ -32,5 +32,6 @@ PhysxPointInPlaneJoint() : PhysxJoint() {
INLINE PhysxPointInPlaneJoint::
~PhysxPointInPlaneJoint() {
free(_name);
}

View File

@ -32,5 +32,6 @@ PhysxPointOnLineJoint() : PhysxJoint() {
INLINE PhysxPointOnLineJoint::
~PhysxPointOnLineJoint() {
free(_name);
}

View File

@ -32,5 +32,6 @@ PhysxPrismaticJoint() : PhysxJoint() {
INLINE PhysxPrismaticJoint::
~PhysxPrismaticJoint() {
free(_name);
}

View File

@ -32,5 +32,6 @@ PhysxPulleyJoint() : PhysxJoint() {
INLINE PhysxPulleyJoint::
~PhysxPulleyJoint() {
free(_name);
}

View File

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

View File

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

View File

@ -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);
}
////////////////////////////////////////////////////////////////////

View File

@ -86,6 +86,8 @@ public:
protected:
INLINE PhysxShape();
char *_name;
////////////////////////////////////////////////////////////////////
public:
static TypeHandle get_class_type() {

View File

@ -22,5 +22,17 @@
INLINE PhysxShapeDesc::
PhysxShapeDesc() {
_name = NULL;
}
////////////////////////////////////////////////////////////////////
// Function: PhysxShapeDesc::Destructor
// Access: Protected
// Description:
////////////////////////////////////////////////////////////////////
INLINE PhysxShapeDesc::
~PhysxShapeDesc() {
free(_name);
}

View File

@ -24,7 +24,9 @@
void PhysxShapeDesc::
set_name(const char *name) {
ptr()->name = name;
free(_name);
_name = strdup(name);
ptr()->name = _name;
}
////////////////////////////////////////////////////////////////////

View File

@ -61,9 +61,11 @@ PUBLISHED:
public:
virtual NxShapeDesc *ptr() const = 0;
char *_name;
protected:
INLINE PhysxShapeDesc();
INLINE ~PhysxShapeDesc();
};
#include "physxShapeDesc.I"

View File

@ -32,5 +32,6 @@ PhysxSphereForceFieldShape() : PhysxForceFieldShape() {
INLINE PhysxSphereForceFieldShape::
~PhysxSphereForceFieldShape() {
free(_name);
}

View File

@ -32,5 +32,6 @@ PhysxSphereShape() : PhysxShape() {
INLINE PhysxSphereShape::
~PhysxSphereShape() {
free(_name);
}

View File

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

View File

@ -32,5 +32,6 @@ PhysxSphericalJoint() : PhysxJoint() {
INLINE PhysxSphericalJoint::
~PhysxSphericalJoint() {
free(_name);
}

View File

@ -32,5 +32,6 @@ PhysxTriangleMeshShape() : PhysxShape() {
INLINE PhysxTriangleMeshShape::
~PhysxTriangleMeshShape() {
free(_name);
}

View File

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

View File

@ -32,5 +32,6 @@ PhysxWheelShape() : PhysxShape() {
INLINE PhysxWheelShape::
~PhysxWheelShape() {
free(_name);
}

View File

@ -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());
}