mirror of https://github.com/bjornbytes/lovr.git
Shape;
This commit is contained in:
parent
4ac72a54d6
commit
43ac25a61d
|
@ -48,6 +48,7 @@ extern map_int_t MeshAttributeTypes;
|
|||
extern map_int_t MeshDrawModes;
|
||||
extern map_int_t MeshUsages;
|
||||
extern map_int_t PolygonWindings;
|
||||
extern map_int_t ShapeTypes;
|
||||
extern map_int_t TextureProjections;
|
||||
extern map_int_t TimeUnits;
|
||||
extern map_int_t VerticalAligns;
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
#include "api/lovr.h"
|
||||
#include "physics/physics.h"
|
||||
|
||||
map_int_t ShapeTypes;
|
||||
|
||||
int l_lovrPhysicsInit(lua_State* L) {
|
||||
lua_newtable(L);
|
||||
luaL_register(L, NULL, lovrPhysics);
|
||||
luax_registertype(L, "World", lovrWorld);
|
||||
luax_registertype(L, "Body", lovrBody);
|
||||
|
||||
map_init(&ShapeTypes);
|
||||
map_set(&ShapeTypes, "sphere", SHAPE_SPHERE);
|
||||
map_set(&ShapeTypes, "box", SHAPE_BOX);
|
||||
map_set(&ShapeTypes, "capsule", SHAPE_CAPSULE);
|
||||
map_set(&ShapeTypes, "cylinder", SHAPE_CYLINDER);
|
||||
|
||||
lovrPhysicsInit();
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -264,3 +264,13 @@ void lovrBodySetUserData(Body* body, void* data) {
|
|||
World* lovrBodyGetWorld(Body* body) {
|
||||
return body->world;
|
||||
}
|
||||
|
||||
ShapeType lovrShapeGetType(Shape* shape) {
|
||||
return shape->type;
|
||||
}
|
||||
|
||||
void lovrShapeDestroy(const Ref* ref) {
|
||||
Shape* shape = containerof(ref, Shape);
|
||||
dGeomDestroy(shape->id);
|
||||
free(shape);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
#include "util.h"
|
||||
#include <ode/ode.h>
|
||||
|
||||
typedef enum {
|
||||
SHAPE_SPHERE,
|
||||
SHAPE_BOX,
|
||||
SHAPE_CAPSULE,
|
||||
SHAPE_CYLINDER
|
||||
} ShapeType;
|
||||
|
||||
typedef struct {
|
||||
Ref ref;
|
||||
dWorldID id;
|
||||
|
@ -12,6 +19,12 @@ typedef struct {
|
|||
World* world;
|
||||
} Body;
|
||||
|
||||
typedef struct {
|
||||
Ref ref;
|
||||
ShapeType type;
|
||||
dGeomID id;
|
||||
} Shape;
|
||||
|
||||
void lovrPhysicsInit();
|
||||
void lovrPhysicsDestroy();
|
||||
|
||||
|
@ -59,3 +72,6 @@ void lovrBodySetAwake(Body* body, int awake);
|
|||
void* lovrBodyGetUserData(Body* body);
|
||||
void lovrBodySetUserData(Body* body, void* data);
|
||||
World* lovrBodyGetWorld(Body* body);
|
||||
|
||||
ShapeType lovrShapeGetType(Shape* shape);
|
||||
void lovrShapeDestroy(const Ref* ref);
|
||||
|
|
Loading…
Reference in New Issue