diff --git a/src/collision/Grid.js b/src/collision/Grid.js index 6bcc1c5..e01ca01 100644 --- a/src/collision/Grid.js +++ b/src/collision/Grid.js @@ -1,7 +1,13 @@ /** +* This module has now been replaced by `Matter.Detector`. +* +* All usage should be migrated to `Matter.Detector` or another alternative. +* For back-compatibility purposes this module will remain for a short term and then later removed in a future release. +* * The `Matter.Grid` module contains methods for creating and manipulating collision broadphase grid structures. * * @class Grid +* @deprecated */ var Grid = {}; @@ -10,11 +16,13 @@ module.exports = Grid; var Pair = require('./Pair'); var Common = require('../core/Common'); +var deprecated = Common.deprecated; (function() { /** * Creates a new grid. + * @deprecated replaced by Matter.Detector * @method create * @param {} options * @return {grid} A new grid @@ -49,6 +57,7 @@ var Common = require('../core/Common'); /** * Updates the grid. + * @deprecated replaced by Matter.Detector * @method update * @param {grid} grid * @param {body[]} bodies @@ -127,8 +136,11 @@ var Common = require('../core/Common'); grid.pairsList = Grid._createActivePairsList(grid); }; + deprecated(Grid, 'update', 'Grid.update ➤ replaced by Matter.Detector'); + /** * Clears the grid. + * @deprecated replaced by Matter.Detector * @method clear * @param {grid} grid */ @@ -138,9 +150,12 @@ var Common = require('../core/Common'); grid.pairsList = []; }; + deprecated(Grid, 'clear', 'Grid.clear ➤ replaced by Matter.Detector'); + /** * Finds the union of two regions. * @method _regionUnion + * @deprecated replaced by Matter.Detector * @private * @param {} regionA * @param {} regionB @@ -158,6 +173,7 @@ var Common = require('../core/Common'); /** * Gets the region a given body falls in for a given grid. * @method _getRegion + * @deprecated replaced by Matter.Detector * @private * @param {} grid * @param {} body @@ -176,6 +192,7 @@ var Common = require('../core/Common'); /** * Creates a region. * @method _createRegion + * @deprecated replaced by Matter.Detector * @private * @param {} startCol * @param {} endCol @@ -196,6 +213,7 @@ var Common = require('../core/Common'); /** * Gets the bucket id at the given position. * @method _getBucketId + * @deprecated replaced by Matter.Detector * @private * @param {} column * @param {} row @@ -208,6 +226,7 @@ var Common = require('../core/Common'); /** * Creates a bucket. * @method _createBucket + * @deprecated replaced by Matter.Detector * @private * @param {} buckets * @param {} bucketId @@ -221,6 +240,7 @@ var Common = require('../core/Common'); /** * Adds a body to a bucket. * @method _bucketAddBody + * @deprecated replaced by Matter.Detector * @private * @param {} grid * @param {} bucket @@ -258,6 +278,7 @@ var Common = require('../core/Common'); /** * Removes a body from a bucket. * @method _bucketRemoveBody + * @deprecated replaced by Matter.Detector * @private * @param {} grid * @param {} bucket @@ -287,6 +308,7 @@ var Common = require('../core/Common'); /** * Generates a list of the active pairs in the grid. * @method _createActivePairsList + * @deprecated replaced by Matter.Detector * @private * @param {} grid * @return [] pairs diff --git a/src/render/Render.js b/src/render/Render.js index 6ee0aaf..7888226 100644 --- a/src/render/Render.js +++ b/src/render/Render.js @@ -76,7 +76,6 @@ var Mouse = require('../core/Mouse'); showDebug: false, showStats: false, showPerformance: false, - showBroadphase: false, showBounds: false, showVelocity: false, showCollisions: false, @@ -116,6 +115,9 @@ var Mouse = require('../core/Mouse'); } }; + // for temporary back compatibility only + render.options.showBroadphase = false; + if (render.options.pixelRatio !== 1) { Render.setPixelRatio(render, render.options.pixelRatio); } @@ -436,9 +438,6 @@ var Mouse = require('../core/Mouse'); Render.constraints(constraints, context); - if (options.showBroadphase) - Render.grid(render, engine.grid, context); - if (options.hasBounds) { // revert view transforms Render.endViewTransform(render); @@ -1285,45 +1284,6 @@ var Mouse = require('../core/Mouse'); c.stroke(); }; - /** - * Description - * @private - * @method grid - * @param {render} render - * @param {grid} grid - * @param {RenderingContext} context - */ - Render.grid = function(render, grid, context) { - var c = context, - options = render.options; - - if (options.wireframes) { - c.strokeStyle = 'rgba(255,180,0,0.1)'; - } else { - c.strokeStyle = 'rgba(255,180,0,0.5)'; - } - - c.beginPath(); - - var bucketKeys = Common.keys(grid.buckets); - - for (var i = 0; i < bucketKeys.length; i++) { - var bucketId = bucketKeys[i]; - - if (grid.buckets[bucketId].length < 2) - continue; - - var region = bucketId.split(/C|R/); - c.rect(0.5 + parseInt(region[1], 10) * grid.bucketWidth, - 0.5 + parseInt(region[2], 10) * grid.bucketHeight, - grid.bucketWidth, - grid.bucketHeight); - } - - c.lineWidth = 1; - c.stroke(); - }; - /** * Description * @private @@ -1765,6 +1725,7 @@ var Mouse = require('../core/Mouse'); /** * A flag to enable or disable the collision broadphase debug overlay. * + * @deprecated no longer implemented * @property options.showBroadphase * @type boolean * @default false