top of page
Search
  • cedarcantab

Extending Box2D-Lite in Javascript: Collision Detection







b2ContactManager.Collide() // This is the top level collision call for the time step. Here

// all the narrow phase collision is processed for the world

// contact list.

if overlap is deemed to persist by the broadphase, then b2Contact.Update is called. --> Evaluate(&m_manifold, xfA, xfB); and warm starting type stuff is carried out here.


if a new AABB overlaps is identified, b2ContactManager.AddPair is called, which in turn after a various checking

// Call the factory.

b2Contact* c = b2Contact::Create(fixtureA, indexA, fixtureB, indexB, m_allocator);

if (c == nullptr)

{

return;

}


b2Contact is a class that calls the collision detection method relevant to the particular pair of fixtures. For polygon vs polygon,


b2PolygonContact::Create


which eventually calls


void b2PolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB)

{

b2CollidePolygons( manifold, (b2PolygonShape*)m_fixtureA->GetShape(), xfA (b2PolygonShape*)m_fixtureB->GetShape(), xfB);

}





1 view0 comments

Recent Posts

See All

p2 naive broadphase

var Broadphase = require('../collision/Broadphase'); module.exports = NaiveBroadphase; /** * Naive broadphase implementation. Does N^2 tests. * * @class NaiveBroadphase * @constructor * @extend

Extending Box2D-Lite in Javascript: Revolute Joint

/// Revolute joint definition. This requires defining an anchor point where the /// bodies are joined. The definition uses local anchor points so that the /// initial configuration can violate the con

sopiro motor constranit

import { Matrix2, Vector2 } from "./math.js"; import { RigidBody } from "./rigidbody.js"; import { Settings } from "./settings.js"; import * as Util from "./util.js"; import { Joint } from "./joint.js

記事: Blog2_Post
bottom of page