box.rst 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. .. default-domain:: C
  2. axis aligned bounding box (AABB)
  3. ================================================================================
  4. Header: cglm/box.h
  5. Some convenient functions provided for AABB.
  6. **Definition of box:**
  7. cglm defines box as two dimensional array of vec3.
  8. The first element is **min** point and the second one is **max** point.
  9. If you have another type e.g. struct or even another representation then you must
  10. convert it before and after call cglm box function.
  11. Table of contents (click to go):
  12. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. Functions:
  14. 1. :c:func:`glm_aabb_transform`
  15. #. :c:func:`glm_aabb_merge`
  16. #. :c:func:`glm_aabb_crop`
  17. #. :c:func:`glm_aabb_crop_until`
  18. #. :c:func:`glm_aabb_frustum`
  19. Functions documentation
  20. ~~~~~~~~~~~~~~~~~~~~~~~
  21. .. c:function:: void glm_aabb_transform(vec3 box[2], mat4 m, vec3 dest[2])
  22. | apply transform to Axis-Aligned Bounding Box
  23. Parameters:
  24. | *[in]* **box** bounding box
  25. | *[in]* **m** transform matrix
  26. | *[out]* **dest** transformed bounding box
  27. .. c:function:: void glm_aabb_merge(vec3 box1[2], vec3 box2[2], vec3 dest[2])
  28. | merges two AABB bounding box and creates new one
  29. two box must be in same space, if one of box is in different space then
  30. you should consider to convert it's space by glm_box_space
  31. Parameters:
  32. | *[in]* **box1** bounding box 1
  33. | *[in]* **box2** bounding box 2
  34. | *[out]* **dest** merged bounding box
  35. .. c:function:: void glm_aabb_crop(vec3 box[2], vec3 cropBox[2], vec3 dest[2])
  36. | crops a bounding box with another one.
  37. this could be useful for gettng a bbox which fits with view frustum and
  38. object bounding boxes. In this case you crop view frustum box with objects
  39. box
  40. Parameters:
  41. | *[in]* **box** bounding box 1
  42. | *[in]* **cropBox** crop box
  43. | *[out]* **dest** cropped bounding box
  44. .. c:function:: void glm_aabb_crop_until(vec3 box[2], vec3 cropBox[2], vec3 clampBox[2], vec3 dest[2])
  45. | crops a bounding box with another one.
  46. this could be useful for gettng a bbox which fits with view frustum and
  47. object bounding boxes. In this case you crop view frustum box with objects
  48. box
  49. Parameters:
  50. | *[in]* **box** bounding box
  51. | *[in]* **cropBox** crop box
  52. | *[in]* **clampBox** miniumum box
  53. | *[out]* **dest** cropped bounding box
  54. .. c:function:: bool glm_aabb_frustum(vec3 box[2], vec4 planes[6])
  55. | check if AABB intersects with frustum planes
  56. this could be useful for frustum culling using AABB.
  57. OPTIMIZATION HINT:
  58. if planes order is similar to LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
  59. then this method should run even faster because it would only use two
  60. planes if object is not inside the two planes
  61. fortunately cglm extracts planes as this order! just pass what you got!
  62. Parameters:
  63. | *[in]* **box** bounding box
  64. | *[out]* **planes** frustum planes