Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
PBasicSphere.h
Go to the documentation of this file.
1#pragma once
2
4#include "Math/TVector3.h"
5
6#include <Common/primitive_type.h>
7
8#include <utility>
9
10namespace ph
11{
12
13class PBasicSphere : public Primitive
14{
15public:
16 explicit PBasicSphere(real radius);
17
19 const Ray& ray,
20 HitProbe& probe,
21 HitDetail* out_detail) const override = 0;
22
23 bool isIntersecting(const Ray& ray, HitProbe& probe) const override;
24
25 bool reintersect(
26 const Ray& ray,
27 HitProbe& probe,
28 const Ray& srcRay,
29 HitProbe& srcProbe) const override;
30
31 bool mayOverlapVolume(const math::AABB3D& volume) const override;
32 math::AABB3D calcAABB() const override;
33 real calcExtendedArea() const override;
34
35 real getRadius() const;
36 real getRcpRadius() const;
37
38protected:
45 auto getRefinedSurfaceAndNormal(const math::Vector3R& srcSurface) const
46 -> std::pair<math::Vector3R, math::Vector3R>;
47
48private:
49 real m_radius;
50 real m_rcpRadius;
51};
52
53// In-header Implementations:
54
55inline real PBasicSphere::getRadius() const
56{
57 return m_radius;
58}
59
60inline real PBasicSphere::getRcpRadius() const
61{
62 return m_rcpRadius;
63}
64
65inline auto PBasicSphere::getRefinedSurfaceAndNormal(const math::Vector3R& srcSurface) const
66-> std::pair<math::Vector3R, math::Vector3R>
67{
68 const auto refinedNormal = srcSurface.safeNormalize({0, 1, 0});
69 const auto refinedSurface = refinedNormal * getRadius();
70 return {refinedSurface, refinedNormal};
71}
72
73}// end namespace ph
Detailed information regarding a ray-primitive intersection.
Definition HitDetail.h:26
Lightweight ray intersection testing and reporting object. If an intersection is found,...
Definition HitProbe.h:27
Definition PBasicSphere.h:14
void calcHitDetail(const Ray &ray, HitProbe &probe, HitDetail *out_detail) const override=0
Calculates properties of a hit, such as coordinates and normal.
math::AABB3D calcAABB() const override
Calculates Axis-Aligned Bounding Box (AABB) of itself.
Definition PBasicSphere.cpp:47
bool reintersect(const Ray &ray, HitProbe &probe, const Ray &srcRay, HitProbe &srcProbe) const override
Intersect the intersected object again with a different ray.
Definition PBasicSphere.cpp:31
auto getRefinedSurfaceAndNormal(const math::Vector3R &srcSurface) const -> std::pair< math::Vector3R, math::Vector3R >
Definition PBasicSphere.h:65
real getRcpRadius() const
Definition PBasicSphere.h:60
real calcExtendedArea() const override
Calculates the area extended by this primitive. The term "extended" implies single-sided,...
Definition PBasicSphere.cpp:52
PBasicSphere(real radius)
Definition PBasicSphere.cpp:11
bool mayOverlapVolume(const math::AABB3D &volume) const override
Conservatively checks whether this object overlaps a volume.
Definition PBasicSphere.cpp:42
bool isIntersecting(const Ray &ray, HitProbe &probe) const override
Determine whether a given ray hits the object.
Definition PBasicSphere.cpp:19
real getRadius() const
Definition PBasicSphere.h:55
A physical shape in the scene.
Definition Primitive.h:23
Represents a ray in space.
Definition Ray.h:21
The root for all renderer implementations.
Definition EEngineProject.h:6