does getUnscaledPoints in btConvexHullShape really work?

nornor71
Posts: 1
Joined: Tue Mar 29, 2011 8:44 am

does getUnscaledPoints in btConvexHullShape really work?

Post by nornor71 »

i want to use the function "getUnscaledPoints" in btConvexHullShape to change all position of vertex every frame,beacuse my object is binded to skeleton.but it seems not work at all,btConvexHullShape didn't update and stay on original shape,here is my code:

Code: Select all


for(int ii = 0;ii< ((btConvexHullShape*)(rigidShape->getPointer()))->getNumPoints();ii++)
			{
				 
				 
				f32 tmp = ((S3DVertex*)(((IAnimatedMeshSceneNode*)Model)->getMesh()->getMeshBuffer(i)->getVertices()))[ii].Pos.X;
				 
				((btConvexHullShape*)(rigidShape->getPointer()))->getUnscaledPoints()[ii].setX(tmp);
				f32 tmpAfter = ((btConvexHullShape*)(rigidShape->getPointer()))->getUnscaledPoints()[ii].getX();
			 
					((btConvexHullShape*)(rigidShape->getPointer()))->getUnscaledPoints()[ii].setY(((S3DVertex*)(((IAnimatedMeshSceneNode*)Model)->getMesh()->getMeshBuffer(i)->getVertices()))[ii].Pos.Y);
				((btConvexHullShape*)(rigidShape->getPointer()))->getUnscaledPoints()[ii].setZ(((S3DVertex*)(((IAnimatedMeshSceneNode*)Model)->getMesh()->getMeshBuffer(i)->getVertices()))[ii].Pos.Z);
				
			}
			 
			((btConvexHullShape*)(rigidShape->getPointer()))->recalcLocalAabb();
			 
			 		}
anyone has experiment of converting binded skin to rigidbody and update shape? thanks for your answer.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: does getUnscaledPoints in btConvexHullShape really work?

Post by Erwin Coumans »

You should be able to change the vertices/points in a btConvexHullShape.

Just make sure to invalidate/remove the existing contact points. You can do this by removing and re-adding the object to the world. Alternatively, you can use the following snippet:

Code: Select all

//clear all contact points involving the object. Note: this is a slow/unoptimized operation.
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(
object->getBroadphaseHandle(),
getDynamicsWorld()->getDispatcher()
);
Thanks,
Erwin