Meshes inside mesh , how to check if mesh can be inside?

Hello,

I hope you’re having a great day!

I’m facing an issue. In short, I need to copy certain shapes, like a carton of milk or a cube of butter, and place them on a shelf, one by one, after a button click. When the row is full, the shapes should start positioning in a new row. They can’t overlap the fridge walls.

Here is my question: How should I approach this problem? I believe I should use the bounding box information of every shape I want to put on the shelf, and perhaps the bounding box information of the shelf itself. But how can I check if a new mesh can fit into the free space or not?

I don’t have a playground set up right now; I’m just looking for some direction. If anyone has any ideas, please share them. :slight_smile:

I hope I’ve written this clearly enough to be understood; if not, I will gladly answer any questions.

I would reduce the problem to 2d and deal with rectangles. Distance between shelves versus object height as a pre check.

Or you could do raycasting to detect free space.

Or change the requirements: rather than button click, let users drag and drop items in and use Havok for collisions.

3 Likes

Thank you for fast reply. I will definitely try your ideas. Drag and drop sounds cool !

Ok, so a quick update: as you suggested, I reduced the problem to 2D and used the x and z dimensions of the shelf and product bounding boxes to calculate the base. Then I check if the product could be placed, and if not, the function place it in a new row, until there is no free space left. It still needs some fine-tuning, but I am really pleased with the outcome. Thank you.

1 Like