Notifications
Clear all

[Closed] Overlapping

I have fractured hollow object and i need to create simple collision boxes for each fracture piece and those collision boxes can’t overlap each other. I created boxes based on each pieces bounding box and then used intersects() to check if collision objects overlap. Then i scaled overlapping boxes while they don’t collide anymore. Well scaling obviously doesn’t work because it scales both sides of box. So I think i need to move collision box vertices which are overlapping another collision box. But how do i know which vertices are overlapping? Damn building UI’s doing simple tasks is somewhat easy, but this is totally new stuff for me and it’s giving me a headache.

9 Replies
1 Reply
(@denist)
Joined: 2 years ago

Posts: 0

if two bboxs are intersected that means at least one corner of a bbox is inside another bbox…
check all 8 corners of both bboxs to find corners which are inside another bbox:


fn containsPoint bmin bmax p = 
(
  (p.x >= bmin.x and p.x <= bmax.x) and (p.y >= bmin.y and p.y <= bmax.y) and (p.z >= bmin.z and p.z <= bmax.z) 
) 

If I have situation like in the image above, vertices in the red box are not inside green box but they still intersect.
Basically what I need to get is both top triangles and rightside triangles from the green box and bottom triangles and leftside triangles from the red box. When i get all those triangles, I know what faces I need to move to get objects separate. And I think I can get the direction to move from inverting triangle normals, right?
I just can’t figure out how to get those damn triangles, it can’t be that hard I’ve tried few different approaches like rays and looping thru all faces and comparing center distances etc but nothing worked. Well of course they might have worked if I would use them in the right way…

you have to check corner positions for both bboxs

do you have exactly boxes or any geometry?

I create boxes (converted to editable mesh) based on bounding boxes from different kind of objects. But yes they will be shaped liked boxes

do you want to modify only one box (some particular or any) or both boxes?

Both boxes. I’m gonna have lots of boxes and I’m gonna loop thru all of them, and if intersection happens between two objects, both need to be resized so they wont intersect anymore. I’ve done it now using scale, and it’s working mostly okay, but it’s not good enough. Would be much better if I could figure out where intersection happens so i wouldn’t have to scale whole objects but just move those intersecting faces away from each other.

if you would move boxes it might cause another intersection with other boxes…

I just want to move those faces (top and rightside from green, bottom and leftside from red in the image), thus making both boxes smaller. I dont want to move whole boxes