From e04de5fb4e365b9f3fd969da681c5508af73f904 Mon Sep 17 00:00:00 2001 From: liabru Date: Sat, 5 Dec 2015 18:12:07 +0000 Subject: [PATCH] removed Detector.bruteForce --- demo/js/lib/matter-tools/matter-tools-dev.js | 6 +- src/collision/Detector.js | 68 -------------------- 2 files changed, 1 insertion(+), 73 deletions(-) diff --git a/demo/js/lib/matter-tools/matter-tools-dev.js b/demo/js/lib/matter-tools/matter-tools-dev.js index bd82328a..d35d9061 100644 --- a/demo/js/lib/matter-tools/matter-tools-dev.js +++ b/demo/js/lib/matter-tools/matter-tools-dev.js @@ -1,5 +1,5 @@ /** -* matter-tools-dev.min.js 0.5.0-dev 2015-07-27 +* matter-tools-dev.min.js 0.5.0-dev 2015-12-05 * https://github.com/liabru/matter-tools * License: MIT */ @@ -195,10 +195,6 @@ gravity.open(); var physics = datGui.addFolder("Engine"); physics.add(engine, "enableSleeping"); - physics.add(gui, "broadphase", [ "grid", "bruteForce" ]).onFinishChange(function(value) { - engine.broadphase = gui.broadphaseCache[value]; - Composite.setModified(engine.world, true, false, false); - }); physics.add(engine.timing, "timeScale", 0, 1.2).step(.05).listen(); physics.add(engine, "velocityIterations", 1, 10).step(1); physics.add(engine, "positionIterations", 1, 10).step(1); diff --git a/src/collision/Detector.js b/src/collision/Detector.js index 719eb92a..2a72bb7e 100644 --- a/src/collision/Detector.js +++ b/src/collision/Detector.js @@ -89,74 +89,6 @@ var Bounds = require('../geometry/Bounds'); return collisions; }; - /** - * Description - * @method bruteForce - * @param {body[]} bodies - * @param {engine} engine - * @return {array} collisions - */ - Detector.bruteForce = function(bodies, engine) { - var collisions = [], - pairsTable = engine.pairs.table; - - // @if DEBUG - var metrics = engine.metrics; - // @endif - - for (var i = 0; i < bodies.length; i++) { - for (var j = i + 1; j < bodies.length; j++) { - var bodyA = bodies[i], - bodyB = bodies[j]; - - // NOTE: could share a function for the below, but may drop performance? - - if ((bodyA.isStatic || bodyA.isSleeping) && (bodyB.isStatic || bodyB.isSleeping)) - continue; - - if (!Detector.canCollide(bodyA.collisionFilter, bodyB.collisionFilter)) - continue; - - // @if DEBUG - metrics.midphaseTests += 1; - // @endif - - // mid phase - if (Bounds.overlaps(bodyA.bounds, bodyB.bounds)) { - - // find a previous collision we could reuse - var pairId = Pair.id(bodyA, bodyB), - pair = pairsTable[pairId], - previousCollision; - - if (pair && pair.isActive) { - previousCollision = pair.collision; - } else { - previousCollision = null; - } - - // narrow phase - var collision = SAT.collides(bodyA, bodyB, previousCollision); - - // @if DEBUG - metrics.narrowphaseTests += 1; - if (collision.reused) - metrics.narrowReuseCount += 1; - // @endif - - if (collision.collided) { - collisions.push(collision); - // @if DEBUG - metrics.narrowDetections += 1; - // @endif - } - } - } - } - - return collisions; - }; - /** * Returns `true` if both supplied collision filters will allow a collision to occur. * See `body.collisionFilter` for more information.