[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51073] trunk/blender/source/blender/ editors/object/object_add.c: Some effect-less code cleanup...
Bastien Montagne
montagne29 at wanadoo.fr
Fri Oct 5 09:05:52 CEST 2012
Revision: 51073
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51073
Author: mont29
Date: 2012-10-05 07:05:52 +0000 (Fri, 05 Oct 2012)
Log Message:
-----------
Some effect-less code cleanup...
Modified Paths:
--------------
trunk/blender/source/blender/editors/object/object_add.c
Modified: trunk/blender/source/blender/editors/object/object_add.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_add.c 2012-10-05 06:40:21 UTC (rev 51072)
+++ trunk/blender/source/blender/editors/object/object_add.c 2012-10-05 07:05:52 UTC (rev 51073)
@@ -110,7 +110,7 @@
#include "object_intern.h"
/* this is an exact copy of the define in rna_lamp.c
- * kept here because of linking order.
+ * kept here because of linking order.
* Icons are only defined here */
EnumPropertyItem lamp_type_items[] = {
{LA_LOCAL, "POINT", ICON_LAMP_POINT, "Point", "Omnidirectional point light source"},
@@ -121,6 +121,23 @@
{0, NULL, 0, NULL, NULL}
};
+/* copy from rna_object_force.c */
+static EnumPropertyItem field_type_items[] = {
+ {PFIELD_FORCE, "FORCE", ICON_FORCE_FORCE, "Force", ""},
+ {PFIELD_WIND, "WIND", ICON_FORCE_WIND, "Wind", ""},
+ {PFIELD_VORTEX, "VORTEX", ICON_FORCE_VORTEX, "Vortex", ""},
+ {PFIELD_MAGNET, "MAGNET", ICON_FORCE_MAGNETIC, "Magnetic", ""},
+ {PFIELD_HARMONIC, "HARMONIC", ICON_FORCE_HARMONIC, "Harmonic", ""},
+ {PFIELD_CHARGE, "CHARGE", ICON_FORCE_CHARGE, "Charge", ""},
+ {PFIELD_LENNARDJ, "LENNARDJ", ICON_FORCE_LENNARDJONES, "Lennard-Jones", ""},
+ {PFIELD_TEXTURE, "TEXTURE", ICON_FORCE_TEXTURE, "Texture", ""},
+ {PFIELD_GUIDE, "GUIDE", ICON_FORCE_CURVE, "Curve Guide", ""},
+ {PFIELD_BOID, "BOID", ICON_FORCE_BOID, "Boid", ""},
+ {PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", ""},
+ {PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
/************************** Exported *****************************/
void ED_object_location_from_view(bContext *C, float loc[3])
@@ -128,7 +145,7 @@
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
float *cursor;
-
+
cursor = give_cursor(scene, v3d);
copy_v3_v3(loc, cursor);
@@ -152,44 +169,44 @@
{
Object *ob = base->object;
Scene *scene = CTX_data_scene(C);
-
+
if (!scene) return;
-
+
if (loc)
copy_v3_v3(ob->loc, loc);
-
+
if (rot)
copy_v3_v3(ob->rot, rot);
-
+
BKE_object_where_is_calc(scene, ob);
}
-/* uses context to figure out transform for primitive */
-/* returns standard diameter */
+/* Uses context to figure out transform for primitive.
+ * Returns standard diameter. */
float ED_object_new_primitive_matrix(bContext *C, Object *obedit,
const float loc[3], const float rot[3], float primmat[][4])
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3];
-
+
unit_m4(primmat);
-
+
eul_to_mat3(rmat, rot);
invert_m3(rmat);
-
+
/* inverse transform for initial rotation and object */
copy_m3_m4(mat, obedit->obmat);
mul_m3_m3m3(cmat, rmat, mat);
invert_m3_m3(imat, cmat);
copy_m4_m3(primmat, imat);
-
+
/* center */
copy_v3_v3(primmat[3], loc);
sub_v3_v3v3(primmat[3], primmat[3], obedit->obmat[3]);
invert_m3_m3(imat, mat);
mul_m3_v3(imat, primmat[3]);
-
+
if (v3d)
return ED_view3d_grid_scale(scene, v3d, NULL);
@@ -206,7 +223,7 @@
void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode)
{
PropertyRNA *prop;
-
+
/* note: this property gets hidden for add-camera operator */
prop = RNA_def_boolean(ot->srna, "view_align", 0, "Align to View", "Align the new object to the view");
RNA_def_property_update_runtime(prop, view_align_update);
@@ -216,14 +233,14 @@
"Enter editmode when adding this object");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
-
+
prop = RNA_def_float_vector_xyz(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location",
"Location for the newly added object", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_float_rotation(ot->srna, "rotation", 3, NULL, -FLT_MAX, FLT_MAX, "Rotation",
"Rotation for the newly added object", (float)-M_PI * 2.0f, (float)M_PI * 2.0f);
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-
+
prop = RNA_def_boolean_layer_member(ot->srna, "layers", 20, NULL, "Layer", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
@@ -233,14 +250,14 @@
if (RNA_struct_find_property(op->ptr, "enter_editmode")) /* optional */
if (!RNA_struct_property_is_set(op->ptr, "enter_editmode"))
RNA_boolean_set(op->ptr, "enter_editmode", U.flag & USER_ADD_EDITMODE);
-
+
if (!RNA_struct_property_is_set(op->ptr, "location")) {
float loc[3];
-
+
ED_object_location_from_view(C, loc);
RNA_float_set_array(op->ptr, "location", loc);
}
-
+
if (!RNA_struct_property_is_set(op->ptr, "layers")) {
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
@@ -273,7 +290,7 @@
View3D *v3d = CTX_wm_view3d(C);
int a, layer_values[20];
int view_align;
-
+
*enter_editmode = FALSE;
if (RNA_struct_find_property(op->ptr, "enter_editmode") && RNA_boolean_get(op->ptr, "enter_editmode")) {
*enter_editmode = TRUE;
@@ -308,17 +325,17 @@
view_align = U.flag & USER_ADD_VIEWALIGNED;
RNA_boolean_set(op->ptr, "view_align", view_align);
}
-
+
if (view_align) {
ED_object_rotation_from_view(C, rot);
RNA_float_set_array(op->ptr, "rotation", rot);
}
else
RNA_float_get_array(op->ptr, "rotation", rot);
-
+
if (is_view_aligned)
*is_view_aligned = view_align;
-
+
RNA_float_get_array(op->ptr, "location", loc);
if (*layer == 0) {
@@ -329,19 +346,19 @@
return 1;
}
-/* for object add primitive operators */
-/* do not call undo push in this function (users of this function have to) */
+/* For object add primitive operators.
+ * Do not call undo push in this function (users of this function have to). */
Object *ED_object_add_type(bContext *C, int type, const float loc[3], const float rot[3],
int enter_editmode, unsigned int layer)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob;
-
- /* for as long scene has editmode... */
+
+ /* For as long scene has editmode... */
if (CTX_data_edit_object(C))
ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */
-
+
/* deselects all, sets scene->basact */
ob = BKE_object_add(scene, type);
BASACT->lay = ob->lay = layer;
@@ -371,12 +388,12 @@
int enter_editmode;
unsigned int layer;
float loc[3], rot[3];
-
+
if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
return OPERATOR_CANCELLED;
ED_object_add_type(C, RNA_enum_get(op->ptr, "type"), loc, rot, enter_editmode, layer);
-
+
return OPERATOR_FINISHED;
}
@@ -386,37 +403,22 @@
ot->name = "Add Object";
ot->description = "Add an object to the scene";
ot->idname = "OBJECT_OT_add";
-
+
/* api callbacks */
ot->invoke = ED_object_add_generic_invoke;
ot->exec = object_add_exec;
-
+
ot->poll = ED_operator_objectmode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_enum(ot->srna, "type", object_type_items, 0, "Type", "");
ED_object_add_generic_props(ot, TRUE);
}
/********************* Add Effector Operator ********************/
-/* copy from rna_object_force.c*/
-static EnumPropertyItem field_type_items[] = {
- {PFIELD_FORCE, "FORCE", ICON_FORCE_FORCE, "Force", ""},
- {PFIELD_WIND, "WIND", ICON_FORCE_WIND, "Wind", ""},
- {PFIELD_VORTEX, "VORTEX", ICON_FORCE_VORTEX, "Vortex", ""},
- {PFIELD_MAGNET, "MAGNET", ICON_FORCE_MAGNETIC, "Magnetic", ""},
- {PFIELD_HARMONIC, "HARMONIC", ICON_FORCE_HARMONIC, "Harmonic", ""},
- {PFIELD_CHARGE, "CHARGE", ICON_FORCE_CHARGE, "Charge", ""},
- {PFIELD_LENNARDJ, "LENNARDJ", ICON_FORCE_LENNARDJONES, "Lennard-Jones", ""},
- {PFIELD_TEXTURE, "TEXTURE", ICON_FORCE_TEXTURE, "Texture", ""},
- {PFIELD_GUIDE, "GUIDE", ICON_FORCE_CURVE, "Curve Guide", ""},
- {PFIELD_BOID, "BOID", ICON_FORCE_BOID, "Boid", ""},
- {PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", ""},
- {PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", ""},
- {0, NULL, 0, NULL, NULL}};
/* for effector add primitive operators */
static Object *effector_add_type(bContext *C, wmOperator *op, int type)
@@ -426,7 +428,7 @@
unsigned int layer;
float loc[3], rot[3];
float mat[4][4];
-
+
object_add_generic_invoke_options(C, op);
if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
@@ -478,22 +480,22 @@
ot->name = "Add Effector";
ot->description = "Add an empty object with a physics effector to the scene";
ot->idname = "OBJECT_OT_effector_add";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = effector_add_exec;
-
+
ot->poll = ED_operator_objectmode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
ot->prop = RNA_def_enum(ot->srna, "type", field_type_items, 0, "Type", "");
ED_object_add_generic_props(ot, TRUE);
}
-/* ***************** Add Camera *************** */
+/********************* Add Camera Operator ********************/
static int object_camera_add_exec(bContext *C, wmOperator *op)
{
@@ -503,17 +505,17 @@
int enter_editmode;
unsigned int layer;
float loc[3], rot[3];
-
+
/* force view align for cameras */
RNA_boolean_set(op->ptr, "view_align", TRUE);
-
+
object_add_generic_invoke_options(C, op);
if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
return OPERATOR_CANCELLED;
ob = ED_object_add_type(C, OB_CAMERA, loc, rot, FALSE, layer);
-
+
if (v3d) {
if (v3d->camera == NULL)
v3d->camera = ob;
@@ -528,33 +530,32 @@
void OBJECT_OT_camera_add(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "Add Camera";
ot->description = "Add a camera object to the scene";
ot->idname = "OBJECT_OT_camera_add";
-
+
/* api callbacks */
ot->exec = object_camera_add_exec;
ot->poll = ED_operator_objectmode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
ED_object_add_generic_props(ot, TRUE);
-
+
/* hide this for cameras, default */
prop = RNA_struct_type_find_property(ot->srna, "view_align");
RNA_def_property_flag(prop, PROP_HIDDEN);
-
}
-/* ***************** add primitives *************** */
+/********************* Add Metaball Operator ********************/
+
static int object_metaball_add_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
- /*MetaElem *elem;*/ /*UNUSED*/
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list