I’ve been working on a voxel destruction system for my fps game for a while now and I recently realized once I implemented welding that getting the position for parts after greedy meshing does not account for the original rotation of the target part. My code works by splitting up a target part into 1x1x1 voxels and then checking for collisions on each one. Once I have the voxels that haven’t collided with anything I greedy mesh them and use the voxel size and the new size for the greedy meshed part to get a position. I’m not great with CFrame math so I’m trying to get any help I can get.
Here are some images of what it looks like(the red parts are what it should line up with):
I’ve already tried this but since the rotation is applied to the middle of the part it offsets it even more and I couldn’t figure out how to correct it, I know you could pivot it but I don’t know how I would be able to figure out where to pivot it from.
In the total algorithm for deciding position you may have to consider the local vector space of the original part when figuring out the position of the new part. Your current positioning is world axis aligned, so if the original part is rotated, the world axis will no longer be aligned with the axis of the part. The CFrame of the original part should give some insight into this. You may be able to translate using the CFrame of the original part, as multiplying a CFrame by a Vector3 will translate that Vector3 in object space but give you the world coordinates as a result
The thing that makes this tricky is since the original part’s position I’m using to calculate the new position has a different size, that’s why I have to do all the math with the part’s size to get a new position, thats why you can’t translate to object space otherwise it will break things.
Without seeing how regionPos coordinates are derived from the original part, which would require object space translation, I can’t help you any further
Thanks for this reply, I ended up doing more research and while I was looking on the forum I came across this post: Non-voxel greedy mesher for runtime parts merging/map optimization. The code helped me understand I just needed to multiply the original position by a new CFrame using the new greedy meshed size and now it works perfectly for rotated objects and I have realtime destruction physics.