mirror of https://github.com/bjornbytes/lovr.git
rm Shape setters;
Jolt doesn't support this and requires you to recreate the shape. Since the shape -> collider relationship is 1:N, we can't really create a new shape because we'd have to figure out which colliders/compoundshapes to assign it to, which isn't feasible.
This commit is contained in:
parent
6cf9f8082e
commit
48559ccd0f
|
@ -336,17 +336,9 @@ static int l_lovrSphereShapeGetRadius(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrSphereShapeSetRadius(lua_State* L) {
|
||||
SphereShape* sphere = luax_checktype(L, 1, SphereShape);
|
||||
float radius = luax_checkfloat(L, 2);
|
||||
lovrSphereShapeSetRadius(sphere, radius);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg lovrSphereShape[] = {
|
||||
lovrShape,
|
||||
{ "getRadius", l_lovrSphereShapeGetRadius },
|
||||
{ "setRadius", l_lovrSphereShapeSetRadius },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -360,18 +352,9 @@ static int l_lovrBoxShapeGetDimensions(lua_State* L) {
|
|||
return 3;
|
||||
}
|
||||
|
||||
static int l_lovrBoxShapeSetDimensions(lua_State* L) {
|
||||
BoxShape* box = luax_checktype(L, 1, BoxShape);
|
||||
float size[3];
|
||||
luax_readscale(L, 2, size, 3, NULL);
|
||||
lovrBoxShapeSetDimensions(box, size[0], size[1], size[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg lovrBoxShape[] = {
|
||||
lovrShape,
|
||||
{ "getDimensions", l_lovrBoxShapeGetDimensions },
|
||||
{ "setDimensions", l_lovrBoxShapeSetDimensions },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -381,32 +364,16 @@ static int l_lovrCapsuleShapeGetRadius(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrCapsuleShapeSetRadius(lua_State* L) {
|
||||
CapsuleShape* capsule = luax_checktype(L, 1, CapsuleShape);
|
||||
float radius = luax_checkfloat(L, 2);
|
||||
lovrCapsuleShapeSetRadius(capsule, radius);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrCapsuleShapeGetLength(lua_State* L) {
|
||||
CapsuleShape* capsule = luax_checktype(L, 1, CapsuleShape);
|
||||
lua_pushnumber(L, lovrCapsuleShapeGetLength(capsule));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrCapsuleShapeSetLength(lua_State* L) {
|
||||
CapsuleShape* capsule = luax_checktype(L, 1, CapsuleShape);
|
||||
float length = luax_checkfloat(L, 2);
|
||||
lovrCapsuleShapeSetLength(capsule, length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg lovrCapsuleShape[] = {
|
||||
lovrShape,
|
||||
{ "getRadius", l_lovrCapsuleShapeGetRadius },
|
||||
{ "setRadius", l_lovrCapsuleShapeSetRadius },
|
||||
{ "getLength", l_lovrCapsuleShapeGetLength },
|
||||
{ "setLength", l_lovrCapsuleShapeSetLength },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -416,32 +383,16 @@ static int l_lovrCylinderShapeGetRadius(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrCylinderShapeSetRadius(lua_State* L) {
|
||||
CylinderShape* cylinder = luax_checktype(L, 1, CylinderShape);
|
||||
float radius = luax_checkfloat(L, 2);
|
||||
lovrCylinderShapeSetRadius(cylinder, radius);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrCylinderShapeGetLength(lua_State* L) {
|
||||
CylinderShape* cylinder = luax_checktype(L, 1, CylinderShape);
|
||||
lua_pushnumber(L, lovrCylinderShapeGetLength(cylinder));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrCylinderShapeSetLength(lua_State* L) {
|
||||
CylinderShape* cylinder = luax_checktype(L, 1, CylinderShape);
|
||||
float length = luax_checkfloat(L, 2);
|
||||
lovrCylinderShapeSetLength(cylinder, length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg lovrCylinderShape[] = {
|
||||
lovrShape,
|
||||
{ "getRadius", l_lovrCylinderShapeGetRadius },
|
||||
{ "setRadius", l_lovrCylinderShapeSetRadius },
|
||||
{ "getLength", l_lovrCylinderShapeGetLength },
|
||||
{ "setLength", l_lovrCylinderShapeSetLength },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -171,23 +171,17 @@ void lovrShapeGetAABB(Shape* shape, float aabb[6]);
|
|||
|
||||
SphereShape* lovrSphereShapeCreate(float radius);
|
||||
float lovrSphereShapeGetRadius(SphereShape* sphere);
|
||||
void lovrSphereShapeSetRadius(SphereShape* sphere, float radius);
|
||||
|
||||
BoxShape* lovrBoxShapeCreate(float w, float h, float d);
|
||||
void lovrBoxShapeGetDimensions(BoxShape* box, float* w, float* h, float* d);
|
||||
void lovrBoxShapeSetDimensions(BoxShape* box, float w, float h, float d);
|
||||
|
||||
CapsuleShape* lovrCapsuleShapeCreate(float radius, float length);
|
||||
float lovrCapsuleShapeGetRadius(CapsuleShape* capsule);
|
||||
void lovrCapsuleShapeSetRadius(CapsuleShape* capsule, float radius);
|
||||
float lovrCapsuleShapeGetLength(CapsuleShape* capsule);
|
||||
void lovrCapsuleShapeSetLength(CapsuleShape* capsule, float length);
|
||||
|
||||
CylinderShape* lovrCylinderShapeCreate(float radius, float length);
|
||||
float lovrCylinderShapeGetRadius(CylinderShape* cylinder);
|
||||
void lovrCylinderShapeSetRadius(CylinderShape* cylinder, float radius);
|
||||
float lovrCylinderShapeGetLength(CylinderShape* cylinder);
|
||||
void lovrCylinderShapeSetLength(CylinderShape* cylinder, float length);
|
||||
|
||||
MeshShape* lovrMeshShapeCreate(int vertexCount, float vertices[], int indexCount, uint32_t indices[]);
|
||||
|
||||
|
|
|
@ -818,11 +818,6 @@ float lovrSphereShapeGetRadius(SphereShape* sphere) {
|
|||
return JPH_SphereShape_GetRadius((JPH_SphereShape*) sphere->shape);
|
||||
}
|
||||
|
||||
void lovrSphereShapeSetRadius(SphereShape* sphere, float radius) {
|
||||
lovrLog(LOG_WARN, "PHY", "Jolt SphereShape radius is read-only");
|
||||
// todo: no setter available, but the shape could be removed and re-added
|
||||
}
|
||||
|
||||
BoxShape* lovrBoxShapeCreate(float w, float h, float d) {
|
||||
BoxShape* box = lovrCalloc(sizeof(BoxShape));
|
||||
box->ref = 1;
|
||||
|
@ -841,11 +836,6 @@ void lovrBoxShapeGetDimensions(BoxShape* box, float* w, float* h, float* d) {
|
|||
*d = halfExtent.z * 2.f;
|
||||
}
|
||||
|
||||
void lovrBoxShapeSetDimensions(BoxShape* box, float w, float h, float d) {
|
||||
lovrLog(LOG_WARN, "PHY", "Jolt BoxShape dimensions are read-only");
|
||||
// todo: no setter available, but the shape could be removed and re-added
|
||||
}
|
||||
|
||||
CapsuleShape* lovrCapsuleShapeCreate(float radius, float length) {
|
||||
lovrCheck(radius > 0.f && length > 0.f, "CapsuleShape dimensions must be positive");
|
||||
CapsuleShape* capsule = lovrCalloc(sizeof(CapsuleShape));
|
||||
|
@ -860,20 +850,10 @@ float lovrCapsuleShapeGetRadius(CapsuleShape* capsule) {
|
|||
return JPH_CapsuleShape_GetRadius((JPH_CapsuleShape*) capsule->shape);
|
||||
}
|
||||
|
||||
void lovrCapsuleShapeSetRadius(CapsuleShape* capsule, float radius) {
|
||||
lovrLog(LOG_WARN, "PHY", "Jolt CapsuleShape radius is read-only");
|
||||
// todo: no setter available, but the shape could be removed and re-added
|
||||
}
|
||||
|
||||
float lovrCapsuleShapeGetLength(CapsuleShape* capsule) {
|
||||
return 2.f * JPH_CapsuleShape_GetHalfHeightOfCylinder((JPH_CapsuleShape*) capsule->shape);
|
||||
}
|
||||
|
||||
void lovrCapsuleShapeSetLength(CapsuleShape* capsule, float length) {
|
||||
lovrLog(LOG_WARN, "PHY", "Jolt CapsuleShape length is read-only");
|
||||
// todo: no setter available, but the shape could be removed and re-added
|
||||
}
|
||||
|
||||
CylinderShape* lovrCylinderShapeCreate(float radius, float length) {
|
||||
lovrCheck(radius > 0.f && length > 0.f, "CylinderShape dimensions must be positive");
|
||||
CylinderShape* cylinder = lovrCalloc(sizeof(CylinderShape));
|
||||
|
@ -888,20 +868,10 @@ float lovrCylinderShapeGetRadius(CylinderShape* cylinder) {
|
|||
return JPH_CylinderShape_GetRadius((JPH_CylinderShape*) cylinder->shape);
|
||||
}
|
||||
|
||||
void lovrCylinderShapeSetRadius(CylinderShape* cylinder, float radius) {
|
||||
lovrLog(LOG_WARN, "PHY", "Jolt CylinderShape radius is read-only");
|
||||
// todo: no setter available, but the shape could be removed and re-added
|
||||
}
|
||||
|
||||
float lovrCylinderShapeGetLength(CylinderShape* cylinder) {
|
||||
return JPH_CylinderShape_GetHalfHeight((JPH_CylinderShape*) cylinder->shape) * 2.f;
|
||||
}
|
||||
|
||||
void lovrCylinderShapeSetLength(CylinderShape* cylinder, float length) {
|
||||
lovrLog(LOG_WARN, "PHY", "Jolt CylinderShape length is read-only");
|
||||
// todo: no setter available, but the shape could be removed and re-added
|
||||
}
|
||||
|
||||
MeshShape* lovrMeshShapeCreate(int vertexCount, float vertices[], int indexCount, uint32_t indices[]) {
|
||||
MeshShape* mesh = lovrCalloc(sizeof(MeshShape));
|
||||
mesh->ref = 1;
|
||||
|
|
Loading…
Reference in New Issue