[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29120] branches/soc-2010-moguri: A couple of small changes:
Mitchell Stokes
mogurijin at gmail.com
Tue Jun 1 09:41:00 CEST 2010
Revision: 29120
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29120
Author: moguri
Date: 2010-06-01 09:41:00 +0200 (Tue, 01 Jun 2010)
Log Message:
-----------
A couple of small changes:
* Adding the ability to change the uniform type (not all types are in the list yet).
* Adding the ability to remove uniforms
Modified Paths:
--------------
branches/soc-2010-moguri/release/scripts/ui/properties_material.py
branches/soc-2010-moguri/source/blender/editors/render/render_ops.c
branches/soc-2010-moguri/source/blender/editors/render/render_shading.c
branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h
branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c
Modified: branches/soc-2010-moguri/release/scripts/ui/properties_material.py
===================================================================
--- branches/soc-2010-moguri/release/scripts/ui/properties_material.py 2010-06-01 06:18:17 UTC (rev 29119)
+++ branches/soc-2010-moguri/release/scripts/ui/properties_material.py 2010-06-01 07:41:00 UTC (rev 29120)
@@ -804,12 +804,19 @@
col.prop(mat, "geometry_input")
col.prop(mat, "geometry_output")
- col.template_list(mat, "uniforms", mat, "active_uniform_index")
+ row = layout.row()
+ col = row.column()
+ col.template_list(mat, "uniforms", mat, "active_uniform_index")
+ col = row.column(align=True)
col.operator("material.uniform_add", icon='ZOOMIN', text="")
+ col.operator("material.uniform_remove", icon='ZOOMOUT', text="").index = mat.active_uniform_index
lay = mat.active_uniform
if lay:
- layout.prop(lay, "name")
+ row = layout.row()
+ #layout.label(text="")
+ row.prop(lay, "name")
+ row.prop(lay, "type", text="")
class VolumeButtonsPanel(bpy.types.Panel):
bl_space_type = 'PROPERTIES'
Modified: branches/soc-2010-moguri/source/blender/editors/render/render_ops.c
===================================================================
--- branches/soc-2010-moguri/source/blender/editors/render/render_ops.c 2010-06-01 06:18:17 UTC (rev 29119)
+++ branches/soc-2010-moguri/source/blender/editors/render/render_ops.c 2010-06-01 07:41:00 UTC (rev 29120)
@@ -54,6 +54,7 @@
WM_operatortype_append(MATERIAL_OT_copy);
WM_operatortype_append(MATERIAL_OT_paste);
WM_operatortype_append(MATERIAL_OT_uniform_add);
+ WM_operatortype_append(MATERIAL_OT_uniform_remove);
WM_operatortype_append(SCENE_OT_render_layer_add);
WM_operatortype_append(SCENE_OT_render_layer_remove);
Modified: branches/soc-2010-moguri/source/blender/editors/render/render_shading.c
===================================================================
--- branches/soc-2010-moguri/source/blender/editors/render/render_shading.c 2010-06-01 06:18:17 UTC (rev 29119)
+++ branches/soc-2010-moguri/source/blender/editors/render/render_shading.c 2010-06-01 07:41:00 UTC (rev 29120)
@@ -1072,6 +1072,38 @@
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+static int uniform_remove_exec(bContext *C, wmOperator *op)
+{
+ Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+ CustomUniform *cu;
+ int index= RNA_int_get(op->ptr, "index");
+
+ cu= BLI_findlink(&ma->csi.uniforms, index);
+
+ if(cu) {
+ BLI_remlink(&ma->csi.uniforms, cu);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void MATERIAL_OT_uniform_remove(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Remove Uniform";
+ ot->idname= "MATERIAL_OT_uniform_remove";
+
+ /* api callbacks */
+ ot->exec= uniform_remove_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Uniform index to remove ", 0, INT_MAX);
+}
+
static short mtexcopied=0; /* must be reset on file load */
static MTex mtexcopybuf;
Modified: branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h 2010-06-01 06:18:17 UTC (rev 29119)
+++ branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h 2010-06-01 07:41:00 UTC (rev 29120)
@@ -76,7 +76,7 @@
struct CustomUniform *next, *prev;
char name[64];
short type, pad[3];
- //void *data;
+ void *data;
} CustomUniform;
typedef struct CustomShaderInfo {
@@ -228,6 +228,16 @@
#define MA_CS_GEOM_OUT_LINE_STRIP 2
#define MA_CS_GEOM_OUT_TRIANGLE_STRIP 4
+/* Uniform type */
+#define MA_UNF_FLOAT 1
+#define MA_UNF_VEC2 2
+#define MA_UNF_VEC3 3
+#define MA_UNF_VEC4 4
+#define MA_UNF_INT 5
+#define MA_UNF_IVEC2 6
+#define MA_UNF_IVEC3 7
+#define MA_UNF_IVEC4 8
+
/* mode (is int) */
#define MA_TRACEBLE 1
#define MA_SHADOW 2
Modified: branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c
===================================================================
--- branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c 2010-06-01 06:18:17 UTC (rev 29119)
+++ branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c 2010-06-01 07:41:00 UTC (rev 29120)
@@ -915,7 +915,6 @@
prop= RNA_def_property(srna, "active_uniform", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "CustomUniform");
RNA_def_property_pointer_funcs(prop, "rna_Material_active_uniform_get", "rna_Material_active_uniform_set", NULL);
- //RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active Uniform", "");
RNA_def_property_update(prop, 0, "rna_Material_update");
@@ -931,6 +930,17 @@
StructRNA *srna;
PropertyRNA *prop;
+ static EnumPropertyItem prop_type_items[] = {
+ {MA_UNF_FLOAT, "FLOAT", 0, "float", "float"},
+ {MA_UNF_VEC2, "VEC2", 0, "vec2", "vec2"},
+ {MA_UNF_VEC3, "VEC3", 0, "vec3", "vec3"},
+ {MA_UNF_VEC4, "VEC4", 0, "vec4", "vec4"},
+ {MA_UNF_INT, "INT", 0, "int", "int"},
+ {MA_UNF_IVEC2, "IVEC2", 0, "ivec2", "ivec2"},
+ {MA_UNF_IVEC3, "IVEC3", 0, "ivec3", "ivec3"},
+ {MA_UNF_IVEC4, "IVEC4", 0, "ivec4", "ivec4"},
+ {0, NULL, 0, NULL, NULL}};
+
srna= RNA_def_struct(brna, "CustomUniform", NULL);
RNA_def_struct_sdna(srna, "CustomUniform");
RNA_def_struct_nested(brna, srna, "Material");
@@ -941,6 +951,12 @@
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "Name", "The name of the uniform");
RNA_def_property_update(prop, 0, "rna_Material_update");
+
+ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type");
+ RNA_def_property_enum_items(prop, prop_type_items);
+ RNA_def_property_ui_text(prop, "Uniform type", "The data type of the uniform");
+ RNA_def_property_update(prop, 0, "rna_Material_update");
}
static void rna_def_material_raymirror(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list