| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  | using System.Collections; | 
					
						
							|  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  | using Godot; | 
					
						
							|  |  |  | using System; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Rokojori | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2025-09-28 08:42:28 +00:00
										 |  |  |   public class OcTreeWalker<T,D>:TreeWalker<OcTreeNode<T,D>> | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  |   {  | 
					
						
							| 
									
										
										
										
											2025-09-28 08:42:28 +00:00
										 |  |  |     public override OcTreeNode<T,D> Parent( OcTreeNode<T,D> node ) | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-09-28 08:42:28 +00:00
										 |  |  |       if ( node is OcTree<T,D> ) | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  |       { | 
					
						
							|  |  |  |         return null; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-28 08:42:28 +00:00
										 |  |  |       var cell = node as OcTreeCell<T,D>; | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       return cell.isRoot ? cell.tree : cell.parent; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-28 08:42:28 +00:00
										 |  |  |     public override int NumChildren( OcTreeNode<T,D> node ) | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-09-28 08:42:28 +00:00
										 |  |  |       if ( node is OcTree<T,D> tree ) | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  |       { | 
					
						
							|  |  |  |         return tree.rootCells.Count; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-28 08:42:28 +00:00
										 |  |  |       var cell = node as OcTreeCell<T,D>; | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       return cell.numCells; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-28 08:42:28 +00:00
										 |  |  |     public override OcTreeNode<T,D> ChildAt( OcTreeNode<T,D> node, int index ) | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |       if ( index < 0 || index >= NumChildren( node ) ) | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         return null; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |        | 
					
						
							| 
									
										
										
										
											2025-09-28 08:42:28 +00:00
										 |  |  |       if ( node is OcTree<T,D> tree ) | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  |       { | 
					
						
							|  |  |  |         return tree.rootCells[ index ]; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-28 08:42:28 +00:00
										 |  |  |       var cell = node as OcTreeCell<T,D>; | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       return cell.cells[ index ]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |