Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_add.c
| Show First 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | |||||
| Object *ED_object_add_type( | Object *ED_object_add_type( | ||||
| bContext *C, | bContext *C, | ||||
| int type, const char *name, | int type, const char *name, | ||||
| const float loc[3], const float rot[3], | const float loc[3], const float rot[3], | ||||
| bool enter_editmode, unsigned int UNUSED(layer)) | bool enter_editmode, unsigned int UNUSED(layer)) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| Object *ob; | Object *ob; | ||||
| /* for as long scene has editmode... */ | /* for as long scene has editmode... */ | ||||
| if (CTX_data_edit_object(C)) | if (CTX_data_edit_object(C)) | ||||
| ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */ | ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */ | ||||
| /* deselects all, sets scene->basact */ | /* deselects all, sets scene->basact */ | ||||
| ob = BKE_object_add(bmain, scene, sl, type, name); | ob = BKE_object_add(bmain, scene, sl, type, name); | ||||
| ▲ Show 20 Lines • Show All 981 Lines • ▼ Show 20 Lines | static bool dupliobject_cmp(const void *a_, const void *b_) | ||||
| return false; | return false; | ||||
| } | } | ||||
| static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, | static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, | ||||
| const bool use_base_parent, | const bool use_base_parent, | ||||
| const bool use_hierarchy) | const bool use_hierarchy) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| ListBase *lb_duplis; | ListBase *lb_duplis; | ||||
| DupliObject *dob; | DupliObject *dob; | ||||
| GHash *dupli_gh, *parent_gh = NULL; | GHash *dupli_gh, *parent_gh = NULL; | ||||
| if (!(base->object->transflag & OB_DUPLI)) { | if (!(base->object->transflag & OB_DUPLI)) { | ||||
| return; | return; | ||||
| } | } | ||||
| Show All 17 Lines | for (dob = lb_duplis->first; dob; dob = dob->next) { | ||||
| /* font duplis can have a totcol without material, we get them from parent | /* font duplis can have a totcol without material, we get them from parent | ||||
| * should be implemented better... | * should be implemented better... | ||||
| */ | */ | ||||
| if (ob_dst->mat == NULL) { | if (ob_dst->mat == NULL) { | ||||
| ob_dst->totcol = 0; | ob_dst->totcol = 0; | ||||
| } | } | ||||
| BKE_collection_object_add_from(scene, base->object, ob_dst); | BKE_collection_object_add_from(scene, base->object, ob_dst); | ||||
| base_dst = BKE_scene_layer_base_find(sl, ob_dst); | base_dst = BKE_view_layer_base_find(sl, ob_dst); | ||||
| BLI_assert(base_dst != NULL); | BLI_assert(base_dst != NULL); | ||||
| BKE_scene_object_base_flag_sync_from_base(base_dst); | BKE_scene_object_base_flag_sync_from_base(base_dst); | ||||
| /* make sure apply works */ | /* make sure apply works */ | ||||
| BKE_animdata_free(&ob_dst->id, true); | BKE_animdata_free(&ob_dst->id, true); | ||||
| ob_dst->adt = NULL; | ob_dst->adt = NULL; | ||||
| ▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | static int convert_poll(bContext *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; | ||||
| return (!ID_IS_LINKED(scene) && obact && scene->obedit != obact && | return (!ID_IS_LINKED(scene) && obact && scene->obedit != obact && | ||||
| (base_act->flag & BASE_SELECTED) && !ID_IS_LINKED(obact)); | (base_act->flag & BASE_SELECTED) && !ID_IS_LINKED(obact)); | ||||
| } | } | ||||
| /* Helper for convert_exec */ | /* Helper for convert_exec */ | ||||
| static Base *duplibase_for_convert(Main *bmain, Scene *scene, SceneLayer *sl, Base *base, Object *ob) | static Base *duplibase_for_convert(Main *bmain, Scene *scene, ViewLayer *sl, Base *base, Object *ob) | ||||
| { | { | ||||
| Object *obn; | Object *obn; | ||||
| Base *basen; | Base *basen; | ||||
| if (ob == NULL) { | if (ob == NULL) { | ||||
| ob = base->object; | ob = base->object; | ||||
| } | } | ||||
| obn = BKE_object_copy(bmain, ob); | obn = BKE_object_copy(bmain, ob); | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); | DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); | ||||
| BKE_collection_object_add_from(scene, ob, obn); | BKE_collection_object_add_from(scene, ob, obn); | ||||
| basen = BKE_scene_layer_base_find(sl, obn); | basen = BKE_view_layer_base_find(sl, obn); | ||||
| ED_object_base_select(basen, BA_SELECT); | ED_object_base_select(basen, BA_SELECT); | ||||
| ED_object_base_select(basen, BA_DESELECT); | ED_object_base_select(basen, BA_DESELECT); | ||||
| 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); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| EvaluationContext eval_ctx; | EvaluationContext eval_ctx; | ||||
| Base *basen = NULL, *basact = NULL; | Base *basen = NULL, *basact = NULL; | ||||
| Object *ob1, *newob, *obact = CTX_data_active_object(C); | Object *ob1, *newob, *obact = CTX_data_active_object(C); | ||||
| DerivedMesh *dm; | DerivedMesh *dm; | ||||
| Curve *cu; | Curve *cu; | ||||
| Nurb *nu; | Nurb *nu; | ||||
| MetaBall *mb; | MetaBall *mb; | ||||
| Mesh *me; | Mesh *me; | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) { | ||||
| keep_original = true; | keep_original = true; | ||||
| BKE_reportf(op->reports, RPT_INFO, | BKE_reportf(op->reports, RPT_INFO, | ||||
| "Converting some linked object/object data, enforcing 'Keep Original' option to True"); | "Converting some linked object/object data, enforcing 'Keep Original' option to True"); | ||||
| } | } | ||||
| DEG_id_tag_update(&base->object->id, OB_RECALC_DATA); | DEG_id_tag_update(&base->object->id, OB_RECALC_DATA); | ||||
| } | } | ||||
| Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, sl, true); | Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true); | ||||
| uint64_t customdata_mask_prev = scene->customdata_mask; | uint64_t customdata_mask_prev = scene->customdata_mask; | ||||
| scene->customdata_mask |= CD_MASK_MESH; | scene->customdata_mask |= CD_MASK_MESH; | ||||
| BKE_scene_graph_update_tagged(bmain->eval_ctx, depsgraph, bmain, scene, sl); | BKE_scene_graph_update_tagged(bmain->eval_ctx, depsgraph, bmain, scene, view_layer); | ||||
| scene->customdata_mask = customdata_mask_prev; | scene->customdata_mask = customdata_mask_prev; | ||||
| } | } | ||||
| for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) { | for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) { | ||||
| Base *base = link->ptr.data; | Base *base = link->ptr.data; | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| if (ob->flag & OB_DONE || !IS_TAGGED(ob->data)) { | if (ob->flag & OB_DONE || !IS_TAGGED(ob->data)) { | ||||
| Show All 10 Lines | if (ob->flag & OB_DONE || !IS_TAGGED(ob->data)) { | ||||
| BKE_object_free_modifiers(ob); /* after derivedmesh calls! */ | BKE_object_free_modifiers(ob); /* after derivedmesh calls! */ | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (ob->type == OB_MESH && target == OB_CURVE) { | else if (ob->type == OB_MESH && target == OB_CURVE) { | ||||
| ob->flag |= OB_DONE; | ob->flag |= OB_DONE; | ||||
| if (keep_original) { | if (keep_original) { | ||||
| basen = duplibase_for_convert(bmain, scene, sl, base, NULL); | basen = duplibase_for_convert(bmain, scene, view_layer, base, NULL); | ||||
| newob = basen->object; | newob = basen->object; | ||||
| /* decrement original mesh's usage count */ | /* decrement original mesh's usage count */ | ||||
| me = newob->data; | me = newob->data; | ||||
| id_us_min(&me->id); | id_us_min(&me->id); | ||||
| /* make a new copy of the mesh */ | /* make a new copy of the mesh */ | ||||
| newob->data = BKE_mesh_copy(bmain, me); | newob->data = BKE_mesh_copy(bmain, me); | ||||
| } | } | ||||
| else { | else { | ||||
| newob = ob; | newob = ob; | ||||
| } | } | ||||
| BKE_mesh_to_curve(&eval_ctx, scene, newob); | BKE_mesh_to_curve(&eval_ctx, scene, newob); | ||||
| if (newob->type == OB_CURVE) { | if (newob->type == OB_CURVE) { | ||||
| BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ | BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ | ||||
| ED_rigidbody_object_remove(bmain, scene, newob); | ED_rigidbody_object_remove(bmain, scene, newob); | ||||
| } | } | ||||
| } | } | ||||
| else if (ob->type == OB_MESH) { | else if (ob->type == OB_MESH) { | ||||
| ob->flag |= OB_DONE; | ob->flag |= OB_DONE; | ||||
| if (keep_original) { | if (keep_original) { | ||||
| basen = duplibase_for_convert(bmain, scene, sl, base, NULL); | basen = duplibase_for_convert(bmain, scene, view_layer, base, NULL); | ||||
| newob = basen->object; | newob = basen->object; | ||||
| /* decrement original mesh's usage count */ | /* decrement original mesh's usage count */ | ||||
| me = newob->data; | me = newob->data; | ||||
| id_us_min(&me->id); | id_us_min(&me->id); | ||||
| /* make a new copy of the mesh */ | /* make a new copy of the mesh */ | ||||
| newob->data = BKE_mesh_copy(bmain, me); | newob->data = BKE_mesh_copy(bmain, me); | ||||
| Show All 14 Lines | else if (ob->type == OB_MESH) { | ||||
| /* re-tessellation is called by DM_to_mesh */ | /* re-tessellation is called by DM_to_mesh */ | ||||
| BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ | BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ | ||||
| } | } | ||||
| else if (ob->type == OB_FONT) { | else if (ob->type == OB_FONT) { | ||||
| ob->flag |= OB_DONE; | ob->flag |= OB_DONE; | ||||
| if (keep_original) { | if (keep_original) { | ||||
| basen = duplibase_for_convert(bmain, scene, sl, 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); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | else if (ob->type == OB_FONT) { | ||||
| 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, sl, 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); | ||||
| } | } | ||||
| Show All 18 Lines | else if (ob->type == OB_MBALL && target == OB_MESH) { | ||||
| if (ob != baseob) { | if (ob != baseob) { | ||||
| /* if motherball is converting it would be marked as done later */ | /* if motherball is converting it would be marked as done later */ | ||||
| ob->flag |= OB_DONE; | ob->flag |= OB_DONE; | ||||
| } | } | ||||
| if (!(baseob->flag & OB_DONE)) { | if (!(baseob->flag & OB_DONE)) { | ||||
| baseob->flag |= OB_DONE; | baseob->flag |= OB_DONE; | ||||
| basen = duplibase_for_convert(bmain, scene, sl, base, baseob); | basen = duplibase_for_convert(bmain, scene, view_layer, base, baseob); | ||||
| newob = basen->object; | newob = basen->object; | ||||
| mb = newob->data; | mb = newob->data; | ||||
| id_us_min(&mb->id); | id_us_min(&mb->id); | ||||
| newob->data = BKE_mesh_add(bmain, "Mesh"); | newob->data = BKE_mesh_add(bmain, "Mesh"); | ||||
| newob->type = OB_MESH; | newob->type = OB_MESH; | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static int convert_exec(bContext *C, wmOperator *op) | ||||
| } | } | ||||
| // XXX ED_object_editmode_enter(C, 0); | // XXX ED_object_editmode_enter(C, 0); | ||||
| // XXX exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */ | // XXX exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */ | ||||
| if (basact) { | if (basact) { | ||||
| /* active base was changed */ | /* active base was changed */ | ||||
| ED_object_base_activate(C, basact); | ED_object_base_activate(C, basact); | ||||
| BASACT(sl) = basact; | BASACT(view_layer) = basact; | ||||
| } | } | ||||
| else if (BASACT(sl)->object->flag & OB_DONE) { | else if (BASACT(view_layer)->object->flag & OB_DONE) { | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, BASACT(sl)->object); | WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, BASACT(view_layer)->object); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_DATA, BASACT(sl)->object); | WM_event_add_notifier(C, NC_OBJECT | ND_DATA, BASACT(view_layer)->object); | ||||
| } | } | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene); | WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| Show All 25 Lines | |||||
| * dupflag: a flag made from constants declared in DNA_userdef_types.h | * dupflag: a flag made from constants declared in DNA_userdef_types.h | ||||
| * The flag tells adduplicate() whether to copy data linked to the object, or to reference the existing data. | * The flag tells adduplicate() whether to copy data linked to the object, or to reference the existing data. | ||||
| * U.dupflag for default operations or you can construct a flag as python does | * U.dupflag for default operations or you can construct a flag as python does | ||||
| * if the dupflag is 0 then no data will be copied (linked duplicate) */ | * if the dupflag is 0 then no data will be copied (linked duplicate) */ | ||||
| /* used below, assumes id.new is correct */ | /* used below, assumes id.new is correct */ | ||||
| /* leaves selection of base/object unaltered */ | /* leaves selection of base/object unaltered */ | ||||
| /* Does set ID->newid pointers. */ | /* Does set ID->newid pointers. */ | ||||
| static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, SceneLayer *sl, Object *ob, int dupflag) | static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer *sl, Object *ob, int dupflag) | ||||
| { | { | ||||
| #define ID_NEW_REMAP_US(a) if ( (a)->id.newid) { (a) = (void *)(a)->id.newid; (a)->id.us++; } | #define ID_NEW_REMAP_US(a) if ( (a)->id.newid) { (a) = (void *)(a)->id.newid; (a)->id.us++; } | ||||
| #define ID_NEW_REMAP_US2(a) if (((ID *)a)->newid) { (a) = ((ID *)a)->newid; ((ID *)a)->us++; } | #define ID_NEW_REMAP_US2(a) if (((ID *)a)->newid) { (a) = ((ID *)a)->newid; ((ID *)a)->us++; } | ||||
| Base *basen = NULL; | Base *basen = NULL; | ||||
| Material ***matarar; | Material ***matarar; | ||||
| Object *obn; | Object *obn; | ||||
| ID *id; | ID *id; | ||||
| int a, didit; | int a, didit; | ||||
| if (ob->mode & OB_MODE_POSE) { | if (ob->mode & OB_MODE_POSE) { | ||||
| ; /* nothing? */ | ; /* nothing? */ | ||||
| } | } | ||||
| else { | else { | ||||
| obn = ID_NEW_SET(ob, BKE_object_copy(bmain, ob)); | obn = ID_NEW_SET(ob, BKE_object_copy(bmain, ob)); | ||||
| DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); | DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); | ||||
| BKE_collection_object_add_from(scene, ob, obn); | BKE_collection_object_add_from(scene, ob, obn); | ||||
| basen = BKE_scene_layer_base_find(sl, obn); | basen = BKE_view_layer_base_find(sl, obn); | ||||
| /* 1) duplis should end up in same group as the original | /* 1) duplis should end up in same group as the original | ||||
| * 2) Rigid Body sim participants MUST always be part of a group... | * 2) Rigid Body sim participants MUST always be part of a group... | ||||
| */ | */ | ||||
| // XXX: is 2) really a good measure here? | // XXX: is 2) really a good measure here? | ||||
| if ((ob->flag & OB_FROMGROUP) != 0 || ob->rigidbody_object || ob->rigidbody_constraint) { | if ((ob->flag & OB_FROMGROUP) != 0 || ob->rigidbody_object || ob->rigidbody_constraint) { | ||||
| Group *group; | Group *group; | ||||
| for (group = bmain->group.first; group; group = group->id.next) { | for (group = bmain->group.first; group; group = group->id.next) { | ||||
| ▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | |||||
| #undef ID_NEW_REMAP_US2 | #undef ID_NEW_REMAP_US2 | ||||
| } | } | ||||
| /* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */ | /* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */ | ||||
| /* leaves selection of base/object unaltered. | /* leaves selection of base/object unaltered. | ||||
| * note: don't call this within a loop since clear_* funcs loop over the entire database. | * note: don't call this within a loop since clear_* funcs loop over the entire database. | ||||
| * note: caller must do DAG_relations_tag_update(bmain); | * note: caller must do DAG_relations_tag_update(bmain); | ||||
| * this is not done automatic since we may duplicate many objects in a batch */ | * this is not done automatic since we may duplicate many objects in a batch */ | ||||
| Base *ED_object_add_duplicate(Main *bmain, Scene *scene, SceneLayer *sl, Base *base, int dupflag) | Base *ED_object_add_duplicate(Main *bmain, Scene *scene, ViewLayer *sl, Base *base, int dupflag) | ||||
| { | { | ||||
| Base *basen; | Base *basen; | ||||
| Object *ob; | Object *ob; | ||||
| clear_sca_new_poins(); /* BGE logic */ | clear_sca_new_poins(); /* BGE logic */ | ||||
| basen = object_add_duplicate_internal(bmain, scene, sl, base->object, dupflag); | basen = object_add_duplicate_internal(bmain, scene, sl, base->object, dupflag); | ||||
| if (basen == NULL) { | if (basen == NULL) { | ||||
| Show All 17 Lines | Base *ED_object_add_duplicate(Main *bmain, Scene *scene, ViewLayer *sl, Base *base, int dupflag) | ||||
| return basen; | return basen; | ||||
| } | } | ||||
| /* contextual operator dupli */ | /* contextual operator dupli */ | ||||
| static int duplicate_exec(bContext *C, wmOperator *op) | static int duplicate_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| const bool linked = RNA_boolean_get(op->ptr, "linked"); | const bool linked = RNA_boolean_get(op->ptr, "linked"); | ||||
| int dupflag = (linked) ? 0 : U.dupflag; | int dupflag = (linked) ? 0 : U.dupflag; | ||||
| clear_sca_new_poins(); /* BGE logic */ | clear_sca_new_poins(); /* BGE logic */ | ||||
| CTX_DATA_BEGIN (C, Base *, base, selected_bases) | CTX_DATA_BEGIN (C, Base *, base, selected_bases) | ||||
| { | { | ||||
| Base *basen = object_add_duplicate_internal(bmain, scene, sl, base->object, dupflag); | Base *basen = object_add_duplicate_internal(bmain, scene, sl, base->object, dupflag); | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
| /* **************** add named object, for dragdrop ************* */ | /* **************** add named object, for dragdrop ************* */ | ||||
| static int add_named_exec(bContext *C, wmOperator *op) | static int add_named_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| const wmEvent *event = win ? win->eventstate : NULL; | const wmEvent *event = win ? win->eventstate : NULL; | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| Base *basen; | Base *basen; | ||||
| Object *ob; | Object *ob; | ||||
| const bool linked = RNA_boolean_get(op->ptr, "linked"); | const bool linked = RNA_boolean_get(op->ptr, "linked"); | ||||
| int dupflag = (linked) ? 0 : U.dupflag; | int dupflag = (linked) ? 0 : U.dupflag; | ||||
| char name[MAX_ID_NAME - 2]; | char name[MAX_ID_NAME - 2]; | ||||
| /* find object, create fake base */ | /* find object, create fake base */ | ||||
| RNA_string_get(op->ptr, "name", name); | RNA_string_get(op->ptr, "name", name); | ||||
| ▲ Show 20 Lines • Show All 162 Lines • Show Last 20 Lines | |||||