mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 23:52:35 +00:00
Exported door model, added CollisionManager#on_ground?(entity), made gravity work in PhyisicsManager if Entity has physics enabled, updated test map
This commit is contained in:
@@ -82,5 +82,29 @@ class IMICFPS
|
||||
|
||||
return box
|
||||
end
|
||||
|
||||
def on_ground?(entity) # TODO: Use some form of caching to speed this up
|
||||
on_ground = false
|
||||
@collisions.detect do |a, b|
|
||||
next unless entity == a || entity == b
|
||||
|
||||
vs = a
|
||||
vs = b if a == entity
|
||||
|
||||
broadphase = search(Ray.new(entity.position, Vector.new(0, -1, 0), entity.velocity.y.abs))
|
||||
|
||||
broadphase.detect do |ent|
|
||||
ray = Ray.new(entity.position - ent.position, Vector.new(0, -1, 0))
|
||||
if ent.model.aabb_tree.search(ray).size > 0
|
||||
on_ground = true
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
break if on_ground
|
||||
end
|
||||
|
||||
return on_ground
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user