Improved terrain collision slightly

This commit is contained in:
2018-07-01 19:10:09 -05:00
parent 5fa2843de2
commit 4c603c3a3d
2 changed files with 6 additions and 2 deletions

View File

@@ -39,7 +39,7 @@ class IMICFPS
smaller_list.each do |vert| smaller_list.each do |vert|
next if vert.nil? next if vert.nil?
if nearest if nearest
if Gosu.distance(vertex.x, vertex.z, vert.x, vert.z) < Gosu.distance(nearest.x, nearest.z, vert.x, vert.z) if distance(vert, vertex) < distance(vert, nearest)
nearest = vert nearest = vert
end end
end end
@@ -49,6 +49,10 @@ class IMICFPS
return nearest return nearest
end end
def distance(vertex, other)
return Math.sqrt((vertex.x-other.x)**2 + (vertex.y-other.y)**2 + (vertex.z-other.z)**2)
end
end end
end end
# class IMICFPS # class IMICFPS

View File

@@ -95,7 +95,7 @@ Camera X:#{@camera.x.round(2)} Y:#{@camera.y.round(2)} Z:#{@camera.z.round(2)}
Field Of View: #{@camera.field_of_view} Field Of View: #{@camera.field_of_view}
Mouse Sesitivity: #{@camera.mouse_sensitivity} Mouse Sesitivity: #{@camera.mouse_sensitivity}
Faces: #{@number_of_faces} Faces: #{@number_of_faces}
Last Frame: #{delta_time}ms (#{Gosu.fps} fps) Last Frame: #{delta_time*1000.0}ms (#{Gosu.fps} fps)
Draw Skydome: #{@draw_skydome} Draw Skydome: #{@draw_skydome}
Debug mode: <c=992200>#{$debug}</c> Debug mode: <c=992200>#{$debug}</c>