RTCHitN(3)
π RTCHitN π
okay bestie, so this one is RTCHitN from the Embree Ray Tracing Kernels 4 manual, section 3 (the library functions girlies π«Ά). she's a hit packet of runtime size and she is literally the moment. let's get into it β¨
πΈ NAME πΈ
RTCHitN β hit packet of runtime size π
β¨ SYNOPSIS β¨
#include <embree4/rtcore.h>
struct HitN;
float& RTCHitN_Ng_x(RTCHitN* hit, unsigned int N, unsigned int i);
float& RTCHitN_Ng_y(RTCHitN* hit, unsigned int N, unsigned int i);
float& RTCHitN_Ng_z(RTCHitN* hit, unsigned int N, unsigned int i);
float& RTCHitN_u(RTCHitN* hit, unsigned int N, unsigned int i);
float& RTCHitN_v(RTCHitN* hit, unsigned int N, unsigned int i);
unsigned& RTCHitN_primID(RTCHitN* hit, unsigned int N, unsigned int i);
unsigned& RTCHitN_geomID(RTCHitN* hit, unsigned int N, unsigned int i);
unsigned& RTCHitN_instID(RTCHitN* hit, unsigned int N, unsigned int i, unsigned int level);
look at her. she's serving function signatures π every single one returns a reference, not a copy, so you can write right back into the packet. iykyk.
π¦ DESCRIPTION π¦
so here's the tea β sometimes you don't know your hit packet size at compile time. like, at all. the big one: when Embree hands you back a hit packet inside the RTCFilterFuncN callback function β surprise, bestie, runtime vibes only π
that's exactly when Embree pulls out the RTCHitN type for hit packets. that's her whole job. main character energy.
β οΈ okay important: these hit packets can only have sizes of1,4,8, or16. no other packet size will be used. periodt. don't come at her with a3, she will not answer the phone π
now, you've got two whole routes and both are valid, pick your fighter:
- implement different special code paths for each of those possible packet sizes, and cast the hit to the appropriate hit packet type π
- implement one general code path that uses the
RTCHitN_XXXhelper functions to access hit packet components π
and those helper functions? they're so simple it's giving wholesome. each one takes:
- a pointer to the hit packet β that's the hit argument π
- the packet size β that's the N argument πΈ
and it returns a reference to a component (like, say, the x component of Ng β¨) of the i-th hit of the packet β that's the i argument π
so: hit, N, i. pointer, size, index. that's the whole recipe. slay.
π EXIT STATUS π
nothing here bestie π this section is literally empty in the original. she said "no exit status, we return references, we don't do exits." iconic behaviour honestly π
π SEE ALSO π
[RTCRayN]
and that's the page, fr fr π¦ this was section 3 of the Embree Ray Tracing Kernels 4 manual β RTCHitN(3) β so go forth, check your N, and only ever pass 1, 4, 8, or 16 πβ¨π no cap.
π¦ where this page comes from
- ubuntu stonking: libembree-dev 4.4.1+dfsg-2ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms