42 MFace *mf = mface + findex;
44 for (
int i = 0; i < numTex; i++) {
61 for (
int i = 0; i < numCol; i++) {
80 const int max = mf->
v4 ? 4 : 3;
82 for (
int i = 0; i <
max; i++, lnors++, tlnors++) {
91 int tot = mf->
v4 ? 4 : 3;
109 const int side = (int)
sqrtf((
float)(fd->
totdisp / corners));
110 const int side_sq = side * side;
112 for (
int i = 0; i < tot; i++, disps += side_sq, ld++) {
121 (
size_t)side_sq,
sizeof(
float[3]),
"converted loop mdisps");
123 memcpy(ld->
disps, disps, (
size_t)side_sq *
sizeof(
float[3]));
126 memset(ld->
disps, 0, (
size_t)side_sq *
sizeof(
float[3]));
135 for (
int i = 0; i < fdata->
totlayer; i++) {
176 int i, j, totloop, totpoly, *polyindex;
179 #define ME_FGON (1 << 3)
194 for (i = 0; i < totface_i; i++, mf++) {
195 totloop += mf->
v4 ? 4 : 3;
214 for (i = 0; i < totedge_i; i++, me++) {
228 for (i = 0; i < totface_i; i++, mf++, mp++) {
239 ml->e = POINTER_AS_UINT(BLI_edgehash_lookup(eh, mf->v1, mf->v2)); \
270 *r_totpoly = totpoly;
271 *r_totloop = totloop;
379 const int *polyindices,
380 uint (*loopindices)[4],
397 for (i = 0; i < numUV; i++) {
401 for (findex = 0, pidx = polyindices, lidx = loopindices; findex < num_faces;
402 pidx++, lidx++, findex++, texface++) {
403 for (j = (mface ? mface[findex].v4 : (*lidx)[3]) ? 4 : 3; j--;) {
409 for (i = 0; i < numCol; i++) {
414 for (findex = 0, lidx = loopindices; findex < num_faces; lidx++, findex++, mcol++) {
415 for (j = (mface ? mface[findex].v4 : (*lidx)[3]) ? 4 : 3; j--;) {
425 for (findex = 0, lidx = loopindices; findex < num_faces; lidx++, findex++, mcol++) {
426 for (j = (mface ? mface[findex].v4 : (*lidx)[3]) ? 4 : 3; j--;) {
437 for (findex = 0, lidx = loopindices; findex < num_faces; lidx++, findex++, of++) {
438 for (j = (mface ? mface[findex].v4 : (*lidx)[3]) ? 4 : 3; j--;) {
448 for (findex = 0, lidx = loopindices; findex < num_faces; lidx++, findex++, fnors++) {
449 for (j = (mface ? mface[findex].v4 : (*lidx)[3]) ? 4 : 3; j--;) {
455 if (hasLoopTangent) {
460 for (findex = 0, pidx = polyindices, lidx = loopindices; findex < num_faces;
461 pidx++, lidx++, findex++) {
462 int nverts = (mface ? mface[findex].
v4 : (*lidx)[3]) ? 4 : 3;
463 for (j = nverts; j--;) {
464 copy_v4_v4(ftangents[findex * 4 + j], ltangents[(*lidx)[j]]);
473 if ((mface->
v3 || nr == 4) && mface->
v3 == mface->
v4) {
477 if ((mface->
v2 || mface->
v4) && mface->
v2 == mface->
v3) {
478 mface->
v3 = mface->
v4;
482 if (mface->
v1 == mface->
v2) {
483 mface->
v2 = mface->
v3;
484 mface->
v3 = mface->
v4;
494 mface->
v1 == mface->
v2 || mface->
v2 == mface->
v3 || mface->
v3 == mface->
v1) {
501 mface->
v1 == mface->
v2 || mface->
v2 == mface->
v3 || mface->
v3 == mface->
v4 ||
502 mface->
v4 == mface->
v1 ||
504 mface->
v1 == mface->
v3 || mface->
v2 == mface->
v4) {
511 if (mface->
v3 == 0) {
512 static int corner_indices[4] = {1, 2, 0, 3};
523 if (mface->
v3 == 0 || mface->
v4 == 0) {
524 static int corner_indices[4] = {2, 3, 0, 1};
546 #define USE_TESSFACE_SPEEDUP
547 #define USE_TESSFACE_QUADS
550 #define TESSFACE_IS_QUAD 1
554 const MPoly *mp, *mpoly;
555 const MLoop *ml, *mloop;
558 int *mface_to_poly_map;
560 int poly_index, mface_index;
570 (
size_t)looptri_num,
sizeof(*mface_to_poly_map), __func__);
576 for (poly_index = 0; poly_index < totpoly; poly_index++, mp++) {
581 if (mp_totloop < 3) {
585 #ifdef USE_TESSFACE_SPEEDUP
587 # define ML_TO_MF(i1, i2, i3) \
588 mface_to_poly_map[mface_index] = poly_index; \
589 mf = &mface[mface_index]; \
590 lidx = lindices[mface_index]; \
592 l1 = mp_loopstart + i1; \
593 l2 = mp_loopstart + i2; \
594 l3 = mp_loopstart + i3; \
595 mf->v1 = mloop[l1].v; \
596 mf->v2 = mloop[l2].v; \
597 mf->v3 = mloop[l3].v; \
603 mf->mat_nr = mp->mat_nr; \
604 mf->flag = mp->flag; \
609 # define ML_TO_MF_QUAD() \
610 mface_to_poly_map[mface_index] = poly_index; \
611 mf = &mface[mface_index]; \
612 lidx = lindices[mface_index]; \
614 l1 = mp_loopstart + 0; \
615 l2 = mp_loopstart + 1; \
616 l3 = mp_loopstart + 2; \
617 l4 = mp_loopstart + 3; \
618 mf->v1 = mloop[l1].v; \
619 mf->v2 = mloop[l2].v; \
620 mf->v3 = mloop[l3].v; \
621 mf->v4 = mloop[l4].v; \
626 mf->mat_nr = mp->mat_nr; \
627 mf->flag = mp->flag; \
628 mf->edcode = TESSFACE_IS_QUAD; \
631 else if (mp_totloop == 3) {
635 else if (mp_totloop == 4) {
636 # ifdef USE_TESSFACE_QUADS
648 const float *co_curr, *co_prev;
652 float axis_mat[3][3];
653 float(*projverts)[2];
656 const uint totfilltri = mp_totloop - 2;
668 ml = mloop + mp_loopstart;
669 co_prev = mvert[ml[mp_totloop - 1].
v].
co;
670 for (j = 0; j < mp_totloop; j++, ml++) {
671 co_curr = mvert[ml->
v].
co;
682 ml = mloop + mp_loopstart;
683 for (j = 0; j < mp_totloop; j++, ml++) {
690 for (j = 0; j < totfilltri; j++) {
692 lidx = lindices[mface_index];
694 mface_to_poly_map[mface_index] = poly_index;
695 mf = &mface[mface_index];
698 l1 = mp_loopstart + tri[0];
699 l2 = mp_loopstart + tri[1];
700 l3 = mp_loopstart + tri[2];
702 mf->
v1 = mloop[l1].
v;
703 mf->
v2 = mloop[l2].
v;
704 mf->
v3 = mloop[l3].
v;
729 totface = mface_index;
734 if (
LIKELY(looptri_num != totface)) {
736 mface_to_poly_map = (
int *)
MEM_reallocN(mface_to_poly_map,
737 sizeof(*mface_to_poly_map) * (size_t)totface);
760 #ifdef USE_TESSFACE_QUADS
762 for (mface_index = 0; mface_index < totface; mface_index++, mf++) {
774 #undef USE_TESSFACE_SPEEDUP
775 #undef USE_TESSFACE_QUADS
810 int a_num = 0, b_num = 0;
811 # define LAYER_CMP(l_a, t_a, l_b, t_b) \
812 ((a_num += CustomData_number_of_layers(l_a, t_a)) == \
813 (b_num += CustomData_number_of_layers(l_b, t_b)))
838 return a_num ? true : fallback;
847 for (
int i = 0; i < ldata->
totlayer; i++) {
typedef float(TangentPoint)[2]
CustomData interface, see also DNA_customdata_types.h.
void CustomData_free(struct CustomData *data, int totelem)
int CustomData_number_of_layers(const struct CustomData *data, int type)
int CustomData_get_clone_layer(const struct CustomData *data, int type)
void CustomData_set_layer_active(struct CustomData *data, int type, int n)
void CustomData_external_add(struct CustomData *data, struct ID *id, int type, int totelem, const char *filepath)
bool CustomData_has_layer(const struct CustomData *data, int type)
void * CustomData_add_layer_named(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem, const char *name)
void CustomData_set_layer_clone(struct CustomData *data, int type, int n)
int CustomData_get_active_layer(const struct CustomData *data, int type)
void CustomData_bmesh_update_active_layers(struct CustomData *fdata, struct CustomData *ldata)
int CustomData_get_stencil_layer(const struct CustomData *data, int type)
void CustomData_set_layer_render(struct CustomData *data, int type, int n)
void * CustomData_get_n(const struct CustomData *data, int type, int index, int n)
void * CustomData_get_layer_n(const struct CustomData *data, int type, int n)
void * CustomData_get_layer(const struct CustomData *data, int type)
bool CustomData_external_test(struct CustomData *data, int type)
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
void CustomData_external_read(struct CustomData *data, struct ID *id, eCustomDataMask mask, int totelem)
void * CustomData_get(const struct CustomData *data, int index, int type)
void CustomData_swap_corners(struct CustomData *data, int index, const int *corner_indices)
void CustomData_set_layer_stencil(struct CustomData *data, int type, int n)
int CustomData_get_render_layer(const struct CustomData *data, int type)
void BKE_mesh_update_customdata_pointers(struct Mesh *me, bool do_ensure_tess_cd)
int multires_mdisp_corners(const struct MDisps *s)
void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP free_value)
void BLI_edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val)
EdgeHash * BLI_edgehash_new_ex(const char *info, unsigned int nentries_reserve)
void axis_dominant_v3_to_m3_negate(float r_mat[3][3], const float normal[3])
MINLINE int poly_to_tri_count(int poly_count, int corner_count)
void mul_v2_m3v3(float r[2], const float M[3][3], const float a[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void normal_float_to_short_v3(short r[3], const float n[3])
MINLINE float normalize_v3(float r[3])
MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const float v_curr[3])
MINLINE void normal_short_to_float_v3(float r[3], const short n[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void zero_v3(float r[3])
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
struct MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
#define BLI_MEMARENA_STD_BUFSIZE
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1)
void BLI_polyfill_calc_arena(const float(*coords)[2], unsigned int coords_num, int coords_sign, unsigned int(*r_tris)[3], struct MemArena *arena)
#define POINTER_FROM_UINT(i)
#define MESH_MLOOPCOL_FROM_MCOL(_mloopcol, _mcol)
#define MESH_MLOOPCOL_TO_MCOL(_mloopcol, _mcol)
_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
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
IconTextureDrawCall normal
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
static void CustomData_bmesh_do_versions_update_active_layers(CustomData *fdata, CustomData *ldata)
static void bm_corners_to_loops_ex(ID *id, CustomData *fdata, CustomData *ldata, MFace *mface, int totloop, int findex, int loopstart, int numTex, int numCol)
void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
void BKE_mesh_add_mface_layers(CustomData *fdata, CustomData *ldata, int total)
void BKE_mesh_tessface_calc(Mesh *mesh)
void BKE_mesh_tessface_ensure(struct Mesh *mesh)
int BKE_mesh_mface_index_validate(MFace *mface, CustomData *fdata, int mfindex, int nr)
#define LAYER_CMP(l_a, t_a, l_b, t_b)
static void mesh_loops_to_tessdata(CustomData *fdata, CustomData *ldata, MFace *mface, const int *polyindices, uint(*loopindices)[4], const int num_faces)
static int mesh_tessface_calc(CustomData *fdata, CustomData *ldata, CustomData *pdata, MVert *mvert, int totface, int totloop, int totpoly)
static bool check_matching_legacy_layer_counts(CustomData *fdata, CustomData *ldata, bool fallback)
#define ML_TO_MF(i1, i2, i3)
static void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *ldata, int totloop)
static void convert_mfaces_to_mpolys(ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata, int totedge_i, int totface_i, int totloop_i, int totpoly_i, MEdge *medge, MFace *mface, int *r_totloop, int *r_totpoly, MLoop **r_mloop, MPoly **r_mpoly)
void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh)
CustomDataExternal * external