lovr/src/physics/physics.c

32 lines
566 B
C
Raw Normal View History

2017-05-16 04:59:53 +00:00
#include "physics.h"
#include <stdlib.h>
void lovrPhysicsInit() {
dInitODE();
if (!dCheckConfiguration("ODE_single_precision")) {
error("lovr.physics must use single precision");
}
atexit(lovrPhysicsDestroy);
}
void lovrPhysicsDestroy() {
dCloseODE();
}
2017-05-16 05:02:08 +00:00
World* lovrWorldCreate() {
World* world = lovrAlloc(sizeof(World), lovrWorldDestroy);
if (!world) return NULL;
world->id = dWorldCreate();
return world;
}
void lovrWorldDestroy(const Ref* ref) {
World* world = containerof(ref, World);
dWorldDestroy(world->id);
free(world);
}