30#include "../shapes2D/round_segment_2d.h"
35 m_segment( aSeg2D.m_segment )
69 if( ( tPlane >= aHitInfo.
m_tHit ) || ( tPlane < FLT_EPSILON ) )
79 if( tPlane < aHitInfo.
m_tHit )
98 if( normal_dot_ray < 0.0f )
102 const float t = n_dot_ray_origin / normal_dot_ray;
109 const float len = glm::dot( v, v );
135 if( normal_dot_ray < 0.0f )
139 const float t = n_dot_ray_origin / normal_dot_ray;
146 const float len = glm::dot( v, v );
175 const double p_dot_p_Start = OCx_Start * OCx_Start + OCy_Start * OCy_Start;
177 const double a = (double)aRay.
m_Dir.x * (
double)aRay.
m_Dir.x +
180 const double b_Start = (double)aRay.
m_Dir.x * (
double)OCx_Start +
181 (double)aRay.
m_Dir.y * (
double)OCy_Start;
185 const float delta_Start = (float) ( b_Start * b_Start - a * c_Start );
187 if( delta_Start > FLT_EPSILON )
189 const float sdelta = sqrtf( delta_Start );
190 const float t = ( -b_Start - sdelta ) / a;
220 const double p_dot_p_End = OCx_End * OCx_End + OCy_End * OCy_End;
222 const double b_End = (double)aRay.
m_Dir.x * (
double)OCx_End +
223 (double)aRay.
m_Dir.y * (
double)OCy_End;
227 const float delta_End = (float)(b_End * b_End - a * c_End);
229 if( delta_End > FLT_EPSILON )
231 const float sdelta = sqrtf( delta_End );
232 const float t = ( -b_End - sdelta ) / a;
269 if( ( tPlane >= aMaxDistance) || ( tPlane < FLT_EPSILON ) )
279 if( tPlane < aMaxDistance )
294 if( normal_dot_ray < 0.0f )
297 float t = n_dot_ray_origin / normal_dot_ray;
304 float len = glm::dot( v, v );
309 if( t < aMaxDistance )
320 if( normal_dot_ray < 0.0f )
324 const float t = n_dot_ray_origin / normal_dot_ray;
331 float len = glm::dot( v, v );
336 if( t < aMaxDistance )
351 double p_dot_p_Start = OCx_Start * OCx_Start + OCy_Start * OCy_Start;
353 double a = (double)aRay.
m_Dir.x * (
double)aRay.
m_Dir.x +
356 double b_Start = (double)aRay.
m_Dir.x * (
double)OCx_Start +
357 (double)aRay.
m_Dir.y * (
double)OCy_Start;
361 float delta_Start = (float)(b_Start * b_Start - a * c_Start);
363 if( delta_Start > FLT_EPSILON )
365 float sdelta = sqrtf( delta_Start );
366 float t = (-b_Start - sdelta) / a;
371 if( t < aMaxDistance )
381 double p_dot_p_End = OCx_End * OCx_End + OCy_End * OCy_End;
384 double b_End = (double)aRay.
m_Dir.x * (
double)OCx_End +
385 (double)aRay.
m_Dir.y * (
double)OCy_End;
389 float delta_End = (float)(b_End * b_End - a * c_End);
391 if( delta_End > FLT_EPSILON )
393 float sdelta = sqrtf( delta_End );
394 float t = ( -b_End - sdelta ) / a;
399 if( t < aMaxDistance )
void Generate(SFVEC3F &aNormal, const RAY &aRay, const HITINFO &aHitInfo) const
const MATERIAL * m_material
bool Intersects(const BBOX_3D &aBBox) const override
float m_seglen_over_two_squared
SFVEC3F m_plane_dir_right
SFVEC3F GetDiffuseColor(const HITINFO &aHitInfo) const override
bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const override
bool IntersectP(const RAY &aRay, float aMaxDistance) const override
ROUND_SEGMENT(const ROUND_SEGMENT_2D &aSeg2D, float aZmin, float aZmax)
Manage a bounding box defined by two SFVEC3F min max points.
void ScaleNextUp()
Scale a bounding box to the next float representation making it larger.
SFVEC3F GetCenter() const
Return the center point of the bounding box.
const SFVEC3F & Min() const
Return the minimum vertex pointer.
const SFVEC3F & Max() const
Return the maximum vertex pointer.
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Set bounding box with new parameters.
void Reset()
Reset the bounding box to zero and de-initialize it.
bool Intersects(const BBOX_3D &aBBox) const
Test if a bounding box intersects this box.
Stores the hit information of a ray with a point on the surface of a object.
float m_tHit
( 4) distance
const OBJECT_3D * pHitObject
( 4) Object that was hitted
SFVEC3F m_HitNormal
(12) normal at the hit point
SFVEC3F m_HitPoint
(12) hit position
float DistanceToPointSquared(const SFVEC2F &aPoint) const
unsigned int m_dirIsNeg[3]
SFVEC3F at(float t) const