top of page
Search
cedarcantab

sopiro(js) nsquared



import { createAABB, detectCollisionAABB } from "./aabb.js";

//N^2 broad phase, actually (N^2 - N) / 2

export function getCollisionPairsNSquared(bodies) {

let pairs = [];

for (let i = 0; i < bodies.length; i++) {

let a = bodies[i];

for (let j = i + 1; j < bodies.length; j++) {

let b = bodies[j];

if (detectCollisionAABB(createAABB(a), createAABB(b))) {

pairs.push({ p1: a, p2: b });

}

}

}

return pairs;

}

1 view0 comments

Recent Posts

See All

p2 naive broadphase

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

sopiro motor constranit

import { Matrix2, Vector2 } from "./math.js"; import { RigidBody } from "./rigidbody.js"; import { Settings } from "./settings.js";...

Comments


記事: Blog2_Post
bottom of page