DHART
Loading...
Searching...
No Matches
HF::RayTracer::RayRequest Struct Reference

#include <RayRequest.h>

+ Collaboration diagram for HF::RayTracer::RayRequest:

Public Member Functions

 RayRequest (float x, float y, float z, float dx, float dy, float dz, float Distance=-1)
 Constructs a RayRequest from origin points (x, y, z) and destination points (dx, dy, dz), as well as a starting distance for the ray. More...
 
bool didHit ()
 Default constructor, empty code block. More...
 

Public Attributes

float x
 
float y
 
float z
 X, Y, and Z origin points. More...
 
float dx
 
float dy
 
float dz
 X, Y and Z direction to cast the ray in. More...
 
bool was_cast = false
 Whether this ray was cast or not. More...
 
float distance = -1
 Before casting: the maximum distance of the ray. After casting: distance to the hitpoint or -9999 on miss. More...
 
int mesh_id = -1
 The ID of the hit mesh. More...
 

Detailed Description

Definition at line 13 of file RayRequest.h.

Constructor & Destructor Documentation

◆ RayRequest()

HF::RayTracer::RayRequest::RayRequest ( float  x,
float  y,
float  z,
float  dx,
float  dy,
float  dz,
float  Distance = -1 
)

Constructs a RayRequest from origin points (x, y, z) and destination points (dx, dy, dz), as well as a starting distance for the ray.

Parameters
xThe x origin coordinate
yThe y origin coordinate
zThe z origin coordinate
dxThe x destination coordinate
dyThe y destination coordinate
dzThe z destination coordinate
DistanceThe maximum distance of the ray (upon construction)
// Requires #include "RayRequest.h"
// For brevity
// Prepare RayRequest's parameters
const float x_in = 0.0;
const float y_in = 0.0;
const float z_in = 0.0;
const float dx_in = 1.0;
const float dy_in = 1.0;
const float dz_in = 2.0;
const float distance_in = 10.0;
// Create the RayRequest
RayRequest request(x_in, y_in, z_in, dx_in, dy_in, dz_in, distance_in);

Definition at line 10 of file RayRequest.cpp.

Member Function Documentation

◆ didHit()

bool HF::RayTracer::RayRequest::didHit ( )

Default constructor, empty code block.

// Requires #include "RayRequest.h"
// For brevity
// Create the RayRequest (no arguments)
RayRequest request;

Tells if the rayrequest it or not. If true, the hit was successful, false otherwise. Rays that weren't cast yet are considered as not hitting.

// Requires #include "RayRequest.h"
// For brevity
// Prepare RayRequest's parameters
const float x_in = 0.0;
const float y_in = 0.0;
const float z_in = 0.0;
const float dx_in = 1.0;
const float dy_in = 1.0;
const float dz_in = 2.0;
const float distance_in = 10.0;
// Create the RayRequest
RayRequest request(x_in, y_in, z_in, dx_in, dy_in, dz_in, distance_in);
// Use didHit
if (request.didHit()) {
std::cout << "Hit" << std::endl;
}
else {
std::cout << "Miss" << std::endl;
}
bool didHit()
Default constructor, empty code block.
Definition: RayRequest.cpp:13

>>>Miss

Definition at line 13 of file RayRequest.cpp.

Member Data Documentation

◆ distance

float HF::RayTracer::RayRequest::distance = -1

Before casting: the maximum distance of the ray. After casting: distance to the hitpoint or -9999 on miss.

Definition at line 17 of file RayRequest.h.

◆ dx

float HF::RayTracer::RayRequest::dx

Definition at line 15 of file RayRequest.h.

◆ dy

float HF::RayTracer::RayRequest::dy

Definition at line 15 of file RayRequest.h.

◆ dz

float HF::RayTracer::RayRequest::dz

X, Y and Z direction to cast the ray in.

Definition at line 15 of file RayRequest.h.

◆ mesh_id

int HF::RayTracer::RayRequest::mesh_id = -1

The ID of the hit mesh.

Definition at line 18 of file RayRequest.h.

◆ was_cast

bool HF::RayTracer::RayRequest::was_cast = false

Whether this ray was cast or not.

Definition at line 16 of file RayRequest.h.

◆ x

float HF::RayTracer::RayRequest::x

Definition at line 14 of file RayRequest.h.

◆ y

float HF::RayTracer::RayRequest::y

Definition at line 14 of file RayRequest.h.

◆ z

float HF::RayTracer::RayRequest::z

X, Y, and Z origin points.

Definition at line 14 of file RayRequest.h.


The documentation for this struct was generated from the following files: