|
7 | 7 | #define lglm_cpp |
8 | 8 | #define LUA_CORE |
9 | 9 |
|
| 10 | +/* @TEMP Disallow 820a2c0e625f26000c688d841836bb10483be34d */ |
| 11 | +#if defined(GLM_FORCE_QUAT_DATA_XYZW) |
| 12 | + #error "glm broke compatbility, please compile without GLM_FORCE_QUAT_DATA_XYZW" |
| 13 | +#endif |
| 14 | + |
10 | 15 | /* |
11 | 16 | @@ LUA_API_LINKAGE is a mark for the linkage specification to core API functions |
12 | 17 | */ |
@@ -1035,8 +1040,12 @@ lua_Integer luaO_HashString(const char *string, size_t length, int ignore_case) |
1035 | 1040 | hash ^= (hash >> 11); |
1036 | 1041 | hash += (hash << 15); |
1037 | 1042 |
|
| 1043 | +#if defined(GRIT_POWER_UHASH) |
| 1044 | + return l_castU2S(hash); |
| 1045 | +#else |
1038 | 1046 | // @TODO: Eventually avoid sign-extension issues. If ever... |
1039 | 1047 | return (lua_Integer)(int)hash; |
| 1048 | +#endif |
1040 | 1049 | } |
1041 | 1050 |
|
1042 | 1051 | /* gritLua functions stored in lbaselib; considered deprecated */ |
@@ -1280,8 +1289,13 @@ LUA_API void lua_pushvector (lua_State *L, lua_Float4 f4, int variant) { |
1280 | 1289 | } |
1281 | 1290 | else if (b_variant == LUA_VVECTOR1) |
1282 | 1291 | lua_pushnumber(L, cast_num(f4.x)); |
1283 | | - else if (b_variant == LUA_VQUAT) |
| 1292 | + else if (b_variant == LUA_VQUAT) { |
| 1293 | +#if defined(GLM_FORCE_QUAT_DATA_XYZW) |
| 1294 | + glm_pushvec_quat(L, glmVector(glm::qua<glm_Float>(f4.x, f4.y, f4.z, f4.w))); |
| 1295 | +#else |
1284 | 1296 | glm_pushvec_quat(L, glmVector(glm::qua<glm_Float>(f4.w, f4.x, f4.y, f4.z))); |
| 1297 | +#endif |
| 1298 | + } |
1285 | 1299 | else |
1286 | 1300 | glm_pushvec(L, glmVector(glm::vec<4, glm_Float>(f4.x, f4.y, f4.z, f4.w)), glm_dimensions(b_variant)); |
1287 | 1301 | } |
@@ -1647,12 +1661,20 @@ LUA_API int glmVec_qua(lua_State *L) { |
1647 | 1661 | if (ttisvector3(o2)) // <angle, axis>, degrees for gritLua compatibility |
1648 | 1662 | return glm_pushquat(L, glm::angleAxis(cast_glmfloat(glm::radians(nvalue(o1))), glm_vecvalue(o2).v3)); |
1649 | 1663 | else if (ttisnumber(o2)) { // <w, x, y, z> |
| 1664 | +#if defined(GLM_FORCE_QUAT_DATA_XYZW) |
| 1665 | + const glm_Float w = cast_glmfloat(nvalue(o1)); |
| 1666 | + const glm_Float x = cast_glmfloat(nvalue(o2)); |
| 1667 | + const glm_Float y = cast_glmfloat(luaL_checknumber(L, 3)); |
| 1668 | + const glm_Float z = cast_glmfloat(luaL_checknumber(L, 4)); |
| 1669 | + return glm_pushquat(L, glm::qua<glm_Float>(x, y, z, w)); |
| 1670 | +#else |
1650 | 1671 | return glm_pushquat(L, glm::qua<glm_Float>( |
1651 | 1672 | cast_glmfloat(nvalue(o1)), |
1652 | 1673 | cast_glmfloat(nvalue(o2)), |
1653 | 1674 | cast_glmfloat(luaL_checknumber(L, 3)), |
1654 | 1675 | cast_glmfloat(luaL_checknumber(L, 4))) |
1655 | 1676 | ); |
| 1677 | +#endif |
1656 | 1678 | } |
1657 | 1679 | return luaL_error(L, "{w, x, y, z} or {angle, axis} expected"); |
1658 | 1680 | } |
|
0 commit comments