MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / FixedJoint

Method FixedJoint

src/constraint/FixedJoint.cpp:35–72  ·  view source on GitHub ↗

Constructor

Source from the content-addressed store, hash-verified

33
34// Constructor
35FixedJoint::FixedJoint(Entity entity, PhysicsWorld& world, const FixedJointInfo& jointInfo)
36 : Joint(entity, world) {
37
38
39 Vector3 anchorPointBody1LocalSpace;
40 Vector3 anchorPointBody2LocalSpace;
41
42 const Transform& transform1 = mWorld.mTransformComponents.getTransform(jointInfo.body1->getEntity());
43 const Transform& transform2 = mWorld.mTransformComponents.getTransform(jointInfo.body2->getEntity());
44
45 if (jointInfo.isUsingLocalSpaceAnchors) {
46
47 anchorPointBody1LocalSpace = jointInfo.anchorPointBody1LocalSpace;
48 anchorPointBody2LocalSpace = jointInfo.anchorPointBody2LocalSpace;
49 }
50 else {
51
52 // Compute the local-space anchor point for each body
53 anchorPointBody1LocalSpace = transform1.getInverse() * jointInfo.anchorPointWorldSpace;
54 anchorPointBody2LocalSpace = transform2.getInverse() * jointInfo.anchorPointWorldSpace;
55 }
56
57 mWorld.mFixedJointsComponents.setLocalAnchorPointBody1(mEntity, anchorPointBody1LocalSpace);
58 mWorld.mFixedJointsComponents.setLocalAnchorPointBody2(mEntity, anchorPointBody2LocalSpace);
59
60 // Store inverse of initial rotation from body 1 to body 2 in body 1 space:
61 //
62 // q20 = q10 r0
63 // <=> r0 = q10^-1 q20
64 // <=> r0^-1 = q20^-1 q10
65 //
66 // where:
67 //
68 // q20 = initial orientation of body 2
69 // q10 = initial orientation of body 1
70 // r0 = initial rotation rotation from body 1 to body 2
71 mWorld.mFixedJointsComponents.setInitOrientationDifferenceInv(mEntity, transform2.getOrientation().getInverse() * transform1.getOrientation());
72}
73
74// Return the force (in Newtons) on body 2 required to satisfy the joint constraint in world-space
75/**

Callers

nothing calls this directly

Calls 5

getEntityMethod · 0.45
getInverseMethod · 0.45

Tested by

no test coverage detected