diff options
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_add.c | 61 | ||||
-rw-r--r-- | source/blender/editors/object/object_bake.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 37 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 46 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 8 | ||||
-rw-r--r-- | source/blender/editors/object/object_transform.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 14 |
10 files changed, 111 insertions, 65 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 225889cdb59..f490ca19a31 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -108,7 +108,7 @@ void ED_object_location_from_view(bContext *C, float *loc) void ED_object_rotation_from_view(bContext *C, float *rot) { - RegionView3D *rv3d = CTX_wm_region_view3d(C); + RegionView3D *rv3d= ED_view3d_context_rv3d(C); if(rv3d) { rv3d->viewquat[0]= -rv3d->viewquat[0]; @@ -176,8 +176,10 @@ void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode) PropertyRNA *prop; RNA_def_boolean(ot->srna, "view_align", 0, "Align to View", "Align the new object to the view."); - if(do_editmode) - RNA_def_boolean(ot->srna, "enter_editmode", 0, "Enter Editmode", "Enter editmode when adding this object."); + if(do_editmode) { + prop= RNA_def_boolean(ot->srna, "enter_editmode", 0, "Enter Editmode", "Enter editmode when adding this object."); + RNA_def_property_flag(prop, PROP_HIDDEN); + } RNA_def_float_vector(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "Location for the newly added object.", -FLT_MAX, FLT_MAX); RNA_def_float_rotation(ot->srna, "rotation", 3, NULL, -FLT_MAX, FLT_MAX, "Rotation", "Rotation for the newly added object", -FLT_MAX, FLT_MAX); @@ -198,23 +200,7 @@ static void object_add_generic_invoke_options(bContext *C, wmOperator *op) ED_object_location_from_view(C, loc); RNA_float_set_array(op->ptr, "location", loc); } - - if (!RNA_property_is_set(op->ptr, "rotation")) { - int view_align; - float rot[3] = {0.f, 0.f, 0.f}; - - /* view align property is just used to set rotation property */ - if (!RNA_property_is_set(op->ptr, "view_align")) - view_align = U.flag & USER_ADD_VIEWALIGNED; - else - view_align = RNA_boolean_get(op->ptr, "view_align"); - - if (view_align) - ED_object_rotation_from_view(C, rot); - - RNA_float_set_array(op->ptr, "rotation", rot); - } - + if (!RNA_property_is_set(op->ptr, "layer")) { View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); @@ -246,17 +232,28 @@ int ED_object_add_generic_invoke(bContext *C, wmOperator *op, wmEvent *event) return op->type->exec(C, op); } -void ED_object_add_generic_get_opts(wmOperator *op, float *loc, float *rot, int *enter_editmode, unsigned int *layer) +void ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, float *rot, int *enter_editmode, unsigned int *layer) { int a, layer_values[32]; + 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; } + if (RNA_property_is_set(op->ptr, "view_align")) + view_align = RNA_boolean_get(op->ptr, "view_align"); + else + view_align = U.flag & USER_ADD_VIEWALIGNED; + + if (view_align) + ED_object_rotation_from_view(C, rot); + else + RNA_float_get_array(op->ptr, "rotation", rot); + + RNA_float_get_array(op->ptr, "location", loc); - RNA_float_get_array(op->ptr, "rotation", rot); RNA_boolean_get_array(op->ptr, "layer", layer_values); for(a=0; a<32; a++) @@ -301,7 +298,7 @@ static int object_add_exec(bContext *C, wmOperator *op) unsigned int layer; float loc[3], rot[3]; - ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer); + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer); ED_object_add_type(C, RNA_enum_get(op->ptr, "type"), loc, rot, enter_editmode, layer); return OPERATOR_FINISHED; @@ -360,7 +357,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) float mat[4][4]; object_add_generic_invoke_options(C, op); - ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer); + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer); if(type==PFIELD_GUIDE) { ob= ED_object_add_type(C, OB_CURVE, loc, rot, FALSE, layer); @@ -435,7 +432,7 @@ static int object_camera_add_exec(bContext *C, wmOperator *op) RNA_boolean_set(op->ptr, "view_align", 1); object_add_generic_invoke_options(C, op); - ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer); + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer); ob= ED_object_add_type(C, OB_CAMERA, loc, rot, FALSE, layer); @@ -491,7 +488,7 @@ static int object_add_curve_exec(bContext *C, wmOperator *op) float mat[4][4]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called - ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer); + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer); if(obedit==NULL || obedit->type!=OB_CURVE) { Curve *cu; @@ -583,7 +580,7 @@ static int object_add_surface_exec(bContext *C, wmOperator *op) float mat[4][4]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called - ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer); + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer); if(obedit==NULL || obedit->type!=OB_SURF) { obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); @@ -648,7 +645,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) float mat[4][4]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called - ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer); + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer); if(obedit==NULL || obedit->type!=OB_MBALL) { obedit= ED_object_add_type(C, OB_MBALL, loc, rot, TRUE, layer); @@ -718,7 +715,7 @@ static int object_add_text_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called - ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer); + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer); if(obedit && obedit->type==OB_FONT) return OPERATOR_CANCELLED; @@ -758,7 +755,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called - ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer); + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer); if ((obedit==NULL) || (obedit->type != OB_ARMATURE)) { obedit= ED_object_add_type(C, OB_ARMATURE, loc, rot, TRUE, layer); @@ -813,7 +810,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; object_add_generic_invoke_options(C, op); - ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer); + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer); ob= ED_object_add_type(C, OB_LAMP, loc, rot, FALSE, layer); if(ob && ob->data) @@ -860,7 +857,7 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; object_add_generic_invoke_options(C, op); - ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer); + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer); if(group) { Object *ob= ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index d3f9847d9b9..9a9461da62e 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -263,7 +263,7 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *_eve steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY); WM_jobs_customdata(steve, bkr, bake_freejob); WM_jobs_timer(steve, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ - WM_jobs_callbacks(steve, bake_startjob, NULL, bake_update); + WM_jobs_callbacks(steve, bake_startjob, NULL, bake_update, NULL); G.afbreek= 0; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 0db31b90365..90727cee53d 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -1110,6 +1110,28 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op) } /* dummy operator callback */ +static int object_constraint_copy_exec(bContext *C, wmOperator *op) +{ + Object *ob=ED_object_active_context(C); + + CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { + if(ob != ob_iter) { + if (ob->data != ob_iter->data){ + copy_constraints(&ob_iter->constraints, &ob->constraints); + } + + if(ob_iter->totcol==ob->totcol) { + ob_iter->actcol= ob->actcol; + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob_iter); + } + } + } + CTX_DATA_END; + + return OPERATOR_FINISHED; +} + +/* dummy operator callback */ static int pose_constraint_add_exec(bContext *C, wmOperator *op) { Object *ob= ED_object_active_context(C); @@ -1170,6 +1192,21 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot) ot->prop= RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); } +void OBJECT_OT_constraint_copy(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Copy Constraints to Others"; + ot->description = "Copy constraints to other selected objects."; + ot->idname= "OBJECT_OT_constraint_copy"; + + /* api callbacks */ + ot->exec= object_constraint_copy_exec; + ot->poll= ED_operator_object_active_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + void POSE_OT_constraint_add(wmOperatorType *ot) { /* identifiers */ diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 2332f08c021..a1d2a6d734a 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -53,12 +53,10 @@ #include "BKE_action.h" #include "BKE_anim.h" #include "BKE_armature.h" -#include "BKE_booleanops.h" #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_customdata.h" #include "BKE_blender.h" -#include "BKE_booleanops.h" #include "BKE_cloth.h" #include "BKE_curve.h" #include "BKE_displist.h" @@ -2054,6 +2052,8 @@ void ED_object_toggle_modes(bContext *C, int mode) WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); if(mode & OB_MODE_POSE) WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_EDIT) + WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); } /************************ Game Properties ***********************/ diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 23f5d0c1475..6b43591479d 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -157,6 +157,7 @@ void OBJECT_OT_explode_refresh(struct wmOperatorType *ot); /* object_constraint.c */ void OBJECT_OT_constraint_add(struct wmOperatorType *ot); void OBJECT_OT_constraint_add_with_targets(struct wmOperatorType *ot); +void OBJECT_OT_constraint_copy(struct wmOperatorType *ot); void POSE_OT_constraint_add(struct wmOperatorType *ot); void POSE_OT_constraint_add_with_targets(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index a43f3de9b14..18cc0adab8a 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -389,32 +389,44 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) { + ModifierTypeInfo *mti= modifierType_getInfo(md->type); + + if (!(md->mode&eModifierMode_Realtime) || (mti->isDisabled && mti->isDisabled(md, 0))) { + BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); + return 0; + } + if (ob->type==OB_MESH) { DerivedMesh *dm; Mesh *me = ob->data; + MultiresModifierData *mmd= find_multires_modifier(ob); + if( me->key) { BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to Mesh with Shape Keys"); return 0; } - + mesh_pmv_off(ob, me); - + /* Multires: ensure that recent sculpting is applied */ if(md->type == eModifierType_Multires) multires_force_update(ob); - - dm = mesh_create_derived_for_modifier(scene, ob, md); - if (!dm) { - BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply"); - return 0; + + if (mmd && mti->type==eModifierTypeType_OnlyDeform) { + multiresModifier_reshapeFromDeformMod (mmd, ob, md); + } else { + dm = mesh_create_derived_for_modifier(scene, ob, md); + if (!dm) { + BKE_report(reports, RPT_ERROR, "Modifier is returned error, skipping apply"); + return 0; + } + + DM_to_mesh(dm, me); + + dm->release(dm); } - - DM_to_mesh(dm, me); - - dm->release(dm); } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { - ModifierTypeInfo *mti = modifierType_getInfo(md->type); Curve *cu; int numVerts; float (*vertexCos)[3]; @@ -427,11 +439,6 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, cu = ob->data; BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tesselated/bevel vertices"); - if (!(md->mode&eModifierMode_Realtime) || (mti->isDisabled && mti->isDisabled(md, 0))) { - BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); - return 0; - } - vertexCos = curve_getVertexCos(cu, &cu->nurb, &numVerts); mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0, 0); curve_applyVertexCos(cu, &cu->nurb, vertexCos); @@ -829,11 +836,6 @@ static int multires_reshape_exec(bContext *C, wmOperator *op) Object *ob= ptr.id.data, *secondob= NULL; MultiresModifierData *mmd= ptr.data; - if(ob->derivedFinal == NULL || ob->derivedFinal->type != DM_TYPE_CCGDM) { - BKE_report(op->reports, RPT_ERROR, "Active objects multires is disabled, can't reshape multires data."); - return OPERATOR_CANCELLED; - } - CTX_DATA_BEGIN(C, Object*, selob, selected_editable_objects) { if(selob->type == OB_MESH && selob != ob) { secondob= selob; diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 2ff99bac1c5..082aa3db62b 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -143,6 +143,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_constraint_add); WM_operatortype_append(OBJECT_OT_constraint_add_with_targets); + WM_operatortype_append(OBJECT_OT_constraint_copy); WM_operatortype_append(POSE_OT_constraint_add); WM_operatortype_append(POSE_OT_constraint_add_with_targets); WM_operatortype_append(OBJECT_OT_constraints_clear); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 52d6a7a7b8b..a6a955e6df8 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1710,21 +1710,21 @@ static int make_local_exec(bContext *C, wmOperator *op) clear_id_newpoins(); - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { if(ob->id.lib) id_make_local(&ob->id, 0); } CTX_DATA_END; /* maybe object pointers */ - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { if(ob->id.lib==NULL) { ID_NEW(ob->parent); } } CTX_DATA_END; - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { id= ob->data; if(id && mode>1) { @@ -1742,7 +1742,7 @@ static int make_local_exec(bContext *C, wmOperator *op) CTX_DATA_END; if(mode>1) { - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { if(ob->type==OB_LAMP) { la= ob->data; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 13b7f883922..c363a9858cb 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -208,7 +208,7 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op) VECCOPY(ob->rot, eul); } } - } + } // Duplicated in source/blender/editors/armature/editarmature.c else { if (ob->rotmode == ROT_MODE_QUAT) { ob->quat[1]=ob->quat[2]=ob->quat[3]= 0.0f; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 6c9b45a63cd..f7847972df1 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -284,7 +284,11 @@ void ED_vgroup_nr_vert_add(Object *ob, int def_nr, int vertnum, float weight, in if(dv==NULL) return; - dv+= vertnum; + /* check that vertnum is valid before trying to get the relevant dvert */ + if ((vertnum < 0) || (vertnum >= tot)) + return; + else + dv += vertnum; /* Lets first check to see if this vert is * already in the weight group -- if so @@ -1454,7 +1458,11 @@ static int vertex_group_remove_from_exec(bContext *C, wmOperator *op) { Object *ob= CTX_data_edit_object(C); - vgroup_remove_verts(ob, 0); + if(RNA_boolean_get(op->ptr, "all")) + vgroup_remove_verts(ob, 0); + else + vgroup_active_remove_verts(ob, 0); + DAG_id_flush_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); @@ -1968,7 +1976,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op) } else { ED_vgroup_give_array(ob->data, &dvert, &dvert_tot); - while(dvert && dvert_tot--) { + while(dvert_tot--) { if(dvert->totweight) defvert_remap(dvert, sort_map); dvert++; |