mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-26 09:49:20 -05:00
remove deprecated Matter.Metrics
This commit is contained in:
parent
08a515b968
commit
63a9e988f4
7 changed files with 2 additions and 171 deletions
|
@ -62,7 +62,6 @@
|
|||
"Query": false,
|
||||
"Runner": false,
|
||||
"Svg": false,
|
||||
"Metrics": false,
|
||||
"Example": false,
|
||||
"__MATTER_VERSION__": false,
|
||||
"__MATTER_IS_DEV__": false,
|
||||
|
|
|
@ -27,10 +27,6 @@ var Bounds = require('../geometry/Bounds');
|
|||
var collisions = [],
|
||||
pairsTable = engine.pairs.table;
|
||||
|
||||
// @if DEBUG
|
||||
var metrics = engine.metrics;
|
||||
// @endif
|
||||
|
||||
for (var i = 0; i < broadphasePairs.length; i++) {
|
||||
var bodyA = broadphasePairs[i][0],
|
||||
bodyB = broadphasePairs[i][1];
|
||||
|
@ -41,10 +37,6 @@ var Bounds = require('../geometry/Bounds');
|
|||
if (!Detector.canCollide(bodyA.collisionFilter, bodyB.collisionFilter))
|
||||
continue;
|
||||
|
||||
// @if DEBUG
|
||||
metrics.midphaseTests += 1;
|
||||
// @endif
|
||||
|
||||
// mid phase
|
||||
if (Bounds.overlaps(bodyA.bounds, bodyB.bounds)) {
|
||||
for (var j = bodyA.parts.length > 1 ? 1 : 0; j < bodyA.parts.length; j++) {
|
||||
|
@ -68,17 +60,8 @@ var Bounds = require('../geometry/Bounds');
|
|||
// narrow phase
|
||||
var collision = SAT.collides(partA, partB, 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,11 +66,6 @@ var Common = require('../core/Common');
|
|||
bucketId,
|
||||
gridChanged = false;
|
||||
|
||||
// @if DEBUG
|
||||
var metrics = engine.metrics;
|
||||
metrics.broadphaseTests = 0;
|
||||
// @endif
|
||||
|
||||
for (i = 0; i < bodies.length; i++) {
|
||||
var body = bodies[i];
|
||||
|
||||
|
@ -87,10 +82,6 @@ var Common = require('../core/Common');
|
|||
// if the body has changed grid region
|
||||
if (!body.region || newRegion.id !== body.region.id || forceUpdate) {
|
||||
|
||||
// @if DEBUG
|
||||
metrics.broadphaseTests += 1;
|
||||
// @endif
|
||||
|
||||
if (!body.region || forceUpdate)
|
||||
body.region = newRegion;
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ var Sleeping = require('./Sleeping');
|
|||
var Resolver = require('../collision/Resolver');
|
||||
var Render = require('../render/Render');
|
||||
var Pairs = require('../collision/Pairs');
|
||||
var Metrics = require('./Metrics');
|
||||
var Grid = require('../collision/Grid');
|
||||
var Events = require('./Events');
|
||||
var Composite = require('../body/Composite');
|
||||
|
@ -59,6 +58,7 @@ var Body = require('../body/Body');
|
|||
broadphase: {
|
||||
controller: Grid
|
||||
}
|
||||
metrics: {}
|
||||
};
|
||||
|
||||
var engine = Common.extend(defaults, options);
|
||||
|
@ -86,11 +86,6 @@ var Body = require('../body/Body');
|
|||
engine.world = options.world || World.create(engine.world);
|
||||
engine.pairs = Pairs.create();
|
||||
engine.broadphase = engine.broadphase.controller.create(engine.broadphase);
|
||||
engine.metrics = engine.metrics || { extended: false };
|
||||
|
||||
// @if DEBUG
|
||||
engine.metrics = Metrics.create(engine.metrics);
|
||||
// @endif
|
||||
|
||||
return engine;
|
||||
};
|
||||
|
@ -134,11 +129,6 @@ var Body = require('../body/Body');
|
|||
var allBodies = Composite.allBodies(world),
|
||||
allConstraints = Composite.allConstraints(world);
|
||||
|
||||
// @if DEBUG
|
||||
// reset metrics logging
|
||||
Metrics.reset(engine.metrics);
|
||||
// @endif
|
||||
|
||||
// if sleeping enabled, call the sleeping controller
|
||||
if (engine.enableSleeping)
|
||||
Sleeping.update(allBodies, timing.timeScale);
|
||||
|
@ -219,11 +209,6 @@ var Body = require('../body/Body');
|
|||
if (pairs.collisionEnd.length > 0)
|
||||
Events.trigger(engine, 'collisionEnd', { pairs: pairs.collisionEnd });
|
||||
|
||||
// @if DEBUG
|
||||
// update metrics log
|
||||
Metrics.update(engine.metrics, engine);
|
||||
// @endif
|
||||
|
||||
// clear force buffers
|
||||
Engine._bodiesClearForces(allBodies);
|
||||
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
// @if DEBUG
|
||||
/**
|
||||
* _Internal Class_, not generally used outside of the engine's internals.
|
||||
*
|
||||
*/
|
||||
|
||||
var Metrics = {};
|
||||
|
||||
module.exports = Metrics;
|
||||
|
||||
var Composite = require('../body/Composite');
|
||||
var Common = require('./Common');
|
||||
|
||||
(function() {
|
||||
|
||||
/**
|
||||
* Creates a new metrics.
|
||||
* @method create
|
||||
* @private
|
||||
* @return {metrics} A new metrics
|
||||
*/
|
||||
Metrics.create = function(options) {
|
||||
var defaults = {
|
||||
extended: false,
|
||||
narrowDetections: 0,
|
||||
narrowphaseTests: 0,
|
||||
narrowReuse: 0,
|
||||
narrowReuseCount: 0,
|
||||
midphaseTests: 0,
|
||||
broadphaseTests: 0,
|
||||
narrowEff: 0.0001,
|
||||
midEff: 0.0001,
|
||||
broadEff: 0.0001,
|
||||
collisions: 0,
|
||||
buckets: 0,
|
||||
bodies: 0,
|
||||
pairs: 0
|
||||
};
|
||||
|
||||
return Common.extend(defaults, false, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Resets metrics.
|
||||
* @method reset
|
||||
* @private
|
||||
* @param {metrics} metrics
|
||||
*/
|
||||
Metrics.reset = function(metrics) {
|
||||
if (metrics.extended) {
|
||||
metrics.narrowDetections = 0;
|
||||
metrics.narrowphaseTests = 0;
|
||||
metrics.narrowReuse = 0;
|
||||
metrics.narrowReuseCount = 0;
|
||||
metrics.midphaseTests = 0;
|
||||
metrics.broadphaseTests = 0;
|
||||
metrics.narrowEff = 0;
|
||||
metrics.midEff = 0;
|
||||
metrics.broadEff = 0;
|
||||
metrics.collisions = 0;
|
||||
metrics.buckets = 0;
|
||||
metrics.pairs = 0;
|
||||
metrics.bodies = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates metrics.
|
||||
* @method update
|
||||
* @private
|
||||
* @param {metrics} metrics
|
||||
* @param {engine} engine
|
||||
*/
|
||||
Metrics.update = function(metrics, engine) {
|
||||
if (metrics.extended) {
|
||||
var world = engine.world,
|
||||
bodies = Composite.allBodies(world);
|
||||
|
||||
metrics.collisions = metrics.narrowDetections;
|
||||
metrics.pairs = engine.pairs.list.length;
|
||||
metrics.bodies = bodies.length;
|
||||
metrics.midEff = (metrics.narrowDetections / (metrics.midphaseTests || 1)).toFixed(2);
|
||||
metrics.narrowEff = (metrics.narrowDetections / (metrics.narrowphaseTests || 1)).toFixed(2);
|
||||
metrics.broadEff = (1 - (metrics.broadphaseTests / (bodies.length || 1))).toFixed(2);
|
||||
metrics.narrowReuse = (metrics.narrowReuseCount / (metrics.narrowphaseTests || 1)).toFixed(2);
|
||||
//var broadphase = engine.broadphase[engine.broadphase.current];
|
||||
//if (broadphase.instance)
|
||||
// metrics.buckets = Common.keys(broadphase.instance.buckets).length;
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
// @endif
|
|
@ -24,10 +24,6 @@ Matter.Runner = require('../core/Runner');
|
|||
Matter.Sleeping = require('../core/Sleeping');
|
||||
Matter.Plugin = require('../core/Plugin');
|
||||
|
||||
// @if DEBUG
|
||||
Matter.Metrics = require('../core/Metrics');
|
||||
// @endif
|
||||
|
||||
Matter.Bodies = require('../factory/Bodies');
|
||||
Matter.Composites = require('../factory/Composites');
|
||||
|
||||
|
|
|
@ -430,41 +430,11 @@ var Mouse = require('../core/Mouse');
|
|||
Render.debug = function(render, context) {
|
||||
var c = context,
|
||||
engine = render.engine,
|
||||
world = engine.world,
|
||||
metrics = engine.metrics,
|
||||
options = render.options,
|
||||
bodies = Composite.allBodies(world),
|
||||
space = " ";
|
||||
options = render.options;
|
||||
|
||||
if (engine.timing.timestamp - (render.debugTimestamp || 0) >= 500) {
|
||||
var text = "";
|
||||
|
||||
if (metrics.timing) {
|
||||
text += "fps: " + Math.round(metrics.timing.fps) + space;
|
||||
}
|
||||
|
||||
// @if DEBUG
|
||||
if (metrics.extended) {
|
||||
if (metrics.timing) {
|
||||
text += "delta: " + metrics.timing.delta.toFixed(3) + space;
|
||||
text += "correction: " + metrics.timing.correction.toFixed(3) + space;
|
||||
}
|
||||
|
||||
text += "bodies: " + bodies.length + space;
|
||||
|
||||
if (engine.broadphase.controller === Grid)
|
||||
text += "buckets: " + metrics.buckets + space;
|
||||
|
||||
text += "\n";
|
||||
|
||||
text += "collisions: " + metrics.collisions + space;
|
||||
text += "pairs: " + engine.pairs.list.length + space;
|
||||
text += "broad: " + metrics.broadEff + space;
|
||||
text += "mid: " + metrics.midEff + space;
|
||||
text += "narrow: " + metrics.narrowEff + space;
|
||||
}
|
||||
// @endif
|
||||
|
||||
render.debugString = text;
|
||||
render.debugTimestamp = engine.timing.timestamp;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue