71 const bool conv_polys = (
84 totvert += dl->parts * dl->nr;
85 totedge += dl->parts * (dl->nr - 1);
89 totvert += dl->parts * dl->nr;
90 totedge += dl->parts * dl->nr;
96 totvert += dl->parts * dl->nr;
97 tot = (((dl->flag &
DL_CYCL_U) ? 1 : 0) + (dl->nr - 1)) *
98 (((dl->flag &
DL_CYCL_V) ? 1 : 0) + (dl->parts - 1));
124 "material_index", AttrDomain::Face);
126 "sharp_face", AttrDomain::Face);
128 DATA_(
"UVMap"), AttrDomain::Corner);
136 const bool is_smooth = (dl->rt &
CU_SMOOTH) != 0;
139 const int startvert = dst_vert;
140 a = dl->parts * dl->nr;
141 const float *data = dl->verts;
148 for (a = 0; a < dl->parts; a++) {
150 for (
b = 1;
b < dl->nr;
b++) {
151 edges[dst_edge][0] = startvert + ofs +
b - 1;
152 edges[dst_edge][1] = startvert + ofs +
b;
158 else if (dl->type ==
DL_POLY) {
160 const int startvert = dst_vert;
161 a = dl->parts * dl->nr;
162 const float *data = dl->verts;
169 for (a = 0; a < dl->parts; a++) {
171 for (
b = 0;
b < dl->nr;
b++) {
172 edges[dst_edge][0] = startvert + ofs +
b;
173 if (
b == dl->nr - 1) {
174 edges[dst_edge][1] = startvert + ofs;
177 edges[dst_edge][1] = startvert + ofs +
b + 1;
185 const int startvert = dst_vert;
187 const float *data = dl->verts;
195 const int *index = dl->index;
197 corner_verts[dst_loop + 0] = startvert + index[0];
198 corner_verts[dst_loop + 1] = startvert + index[2];
199 corner_verts[dst_loop + 2] = startvert + index[1];
200 face_offsets[dst_poly] = dst_loop;
201 material_indices.
span[dst_poly] = dl->col;
203 for (
int i = 0; i < 3; i++) {
204 uv_map[dst_loop + i][0] = (corner_verts[dst_loop + i] - startvert) /
float(dl->nr - 1);
205 uv_map[dst_loop + i][1] = 0.0f;
208 sharp_faces.span[dst_poly] = !is_smooth;
214 else if (dl->type ==
DL_SURF) {
215 const int startvert = dst_vert;
216 a = dl->parts * dl->nr;
217 const float *data = dl->verts;
224 for (a = 0; a < dl->parts; a++) {
226 if ((dl->flag &
DL_CYCL_V) == 0 && a == dl->parts - 1) {
232 p1 = startvert + dl->nr * a;
233 p2 = p1 + dl->nr - 1;
239 p2 = startvert + dl->nr * a;
245 if ((dl->flag &
DL_CYCL_V) && a == dl->parts - 1) {
246 p3 -= dl->parts * dl->nr;
247 p4 -= dl->parts * dl->nr;
250 for (;
b < dl->nr;
b++) {
251 corner_verts[dst_loop + 0] = p1;
252 corner_verts[dst_loop + 1] = p3;
253 corner_verts[dst_loop + 2] = p4;
254 corner_verts[dst_loop + 3] = p2;
255 face_offsets[dst_poly] = dst_loop;
256 material_indices.
span[dst_poly] = dl->col;
258 int orco_sizeu = dl->nr - 1;
259 int orco_sizev = dl->parts - 1;
272 for (
int i = 0; i < 4; i++) {
274 int v = corner_verts[dst_loop + i] - startvert;
276 uv_map[dst_loop + i][0] = (
v / dl->nr) /
float(orco_sizev);
277 uv_map[dst_loop + i][1] = (
v % dl->nr) /
float(orco_sizeu);
280 if (
ELEM(i, 1, 2) && uv_map[dst_loop + i][0] == 0.0f) {
281 uv_map[dst_loop + i][0] = 1.0f;
283 if (
ELEM(i, 0, 1) && uv_map[dst_loop + i][1] == 0.0f) {
284 uv_map[dst_loop + i][1] = 1.0f;
288 sharp_faces.span[dst_poly] = !is_smooth;
302 mesh_calc_edges(*mesh,
true,
false);
305 material_indices.
finish();
306 sharp_faces.finish();
307 uv_attribute.finish();
334 mesh->totcol = cu->
totcol;
343 if (ob->
runtime->curve_cache) {
344 disp = ob->
runtime->curve_cache->disp;
362 VertLink *vl = MEM_cnew<VertLink>(
"VertLink");
369 VertLink *vl = MEM_cnew<VertLink>(
"VertLink");
379 const Span<int> corner_edges = mesh->corner_edges();
384 ListBase edges = {
nullptr,
nullptr};
389 for (
const int edge : corner_edges.
slice(polys[i])) {
396 if (edge_users[i] == edge_users_test) {
397 EdgeLink *edl = MEM_cnew<EdgeLink>(
"EdgeLink");
398 edl->
edge = &mesh_edges[i];
406 while (edges.first) {
409 ListBase polyline = {
nullptr,
nullptr};
413 uint startVert = edge_current[0];
414 uint endVert = edge_current[1];
431 if (edge[0] == endVert) {
438 else if (edge[1] == endVert) {
445 else if (edge[0] == startVert) {
452 else if (edge[1] == startVert) {
465 if (startVert == endVert) {
480 nu->
pntsu = faces_num;
491 for (i = 0, bp = nu->
bp; i < faces_num; i++, bp++, vl = (
VertLink *)vl->
next) {
517 ListBase nurblist = {
nullptr,
nullptr};
522 if (nurblist.
first) {
558 ob->
data = pointcloud;
574 if (
const PointCloud *points = geometry.get_pointcloud()) {
575 mesh->verts_num = points->totpoint;
591 const Curve *curve = (
const Curve *)object->data;
604 (
const ID *)object->data,
615 temp_curve->
editfont = curve->editfont;
616 temp_curve->
editnurb = curve->editnurb;
624 ID *final_object_data =
static_cast<ID *
>(temp_object->
data);
626 Curve &curve = *
reinterpret_cast<Curve *
>(final_object_data);
628 curve.editnurb =
nullptr;
634 const bool object_data_stored_in_data_eval = final_object_data ==
635 temp_object->
runtime->data_eval;
638 if (!object_data_stored_in_data_eval) {
649 Curve &curve = *
static_cast<Curve *
>(
object.data);
657 Object bevel_object = blender::dna::shallow_zero_initialize();
659 if (curve.bevobj !=
nullptr) {
660 bevel_object = blender::dna::shallow_copy(*curve.bevobj);
661 bevel_runtime = *curve.bevobj->runtime;
662 bevel_object.
runtime = &bevel_runtime;
666 curve.bevobj = &bevel_object;
670 Object taper_object = blender::dna::shallow_zero_initialize();
672 if (curve.taperobj !=
nullptr) {
673 taper_object = blender::dna::shallow_copy(*curve.taperobj);
674 taper_runtime = *curve.taperobj->runtime;
675 taper_object.
runtime = &taper_runtime;
679 curve.taperobj = &taper_object;
701 return geometry_set_eval->get_curves();
730 ID *temp_data =
static_cast<ID *
>(temp_object->
data);
734 if (temp_data != temp_object->
data) {
737 Curve *curve =
reinterpret_cast<Curve *
>(temp_data);
739 curve->editnurb =
nullptr;
763 if (mesh_eval ==
nullptr) {
791 const bool preserve_origindex)
801 Object object_for_eval = blender::dna::shallow_copy(*
object);
803 object_for_eval.
runtime = &runtime;
805 if (object_for_eval.
runtime->data_orig !=
nullptr) {
806 object_for_eval.
data = object_for_eval.
runtime->data_orig;
811 if (preserve_origindex) {
823 const bool preserve_all_data_layers,
824 const bool preserve_origindex)
829 if (!(object->runtime->data_orig &&
GS(object->runtime->data_orig->name) !=
ID_ME) &&
830 (preserve_all_data_layers || preserve_origindex))
834 const Mesh *mesh_input = (
const Mesh *)object->data;
837 if (mesh_input->
runtime->edit_mesh !=
nullptr) {
839 mesh_input = editmesh_eval_final;
847 const bool preserve_all_data_layers,
848 const bool preserve_origindex)
850 Mesh *new_mesh =
nullptr;
851 switch (object->type) {
862 depsgraph,
object, preserve_all_data_layers, preserve_origindex);
868 if (new_mesh ==
nullptr) {
885 new_mesh->
runtime->edit_mesh =
nullptr;
893 if (*id_p ==
nullptr) {
904 if (*id_p ==
nullptr) {
908 const int cb_flag = cb_data->
cb_flag;
923 bool preserve_all_data_layers)
928 if (mesh ==
nullptr) {
932 return mesh_in_bmain;
956 mesh_in_bmain->
mat = mesh->mat;
957 mesh_in_bmain->
totcol = mesh->totcol;
963 mesh_in_bmain->attributes_for_write().remove_anonymous();
974 return mesh_in_bmain;
979 const auto &src_cache = src.
runtime->loose_verts_cache;
980 if (src_cache.is_cached() && src_cache.data().count == 0) {
981 dst.tag_loose_verts_none();
987 const auto &src_cache = src.
runtime->loose_edges_cache;
988 if (src_cache.is_cached() && src_cache.data().count == 0) {
989 dst.tag_loose_edges_none();
995 if (src.no_overlapping_topology()) {
996 dst.tag_overlapping_none();
1012 const int active_kb_index =
object.shapenr - 1;
1015 CLOG_ERROR(&
LOG,
"Could not find object's active shapekey %d", active_kb_index);
1024 const int actshape_uid)
1037 if (kb->
uid == actshape_uid) {
1038 mesh.attributes().lookup<
float3>(
"position").varray.materialize(kb_coords);
1041 kb_coords.
copy_from({
static_cast<const float3 *
>(layer.data), mesh.verts_num});
1046 if (kb->totelem != mesh.verts_num) {
1048 kb->totelem = mesh.verts_num;
1049 kb->data = MEM_cnew_array<float3>(kb->totelem, __func__);
1050 CLOG_ERROR(&
LOG,
"Data for shape key '%s' on mesh missing from evaluated mesh ", kb->name);
1083 std::swap(mesh_dst->
runtime->face_offsets_sharing_info,
1084 mesh_src->
runtime->face_offsets_sharing_info);
1095 if (
Key *key_dst = mesh_dst->
key) {
1101 else if (verts_num_changed) {
1102 CLOG_WARN(&
LOG,
"Shape key data lost when replacing mesh '%s' in Main", mesh_src->
id.
name);
1104 mesh_dst->
key =
nullptr;
1122 const int totvert = mesh_src->
verts_num;
void BKE_curve_texspace_calc(Curve *cu)
short BKE_curve_type_get(const Curve *cu)
Curve * BKE_curve_add(Main *bmain, const char *name, int type)
Low-level operations for curves.
int CustomData_get_layer_index_n(const CustomData *data, eCustomDataType type, int n)
void CustomData_init_from(const CustomData *source, CustomData *dest, eCustomDataMask mask, int totelem)
void CustomData_free(CustomData *data, int totelem)
bool CustomData_merge(const CustomData *source, CustomData *dest, eCustomDataMask mask, int totelem)
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
int CustomData_number_of_layers(const CustomData *data, eCustomDataType type)
const CustomData_MeshMasks CD_MASK_MESH
display list (or rather multi purpose list) stuff.
void BKE_displist_make_curveTypes(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, bool for_render)
KeyBlock * BKE_keyblock_add(Key *key, const char *name)
KeyBlock * BKE_keyblock_find_uid(Key *key, int uid)
@ LIB_ID_COPY_SET_COPIED_ON_WRITE
@ LIB_ID_CREATE_NO_USER_REFCOUNT
void BKE_id_free(Main *bmain, void *idv)
void id_us_ensure_real(ID *id)
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
void * BKE_id_new_nomain(short type, const char *name)
void BKE_library_foreach_ID_link(Main *bmain, ID *id, blender::FunctionRef< LibraryIDLinkCallback > callback, void *user_data, int flag)
General operations, lookup, etc. for materials.
void BKE_id_materials_copy(struct Main *bmain, struct ID *id_src, struct ID *id_dst)
void BKE_mesh_clear_geometry_and_metadata(Mesh *mesh)
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
Mesh * BKE_mesh_add(Main *bmain, const char *name)
void BKE_mesh_copy_parameters(Mesh *me_dst, const Mesh *me_src)
Mesh * BKE_mesh_copy_for_eval(const Mesh &source)
void BKE_mesh_texspace_calc(Mesh *mesh)
void BKE_mesh_wrapper_ensure_mdata(Mesh *mesh)
Mesh * BKE_mesh_wrapper_ensure_subdivision(Mesh *mesh)
General operations, lookup, etc. for blender objects.
Mesh * BKE_object_get_evaluated_mesh_no_subsurf(const Object *object_eval)
void BKE_object_runtime_reset(Object *object)
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
void BKE_object_runtime_free_data(Object *object)
void BKE_object_free_modifiers(Object *ob, int flag)
const Mesh * BKE_object_get_editmesh_eval_final(const Object *object)
void BKE_object_free_derived_caches(Object *ob)
General operations for point clouds.
void * BKE_pointcloud_add(Main *bmain, const char *name)
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define STRNCPY(dst, src)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
bool DEG_is_original_id(const ID *id)
ID * DEG_get_original_id(ID *id)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
bool DEG_is_evaluated_object(const Object *object)
#define CD_MASK_ORIGINDEX
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v
constexpr void copy_from(Span< T > values) const
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
IndexRange index_range() const
local_group_size(16, 16) .push_constant(Type b
const Depsgraph * depsgraph
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_dupallocN)(const void *vmemh)
void BKE_mesh_to_pointcloud(Main *bmain, Depsgraph *depsgraph, Scene *, Object *ob)
static Mesh * mesh_new_from_mesh_object(Depsgraph *depsgraph, Object *object, const bool preserve_all_data_layers, const bool preserve_origindex)
static void copy_loose_edge_hint(const Mesh &src, Mesh &dst)
void BKE_mesh_to_curve_nurblist(const Mesh *mesh, ListBase *nurblist, const int edge_users_test)
void BKE_pointcloud_to_mesh(Main *bmain, Depsgraph *depsgraph, Scene *, Object *ob)
Mesh * BKE_mesh_new_nomain_from_curve(const Object *ob)
static Mesh * mesh_new_from_mball_object(Object *object)
static Mesh * mesh_new_from_mesh(Object *object, const Mesh *mesh)
static Object * object_for_curve_to_mesh_create(const Object *object)
static void mesh_copy_texture_space_from_curve_type(const Curve *cu, Mesh *mesh)
void BKE_mesh_nomain_to_meshkey(Mesh *mesh_src, Mesh *mesh_dst, KeyBlock *kb)
static void appendPolyLineVert(ListBase *lb, uint index)
static KeyBlock * keyblock_ensure_from_uid(Key &key, const int uid, const StringRefNull name)
static Mesh * mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispbase)
static void curve_to_mesh_eval_ensure(Object &object)
void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob)
static int foreach_libblock_make_original_callback(LibraryIDLinkCallbackData *cb_data)
Mesh * BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *dispbase)
Mesh * BKE_mesh_new_from_object(Depsgraph *depsgraph, Object *object, const bool preserve_all_data_layers, const bool preserve_origindex)
static void copy_overlapping_hint(const Mesh &src, Mesh &dst)
static void prependPolyLineVert(ListBase *lb, uint index)
void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene *, Object *ob)
static void move_shapekey_layers_to_keyblocks(const Mesh &mesh, const CustomData &custom_data, Key &key_dst, const int actshape_uid)
static int find_object_active_key_uid(const Key &key, const Object &object)
static Mesh * mesh_new_from_evaluated_curve_type_object(const Object *evaluated_object)
static void copy_loose_vert_hint(const Mesh &src, Mesh &dst)
static int foreach_libblock_make_usercounts_callback(LibraryIDLinkCallbackData *cb_data)
static Mesh * mesh_new_from_mesh_object_with_layers(Depsgraph *depsgraph, Object *object, const bool preserve_origindex)
static const Curves * get_evaluated_curves_from_object(const Object *object)
static Mesh * mesh_new_from_curve_type_object(const Object *object)
Mesh * BKE_mesh_new_from_object_to_bmain(Main *bmain, Depsgraph *depsgraph, Object *object, bool preserve_all_data_layers)
static void object_for_curve_to_mesh_free(Object *temp_object)
GeometrySet object_get_evaluated_geometry_set(const Object &object)
Mesh * curve_to_wire_mesh(const CurvesGeometry &curve, const bke::AttributeFilter &attribute_filter={})
Mesh * mesh_create_eval_final(Depsgraph *depsgraph, const Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
struct EditFont * editfont
float texspace_location[3]
MeshRuntimeHandle * runtime
char * default_color_attribute
ListBase vertex_group_names
int * face_offset_indices
char * active_color_attribute
ObjectRuntimeHandle * runtime
MutableVArraySpan< T > span