67 const float imat[4][4],
93 MVert *mvert = *mvert_pp;
94 MEdge *medge = *medge_pp;
95 MLoop *mloop = *mloop_pp;
96 MPoly *mpoly = *mpoly_pp;
116 int *vgroup_index_map;
117 int vgroup_index_map_len;
119 ob_src, ob_dst, &vgroup_index_map_len);
121 dvert, me->
totvert, vgroup_index_map, vgroup_index_map_len);
122 if (vgroup_index_map !=
nullptr) {
128 if (ob_src != ob_dst) {
156 float(*ocos)[3] =
static_cast<float(*)[3]
>(okb->
data);
164 for (
a = 0, mvert = *mvert_pp;
a < me->
totvert;
a++,
cos++, mvert++) {
185 float(*ocos)[3] =
static_cast<float(*)[3]
>(okb->
data);
192 for (
a = 0, mvert = *mvert_pp;
a < me->
totvert;
a++,
cos++, mvert++) {
206 medge->
v1 += *vertofs;
207 medge->
v2 += *vertofs;
212 if (ob_src != ob_dst) {
227 mloop->
v += *vertofs;
228 mloop->
e += *edgeofs;
238 for (
b = 0;
b < totcol;
b++) {
239 if (ma == matar[
b]) {
263 int fmap_index_map_len;
266 if (fmap_index_map !=
nullptr) {
297 int max_face_set = 0;
301 if (
abs(face_sets[f]) <= *face_set_offset) {
302 if (face_sets[f] > 0) {
303 face_sets[f] += *face_set_offset;
306 face_sets[f] -= *face_set_offset;
309 max_face_set =
max_ii(max_face_set,
abs(face_sets[f]));
311 *face_set_offset = max_face_set;
321 MVert *mvert =
nullptr;
322 MEdge *medge =
nullptr;
323 MPoly *mpoly =
nullptr;
324 MLoop *mloop =
nullptr;
325 Key *key, *nkey =
nullptr;
327 int a,
b, totcol, totmat = 0, totedge = 0, totvert = 0;
328 int totloop = 0, totpoly = 0, vertofs, *matmap =
nullptr;
329 int i, haskey = 0, edgeofs, loopofs, polyofs;
330 bool ok =
false, join_parent =
false;
348 if (ob_iter->type ==
OB_MESH) {
349 me =
static_cast<Mesh *
>(ob_iter->data);
355 totmat += ob_iter->totcol;
361 if ((ob->
parent !=
nullptr) && (ob_iter == ob->
parent)) {
399 "Joining results in %d vertices, limit is %ld",
417 matmap =
static_cast<int *
>(
MEM_callocN(
sizeof(*matmap) * totmat, __func__));
442 kb->data =
MEM_callocN(
sizeof(
float[3]) * totvert,
"join_shapekey");
443 kb->totelem = totvert;
455 int face_set_id_offset = 0;
461 if ((ob != ob_iter) && (ob_iter->type ==
OB_MESH)) {
462 me =
static_cast<Mesh *
>(ob_iter->data);
484 memcpy(fmap_new, fmap,
sizeof(
bFaceMap));
498 for (
a = 1;
a <= ob_iter->totcol;
a++) {
501 for (
b = 0;
b < totcol;
b++) {
502 if (ma == matar[
b]) {
521 if (me->
key && key) {
523 int *index_map =
static_cast<int *
>(
537 index_map[i] = key->
totkey;
544 kbn->
data =
MEM_callocN(
sizeof(
float[3]) * totvert,
"joined_shapekey");
555 kb_map[i]->
relative = index_map[kb->relative];
626 if (ob_iter->type ==
OB_MESH) {
754 Mesh *selme =
nullptr;
755 Mesh *me_deformed =
nullptr;
758 bool ok =
false, nonequal_verts =
false;
761 if (ob_iter == ob_active) {
765 if (ob_iter->type ==
OB_MESH) {
766 selme = (
Mesh *)ob_iter->data;
772 nonequal_verts =
true;
779 if (nonequal_verts) {
785 "No additional selected meshes with equal vertex count to join");
790 if (key ==
nullptr) {
801 if (ob_iter == ob_active) {
805 if (ob_iter->type ==
OB_MESH) {
806 selme = (
Mesh *)ob_iter->data;
845 Mesh *me_mirror =
nullptr;
849 if (me_eval !=
nullptr) {
859 *r_me_mirror = me_mirror;
860 *r_em_mirror = em_mirror;
899 mvert = &mvert[index];
900 vec[0] = -mvert->
co[0];
901 vec[1] = mvert->
co[1];
902 vec[2] = mvert->
co[2];
972 return (
BMVert *)(poinval);
1008 static float *editmesh_get_mirror_uv(
1009 BMEditMesh *em,
int axis,
float *uv,
float *mirrCent,
float *face_cent)
1022 vec[1] = -((uv[1]) - mirrCent[1]) + mirrCent[1];
1024 cent_vec[0] = face_cent[0];
1025 cent_vec[1] = -((face_cent[1]) - mirrCent[1]) + mirrCent[1];
1028 vec[0] = -((uv[0]) - mirrCent[0]) + mirrCent[0];
1031 cent_vec[0] = -((face_cent[0]) - mirrCent[0]) + mirrCent[0];
1032 cent_vec[1] = face_cent[1];
1043 if ((
fabsf(cent[0] - cent_vec[0]) < 0.001f) && (
fabsf(cent[1] - cent_vec[1]) < 0.001f)) {
1049 if ((
fabsf(luv->
uv[0] - vec[0]) < 0.001f) && (
fabsf(luv->
uv[1] - vec[1]) < 0.001f)) {
1076 return ((v0 * 39) ^ (
v1 * 31));
1082 if (
a->v1 ==
b->v1 &&
a->v2 ==
b->v2 &&
a->v3 ==
b->v3 &&
a->v4 ==
b->v4) {
1085 if (
a->v4 ==
b->v1 &&
a->v1 ==
b->v2 &&
a->v2 ==
b->v3 &&
a->v3 ==
b->v4) {
1088 if (
a->v3 ==
b->v1 &&
a->v4 ==
b->v2 &&
a->v1 ==
b->v3 &&
a->v2 ==
b->v4) {
1091 if (
a->v2 ==
b->v1 &&
a->v3 ==
b->v2 &&
a->v4 ==
b->v3 &&
a->v1 ==
b->v4) {
1096 if (
a->v1 ==
b->v1 &&
a->v2 ==
b->v2 &&
a->v3 ==
b->v3) {
1099 if (
a->v3 ==
b->v1 &&
a->v1 ==
b->v2 &&
a->v2 ==
b->v3) {
1102 if (
a->v2 ==
b->v1 &&
a->v3 ==
b->v2 &&
a->v1 ==
b->v3) {
1119 MFace mirrormf, *mf, *hashmf, *mface;
1121 int *mirrorverts, *mirrorfaces;
1130 mirrorverts =
static_cast<int *
>(
MEM_callocN(
sizeof(
int) * totvert,
"MirrorVerts"));
1131 mirrorfaces =
static_cast<int *
>(
MEM_callocN(
sizeof(
int[2]) * totface,
"MirrorFaces"));
1133 mvert = me_eval ? me_eval->
mvert : me->
mvert;
1134 mface = me_eval ? me_eval->
mface : me->
mface;
1138 for (
a = 0,
mv = mvert;
a < totvert;
a++,
mv++) {
1145 for (
a = 0, mf = mface;
a < totface;
a++, mf++) {
1149 for (
a = 0, mf = mface;
a < totface;
a++, mf++) {
1150 mirrormf.
v1 = mirrorverts[mf->
v3];
1151 mirrormf.
v2 = mirrorverts[mf->
v2];
1152 mirrormf.
v3 = mirrorverts[mf->
v1];
1153 mirrormf.
v4 = (mf->
v4) ? mirrorverts[mf->
v4] : 0;
1156 if (mf->
v4 && mirrormf.
v4 == 0) {
1163 mirrorfaces[
a * 2] = hashmf - mface;
1167 mirrorfaces[
a * 2] = -1;
1186 if (!me || me->
totpoly == 0) {
1205 if ((*r_index) == 0 || (*r_index) > (
uint)me->
totpoly) {
1217 const float mval[2],
1228 for (ml = &mloop[mp->
loopstart]; j--; ml++) {
1230 const int v_idx = ml->
v;
1231 const float *co = mvert[v_idx].
co;
1234 if (len_test < *r_len_best) {
1235 *r_len_best = len_test;
1236 *r_v_idx_best = v_idx;
1262 const float mval_f[2] = {(
float)mval[0], (
float)mval[1]};
1263 float len_best = FLT_MAX;
1265 MPoly *me_eval_mpoly;
1266 MLoop *me_eval_mloop;
1267 MVert *me_eval_mvert;
1268 uint me_eval_mpoly_len;
1270 me_eval_mpoly = me_eval->
mpoly;
1271 me_eval_mloop = me_eval->
mloop;
1272 me_eval_mvert = me_eval->
mvert;
1274 me_eval_mpoly_len = me_eval->
totpoly;
1279 if (index_mp_to_orig) {
1282 for (i = 0; i < me_eval_mpoly_len; i++) {
1283 if (index_mp_to_orig[i] == poly_index) {
1295 if (poly_index < me_eval_mpoly_len) {
1298 &me_eval_mpoly[poly_index],
1310 if (index_mv_to_orig) {
1311 v_idx_best = index_mv_to_orig[v_idx_best];
1316 *r_index = v_idx_best;
1343 const float UNUSED(no[3]))
1352 if (len < data->len_best) {
1354 data->v_idx_best = index;
1367 if (!me || me->
totvert == 0) {
1387 if ((*r_index) == 0 || (*r_index) > (
uint)me->
totvert) {
1403 const float mval_f[2] = {(
float)mval[0], (
float)mval[1]};
1409 if (me_eval ==
nullptr) {
1415 data.region = region;
1416 data.mval_f = mval_f;
1417 data.len_best = FLT_MAX;
1418 data.v_idx_best = -1;
1422 if (
data.v_idx_best == -1) {
1426 *r_index =
data.v_idx_best;
1440 if (cd_dvert_offset != -1) {
1466 if (index == -1 || me->
dvert ==
nullptr) {
1469 return me->
dvert + index;
1484 const uint objects_len,
1499 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
1500 Object *obedit = objects[ob_index];
1519 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
1520 Object *obedit = objects[ob_index];
typedef float(TangentPoint)[2]
struct Scene * CTX_data_scene(const bContext *C)
#define CTX_DATA_BEGIN(C, Type, instance, member)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
CustomData interface, see also DNA_customdata_types.h.
bool CustomData_merge(const struct CustomData *source, struct CustomData *dest, eCustomDataMask mask, eCDAllocType alloctype, int totelem)
void CustomData_copy_data_named(const struct CustomData *source, struct CustomData *dest, int source_index, int dest_index, int count)
void CustomData_free(struct CustomData *data, int totelem)
const CustomData_MeshMasks CD_MASK_BAREMESH_ORIGINDEX
const CustomData_MeshMasks CD_MASK_BAREMESH
void * CustomData_get_layer(const struct CustomData *data, int type)
void * CustomData_bmesh_get(const struct CustomData *data, void *block, int type)
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
void * CustomData_get(const struct CustomData *data, int index, int type)
int CustomData_get_offset(const struct CustomData *data, int type)
const CustomData_MeshMasks CD_MASK_MESH
void CustomData_reset(struct CustomData *data)
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
struct KeyBlock * BKE_keyblock_find_name(struct Key *key, const char name[])
void BKE_keyblock_copy_settings(struct KeyBlock *kb_dst, const struct KeyBlock *kb_src)
copy shape-key attributes, but not key data or name/UID.
void BKE_keyblock_convert_from_mesh(const struct Mesh *me, const struct Key *key, struct KeyBlock *kb)
void BKE_key_sort(struct Key *key)
struct KeyBlock * BKE_keyblock_add(struct Key *key, const char *name)
struct Key * BKE_key_add(struct Main *bmain, struct ID *id)
struct ID * BKE_id_copy(struct Main *bmain, const struct ID *id)
void id_us_min(struct ID *id)
void id_us_plus(struct ID *id)
void BKE_id_free_ex(struct Main *bmain, void *idv, int flag, bool use_flag_from_idtag)
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
void BKE_objects_materials_test_all(struct Main *bmain, struct ID *id)
void BKE_mesh_tessface_clear(struct Mesh *mesh)
struct Mesh * BKE_mesh_from_object(struct Object *ob)
int BKE_mesh_mselect_active_get(struct Mesh *me, int type)
void BKE_mesh_update_customdata_pointers(struct Mesh *me, bool do_ensure_tess_cd)
void BKE_mesh_clear_derived_normals(struct Mesh *mesh)
void BKE_mesh_normals_tag_dirty(struct Mesh *mesh)
void BKE_mesh_foreach_mapped_vert(struct Mesh *mesh, void(*func)(void *userData, int index, const float co[3], const float no[3]), void *userData, MeshForeachFlag flag)
void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb)
struct Mesh * mesh_get_eval_deform(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
void BKE_mesh_runtime_clear_geometry(struct Mesh *mesh)
struct Mesh * mesh_get_eval_final(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
void multiresModifier_prepare_join(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct Object *to_ob)
struct MultiresModifierData * get_multires_modifier(struct Scene *scene, struct Object *ob, bool use_first)
General operations, lookup, etc. for blender objects.
void BKE_object_apply_mat4_ex(struct Object *ob, const float mat[4][4], struct Object *parent, const float parentinv[4][4], bool use_compat)
void BKE_object_free_derived_caches(struct Object *ob)
Functions for dealing with object face-maps.
int * BKE_object_facemap_index_map_create(struct Object *ob_src, struct Object *ob_dst, int *r_map_len)
void BKE_object_facemap_index_map_apply(int *fmap, int fmap_len, const int *map, int map_len)
struct bFaceMap * BKE_object_facemap_find_name(struct Object *ob, const char *name)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_new_ex(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void invert_m4_m4_safe_ortho(float Ainv[4][4], const float A[4][4])
void mul_m4_v3(const float M[4][4], float r[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float len_manhattan_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
struct Depsgraph Depsgraph
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
Object is a sort of wrapper for general info.
uint DRW_select_buffer_find_nearest_to_point(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const int center[2], uint id_min, uint id_max, uint *dist)
uint DRW_select_buffer_sample_point(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const int center[2])
bool ED_mesh_mirrtopo_recalc_check(struct BMEditMesh *em, struct Mesh *me, MirrTopoStore_t *mesh_topo_store)
void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store)
void ED_mesh_mirror_spatial_table_begin(struct Object *ob, struct BMEditMesh *em, struct Mesh *me_eval)
void ED_mesh_mirror_spatial_table_end(struct Object *ob)
int ED_mesh_mirror_spatial_table_lookup(struct Object *ob, struct BMEditMesh *em, struct Mesh *me_eval, const float co[3])
void ED_mesh_mirrtopo_init(struct BMEditMesh *em, struct Mesh *me, MirrTopoStore_t *mesh_topo_store, bool skip_em_vert_array_init)
bool ED_object_multires_update_totlevels_cb(struct Object *ob, void *totlevel_v)
bool ED_object_iter_other(struct Main *bmain, struct Object *orig_ob, bool include_orig, bool(*callback)(struct Object *ob, void *callback_data), void *callback_data)
void ED_object_base_free_and_unlink(struct Main *bmain, struct Scene *scene, struct Object *ob)
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
void ED_view3d_select_id_validate(struct ViewContext *vc)
#define V3D_PROJ_TEST_CLIP_DEFAULT
eV3DProjStatus ED_view3d_project_float_object(const struct ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
void ED_view3d_init_mats_rv3d(const struct Object *ob, struct RegionView3D *rv3d)
_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 BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_elem_index_get(ele)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
ATTR_WARN_UNUSED_RESULT BMesh * bm
BMVert * BM_mesh_active_vert_get(BMesh *bm)
void BM_mesh_elem_index_ensure_ex(BMesh *bm, const char htype, int elem_offset[4])
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
void BM_face_uv_calc_center_median(const BMFace *f, const int cd_loop_uv_offset, float r_cent[2])
const Depsgraph * depsgraph
static int elem_offset(const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
struct BMEditMesh * edit_mesh
struct MDeformVert * dvert
ListBase vertex_group_names
int vertex_group_active_index
struct Depsgraph * depsgraph
struct ReportList * reports
void WM_event_add_notifier(const bContext *C, uint type, void *reference)