Leviathan  0.8.0.0
Leviathan game engine
Leviathan::Plane Struct Reference

A plane represented by a normal and a distance. More...

#include <Plane.h>

Public Member Functions

 Plane (const Float3 &normal, float distance)
 
DLLEXPORT std::tuple< bool, float > CalculateIntersection (const Ray &ray) const
 

Public Attributes

Float3 Normal
 
float Distance
 

Detailed Description

A plane represented by a normal and a distance.

Definition at line 12 of file Plane.h.

Constructor & Destructor Documentation

◆ Plane()

Leviathan::Plane::Plane ( const Float3 normal,
float  distance 
)
inline

Definition at line 14 of file Plane.h.

14 : Normal(normal), Distance(distance) {}
std::iterator_traits< octet_iterator >::difference_type distance(octet_iterator first, octet_iterator last)
Definition: checked.h:198
Float3 Normal
Definition: Plane.h:21
float Distance
Definition: Plane.h:22

Member Function Documentation

◆ CalculateIntersection()

DLLEXPORT std::tuple< bool, float > Plane::CalculateIntersection ( const Ray ray) const
Returns
Whether a ray intersects with this as well as the distance to the intersection from the ray origin

Definition at line 8 of file Plane.cpp.

9 {
10  // This code is copied from bs::framework with modifications, see License.txt for details
11  const float denom = Normal.Dot(ray.GetDirection());
12 
13  if(std::abs(denom) < EPSILON) {
14  // Parallel
15  return std::make_tuple(false, 0.0f);
16  } else {
17  const float nom = Normal.Dot(ray.GetOrigin()) - Distance;
18  const float t = -(nom / denom);
19  return std::make_tuple(t >= 0.f, t);
20  }
21 }
const auto GetDirection() const
Definition: Ray.h:37
constexpr float EPSILON
Definition: Define.h:70
const auto GetOrigin() const
Definition: Ray.h:32
DLLEXPORT constexpr float Dot(const Float3 &val) const noexcept
Definition: Types.h:1227
Float3 Normal
Definition: Plane.h:21
float Distance
Definition: Plane.h:22

Member Data Documentation

◆ Distance

float Leviathan::Plane::Distance

Definition at line 22 of file Plane.h.

◆ Normal

Float3 Leviathan::Plane::Normal

Definition at line 21 of file Plane.h.


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