Added some comments.
This commit is contained in:
parent
ec8ba98b56
commit
c56e93a617
1 changed files with 14 additions and 5 deletions
19
math/spvo.py
19
math/spvo.py
|
@ -25,17 +25,26 @@ class SparseVoxelOctree:
|
||||||
self.origin = (0, 0, 0)
|
self.origin = (0, 0, 0)
|
||||||
|
|
||||||
def _get_child_index(self, x, y, z, size):
|
def _get_child_index(self, x, y, z, size):
|
||||||
|
"""
|
||||||
|
Get the index of a child.
|
||||||
|
Index: The position of the node in the node parent's children list.
|
||||||
|
"""
|
||||||
|
|
||||||
index = 0
|
index = 0
|
||||||
|
|
||||||
if x >= size // 2:
|
if x >= size // 2: # x pos
|
||||||
index |= 1
|
# there are only 2 possible x coordinate values in a 2x2 cube, so we use the 1st bit in index for x
|
||||||
x -= size // 2
|
# xyz: the coordinates of the parent node
|
||||||
|
index |= 1 # set 1st bit to 1
|
||||||
|
x -= size // 2 # get parent x
|
||||||
|
|
||||||
if y >= size // 2:
|
# and the same for y and z
|
||||||
|
|
||||||
|
if y >= size // 2: # y pos
|
||||||
index |= 2
|
index |= 2
|
||||||
y -= size // 2
|
y -= size // 2
|
||||||
|
|
||||||
if z >= size // 2:
|
if z >= size // 2: # z pos
|
||||||
index |= 4
|
index |= 4
|
||||||
z -= size // 2
|
z -= size // 2
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue