rtcSetGeo...sFunction(3)

πŸ’… rtcSetGeo...sFunction(3) β€” Embree Ray Tracing Kernels 4

okay bestie, gather round, because this one is literally the glow-up your custom geometry has been waiting for ✨ it lives in the Embree Ray Tracing Kernels 4 manual, it's page rtcSetGeo...sFunction(3), and it's all about telling Embree how to hug your weird little user-defined primitives with bounding boxes. no cap.


πŸŽ€ NAME πŸŽ€

rtcSetGeometryBoundsFunction β€” sets a callback so Embree can ask you what the bounding box of your user-defined primitives is πŸ’–


✨ SYNOPSIS ✨

#include <embree4/rtcore.h>

struct RTCBoundsFunctionArguments
{
  void* geometryUserPtr;
  unsigned int primID;
  unsigned int timeStep;
  struct RTCBounds* bounds_o;
};

typedef void (*RTCBoundsFunction)(
  const struct RTCBoundsFunctionArguments* args
);

void rtcSetGeometryBoundsFunction(
  RTCGeometry geometry,
  RTCBoundsFunction bounds,
  void* userPtr
);

πŸ¦‹ DESCRIPTION πŸ¦‹

so rtcSetGeometryBoundsFunction registers a bounding box callback function (that's the bounds argument, bestie) together with a payload (the userPtr argument) onto the user geometry you picked (the geometry argument). it's giving "hey Embree, here's my phone number, text me when you need a bbox" πŸ“±πŸ’–

Only a single callback function can be registered per geometry β€” one (1) β€” and further invocations overwrite the previously set callback function. yes, it's a "new phone who dis" situation, the old one is gone. and if you pass NULL as the function pointer? that disables the registered callback function entirely. bye bye πŸ‘‹

In SYCL mode the BVH construction is done on the host, and the function pointer you pass must be a host-side function pointer. periodt. don't try to be cute with it.

The registered bounding box callback function gets invoked to calculate axis-aligned bounding boxes of the primitives of the user-defined geometry during spatial acceleration structure construction πŸ—οΈβœ¨ The bounding box callback of RTCBoundsFunction type is invoked with a pointer to a structure of type RTCBoundsFunctionArguments which contains various arguments, such as:

  • the user data of the geometry β€” that's the geometryUserPtr member 🫢
  • the ID of the primitive to calculate the bounds for β€” the primID member πŸ”’
  • the time step at which to calculate the bounds β€” the timeStep member ⏱️
  • and a memory location to write the calculated bound to β€” the bounds_o member πŸ“

In a typical usage scenario, one would store a pointer to the internal representation of the user geometry object using rtcSetGeometryUserData. The callback function can then read that pointer from the geometryUserPtr field and calculate the proper bounding box for the requested primitive and time, and store that bounding box to the destination structure (the bounds_o member). it's a whole little loop of trust, iykyk πŸ’ž


πŸ’€ EXIT STATUS πŸ’€

On failure an error code is set that can be queried using rtcGetDeviceError. so if something goes sideways, that's where the receipts live 🧾


πŸ‘‘ SEE ALSO πŸ‘‘

  • [RTC_GEOMETRY_TYPE_USER]

okay that's the whole page, mwah πŸ’‹ it's from the Embree Ray Tracing Kernels 4 manual, and yes the page is still called rtcSetGeo...sFunction(3) β€” truncated name, full drama, we love her for it πŸŽ€βœ¨

πŸ“¦ where this page comes from