diff --git a/src/api/l_physics_shapes.c b/src/api/l_physics_shapes.c index fbb61c4c3..95ba53bf2 100644 --- a/src/api/l_physics_shapes.c +++ b/src/api/l_physics_shapes.c @@ -553,7 +553,7 @@ static int l_lovrConvexShapeGetFace(lua_State* L) { uint32_t* indices = count > COUNTOF(stack) ? lovrMalloc(count * sizeof(uint32_t)) : stack; lovrConvexShapeGetFace(convex, index, indices, count); for (uint32_t i = 0; i < count; i++) { - lua_pushinteger(L, indices[i]); + lua_pushinteger(L, indices[i] + 1); lua_rawseti(L, -2, i + 1); } if (indices != stack) { diff --git a/test/lovr/physics.lua b/test/lovr/physics.lua index 6707383e8..a99939318 100644 --- a/test/lovr/physics.lua +++ b/test/lovr/physics.lua @@ -87,6 +87,11 @@ group('physics', function() test('ConvexShape', function() shape = lovr.physics.newConvexShape({ 1, 1, 0, -1, 1, 0, 0, 0, 0, 0, 0, 1 }) expect(shape:getPointCount()).to.equal(4) + expect(shape:getFaceCount()).to.equal(4) + expect(shape:getFace(1)).to.equal({ 1, 2, 3 }) + expect(shape:getFace(2)).to.equal({ 2, 4, 3 }) + expect(shape:getFace(3)).to.equal({ 4, 1, 3 }) + expect(shape:getFace(4)).to.equal({ 1, 4, 2 }) if lovr.graphics then mesh = lovr.graphics.newMesh({