1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
---|---|
2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
3 | #include "BsPhysXFixedJoint.h" |
4 | #include "BsFPhysXJoint.h" |
5 | #include "BsPhysXRigidbody.h" |
6 | #include "extensions/PxFixedJoint.h" |
7 | #include "PxRigidDynamic.h" |
8 | |
9 | using namespace physx; |
10 | |
11 | namespace bs |
12 | { |
13 | PhysXFixedJoint::PhysXFixedJoint(PxPhysics* physx, const FIXED_JOINT_DESC& desc) |
14 | :FixedJoint(desc) |
15 | { |
16 | PxRigidActor* actor0 = nullptr; |
17 | if (desc.bodies[0].body != nullptr) |
18 | actor0 = static_cast<PhysXRigidbody*>(desc.bodies[0].body)->_getInternal(); |
19 | |
20 | PxRigidActor* actor1 = nullptr; |
21 | if (desc.bodies[1].body != nullptr) |
22 | actor1 = static_cast<PhysXRigidbody*>(desc.bodies[1].body)->_getInternal(); |
23 | |
24 | PxTransform tfrm0 = toPxTransform(desc.bodies[0].position, desc.bodies[0].rotation); |
25 | PxTransform tfrm1 = toPxTransform(desc.bodies[1].position, desc.bodies[1].rotation); |
26 | |
27 | PxFixedJoint* joint = PxFixedJointCreate(*physx, actor0, tfrm0, actor1, tfrm1); |
28 | joint->userData = this; |
29 | |
30 | mInternal = bs_new<FPhysXJoint>(joint, desc); |
31 | } |
32 | |
33 | PhysXFixedJoint::~PhysXFixedJoint() |
34 | { |
35 | bs_delete(mInternal); |
36 | } |
37 | } |