Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_add.c
| Show First 20 Lines • Show All 1,964 Lines • ▼ Show 20 Lines | if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) { | ||||
| BKE_displist_make_curveTypes(depsgraph, scene, ob, true, false); | BKE_displist_make_curveTypes(depsgraph, scene, ob, true, false); | ||||
| } | } | ||||
| else if (ob->type == OB_MBALL) { | else if (ob->type == OB_MBALL) { | ||||
| BKE_displist_make_mball(depsgraph, scene, ob); | BKE_displist_make_mball(depsgraph, scene, ob); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void curvetomesh(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob) | static void curvetomesh(Main *bmain, Depsgraph *depsgraph, Object *ob) | ||||
| { | { | ||||
| convert_ensure_curve_cache(depsgraph, scene, ob); | Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); | ||||
| BKE_mesh_from_nurbs(bmain, ob); /* also does users */ | Curve *curve = ob->data; | ||||
| Mesh *mesh = BKE_mesh_new_from_object_to_bmain(bmain, depsgraph, object_eval, true); | |||||
| if (ob->type == OB_MESH) { | |||||
| BKE_object_free_modifiers(ob, 0); | BKE_object_free_modifiers(ob, 0); | ||||
brecht: Why is it no freeing modifiers anymore? I can see how it's weak though if you have multiple… | |||||
Done Inline ActionsThat is a very great question. sergey: That is a very great question. | |||||
| /* Replace curve used by the object itself. */ | |||||
| ob->data = mesh; | |||||
| ob->type = OB_MESH; | |||||
| id_us_min(&curve->id); | |||||
| id_us_plus(&mesh->id); | |||||
| /* Change objects which are using same curve. | |||||
| * A bit annoying, but: | |||||
| * - It's possible to have multiple curve objects selected which are sharing the same curve | |||||
| * datablock. We don't want mesh to be created for every of those objects. | |||||
| * - This is how conversion worked for a long long time. */ | |||||
| LISTBASE_FOREACH (Object *, other_object, &bmain->objects) { | |||||
| if (other_object->data == curve) { | |||||
| other_object->type = OB_MESH; | |||||
| id_us_min((ID *)other_object->data); | |||||
| other_object->data = ob->data; | |||||
| id_us_plus((ID *)other_object->data); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| static bool convert_poll(bContext *C) | static bool convert_poll(bContext *C) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Base *base_act = CTX_data_active_base(C); | Base *base_act = CTX_data_active_base(C); | ||||
| Object *obact = base_act ? base_act->object : NULL; | Object *obact = base_act ? base_act->object : NULL; | ||||
| ▲ Show 20 Lines • Show All 240 Lines • ▼ Show 20 Lines | else if (ob->type == OB_FONT) { | ||||
| for (nu = cu->nurb.first; nu; nu = nu->next) { | for (nu = cu->nurb.first; nu; nu = nu->next) { | ||||
| nu->charidx = 0; | nu->charidx = 0; | ||||
| } | } | ||||
| cu->flag &= ~CU_3D; | cu->flag &= ~CU_3D; | ||||
| BKE_curve_curve_dimension_update(cu); | BKE_curve_curve_dimension_update(cu); | ||||
| if (target == OB_MESH) { | if (target == OB_MESH) { | ||||
| curvetomesh(bmain, depsgraph, scene, newob); | curvetomesh(bmain, depsgraph, newob); | ||||
| /* meshes doesn't use displist */ | /* meshes doesn't use displist */ | ||||
| BKE_object_free_curve_cache(newob); | BKE_object_free_curve_cache(newob); | ||||
| } | } | ||||
| } | } | ||||
| else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { | else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { | ||||
| ob->flag |= OB_DONE; | ob->flag |= OB_DONE; | ||||
| if (target == OB_MESH) { | if (target == OB_MESH) { | ||||
| if (keep_original) { | if (keep_original) { | ||||
| basen = duplibase_for_convert(bmain, scene, view_layer, base, NULL); | basen = duplibase_for_convert(bmain, scene, view_layer, base, NULL); | ||||
| newob = basen->object; | newob = basen->object; | ||||
| /* decrement original curve's usage count */ | /* decrement original curve's usage count */ | ||||
| id_us_min(&((Curve *)newob->data)->id); | id_us_min(&((Curve *)newob->data)->id); | ||||
| /* make a new copy of the curve */ | /* make a new copy of the curve */ | ||||
| newob->data = BKE_curve_copy(bmain, ob->data); | newob->data = BKE_curve_copy(bmain, ob->data); | ||||
| } | } | ||||
| else { | else { | ||||
| newob = ob; | newob = ob; | ||||
| } | } | ||||
| curvetomesh(bmain, depsgraph, scene, newob); | curvetomesh(bmain, depsgraph, newob); | ||||
| /* meshes doesn't use displist */ | /* meshes doesn't use displist */ | ||||
| BKE_object_free_curve_cache(newob); | BKE_object_free_curve_cache(newob); | ||||
| } | } | ||||
| } | } | ||||
| else if (ob->type == OB_MBALL && target == OB_MESH) { | else if (ob->type == OB_MBALL && target == OB_MESH) { | ||||
| Object *baseob; | Object *baseob; | ||||
| ▲ Show 20 Lines • Show All 510 Lines • Show Last 20 Lines | |||||
Why is it no freeing modifiers anymore? I can see how it's weak though if you have multiple objects using the same data.