1rtcSetGeometryPointQueryFuEnmcbtrieoen(R3a)y TracingrKtecrSneetlGseo3metryPointQueryFunction(3)
2
3
4
5   NAME
6              rtcSetGeometryPointQueryFunction - sets the point query callback function
7                for a geometry
8
9   SYNOPSIS
10              #include <embree3/rtcore.h>
11
12              struct RTCPointQueryFunctionArguments
13              {
14                // the (world space) query object that was passed as an argument of rtcPointQuery.
15                struct RTCPointQuery* query;
16
17                // used for user input/output data. Will not be read or modified internally.
18                void* userPtr;
19
20                // primitive and geometry ID of primitive
21                unsigned int  primID;
22                unsigned int  geomID;
23
24                // the instance stack with instance IDs and transformation information
25                struct RTCPointQueryInstanceStack* instStack;
26
27                // scaling factor indicating whether the current instance transformation
28                // is a similarity transformation.
29                float similarityScale;
30              };
31
32              typedef bool (*RTCPointQueryFunction)(
33                struct RTCPointQueryFunctionArguments* args
34              );
35
36              void rtcSetGeometryPointQueryFunction(
37                RTCGeometry geometry,
38                RTCPointQueryFunction queryFunc
39              );
40
41   DESCRIPTION
42       The  rtcSetGeometryPointQueryFunction  function registers a point query
43       callback function  (queryFunc  argument)  for  the  specified  geometry
44       (geometry argument).
45
46       Only a single callback function can be registered per geometry and fur‐
47       ther invocations overwrite the previously set callback function.  Pass‐
48       ing NULL as function pointer disables the registered callback function.
49
50       The  registered  callback  function  is  invoked by [rtcPointQuery] for
51       every primitive of the geometry that intersects the corresponding point
52       query domain.  The callback function of type RTCPointQueryFunction gets
53       passed a number of arguments through the RTCPointQueryFunctionArguments
54       structure.   The query object is the original point query object passed
55       into [rtcPointQuery], usrPtr is an arbitrary pointer to pass input into
56       and  store  results  of  the callback function.  The primID, geomID and
57       instStack (see [rtcInitPointQueryInstanceStack]  for  details)  can  be
58       used to identify the geometry data of the primitive.
59
60       A  RTCPointQueryFunction  can also be passed directly as an argument to
61       [rtcPointQuery].  In this case the callback is invoked for  all  primi‐
62       tives  in  the  scene  that  intersect the query domain.  If a callback
63       function is passed as an argument to [rtcPointQuery] and (a potentially
64       different)  callback  function is set for a geometry with [rtcSetGeome‐
65       tryPointQueryFunction] both callback functions are invoked.
66
67       If instancing is used, the parameter simliarityScale indicates  whether
68       the current instance transform (top element of instStack) is a similar‐
69       ity transformation or not.  Similarity transformations are composed  of
70       translation,  rotation  and uniform scaling and if a matrix M defines a
71       similarity transformation, there is a scaling factor D  such  that  for
72       all  x,y:  dist(Mx,  My)  = D * dist(x, y).  In this case the parameter
73       scalingFactor is this scaling factor D and otherwise it is 0.  A  valid
74       similarity  scale  (similarityScale  >  0)  allows  to compute distance
75       information in instance space and scale the distances accordingly  into
76       world  space  (for example, to update the query radius, see below).  If
77       the current instance transform is not a similarity transform (similari‐
78       tyScale  is  0),  the distance computation has to be performed in world
79       space to ensure correctness.  In this case the instance to world trans‐
80       formations  given  with  the  instStack should be used to transform the
81       primitive data into world space.  Otherwise, the query location can  be
82       transformed  into instance space which can be more efficient.  If there
83       is no instance transform, the similarity scale is 1.
84
85       The callback function will potentially be called for primitives outside
86       the query domain for two resons: First, the callback is invoked for all
87       primitives inside a BVH leaf node since no geometry data of  primitives
88       is  determined  internally  and therefore individual primitives are not
89       culled (only their (aggregated) bounding boxes).  Second, in  case  non
90       similarity  transformations  are  used, the resulting ellipsoidal query
91       domain (in instance space) is approximated by its axis aligned bounding
92       box  internally  and  therefore  inner  nodes that do not intersect the
93       original domain might intersect the approximative  bounding  box  which
94       results in unneccessary callbacks.  In any case, the callbacks are con‐
95       servative, i.e.  if a primitive is inside the query domain  a  callback
96       will be invoked but the reverse is not neccessarily true.
97
98       For  efficiency,  the  radius  of the query object can be decreased (in
99       world space) inside the callback function to improve culling of  geome‐
100       try  during  BVH traversal.  If the query radius was updated, the call‐
101       back function should return true to issue an update of internal traver‐
102       sal  information.  Increasing the radius or modifying the time or posi‐
103       tion of the query results in undefined behaviour.
104
105       Within the callback function, it is safe to call [rtcPointQuery] again,
106       for  example  when  implementing instancing manually.  In this case the
107       instance transformation should be pushed onto  the  instStack.   Embree
108       will  internally  compute the point query information in instance space
109       using the top element of instStack when [rtcPointQuery] is called.
110
111       For a reference implementation of a closest point traversal of triangle
112       meshes  using  instancing  and user defined instancing see the tutorial
113       [ClosestPoint].
114
115   SEE ALSO
116       [rtcPointQuery], [rtcInitPointQueryInstanceStack]
117
118
119
120                                           rtcSetGeometryPointQueryFunction(3)
Impressum