Jump to content
  • Advertisement
Sign in to follow this  
bretbas

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

This topic is 558 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement

Are you attaching the shape after the actor is added to the scene ?

No, In the first, I add all of shapes to an actor. After that I add the actor to the scene

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!