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