# Precise bounding box

**URL:** <https://forum.babylonjs.com/t/precise-bounding-box/12764>\
**Category:** Questions\
**Created:** [July 23, 2020, 12:20pm UTC](https://forum.babylonjs.com/t/precise-bounding-box/12764 "2020-07-23T12:20:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Katherek](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/katherek/32/8934_2.png) [@Katherek](https://forum.babylonjs.com/u/Katherek)\
**Post date:** [July 23, 2020, 12:20pm UTC](https://forum.babylonjs.com/t/precise-bounding-box/12764/1 "2020-07-23T12:20:49Z")

</div>

Hey, can someone explain me what’s the way to create the most accurate bounding box on a complex model (war plane) to have accurate collisions with a physics engine ?

---

<div class="post-metadata">

**Author:** ![Raggar](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raggar/32/20672_2.png) [@Raggar](https://forum.babylonjs.com/u/Raggar)\
**Post date:** [July 23, 2020, 1:38pm UTC](https://forum.babylonjs.com/t/precise-bounding-box/12764/2 "2020-07-23T13:38:02Z")

</div>

BabylonJS already creates a bounding box around your meshes upon creation/import, so I think you might be looking for something else. Do you mean multiple smaller boxes to create a compound physics-body, or are you looking for a way of creating a convex hull?

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [July 23, 2020, 1:38pm UTC](https://forum.babylonjs.com/t/precise-bounding-box/12764/3 "2020-07-23T13:38:43Z")

</div>

Hi @Katherek

By accurate, do you mean the smallest enclosing bounding box?  
If so, you can try to compute a smaller oriented bounding box. Check this blogpost : [minimum OBB | The Infinite Loop](https://geidav.wordpress.com/tag/minimum-obb/)  
And more specifically, the Rotating Calipers.  
The article speaks of 2D coordinates system but it can be applied to 3D.

---

<div class="post-metadata">

**Author:** ![Katherek](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/katherek/32/8934_2.png) [@Katherek](https://forum.babylonjs.com/u/Katherek)\
**Post date:** [July 23, 2020, 2:19pm UTC](https://forum.babylonjs.com/t/precise-bounding-box/12764/5 "2020-07-23T14:19:16Z")

</div>

I think it’s not what I want to do, I want to create a “collisions box” who follows the vertices of the model but I think it’s hard to do so I think I have to create multiple boxes or try to use the rotating calipers.  
How can I use the rotating calipers ?  
Thanks.

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [July 23, 2020, 2:21pm UTC](https://forum.babylonjs.com/t/precise-bounding-box/12764/6 "2020-07-23T14:21:46Z")

</div>

rotating calipers is an algorithm…you’ll have to implement it yourself 🙂

---

<div class="post-metadata">

**Author:** ![Katherek](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/katherek/32/8934_2.png) [@Katherek](https://forum.babylonjs.com/u/Katherek)\
**Post date:** [July 23, 2020, 2:58pm UTC](https://forum.babylonjs.com/t/precise-bounding-box/12764/7 "2020-07-23T14:58:36Z")

</div>

Ah okay thanks ! Also, If I use a physics Impostor with the type ConvexHullImpostor or with the type MeshImpostor it works fine but when there is a collision the performance is so much worse, do you know how to fix it ?

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [July 23, 2020, 3:05pm UTC](https://forum.babylonjs.com/t/precise-bounding-box/12764/8 "2020-07-23T15:05:23Z")

</div>

IIRC, the convex hull composition depends on the number of vertices. The more vertices, the more plans, the more cpu intensive. You can try to build the convex hull is a more simplified mesh input.  
Or you can try compounds of volumes(sphere, box, …) to make an approximation of the mesh.

---

<div class="post-metadata">

**Author:** ![Katherek](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/katherek/32/8934_2.png) [@Katherek](https://forum.babylonjs.com/u/Katherek)\
**Post date:** [July 23, 2020, 3:12pm UTC](https://forum.babylonjs.com/t/precise-bounding-box/12764/9 "2020-07-23T15:12:01Z")

</div>

Thanks so much for helping me ! I’ll try and if I have another problem I will say it here.
