32 const uchar(*polys)[2] =
reinterpret_cast<const uchar(*)[2]
>(polys_flat);
33 const uint polys_len = polys_flat_len / 2;
38 float (*verts_step)[2] = verts;
40 uint(*tris_step)[3] = tris;
42 const float range_uchar[2] = {
43 (rect ? (rect->
xmax - rect->
xmin) : 2.0f) / 255.0f,
44 (rect ? (rect->
ymax - rect->
ymin) : 2.0f) / 255.0f,
46 const float min_uchar[2] = {
47 (rect ? rect->
xmin : -1.0f),
48 (rect ? rect->
ymin : -1.0f),
53 while (i_poly != polys_len) {
54 for (
uint j = 0; j < 2; j++) {
55 verts[i_vert][j] = min_uchar[j] + (
float(polys[i_poly][j]) * range_uchar[j]);
59 if (polys[i_poly - 1][0] == polys[i_poly][0] && polys[i_poly - 1][1] == polys[i_poly][1]) {
60 const uint verts_step_len = (&verts[i_vert]) - verts_step;
62 const uint tris_len = (verts_step_len - 2);
65 if (verts_step != verts) {
66 uint *t = tris_step[0];
67 const uint offset = (verts_step - verts);
68 uint tot = tris_len * 3;
75 verts_step += verts_step_len;
76 tris_step += tris_len;
87 if (format.attr_len == 0) {
91 const uint verts_len = (verts_step - verts);
92 const uint tris_len = (tris_step - tris);
93 gpu::VertBuf *vbo = GPU_vertbuf_create_with_format(format);
99 for (
uint i = 0; i < verts_len; i++) {
105 for (
uint i = 0; i < tris_len; i++) {
121 const uchar(*polys)[2] =
reinterpret_cast<const uchar(*)[2]
>(polys_flat);
122 const uint polys_len = polys_flat_len / 2;
130 const float range_uchar[2] = {
131 (rect ? (rect->
xmax - rect->
xmin) : 2.0f) / 255.0f,
132 (rect ? (rect->
ymax - rect->
ymin) : 2.0f) / 255.0f,
134 const float min_uchar[2] = {
135 (rect ? rect->
xmin : -1.0f),
136 (rect ? rect->
ymin : -1.0f),
139 uint i_poly_prev = 0;
141 while (i_poly != polys_len) {
143 if (polys[i_poly - 1][0] == polys[i_poly][0] && polys[i_poly - 1][1] == polys[i_poly][1]) {
144 const uchar(*polys_step)[2] = polys + i_poly_prev;
145 const uint polys_step_len = i_poly - i_poly_prev;
147 for (
uint i_prev = polys_step_len - 1, i = 0; i < polys_step_len; i_prev = i++) {
152 data.as_u16[0] = *(
reinterpret_cast<const uint16_t *
>(polys_step[i_prev]));
153 data.as_u16[1] = *(
reinterpret_cast<const uint16_t *
>(polys_step[i]));
154 if (
data.as_u16[0] >
data.as_u16[1]) {
155 std::swap(
data.as_u16[0],
data.as_u16[1]);
157 *lines_step =
data.as_u32;
161 i_poly_prev = i_poly;
166 uint lines_len = lines_step - lines;
172 for (
uint i_prev = 0, i = 1; i < lines_len; i_prev = i++) {
173 if (lines[i] != lines[i_prev]) {
174 *lines_step++ = lines[i_prev];
180 *lines_step++ = lines[lines_len - 1];
181 lines_len = lines_step - lines;
189 if (format.attr_len == 0) {
193 gpu::VertBuf *vbo = GPU_vertbuf_create_with_format(format);
194 const uint vbo_len_capacity = lines_len * 2;
200 for (
uint i = 0; i < lines_len; i++) {
205 data.as_u32 = lines[i];
206 for (
uint k = 0; k < 2; k++) {
208 for (
uint j = 0; j < 2; j++) {
209 pos_v2[j] = min_uchar[j] + (
float(
data.as_u8_pair[k][j]) * range_uchar[j]);
226 static const std::array<float3, 8> bone_box_verts = {
227 float3{1.0f, -1.0f, 1.0f},
228 float3{1.0f, -1.0f, -1.0f},
229 float3{-1.0f, -1.0f, -1.0f},
230 float3{-1.0f, -1.0f, 1.0f},
232 float3{1.0f, 1.0f, -1.0f},
233 float3{-1.0f, 1.0f, -1.0f},
234 float3{-1.0f, 1.0f, 1.0f},
237 static const std::array<int3, 12> bone_box_solid_tris = {
259 gpu::VertBuf *vbo = GPU_vertbuf_create_with_format(format);
261 const int tri_len = bone_box_solid_tris.size();
262 const int vert_len = bone_box_verts.size();
270 for (
int i = 0; i < vert_len; i++) {
274 for (
int i = 0; i < tri_len; i++) {
275 const int3 tri_indices = bone_box_solid_tris[i];
Read Blender memory allocation and freeing.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
GPU_INLINE uint GPU_vertbuf_raw_used(const GPUVertBufRaw *a)
gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, gpu::VertBuf *vertex_buf, gpu::IndexBuf *index_buf, GPUBatchFlag owns_flag)
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
MINLINE void copy_v2_v2(float r[2], const float a[2])
void BLI_polyfill_calc(const float(*coords)[2], unsigned int coords_num, int coords_sign, unsigned int(*r_tris)[3])
gpu::Batch * GPU_batch_unit_cube() ATTR_WARN_UNUSED_RESULT
ATTR_WARN_UNUSED_RESULT const BMVert * v
GPU_INLINE void * GPU_vertbuf_raw_step(GPUVertBufRaw *a)
gpu::IndexBuf * GPU_indexbuf_build(GPUIndexBufBuilder *)
VecBase< int32_t, 3 > int3
BMesh const char void * data
gpu::Batch * GPU_batch_wire_from_poly_2d_encoded(const uchar *polys_flat, uint polys_flat_len, const rctf *rect) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
gpu::Batch * GPU_batch_tris_from_poly_2d_encoded(const uchar *polys_flat, uint polys_flat_len, const rctf *rect) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3)
void GPU_vertbuf_attr_get_raw_data(gpu::VertBuf *, uint a_idx, GPUVertBufRaw *access)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void GPU_vertbuf_vert_set(gpu::VertBuf *verts, uint v_idx, const void *data)
void GPU_vertbuf_data_alloc(gpu::VertBuf &verts, uint v_len)
int BLI_sortutil_cmp_int(const void *a_, const void *b_)
VecBase< float, 3 > float3
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float