BsPhysXFixedJoint.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsPhysXFixedJoint.h"
  4. #include "BsFPhysxJoint.h"
  5. #include "BsPhysXRigidbody.h"
  6. #include "extensions\PxFixedJoint.h"
  7. #include "PxRigidDynamic.h"
  8. using namespace physx;
  9. namespace bs
  10. {
  11. PhysXFixedJoint::PhysXFixedJoint(PxPhysics* physx, const FIXED_JOINT_DESC& desc)
  12. :FixedJoint(desc)
  13. {
  14. PxRigidActor* actor0 = nullptr;
  15. if (desc.bodies[0].body != nullptr)
  16. actor0 = static_cast<PhysXRigidbody*>(desc.bodies[0].body)->_getInternal();
  17. PxRigidActor* actor1 = nullptr;
  18. if (desc.bodies[1].body != nullptr)
  19. actor1 = static_cast<PhysXRigidbody*>(desc.bodies[1].body)->_getInternal();
  20. PxTransform tfrm0 = toPxTransform(desc.bodies[0].position, desc.bodies[0].rotation);
  21. PxTransform tfrm1 = toPxTransform(desc.bodies[1].position, desc.bodies[1].rotation);
  22. PxFixedJoint* joint = PxFixedJointCreate(*physx, actor0, tfrm0, actor1, tfrm1);
  23. joint->userData = this;
  24. mInternal = bs_new<FPhysXJoint>(joint, desc);
  25. }
  26. PhysXFixedJoint::~PhysXFixedJoint()
  27. {
  28. bs_delete(mInternal);
  29. }
  30. }