DPAINT_OT_output_toggle operator was using an index option for what was really a toggle between 2 values, changed its index option to an enum.

if a value other than 1/0 was given it would use an uninitialized pointer too (compiler warning, review should pick up this stuff).

also renamed some RNA attrs:
 output_name --> output_name_a
 output_name2 --> output_name_b
 do_output1 --> use_output_a
 do_output2 --> use_output_b
 do_smudge --> use_smudge
 max_velocity --> velocity_max
This commit is contained in:
Campbell Barton 2011-11-14 06:46:07 +00:00
parent f474576351
commit 11a7a406fb
5 changed files with 40 additions and 36 deletions

@ -213,33 +213,33 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
# paintmap output
row = layout.row()
row.prop_search(surface, "output_name", ob.data, "vertex_colors", text="Paintmap layer: ")
row.prop_search(surface, "output_name_a", ob.data, "vertex_colors", text="Paintmap layer: ")
if surface.output_exists(object=ob, index=0):
ic = 'ZOOMOUT'
else:
ic = 'ZOOMIN'
row.operator("dpaint.output_toggle", icon=ic, text="").index = 0
row.operator("dpaint.output_toggle", icon=ic, text="").output = 'A'
# wetmap output
row = layout.row()
row.prop_search(surface, "output_name2", ob.data, "vertex_colors", text="Wetmap layer: ")
row.prop_search(surface, "output_name_b", ob.data, "vertex_colors", text="Wetmap layer: ")
if surface.output_exists(object=ob, index=1):
ic = 'ZOOMOUT'
else:
ic = 'ZOOMIN'
row.operator("dpaint.output_toggle", icon=ic, text="").index = 1
row.operator("dpaint.output_toggle", icon=ic, text="").output = 'B'
elif surface_type == 'WEIGHT':
row = layout.row()
row.prop_search(surface, "output_name", ob, "vertex_groups", text="Vertex Group: ")
row.prop_search(surface, "output_name_a", ob, "vertex_groups", text="Vertex Group: ")
if surface.output_exists(object=ob, index=0):
ic = 'ZOOMOUT'
else:
ic = 'ZOOMIN'
row.operator("dpaint.output_toggle", icon=ic, text="").index = 0
row.operator("dpaint.output_toggle", icon=ic, text="").output = 'A'
# image format outputs
if surface.surface_format == 'IMAGE':
@ -254,19 +254,19 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
if surface_type == 'PAINT':
split = layout.split(percentage=0.4)
split.prop(surface, "do_output1", text="Paintmaps:")
split.prop(surface, "use_output_a", text="Paintmaps:")
sub = split.row()
sub.active = surface.do_output1
sub.prop(surface, "output_name", text="")
sub.active = surface.use_output_a
sub.prop(surface, "output_name_a", text="")
split = layout.split(percentage=0.4)
split.prop(surface, "do_output2", text="Wetmaps:")
split.prop(surface, "do_output_b", text="Wetmaps:")
sub = split.row()
sub.active = surface.do_output2
sub.prop(surface, "output_name2", text="")
sub.active = surface.do_output_b
sub.prop(surface, "output_name_b", text="")
else:
col = layout.column()
col.prop(surface, "output_name", text="Filename: ")
col.prop(surface, "output_name_a", text="Filename: ")
if surface_type == 'DISPLACE':
col.prop(surface, "displace_type", text="Displace Type")
col.prop(surface, "depth_clamp")
@ -454,14 +454,14 @@ class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, Panel):
col = layout.column()
col.active = (brush.velocity_alpha or brush.velocity_color or brush.velocity_depth)
col.prop(brush, "max_velocity")
col.prop(brush, "velocity_max")
col.template_color_ramp(brush, "velocity_ramp", expand=True)
layout.separator()
row = layout.row()
row.prop(brush, "do_smudge")
row.prop(brush, "use_smudge")
sub = row.row()
sub.active = brush.do_smudge
sub.active = brush.use_smudge
sub.prop(brush, "smudge_strength")

@ -64,7 +64,7 @@ void dynamicPaint_freeSurfaceData(struct DynamicPaintSurface *surface);
void dynamicPaint_cacheUpdateFrames(struct DynamicPaintSurface *surface);
int dynamicPaint_surfaceHasColorPreview(struct DynamicPaintSurface *surface);
int dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, struct Object *ob, int index);
int dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, struct Object *ob, int output);
void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface);
void dynamicPaintSurface_setUniqueName(struct DynamicPaintSurface *surface, const char *basename);
void dynamicPaint_resetPreview(struct DynamicPaintCanvasSettings *canvas);

@ -279,13 +279,13 @@ static void dynamicPaint_setPreview(DynamicPaintSurface *t_surface)
}
}
int dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object *ob, int index)
int dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object *ob, int output)
{
char *name;
if (index == 0)
if (output == 0)
name = surface->output_name;
else if (index == 1)
else if (output == 1)
name = surface->output_name2;
else
return 0;

@ -197,24 +197,23 @@ void DPAINT_OT_type_toggle(wmOperatorType *ot)
static int output_toggle_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
Scene *scene = CTX_data_scene(C);
DynamicPaintSurface *surface;
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
int index= RNA_int_get(op->ptr, "index");
int output= RNA_enum_get(op->ptr, "output"); /* currently only 1/0 */
if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED;
surface = get_activeSurface(pmd->canvas);
/* if type is already enabled, toggle it off */
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
int exists = dynamicPaint_outputLayerExists(surface, ob, index);
char *name;
int exists = dynamicPaint_outputLayerExists(surface, ob, output);
const char *name;
if (index == 0)
if (output == 0)
name = surface->output_name;
else if (index == 1)
else
name = surface->output_name2;
/* Vertex Color Layer */
@ -226,8 +225,9 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
}
/* Vertex Weight Layer */
else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
if (!exists)
if (!exists) {
ED_vgroup_add_name(ob, name);
}
else {
bDeformGroup *defgroup = defgroup_find_name(ob, name);
if (defgroup) ED_vgroup_delete(ob, defgroup);
@ -240,7 +240,11 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
void DPAINT_OT_output_toggle(wmOperatorType *ot)
{
PropertyRNA *prop;
static EnumPropertyItem prop_output_toggle_types[] = {
{0, "A", 0, "Output A", ""},
{1, "B", 0, "Output B", ""},
{0, NULL, 0, NULL, NULL}
};
/* identifiers */
ot->name= "Toggle Output Layer";
@ -255,8 +259,7 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_int(ot->srna, "index", 0, 0, 1, "Index", "", 0, 1);
ot->prop= prop;
ot->prop= RNA_def_enum(ot->srna, "output", prop_output_toggle_types, 0, "Output Toggle", "");
}

@ -553,20 +553,20 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Output Path", "Directory to save the textures");
/* output for primary surface data */
prop= RNA_def_property(srna, "output_name", PROP_STRING, PROP_NONE);
prop= RNA_def_property(srna, "output_name_a", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "output_name");
RNA_def_property_ui_text(prop, "Output name", "");
prop= RNA_def_property(srna, "do_output1", PROP_BOOLEAN, PROP_NONE);
prop= RNA_def_property(srna, "use_output_a", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_OUT1);
RNA_def_property_ui_text(prop, "Save layer", "Output name");
/* output for secondary sufrace data */
prop= RNA_def_property(srna, "output_name2", PROP_STRING, PROP_NONE);
prop= RNA_def_property(srna, "output_name_b", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "output_name2");
RNA_def_property_ui_text(prop, "Output name", "Output name");
prop= RNA_def_property(srna, "do_output2", PROP_BOOLEAN, PROP_NONE);
prop= RNA_def_property(srna, "use_output_b", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_OUT2);
RNA_def_property_ui_text(prop, "Save layer", "");
@ -774,7 +774,7 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.00, 5.0, 1, 2);
RNA_def_property_ui_text(prop, "Clamp Waves", "Maximum level of surface intersection used to influence waves. Use 0.0 to disable");
prop= RNA_def_property(srna, "do_smudge", PROP_BOOLEAN, PROP_NONE);
prop= RNA_def_property(srna, "use_smudge", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DO_SMUDGE);
RNA_def_property_ui_text(prop, "Do Smudge", "Makes this brush to smudge existing paint as it moves");
@ -783,7 +783,8 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0, 1.0, 5, 2);
RNA_def_property_ui_text(prop, "Smudge Strength", "Smudge effect strength");
prop= RNA_def_property(srna, "max_velocity", PROP_FLOAT, PROP_NONE);
prop= RNA_def_property(srna, "velocity_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "max_velocity");
RNA_def_property_range(prop, 0.0001, 10.0);
RNA_def_property_ui_range(prop, 0.1, 2.0, 5, 2);
RNA_def_property_ui_text(prop, "Max Velocity", "Velocity considered as maximum influence. (Blender units per frame)");