mirror of
https://github.com/liabru/matter-js.git
synced 2025-01-07 15:28:06 -05:00
deprecated Matter.Grid
This commit is contained in:
parent
a6b5e7d849
commit
e366d0e992
2 changed files with 26 additions and 43 deletions
|
@ -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.
|
* The `Matter.Grid` module contains methods for creating and manipulating collision broadphase grid structures.
|
||||||
*
|
*
|
||||||
* @class Grid
|
* @class Grid
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Grid = {};
|
var Grid = {};
|
||||||
|
@ -10,11 +16,13 @@ module.exports = Grid;
|
||||||
|
|
||||||
var Pair = require('./Pair');
|
var Pair = require('./Pair');
|
||||||
var Common = require('../core/Common');
|
var Common = require('../core/Common');
|
||||||
|
var deprecated = Common.deprecated;
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new grid.
|
* Creates a new grid.
|
||||||
|
* @deprecated replaced by Matter.Detector
|
||||||
* @method create
|
* @method create
|
||||||
* @param {} options
|
* @param {} options
|
||||||
* @return {grid} A new grid
|
* @return {grid} A new grid
|
||||||
|
@ -49,6 +57,7 @@ var Common = require('../core/Common');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the grid.
|
* Updates the grid.
|
||||||
|
* @deprecated replaced by Matter.Detector
|
||||||
* @method update
|
* @method update
|
||||||
* @param {grid} grid
|
* @param {grid} grid
|
||||||
* @param {body[]} bodies
|
* @param {body[]} bodies
|
||||||
|
@ -127,8 +136,11 @@ var Common = require('../core/Common');
|
||||||
grid.pairsList = Grid._createActivePairsList(grid);
|
grid.pairsList = Grid._createActivePairsList(grid);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
deprecated(Grid, 'update', 'Grid.update ➤ replaced by Matter.Detector');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the grid.
|
* Clears the grid.
|
||||||
|
* @deprecated replaced by Matter.Detector
|
||||||
* @method clear
|
* @method clear
|
||||||
* @param {grid} grid
|
* @param {grid} grid
|
||||||
*/
|
*/
|
||||||
|
@ -138,9 +150,12 @@ var Common = require('../core/Common');
|
||||||
grid.pairsList = [];
|
grid.pairsList = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
deprecated(Grid, 'clear', 'Grid.clear ➤ replaced by Matter.Detector');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the union of two regions.
|
* Finds the union of two regions.
|
||||||
* @method _regionUnion
|
* @method _regionUnion
|
||||||
|
* @deprecated replaced by Matter.Detector
|
||||||
* @private
|
* @private
|
||||||
* @param {} regionA
|
* @param {} regionA
|
||||||
* @param {} regionB
|
* @param {} regionB
|
||||||
|
@ -158,6 +173,7 @@ var Common = require('../core/Common');
|
||||||
/**
|
/**
|
||||||
* Gets the region a given body falls in for a given grid.
|
* Gets the region a given body falls in for a given grid.
|
||||||
* @method _getRegion
|
* @method _getRegion
|
||||||
|
* @deprecated replaced by Matter.Detector
|
||||||
* @private
|
* @private
|
||||||
* @param {} grid
|
* @param {} grid
|
||||||
* @param {} body
|
* @param {} body
|
||||||
|
@ -176,6 +192,7 @@ var Common = require('../core/Common');
|
||||||
/**
|
/**
|
||||||
* Creates a region.
|
* Creates a region.
|
||||||
* @method _createRegion
|
* @method _createRegion
|
||||||
|
* @deprecated replaced by Matter.Detector
|
||||||
* @private
|
* @private
|
||||||
* @param {} startCol
|
* @param {} startCol
|
||||||
* @param {} endCol
|
* @param {} endCol
|
||||||
|
@ -196,6 +213,7 @@ var Common = require('../core/Common');
|
||||||
/**
|
/**
|
||||||
* Gets the bucket id at the given position.
|
* Gets the bucket id at the given position.
|
||||||
* @method _getBucketId
|
* @method _getBucketId
|
||||||
|
* @deprecated replaced by Matter.Detector
|
||||||
* @private
|
* @private
|
||||||
* @param {} column
|
* @param {} column
|
||||||
* @param {} row
|
* @param {} row
|
||||||
|
@ -208,6 +226,7 @@ var Common = require('../core/Common');
|
||||||
/**
|
/**
|
||||||
* Creates a bucket.
|
* Creates a bucket.
|
||||||
* @method _createBucket
|
* @method _createBucket
|
||||||
|
* @deprecated replaced by Matter.Detector
|
||||||
* @private
|
* @private
|
||||||
* @param {} buckets
|
* @param {} buckets
|
||||||
* @param {} bucketId
|
* @param {} bucketId
|
||||||
|
@ -221,6 +240,7 @@ var Common = require('../core/Common');
|
||||||
/**
|
/**
|
||||||
* Adds a body to a bucket.
|
* Adds a body to a bucket.
|
||||||
* @method _bucketAddBody
|
* @method _bucketAddBody
|
||||||
|
* @deprecated replaced by Matter.Detector
|
||||||
* @private
|
* @private
|
||||||
* @param {} grid
|
* @param {} grid
|
||||||
* @param {} bucket
|
* @param {} bucket
|
||||||
|
@ -258,6 +278,7 @@ var Common = require('../core/Common');
|
||||||
/**
|
/**
|
||||||
* Removes a body from a bucket.
|
* Removes a body from a bucket.
|
||||||
* @method _bucketRemoveBody
|
* @method _bucketRemoveBody
|
||||||
|
* @deprecated replaced by Matter.Detector
|
||||||
* @private
|
* @private
|
||||||
* @param {} grid
|
* @param {} grid
|
||||||
* @param {} bucket
|
* @param {} bucket
|
||||||
|
@ -287,6 +308,7 @@ var Common = require('../core/Common');
|
||||||
/**
|
/**
|
||||||
* Generates a list of the active pairs in the grid.
|
* Generates a list of the active pairs in the grid.
|
||||||
* @method _createActivePairsList
|
* @method _createActivePairsList
|
||||||
|
* @deprecated replaced by Matter.Detector
|
||||||
* @private
|
* @private
|
||||||
* @param {} grid
|
* @param {} grid
|
||||||
* @return [] pairs
|
* @return [] pairs
|
||||||
|
|
|
@ -76,7 +76,6 @@ var Mouse = require('../core/Mouse');
|
||||||
showDebug: false,
|
showDebug: false,
|
||||||
showStats: false,
|
showStats: false,
|
||||||
showPerformance: false,
|
showPerformance: false,
|
||||||
showBroadphase: false,
|
|
||||||
showBounds: false,
|
showBounds: false,
|
||||||
showVelocity: false,
|
showVelocity: false,
|
||||||
showCollisions: 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) {
|
if (render.options.pixelRatio !== 1) {
|
||||||
Render.setPixelRatio(render, render.options.pixelRatio);
|
Render.setPixelRatio(render, render.options.pixelRatio);
|
||||||
}
|
}
|
||||||
|
@ -436,9 +438,6 @@ var Mouse = require('../core/Mouse');
|
||||||
|
|
||||||
Render.constraints(constraints, context);
|
Render.constraints(constraints, context);
|
||||||
|
|
||||||
if (options.showBroadphase)
|
|
||||||
Render.grid(render, engine.grid, context);
|
|
||||||
|
|
||||||
if (options.hasBounds) {
|
if (options.hasBounds) {
|
||||||
// revert view transforms
|
// revert view transforms
|
||||||
Render.endViewTransform(render);
|
Render.endViewTransform(render);
|
||||||
|
@ -1285,45 +1284,6 @@ var Mouse = require('../core/Mouse');
|
||||||
c.stroke();
|
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
|
* Description
|
||||||
* @private
|
* @private
|
||||||
|
@ -1765,6 +1725,7 @@ var Mouse = require('../core/Mouse');
|
||||||
/**
|
/**
|
||||||
* A flag to enable or disable the collision broadphase debug overlay.
|
* A flag to enable or disable the collision broadphase debug overlay.
|
||||||
*
|
*
|
||||||
|
* @deprecated no longer implemented
|
||||||
* @property options.showBroadphase
|
* @property options.showBroadphase
|
||||||
* @type boolean
|
* @type boolean
|
||||||
* @default false
|
* @default false
|
||||||
|
|
Loading…
Reference in a new issue