Updating NxOgre

mephisto

10-09-2011 15:24:57

Hello, today I am decided to add few things to NxOgre:
-all joints
-add getContact func. to NxOgre::Wheel. The PhysX analog is NxWheel::getContact( NxWheelContactData& ). This function return NxShape* when contact and NULL in other cases. I have added in PrototypeFunctions::WheelContactDataToNxWheelContactData. So the body of NxOgre::Wheel::getContact is :

Shape* Wheel::getContact(WheelContactData& dest) const
{
NxWheelDesc data;
NxShape* shape;
Functions::PrototypeFunctions::WheelContactDataToNxWheelContactData(dest, data);
shape = mWheelShape->getContact(data);
if(shape)
return Functions::ShapeFunctions::createDirtyShape(shape, NULL); // ambiguous
else
return Functions::ShapeFunctions::createNull(shape); // ambiguous
}


createDirtyShape takes RigidBody* as 2nd parameter but in the function body its not used.

createNull takes bool as 2nd parameter in the declaration but only one parameter in the definition.

bellow is the code:

FILE : "NxOgreShapeFunctions.h"
inline Shape* createNull(NxShape*);

FILE : "NxOgreShapeFunctions.cpp"
Shape* createNull(NxShape* shape, bool)
{
return 0;
}

Shape* createDirtyShape(NxShape* physx_shape, RigidBody* rigid_body)
{
Shape* shape = mFunctions[int(physx_shape->getType())] (physx_shape, true);
shape->setId(-1);
return shape;
}

mephisto

10-09-2011 15:38:07

Oh I see...for createNull fnc. the second parameter is for convintion only ( ShapeBinder ), bellow is the ShapeBinder. How should be the last two lines?

typedef Shape* (*ShapeFunction)(NxShape*, bool);

ShapeFunction mFunctions[NX_SHAPE_COUNT];

struct ShapeBinder
{

ShapeBinder()
{
mFunctions[NX_SHAPE_PLANE] = &createPlane;
mFunctions[NX_SHAPE_SPHERE] = &createSphere;
mFunctions[NX_SHAPE_BOX] = &createBox;
mFunctions[NX_SHAPE_CAPSULE] = &createCapsule;
mFunctions[NX_SHAPE_WHEEL] = &createWheel;
mFunctions[NX_SHAPE_CONVEX] = &createConvex;
mFunctions[NX_SHAPE_HEIGHTFIELD] = &createHeightField;
mFunctions[NX_SHAPE_MESH] = &createTriangleMesh;
mFunctions[NX_SHAPE_RAW_MESH] = &createNull;
mFunctions[NX_SHAPE_COMPOUND] = &createNull;
}

} gShapeBinder;

mephisto

10-09-2011 15:51:46

Another questions:
- The last parameter of NxWheelShapeData is NxMaterailIndex otherShapeMaterialIndex, I cannot find the equivalent in NxOgre.
- In PrototypeFunctions SphericalJointDescriptionToNxSphericalJointDescription and RevoluteJointDescriptionToNxRevoluteJointDescription use same part of code

desc.jointFlags = source.mJointFlags;
desc.localAnchor[0] = source.mLocalAnchor[0].as<NxVec3>();
desc.localAnchor[1] = source.mLocalAnchor[1].as<NxVec3>();
desc.localAxis[0] = source.mLocalAxis[0].as<NxVec3>();
desc.localAxis[1] = source.mLocalAxis[1].as<NxVec3>();
desc.localNormal[0] = source.mLocalNormal[0].as<NxVec3>();
desc.localNormal[1] = source.mLocalNormal[1].as<NxVec3>();

I suppose that we can simply replace this by this func. call:

void PrototypeFunctions::JointDescriptionToNxJointDescription(const JointDescription& source, NxJointDesc& desc)
{
desc.jointFlags = source.mJointFlags;
desc.localAnchor[0] = source.mLocalAnchor[0].as<NxVec3>();
desc.localAnchor[1] = source.mLocalAnchor[1].as<NxVec3>();
desc.localAxis[0] = source.mLocalAxis[0].as<NxVec3>();
desc.localAxis[1] = source.mLocalAxis[1].as<NxVec3>();
desc.localNormal[0] = source.mLocalNormal[0].as<NxVec3>();
desc.localNormal[1] = source.mLocalNormal[1].as<NxVec3>();
}