39 this->vertex_count = this->get_vertex_count();
40 this->poly_count = this->get_poly_count();
41 this->loop_count = this->poly_count * 4;
45 int get_vertex_count()
59 const float z_bottom = -config.
size.z / 2.0f;
60 const float z_delta = config.
size.z / config.
edges_z;
62 const float x_left = -config.
size.x / 2.0f;
63 const float x_delta = config.
size.x / config.
edges_x;
65 const float y_front = -config.
size.y / 2.0f;
66 const float y_delta = config.
size.y / config.
edges_y;
73 const float z_pos = z_bottom + z_delta *
z;
75 const float y_pos = y_front + y_delta *
y;
77 const float x_pos = x_left + x_delta *
x;
86 const float y_pos = y_front + y_delta *
y;
87 const float z_pos = z_bottom + z_delta *
z;
89 const float x_pos = x_left + x_delta *
x;
95 const float x_pos = x_left;
96 const float y_pos = y_front + y_delta *
y;
97 const float z_pos = z_bottom + z_delta *
z;
99 const float x_pos2 = x_left + x_delta * config.
edges_x;
113 const int poly_index,
114 const int loop_index,
120 MPoly &poly = polys[poly_index];
124 MLoop &loop_1 = loops[loop_index];
126 MLoop &loop_2 = loops[loop_index + 1];
128 MLoop &loop_3 = loops[loop_index + 2];
130 MLoop &loop_4 = loops[loop_index + 3];
142 const int xy_cross_section_vert_count = config.
verts_x * config.
verts_y -
146 int vert_1_start = 0;
150 const int vert_1 = vert_1_start +
x;
151 const int vert_2 = vert_1_start + config.
verts_x +
x;
152 const int vert_3 = vert_2 + 1;
153 const int vert_4 = vert_1 + 1;
155 define_quad(polys, loops, poly_index, loop_index, vert_1, vert_2, vert_3, vert_4);
159 vert_1_start += config.
verts_x;
173 vert_1_start +
x + 1,
174 vert_2_start +
x + 1,
179 vert_1_start = vert_2_start;
187 vert_2_start = vert_1_start + config.
verts_x;
196 vert_1_start +
x + 1,
197 vert_2_start +
x + 1,
202 vert_2_start += config.
verts_x;
203 vert_1_start += config.
verts_x;
208 vert_2_start = vert_1_start + xy_cross_section_vert_count;
221 vert_2_start +
x + 1,
222 vert_1_start +
x + 1);
226 vert_2_start += xy_cross_section_vert_count;
227 vert_1_start += xy_cross_section_vert_count;
241 if (
z == 0 ||
y == 0) {
242 vert_1 = vert_1_start + config.
verts_x *
y;
243 vert_4 = vert_1 + config.
verts_x;
246 vert_1 = vert_1_start + 2 *
y;
251 if (
y == 0 ||
z == (config.
edges_z - 1)) {
252 vert_2 = vert_2_start + config.
verts_x *
y;
253 vert_3 = vert_2 + config.
verts_x;
256 vert_2 = vert_2_start + 2 *
y;
261 define_quad(polys, loops, poly_index, loop_index, vert_1, vert_2, vert_3, vert_4);
269 vert_1_start += xy_cross_section_vert_count;
271 vert_2_start += xy_cross_section_vert_count;
280 int vert_1 = vert_1_start;
281 int vert_2 = vert_2_start;
282 int vert_3 = vert_2_start + 2;
283 int vert_4 = vert_1 + config.
verts_x;
286 vert_1 = vert_1_start + config.
verts_x *
y;
287 vert_4 = vert_1 + config.
verts_x;
290 vert_1 = vert_1_start + 2 *
y;
295 vert_2 = vert_2_start + config.
verts_x *
y;
296 vert_3 = vert_2 + config.
verts_x;
299 vert_2 = vert_2_start + 2 *
y;
304 vert_3 = vert_2 + config.
verts_x;
305 vert_4 = vert_1 + config.
verts_x;
308 define_quad(polys, loops, poly_index, loop_index, vert_1, vert_4, vert_3, vert_2);
316 vert_1_start += xy_cross_section_vert_count;
318 vert_2_start += xy_cross_section_vert_count;
331 const float x_delta = 0.25f /
static_cast<float>(config.
edges_x);
332 const float y_delta = 0.25f /
static_cast<float>(config.
edges_y);
333 const float z_delta = 0.25f /
static_cast<float>(config.
edges_z);
338 uvs[loop_index++] =
float2(0.25f +
x * x_delta, 0.375f -
y * y_delta);
339 uvs[loop_index++] =
float2(0.25f +
x * x_delta, 0.375f - (
y + 1) * y_delta);
340 uvs[loop_index++] =
float2(0.25f + (
x + 1) * x_delta, 0.375f - (
y + 1) * y_delta);
341 uvs[loop_index++] =
float2(0.25f + (
x + 1) * x_delta, 0.375f -
y * y_delta);
348 uvs[loop_index++] =
float2(0.25f +
x * x_delta, 0.375f +
z * z_delta);
349 uvs[loop_index++] =
float2(0.25f + (
x + 1) * x_delta, 0.375f +
z * z_delta);
350 uvs[loop_index++] =
float2(0.25f + (
x + 1) * x_delta, 0.375f + (
z + 1) * z_delta);
351 uvs[loop_index++] =
float2(0.25f +
x * x_delta, 0.375f + (
z + 1) * z_delta);
358 uvs[loop_index++] =
float2(0.25f +
x * x_delta, 0.625f +
y * y_delta);
359 uvs[loop_index++] =
float2(0.25f + (
x + 1) * x_delta, 0.625f +
y * y_delta);
360 uvs[loop_index++] =
float2(0.25f + (
x + 1) * x_delta, 0.625f + (
y + 1) * y_delta);
361 uvs[loop_index++] =
float2(0.25f +
x * x_delta, 0.625f + (
y + 1) * y_delta);
368 uvs[loop_index++] =
float2(1.0f -
x * x_delta, 0.375f +
z * z_delta);
369 uvs[loop_index++] =
float2(1.0f -
x * x_delta, 0.375f + (
z + 1) * z_delta);
370 uvs[loop_index++] =
float2(1.0f - (
x + 1) * x_delta, 0.375f + (
z + 1) * z_delta);
371 uvs[loop_index++] =
float2(1.0f - (
x + 1) * x_delta, 0.375f +
z * z_delta);
378 uvs[loop_index++] =
float2(0.25f -
y * y_delta, 0.375f +
z * z_delta);
379 uvs[loop_index++] =
float2(0.25f -
y * y_delta, 0.375f + (
z + 1) * z_delta);
380 uvs[loop_index++] =
float2(0.25f - (
y + 1) * y_delta, 0.375f + (
z + 1) * z_delta);
381 uvs[loop_index++] =
float2(0.25f - (
y + 1) * y_delta, 0.375f +
z * z_delta);
388 uvs[loop_index++] =
float2(0.50f +
y * y_delta, 0.375f +
z * z_delta);
389 uvs[loop_index++] =
float2(0.50f + (
y + 1) * y_delta, 0.375f +
z * z_delta);
390 uvs[loop_index++] =
float2(0.50f + (
y + 1) * y_delta, 0.375f + (
z + 1) * z_delta);
391 uvs[loop_index++] =
float2(0.50f +
y * y_delta, 0.375f + (
z + 1) * z_delta);
struct Mesh * BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
void BKE_mesh_calc_edges(struct Mesh *mesh, bool keep_existing_edges, bool select_new_edges)
MINLINE void copy_v3_v3(float r[3], const float a[3])
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
GSpanAttributeWriter lookup_or_add_for_write_only_span(const AttributeIDRef &attribute_id, const eAttrDomain domain, const eCustomDataType data_type)
MutableAttributeAccessor mesh_attributes_for_write(Mesh &mesh)
static void calculate_polys(const CuboidConfig &config, MutableSpan< MPoly > polys, MutableSpan< MLoop > loops)
static void calculate_vertices(const CuboidConfig &config, MutableSpan< MVert > verts)
static void define_quad(MutableSpan< MPoly > polys, MutableSpan< MLoop > loops, const int poly_index, const int loop_index, const int vert_1, const int vert_2, const int vert_3, const int vert_4)
static void calculate_uvs(const CuboidConfig &config, Mesh *mesh, const bke::AttributeIDRef &uv_id)
Mesh * create_cuboid_mesh(const float3 &size, int verts_x, int verts_y, int verts_z, const bke::AttributeIDRef &uv_id)
vec_base< float, 3 > float3
vec_base< float, 2 > float2
MutableVArraySpan< T > span
CuboidConfig(float3 size, int verts_x, int verts_y, int verts_z)