Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
Culler Class Reference

Select and sort objects based on visibility and distance criteria. More...

#include <Culler.hpp>

Classes

struct  DistPair
 

Public Types

using List = std::vector< long >
 Indices of selected objects.
 

Public Member Functions

 Culler (const std::vector< Object > &objects)
 
const Listcull (const glm::mat4 &view, const glm::mat4 &proj)
 
const ListcullAndSort (const glm::mat4 &view, const glm::mat4 &proj, const glm::vec3 &pos)
 
void interface ()
 
Culleroperator= (const Culler &)=delete
 
 Culler (const Culler &)=delete
 
Culleroperator= (Culler &&)=delete
 
 Culler (Culler &&)=delete
 

Private Types

enum class  Ordering { FRONT_TO_BACK , BACK_TO_FRONT }
 Define ordering of sorted objects. More...
 

Private Attributes

const std::vector< Object > & _objects
 Reference to the objects to process.
 
List _order
 Will contain the indices of the objects selected.
 
std::vector< DistPair_distances
 Intermediate storage for sorting.
 
Frustum _frustum
 Current view frustum.
 
unsigned long _maxCount
 Maximum number of objects to select.
 
bool _freezeFrustum = false
 Should the frustum not be updated.
 

Detailed Description

Select and sort objects based on visibility and distance criteria.

This can be used to limit the number of objects drawn based on if they fall inside a camera frustum. Their ordering can also be optimized, for instance to maximize depth rejection or ensure transparent objects are rendered back to front.

Member Enumeration Documentation

◆ Ordering

enum class Culler::Ordering
strongprivate

Define ordering of sorted objects.

Enumerator
FRONT_TO_BACK 

Closest first.

BACK_TO_FRONT 

Furthest first.

Constructor & Destructor Documentation

◆ Culler() [1/3]

Culler::Culler ( const std::vector< Object > &  objects)

Constructor

Parameters
objectsthe list of objects to process

◆ Culler() [2/3]

Culler::Culler ( const Culler )
delete

Copy constructor (disabled).

◆ Culler() [3/3]

Culler::Culler ( Culler &&  )
delete

Move constructor (disabled).

Member Function Documentation

◆ cull()

const Culler::List & Culler::cull ( const glm::mat4 &  view,
const glm::mat4 &  proj 
)

Detect objects that are inside the view frustum. This returns the indices of the objects that are visible in a list padded to the objects count with -1s.

Parameters
viewthe view matrix
projthe projection matrix
Returns
indices of the objects to be rendered
Note
As soon as a -1 is encountered in the list, all further indices will also be -1.

◆ cullAndSort()

const Culler::List & Culler::cullAndSort ( const glm::mat4 &  view,
const glm::mat4 &  proj,
const glm::vec3 &  pos 
)

Detect objects that are inside the view frustum and sort them based on their type. This returns the object indices in a list padded to the objects count with -1s.

Parameters
viewthe view matrix
projthe projection matrix
posthe camera position in world space
Returns
indices of the objects to be rendered
Note
As soon as a -1 is encountered in the list, all further indices will also be -1.

◆ interface()

void Culler::interface ( )

Display culling options GUI.

◆ operator=() [1/2]

Culler & Culler::operator= ( const Culler )
delete

Copy assignment operator (disabled).

Returns
a reference to the object assigned to

◆ operator=() [2/2]

Culler & Culler::operator= ( Culler &&  )
delete

Move assignment operator (disabled).

Returns
a reference to the object assigned to

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