diff options
author | sanine <sanine.not@pm.me> | 2023-03-29 00:01:54 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-03-29 00:01:54 -0500 |
commit | 5a93fb6f6a8fb6f1dad821b407b4f4531bc23783 (patch) | |
tree | d7b7fb60868e2381bdd14efa357188ba3a27b804 /honey/ode.lua | |
parent | 45dbe47d17303050cbea7c2c51e838acfe21c2fb (diff) |
add image caching
Diffstat (limited to 'honey/ode.lua')
-rw-r--r-- | honey/ode.lua | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/honey/ode.lua b/honey/ode.lua new file mode 100644 index 0000000..4cd2e54 --- /dev/null +++ b/honey/ode.lua @@ -0,0 +1,55 @@ +local module = {} +setmetatable(module, {__index=_G} +setfenv(1, module) + + +--===== collision =====-- + +Geom = {} +Geom.__index = Geom + + +function Geom.new(_, type, params) + local self = {} + self.type = type + self.params = params + setmetatable(self, Geom) + return self +end +setmetatable(Geom, {__call=Geom.new}) + + +function Geom.renew(geom) + return ode.GeomGetData(geom) +end + + +local function instantiateSphere(space, params) + local geom = ode.CreateSphere(space, params.radius) + return geom +end + + +local function instantiatePlane(space, params) + local geom = ode.CreatePlane(space, params.a, params.b, params.c, params.d) + return geom +end + + +function Geom.instantiate(self, space) + if self.type == "sphere" then + self.geom = instantiateSphere(space, self.params) + elseif self.type == "plane" then + self.geom = instantiatePlane(space, self.params) + else + error(string.format("bad geom type: %s", self.type)) + end + ode.GeomSetData(self.geom, self) + return self +end + + +function Geom.setBody(self, body) + ode.GeomSetBody(self.geom, body.body) + return self +end |