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> raw_data;
17 int64_t byte_size{};
18 };
19
20 struct gpu_buffer
21 {
22 void* handle{}; // Can be casted to e.g. a QRhiBuffer
23 int64_t byte_size{};
24 };
25
26 struct buffer
27 {
28 ossia::variant<cpu_buffer, gpu_buffer> data;
29 bool dirty{};
30 };
31
32 struct binding
33 {
34 uint32_t byte_stride{};
35 enum
36 {
37 per_vertex,
38 per_instance
39 } classification{};
40 int step_rate{};
41 };
42
43 struct attribute
44 {
45 int binding = 0;
46 int location = 0;
47
48 enum
49 {
50 float4,
51 float3,
52 float2,
53 float1,
54 unormbyte4,
55 unormbyte2,
56 unormbyte1,
57 uint4,
58 uint3,
59 uint2,
60 uint1,
61 sint4,
62 sint3,
63 sint2,
64 sint1,
65 half4,
66 half3,
67 half2,
68 half1,
69 ushort4,
70 ushort3,
71 ushort2,
72 ushort1,
73 sshort4,
74 sshort3,
75 sshort2,
76 sshort1,
77 } format
78 = float4;
79
80 uint32_t byte_offset = 0;
81 };
82
83 struct input
84 {
85 int buffer{};
86 int64_t byte_offset{};
87 };
88
89 ossia::small_vector<buffer, 2> buffers;
90 ossia::small_vector<binding, 2> bindings;
91 ossia::small_vector<attribute, 2> attributes;
92 ossia::small_vector<input, 2> input;
93
94 int vertices{}, indices{}, instances{1};
95 enum
96 {
97 triangles,
98 triangle_strip,
99 triangle_fan,
100 lines,
101 line_strip,
102 points
103 } topology;
104 enum
105 {
106 none,
107 front,
108 back
109 } cull_mode;
110 enum
111 {
112 counter_clockwise,
113 clockwise
114 } front_face;
115
116 struct
117 {
118 int buffer{-1};
119 int64_t byte_offset{};
120 enum
121 {
122 uint16,
123 uint32
124 } format{};
125 } index;
126};
127
128struct mesh_list
129{
130 std::vector<geometry> meshes;
131 int64_t dirty_index{};
132};
133using mesh_list_ptr = std::shared_ptr<mesh_list>;
134struct transform3d
135{
136 float matrix[16]{
137 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1.,
138 };
139};
140
141struct geometry_filter
142{
143 int64_t node_id{}; // which node is responsible for initalizing the UBO
144 int64_t filter_id{}; // unique index for this filter instance
158 std::string shader;
159 int64_t dirty_index{};
160};
161
162struct geometry_filter_list
163{
164 std::vector<geometry_filter> filters;
165 int64_t dirty_index{};
166};
167using geometry_filter_list_ptr = std::shared_ptr<geometry_filter_list>;
168
169struct geometry_spec
170{
171 mesh_list_ptr meshes;
172 geometry_filter_list_ptr filters;
173
174 operator bool() const noexcept { return meshes && filters; }
175 bool operator==(const geometry_spec&) const noexcept = default;
176 bool operator<(const geometry_spec& rhs) const noexcept
177 {
178 return (meshes < rhs.meshes) || (meshes == rhs.meshes && filters < rhs.filters);
179 }
180};
181
182struct OSSIA_EXPORT geometry_port
183{
184 static const constexpr int which = 4;
185 enum dirt_flags
186 {
187 dirty_transform = 0x1,
188 dirty_meshes = 0x2
189 };
190
191 void clear();
192
193 geometry_spec geometry;
194 transform3d transform;
195 uint8_t flags{};
196};
197
198struct geometry_delay_line
199{
200 std::vector<geometry_spec> geometries;
201};
202
203}
Definition git_info.h:7