pub type IntersectContext = RTCIntersectContext;Expand description
Per ray-query intersection context.
This is used to configure intersection flags, specify a filter callback function, and specify the chain of IDs of the current instance, and to attach arbitrary user data to the query (e.g. per ray data).
§Context Filter Callback
A filter function can be specified inside the context. This function is
invoked as a second filter stage after the per-geometry intersect
GeometryBuilder::set_intersect_filter_function or occluded filter
GeometryBuilder::set_occluded_filter_function function is invoked. Only
rays that passed the first filter stage are valid in this second filter
stage. Having such a per ray-query filter function can be useful to
implement modifications of the behavior of the query, such as collecting all
hits or accumulating transparencies.
It is guaranteed that the intersection context passed to a ray query is
directly passed to the registered callback function. This means that it’s
possible to attach arbitrary user data to the context and access it from the
callback (see IntersectContextExt). On the contrary, the ray is not
guaranteed to be passed to the callback functions, thus reading additional
data from the ray passed to the callback is not possible.
§Note
The support for the context filter function must be enabled for a scene by
using the SceneFlags::CONTEXT_FILTER_FUNCTION flag.
In case of instancing this feature has to get enabled also for each instantiated scene.
§Hints
Best primary ray performance can be obtained by using the ray stream API
and setting the intersect context flag to
IntersectContextFlags::COHERENT. For
secondary rays, it is typically better to use the
IntersectContextFlags::INCOHERENT,
unless the rays are known to be coherent(e.g. for primary transparency
rays).
Aliased Type§
#[repr(C)]pub struct IntersectContext {
pub flags: RTCIntersectContextFlags,
pub filter: Option<unsafe extern "C" fn(*const RTCFilterFunctionNArguments)>,
pub instID: [u32; 1],
}Fields§
§flags: RTCIntersectContextFlags§filter: Option<unsafe extern "C" fn(*const RTCFilterFunctionNArguments)>§instID: [u32; 1]Implementations§
Source§impl IntersectContext
impl IntersectContext
Sourcepub fn coherent() -> IntersectContext
pub fn coherent() -> IntersectContext
Shortcut to create a IntersectContext with coherent flag set.
Sourcepub fn incoherent() -> IntersectContext
pub fn incoherent() -> IntersectContext
Shortcut to create a IntersectContext with incoherent flag set.
Sourcepub fn new(flags: RTCIntersectContextFlags) -> IntersectContext
pub fn new(flags: RTCIntersectContextFlags) -> IntersectContext
Create a context with the given traversal flags. For the common cases
use coherent / incoherent.
Sourcepub unsafe fn ext<T>(&self) -> &T
pub unsafe fn ext<T>(&self) -> &T
Recover the per-ray extension T from a context inside a callback.
Callbacks (geometry intersect/occluded/filter functions) receive the
base &IntersectContext that embree carried through unchanged from
the query. If the query passed an IntersectContextExt<T>, its
ext: T sits directly after the base context, and this returns it.
§Safety
The ray query that produced this callback must have used an
IntersectContextExt<T> with the same T. This reinterprets the
bytes following the base context as T; calling it with a different
T, or when the query used a plain IntersectContext, is
undefined behavior. embree gives no way to check this at runtime,
which is why it is unsafe and localized to the exact callback that
needs the extension, rather than baked into the callback’s type.
Trait Implementations§
Source§impl AsIntersectContext for IntersectContext
impl AsIntersectContext for IntersectContext
Source§type Ext = ()
type Ext = ()
()
for a plain IntersectContext, E for an IntersectContextExt<E>.Source§fn as_context(&self) -> &IntersectContext
fn as_context(&self) -> &IntersectContext
IntersectContext embree carries through to callbacks.Source§fn as_mut_context(&mut self) -> &mut IntersectContext
fn as_mut_context(&mut self) -> &mut IntersectContext
as_context.Source§fn as_extended(&self) -> Option<&Self::Ext>
fn as_extended(&self) -> Option<&Self::Ext>
None for a plain context).Source§fn as_mut_extended(&mut self) -> Option<&mut Self::Ext>
fn as_mut_extended(&mut self) -> Option<&mut Self::Ext>
as_extended.Source§fn as_context_ptr(&self) -> *const IntersectContext
fn as_context_ptr(&self) -> *const IntersectContext
*const to the base context, for the FFI query call.Source§fn as_mut_context_ptr(&mut self) -> *mut IntersectContext
fn as_mut_context_ptr(&mut self) -> *mut IntersectContext
*mut to the base context, for the FFI query call.