Unravel Engine C++ Reference
Loading...
Searching...
No Matches
render_proxy.h
Go to the documentation of this file.
1#pragma once
2#include <engine/engine_export.h>
3
4#include <hpp/small_vector.hpp>
5#include <math/math.h>
6
7#include <cstdint>
8#include <vector>
9
10namespace unravel
11{
12
30{
33 hpp::small_vector<hpp::small_vector<math::bbox>> instance_bounds;
34
36 std::vector<math::bbox> skinned_bounds;
37
41
45
47 uint64_t version{0};
48
49 void clear()
50 {
51 instance_bounds.clear();
52 skinned_bounds.clear();
53 animated_bounds = {};
55 }
56
57 void begin_refresh(size_t submesh_count)
58 {
59 instance_bounds.clear();
60 instance_bounds.resize(submesh_count);
61 skinned_bounds.clear();
62 animated_bounds = {};
64 version++;
65 }
66
67 void add_instance_bounds(uint32_t submesh_index, const math::bbox& world_bounds)
68 {
69 if(submesh_index >= instance_bounds.size())
70 {
71 instance_bounds.resize(submesh_index + 1);
72 }
73 instance_bounds[submesh_index].emplace_back(world_bounds);
74 if(world_bounds.is_populated())
75 {
78 }
79 }
80
85 auto get_instance_bounds(uint32_t submesh_index, size_t instance_index) const -> const math::bbox*
86 {
87 if(submesh_index >= instance_bounds.size())
88 {
89 return nullptr;
90 }
91 const auto& bounds_list = instance_bounds[submesh_index];
92 if(instance_index >= bounds_list.size())
93 {
94 return nullptr;
95 }
96 const auto& bounds = bounds_list[instance_index];
97 return bounds.is_populated() ? &bounds : nullptr;
98 }
99
104 auto get_skinned_bounds(uint32_t submesh_index) const -> const math::bbox*
105 {
106 if(submesh_index >= skinned_bounds.size())
107 {
108 return nullptr;
109 }
110 const auto& bounds = skinned_bounds[submesh_index];
111 return bounds.is_populated() ? &bounds : nullptr;
112 }
113
114 auto has_animated_bounds() const -> bool
115 {
117 }
118
119 auto has_instance_bounds() const -> bool
120 {
122 }
123
126 auto has_pose_bounds() const -> bool
127 {
129 }
130};
131
132} // namespace unravel
Storage for box vector values and wraps up common functionality.
Definition bbox.h:21
bbox & add_point(const vec3 &point)
Grows the bounding box based on the point passed.
Definition bbox.cpp:924
vec3 max
The maximum vector value of the bounding box.
Definition bbox.h:311
vec3 min
The minimum vector value of the bounding box.
Definition bbox.h:306
bool is_populated() const
Checks if the bounding box is populated.
Definition bbox.cpp:36
Retained per-model render proxy data used by the culling/LOD code.
auto has_instance_bounds() const -> bool
auto has_pose_bounds() const -> bool
std::vector< math::bbox > skinned_bounds
Cached world-space animated bounds per skinned submesh index.
void begin_refresh(size_t submesh_count)
auto has_animated_bounds() const -> bool
auto get_instance_bounds(uint32_t submesh_index, size_t instance_index) const -> const math::bbox *
Gets the cached world bounds for a (submesh, instance) pair.
void add_instance_bounds(uint32_t submesh_index, const math::bbox &world_bounds)
hpp::small_vector< hpp::small_vector< math::bbox > > instance_bounds
auto get_skinned_bounds(uint32_t submesh_index) const -> const math::bbox *
Gets the cached animated world bounds for a skinned submesh.