Advertisement

Physx PxBoxGeometry always get bias from original Boundingbox

Started by October 25, 2015 09:50 AM
-1 comments, last by 562538332 9 years, 3 months ago
I want to attach a PxBoxGeometry to the PxRigidDynamic as a simulation data because Physx doesn't allow TriangleMesh being simulated in a simulated PxRigidDynamic.
So I create a PxShape with a PxBoxGeometry like this:
vec3 halfSize = boundingBox.GetHalfSize();
PxBoxGeometry boxGeometry = PxBoxGeometry(halfSize.x, halfSize.y, halfSize.z);
PxShape* boxShape = physics->createShape(boxGeometry, *material);
body->attachShape(*boxShape);
After that I found the boxShape got bias from the original. In order to prove that, I also created a ConvexMesh using the box's vertices:
convexDesc.points.count = 8;
convexDesc.points.stride = sizeof(vec3);
convexDesc.points.data = boundingBox.GetAllCorners();
convexDesc.flags = PxConvexFlag::eCOMPUTE_CONVEX;
PxDefaultMemoryOutputStream stream;
if(cooking->cookConvexMesh(convexDesc, stream))
{
PxDefaultMemoryInputData input(stream.getData(), stream.getSize());
PxConvexMesh* convexMesh = physics->createConvexMesh(input);
PxConvexMeshGeometry convexGeomtry = PxConvexMeshGeometry(convexMesh);
PxShape *convexShape = physics->createShape(convexGeomtry, *material);
body->attachShape(*convexShape);
}
The code above worked very well. The Convex really surrounded the original boundingbox(It actually was the original boundingbox).
That is how the two bounding box get different position:
[attachment=29445:box.JPG]
Note that for both the PxBoxGeometry Shape and the PxConvexMeshGeometry Shape I haven't set localPosition beacuse it's not necessary.
That's is very confusing! After that I also created a PxSphereGeometry and found it also got bias from original.
What is the reason?

This topic is closed to new replies.

Advertisement