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 of 1, 4, 8, or 16. no other packet size will be used. periodt. don't come at her with a 3, she will not answer the phone πŸ’€

now, you've got two whole routes and both are valid, pick your fighter:

  1. implement different special code paths for each of those possible packet sizes, and cast the hit to the appropriate hit packet type πŸ‘‘
  2. implement one general code path that uses the RTCHitN_XXX helper 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