mirror of https://github.com/bjornbytes/lovr.git
World:getGravity; World:setGravity;
This commit is contained in:
parent
70bc90154b
commit
3c8f4bd63b
|
@ -1,6 +1,27 @@
|
||||||
#include "api/lovr.h"
|
#include "api/lovr.h"
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
|
||||||
|
int l_lovrWorldGetGravity(lua_State* L) {
|
||||||
|
World* world = luax_checktype(L, 1, World);
|
||||||
|
float x, y, z;
|
||||||
|
lovrWorldGetGravity(world, &x, &y, &z);
|
||||||
|
lua_pushnumber(L, x);
|
||||||
|
lua_pushnumber(L, y);
|
||||||
|
lua_pushnumber(L, z);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
int l_lovrWorldSetGravity(lua_State* L) {
|
||||||
|
World* world = luax_checktype(L, 1, World);
|
||||||
|
float x = luaL_checknumber(L, 2);
|
||||||
|
float y = luaL_checknumber(L, 3);
|
||||||
|
float z = luaL_checknumber(L, 4);
|
||||||
|
lovrWorldSetGravity(world, x, y, z);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg lovrWorld[] = {
|
const luaL_Reg lovrWorld[] = {
|
||||||
|
{ "getGravity", l_lovrWorldGetGravity },
|
||||||
|
{ "setGravity", l_lovrWorldSetGravity },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,3 +29,15 @@ void lovrWorldDestroy(const Ref* ref) {
|
||||||
dWorldDestroy(world->id);
|
dWorldDestroy(world->id);
|
||||||
free(world);
|
free(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lovrWorldGetGravity(World* world, float* x, float* y, float* z) {
|
||||||
|
dReal gravity[3];
|
||||||
|
dWorldGetGravity(world->id, gravity);
|
||||||
|
*x = gravity[0];
|
||||||
|
*y = gravity[1];
|
||||||
|
*z = gravity[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
void lovrWorldSetGravity(World* world, float x, float y, float z) {
|
||||||
|
dWorldSetGravity(world->id, x, y, z);
|
||||||
|
}
|
||||||
|
|
|
@ -11,3 +11,5 @@ void lovrPhysicsDestroy();
|
||||||
|
|
||||||
World* lovrWorldCreate();
|
World* lovrWorldCreate();
|
||||||
void lovrWorldDestroy(const Ref* ref);
|
void lovrWorldDestroy(const Ref* ref);
|
||||||
|
void lovrWorldGetGravity(World* world, float* x, float* y, float* z);
|
||||||
|
void lovrWorldSetGravity(World* world, float x, float y, float z);
|
||||||
|
|
Loading…
Reference in New Issue