Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
Olympe::ViewportCulling Class Reference

Static helpers for AABB-based viewport culling. More...

#include <ViewportCulling.h>

Static Public Member Functions

static bool IsNodeVisible (float nodeX, float nodeY, float nodeW, float nodeH, const ViewRect &viewport, float margin=50.0f)
 Tests whether a single node rectangle overlaps the viewport.
 
static std::vector< intFilterVisibleNodes (const std::vector< std::pair< int, ViewRect > > &nodeRects, const ViewRect &viewport, float margin=50.0f)
 Filters a list of (id, rect) pairs and returns only the visible IDs.
 

Detailed Description

Static helpers for AABB-based viewport culling.

Typical usage:

for (int id : visible) RenderNode(id);
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
static std::vector< int > FilterVisibleNodes(const std::vector< std::pair< int, ViewRect > > &nodeRects, const ViewRect &viewport, float margin=50.0f)
Filters a list of (id, rect) pairs and returns only the visible IDs.
An axis-aligned rectangle used to describe the viewport or a node bounds.

Definition at line 54 of file ViewportCulling.h.

Member Function Documentation

◆ FilterVisibleNodes()

std::vector< int > Olympe::ViewportCulling::FilterVisibleNodes ( const std::vector< std::pair< int, ViewRect > > &  nodeRects,
const ViewRect viewport,
float  margin = 50.0f 
)
static

Filters a list of (id, rect) pairs and returns only the visible IDs.

Parameters
nodeRectsList of (nodeId, ViewRect) pairs.
viewportCurrent visible rectangle in graph space.
marginExtra padding applied to the viewport before testing.
Returns
IDs of visible nodes.

Definition at line 48 of file ViewportCulling.cpp.

References GetComponentTypeID_Static(), and IsNodeVisible().

+ Here is the call graph for this function:

◆ IsNodeVisible()

bool Olympe::ViewportCulling::IsNodeVisible ( float  nodeX,
float  nodeY,
float  nodeW,
float  nodeH,
const ViewRect viewport,
float  margin = 50.0f 
)
static

Tests whether a single node rectangle overlaps the viewport.

Parameters
nodeXNode left edge in graph space.
nodeYNode top edge in graph space.
nodeWNode width.
nodeHNode height.
viewportCurrent visible rectangle in graph space.
marginExtra padding applied to the viewport before testing.
Returns
true if the node is at least partially visible.

Definition at line 18 of file ViewportCulling.cpp.

References GetComponentTypeID_Static(), Olympe::ViewRect::h, Olympe::ViewRect::w, Olympe::ViewRect::x, and Olympe::ViewRect::y.

Referenced by FilterVisibleNodes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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