Cogs.Core
LoftedCrossSectionsSystem.h
1#pragma once
2
3#include "Systems/ComponentSystem.h"
4
5#include "LoftedCrossSectionsComponent.h"
6
7#include "Foundation/Logging/Logger.h"
8
9#include <vector>
10
11namespace Cogs
12{
13 namespace Core
14 {
15 class Context;
16
17 struct Mesh;
18
20 {
21 std::vector<uint8_t> inside;
22 std::vector<uint8_t> classification;
23 glm::vec3 viewpoint;
24 bool visibilityProcessed = false;
25 };
26
28 : public ComponentSystemWithDataPool<LoftedCrossSectionsComponent, LoftedCrossSectionsData>
29 {
30 public:
31 LoftedCrossSectionsSystem(Memory::Allocator * allocator, SizeType capacity) : ComponentSystemWithDataPool(allocator, capacity) {}
32
33 void initialize(Context * context) override;
34
35 void update(Context* context) override;
36
37 private:
39 {
40 uint8_t newVertices;
41 uint8_t outIndices;
42 uint8_t cutIndices;
43 uint8_t padding;
44 };
45
46 std::vector<CellClassCounts> shellCellClassCounts;
47 std::vector<CellClassCounts> hollowCellClassCounts;
48 std::vector<CellClassCounts> solidCellClassCounts;
49
50 void solidInitialize();
51
52 void shellInitialize();
53
54 void hollowInitialize();
55
56
57 static void solidOpenAlignedClassifySamples(std::vector<uint8_t>& inside,
58 const float* pos, const size_t pos_stride,
59 const std::vector<glm::vec3>& spine,
60 const glm::vec3& viewer,
61 const int slices,
62 const int samples);
63
64 static void shellOpenAlignedClassifySamples(std::vector<uint8_t>& inside,
65 const float* pos, const size_t pos_stride,
66 const std::vector<glm::vec3>& spine,
67 const glm::vec3& viewer,
68 const int slices, const int samples);
69
70 static void hollowOpenAlignedClassifySamples(std::vector<uint8_t>& inside,
71 const float* pos, const size_t pos_stride,
72 const std::vector<glm::vec3>& spine,
73 const glm::vec3& viewer,
74 const int slices, const int samples);
75
76
77 void solidOpenAlignedCountCellResources(size_t& newVertices, size_t& outIndices, size_t& cutIndices,
78 std::vector<uint8_t>& classification,
79 const std::vector<glm::vec3>& spine,
80 const std::vector<uint8_t>& inside,
81 const glm::vec3& viewer,
82 const int slices, const int samples, const bool doubleSeam);
83
84 void shellOpenAlignedCountCellResources(size_t& newVertices, size_t& outIndices,
85 std::vector<uint8_t>& classification,
86 const std::vector<glm::vec3>& spine,
87 const std::vector<uint8_t>& inside,
88 const glm::vec3& viewer,
89 const int slices, const int samples, const bool doubleSeam);
90
91 void hollowOpenAlignedCountCellResources(size_t& newVertices,
92 size_t& outIndices,
93 size_t& cutIndices,
94 std::vector<uint8_t>& classification,
95 const std::vector<glm::vec3>& spine,
96 const std::vector<uint8_t>& inside,
97 const glm::vec3& viewer,
98 const int slices, const int samples, const bool doubleSeam);
99
100
101 static void solidOpenAlignedSkin(std::vector<unsigned int>& outSurface,
102 std::vector<unsigned int>& cutSurface,
103 float* pos, const size_t pos_stride,
104 float* tex, const size_t tex_stride,
105 float* nrm, const size_t nrm_stride,
106 const std::vector<uint8_t>& classification,
107 const std::vector<glm::vec3>& spine,
108 const glm::vec3& viewer,
109 const int slices, const int samples, const bool doubleSeam);
110
111 static void shellOpenAlignedSkin(std::vector<unsigned int>& outSurface,
112 float* pos, const size_t pos_stride,
113 float* tex, const size_t tex_stride,
114 float* nrm, const size_t nrm_stride,
115 const std::vector<uint8_t>& classification,
116 const std::vector<glm::vec3>& spine,
117 const glm::vec3& viewer,
118 const int slices, const int samples, const bool doubleSeam);
119
120 static void hollowOpenAlignedSkin(std::vector<unsigned int>& outSurface,
121 std::vector<unsigned int>& cutSurface,
122 float* pos, const size_t pos_stride,
123 float* tex, const size_t tex_stride,
124 float* nrm, const size_t nrm_stride,
125 const std::vector<uint8_t>& classification,
126 const std::vector<glm::vec3>& spine,
127 const glm::vec3& viewer,
128 const int slices, const int samples, const bool doubleSeam);
129
130 // ---
131
132 static void solidOpenCountCellResources(size_t& newVertices, size_t& outIndices, size_t& cutIndices,
133 const int slices, const int samples, const bool doubleSeam);
134
135 static void shellOpenCountCellResources(size_t& outIndices,
136 const int slices, const int samples, const bool doubleSeam);
137
138 static void hollowOpenCountCellResources(size_t& newVertices, size_t& outIndices, size_t& cutIndices,
139 const int slices, const int samples, const bool doubleSeam);
140
141 // ---
142
143 static void solidOpenSkin(std::vector<unsigned int>& outSurface,
144 std::vector<unsigned int>& cutSurface,
145 float* pos, const size_t pos_stride,
146 float* tex, const size_t tex_stride,
147 float* nrm, const size_t nrm_stride,
148 const std::vector<glm::vec3>& spine,
149 const int slices, const int samples, const bool doubleSeam);
150
151 static void shellOpenSkin(std::vector<unsigned int>& outSurface,
152 const int slices, const int samples, const bool doubleSeam);
153
154 // ---
155
156
157 static void hollowOpenSkin(std::vector<unsigned int>& outSurface,
158 std::vector<unsigned int>& cutSurface,
159 float* pos, const size_t pos_stride,
160 float* tex, const size_t tex_stride,
161 float* nrm, const size_t nrm_stride,
162 const int slices, const int samples, const bool doubleSeam);
163
164 // ---
165
166 static void solidClosedCountCellResources(size_t& newVertices, size_t& outIndices, const int slices, const int samples, const bool doubleSeam);
167
168 static void shellClosedCountCellResources(size_t& outIndices, const int slices, const int samples, const bool doubleSeam);
169
170 static void hollowClosedCountCellResources(size_t& newVertices, size_t& outIndices, size_t& cutIndices,
171 const int slices, const int samples, const bool doubleSeam);
172
173 // ---
174
175 void solidClosedSkin(std::vector<unsigned int>& outSurface,
176 float* pos, const size_t pos_stride,
177 float* tex, const size_t tex_stride,
178 float* nrm, const size_t nrm_stride,
179 const std::vector<glm::vec3>& spine,
180 const int slices, const int samples, const bool doubleSeam);
181
182 void shellClosedSkin(std::vector<unsigned int>& outSurface,
183 const int slices, const int samples, const bool doubleSeam);
184
185
186 void hollowClosedSkin(std::vector<unsigned int>& outSurface,
187 const int slices, const int samples, const bool doubleSeam);
188
189 // ---
190
191 bool process(Context* context,
192 glm::vec4 viewer_world,
195 Mesh* mesh);
196
197 };
198
199
200 } // namespace Core
201} // namespace Cogs
Context * context
Pointer to the Context instance the system lives in.
void update()
Updates the system state to that of the current frame.
Component system with parallel data per component stored in a pool similar to how the components them...
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
void initialize(Context *context) override
Initialize the system.
Base allocator implementation.
Definition: Allocator.h:30
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
ComponentIndex SizeType
Type used to track the size of pools.
Definition: Component.h:19
bool visibilityProcessed
Visibility flag when update was invoked last time.
Meshes contain streams of vertex data in addition to index data and options defining geometry used fo...
Definition: Mesh.h:265