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.c169
1 files changed, 47 insertions, 122 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 615fbb527b3..88ab3450b04 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -116,7 +116,7 @@
/* this is an exact copy of the define in rna_lamp.c
* kept here because of linking order.
* Icons are only defined here */
-EnumPropertyItem lamp_type_items[] = {
+EnumPropertyItem rna_enum_lamp_type_items[] = {
{LA_LOCAL, "POINT", ICON_LAMP_POINT, "Point", "Omnidirectional point light source"},
{LA_SUN, "SUN", ICON_LAMP_SUN, "Sun", "Constant direction parallel ray light source"},
{LA_SPOT, "SPOT", ICON_LAMP_SPOT, "Spot", "Directional cone light source"},
@@ -261,10 +261,7 @@ static void view_align_update(struct Main *UNUSED(main), struct Scene *UNUSED(sc
void ED_object_add_unit_props(wmOperatorType *ot)
{
- PropertyRNA *prop;
-
- prop = RNA_def_float(ot->srna, "radius", 1.0f, 0.0, OBJECT_ADD_SIZE_MAXF, "Radius", "", 0.001, 100.00);
- RNA_def_property_subtype(prop, PROP_DISTANCE);
+ RNA_def_float_distance(ot->srna, "radius", 1.0f, 0.0, OBJECT_ADD_SIZE_MAXF, "Radius", "", 0.001, 100.00);
}
void ED_object_add_generic_props(wmOperatorType *ot, bool do_editmode)
@@ -293,6 +290,11 @@ void ED_object_add_generic_props(wmOperatorType *ot, bool do_editmode)
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
+void ED_object_add_mesh_props(wmOperatorType *ot)
+{
+ RNA_def_boolean(ot->srna, "calc_uvs", false, "Generate UVs", "Generate a default UV map");
+}
+
bool ED_object_add_generic_get_opts(bContext *C, wmOperator *op, const char view_align_axis,
float loc[3], float rot[3],
bool *enter_editmode, unsigned int *layer, bool *is_view_aligned)
@@ -482,7 +484,7 @@ void OBJECT_OT_add(wmOperatorType *ot)
/* properties */
ED_object_add_unit_props(ot);
- RNA_def_enum(ot->srna, "type", object_type_items, 0, "Type", "");
+ RNA_def_enum(ot->srna, "type", rna_enum_object_type_items, 0, "Type", "");
ED_object_add_generic_props(ot, true);
}
@@ -516,7 +518,7 @@ static int effector_add_exec(bContext *C, wmOperator *op)
cu->flag |= CU_PATH | CU_3D;
ED_object_editmode_enter(C, 0);
ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
- BLI_addtail(&cu->editnurb->nurbs, add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, dia));
+ 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);
}
@@ -641,7 +643,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op)
ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
dia = RNA_float_get(op->ptr, "radius");
- add_metaball_primitive(C, obedit, mat, dia, RNA_enum_get(op->ptr, "type"));
+ ED_mball_add_primitive(C, obedit, mat, dia, RNA_enum_get(op->ptr, "type"));
/* userdef */
if (newob && !enter_editmode) {
@@ -668,7 +670,7 @@ void OBJECT_OT_metaball_add(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- ot->prop = RNA_def_enum(ot->srna, "type", metaelem_type_items, 0, "Primitive", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_metaelem_type_items, 0, "Primitive", "");
ED_object_add_unit_props(ot);
ED_object_add_generic_props(ot, true);
@@ -815,7 +817,7 @@ void OBJECT_OT_empty_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- ot->prop = RNA_def_enum(ot->srna, "type", object_empty_drawtype_items, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_object_empty_drawtype_items, 0, "Type", "");
ED_object_add_unit_props(ot);
ED_object_add_generic_props(ot, false);
@@ -951,7 +953,7 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- ot->prop = RNA_def_enum(ot->srna, "type", lamp_type_items, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_lamp_type_items, 0, "Type", "");
RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_LAMP);
ED_object_add_unit_props(ot);
@@ -1149,7 +1151,6 @@ static int object_delete_exec(bContext *C, wmOperator *op)
}
}
/* end global */
-
}
CTX_DATA_END;
@@ -1157,12 +1158,12 @@ static int object_delete_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
/* delete has to handle all open scenes */
- BKE_main_id_flag_listbase(&bmain->scene, LIB_DOIT, 1);
+ BKE_main_id_tag_listbase(&bmain->scene, LIB_TAG_DOIT, true);
for (win = wm->windows.first; win; win = win->next) {
scene = win->screen->scene;
- if (scene->id.flag & LIB_DOIT) {
- scene->id.flag &= ~LIB_DOIT;
+ if (scene->id.tag & LIB_TAG_DOIT) {
+ scene->id.tag &= ~LIB_TAG_DOIT;
DAG_relations_tag_update(bmain);
@@ -1195,89 +1196,16 @@ void OBJECT_OT_delete(wmOperatorType *ot)
/**************************** Copy Utilities ******************************/
/* after copying objects, copied data should get new pointers */
-static void copy_object_set_idnew(bContext *C, int dupflag)
+static void copy_object_set_idnew(bContext *C)
{
Main *bmain = CTX_data_main(C);
- Material *ma, *mao;
- ID *id;
- int a;
- /* XXX check object pointers */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
- BKE_object_relink(ob);
+ BKE_libblock_relink(&ob->id);
}
CTX_DATA_END;
- /* materials */
- if (dupflag & USER_DUP_MAT) {
- mao = bmain->mat.first;
- while (mao) {
- if (mao->id.newid) {
- ma = (Material *)mao->id.newid;
-
- if (dupflag & USER_DUP_TEX) {
- for (a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- id = (ID *)ma->mtex[a]->tex;
- if (id) {
- ID_NEW_US(ma->mtex[a]->tex)
- else
- ma->mtex[a]->tex = BKE_texture_copy(ma->mtex[a]->tex);
- id->us--;
- }
- }
- }
- }
-#if 0 // XXX old animation system
- id = (ID *)ma->ipo;
- if (id) {
- ID_NEW_US(ma->ipo)
- else
- ma->ipo = copy_ipo(ma->ipo);
- id->us--;
- }
-#endif // XXX old animation system
- }
- mao = mao->id.next;
- }
- }
-
-#if 0 // XXX old animation system
- /* lamps */
- if (dupflag & USER_DUP_IPO) {
- Lamp *la = bmain->lamp.first;
- while (la) {
- if (la->id.newid) {
- Lamp *lan = (Lamp *)la->id.newid;
- id = (ID *)lan->ipo;
- if (id) {
- ID_NEW_US(lan->ipo)
- else
- lan->ipo = copy_ipo(lan->ipo);
- id->us--;
- }
- }
- la = la->id.next;
- }
- }
-
- /* ipos */
- ipo = bmain->ipo.first;
- while (ipo) {
- if (ipo->id.lib == NULL && ipo->id.newid) {
- Ipo *ipon = (Ipo *)ipo->id.newid;
- IpoCurve *icu;
- for (icu = ipon->curve.first; icu; icu = icu->next) {
- if (icu->driver) {
- ID_NEW(icu->driver->ob);
- }
- }
- }
- ipo = ipo->id.next;
- }
-#endif // XXX old animation system
-
set_sca_new_poins();
BKE_main_id_clear_newpoins(bmain);
@@ -1468,7 +1396,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
if (parent_gh)
BLI_ghash_free(parent_gh, NULL, NULL);
- copy_object_set_idnew(C, 0);
+ copy_object_set_idnew(C);
free_object_duplilist(lb);
@@ -1616,7 +1544,7 @@ static int convert_exec(bContext *C, wmOperator *op)
/* flag data thats not been edited (only needed for !keep_original) */
if (ob->data) {
- ((ID *)ob->data)->flag |= LIB_DOIT;
+ ((ID *)ob->data)->tag |= LIB_TAG_DOIT;
}
/* possible metaball basis is not in this scene */
@@ -1660,7 +1588,7 @@ static int convert_exec(bContext *C, wmOperator *op)
/* decrement original mesh's usage count */
me = newob->data;
- me->id.us--;
+ id_us_min(&me->id);
/* make a new copy of the mesh */
newob->data = BKE_mesh_copy(me);
@@ -1685,7 +1613,7 @@ static int convert_exec(bContext *C, wmOperator *op)
/* decrement original mesh's usage count */
me = newob->data;
- me->id.us--;
+ id_us_min(&me->id);
/* make a new copy of the mesh */
newob->data = BKE_mesh_copy(me);
@@ -1716,7 +1644,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
/* decrement original curve's usage count */
- ((Curve *)newob->data)->id.us--;
+ id_us_min(&((Curve *)newob->data)->id);
/* make a new copy of the curve */
newob->data = BKE_curve_copy(ob->data);
@@ -1737,19 +1665,19 @@ static int convert_exec(bContext *C, wmOperator *op)
cu->type = OB_CURVE;
if (cu->vfont) {
- cu->vfont->id.us--;
+ id_us_min(&cu->vfont->id);
cu->vfont = NULL;
}
if (cu->vfontb) {
- cu->vfontb->id.us--;
+ id_us_min(&cu->vfontb->id);
cu->vfontb = NULL;
}
if (cu->vfonti) {
- cu->vfonti->id.us--;
+ id_us_min(&cu->vfonti->id);
cu->vfonti = NULL;
}
if (cu->vfontbi) {
- cu->vfontbi->id.us--;
+ id_us_min(&cu->vfontbi->id);
cu->vfontbi = NULL;
}
@@ -1787,7 +1715,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
/* decrement original curve's usage count */
- ((Curve *)newob->data)->id.us--;
+ id_us_min(&((Curve *)newob->data)->id);
/* make a new copy of the curve */
newob->data = BKE_curve_copy(ob->data);
@@ -1822,7 +1750,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
mb = newob->data;
- mb->id.us--;
+ id_us_min(&mb->id);
newob->data = BKE_mesh_add(bmain, "Mesh");
newob->type = OB_MESH;
@@ -1862,7 +1790,7 @@ static int convert_exec(bContext *C, wmOperator *op)
if (!keep_original && (ob->flag & OB_DONE)) {
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- ((ID *)ob->data)->flag &= ~LIB_DOIT; /* flag not to convert this datablock again */
+ ((ID *)ob->data)->tag &= ~LIB_TAG_DOIT; /* flag not to convert this datablock again */
}
}
CTX_DATA_END;
@@ -1988,7 +1916,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
ID_NEW_US(obn->mat[a])
else
obn->mat[a] = BKE_material_copy(obn->mat[a]);
- id->us--;
+ id_us_min(id);
if (dupflag & USER_DUP_ACT) {
BKE_animdata_copy_id_action(&obn->mat[a]->id);
@@ -2009,7 +1937,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
BKE_animdata_copy_id_action(&psys->part->id);
}
- id->us--;
+ id_us_min(id);
}
}
}
@@ -2023,12 +1951,9 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
ID_NEW_US2(obn->data)
else {
obn->data = BKE_mesh_copy(obn->data);
- if (obn->fluidsimSettings) {
- obn->fluidsimSettings->orgMesh = (Mesh *)obn->data;
- }
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_CURVE:
@@ -2038,7 +1963,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_curve_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_SURF:
@@ -2048,7 +1973,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_curve_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_FONT:
@@ -2058,7 +1983,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_curve_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_MBALL:
@@ -2068,7 +1993,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_mball_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_LAMP:
@@ -2078,7 +2003,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_lamp_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_ARMATURE:
@@ -2092,7 +2017,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
BKE_pose_rebuild(obn, obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_LATTICE:
@@ -2102,7 +2027,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_lattice_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_CAMERA:
@@ -2112,7 +2037,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_camera_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_SPEAKER:
@@ -2122,7 +2047,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_speaker_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
}
@@ -2159,7 +2084,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
ID_NEW_US((*matarar)[a])
else
(*matarar)[a] = BKE_material_copy((*matarar)[a]);
- id->us--;
+ id_us_min(id);
}
}
}
@@ -2190,7 +2115,7 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag
ob = basen->object;
/* link own references to the newly duplicated data [#26816] */
- BKE_object_relink(ob);
+ BKE_libblock_relink(&ob->id);
set_sca_new_poins_ob(ob);
/* DAG_relations_tag_update(bmain); */ /* caller must do */
@@ -2235,7 +2160,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- copy_object_set_idnew(C, dupflag);
+ copy_object_set_idnew(C);
DAG_relations_tag_update(bmain);
@@ -2262,7 +2187,7 @@ void OBJECT_OT_duplicate(wmOperatorType *ot)
/* to give to transform */
RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data");
- prop = RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", "");
+ prop = RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
}
@@ -2320,7 +2245,7 @@ static int add_named_exec(bContext *C, wmOperator *op)
ED_base_object_select(basen, BA_SELECT);
ED_base_object_activate(C, basen);
- copy_object_set_idnew(C, dupflag);
+ copy_object_set_idnew(C);
DAG_relations_tag_update(bmain);