17#ifndef RESONANCE_AUDIO_GEOMETRICAL_ACOUSTICS_ACOUSTIC_RAY_H_
18#define RESONANCE_AUDIO_GEOMETRICAL_ACOUSTICS_ACOUSTIC_RAY_H_
23#include "embree2/rtcore.h"
24#include "embree2/rtcore_ray.h"
25#include "base/constants_and_types.h"
32class RTCORE_ALIGN(16) AcousticRay :
public RTCRay {
41 static const float kInfinity;
46 static const float kRayEpsilon;
51 : energies_(), type_(RayType::kSpecular), prior_distance_(0.0f) {
63 geomID = RTC_INVALID_GEOMETRY_ID;
80 AcousticRay(
const float origin[3],
const float direction[3],
float t_near,
82 const std::array<float, kNumReverbOctaveBands>& energies,
83 RayType ray_type,
float prior_distance)
84 : energies_(energies), type_(ray_type), prior_distance_(prior_distance) {
88 dir[0] = direction[0];
89 dir[1] = direction[1];
90 dir[2] = direction[2];
96 geomID = RTC_INVALID_GEOMETRY_ID;
104 const float* origin()
const {
return org; }
105 void set_origin(
const float origin[3]) {
112 const float* direction()
const {
return dir; }
113 void set_direction(
const float direction[3]) {
114 dir[0] = direction[0];
115 dir[1] = direction[1];
116 dir[2] = direction[2];
120 const float t_near()
const {
return tnear; }
121 void set_t_near(
float t_near) { tnear = t_near; }
124 const float t_far()
const {
return tfar; }
125 void set_t_far(
float t_far) { tfar = t_far; }
133 const float* intersected_geometry_normal()
const {
return Ng; }
134 void set_intersected_geometry_normal(
135 const float intersected_geometry_normal[3]) {
136 Ng[0] = intersected_geometry_normal[0];
137 Ng[1] = intersected_geometry_normal[1];
138 Ng[2] = intersected_geometry_normal[2];
143 const unsigned int intersected_geometry_id()
const {
return geomID; }
147 const unsigned int intersected_primitive_id()
const {
return primID; }
150 const std::array<float, kNumReverbOctaveBands>& energies()
const {
153 void set_energies(
const std::array<float, kNumReverbOctaveBands>& energies) {
154 energies_ = energies;
158 const RayType type()
const {
return type_; }
159 void set_type(
const RayType type) { type_ = type; }
162 const float prior_distance()
const {
return prior_distance_; }
163 void set_prior_distance(
float prior_distance) {
164 prior_distance_ = prior_distance;
176 bool Intersect(RTCScene scene) {
177 rtcIntersect(scene, *
this);
178 return geomID != RTC_INVALID_GEOMETRY_ID;
184 std::array<float, kNumReverbOctaveBands> energies_;
187 RayType type_ = RayType::kSpecular;
190 float prior_distance_ = 0.0f;