Skip to content

Commit 43b111d

Browse files
committed
Removed unused code and tidied up the Phaser specific additions
1 parent 9c43681 commit 43b111d

1 file changed

Lines changed: 29 additions & 48 deletions

File tree

  • src/physics/matter-js/lib/body

src/physics/matter-js/lib/body/Body.js

Lines changed: 29 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,10 @@ var Axes = require('../geometry/Axes');
4040
id: Common.nextId(),
4141
type: 'body',
4242
label: 'Body',
43-
gameObject: null, // custom Phaser property
4443
parts: [],
4544
plugin: {},
4645
angle: 0,
47-
vertices: Vertices.fromPath('L 0 0 L 40 0 L 40 40 L 0 40'),
48-
scale: { x: 1, y: 1 }, // custom Phaser property
49-
centerOfMass: { x: 0, y: 0 }, // custom Phaser property
46+
vertices: null, // Phaser change: no point calling fromPath if they pass in vertices anyway
5047
position: { x: 0, y: 0 },
5148
force: { x: 0, y: 0 },
5249
torque: 0,
@@ -61,11 +58,6 @@ var Axes = require('../geometry/Axes');
6158
isSensor: false,
6259
isStatic: false,
6360
isSleeping: false,
64-
ignoreGravity: false, // custom Phaser property
65-
ignorePointer: false, // custom Phaser property
66-
onCollideCallback: null, // custom Phaser property
67-
onCollideEndCallback: null, // custom Phaser property
68-
onCollideActiveCallback: null, // custom Phaser property
6961
motion: 0,
7062
sleepThreshold: 60,
7163
density: 0.001,
@@ -80,21 +72,6 @@ var Axes = require('../geometry/Axes');
8072
},
8173
slop: 0.05,
8274
timeScale: 1,
83-
render: {
84-
visible: true,
85-
opacity: 1,
86-
sprite: {
87-
xScale: 1,
88-
yScale: 1,
89-
xOffset: 0,
90-
yOffset: 0
91-
},
92-
fillColor: null, // custom Phaser property
93-
fillOpacity: null, // custom Phaser property
94-
lineColor: null, // custom Phaser property
95-
lineOpacity: null, // custom Phaser property
96-
lineThickness: null // custom Phaser property
97-
},
9875
events: null,
9976
bounds: null,
10077
chamfer: null,
@@ -106,13 +83,40 @@ var Axes = require('../geometry/Axes');
10683
area: 0,
10784
mass: 0,
10885
inertia: 0,
109-
_original: null
86+
_original: null,
87+
render: {
88+
visible: true,
89+
opacity: 1,
90+
sprite: {
91+
xScale: 1,
92+
yScale: 1,
93+
xOffset: 0,
94+
yOffset: 0
95+
},
96+
fillColor: null, // custom Phaser property
97+
fillOpacity: null, // custom Phaser property
98+
lineColor: null, // custom Phaser property
99+
lineOpacity: null, // custom Phaser property
100+
lineThickness: null // custom Phaser property
101+
},
102+
gameObject: null, // custom Phaser property
103+
scale: { x: 1, y: 1 }, // custom Phaser property
104+
centerOfMass: { x: 0, y: 0 }, // custom Phaser property
105+
ignoreGravity: false, // custom Phaser property
106+
ignorePointer: false, // custom Phaser property
107+
onCollideCallback: null, // custom Phaser property
108+
onCollideEndCallback: null, // custom Phaser property
109+
onCollideActiveCallback: null // custom Phaser property
110110
};
111111

112112
if (!options.hasOwnProperty('position') && options.hasOwnProperty('vertices'))
113113
{
114114
options.position = Vertices.centre(options.vertices);
115115
}
116+
else if (!options.hasOwnProperty('vertices'))
117+
{
118+
defaults.vertices = Vertices.fromPath('L 0 0 L 40 0 L 40 40 L 0 40');
119+
}
116120

117121
var body = Common.extend(defaults, options);
118122

@@ -203,26 +207,8 @@ var Axes = require('../geometry/Axes');
203207
inertia: options.inertia || body.inertia
204208
});
205209

206-
/*
207-
if (body.parts.length === 1)
208-
{
209-
var w = (body.bounds.max.x - body.bounds.min.x);
210-
var h = (body.bounds.max.y - body.bounds.min.y);
211-
212-
body.centerOfMass.x = w / 2;
213-
body.centerOfMass.y = h / 2;
214-
215-
Vertices.calcOffset(body.vertices, body.position);
216-
}
217-
*/
218-
219210
body.centerOfMass.x = -(body.bounds.min.x - body.position.x) / (body.bounds.max.x - body.bounds.min.x);
220211
body.centerOfMass.y = -(body.bounds.min.y - body.position.y) / (body.bounds.max.y - body.bounds.min.y);
221-
222-
if (!body.isStatic)
223-
{
224-
console.log('com', body.centerOfMass.x, body.centerOfMass.y);
225-
}
226212
};
227213

228214
/**
@@ -484,11 +470,6 @@ var Axes = require('../geometry/Axes');
484470
Body.setMass(body, total.mass);
485471
Body.setInertia(body, total.inertia);
486472
Body.setPosition(body, total.centre);
487-
488-
// for (i = 0; i < parts.length; i++)
489-
// {
490-
// Vertices.calcOffset(parts[i].vertices, total.centre);
491-
// }
492473
};
493474

494475
/**

0 commit comments

Comments
 (0)