Hello devforums!

im back again with another problem

so for context i created a voxelizer which basically subdivide parts. here is what it does.

from this part

to this

the voxelizing code is here

but problems arise when the size of the voxel does not add up to the size of the original part, here is the image version of the problem

for context, the y axis of the original part is 22 while the voxel part size is only 4 on each side which results in this:

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

notice that the black part only perfectly fits on the y axis while maintaining other axis the same size as other voxels.

so uh yeah can anyone help me out here? Im just stuck in this problem and its beginning to eat away my patience, thank you