DISABLED collision detection and physics

This commit is contained in:
2019-12-09 16:37:50 -06:00
parent 59334132c8
commit 75f94963b2
3 changed files with 7 additions and 6 deletions

View File

@@ -56,16 +56,16 @@ class IMICFPS
broadphase.each do |entity, _collisions|
_collisions.each do |ent|
# aabb vs aabb
next unless entity.bounding_box.intersect?(ent.bounding_box)
# next unless entity.bounding_box.intersect?(ent.bounding_box)
# entity model aabb tree vs ent model aabb tree
ent_tree_search = ent.model.aabb_tree.search(localize_entity_bounding_box(entity, ent), true)
next if ent_tree_search.size == 0
# ent_tree_search = ent.model.aabb_tree.search(localize_entity_bounding_box(entity, ent), true)
# next if ent_tree_search.size == 0
# puts "#{ent.class} -> #{ent_tree_search.size} (#{Gosu.milliseconds})"
entity.position.y = ent_tree_search.first.object.vertices.first.y if entity.is_a?(Player) && ent.is_a?(Terrain)
# entity.position.y = ent_tree_search.first.object.vertices.first.y if entity.is_a?(Player) && ent.is_a?(Terrain)
@collisions[entity] = _collisions
# @collisions[entity] = _collisions
end
end
end

View File

@@ -32,6 +32,7 @@ class IMICFPS
entity.velocity.y = 0
else
entity.velocity.y -= @collision_manager.map.gravity * entity.delta_time if entity.manifest.physics
entity.velocity.y = 0 if entity.velocity.y < 0
end
end
end

View File

@@ -55,7 +55,7 @@ class IMICFPS
end
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)
build_collision_tree
# build_collision_tree
puts " Building mesh collision tree took #{((Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)-start_time)/1000.0).round(2)} seconds" if $debug.get(:stats)
end