Skip to content

Commit 30dda88

Browse files
committed
Matter.TileBody.setFromTileCollision no longer checks if the shape is concave or convex before modifying the vertices, as the update to the Matter.js lib in 3.12 stopped this from working with Tiled collision shapes.
1 parent d9f0483 commit 30dda88

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ one set of bindings ever created, which makes things a lot cleaner.
211211
* `WebGLRenderer.preRender` now calls `gl.clearColor` in order to restore the background clear color in case something, like a Render Texture, has changed it.
212212
* `Map.set` will now update an existing value if you provide it with a key that already exists within the Map. Previously, if you tried to set the value of a key that existed it would be skipped.
213213
* `MatterSprite` would set its `type` property to be `Image`. It now sets it to be `Sprite` as it should do.
214+
* `Matter.TileBody.setFromTileCollision` no longer checks if the shape is concave or convex before modifying the vertices, as the update to the Matter.js lib in 3.12 stopped this from working with Tiled collision shapes.
214215

215216
### Bug Fixes
216217

src/physics/matter-js/MatterTileBody.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,14 @@ var MatterTileBody = new Class({
220220
// matter expects points to be relative to the center of mass. This only applies to
221221
// convex shapes. When a concave shape is decomposed, multiple parts are created and
222222
// the individual parts are positioned relative to (ox, oy).
223-
if (Vertices.isConvex(points))
224-
{
225-
var center = Vertices.centre(vertices);
226-
ox += center.x;
227-
oy += center.y;
228-
}
223+
//
224+
// Update: 8th January 2019 - the latest version of Matter needs the Vertices adjusted,
225+
// regardless if convex or concave.
226+
227+
var center = Vertices.centre(vertices);
228+
229+
ox += center.x;
230+
oy += center.y;
229231

230232
body = Bodies.fromVertices(ox, oy, vertices, options);
231233
}

src/physics/matter-js/World.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ var World = new Class({
537537
convertTilemapLayer: function (tilemapLayer, options)
538538
{
539539
var layerData = tilemapLayer.layer;
540-
var tiles = tilemapLayer.getTilesWithin(0, 0, layerData.width, layerData.height, {isColliding: true});
540+
var tiles = tilemapLayer.getTilesWithin(0, 0, layerData.width, layerData.height, { isColliding: true });
541541

542542
this.convertTiles(tiles, options);
543543

0 commit comments

Comments
 (0)