rtcore_scene.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // Copyright 2009-2021 Intel Corporation
  2. // SPDX-License-Identifier: Apache-2.0
  3. #pragma once
  4. #include "rtcore_device.h"
  5. RTC_NAMESPACE_BEGIN
  6. /* Forward declarations for ray structures */
  7. struct RTCRayHit;
  8. struct RTCRayHit4;
  9. struct RTCRayHit8;
  10. struct RTCRayHit16;
  11. struct RTCRayHitNp;
  12. /* Scene flags */
  13. enum RTCSceneFlags
  14. {
  15. RTC_SCENE_FLAG_NONE = 0,
  16. RTC_SCENE_FLAG_DYNAMIC = (1 << 0),
  17. RTC_SCENE_FLAG_COMPACT = (1 << 1),
  18. RTC_SCENE_FLAG_ROBUST = (1 << 2),
  19. RTC_SCENE_FLAG_CONTEXT_FILTER_FUNCTION = (1 << 3)
  20. };
  21. /* Creates a new scene. */
  22. RTC_API RTCScene rtcNewScene(RTCDevice device);
  23. /* Returns the device the scene got created in. The reference count of
  24. * the device is incremented by this function. */
  25. RTC_API RTCDevice rtcGetSceneDevice(RTCScene hscene);
  26. /* Retains the scene (increments the reference count). */
  27. RTC_API void rtcRetainScene(RTCScene scene);
  28. /* Releases the scene (decrements the reference count). */
  29. RTC_API void rtcReleaseScene(RTCScene scene);
  30. /* Attaches the geometry to a scene. */
  31. RTC_API unsigned int rtcAttachGeometry(RTCScene scene, RTCGeometry geometry);
  32. /* Attaches the geometry to a scene using the specified geometry ID. */
  33. RTC_API void rtcAttachGeometryByID(RTCScene scene, RTCGeometry geometry, unsigned int geomID);
  34. /* Detaches the geometry from the scene. */
  35. RTC_API void rtcDetachGeometry(RTCScene scene, unsigned int geomID);
  36. /* Gets a geometry handle from the scene. This function is not thread safe and should get used during rendering. */
  37. RTC_API RTCGeometry rtcGetGeometry(RTCScene scene, unsigned int geomID);
  38. /* Gets a geometry handle from the scene. This function is thread safe and should NOT get used during rendering. */
  39. RTC_API RTCGeometry rtcGetGeometryThreadSafe(RTCScene scene, unsigned int geomID);
  40. /* Commits the scene. */
  41. RTC_API void rtcCommitScene(RTCScene scene);
  42. /* Commits the scene from multiple threads. */
  43. RTC_API void rtcJoinCommitScene(RTCScene scene);
  44. /* Progress monitor callback function */
  45. typedef bool (*RTCProgressMonitorFunction)(void* ptr, double n);
  46. /* Sets the progress monitor callback function of the scene. */
  47. RTC_API void rtcSetSceneProgressMonitorFunction(RTCScene scene, RTCProgressMonitorFunction progress, void* ptr);
  48. /* Sets the build quality of the scene. */
  49. RTC_API void rtcSetSceneBuildQuality(RTCScene scene, enum RTCBuildQuality quality);
  50. /* Sets the scene flags. */
  51. RTC_API void rtcSetSceneFlags(RTCScene scene, enum RTCSceneFlags flags);
  52. /* Returns the scene flags. */
  53. RTC_API enum RTCSceneFlags rtcGetSceneFlags(RTCScene scene);
  54. /* Returns the axis-aligned bounds of the scene. */
  55. RTC_API void rtcGetSceneBounds(RTCScene scene, struct RTCBounds* bounds_o);
  56. /* Returns the linear axis-aligned bounds of the scene. */
  57. RTC_API void rtcGetSceneLinearBounds(RTCScene scene, struct RTCLinearBounds* bounds_o);
  58. /* Perform a closest point query of the scene. */
  59. RTC_API bool rtcPointQuery(RTCScene scene, struct RTCPointQuery* query, struct RTCPointQueryContext* context, RTCPointQueryFunction queryFunc, void* userPtr);
  60. /* Perform a closest point query with a packet of 4 points with the scene. */
  61. RTC_API bool rtcPointQuery4(const int* valid, RTCScene scene, struct RTCPointQuery4* query, struct RTCPointQueryContext* context, RTCPointQueryFunction queryFunc, void** userPtr);
  62. /* Perform a closest point query with a packet of 4 points with the scene. */
  63. RTC_API bool rtcPointQuery8(const int* valid, RTCScene scene, struct RTCPointQuery8* query, struct RTCPointQueryContext* context, RTCPointQueryFunction queryFunc, void** userPtr);
  64. /* Perform a closest point query with a packet of 4 points with the scene. */
  65. RTC_API bool rtcPointQuery16(const int* valid, RTCScene scene, struct RTCPointQuery16* query, struct RTCPointQueryContext* context, RTCPointQueryFunction queryFunc, void** userPtr);
  66. /* Intersects a single ray with the scene. */
  67. RTC_API void rtcIntersect1(RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit* rayhit);
  68. /* Intersects a packet of 4 rays with the scene. */
  69. RTC_API void rtcIntersect4(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit4* rayhit);
  70. /* Intersects a packet of 8 rays with the scene. */
  71. RTC_API void rtcIntersect8(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit8* rayhit);
  72. /* Intersects a packet of 16 rays with the scene. */
  73. RTC_API void rtcIntersect16(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit16* rayhit);
  74. /* Intersects a stream of M rays with the scene. */
  75. RTC_API void rtcIntersect1M(RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit* rayhit, unsigned int M, size_t byteStride);
  76. /* Intersects a stream of pointers to M rays with the scene. */
  77. RTC_API void rtcIntersect1Mp(RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit** rayhit, unsigned int M);
  78. /* Intersects a stream of M ray packets of size N in SOA format with the scene. */
  79. RTC_API void rtcIntersectNM(RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHitN* rayhit, unsigned int N, unsigned int M, size_t byteStride);
  80. /* Intersects a stream of M ray packets of size N in SOA format with the scene. */
  81. RTC_API void rtcIntersectNp(RTCScene scene, struct RTCIntersectContext* context, const struct RTCRayHitNp* rayhit, unsigned int N);
  82. /* Tests a single ray for occlusion with the scene. */
  83. RTC_API void rtcOccluded1(RTCScene scene, struct RTCIntersectContext* context, struct RTCRay* ray);
  84. /* Tests a packet of 4 rays for occlusion occluded with the scene. */
  85. RTC_API void rtcOccluded4(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRay4* ray);
  86. /* Tests a packet of 8 rays for occlusion with the scene. */
  87. RTC_API void rtcOccluded8(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRay8* ray);
  88. /* Tests a packet of 16 rays for occlusion with the scene. */
  89. RTC_API void rtcOccluded16(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRay16* ray);
  90. /* Tests a stream of M rays for occlusion with the scene. */
  91. RTC_API void rtcOccluded1M(RTCScene scene, struct RTCIntersectContext* context, struct RTCRay* ray, unsigned int M, size_t byteStride);
  92. /* Tests a stream of pointers to M rays for occlusion with the scene. */
  93. RTC_API void rtcOccluded1Mp(RTCScene scene, struct RTCIntersectContext* context, struct RTCRay** ray, unsigned int M);
  94. /* Tests a stream of M ray packets of size N in SOA format for occlusion with the scene. */
  95. RTC_API void rtcOccludedNM(RTCScene scene, struct RTCIntersectContext* context, struct RTCRayN* ray, unsigned int N, unsigned int M, size_t byteStride);
  96. /* Tests a stream of M ray packets of size N in SOA format for occlusion with the scene. */
  97. RTC_API void rtcOccludedNp(RTCScene scene, struct RTCIntersectContext* context, const struct RTCRayNp* ray, unsigned int N);
  98. /*! collision callback */
  99. struct RTCCollision { unsigned int geomID0; unsigned int primID0; unsigned int geomID1; unsigned int primID1; };
  100. typedef void (*RTCCollideFunc) (void* userPtr, struct RTCCollision* collisions, unsigned int num_collisions);
  101. /*! Performs collision detection of two scenes */
  102. RTC_API void rtcCollide (RTCScene scene0, RTCScene scene1, RTCCollideFunc callback, void* userPtr);
  103. #if defined(__cplusplus)
  104. /* Helper for easily combining scene flags */
  105. inline RTCSceneFlags operator|(RTCSceneFlags a, RTCSceneFlags b) {
  106. return (RTCSceneFlags)((size_t)a | (size_t)b);
  107. }
  108. #endif
  109. RTC_NAMESPACE_END