OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
geometry_port.hpp
1#pragma once
2#include <ossia/detail/config.hpp>
3
4#include <ossia/detail/small_vector.hpp>
5#include <ossia/detail/variant.hpp>
6
7#include <memory>
8#include <string>
9
10namespace ossia
11{
12struct geometry
13{
14 struct cpu_buffer
15 {
16 std::shared_ptr<void> data;
17 int64_t size{};
18 };
19
20 struct gpu_buffer
21 {
22 void* handle{}; // Can be casted to e.g. a QRhiBuffer
23 };
24 struct buffer
25 {
26 ossia::variant<cpu_buffer, gpu_buffer> data;
27 bool dirty{};
28 };
29
30 struct binding
31 {
32 uint32_t stride{};
33 enum
34 {
35 per_vertex,
36 per_instance
37 } classification{};
38 int step_rate{};
39 };
40
41 struct attribute
42 {
43 int binding = 0;
44 int location = 0;
45
46 enum
47 {
48 fp4,
49 fp3,
50 fp2,
51 fp1,
52 unsigned4,
53 unsigned2,
54 unsigned1
55 } format
56 = fp4;
57
58 uint32_t offset = 0;
59 };
60
61 struct input
62 {
63 int buffer{};
64 int64_t offset{};
65 };
66
67 ossia::small_vector<buffer, 2> buffers;
68 ossia::small_vector<binding, 2> bindings;
69 ossia::small_vector<attribute, 2> attributes;
70 ossia::small_vector<input, 2> input;
71
72 int vertices{}, indices{};
73 enum
74 {
75 triangles,
76 triangle_strip,
77 triangle_fan,
78 lines,
79 line_strip,
80 points
81 } topology;
82 enum
83 {
84 none,
85 front,
86 back
87 } cull_mode;
88 enum
89 {
90 counter_clockwise,
91 clockwise
92 } front_face;
93
94 struct
95 {
96 int buffer{-1};
97 int64_t offset{};
98 enum
99 {
100 uint16,
101 uint32
102 } format{};
103 } index;
104};
105
106struct mesh_list
107{
108 std::vector<geometry> meshes;
109 int64_t dirty_index{};
110};
111using mesh_list_ptr = std::shared_ptr<mesh_list>;
112struct transform3d
113{
114 float matrix[16]{
115 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1.,
116 };
117};
118
119struct geometry_filter
120{
121 int64_t node_id{}; // which node is responsible for initalizing the UBO
122 int64_t filter_id{}; // unique index for this filter instance
136 std::string shader;
137 int64_t dirty_index{};
138};
139
140struct geometry_filter_list
141{
142 std::vector<geometry_filter> filters;
143 int64_t dirty_index{};
144};
145using geometry_filter_list_ptr = std::shared_ptr<geometry_filter_list>;
146
147struct geometry_spec
148{
149 mesh_list_ptr meshes;
150 geometry_filter_list_ptr filters;
151
152 operator bool() const noexcept { return meshes && filters; }
153 bool operator==(const geometry_spec&) const noexcept = default;
154 bool operator<(const geometry_spec& rhs) const noexcept
155 {
156 return (meshes < rhs.meshes) || (meshes == rhs.meshes && filters < rhs.filters);
157 }
158};
159
160struct OSSIA_EXPORT geometry_port
161{
162 static const constexpr int which = 4;
163 enum dirt_flags
164 {
165 dirty_transform = 0x1,
166 dirty_meshes = 0x2
167 };
168
169 void clear();
170
171 geometry_spec geometry;
172 transform3d transform;
173 uint8_t flags{};
174};
175
176struct geometry_delay_line
177{
178 std::vector<geometry_spec> geometries;
179};
180
181}
Definition git_info.h:7