summaryrefslogtreecommitdiff
path: root/honey/ecs-systems.lua
diff options
context:
space:
mode:
Diffstat (limited to 'honey/ecs-systems.lua')
-rw-r--r--honey/ecs-systems.lua36
1 files changed, 25 insertions, 11 deletions
diff --git a/honey/ecs-systems.lua b/honey/ecs-systems.lua
index e400011..3243d02 100644
--- a/honey/ecs-systems.lua
+++ b/honey/ecs-systems.lua
@@ -121,11 +121,11 @@ function renderCamera(params)
for id, camera in pairs(self.db:queryComponent("camera")) do
local projection = camera.projection
local cameraTransform = self.db:getComponent(id, "transform")
- local view
+ local view = Mat4()
if cameraTransform then
- view = cameraTransform._matrix
+ honey.glm.mat4_inv(cameraTransform._matrix.data, view.data)
else
- view = Mat4():identity()
+ view:identity()
end
local entities = self.db:queryComponent("renderMesh")
@@ -227,6 +227,14 @@ physics = function(params)
physics.mass.density,
physics.mass.radius
)
+ elseif class == "capsule" then
+ ode.MassSetCapsule(
+ mass,
+ physics.mass.density,
+ physics.mass.direction,
+ physics.mass.radius,
+ physics.mass.length
+ )
end
ode.BodySetMass(body, mass)
local m = self.db:getComponent(id, "transform").matrix
@@ -240,18 +248,22 @@ physics = function(params)
m[2][1], m[2][2], m[2][3],
m[3][1], m[3][2], m[3][3]
)
+ local vel = physics.velocity or Vec3{0,0,0}
ode.BodySetLinearVel(
- body,
- physics.velocity[1],
- physics.velocity[2],
- physics.velocity[3]
+ body, vel[1], vel[2], vel[3]
)
+ physics.velocity = vel
+
+ local avel = physics.angularVelocity or Vec3{0,0,0}
ode.BodySetAngularVel(
- body,
- physics.angularVelocity[1],
- physics.angularVelocity[2],
- physics.angularVelocity[3]
+ body, avel[1], avel[2], avel[3]
)
+ physics.angularVelocity = avel
+
+ if physics.maxAngularSpeed then
+ ode.BodySetMaxAngularSpeed(physics.maxAngularSpeed)
+ end
+
physics._body = body
end
end
@@ -321,6 +333,8 @@ local function createGeom(self, id, collision)
local geom
if collision.class == "sphere" then
geom = ode.CreateSphere(self.space, collision.radius)
+ elseif collision.class == "capsule" then
+ geom = ode.CreateCapsule(self.space, collision.radius, collision.length)
elseif collision.class == "plane" then
local transform = self.db:getComponent(id, "transform")
local m = transform.matrix