Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/object/object_add.c')
-rw-r--r--source/blender/editors/object/object_add.c254
1 files changed, 158 insertions, 96 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 4de48fba494..e15e64a5e45 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -41,6 +41,7 @@
#include "DNA_object_fluidsim_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
+#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_vfont_types.h"
@@ -284,7 +285,7 @@ float ED_object_new_primitive_matrix(
return dia;
}
- // return 1.0f;
+ /* return 1.0f; */
}
/** \} */
@@ -527,14 +528,17 @@ Object *ED_object_add_type_with_obdata(bContext *C,
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *ob;
- /* for as long scene has editmode... */
- if (CTX_data_edit_object(C)) {
- ED_object_editmode_exit(C, EM_FREEDATA);
+ /* For as long scene has editmode... */
+ {
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
+ if (obedit != NULL) {
+ ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA);
+ }
}
/* deselects all, sets active object */
+ Object *ob;
if (obdata != NULL) {
BLI_assert(type == BKE_object_obdata_to_type(obdata));
ob = BKE_object_add_for_data(bmain, view_layer, type, name, obdata, true);
@@ -591,18 +595,16 @@ Object *ED_object_add_type(bContext *C,
/* for object add operator */
static int object_add_exec(bContext *C, wmOperator *op)
{
- Object *ob;
- bool enter_editmode;
ushort local_view_bits;
+ bool enter_editmode;
float loc[3], rot[3], radius;
-
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
radius = RNA_float_get(op->ptr, "radius");
- ob = ED_object_add_type(
+ Object *ob = ED_object_add_type(
C, RNA_enum_get(op->ptr, "type"), NULL, loc, rot, enter_editmode, local_view_bits);
if (ob->type == OB_LATTICE) {
@@ -662,27 +664,22 @@ static const char *get_lightprobe_defname(int type)
static int lightprobe_add_exec(bContext *C, wmOperator *op)
{
- Object *ob;
- LightProbe *probe;
- int type;
bool enter_editmode;
ushort local_view_bits;
float loc[3], rot[3];
- float radius;
-
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
- type = RNA_enum_get(op->ptr, "type");
- radius = RNA_float_get(op->ptr, "radius");
+ int type = RNA_enum_get(op->ptr, "type");
+ float radius = RNA_float_get(op->ptr, "radius");
- ob = ED_object_add_type(
+ Object *ob = ED_object_add_type(
C, OB_LIGHTPROBE, get_lightprobe_defname(type), loc, rot, false, local_view_bits);
copy_v3_fl(ob->scale, radius);
- probe = (LightProbe *)ob->data;
+ LightProbe *probe = (LightProbe *)ob->data;
BKE_lightprobe_type_set(probe, type);
@@ -761,35 +758,35 @@ static const char *get_effector_defname(ePFieldType type)
static int effector_add_exec(bContext *C, wmOperator *op)
{
- Object *ob;
- int type;
bool enter_editmode;
ushort local_view_bits;
float loc[3], rot[3];
- float mat[4][4];
- float dia;
-
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
- type = RNA_enum_get(op->ptr, "type");
- dia = RNA_float_get(op->ptr, "radius");
+ int type = RNA_enum_get(op->ptr, "type");
+ float dia = RNA_float_get(op->ptr, "radius");
+ Object *ob;
if (type == PFIELD_GUIDE) {
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
Curve *cu;
ob = ED_object_add_type(
C, OB_CURVE, get_effector_defname(type), loc, rot, false, local_view_bits);
cu = ob->data;
cu->flag |= CU_PATH | CU_3D;
- ED_object_editmode_enter(C, 0);
+ ED_object_editmode_enter_ex(bmain, scene, ob, 0);
+
+ float mat[4][4];
ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
BLI_addtail(&cu->editnurb->nurbs,
ED_curve_add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, dia));
if (!enter_editmode) {
- ED_object_editmode_exit(C, EM_FREEDATA);
+ ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA);
}
}
else {
@@ -839,20 +836,18 @@ static int object_camera_add_exec(bContext *C, wmOperator *op)
{
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
- Object *ob;
- Camera *cam;
- bool enter_editmode;
- ushort local_view_bits;
- float loc[3], rot[3];
/* force view align for cameras */
RNA_enum_set(op->ptr, "align", ALIGN_VIEW);
+ ushort local_view_bits;
+ bool enter_editmode;
+ float loc[3], rot[3];
if (!ED_object_add_generic_get_opts(
C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
- ob = ED_object_add_type(C, OB_CAMERA, NULL, loc, rot, false, local_view_bits);
+ Object *ob = ED_object_add_type(C, OB_CAMERA, NULL, loc, rot, false, local_view_bits);
if (v3d) {
if (v3d->camera == NULL) {
@@ -863,7 +858,7 @@ static int object_camera_add_exec(bContext *C, wmOperator *op)
}
}
- cam = ob->data;
+ Camera *cam = ob->data;
cam->drawsize = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) : ED_scene_grid_scale(scene, NULL);
return OPERATOR_FINISHED;
@@ -900,19 +895,21 @@ void OBJECT_OT_camera_add(wmOperatorType *ot)
static int object_metaball_add_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- bool newob = false;
- bool enter_editmode;
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+
ushort local_view_bits;
+ bool enter_editmode;
float loc[3], rot[3];
- float mat[4][4];
- float dia;
-
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
+
+ bool newob = false;
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
if (obedit == NULL || obedit->type != OB_MBALL) {
obedit = ED_object_add_type(C, OB_MBALL, NULL, loc, rot, true, local_view_bits);
newob = true;
@@ -921,17 +918,18 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
+ float mat[4][4];
ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
/* Halving here is done to account for constant values from #BKE_mball_element_add.
* While the default radius of the resulting meta element is 2,
* we want to pass in 1 so other values such as resolution are scaled by 1.0. */
- dia = RNA_float_get(op->ptr, "radius") / 2;
+ float dia = RNA_float_get(op->ptr, "radius") / 2;
ED_mball_add_primitive(C, obedit, newob, mat, dia, RNA_enum_get(op->ptr, "type"));
/* userdef */
if (newob && !enter_editmode) {
- ED_object_editmode_exit(C, EM_FREEDATA);
+ ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA);
}
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
@@ -1017,7 +1015,11 @@ void OBJECT_OT_text_add(wmOperatorType *ot)
static int object_armature_add_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
+
RegionView3D *rv3d = CTX_wm_region_view3d(C);
bool newob = false;
bool enter_editmode;
@@ -1032,7 +1034,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
}
if ((obedit == NULL) || (obedit->type != OB_ARMATURE)) {
obedit = ED_object_add_type(C, OB_ARMATURE, NULL, loc, rot, true, local_view_bits);
- ED_object_editmode_enter(C, 0);
+ ED_object_editmode_enter_ex(bmain, scene, obedit, 0);
newob = true;
}
else {
@@ -1049,7 +1051,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
/* userdef */
if (newob && !enter_editmode) {
- ED_object_editmode_exit(C, EM_FREEDATA);
+ ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA);
}
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
@@ -1608,15 +1610,14 @@ void OBJECT_OT_data_instance_add(wmOperatorType *ot)
static int object_speaker_add_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- Object *ob;
- ushort local_view_bits;
- float loc[3], rot[3];
Scene *scene = CTX_data_scene(C);
+ ushort local_view_bits;
+ float loc[3], rot[3];
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
- ob = ED_object_add_type(C, OB_SPEAKER, NULL, loc, rot, false, local_view_bits);
+ Object *ob = ED_object_add_type(C, OB_SPEAKER, NULL, loc, rot, false, local_view_bits);
/* to make it easier to start using this immediately in NLA, a default sound clip is created
* ready to be moved around to retime the sound and/or make new sound clips
@@ -1677,10 +1678,10 @@ static int object_hair_add_exec(bContext *C, wmOperator *op)
{
ushort local_view_bits;
float loc[3], rot[3];
-
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
+
Object *object = ED_object_add_type(C, OB_HAIR, NULL, loc, rot, false, local_view_bits);
object->dtx |= OB_DRAWBOUNDOX; /* TODO: remove once there is actual drawing. */
@@ -1712,7 +1713,7 @@ void OBJECT_OT_hair_add(wmOperatorType *ot)
static bool object_pointcloud_add_poll(bContext *C)
{
- if (!U.experimental.use_new_particle_system) {
+ if (!U.experimental.use_new_point_cloud_type) {
return false;
}
return ED_operator_objectmode(C);
@@ -1722,10 +1723,10 @@ static int object_pointcloud_add_exec(bContext *C, wmOperator *op)
{
ushort local_view_bits;
float loc[3], rot[3];
-
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
+
Object *object = ED_object_add_type(C, OB_POINTCLOUD, NULL, loc, rot, false, local_view_bits);
object->dtx |= OB_DRAWBOUNDOX; /* TODO: remove once there is actual drawing. */
@@ -1778,7 +1779,6 @@ static int object_delete_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win;
const bool use_global = RNA_boolean_get(op->ptr, "use_global");
uint changed_count = 0;
@@ -1871,7 +1871,7 @@ static int object_delete_exec(bContext *C, wmOperator *op)
/* delete has to handle all open scenes */
BKE_main_id_tag_listbase(&bmain->scenes, LIB_TAG_DOIT, true);
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
scene = WM_window_get_active_scene(win);
if (scene->id.tag & LIB_TAG_DOIT) {
@@ -2063,18 +2063,16 @@ static void make_object_duplilist_real(bContext *C,
{
Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- ListBase *lb_duplis;
- DupliObject *dob;
- GHash *dupli_gh, *parent_gh = NULL, *instancer_gh = NULL;
+ GHash *parent_gh = NULL, *instancer_gh = NULL;
if (!(base->object->transflag & OB_DUPLI)) {
return;
}
Object *object_eval = DEG_get_evaluated_object(depsgraph, base->object);
- lb_duplis = object_duplilist(depsgraph, scene, object_eval);
+ ListBase *lb_duplis = object_duplilist(depsgraph, scene, object_eval);
- dupli_gh = BLI_ghash_ptr_new(__func__);
+ GHash *dupli_gh = BLI_ghash_ptr_new(__func__);
if (use_hierarchy) {
parent_gh = BLI_ghash_new(dupliobject_hash, dupliobject_cmp, __func__);
@@ -2084,10 +2082,10 @@ static void make_object_duplilist_real(bContext *C,
}
}
- for (dob = lb_duplis->first; dob; dob = dob->next) {
+ LISTBASE_FOREACH (DupliObject *, dob, lb_duplis) {
Object *ob_src = DEG_get_original_object(dob->ob);
- Object *ob_dst = ID_NEW_SET(ob_src, BKE_object_copy(bmain, ob_src));
- Base *base_dst;
+ Object *ob_dst = ID_NEW_SET(ob_src, BKE_id_copy(bmain, &ob_src->id));
+ id_us_min(&ob_dst->id);
/* font duplis can have a totcol without material, we get them from parent
* should be implemented better...
@@ -2097,7 +2095,7 @@ static void make_object_duplilist_real(bContext *C,
}
BKE_collection_object_add_from(bmain, scene, base->object, ob_dst);
- base_dst = BKE_view_layer_base_find(view_layer, ob_dst);
+ Base *base_dst = BKE_view_layer_base_find(view_layer, ob_dst);
BLI_assert(base_dst != NULL);
ED_object_base_select(base_dst, BA_SELECT);
@@ -2146,7 +2144,7 @@ static void make_object_duplilist_real(bContext *C,
}
}
- for (dob = lb_duplis->first; dob; dob = dob->next) {
+ LISTBASE_FOREACH (DupliObject *, dob, lb_duplis) {
Object *ob_src = dob->ob;
Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob);
@@ -2228,7 +2226,7 @@ static void make_object_duplilist_real(bContext *C,
}
if (base->object->transflag & OB_DUPLICOLLECTION && base->object->instance_collection) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
if (ob->proxy_group == base->object) {
ob->proxy = NULL;
ob->proxy_from = NULL;
@@ -2315,9 +2313,28 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot)
* \{ */
static const EnumPropertyItem convert_target_items[] = {
- {OB_CURVE, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve from Mesh/Text", ""},
- {OB_MESH, "MESH", ICON_OUTLINER_OB_MESH, "Mesh from Curve/Meta/Surf/Text", ""},
- {OB_GPENCIL, "GPENCIL", ICON_OUTLINER_OB_GREASEPENCIL, "Grease Pencil from Curve/Mesh", ""},
+ {OB_CURVE, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve", "Curve from Mesh or Text objects"},
+ {OB_MESH,
+ "MESH",
+ ICON_OUTLINER_OB_MESH,
+ "Mesh",
+#ifdef WITH_POINT_CLOUD
+ "Mesh from Curve, Surface, Metaball, Text, or Pointcloud objects"},
+#else
+ "Mesh from Curve, Surface, Metaball, or Text objects"},
+#endif
+ {OB_GPENCIL,
+ "GPENCIL",
+ ICON_OUTLINER_OB_GREASEPENCIL,
+ "Grease Pencil",
+ "Grease Pencil from Curve or Mesh objects"},
+#ifdef WITH_POINT_CLOUD
+ {OB_POINTCLOUD,
+ "POINTCLOUD",
+ ICON_OUTLINER_OB_POINTCLOUD,
+ "Pointcloud",
+ "Pointcloud from Mesh objects"},
+#endif
{0, NULL, 0, NULL, NULL},
};
@@ -2331,7 +2348,7 @@ static void object_data_convert_ensure_curve_cache(Depsgraph *depsgraph, Scene *
*/
if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
/* We need 'for render' ON here, to enable computing bevel dipslist if needed.
- * Also makes sense anyway, we would not want e.g. to loose hidden parts etc. */
+ * Also makes sense anyway, we would not want e.g. to lose hidden parts etc. */
BKE_displist_make_curveTypes(depsgraph, scene, ob, true, false);
}
else if (ob->type == OB_MBALL) {
@@ -2392,18 +2409,16 @@ static bool object_convert_poll(bContext *C)
static Base *duplibase_for_convert(
Main *bmain, Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, Base *base, Object *ob)
{
- Object *obn;
- Base *basen;
-
if (ob == NULL) {
ob = base->object;
}
- obn = BKE_object_copy(bmain, ob);
+ Object *obn = (Object *)BKE_id_copy(bmain, &ob->id);
+ id_us_min(&obn->id);
DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
BKE_collection_object_add_from(bmain, scene, ob, obn);
- basen = BKE_view_layer_base_find(view_layer, obn);
+ Base *basen = BKE_view_layer_base_find(view_layer, obn);
ED_object_base_select(basen, BA_SELECT);
ED_object_base_select(base, BA_DESELECT);
@@ -2450,11 +2465,6 @@ static int object_convert_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
Base *basen = NULL, *basact = NULL;
Object *ob1, *obact = CTX_data_active_object(C);
- Curve *cu;
- Nurb *nu;
- MetaBall *mb;
- Mesh *me;
- Object *ob_gpencil = NULL;
const short target = RNA_enum_get(op->ptr, "target");
bool keep_original = RNA_boolean_get(op->ptr, "keep_original");
@@ -2540,7 +2550,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
/* obdata already modified */
if (!IS_TAGGED(ob->data)) {
/* When 2 objects with linked data are selected, converting both
- * would keep modifiers on all but the converted object [#26003] */
+ * would keep modifiers on all but the converted object T26003. */
if (ob->type == OB_MESH) {
BKE_object_free_modifiers(ob, 0); /* after derivedmesh calls! */
}
@@ -2558,11 +2568,11 @@ static int object_convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
/* decrement original mesh's usage count */
- me = newob->data;
+ Mesh *me = newob->data;
id_us_min(&me->id);
/* make a new copy of the mesh */
- newob->data = BKE_mesh_copy(bmain, me);
+ newob->data = BKE_id_copy(bmain, &me->id);
}
else {
newob = ob;
@@ -2587,7 +2597,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
mat4_to_loc_rot_size(loc, rot, size, ob->obmat);
mat3_to_eul(eul, rot);
- ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits);
+ Object *ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits);
copy_v3_v3(ob_gpencil->loc, loc);
copy_v3_v3(ob_gpencil->rot, eul);
copy_v3_v3(ob_gpencil->scale, size);
@@ -2624,6 +2634,31 @@ static int object_convert_exec(bContext *C, wmOperator *op)
}
ob_gpencil->actcol = actcol;
}
+ else if (ob->type == OB_MESH && target == OB_POINTCLOUD) {
+ ob->flag |= OB_DONE;
+
+ if (keep_original) {
+ basen = duplibase_for_convert(bmain, depsgraph, scene, view_layer, base, NULL);
+ newob = basen->object;
+
+ /* decrement original mesh's usage count */
+ Mesh *me = newob->data;
+ id_us_min(&me->id);
+
+ /* make a new copy of the mesh */
+ newob->data = BKE_id_copy(bmain, &me->id);
+ }
+ else {
+ newob = ob;
+ }
+
+ BKE_mesh_to_pointcloud(bmain, depsgraph, scene, newob);
+
+ if (newob->type == OB_POINTCLOUD) {
+ BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */
+ ED_rigidbody_object_remove(bmain, scene, newob);
+ }
+ }
else if (ob->type == OB_MESH) {
ob->flag |= OB_DONE;
@@ -2632,11 +2667,11 @@ static int object_convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
/* decrement original mesh's usage count */
- me = newob->data;
+ Mesh *me = newob->data;
id_us_min(&me->id);
/* make a new copy of the mesh */
- newob->data = BKE_mesh_copy(bmain, me);
+ newob->data = BKE_id_copy(bmain, &me->id);
}
else {
newob = ob;
@@ -2651,6 +2686,8 @@ static int object_convert_exec(bContext *C, wmOperator *op)
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_MESH);
me_eval = BKE_mesh_copy_for_eval(me_eval, false);
+ /* Full (edge-angle based) draw calculation should ideally be performed. */
+ BKE_mesh_edges_set_draw_render(me_eval);
BKE_mesh_nomain_to_mesh(me_eval, newob->data, newob, &CD_MASK_MESH, true);
BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */
}
@@ -2665,13 +2702,13 @@ static int object_convert_exec(bContext *C, wmOperator *op)
id_us_min(&((Curve *)newob->data)->id);
/* make a new copy of the curve */
- newob->data = BKE_curve_copy(bmain, ob->data);
+ newob->data = BKE_id_copy(bmain, ob->data);
}
else {
newob = ob;
}
- cu = newob->data;
+ Curve *cu = newob->data;
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
BKE_vfont_to_curve_ex(ob_eval, ob_eval->data, FO_EDIT, &cu->nurb, NULL, NULL, NULL, NULL);
@@ -2709,7 +2746,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
}
}
- for (nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
nu->charidx = 0;
}
@@ -2736,7 +2773,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
id_us_min(&((Curve *)newob->data)->id);
/* make a new copy of the curve */
- newob->data = BKE_curve_copy(bmain, ob->data);
+ newob->data = BKE_id_copy(bmain, ob->data);
}
else {
newob = ob;
@@ -2758,7 +2795,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
* Nurbs Surface are not supported.
*/
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
- ob_gpencil = ED_gpencil_add_object(C, ob->loc, local_view_bits);
+ Object *ob_gpencil = ED_gpencil_add_object(C, ob->loc, local_view_bits);
copy_v3_v3(ob_gpencil->rot, ob->rot);
copy_v3_v3(ob_gpencil->scale, ob->scale);
BKE_gpencil_convert_curve(bmain, scene, ob_gpencil, ob, false, 1.0f, 0.0f);
@@ -2783,13 +2820,13 @@ static int object_convert_exec(bContext *C, wmOperator *op)
basen = duplibase_for_convert(bmain, depsgraph, scene, view_layer, base, baseob);
newob = basen->object;
- mb = newob->data;
+ MetaBall *mb = newob->data;
id_us_min(&mb->id);
newob->data = BKE_mesh_add(bmain, "Mesh");
newob->type = OB_MESH;
- me = newob->data;
+ Mesh *me = newob->data;
me->totcol = mb->totcol;
if (newob->totcol) {
me->mat = MEM_dupallocN(mb->mat);
@@ -2809,6 +2846,31 @@ static int object_convert_exec(bContext *C, wmOperator *op)
mballConverted = 1;
}
}
+ else if (ob->type == OB_POINTCLOUD && target == OB_MESH) {
+ ob->flag |= OB_DONE;
+
+ if (keep_original) {
+ basen = duplibase_for_convert(bmain, depsgraph, scene, view_layer, base, NULL);
+ newob = basen->object;
+
+ /* decrement original pointclouds's usage count */
+ PointCloud *pointcloud = newob->data;
+ id_us_min(&pointcloud->id);
+
+ /* make a new copy of the pointcloud */
+ newob->data = BKE_id_copy(bmain, &pointcloud->id);
+ }
+ else {
+ newob = ob;
+ }
+
+ BKE_pointcloud_to_mesh(bmain, depsgraph, scene, newob);
+
+ if (newob->type == OB_MESH) {
+ BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */
+ ED_rigidbody_object_remove(bmain, scene, newob);
+ }
+ }
else {
continue;
}
@@ -2870,7 +2932,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
/* Remove curves and meshes converted to Grease Pencil object. */
if (gpencilConverted) {
FOREACH_SCENE_OBJECT_BEGIN (scene, ob_delete) {
- if ((ob_delete->type == OB_CURVE) || (ob_delete->type == OB_MESH)) {
+ if (ELEM(ob_delete->type, OB_CURVE, OB_MESH)) {
if (ob_delete->flag & OB_DONE) {
ED_object_base_free_and_unlink(bmain, scene, ob_delete);
}
@@ -2927,7 +2989,7 @@ void OBJECT_OT_convert(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name = "Convert to";
+ ot->name = "Convert To";
ot->description = "Convert selected objects to another type";
ot->idname = "OBJECT_OT_convert";
@@ -3025,7 +3087,7 @@ static Base *object_add_duplicate_internal(Main *bmain,
/* 1) duplis should end up in same collection as the original
* 2) Rigid Body sim participants MUST always be part of a collection...
*/
- // XXX: is 2) really a good measure here?
+ /* XXX: is 2) really a good measure here? */
if (ob->rigidbody_object || ob->rigidbody_constraint) {
Collection *collection;
for (collection = bmain->collections.first; collection; collection = collection->id.next) {
@@ -3057,7 +3119,7 @@ Base *ED_object_add_duplicate(
ob = basen->object;
- /* link own references to the newly duplicated data [#26816] */
+ /* link own references to the newly duplicated data T26816. */
BKE_libblock_relink_to_newid(&ob->id);
/* DAG_relations_tag_update(bmain); */ /* caller must do */