1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "../math/vec.isph"
struct Ray1
{
uniform Vec3f org; //!< Ray origin
uniform float tnear; //!< Start of ray segment
uniform Vec3f dir; //!< Ray direction
uniform float time; //!< Time of this ray for motion blur.
uniform float tfar; //!< End of ray segment
uniform int mask; //!< used to mask out objects during traversal
uniform int id; //!< ray ID
uniform int flags; //!< ray flags
uniform Vec3f Ng; //!< Geometric normal.
uniform float u; //!< Barycentric u coordinate of hit
uniform float v; //!< Barycentric v coordinate of hit
uniform int primID; //!< primitive ID
uniform int geomID; //!< geometry ID
uniform int instID[RTC_MAX_INSTANCE_LEVEL_COUNT]; //!< instance ID
varying int align[0]; //!< aligns ray on stack to at least 16 bytes
};
inline uniform RTCRayHit* uniform RTCRayHit1_(uniform Ray1& ray)
{
uniform RTCRayHit* uniform ray_ptr = (uniform RTCRayHit* uniform)&ray;
return ray_ptr;
}
/*! Ray structure. Contains all information about a ray including
* precomputed reciprocal direction. */
struct Ray
{
Vec3f org; //!< Ray origin
float tnear; //!< Start of ray segment
Vec3f dir; //!< Ray direction
float time; //!< Time of this ray for motion blur.
float tfar; //!< End of ray segment
int mask; //!< used to mask out objects during traversal
int id; //!< ray ID
int flags; //!< ray flags
Vec3f Ng; //!< Geometric normal.
float u; //!< Barycentric u coordinate of hit
float v; //!< Barycentric v coordinate of hit
int primID; //!< primitive ID
int geomID; //!< geometry ID
int instID[RTC_MAX_INSTANCE_LEVEL_COUNT]; //!< instance ID
};
inline varying RTCRayHit* uniform RTCRayHit_(varying Ray& ray)
{
varying RTCRayHit* uniform ray_ptr = (varying RTCRayHit* uniform)&ray;
return ray_ptr;
}
inline varying RTCRay* uniform RTCRay_(varying Ray& ray)
{
varying RTCRay* uniform ray_ptr = (varying RTCRay* uniform)&ray;
return ray_ptr;
}
inline varying RTCHit* uniform RTCHit_(varying Ray& ray)
{
varying RTCHit* uniform hit_ptr = (varying RTCHit* uniform)&(ray.Ng.x);
return hit_ptr;
}
/*! Constructs a ray from origin, direction, and ray segment. Near
* has to be smaller than far. */
inline Ray make_Ray(const Vec3f org,
const Vec3f dir,
const float tnear = 0.0f,
const float tfar = inf,
const float time = 0.0f,
const int mask = -1,
const int geomID = -1,
const int primID = -1)
{
Ray ray;
ray.org = org;
ray.tnear = tnear;
ray.dir = dir;
ray.time = time;
ray.tfar = tfar;
ray.mask = -1;
ray.geomID = geomID;
ray.primID = primID;
ray.instID[0] = RTC_INVALID_GEOMETRY_ID;
return ray;
}
inline void init_Ray(Ray &ray,
const Vec3f org,
const Vec3f dir,
const float tnear = 0.0f,
const float tfar = inf,
const float time = 0.0f,
const int mask = -1,
const int geomID = -1,
const int primID = -1)
{
ray.org = org;
ray.tnear = tnear;
ray.dir = dir;
ray.time = time;
ray.tfar = tfar;
ray.mask = -1;
ray.geomID = geomID;
ray.primID = primID;
ray.instID[0] = RTC_INVALID_GEOMETRY_ID;
}
inline bool noHit(const Ray& r) { return r.geomID < 0; }
inline bool hadHit(const Ray& r) { return r.geomID >= 0; }
/*! intersection context passed to intersect/occluded calls */
struct IntersectContext
{
RTCIntersectContext context;
void* userRayExt; //!< can be used to pass extended ray data to callbacks
};
inline void InitIntersectionContext(uniform IntersectContext* uniform context)
{
rtcInitIntersectContext(&context->context);
context->userRayExt = NULL;
}
|