Sign in to follow this  

difference between createShape(...) method and attachShape(...)

Recommended Posts

Hello everyone! I try to create a vehicle with PhysX. I create RigidDynamic, Shapes for wheels, Shape for a chassis and etc...
I want to attach shapes to RigidDynamic. Code:
auto physicsMaterialParam = colliderComponent -> getPhysicsMaterialParam();
auto geometry = colliderComponent -> getGeometry();
auto qryFilterData = colliderComponent -> getQueryFilterData();
auto simFilterData = colliderComponent -> getSimulationFilterData();

auto physicsMaterial = BTSPhysics :: getInstance() -> getPhysicsSDK() -> createMaterial( physicsMaterialParam.restitution, physicsMaterialParam.staticFriction, physicsMaterialParam.dynamicFriction );
auto collider = _component -> getPhysicsActor() -> createShape( *geometry, *physicsMaterial );

collider -> setLocalPose( PxTransform( position, rotation ) );
collider -> setQueryFilterData( qryFilterData );
collider -> setSimulationFilterData( simFilterData );
How you can see, I use createShape(...) method of PxRigidDynamic class. With this code, the wheels rotate. It's ok.

But I want to encapsulate creation and initialize of PxShape in other class. I have found new suitable method of PxRigidDynamic class - attachShape. So, code:
// somewhere created PxShape
auto collider = colliderComponent -> getCollider();
collider -> setLocalPose( PxTransform( position, rotation ) );
_component -> getPhysicsActor() -> attachShape( *collider );
It's ok, but....but the wheels dont rotate now. 

So, there is my question: what's the difference between createShape(...) method and attachShape(...)?


P.S. I'm from Russia, and my English is poor:(

Sorry in advance )

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this