MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _plot_face

Function _plot_face

core/math/geometry_3d.cpp:229–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227};
228
229static inline void _plot_face(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z, const Vector3 &voxelsize, const Face3 &p_face) {
230 AABB aabb(Vector3(x, y, z), Vector3(len_x, len_y, len_z));
231 aabb.position = aabb.position * voxelsize;
232 aabb.size = aabb.size * voxelsize;
233
234 if (!p_face.intersects_aabb(aabb)) {
235 return;
236 }
237
238 if (len_x == 1 && len_y == 1 && len_z == 1) {
239 p_cell_status[x][y][z] = _CELL_SOLID;
240 return;
241 }
242
243 int div_x = len_x > 1 ? 2 : 1;
244 int div_y = len_y > 1 ? 2 : 1;
245 int div_z = len_z > 1 ? 2 : 1;
246
247#define SPLIT_DIV(m_i, m_div, m_v, m_len_v, m_new_v, m_new_len_v) \
248 if (m_div == 1) { \
249 m_new_v = m_v; \
250 m_new_len_v = 1; \
251 } else if (m_i == 0) { \
252 m_new_v = m_v; \
253 m_new_len_v = m_len_v / 2; \
254 } else { \
255 m_new_v = m_v + m_len_v / 2; \
256 m_new_len_v = m_len_v - m_len_v / 2; \
257 }
258
259 int new_x;
260 int new_len_x;
261 int new_y;
262 int new_len_y;
263 int new_z;
264 int new_len_z;
265
266 for (int i = 0; i < div_x; i++) {
267 SPLIT_DIV(i, div_x, x, len_x, new_x, new_len_x);
268
269 for (int j = 0; j < div_y; j++) {
270 SPLIT_DIV(j, div_y, y, len_y, new_y, new_len_y);
271
272 for (int k = 0; k < div_z; k++) {
273 SPLIT_DIV(k, div_z, z, len_z, new_z, new_len_z);
274
275 _plot_face(p_cell_status, new_x, new_y, new_z, new_len_x, new_len_y, new_len_z, voxelsize, p_face);
276 }
277 }
278 }
279
280#undef SPLIT_DIV
281}
282
283static inline void _mark_outside(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z) {
284 if (p_cell_status[x][y][z] & 3) {

Callers 3

_plot_faceMethod · 0.85
plot_meshMethod · 0.85
wrap_geometryMethod · 0.85

Calls 2

intersects_aabbMethod · 0.80
Vector3Function · 0.70

Tested by

no test coverage detected