@@ -165,7 +165,12 @@ def _insert_skipped_nodes(cg: ChunkedGraph):
165165 uchunk_ids = np .unique (chunk_ids )
166166 children_chunks_map [node ] = uchunk_ids
167167 for c in uchunk_ids :
168- chunk_nodes_map [c ] = children [chunk_ids == c ]
168+ if c in chunk_nodes_map :
169+ chunk_nodes_map [c ] = np .concatenate (
170+ [chunk_nodes_map [c ], children [chunk_ids == c ]]
171+ )
172+ else :
173+ chunk_nodes_map [c ] = children [chunk_ids == c ]
169174 return HierarchyInfo (
170175 new_children_map ,
171176 children_chunks_map ,
@@ -176,7 +181,7 @@ def _insert_skipped_nodes(cg: ChunkedGraph):
176181 )
177182
178183
179- def _validate_octree (octree : np .ndarray , octree_node_ids : np .ndarray ):
184+ def _validate_octree (octree : np .ndarray , octree_chunks : np .ndarray ):
180185 assert octree .size % 5 == 0 , "Invalid octree size."
181186 num_nodes = octree .size // 5
182187 seen_nodes = set ()
@@ -192,7 +197,7 @@ def _explore_node(node: int):
192197 x , y , z = octree [node * 5 : node * 5 + 3 ]
193198 child_begin = octree [node * 5 + 3 ] & ~ (1 << 31 )
194199 child_end = octree [node * 5 + 4 ] & ~ (1 << 31 )
195- p = octree_node_ids [node ]
200+ p = octree_chunks [node ]
196201
197202 if (
198203 child_begin < 0
@@ -206,7 +211,7 @@ def _explore_node(node: int):
206211
207212 for child in range (child_begin , child_end ):
208213 cx , cy , cz = octree [child * 5 : child * 5 + 3 ]
209- c = octree_node_ids [child ]
214+ c = octree_chunks [child ]
210215 msg = f"Invalid child position: parent { (node , p )} at { (x , y , z )} , child { (child , c )} at { (cx , cy ,cz )} ."
211216 assert cx >> 1 == x and cy >> 1 == y and cz >> 1 == z , msg
212217 _explore_node (child )
@@ -287,7 +292,7 @@ def build_octree(
287292 if children_chunks .size == 0 :
288293 octree [offset + 4 ] |= 1 << 31
289294
290- # _validate_octree(octree, octree_node_ids )
295+ _validate_octree (octree , octree_chunks )
291296 fragments = []
292297 for chunk in octree_chunks :
293298 if chunk in virtual_chunk_hierarchy :
0 commit comments