69 # define ASSERT_IS_VALID_MESH(mesh) \
70 (BLI_assert((mesh == NULL) || (BKE_mesh_is_valid(mesh) == true)))
72 # define ASSERT_IS_VALID_MESH(mesh)
81 MLoop *mloop, *allloop;
83 const float *nors, *
verts;
115 int count = index[2] != index[3] ? 4 : 3;
117 mloop[0].
v = index[0];
118 mloop[1].
v = index[1];
119 mloop[2].
v = index[2];
121 mloop[3].
v = index[3];
125 mpoly->
loopstart = (int)(mloop - allloop);
146 MEdge **r_alledge,
int *r_totedge,
const MPoly *mpoly,
MLoop *mloop,
const int totpoly)
148 int totedge = *r_totedge;
151 unsigned int eh_reserve;
158 for (i = 0, mp = mpoly; i < totpoly; i++, mp++) {
167 MEdge *medge = *r_alledge;
168 for (i = 0; i < totedge; i++, medge++) {
177 unsigned int e_index = totedge;
179 *r_alledge = medge = (*r_alledge ?
184 totedge += totedge_new;
197 *r_totedge = totedge;
199 for (i = 0, mp = mpoly; i < totpoly; i++, mp++) {
203 for (j = 0; j < mp->
totloop; j++,
l++) {
270 int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totpoly = 0;
271 int p1, p2, p3, p4, *index;
272 const bool conv_polys = (
279 dl = dispbase->
first;
283 totedge += dl->
parts * (dl->
nr - 1);
292 if (dl->
parts != 0) {
320 totpoly,
sizeof(
MLoop[4]),
"nurbs_init mloop");
330 dl = dispbase->
first;
335 startvert = vertcount;
347 for (b = 1; b < dl->
nr; b++) {
348 medge->
v1 = startvert + ofs + b - 1;
349 medge->
v2 = startvert + ofs + b;
358 startvert = vertcount;
370 for (b = 0; b < dl->
nr; b++) {
371 medge->
v1 = startvert + ofs + b;
372 if (b == dl->
nr - 1) {
373 medge->
v2 = startvert + ofs;
376 medge->
v2 = startvert + ofs + b + 1;
385 startvert = vertcount;
398 mloop[0].
v = startvert + index[0];
399 mloop[1].
v = startvert + index[2];
400 mloop[2].
v = startvert + index[1];
401 mpoly->
loopstart = (int)(mloop - (*r_allloop));
406 for (
int i = 0; i < 3; i++, mloopuv++) {
407 mloopuv->
uv[0] = (mloop[i].
v - startvert) / (
float)(dl->
nr - 1);
408 mloopuv->
uv[1] = 0.0f;
421 startvert = vertcount;
438 p1 = startvert + dl->
nr *
a;
439 p2 = p1 + dl->
nr - 1;
445 p2 = startvert + dl->
nr *
a;
456 for (; b < dl->
nr; b++) {
461 mpoly->
loopstart = (int)(mloop - (*r_allloop));
466 int orco_sizeu = dl->
nr - 1;
467 int orco_sizev = dl->
parts - 1;
480 for (
int i = 0; i < 4; i++, mloopuv++) {
482 int v = mloop[i].
v - startvert;
484 mloopuv->
uv[0] = (
v / dl->
nr) / (
float)orco_sizev;
485 mloopuv->
uv[1] = (
v % dl->
nr) / (
float)orco_sizeu;
488 if ((i == 1 || i == 2) && mloopuv->
uv[0] == 0.0f) {
489 mloopuv->
uv[0] = 1.0f;
491 if ((i == 0 || i == 1) && mloopuv->
uv[1] == 0.0f) {
492 mloopuv->
uv[1] = 1.0f;
518 *r_totpoly = totpoly;
519 *r_totloop = totloop;
520 *r_totedge = totedge;
521 *r_totvert = totvert;
534 int totvert, totedge, totloop, totpoly;
560 const char *uvname =
"UVMap";
596 int totvert, totedge, totloop, totpoly;
624 me->totvert = totvert;
625 me->totedge = totedge;
626 me->totloop = totloop;
627 me->totpoly = totpoly;
635 const char *uvname =
"UVMap";
654 me->totcol = cu->totcol;
681 if (ob1->
data == cu) {
708 if (ob->runtime.curve_cache) {
709 disp = ob->runtime.curve_cache->disp;
758 for (i = 0, mp = mpoly; i < mpoly_len; i++, mp++) {
761 for (j = 0; j < mp->
totloop; j++, ml++) {
768 for (i = 0; i < medge_len; i++, med++) {
769 if (edge_users[i] == edge_users_test) {
780 while (edges.
first) {
787 unsigned int startVert = med_current->
v1;
788 unsigned int endVert = med_current->
v2;
806 if (med->
v1 == endVert) {
814 else if (med->
v2 == endVert) {
822 else if (med->
v1 == startVert) {
830 else if (med->
v2 == startVert) {
844 if (startVert == endVert) {
869 for (i = 0, bp = nu->
bp; i < totpoly; i++, bp++, vl = (
VertLink *)vl->
next) {
895 if (nurblist.
first) {
926 for (
int i = 0; i < me->
totvert; i++, mvert++) {
946 ob->
data = pointcloud;
975 for (
int i = 0; i < me->
totvert; i++, mvert++) {
1032 "CurveCache for curve types");
1046 Curve *temp_curve = (
Curve *)temp_object->data;
1067 Object remapped_object = *
object;
1069 remapped_object.data = &remapped_curve;
1079 if (remapped_curve.bevobj !=
NULL) {
1080 bevel_object = *remapped_curve.bevobj;
1081 bevel_object.runtime.bb =
NULL;
1083 remapped_curve.bevobj = &bevel_object;
1088 if (remapped_curve.taperobj !=
NULL) {
1089 taper_object = *remapped_curve.taperobj;
1092 remapped_curve.taperobj = &taper_object;
1104 NULL,
NULL, &remapped_object, &remapped_object.runtime.curve_cache->disp, &mesh_eval,
false);
1109 if (mesh_eval !=
NULL) {
1149 Mesh *mesh_result = temp_object->
data;
1180 for (
int i = mball->
totcol; i-- > 0;) {
1204 const bool preserve_origindex)
1214 Object object_for_eval = *object;
1221 if (preserve_origindex) {
1233 const bool preserve_all_data_layers,
1234 const bool preserve_origindex)
1236 if (preserve_all_data_layers || preserve_origindex) {
1239 Mesh *mesh_input =
object->data;
1250 const bool preserve_all_data_layers,
1251 const bool preserve_origindex)
1254 switch (object->
type) {
1265 depsgraph,
object, preserve_all_data_layers, preserve_origindex);
1271 if (new_mesh ==
NULL) {
1296 if (*id_p ==
NULL) {
1307 if (*id_p ==
NULL) {
1311 const int cb_flag = cb_data->
cb_flag;
1326 bool preserve_all_data_layers)
1335 return mesh_in_bmain;
1377 return mesh_in_bmain;
1383 Key *key = mesh_src->
key;
1386 if (!mesh_src->
key) {
1393 "vertex size mismatch (mesh/dm) '%s' (%d != %d)",
1406 "vertex size mismatch (Mesh '%s':%d != KeyBlock '%s':%d)",
1422 mesh_dest->vdata.layers[ci].uid = kb->
uid;
1430 const bool build_shapekey_layers)
1446 if (build_shapekey_layers && me->
key &&
1459 if (build_shapekey_layers) {
1468 if (build_shapekey_layers) {
1475 if (mesh_temp !=
result) {
1489 if (!mesh_dst->
key) {
1494 for (i = 0; i < tot; i++) {
1500 if (kb->
uid == layer->
uid) {
1518 if (kb->
uid == actshape_uid) {
1521 for (j = 0; j < mesh_src->
totvert; j++, kbcos++, mvert++) {
1526 for (j = 0; j < kb->
totelem; j++,
cos++, kbcos++) {
1540 CLOG_ERROR(&
LOG,
"lost a shapekey layer: '%s'! (bmesh internal error)", kb->
name);
1549 bool take_ownership)
1556 Mesh tmp = *mesh_dst;
1557 int totvert, totedge , totloop, totpoly;
1558 int did_shapekeys = 0;
1561 if (take_ownership ) {
1567 if (!has_any_referenced_layers) {
1654 if (totloop == mesh_dst->
totloop) {
1700 if (take_ownership) {
1715 int a, totvert = mesh_src->
totvert;
1719 if (totvert == 0 || mesh_dst->
totvert == 0 || mesh_dst->
totvert != totvert) {
1730 mvert = mesh_src->
mvert;
1732 for (
a = 0;
a < kb->
totelem;
a++, fp += 3, mvert++) {
typedef float(TangentPoint)[2]
struct Curve * BKE_curve_add(struct Main *bmain, const char *name, int type)
void BKE_curve_texspace_calc(struct Curve *cu)
void CustomData_free(struct CustomData *data, int totelem)
int CustomData_number_of_layers(const struct CustomData *data, int type)
bool CustomData_free_layer(struct CustomData *data, int type, int totelem, int index)
bool CustomData_has_layer(const struct CustomData *data, int type)
int CustomData_get_named_layer_index(const struct CustomData *data, int type, const char *name)
void * CustomData_set_layer(const struct CustomData *data, int type, void *ptr)
int CustomData_get_layer_index_n(const struct CustomData *data, int type, int n)
void * CustomData_add_layer_named(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem, const char *name)
bool CustomData_has_referenced(const struct CustomData *data)
void * CustomData_get_layer_n(const struct CustomData *data, int type, int n)
void * CustomData_get_layer(const struct CustomData *data, int type)
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
bool CustomData_merge(const struct CustomData *source, struct CustomData *dest, CustomDataMask mask, eCDAllocType alloctype, int totelem)
void CustomData_copy(const struct CustomData *source, struct CustomData *dest, CustomDataMask mask, eCDAllocType alloctype, int totelem)
void CustomData_realloc(struct CustomData *data, int totelem)
void CustomData_free_typemask(struct CustomData *data, int totelem, CustomDataMask mask)
const CustomData_MeshMasks CD_MASK_MESH
void CustomData_reset(struct CustomData *data)
void CustomData_update_typemap(struct CustomData *data)
display list (or rather multi purpose list) stuff.
void BKE_displist_copy(struct ListBase *lbn, const struct ListBase *lb)
void BKE_displist_make_curveTypes_forRender(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct Mesh **r_final, const bool for_orco)
void BKE_keyblock_convert_to_mesh(struct KeyBlock *kb, struct Mesh *me)
struct KeyBlock * BKE_keyblock_add(struct Key *key, const char *name)
void id_us_min(struct ID *id)
void * BKE_id_new_nomain(const short type, const char *name)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag)
void BKE_id_free(struct Main *bmain, void *idv)
void id_us_ensure_real(struct ID *id)
void id_us_plus(struct ID *id)
void BKE_id_free_us(struct Main *bmain, void *idv) ATTR_NONNULL()
void BKE_library_foreach_ID_link(struct Main *bmain, struct ID *id, LibraryIDLinkCallback callback, void *user_data, int flag)
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
void BKE_id_materials_copy(struct Main *bmain, struct ID *id_src, struct ID *id_dst)
void BKE_mesh_poly_edgehash_insert(struct EdgeHash *ehash, const struct MPoly *mp, const struct MLoop *mloop)
void BKE_mesh_ensure_normals(struct Mesh *me)
struct Mesh * BKE_mesh_add(struct Main *bmain, const char *name)
void BKE_mesh_vert_coords_apply(struct Mesh *mesh, const float(*vert_coords)[3])
struct Mesh * BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
void BKE_mesh_texspace_copy_from_object(struct Mesh *me, struct Object *ob)
void BKE_mesh_calc_normals(struct Mesh *me)
void BKE_mesh_texspace_calc(struct Mesh *me)
void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd)
void BKE_mesh_calc_edges(struct Mesh *mesh, bool keep_existing_edges, const bool select_new_edges)
float(* BKE_mesh_vert_coords_alloc(const struct Mesh *mesh, int *r_vert_len))[3]
struct Mesh * mesh_get_eval_final(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
void BKE_mesh_runtime_clear_geometry(struct Mesh *mesh)
struct Mesh * mesh_create_eval_final(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
void BKE_mesh_wrapper_ensure_mdata(struct Mesh *me)
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
@ eModifierTypeType_OnlyDeform
General operations, lookup, etc. for blender objects.
void BKE_object_free_modifiers(struct Object *ob, const int flag)
void BKE_object_free_derived_caches(struct Object *ob)
void BKE_object_free_curve_cache(struct Object *ob)
void BKE_object_eval_assign_data(struct Object *object, struct ID *data, bool is_owned)
General operations for point-clouds.
void * BKE_pointcloud_add(struct Main *bmain, const char *name)
void BKE_pointcloud_update_customdata_pointers(struct PointCloud *pointcloud)
const char * POINTCLOUD_ATTR_POSITION
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
BLI_INLINE void BLI_edgehashIterator_step(EdgeHashIterator *ehi)
#define BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS(totpoly)
void BLI_edgehashIterator_free(EdgeHashIterator *ehi)
void * BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT
int BLI_edgehash_len(EdgeHash *eh) ATTR_WARN_UNUSED_RESULT
bool BLI_edgehash_haskey(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
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])
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
#define POINTER_AS_UINT(i)
#define POINTER_FROM_UINT(i)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define CLOG_ERROR(clg_ref,...)
struct Depsgraph Depsgraph
bool DEG_is_original_id(const struct ID *id)
bool DEG_is_evaluated_object(const struct Object *object)
struct ID * DEG_get_original_id(struct ID *id)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
#define CD_MASK_ORIGINDEX
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
const Depsgraph * depsgraph
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
void *(* MEM_callocN)(size_t len, const char *str)
void BKE_mesh_from_metaball(ListBase *lb, Mesh *me)
static Mesh * mesh_new_from_curve_type_object(Object *object)
void BKE_pointcloud_from_mesh(Mesh *me, PointCloud *pointcloud)
void BKE_mesh_from_pointcloud(const PointCloud *pointcloud, Mesh *me)
static Mesh * mesh_new_from_mesh_object(Depsgraph *depsgraph, Object *object, const bool preserve_all_data_layers, const bool preserve_origindex)
static void add_shapekey_layers(Mesh *mesh_dest, Mesh *mesh_src)
static void prependPolyLineVert(ListBase *lb, unsigned int index)
void BKE_pointcloud_to_mesh(Main *bmain, Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob)
void BKE_mesh_nomain_to_meshkey(Mesh *mesh_src, Mesh *mesh_dst, KeyBlock *kb)
void BKE_mesh_edges_set_draw_render(Mesh *mesh)
void BKE_mesh_to_pointcloud(Main *bmain, Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob)
void BKE_mesh_from_nurbs(Main *bmain, Object *ob)
static void appendPolyLineVert(ListBase *lb, unsigned int index)
static Object * object_for_curve_to_mesh_create(Object *object)
static int foreach_libblock_make_original_callback(LibraryIDLinkCallbackData *cb_data)
int BKE_mesh_nurbs_displist_to_mdata(Object *ob, const ListBase *dispbase, MVert **r_allvert, int *r_totvert, MEdge **r_alledge, int *r_totedge, MLoop **r_allloop, MPoly **r_allpoly, MLoopUV **r_alluv, int *r_totloop, int *r_totpoly)
void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob)
Mesh * BKE_mesh_new_nomain_from_curve(Object *ob)
void BKE_mesh_to_curve_nurblist(const Mesh *me, ListBase *nurblist, const int edge_users_test)
Mesh * BKE_mesh_new_nomain_from_curve_displist(Object *ob, ListBase *dispbase)
static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int actshape_uid)
static void curve_to_mesh_eval_ensure(Object *object)
static Mesh * mesh_new_from_mesh_object_with_layers(Depsgraph *depsgraph, Object *object, const bool preserve_origindex)
static Mesh * mesh_new_from_mball_object(Object *object)
static void make_edges_mdata_extend(MEdge **r_alledge, int *r_totedge, const MPoly *mpoly, MLoop *mloop, const int totpoly)
Mesh * BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph, Scene *scene, Object *ob_eval, ModifierData *md_eval, const bool build_shapekey_layers)
static Mesh * mesh_new_from_mesh(Object *object, Mesh *mesh)
Mesh * BKE_mesh_new_from_object(Depsgraph *depsgraph, Object *object, const bool preserve_all_data_layers, const bool preserve_origindex)
static int foreach_libblock_make_usercounts_callback(LibraryIDLinkCallbackData *cb_data)
Mesh * BKE_mesh_new_from_object_to_bmain(Main *bmain, Depsgraph *depsgraph, Object *object, bool preserve_all_data_layers)
int BKE_mesh_nurbs_to_mdata(Object *ob, MVert **r_allvert, int *r_totvert, MEdge **r_alledge, int *r_totedge, MLoop **r_allloop, MPoly **r_allpoly, int *r_totloop, int *r_totpoly)
#define ASSERT_IS_VALID_MESH(mesh)
void BKE_mesh_from_nurbs_displist(Main *bmain, Object *ob, ListBase *dispbase, const char *obdata_name, bool temporary)
void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, const CustomData_MeshMasks *mask, bool take_ownership)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
struct Mesh * mesh_eval_final
struct EditFont * editfont
struct BMEditMesh * edit_mesh
struct CustomData pdata ldata
struct CustomData vdata edata fdata
bool(* isDisabled)(const struct Scene *scene, struct ModifierData *md, bool userRenderParams)
struct Mesh *(* modifyMesh)(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh)
void(* deformVerts)(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh, float(*vertexCos)[3], int numVerts)
struct CurveCache * curve_cache
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)