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

Method FindMinSeparation

CollisionB2TimeOfImpact.go:156–223  ·  view source on GitHub ↗
(indexA *int, indexB *int, t float64)

Source from the content-addressed store, hash-verified

154
155//
156func (sepfunc *B2SeparationFunction) FindMinSeparation(indexA *int, indexB *int, t float64) float64 {
157
158 xfA := MakeB2Transform()
159 xfB := MakeB2Transform()
160
161 sepfunc.M_sweepA.GetTransform(&xfA, t)
162 sepfunc.M_sweepB.GetTransform(&xfB, t)
163
164 switch sepfunc.M_type {
165 case B2SeparationFunction_Type.E_points:
166 {
167 axisA := B2RotVec2MulT(xfA.Q, sepfunc.M_axis)
168 axisB := B2RotVec2MulT(xfB.Q, sepfunc.M_axis.OperatorNegate())
169
170 *indexA = sepfunc.M_proxyA.GetSupport(axisA)
171 *indexB = sepfunc.M_proxyB.GetSupport(axisB)
172
173 localPointA := sepfunc.M_proxyA.GetVertex(*indexA)
174 localPointB := sepfunc.M_proxyB.GetVertex(*indexB)
175
176 pointA := B2TransformVec2Mul(xfA, localPointA)
177 pointB := B2TransformVec2Mul(xfB, localPointB)
178
179 separation := B2Vec2Dot(B2Vec2Sub(pointB, pointA), sepfunc.M_axis)
180 return separation
181 }
182
183 case B2SeparationFunction_Type.E_faceA:
184 {
185 normal := B2RotVec2Mul(xfA.Q, sepfunc.M_axis)
186 pointA := B2TransformVec2Mul(xfA, sepfunc.M_localPoint)
187
188 axisB := B2RotVec2MulT(xfB.Q, normal.OperatorNegate())
189
190 *indexA = -1
191 *indexB = sepfunc.M_proxyB.GetSupport(axisB)
192
193 localPointB := sepfunc.M_proxyB.GetVertex(*indexB)
194 pointB := B2TransformVec2Mul(xfB, localPointB)
195
196 separation := B2Vec2Dot(B2Vec2Sub(pointB, pointA), normal)
197 return separation
198 }
199
200 case B2SeparationFunction_Type.E_faceB:
201 {
202 normal := B2RotVec2Mul(xfB.Q, sepfunc.M_axis)
203 pointB := B2TransformVec2Mul(xfB, sepfunc.M_localPoint)
204
205 axisA := B2RotVec2MulT(xfA.Q, normal.OperatorNegate())
206
207 *indexB = -1
208 *indexA = sepfunc.M_proxyA.GetSupport(axisA)
209
210 localPointA := sepfunc.M_proxyA.GetVertex(*indexA)
211 pointA := B2TransformVec2Mul(xfA, localPointA)
212
213 separation := B2Vec2Dot(B2Vec2Sub(pointA, pointB), normal)

Callers 1

B2TimeOfImpactFunction · 0.95

Calls 11

MakeB2TransformFunction · 0.85
B2RotVec2MulTFunction · 0.85
B2TransformVec2MulFunction · 0.85
B2Vec2DotFunction · 0.85
B2Vec2SubFunction · 0.85
B2RotVec2MulFunction · 0.85
B2AssertFunction · 0.85
GetSupportMethod · 0.80
GetVertexMethod · 0.80
GetTransformMethod · 0.45
OperatorNegateMethod · 0.45

Tested by

no test coverage detected