Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
KdtreeAABB.h
Go to the documentation of this file.
1#pragma once
2
4#include "Core/Ray.h"
6#include "Math/math_fwd.h"
7
8#include <Common/primitive_type.h>
9
10namespace ph
11{
12
13// TODO: replace this with TAABB3D
14class KdtreeAABB final
15{
16public:
17 KdtreeAABB();
18 explicit KdtreeAABB(const math::AABB3D& aabb);
19 KdtreeAABB(const math::Vector3R& minVertex, const math::Vector3R& maxVertex);
20
21 bool isIntersectingVolume(const Ray& ray, real* const out_rayNearHitDist, real* const out_rayFarHitDist) const;
22 bool isIntersectingVolume(const math::AABB3D& aabb) const;
23 bool trySplitAt(const int32 axis, const real splitPos, KdtreeAABB* const out_negativeAABB, KdtreeAABB* const out_positiveAABB) const;
24
25 void getMinVertex(real* const out_vector3f) const;
26 void getMaxVertex(real* const out_vector3f) const;
27 real getMinVertex(const int32 axis) const;
28 real getMaxVertex(const int32 axis) const;
29 void getAABB(math::AABB3D* const out_aabb) const;
30
31 inline real getExtent(const int32 axis) const
32 {
33 real minVertex[KDTREE_NUM_AXES];
34 real maxVertex[KDTREE_NUM_AXES];
35 getMinVertex(minVertex);
36 getMaxVertex(maxVertex);
37 return maxVertex[axis] - minVertex[axis];
38 }
39
40 inline real getSurfaceArea() const
41 {
42 const real xExtent = m_aabb.getMaxVertex().x() - m_aabb.getMinVertex().x();
43 const real yExtent = m_aabb.getMaxVertex().y() - m_aabb.getMinVertex().y();
44 const real zExtent = m_aabb.getMaxVertex().z() - m_aabb.getMinVertex().z();
45 return 2.0_r * (xExtent * yExtent + yExtent * zExtent + zExtent * xExtent);
46 }
47
48private:
49 math::AABB3D m_aabb;
50};
51
52}// end namespace ph
Definition KdtreeAABB.h:15
KdtreeAABB()
Definition KdtreeAABB.cpp:7
real getExtent(const int32 axis) const
Definition KdtreeAABB.h:31
bool trySplitAt(const int32 axis, const real splitPos, KdtreeAABB *const out_negativeAABB, KdtreeAABB *const out_positiveAABB) const
Definition KdtreeAABB.cpp:29
void getAABB(math::AABB3D *const out_aabb) const
Definition KdtreeAABB.cpp:81
real getSurfaceArea() const
Definition KdtreeAABB.h:40
void getMinVertex(real *const out_vector3f) const
Definition KdtreeAABB.cpp:53
bool isIntersectingVolume(const Ray &ray, real *const out_rayNearHitDist, real *const out_rayFarHitDist) const
Definition KdtreeAABB.cpp:19
void getMaxVertex(real *const out_vector3f) const
Definition KdtreeAABB.cpp:60
Represents a ray in space.
Definition Ray.h:21
const TVector3< T > & getMaxVertex() const
Get the corner vertex of the maximum (+++) octant.
Definition TAABB3D.ipp:152
const TVector3< T > & getMinVertex() const
Get the corner vertex of the minimum (—) octant.
Definition TAABB3D.ipp:146
T & y()
Definition TVector3.ipp:189
T & z()
Definition TVector3.ipp:195
T & x()
Definition TVector3.ipp:183
#define KDTREE_NUM_AXES
Definition kdtree_core.h:8
The root for all renderer implementations.
Definition EEngineProject.h:6