Rename CoordinateSpace;

It's now OriginType, and global -> root and local -> parent.
This commit is contained in:
bjorn 2022-08-17 22:33:43 -07:00
parent f570ee980c
commit f515346e20
5 changed files with 23 additions and 23 deletions

View File

@ -28,7 +28,6 @@ extern StringEntry lovrBlockType[];
extern StringEntry lovrBufferLayout[];
extern StringEntry lovrChannelLayout[];
extern StringEntry lovrCompareMode[];
extern StringEntry lovrCoordinateSpace[];
extern StringEntry lovrCullMode[];
extern StringEntry lovrDefaultAttribute[];
extern StringEntry lovrDefaultShader[];
@ -47,6 +46,7 @@ extern StringEntry lovrHorizontalAlign[];
extern StringEntry lovrJointType[];
extern StringEntry lovrKeyboardKey[];
extern StringEntry lovrMeshMode[];
extern StringEntry lovrOriginType[];
extern StringEntry lovrPassType[];
extern StringEntry lovrPermission[];
extern StringEntry lovrSampleFormat[];

View File

@ -45,12 +45,6 @@ StringEntry lovrCompareMode[] = {
{ 0 }
};
StringEntry lovrCoordinateSpace[] = {
[SPACE_LOCAL] = ENTRY("local"),
[SPACE_GLOBAL] = ENTRY("global"),
{ 0 }
};
StringEntry lovrCullMode[] = {
[CULL_NONE] = ENTRY("none"),
[CULL_FRONT] = ENTRY("front"),
@ -132,6 +126,12 @@ StringEntry lovrMeshMode[] = {
{ 0 }
};
StringEntry lovrOriginType[] = {
[ORIGIN_ROOT] = ENTRY("root"),
[ORIGIN_PARENT] = ENTRY("parent"),
{ 0 }
};
StringEntry lovrPassType[] = {
[PASS_RENDER] = ENTRY("render"),
[PASS_COMPUTE] = ENTRY("compute"),

View File

@ -110,9 +110,9 @@ static int l_lovrModelGetNodeDraw(lua_State* L) {
static int l_lovrModelGetNodePosition(lua_State* L) {
Model* model = luax_checktype(L, 1, Model);
uint32_t node = luax_checknodeindex(L, 2, model);
CoordinateSpace space = luax_checkenum(L, 3, CoordinateSpace, "global");
OriginType origin = luax_checkenum(L, 3, OriginType, "root");
float position[4], scale[4], rotation[4];
lovrModelGetNodeTransform(model, node, position, scale, rotation, space);
lovrModelGetNodeTransform(model, node, position, scale, rotation, origin);
lua_pushnumber(L, position[0]);
lua_pushnumber(L, position[1]);
lua_pushnumber(L, position[2]);
@ -132,9 +132,9 @@ static int l_lovrModelSetNodePosition(lua_State* L) {
static int l_lovrModelGetNodeScale(lua_State* L) {
Model* model = luax_checktype(L, 1, Model);
uint32_t node = luax_checknodeindex(L, 2, model);
CoordinateSpace space = luax_checkenum(L, 3, CoordinateSpace, "global");
OriginType origin = luax_checkenum(L, 3, OriginType, "root");
float position[4], scale[4], rotation[4], angle, ax, ay, az;
lovrModelGetNodeTransform(model, node, position, scale, rotation, space);
lovrModelGetNodeTransform(model, node, position, scale, rotation, origin);
quat_getAngleAxis(rotation, &angle, &ax, &ay, &az);
lua_pushnumber(L, angle);
lua_pushnumber(L, ax);
@ -156,9 +156,9 @@ static int l_lovrModelSetNodeScale(lua_State* L) {
static int l_lovrModelGetNodeOrientation(lua_State* L) {
Model* model = luax_checktype(L, 1, Model);
uint32_t node = luax_checknodeindex(L, 2, model);
CoordinateSpace space = luax_checkenum(L, 3, CoordinateSpace, "global");
OriginType origin = luax_checkenum(L, 3, OriginType, "root");
float position[4], scale[4], rotation[4], angle, ax, ay, az;
lovrModelGetNodeTransform(model, node, position, scale, rotation, space);
lovrModelGetNodeTransform(model, node, position, scale, rotation, origin);
quat_getAngleAxis(rotation, &angle, &ax, &ay, &az);
lua_pushnumber(L, angle);
lua_pushnumber(L, ax);
@ -180,9 +180,9 @@ static int l_lovrModelSetNodeOrientation(lua_State* L) {
static int l_lovrModelGetNodePose(lua_State* L) {
Model* model = luax_checktype(L, 1, Model);
uint32_t node = luax_checknodeindex(L, 2, model);
CoordinateSpace space = luax_checkenum(L, 3, CoordinateSpace, "global");
OriginType origin = luax_checkenum(L, 3, OriginType, "root");
float position[4], scale[4], rotation[4], angle, ax, ay, az;
lovrModelGetNodeTransform(model, node, position, scale, rotation, space);
lovrModelGetNodeTransform(model, node, position, scale, rotation, origin);
quat_getAngleAxis(rotation, &angle, &ax, &ay, &az);
lua_pushnumber(L, position[0]);
lua_pushnumber(L, position[1]);
@ -209,9 +209,9 @@ static int l_lovrModelSetNodePose(lua_State* L) {
static int l_lovrModelGetNodeTransform(lua_State* L) {
Model* model = luax_checktype(L, 1, Model);
uint32_t node = luax_checknodeindex(L, 2, model);
CoordinateSpace space = luax_checkenum(L, 3, CoordinateSpace, "global");
OriginType origin = luax_checkenum(L, 3, OriginType, "root");
float position[4], scale[4], rotation[4], angle, ax, ay, az;
lovrModelGetNodeTransform(model, node, position, scale, rotation, space);
lovrModelGetNodeTransform(model, node, position, scale, rotation, origin);
quat_getAngleAxis(rotation, &angle, &ax, &ay, &az);
lua_pushnumber(L, position[0]);
lua_pushnumber(L, position[1]);

View File

@ -2811,8 +2811,8 @@ void lovrModelAnimate(Model* model, uint32_t animationIndex, float time, float a
model->transformsDirty = true;
}
void lovrModelGetNodeTransform(Model* model, uint32_t node, float position[4], float scale[4], float rotation[4], CoordinateSpace space) {
if (space == SPACE_LOCAL) {
void lovrModelGetNodeTransform(Model* model, uint32_t node, float position[4], float scale[4], float rotation[4], OriginType origin) {
if (origin == ORIGIN_PARENT) {
vec3_init(position, model->localTransforms[node].properties[PROP_TRANSLATION]);
vec3_init(scale, model->localTransforms[node].properties[PROP_SCALE]);
quat_init(rotation, model->localTransforms[node].properties[PROP_ROTATION]);

View File

@ -401,9 +401,9 @@ typedef struct {
} ModelInfo;
typedef enum {
SPACE_LOCAL,
SPACE_GLOBAL
} CoordinateSpace;
ORIGIN_ROOT,
ORIGIN_PARENT
} OriginType;
typedef enum {
MESH_POINTS,
@ -427,7 +427,7 @@ uint32_t lovrModelGetNodeDrawCount(Model* model, uint32_t node);
void lovrModelGetNodeDraw(Model* model, uint32_t node, uint32_t index, ModelDraw* draw);
void lovrModelResetNodeTransforms(Model* model);
void lovrModelAnimate(Model* model, uint32_t animationIndex, float time, float alpha);
void lovrModelGetNodeTransform(Model* model, uint32_t node, float position[4], float scale[4], float rotation[4], CoordinateSpace space);
void lovrModelGetNodeTransform(Model* model, uint32_t node, float position[4], float scale[4], float rotation[4], OriginType origin);
void lovrModelSetNodeTransform(Model* model, uint32_t node, float position[4], float scale[4], float rotation[4], float alpha);
Texture* lovrModelGetTexture(Model* model, uint32_t index);
Material* lovrModelGetMaterial(Model* model, uint32_t index);