Skip to content

Commit 76d2c97

Browse files
committed
Added showSensor debug option
1 parent c8b2ff5 commit 76d2c97

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

src/physics/matter-js/World.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ var World = new Class({
248248
showJoint: GetFastValue(debugConfig, 'showJoint', true),
249249
showInternalEdges: GetFastValue(debugConfig, 'showInternalEdges', false),
250250
showConvexHulls: GetFastValue(debugConfig, 'showConvexHulls', false),
251+
showSensors: GetFastValue(debugConfig, 'showSensors', true),
251252

252253
renderFill: GetFastValue(debugConfig, 'renderFill', false),
253254
renderLine: GetFastValue(debugConfig, 'renderLine', true),
@@ -265,6 +266,9 @@ var World = new Class({
265266
sleepFillColor: GetFastValue(debugConfig, 'sleepFillColor', 0x464646),
266267
sleepLineColor: GetFastValue(debugConfig, 'sleepLineColor', 0x999a99),
267268

269+
sensorFillColor: GetFastValue(debugConfig, 'sensorFillColor', 0x0d177b),
270+
sensorLineColor: GetFastValue(debugConfig, 'sensorLineColor', 0x1327e4),
271+
268272
positionSize: GetFastValue(debugConfig, 'positionSize', 4),
269273
positionColor: GetFastValue(debugConfig, 'positionColor', 0xe042da),
270274

@@ -1417,6 +1421,9 @@ var World = new Class({
14171421

14181422
var config = this.debugConfig;
14191423

1424+
var sensorFillColor = config.sensorFillColor;
1425+
var sensorLineColor = config.sensorLineColor;
1426+
14201427
// Handle compound parts
14211428
var parts = body.parts;
14221429
var partsLength = parts.length;
@@ -1427,7 +1434,7 @@ var World = new Class({
14271434
var render = part.render;
14281435
var opacity = render.opacity;
14291436

1430-
if (!render.visible || opacity === 0)
1437+
if (!render.visible || opacity === 0 || (part.isSensor && !config.showSensors))
14311438
{
14321439
continue;
14331440
}
@@ -1437,14 +1444,29 @@ var World = new Class({
14371444

14381445
graphics.beginPath();
14391446

1440-
if (fillColor !== null)
1447+
if (part.isSensor)
14411448
{
1442-
graphics.fillStyle(fillColor, fillOpacity * opacity);
1449+
if (fillColor !== null)
1450+
{
1451+
graphics.fillStyle(sensorFillColor, fillOpacity * opacity);
1452+
}
1453+
1454+
if (lineColor !== null)
1455+
{
1456+
graphics.lineStyle(lineThickness, sensorLineColor, lineOpacity * opacity);
1457+
}
14431458
}
1444-
1445-
if (lineColor !== null)
1459+
else
14461460
{
1447-
graphics.lineStyle(lineThickness, lineColor, lineOpacity * opacity);
1461+
if (fillColor !== null)
1462+
{
1463+
graphics.fillStyle(fillColor, fillOpacity * opacity);
1464+
}
1465+
1466+
if (lineColor !== null)
1467+
{
1468+
graphics.lineStyle(lineThickness, lineColor, lineOpacity * opacity);
1469+
}
14481470
}
14491471

14501472
if (circleRadius)

0 commit comments

Comments
 (0)