Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_add.c
| Show First 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | else { | ||||
| zero_v3(rot); | zero_v3(rot); | ||||
| } | } | ||||
| } | } | ||||
| void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3], const float rot[3]) | void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3], const float rot[3]) | ||||
| { | { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| if (!scene) { | if (!scene) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (loc) { | if (loc) { | ||||
| copy_v3_v3(ob->loc, loc); | copy_v3_v3(ob->loc, loc); | ||||
| } | } | ||||
| if (rot) { | if (rot) { | ||||
| copy_v3_v3(ob->rot, rot); | copy_v3_v3(ob->rot, rot); | ||||
| } | } | ||||
| BKE_object_where_is_calc(depsgraph, scene, ob); | Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); | ||||
| Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); | |||||
| BKE_object_transform_copy(object_eval, ob); | |||||
| BKE_object_where_is_calc(depsgraph, scene_eval, object_eval); | |||||
| BKE_object_transform_copy(ob, object_eval); | |||||
| } | } | ||||
| /* Uses context to figure out transform for primitive. | /* Uses context to figure out transform for primitive. | ||||
| * Returns standard diameter. */ | * Returns standard diameter. */ | ||||
| float ED_object_new_primitive_matrix( | float ED_object_new_primitive_matrix( | ||||
| bContext *C, Object *obedit, const float loc[3], const float rot[3], float primmat[4][4]) | bContext *C, Object *obedit, const float loc[3], const float rot[3], float primmat[4][4]) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ▲ Show 20 Lines • Show All 1,491 Lines • ▼ Show 20 Lines | else if (a->persistent_id[i] == INT_MAX) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* matching */ | /* matching */ | ||||
| return false; | return false; | ||||
| } | } | ||||
| static void make_object_duplilist_real( | static void make_object_duplilist_real(bContext *C, | ||||
| bContext *C, Scene *scene, Base *base, const bool use_base_parent, const bool use_hierarchy) | Depsgraph *depsgraph, | ||||
| Scene *scene, | |||||
| Base *base, | |||||
| const bool use_base_parent, | |||||
| const bool use_hierarchy) | |||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | |||||
| ListBase *lb_duplis; | ListBase *lb_duplis; | ||||
| DupliObject *dob; | DupliObject *dob; | ||||
| GHash *dupli_gh, *parent_gh = NULL, *instancer_gh = NULL; | GHash *dupli_gh, *parent_gh = NULL, *instancer_gh = NULL; | ||||
| if (!(base->object->transflag & OB_DUPLI)) { | if (!(base->object->transflag & OB_DUPLI)) { | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | static void make_object_duplilist_real(bContext *C, | ||||
| base->object->transflag &= ~OB_DUPLI; | base->object->transflag &= ~OB_DUPLI; | ||||
| DEG_id_tag_update(&base->object->id, ID_RECALC_COPY_ON_WRITE); | DEG_id_tag_update(&base->object->id, ID_RECALC_COPY_ON_WRITE); | ||||
| } | } | ||||
| static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) | static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | |||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| const bool use_base_parent = RNA_boolean_get(op->ptr, "use_base_parent"); | const bool use_base_parent = RNA_boolean_get(op->ptr, "use_base_parent"); | ||||
| const bool use_hierarchy = RNA_boolean_get(op->ptr, "use_hierarchy"); | const bool use_hierarchy = RNA_boolean_get(op->ptr, "use_hierarchy"); | ||||
| BKE_main_id_clear_newpoins(bmain); | BKE_main_id_clear_newpoins(bmain); | ||||
| CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { | CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { | ||||
| make_object_duplilist_real(C, scene, base, use_base_parent, use_hierarchy); | make_object_duplilist_real(C, depsgraph, scene, base, use_base_parent, use_hierarchy); | ||||
| /* dependencies were changed */ | /* dependencies were changed */ | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, base->object); | WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, base->object); | ||||
| } | } | ||||
| CTX_DATA_END; | CTX_DATA_END; | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| WM_event_add_notifier(C, NC_SCENE, scene); | WM_event_add_notifier(C, NC_SCENE, scene); | ||||
| Show All 10 Lines | void OBJECT_OT_duplicates_make_real(wmOperatorType *ot) | ||||
| ot->idname = "OBJECT_OT_duplicates_make_real"; | ot->idname = "OBJECT_OT_duplicates_make_real"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = object_duplicates_make_real_exec; | ot->exec = object_duplicates_make_real_exec; | ||||
| ot->poll = ED_operator_objectmode; | ot->poll = ED_operator_objectmode; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| RNA_def_boolean(ot->srna, | RNA_def_boolean(ot->srna, | ||||
| "use_base_parent", | "use_base_parent", | ||||
| 0, | 0, | ||||
| "Parent", | "Parent", | ||||
| "Parent newly created objects to the original duplicator"); | "Parent newly created objects to the original duplicator"); | ||||
| RNA_def_boolean( | RNA_def_boolean( | ||||
| ot->srna, "use_hierarchy", 0, "Keep Hierarchy", "Maintain parent child relationships"); | ot->srna, "use_hierarchy", 0, "Keep Hierarchy", "Maintain parent child relationships"); | ||||
| ▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | static Base *duplibase_for_convert( | ||||
| } | } | ||||
| return basen; | return basen; | ||||
| } | } | ||||
| static int convert_exec(bContext *C, wmOperator *op) | static int convert_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Base *basen = NULL, *basact = NULL; | Base *basen = NULL, *basact = NULL; | ||||
| Object *ob1, *obact = CTX_data_active_object(C); | Object *ob1, *obact = CTX_data_active_object(C); | ||||
| Curve *cu; | Curve *cu; | ||||
| Nurb *nu; | Nurb *nu; | ||||
| MetaBall *mb; | MetaBall *mb; | ||||
| Mesh *me; | Mesh *me; | ||||
| ▲ Show 20 Lines • Show All 765 Lines • Show Last 20 Lines | |||||