mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-16 08:02:36 +00:00
Fixed always adding a new node to AABBTree when updating a node.
This commit is contained in:
@@ -28,9 +28,9 @@ class IMICFPS
|
|||||||
@physics_manager.update
|
@physics_manager.update
|
||||||
|
|
||||||
# binding.irb
|
# binding.irb
|
||||||
p @aabb_tree
|
# p @aabb_tree
|
||||||
collisions.each do |ent, list|
|
collisions.each do |ent, list|
|
||||||
puts "#{ent.class} -> [#{list.map{|e| e.class}.join(', ')}]"
|
# puts "#{ent.class} -> [#{list.map{|e| e.class}.join(', ')}]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -79,13 +79,6 @@ class IMICFPS
|
|||||||
glMatrixMode(GL_MODELVIEW) # The modelview matrix is where object information is stored.
|
glMatrixMode(GL_MODELVIEW) # The modelview matrix is where object information is stored.
|
||||||
glLoadIdentity
|
glLoadIdentity
|
||||||
|
|
||||||
# if $debug && @entity
|
|
||||||
# glBegin(GL_LINES)
|
|
||||||
# glColor3f(1,0,0)
|
|
||||||
# glVertex3f(@x, @y, @z)
|
|
||||||
# glVertex3f(@entity.x, @entity.y, @entity.z)
|
|
||||||
# glEnd
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
class IMICFPS
|
class IMICFPS
|
||||||
class AABBTree
|
class AABBTree
|
||||||
class AABBNode
|
class AABBNode
|
||||||
attr_accessor :bounding_box, :parent, :object, :a, :b
|
attr_accessor :bounding_box, :parent, :object
|
||||||
|
attr_reader :a, :b
|
||||||
def initialize(parent:, object:, bounding_box:)
|
def initialize(parent:, object:, bounding_box:)
|
||||||
@parent = parent
|
@parent = parent
|
||||||
@object = object
|
@object = object
|
||||||
@@ -11,6 +12,16 @@ class IMICFPS
|
|||||||
@b = nil
|
@b = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def a=(leaf)
|
||||||
|
@a = leaf
|
||||||
|
@a.parent = self
|
||||||
|
end
|
||||||
|
|
||||||
|
def b=(leaf)
|
||||||
|
@b = leaf
|
||||||
|
@b.parent = self
|
||||||
|
end
|
||||||
|
|
||||||
def leaf?
|
def leaf?
|
||||||
@object
|
@object
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ class IMICFPS
|
|||||||
def update(object, bounding_box)
|
def update(object, bounding_box)
|
||||||
leaf = remove(object)
|
leaf = remove(object)
|
||||||
leaf.bounding_box = bounding_box
|
leaf.bounding_box = bounding_box
|
||||||
@objects[object] = leaf
|
|
||||||
insert_leaf(leaf)
|
insert_leaf(leaf)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -50,7 +49,6 @@ class IMICFPS
|
|||||||
def remove(object)
|
def remove(object)
|
||||||
leaf = @objects.delete(object)
|
leaf = @objects.delete(object)
|
||||||
@root = @root.remove_subtree(leaf) if leaf
|
@root = @root.remove_subtree(leaf) if leaf
|
||||||
@root.parent = nil
|
|
||||||
|
|
||||||
return leaf
|
return leaf
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user