diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_multires.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 16 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 27 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 4 |
6 files changed, 45 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 3b0ff2db6f4..29a522d711f 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -60,12 +60,12 @@ void multires_force_update(struct Object *ob); struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, struct DerivedMesh*, struct Mesh *, int, int); +struct MultiresModifierData *find_multires_modifier(struct Object *ob); int multiresModifier_switch_level(struct Object *, const int); void multiresModifier_join(struct Object *); void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction); void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int distance, int updateblock, int simple); -void multiresModifier_setLevel(void *mmd_v, void *ob_v); int multiresModifier_reshape(struct MultiresModifierData *mmd, struct Object *dst, struct Object *src); /* Related to the old multires */ diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index dfd83a7b42e..244c2711e63 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -59,16 +59,26 @@ static const int multires_max_levels = 13; static const int multires_quad_tot[] = {4, 9, 25, 81, 289, 1089, 4225, 16641, 66049, 263169, 1050625, 4198401, 16785409}; static const int multires_side_tot[] = {2, 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097}; -int multiresModifier_switch_level(Object *ob, const int distance) +MultiresModifierData *find_multires_modifier(Object *ob) { - ModifierData *md = NULL; + ModifierData *md; MultiresModifierData *mmd = NULL; for(md = ob->modifiers.first; md; md = md->next) { - if(md->type == eModifierType_Multires) + if(md->type == eModifierType_Multires) { mmd = (MultiresModifierData*)md; + break; + } } + return mmd; + +} + +int multiresModifier_switch_level(Object *ob, const int distance) +{ + MultiresModifierData *mmd = find_multires_modifier(ob); + if(mmd) { mmd->lvl += distance; if(mmd->lvl < 1) mmd->lvl = 1; diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 7203f56b40f..223f2190f4b 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -86,6 +86,7 @@ void GROUP_OT_objects_remove_active(struct wmOperatorType *ot); /* object_modifier.c */ void OBJECT_OT_modifier_add(struct wmOperatorType *ot); +void OBJECT_OT_multires_subdivide(struct wmOperatorType *ot); #endif /* ED_OBJECT_INTERN_H */ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 04bcc4e3717..68b8c4a6a14 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -46,6 +46,7 @@ #include "BKE_global.h" #include "BKE_mesh.h" #include "BKE_modifier.h" +#include "BKE_multires.h" #include "BKE_report.h" #include "BKE_object.h" #include "BKE_particle.h" @@ -367,6 +368,32 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", modifier_type_items, 0, "Type", ""); } +static int multires_subdivide_exec(bContext *C, wmOperator *op) +{ + Object *ob = CTX_data_active_object(C); + MultiresModifierData *mmd = find_multires_modifier(ob); + + if(mmd) { + multiresModifier_subdivide(mmd, ob, 1, 0, mmd->simple); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + } + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_multires_subdivide(wmOperatorType *ot) +{ + ot->name= "Multires Subdivide"; + ot->description= "Add a new level of subdivision."; + ot->idname= "OBJECT_OT_multires_subdivide"; + ot->poll= ED_operator_object_active; + + ot->exec= multires_subdivide_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + #if 0 static void modifiers_add(void *ob_v, int type) { diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index e668c494fba..f2a020e69a6 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -100,6 +100,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_primitive_add); WM_operatortype_append(OBJECT_OT_modifier_add); + WM_operatortype_append(OBJECT_OT_multires_subdivide); } void ED_keymap_object(wmWindowManager *wm) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 38325246aef..2451645330c 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -335,9 +335,9 @@ static void rna_def_modifier_multires(BlenderRNA *brna) rna_def_property_subdivision_common(srna, "simple"); - prop= RNA_def_property(srna, "levels", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "level", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "lvl"); - RNA_def_property_ui_text(prop, "Levels", ""); + RNA_def_property_ui_text(prop, "Level", ""); RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MultiresModifier_level_range"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); } |