[Fix] Fix split point in BSP

This commit is contained in:
kleph 2016-05-18 23:47:37 +02:00
parent 47cb202181
commit df033d257c

View file

@ -45,7 +45,7 @@ class Leaf:
return False return False
split_point = random.randint(MIN_LEAF_SIZE, self.width - MIN_LEAF_SIZE) split_point = random.randint(MIN_LEAF_SIZE, self.width - MIN_LEAF_SIZE)
self.left_leaf = Leaf(self.x, self.y, split_point, self.height, self.id+1) self.left_leaf = Leaf(self.x, self.y, split_point, self.height, self.id+1)
self.right_leaf = Leaf(self.x + split_point-1, self.y, self.width - split_point+1, self.height, self.id+2) self.right_leaf = Leaf(self.x + split_point, self.y, self.width - split_point, self.height, self.id+2)
else: else:
# y # y
@ -53,7 +53,7 @@ class Leaf:
return False return False
split_point = random.randint(MIN_LEAF_SIZE, self.height - MIN_LEAF_SIZE) split_point = random.randint(MIN_LEAF_SIZE, self.height - MIN_LEAF_SIZE)
self.left_leaf = Leaf(self.x, self.y, self.width, split_point, self.id+1) self.left_leaf = Leaf(self.x, self.y, self.width, split_point, self.id+1)
self.right_leaf = Leaf(self.x, self.y + split_point-1, self.width, self.height - split_point+1, self.id+2) self.right_leaf = Leaf(self.x, self.y + split_point, self.width, self.height - split_point, self.id+2)
return True return True