MCPcopy Create free account
hub / github.com/ByteArena/box2d / MakeB2MouseJoint

Function MakeB2MouseJoint

DynamicsB2JointMouse.go:87–110  ·  view source on GitHub ↗

p = attached point, m = mouse point C = p - m Cdot = v = v + cross(w, r) J = [I r_skew] Identity used: w k % (rx i + ry j) = w * (-ry i + rx j)

(def *B2MouseJointDef)

Source from the content-addressed store, hash-verified

85// w k % (rx i + ry j) = w * (-ry i + rx j)
86
87func MakeB2MouseJoint(def *B2MouseJointDef) *B2MouseJoint {
88 res := B2MouseJoint{
89 B2Joint: MakeB2Joint(def),
90 }
91
92 B2Assert(def.Target.IsValid())
93 B2Assert(B2IsValid(def.MaxForce) && def.MaxForce >= 0.0)
94 B2Assert(B2IsValid(def.FrequencyHz) && def.FrequencyHz >= 0.0)
95 B2Assert(B2IsValid(def.DampingRatio) && def.DampingRatio >= 0.0)
96
97 res.M_targetA = def.Target
98 res.M_localAnchorB = B2TransformVec2MulT(res.M_bodyB.GetTransform(), res.M_targetA)
99
100 res.M_maxForce = def.MaxForce
101 res.M_impulse.SetZero()
102
103 res.M_frequencyHz = def.FrequencyHz
104 res.M_dampingRatio = def.DampingRatio
105
106 res.M_beta = 0.0
107 res.M_gamma = 0.0
108
109 return &res
110}
111
112func (joint *B2MouseJoint) SetTarget(target B2Vec2) {
113 if target != joint.M_targetA {

Callers 1

B2JointCreateFunction · 0.85

Calls 7

MakeB2JointFunction · 0.85
B2AssertFunction · 0.85
B2IsValidFunction · 0.85
B2TransformVec2MulTFunction · 0.85
IsValidMethod · 0.45
GetTransformMethod · 0.45
SetZeroMethod · 0.45

Tested by

no test coverage detected