Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What's a faster way to fill a voxel mesh along a spline?

Discussion in 'Scripting' started by keenanwoodall, Jul 27, 2015.

  1. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Posts:
    597
    I've been working on a voxel mesh and want to fill/erase the mesh along a spline. Right now I am incrementing along the spline and looping through the voxel grid for every increment; checking if the grid index is inside the volume of a cube at the point on the spline. This gets pretty inefficient when you have a long spline and increment at small values. Is there a way to loop through the indices once and check if it's near the spline?
    Here's a video of the current code. At around 2:40 on the video you can see the increment size being changed. Each cube that runs along the spline (each time it increments forward) loops through the entire grid of voxels. This results in a very inefficient program.