70 const bool conv_polys = (
83 totvert += dl->parts * dl->nr;
84 totedge += dl->parts * (dl->nr - 1);
88 totvert += dl->parts * dl->nr;
89 totedge += dl->parts * dl->nr;
95 totvert += dl->parts * dl->nr;
96 tot = (((dl->flag &
DL_CYCL_U) ? 1 : 0) + (dl->nr - 1)) *
97 (((dl->flag &
DL_CYCL_V) ? 1 : 0) + (dl->parts - 1));
135 const bool is_smooth = (dl->rt &
CU_SMOOTH) != 0;
138 const int startvert = dst_vert;
139 a = dl->parts * dl->nr;
140 const float *
data = dl->verts;
147 for (a = 0; a < dl->parts; a++) {
149 for (
b = 1;
b < dl->nr;
b++) {
150 edges[dst_edge][0] = startvert + ofs +
b - 1;
151 edges[dst_edge][1] = startvert + ofs +
b;
157 else if (dl->type ==
DL_POLY) {
159 const int startvert = dst_vert;
160 a = dl->parts * dl->nr;
161 const float *
data = dl->verts;
168 for (a = 0; a < dl->parts; a++) {
170 for (
b = 0;
b < dl->nr;
b++) {
171 edges[dst_edge][0] = startvert + ofs +
b;
172 if (
b == dl->nr - 1) {
173 edges[dst_edge][1] = startvert + ofs;
176 edges[dst_edge][1] = startvert + ofs +
b + 1;
184 const int startvert = dst_vert;
186 const float *
data = dl->verts;
194 const int *index = dl->index;
196 corner_verts[dst_loop + 0] = startvert + index[0];
197 corner_verts[dst_loop + 1] = startvert + index[2];
198 corner_verts[dst_loop + 2] = startvert + index[1];
199 face_offsets[dst_poly] = dst_loop;
200 material_indices.
span[dst_poly] = dl->col;
202 for (
int i = 0;
i < 3;
i++) {
203 uv_map[dst_loop +
i][0] = (corner_verts[dst_loop +
i] - startvert) /
float(dl->nr - 1);
204 uv_map[dst_loop +
i][1] = 0.0f;
207 sharp_faces.span[dst_poly] = !is_smooth;
213 else if (dl->type ==
DL_SURF) {
214 const int startvert = dst_vert;
215 a = dl->parts * dl->nr;
216 const float *
data = dl->verts;
223 for (a = 0; a < dl->parts; a++) {
225 if ((dl->flag &
DL_CYCL_V) == 0 && a == dl->parts - 1) {
231 p1 = startvert + dl->nr * a;
232 p2 = p1 + dl->nr - 1;
238 p2 = startvert + dl->nr * a;
244 if ((dl->flag &
DL_CYCL_V) && a == dl->parts - 1) {
245 p3 -= dl->parts * dl->nr;
246 p4 -= dl->parts * dl->nr;
249 for (;
b < dl->nr;
b++) {
250 corner_verts[dst_loop + 0] = p1;
251 corner_verts[dst_loop + 1] = p3;
252 corner_verts[dst_loop + 2] = p4;
253 corner_verts[dst_loop + 3] = p2;
254 face_offsets[dst_poly] = dst_loop;
255 material_indices.
span[dst_poly] = dl->col;
257 int orco_sizeu = dl->nr - 1;
258 int orco_sizev = dl->parts - 1;
271 for (
int i = 0;
i < 4;
i++) {
273 int v = corner_verts[dst_loop +
i] - startvert;
275 uv_map[dst_loop +
i][0] = (
v / dl->nr) /
float(orco_sizev);
276 uv_map[dst_loop +
i][1] = (
v % dl->nr) /
float(orco_sizeu);
279 if (
ELEM(
i, 1, 2) && uv_map[dst_loop +
i][0] == 0.0f) {
280 uv_map[dst_loop +
i][0] = 1.0f;
282 if (
ELEM(
i, 0, 1) && uv_map[dst_loop +
i][1] == 0.0f) {
283 uv_map[dst_loop +
i][1] = 1.0f;
287 sharp_faces.span[dst_poly] = !is_smooth;
304 material_indices.
finish();
305 sharp_faces.finish();
306 uv_attribute.finish();
342 if (ob->
runtime->curve_cache) {
343 disp = ob->
runtime->curve_cache->disp;
383 ListBase edges = {
nullptr,
nullptr};
388 for (
const int edge : corner_edges.
slice(polys[
i])) {
395 if (edge_users[
i] == edge_users_test) {
397 edl->
edge = &mesh_edges[
i];
405 while (edges.
first) {
408 ListBase polyline = {
nullptr,
nullptr};
412 uint startVert = edge_current[0];
413 uint endVert = edge_current[1];
430 if (edge[0] == endVert) {
437 else if (edge[1] == endVert) {
444 else if (edge[0] == startVert) {
451 else if (edge[1] == startVert) {
464 if (startVert == endVert) {
479 nu->
pntsu = faces_num;
516 ListBase nurblist = {
nullptr,
nullptr};
521 if (nurblist.
first) {
555 pointcloud->attributes_for_write());
560 ob->
data = pointcloud;
577 mesh->verts_num = points->totpoint;
582 mesh->attributes_for_write());
630 ID *final_object_data =
static_cast<ID *
>(temp_object->
data);
632 Curve &curve = *
reinterpret_cast<Curve *
>(final_object_data);
640 const bool object_data_stored_in_data_eval = final_object_data ==
641 temp_object->
runtime->data_eval;
644 if (!object_data_stored_in_data_eval) {
655 Curve &curve = *
static_cast<Curve *
>(
object.data);
663 Object bevel_object = blender::dna::shallow_zero_initialize();
665 if (curve.
bevobj !=
nullptr) {
666 bevel_object = blender::dna::shallow_copy(*curve.
bevobj);
668 bevel_object.
runtime = &bevel_runtime;
672 curve.
bevobj = &bevel_object;
676 Object taper_object = blender::dna::shallow_zero_initialize();
679 taper_object = blender::dna::shallow_copy(*curve.
taperobj);
681 taper_object.
runtime = &taper_runtime;
707 return geometry_set_eval->get_curves();
736 ID *temp_data =
static_cast<ID *
>(temp_object->
data);
740 if (temp_data != temp_object->
data) {
743 Curve *curve =
reinterpret_cast<Curve *
>(temp_data);
769 if (mesh_eval ==
nullptr) {
783 else if (ensure_subdivision) {
797 const bool preserve_origindex,
798 const bool ensure_subdivision)
808 Object object_for_eval = blender::dna::shallow_copy(*
object);
810 object_for_eval.
runtime = &runtime;
812 if (object_for_eval.
runtime->data_orig !=
nullptr) {
813 object_for_eval.
data = object_for_eval.
runtime->data_orig;
818 if (preserve_origindex) {
827 if (ensure_subdivision) {
831 if (
result != result_maybe_subdiv) {
834 if (
result->runtime->mesh_eval == result_maybe_subdiv) {
835 result->runtime->mesh_eval =
nullptr;
837 result = result_maybe_subdiv;
850 const bool preserve_all_data_layers,
851 const bool preserve_origindex,
852 const bool use_subdivision)
858 (preserve_all_data_layers || preserve_origindex))
861 depsgraph,
object, preserve_origindex, use_subdivision);
866 if (mesh_input->
runtime->edit_mesh !=
nullptr) {
868 mesh_input = editmesh_eval_final;
876 const bool preserve_all_data_layers,
877 const bool preserve_origindex,
878 const bool ensure_subdivision)
880 Mesh *new_mesh =
nullptr;
892 depsgraph,
object, preserve_all_data_layers, preserve_origindex, ensure_subdivision);
898 if (new_mesh ==
nullptr) {
915 new_mesh->
runtime->edit_mesh =
nullptr;
923 if (*id_p ==
nullptr) {
934 if (*id_p ==
nullptr) {
953 bool preserve_all_data_layers)
958 if (
mesh ==
nullptr) {
962 return mesh_in_bmain;
986 mesh_in_bmain->
mat =
mesh->mat;
993 mesh_in_bmain->attributes_for_write().remove_anonymous();
1004 return mesh_in_bmain;
1009 const auto &src_cache = src.
runtime->loose_verts_cache;
1010 if (src_cache.is_cached() && src_cache.data().count == 0) {
1011 dst.tag_loose_verts_none();
1017 const auto &src_cache = src.
runtime->loose_edges_cache;
1018 if (src_cache.is_cached() && src_cache.data().count == 0) {
1019 dst.tag_loose_edges_none();
1025 if (src.no_overlapping_topology()) {
1026 dst.tag_overlapping_none();
1042 const int active_kb_index =
object.shapenr - 1;
1045 CLOG_ERROR(&
LOG,
"Could not find object's active shapekey %d", active_kb_index);
1054 const int actshape_uid)
1067 if (kb->
uid == actshape_uid) {
1068 mesh.attributes().lookup<
float3>(
"position").varray.materialize(kb_coords);
1076 if (kb->totelem !=
mesh.verts_num) {
1078 kb->totelem =
mesh.verts_num;
1080 CLOG_ERROR(&
LOG,
"Data for shape key '%s' on mesh missing from evaluated mesh ", kb->name);
1113 std::swap(mesh_dst->
runtime->face_offsets_sharing_info,
1114 mesh_src->
runtime->face_offsets_sharing_info);
1125 if (process_shape_keys) {
1126 if (
Key *key_dst = mesh_dst->
key) {
1132 else if (verts_num_changed) {
1133 CLOG_WARN(&
LOG,
"Shape key data lost when replacing mesh '%s' in Main", mesh_src->
id.
name);
1135 mesh_dst->
key =
nullptr;
1154 const int totvert = mesh_src->
verts_num;
void BKE_curve_texspace_calc(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)
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)
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)
@ LIB_ID_COPY_SET_COPIED_ON_WRITE
@ LIB_ID_CREATE_NO_USER_REFCOUNT
void * BKE_id_new_nomain(short type, const char *name)
LibraryForeachIDCallbackFlag
void BKE_library_foreach_ID_link(Main *bmain, ID *id, blender::FunctionRef< LibraryIDLinkCallback > callback, void *user_data, LibraryForeachIDFlag flag)
General operations, lookup, etc. for materials.
void BKE_id_materials_copy(Main *bmain, ID *id_src, 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.
PointCloud * BKE_pointcloud_add(Main *bmain, const char *name)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE void copy_v3_v3(float r[3], const float a[3])
char * STRNCPY(char(&dst)[N], const char *src)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
bool DEG_is_original(const T *id)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
bool DEG_is_evaluated(const T *id)
T * DEG_get_original(T *id)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
#define CD_MASK_ORIGINDEX
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
static void copy_attributes(PointCloud *pointcloud, const ::PointCloud &b_pointcloud, const bool need_motion, const float motion_scale)
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
BPy_StructRNA * depsgraph
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
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef attribute_id, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef attribute_id, AttrDomain domain, AttrType data_type)
IndexRange index_range() const
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_dupallocN(const void *vmemh)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void BKE_mesh_to_pointcloud(Main *bmain, Depsgraph *depsgraph, Scene *, Object *ob)
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_mesh_object(Depsgraph *depsgraph, Object *object, const bool preserve_all_data_layers, const bool preserve_origindex, const bool use_subdivision)
static Mesh * mesh_new_from_mball_object(Object *object)
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)
static int foreach_libblock_make_original_callback(LibraryIDLinkCallbackData *cb_data)
Mesh * BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *dispbase)
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)
void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, bool process_shape_keys)
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)
Mesh * BKE_mesh_new_from_object(Depsgraph *depsgraph, Object *object, const bool preserve_all_data_layers, const bool preserve_origindex, const bool ensure_subdivision)
static void copy_loose_vert_hint(const Mesh &src, Mesh &dst)
static int foreach_libblock_make_usercounts_callback(LibraryIDLinkCallbackData *cb_data)
static const Curves * get_evaluated_curves_from_object(const Object *object)
static Mesh * mesh_new_from_mesh(Object *object, const Mesh *mesh, const bool ensure_subdivision)
static Mesh * mesh_new_from_curve_type_object(const Object *object)
static Mesh * mesh_new_from_mesh_object_with_layers(Depsgraph *depsgraph, Object *object, const bool preserve_origindex, const bool ensure_subdivision)
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, bool apply_subdiv=true)
void mesh_calc_edges(Mesh &mesh, bool keep_existing_edges, bool select_new_edges)
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)
VecBase< int32_t, 2 > int2
VecBase< float, 3 > float3
struct EditFont * editfont
float texspace_location[3]
LibraryForeachIDCallbackFlag cb_flag
MeshRuntimeHandle * runtime
char * default_color_attribute
ListBase vertex_group_names
int * face_offset_indices
char * active_color_attribute
ObjectRuntimeHandle * runtime
MutableVArraySpan< T > span