r3d_visibility.odin 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* r3d_visibility.odin -- R3D Visibility Module.
  2. *
  3. * Copyright (c) 2025-2026 Le Juez Victor
  4. *
  5. * This software is provided 'as-is', without any express or implied warranty.
  6. * For conditions of distribution and use, see accompanying LICENSE file.
  7. */
  8. package r3d
  9. import rl "vendor:raylib"
  10. when ODIN_OS == .Windows {
  11. foreign import lib {
  12. "windows/libr3d.a",
  13. "system:raylib",
  14. "system:assimp",
  15. }
  16. } else when ODIN_OS == .Linux {
  17. foreign import lib {
  18. "linux/libr3d.a",
  19. "system:raylib",
  20. "system:assimp",
  21. }
  22. } else when ODIN_OS == .Darwin {
  23. foreign import lib {
  24. "darwin/libr3d.a",
  25. "system:raylib",
  26. "system:assimp",
  27. }
  28. }
  29. @(default_calling_convention="c", link_prefix="R3D_")
  30. foreign lib {
  31. /**
  32. * @brief Checks if a point is inside the view frustum.
  33. *
  34. * Tests whether a 3D point lies within the camera's frustum by checking against all six planes.
  35. * You can call this only after `R3D_Begin`, which updates the internal frustum state.
  36. *
  37. * @param position The 3D point to test.
  38. * @return `true` if inside the frustum, `false` otherwise.
  39. */
  40. IsPointVisible :: proc(position: rl.Vector3) -> bool ---
  41. /**
  42. * @brief Checks if a sphere is inside the view frustum.
  43. *
  44. * Tests whether a sphere intersects the camera's frustum using plane-sphere tests.
  45. * You can call this only after `R3D_Begin`, which updates the internal frustum state.
  46. *
  47. * @param position The center of the sphere.
  48. * @param radius The sphere's radius (must be positive).
  49. * @return `true` if at least partially inside the frustum, `false` otherwise.
  50. */
  51. IsSphereVisible :: proc(position: rl.Vector3, radius: f32) -> bool ---
  52. /**
  53. * @brief Checks if an AABB is inside the view frustum.
  54. *
  55. * Determines whether an axis-aligned bounding box intersects the frustum.
  56. * You can call this only after `R3D_Begin`, which updates the internal frustum state.
  57. *
  58. * @param aabb The bounding box to test.
  59. * @return `true` if at least partially inside the frustum, `false` otherwise.
  60. */
  61. IsBoundingBoxVisible :: proc(aabb: rl.BoundingBox) -> bool ---
  62. /**
  63. * @brief Checks if an OBB is inside the view frustum.
  64. *
  65. * Tests an oriented bounding box (transformed AABB) for frustum intersection.
  66. * You can call this only after `R3D_Begin`, which updates the internal frustum state.
  67. *
  68. * @param aabb Local-space bounding box.
  69. * @param transform World-space transform matrix.
  70. * @return `true` if the transformed box intersects the frustum, `false` otherwise.
  71. */
  72. IsOrientedBoxVisible :: proc(aabb: rl.BoundingBox, transform: rl.Matrix) -> bool ---
  73. }