101 const int *idx = dl->
index;
103 const int i_end = dl->
parts;
104 for (
int i = 0; i < i_end; i++, idx += 3) {
105 set_tri_indices(thunk, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs);
110 for (
int i = 0; i < i_end; i++, idx += 4) {
111 set_quad_tri_indices(thunk, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs);
112 set_quad_tri_indices(thunk, idx[2] + ofs, idx[0] + ofs, idx[3] + ofs);
117 const int i_end = dl->
parts;
118 for (
int i = 0; i < i_end; i++, idx += 4) {
119 if (idx[2] != idx[3]) {
120 set_quad_tri_indices(thunk, idx[2] + ofs, idx[0] + ofs, idx[1] + ofs);
121 set_quad_tri_indices(thunk, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs);
124 set_tri_indices(thunk, idx[2] + ofs, idx[0] + ofs, idx[1] + ofs);
141 for (
int i = 0; i < dl->
parts; i++) {
142 set_tri_indices(thunk, v_idx + 0, v_idx + 1, v_idx + 2);
147 for (
int a = 0;
a < dl->
parts;
a++) {
152 for (; b < dl->
nr; b++) {
153 set_quad_tri_indices(thunk, v_idx + 0, v_idx + 1, v_idx + 2);
154 set_quad_tri_indices(thunk, v_idx + 3, v_idx + 4, v_idx + 5);
161 const int *idx = dl->
index;
162 for (
int i = 0; i < dl->
parts; i++, idx += 4) {
163 if (idx[2] != idx[3]) {
164 set_quad_tri_indices(thunk, v_idx + 0, v_idx + 1, v_idx + 2);
165 set_quad_tri_indices(thunk, v_idx + 3, v_idx + 4, v_idx + 5);
169 set_tri_indices(thunk, v_idx + 0, v_idx + 1, v_idx + 2);
189 if (
format.attr_len == 0) {
208 int vbo_len_used = 0;
210 const bool ndata_is_single = dl->type ==
DL_INDEX3;
212 const float *fp_co = dl->verts;
213 const float *fp_no = dl->nors;
214 const int vbo_end = vbo_len_used +
dl_vert_len(dl);
215 while (vbo_len_used < vbo_end) {
221 if (ndata_is_single ==
false) {
238 if (
format.attr_len == 0) {
259 for (
int i = 0; i < vert_len; i++) {
301 for (
int i = 0; i < mat_len; i++) {
316 for (
int i = 0; i < mat_len; i++) {
356 int orco_sizeu = dl->
nr - 1;
357 int orco_sizev = dl->
parts - 1;
367 for (
int i = 0; i < 4; i++) {
371 r_uv[i][0] = (
quad[i] / dl->
nr) / (
float)orco_sizev;
372 r_uv[i][1] = (
quad[i] % dl->
nr) / (
float)orco_sizeu;
375 if ((i == 1 || i == 2) && r_uv[i][0] == 0.0f) {
378 if ((i == 0 || i == 1) && r_uv[i][1] == 0.0f) {
388 const bool do_hq_normals)
418 const bool do_hq_normals)
420 if (pos_step->
size != 0) {
426 if (uv_step->
size != 0) {
431 if (tan_step->
size != 0) {
436 #define SURFACE_QUAD_ITER_BEGIN(dl) \
439 int quad_index = 0; \
440 int max_v = (dl->flag & DL_CYCL_V) ? dl->parts : (dl->parts - 1); \
441 int max_u = (dl->flag & DL_CYCL_U) ? dl->nr : (dl->nr - 1); \
442 for (int v = 0; v < max_v; v++) { \
443 quad[3] = dl->nr * v; \
444 quad[0] = quad[3] + 1; \
445 quad[2] = quad[3] + dl->nr; \
446 quad[1] = quad[0] + dl->nr; \
448 if (v == dl->parts - 1) { \
449 quad[1] -= dl->parts * dl->nr; \
450 quad[2] -= dl->parts * dl->nr; \
452 for (int u = 0; u < max_u; u++, quad_index++) { \
454 if (u == dl->nr - 1) { \
459 #define SURFACE_QUAD_ITER_END \
473 float(*nor_flat)[3] =
MEM_mallocN(
sizeof(
float[3]) * u_len * v_len, __func__);
499 uint pos_hq, nor_hq, tan_hq;
537 do_hq_normals ? &format_pos_nor_hq : &format_pos_nor);
559 const float(*nors)[3] = (
float(*)[3])dl->
nors;
560 const int *idx = dl->
index;
577 tangent_packed.
high[0] = 0;
578 tangent_packed.
high[1] = 0;
579 tangent_packed.
high[2] = 0;
586 const float x_max = (
float)(dl->
nr - 1);
587 uv[0][1] = uv[1][1] = uv[2][1] = 0.0f;
588 const int i_end = dl->
parts;
589 for (
int i = 0; i < i_end; i++, idx += 3) {
591 uv[0][0] = idx[0] / x_max;
592 uv[1][0] = idx[1] / x_max;
593 uv[2][0] = idx[2] / x_max;
635 for (
int j = 0; j < 4; j++) {
641 pnors_quad[1] = pnors_quad[2] = pnors_quad[3] = pnors_quad[0];
645 for (
int j = 0; j < 4; j++) {
646 float *
tan = tangents[quad_index * 4 + j];
694 uv[0][0] = uv[0][1] = uv[1][0] = uv[3][1] = 0.0f;
695 uv[1][1] = uv[2][0] = uv[2][1] = uv[3][0] = 1.0f;
697 const int i_end = dl->
parts;
698 for (
int i = 0; i < i_end; i++, idx += 4) {
699 const bool is_tri = idx[2] != idx[3];
704 int idx_len = is_tri ? 3 : 4;
705 for (
int j = 0; j < idx_len; j++) {
718 pnors_idx[1] = pnors_idx[2] = pnors_idx[3] = pnors_idx[0];
763 if (pos_step.
size != 0) {
765 if (vbo_len_used < vbo_len_capacity) {
769 if (uv_step.
size != 0) {
771 if (vbo_len_used < vbo_len_capacity) {
778 #define NO_EDGE INT_MAX
782 bool inv_indices = (
v2 > v3);
786 if (!value_is_init || v_data ==
NO_EDGE) {
789 int value = (int)
v1 + 1;
795 bool inv_opposite = (v_data < 0);
798 if (inv_opposite == inv_indices) {
802 *r_is_manifold =
false;
812 void **packed = (
void **)thunk;
815 bool *r_is_manifold = (
bool *)packed[2];
829 *r_is_manifold =
true;
838 void *thunk[3] = {&elb, eh, r_is_manifold};
864 *r_is_manifold =
false;
typedef float(TangentPoint)[2]
display list (or rather multi purpose list) stuff.
void BKE_displist_normals_add(struct ListBase *lb)
void BKE_displist_tangent_calc(const DispList *dl, float(*fnormals)[3], float(**r_tangent)[4])
#define BLI_array_alloca(arr, realsize)
void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP free_value)
BLI_INLINE void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, unsigned int *r_v0, unsigned int *r_v1)
BLI_INLINE bool BLI_edgehashIterator_isDone(EdgeHashIterator *ehi)
EdgeHash * BLI_edgehash_new_ex(const char *info, const unsigned int nentries_reserve)
EdgeHashIterator * BLI_edgehashIterator_new(EdgeHash *eh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool BLI_edgehash_ensure_p(EdgeHash *eh, unsigned int v0, unsigned int v1, void ***r_val) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void BLI_edgehashIterator_step(EdgeHashIterator *ehi)
void BLI_edgehashIterator_free(EdgeHashIterator *ehi)
BLI_INLINE void * BLI_edgehashIterator_getValue(EdgeHashIterator *ehi)
#define LISTBASE_FOREACH(type, var, list)
float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
MINLINE void normal_float_to_short_v3(short r[3], const float n[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_v3_short(short r[3], const short a[3])
MINLINE void normal_float_to_short_v2(short r[2], const float n[2])
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
bool GPU_use_hq_normals_workaround(void)
bool GPU_crappy_amd_driver(void)
struct GPUIndexBuf GPUIndexBuf
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder *, uint v1, uint v2)
void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3, uint v4)
void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *, GPUIndexBuf *)
void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3)
_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 stride
_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 v1
const GPUVertFormat * GPU_vertbuf_get_format(const GPUVertBuf *verts)
struct GPUVertBuf GPUVertBuf
GPU_INLINE uint GPU_vertbuf_raw_used(GPUVertBufRaw *a)
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len)
#define GPU_vertbuf_init_with_format(verts, format)
void * GPU_vertbuf_get_data(const GPUVertBuf *verts)
GPU_INLINE void * GPU_vertbuf_raw_step(GPUVertBufRaw *a)
void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *, uint a_idx, GPUVertBufRaw *access)
void GPU_vertbuf_attr_set(GPUVertBuf *, uint a_idx, uint v_idx, const void *data)
void GPU_vertbuf_data_resize(GPUVertBuf *, uint v_len)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
void DRW_displist_indexbuf_create_edges_adjacency_lines(struct ListBase *lb, struct GPUIndexBuf *ibo, bool *r_is_manifold)
static int displist_indexbufbuilder_tess_set(SetTriIndicesFn *set_tri_indices, SetTriIndicesFn *set_quad_tri_indices, void *thunk, const DispList *dl, const int ofs)
void() SetTriIndicesFn(void *thunk, uint v1, uint v2, uint v3)
static int curve_render_surface_vert_len_get(const ListBase *lb)
static void set_edges_adjacency_lines_indices(void *thunk, uint v1, uint v2, uint v3)
static void displist_indexbufbuilder_set(SetTriIndicesFn *set_tri_indices, SetTriIndicesFn *set_quad_tri_indices, void *thunk, const DispList *dl, const int ofs)
static void displist_vertbuf_attr_set_nor(GPUVertBufRaw *step, const GPUNormal *n1, const GPUNormal *n2, const GPUNormal *n3, const bool do_hq_normals)
void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv_and_tan(ListBase *lb, GPUVertBuf *vbo_pos_nor, GPUVertBuf *vbo_uv, GPUVertBuf *vbo_tan, const Scene *scene)
void DRW_displist_vertbuf_create_wiredata(ListBase *lb, GPUVertBuf *vbo)
void DRW_displist_vertbuf_create_pos_and_nor(ListBase *lb, GPUVertBuf *vbo, const Scene *scene)
static int dl_vert_len(const DispList *dl)
void DRW_displist_indexbuf_create_triangles_loop_split_by_material(ListBase *lb, GPUIndexBuf **ibo_mats, uint mat_len)
static void set_overlay_wires_tri_indices(void *thunk, uint v1, uint v2, uint v3)
#define SURFACE_QUAD_ITER_BEGIN(dl)
static int curve_render_surface_tri_len_get(const ListBase *lb)
void DRW_displist_indexbuf_create_triangles_in_order(ListBase *lb, GPUIndexBuf *ibo)
static void displist_surf_fnors_ensure(const DispList *dl, float(**fnors)[3])
void DRW_vertbuf_create_wiredata(GPUVertBuf *vbo, const int vert_len)
static void displist_vertbuf_attr_set_tri_pos_nor_uv(GPUVertBufRaw *pos_step, GPUVertBufRaw *nor_step, GPUVertBufRaw *uv_step, GPUVertBufRaw *tan_step, const float v1[3], const float v2[3], const float v3[3], const GPUNormal *n1, const GPUNormal *n2, const GPUNormal *n3, const GPUNormal *t1, const GPUNormal *t2, const GPUNormal *t3, const float uv1[2], const float uv2[2], const float uv3[2], const bool do_hq_normals)
static void set_overlay_wires_quad_tri_indices(void *thunk, uint v1, uint v2, uint v3)
static void surf_uv_quad(const DispList *dl, const uint quad[4], float r_uv[4][2])
void DRW_displist_indexbuf_create_lines_in_order(ListBase *lb, GPUIndexBuf *ibo)
#define SURFACE_QUAD_ITER_END
static int dl_tri_len(const DispList *dl)
static void set_edge_adjacency_lines_indices(EdgeHash *eh, GPUIndexBufBuilder *elb, bool *r_is_manifold, uint v1, uint v2, uint v3)
#define DRW_TEST_ASSIGN_VBO(v)
struct @612::@615 attr_id
void *(* MEM_mallocN)(size_t len, const char *str)
INLINE Rall1d< T, V, S > tan(const Rall1d< T, V, S > &arg)
__forceinline const avxi abs(const avxi &a)