Advertisement
Rakshalpha

OctreeComponent

Oct 14th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. namespace Assets.Scripts._CoreLibaryCode
  4. {
  5.     public class OctreeComponent : MonoBehaviour
  6.     {
  7.         public float size = 1;
  8.         public int depth = 1;
  9.  
  10.         private void Update()
  11.         {
  12.             if (Input.GetMouseButtonDown(0))
  13.             {
  14.                 var octree = new Octree<GameObject>(gameObject.transform.position, size, depth);
  15.  
  16.                 VoxelizeObject(octree.GetRoot());
  17.             }
  18.         }
  19.  
  20.         void VoxelizeObject(Octree<GameObject>.OctreeNode<GameObject> node, int nodeDepth = 0)
  21.         {
  22.             if (!node.IsLeaf())
  23.             {
  24.                 // Looping code goes here for activating pool of voxels
  25.                 // DrawCall(subnode, nodeDepth + 1);
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement