MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / Update

Method Update

engine/source/Box2D/Dynamics/Contacts/b2Contact.cpp:161–247  ·  view source on GitHub ↗

Update the contact manifold and touching status. Note: do not assume the fixture AABBs are overlapping or are valid.

Source from the content-addressed store, hash-verified

159// Update the contact manifold and touching status.
160// Note: do not assume the fixture AABBs are overlapping or are valid.
161void b2Contact::Update(b2ContactListener* listener)
162{
163 b2Manifold oldManifold = m_manifold;
164
165 // Re-enable this contact.
166 m_flags |= e_enabledFlag;
167
168 bool touching = false;
169 bool wasTouching = (m_flags & e_touchingFlag) == e_touchingFlag;
170
171 bool sensorA = m_fixtureA->IsSensor();
172 bool sensorB = m_fixtureB->IsSensor();
173 bool sensor = sensorA || sensorB;
174
175 b2Body* bodyA = m_fixtureA->GetBody();
176 b2Body* bodyB = m_fixtureB->GetBody();
177 const b2Transform& xfA = bodyA->GetTransform();
178 const b2Transform& xfB = bodyB->GetTransform();
179
180 // Is this contact a sensor?
181 if (sensor)
182 {
183 const b2Shape* shapeA = m_fixtureA->GetShape();
184 const b2Shape* shapeB = m_fixtureB->GetShape();
185 touching = b2TestOverlap(shapeA, m_indexA, shapeB, m_indexB, xfA, xfB);
186
187 // Sensors don't generate manifolds.
188 m_manifold.pointCount = 0;
189 }
190 else
191 {
192 Evaluate(&m_manifold, xfA, xfB);
193 touching = m_manifold.pointCount > 0;
194
195 // Match old contact ids to new contact ids and copy the
196 // stored impulses to warm start the solver.
197 for (int32 i = 0; i < m_manifold.pointCount; ++i)
198 {
199 b2ManifoldPoint* mp2 = m_manifold.points + i;
200 mp2->normalImpulse = 0.0f;
201 mp2->tangentImpulse = 0.0f;
202 b2ContactID id2 = mp2->id;
203
204 for (int32 j = 0; j < oldManifold.pointCount; ++j)
205 {
206 b2ManifoldPoint* mp1 = oldManifold.points + j;
207
208 if (mp1->id.key == id2.key)
209 {
210 mp2->normalImpulse = mp1->normalImpulse;
211 mp2->tangentImpulse = mp1->tangentImpulse;
212 break;
213 }
214 }
215 }
216
217 if (touching != wasTouching)
218 {

Callers 2

CollideMethod · 0.45
SolveTOIMethod · 0.45

Calls 9

IsSensorMethod · 0.80
GetBodyMethod · 0.80
GetTransformMethod · 0.80
GetShapeMethod · 0.80
SetAwakeMethod · 0.80
b2TestOverlapFunction · 0.50
BeginContactMethod · 0.45
EndContactMethod · 0.45
PreSolveMethod · 0.45

Tested by

no test coverage detected