rtcSetGeometryIntersectFunction.3embree3 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. .TH "rtcSetGeometryIntersectFunction" "3" "" "" "Embree Ray Tracing Kernels 3"
  2. .SS NAME
  3. .IP
  4. .nf
  5. \f[C]
  6. rtcSetGeometryIntersectFunction\ \-\ sets\ the\ callback\ function\ to
  7. \ \ intersect\ a\ user\ geometry
  8. \f[]
  9. .fi
  10. .SS SYNOPSIS
  11. .IP
  12. .nf
  13. \f[C]
  14. #include\ <embree3/rtcore.h>
  15. struct\ RTCIntersectFunctionNArguments
  16. {
  17. \ \ int*\ valid;
  18. \ \ void*\ geometryUserPtr;
  19. \ \ unsigned\ int\ primID;
  20. \ \ struct\ RTCIntersectContext*\ context;
  21. \ \ struct\ RTCRayHitN*\ rayhit;
  22. \ \ unsigned\ int\ N;
  23. };
  24. typedef\ void\ (*RTCIntersectFunctionN)(
  25. \ \ const\ struct\ RTCIntersectFunctionNArguments*\ args
  26. );
  27. void\ rtcSetGeometryIntersectFunction(
  28. \ \ RTCGeometry\ geometry,
  29. \ \ RTCIntersectFunctionN\ intersect
  30. );
  31. \f[]
  32. .fi
  33. .SS DESCRIPTION
  34. .PP
  35. The \f[C]rtcSetGeometryIntersectFunction\f[] function registers a
  36. ray/primitive intersection callback function (\f[C]intersect\f[]
  37. argument) for the specified user geometry (\f[C]geometry\f[] argument).
  38. .PP
  39. Only a single callback function can be registered per geometry and
  40. further invocations overwrite the previously set callback function.
  41. Passing \f[C]NULL\f[] as function pointer disables the registered
  42. callback function.
  43. .PP
  44. The registered callback function is invoked by
  45. \f[C]rtcIntersect\f[]\-type ray queries to calculate the intersection of
  46. a ray packet of variable size with one user\-defined primitive.
  47. The callback function of type \f[C]RTCIntersectFunctionN\f[] gets passed
  48. a number of arguments through the
  49. \f[C]RTCIntersectFunctionNArguments\f[] structure.
  50. The value \f[C]N\f[] specifies the ray packet size, \f[C]valid\f[]
  51. points to an array of integers that specify whether the corresponding
  52. ray is valid (\-1) or invalid (0), the \f[C]geometryUserPtr\f[] member
  53. points to the geometry user data previously set through
  54. \f[C]rtcSetGeometryUserData\f[], the \f[C]context\f[] member points to
  55. the intersection context passed to the ray query, the \f[C]rayhit\f[]
  56. member points to a ray and hit packet of variable size \f[C]N\f[], and
  57. the \f[C]primID\f[] member identifies the primitive ID of the primitive
  58. to intersect.
  59. .PP
  60. The \f[C]ray\f[] component of the \f[C]rayhit\f[] structure contains
  61. valid data, in particular the \f[C]tfar\f[] value is the current closest
  62. hit distance found.
  63. All data inside the \f[C]hit\f[] component of the \f[C]rayhit\f[]
  64. structure are undefined and should not be read by the function.
  65. .PP
  66. The task of the callback function is to intersect each active ray from
  67. the ray packet with the specified user primitive.
  68. If the user\-defined primitive is missed by a ray of the ray packet, the
  69. function should return without modifying the ray or hit.
  70. If an intersection of the user\-defined primitive with the ray was found
  71. in the valid range (from \f[C]tnear\f[] to \f[C]tfar\f[]), it should
  72. update the hit distance of the ray (\f[C]tfar\f[] member) and the hit
  73. (\f[C]u\f[], \f[C]v\f[], \f[C]Ng\f[], \f[C]instID\f[], \f[C]geomID\f[],
  74. \f[C]primID\f[] members).
  75. In particular, the currently intersected instance is stored in the
  76. \f[C]instID\f[] field of the intersection context, which must be copied
  77. into the \f[C]instID\f[] member of the hit.
  78. .PP
  79. As a primitive might have multiple intersections with a ray, the
  80. intersection filter function needs to be invoked by the user geometry
  81. intersection callback for each encountered intersection, if filtering of
  82. intersections is desired.
  83. This can be achieved through the \f[C]rtcFilterIntersection\f[] call.
  84. .PP
  85. Within the user geometry intersect function, it is safe to trace new
  86. rays and create new scenes and geometries.
  87. .IP
  88. .nf
  89. \f[C]
  90. \f[]
  91. .fi
  92. .SS EXIT STATUS
  93. .PP
  94. On failure an error code is set that can be queried using
  95. \f[C]rtcGetDeviceError\f[].
  96. .SS SEE ALSO
  97. .PP
  98. [rtcSetGeometryOccludedFunction], [rtcSetGeometryUserData],
  99. [rtcFilterIntersection]