mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-16 08:02:36 +00:00
Improved terrain collision slightly
This commit is contained in:
@@ -39,7 +39,7 @@ class IMICFPS
|
||||
smaller_list.each do |vert|
|
||||
next if vert.nil?
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -49,6 +49,10 @@ class IMICFPS
|
||||
|
||||
return nearest
|
||||
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
|
||||
# class IMICFPS
|
||||
|
||||
Reference in New Issue
Block a user