now what i want to do in this special situation is to add parts on the axis that the voxel could not fill while maintaining the size on other axis which can be filled, here is another image of what i mean
i dont think you get what i mean, i have the problem when the voxel size are not able to add up to the original parts which results empty spaces, for more details please re-read the post again.
im not sure if its you or me misunderstanding but that’s not what i wanted though?
im subdividing a cube to a set of sizes that breaks a part to a few parts, but problem arise when that set of sizes are not able to add up to the original 1 part cube, do you get what i mean here?
this happens when the set size for little bob’s is (4,4,4) while Bob size is (20, 22, 20).
Now what i want to do is to make the code to create a part that will fit in those empty spaces to complete Bob’s size while still being the same as other little bob’s, for example
from the image above we know that all little bob’s size adds up to (20,20,20) while Bob’s size is (20, 22, 20), we just need a part that has the size of (4,2,4) so it can perfectly fits within Bob’s size, here is the image of what im talking about
the black part’s size on the x and z is 4 which is the same as other little bob’s but the size of the y axis is 2 so it fills completely bob’s size
Instead of using the part size directly, you could round each axis up to the nearest multiple of voxelSize:
local function roundUp(x, n)
return n*math.ceil(x / n)
end
local size = Vector3.new(
roundUp(part.Size.X, voxSize),
roundUp(part.Size.Y, voxSize),
roundUp(part.Size.Z, voxSize)
)
And then use that size in your loop instead.
You may need to add some padding here and there to avoid rounding errors.