Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Culler.hpp
1#pragma once
2
3#include "Common.hpp"
4#include "scene/Object.hpp"
5
11class Culler {
12
13public:
14
15 using List = std::vector<long>;
16
20 Culler(const std::vector<Object> & objects);
21
28 const List & cull(const glm::mat4 & view, const glm::mat4 & proj);
29
37 const List & cullAndSort(const glm::mat4 & view, const glm::mat4 & proj, const glm::vec3 & pos);
38
40 void interface();
41
45 Culler & operator=(const Culler &) = delete;
46
48 Culler(const Culler &) = delete;
49
53 Culler & operator=(Culler &&) = delete;
54
56 Culler(Culler &&) = delete;
57
58private:
59
61 enum class Ordering {
64 };
65
66 const std::vector<Object> & _objects;
68
70 struct DistPair {
71 long id = -1;
72 double distance = std::numeric_limits<double>::max();
73 long material = -1;
74 };
75 std::vector<DistPair> _distances;
76
78 unsigned long _maxCount;
79 bool _freezeFrustum = false;
80
81};
Select and sort objects based on visibility and distance criteria.
Definition: Culler.hpp:11
std::vector< long > List
Indices of selected objects.
Definition: Culler.hpp:15
unsigned long _maxCount
Maximum number of objects to select.
Definition: Culler.hpp:78
Ordering
Define ordering of sorted objects.
Definition: Culler.hpp:61
@ FRONT_TO_BACK
Closest first.
@ BACK_TO_FRONT
Furthest first.
void interface()
Definition: Culler.cpp:128
Culler & operator=(Culler &&)=delete
Culler & operator=(const Culler &)=delete
Culler(Culler &&)=delete
bool _freezeFrustum
Should the frustum not be updated.
Definition: Culler.hpp:79
const List & cullAndSort(const glm::mat4 &view, const glm::mat4 &proj, const glm::vec3 &pos)
Definition: Culler.cpp:41
const List & cull(const glm::mat4 &view, const glm::mat4 &proj)
Definition: Culler.cpp:11
std::vector< DistPair > _distances
Intermediate storage for sorting.
Definition: Culler.hpp:75
List _order
Will contain the indices of the objects selected.
Definition: Culler.hpp:67
Culler(const Culler &)=delete
const std::vector< Object > & _objects
Reference to the objects to process.
Definition: Culler.hpp:66
Frustum _frustum
Current view frustum.
Definition: Culler.hpp:77
Represent a 3D frustum, volume defined by the intersection of six planes.
Definition: Bounds.hpp:106
Definition: Culler.hpp:70
double distance
Distance.
Definition: Culler.hpp:72
long material
Material set (lower is closer).
Definition: Culler.hpp:73