- Home /
Correct position of overlapping meshes
I am working on an AR-App where the user is required to measure multiple rooms. Due to inaccuracies during the measurement-process, the rooms tend to overlap sometimes as seen in the example on the left.
I want to correct the position of the rooms to prevent overlapping as seen in the example on the right.
What I tried so far, is to use mesholliders to calculate the penetration between the rooms using Physics.ComputePenetration
and then continuously moving each room using the method's return parameters out Vector3 direction
and out float distance
until there is no further penetration. This gives me the following result:
Because I can only use convex mesh colliders to compute penetration, there is quite a huge offset whenever the rooms have a more concave shape.
Is there any way I can get around this? Maybe there is also a completely different approach that works better. I only need to prevent the rooms from overlapping while their positions should be as close as possible to their original ones.