[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29867] branches/soc-2010-moguri: Created an operator to update the material.

Mitchell Stokes mogurijin at gmail.com
Fri Jul 2 11:47:10 CEST 2010


Revision: 29867
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29867
Author:   moguri
Date:     2010-07-02 11:47:10 +0200 (Fri, 02 Jul 2010)

Log Message:
-----------
Created an operator to update the material. I used this new operator to create a "Reload Shaders" button.

Modified Paths:
--------------
    branches/soc-2010-moguri/release/scripts/ui/properties_material.py
    branches/soc-2010-moguri/source/blender/editors/render/render_intern.h
    branches/soc-2010-moguri/source/blender/editors/render/render_ops.c
    branches/soc-2010-moguri/source/blender/editors/render/render_shading.c

Modified: branches/soc-2010-moguri/release/scripts/ui/properties_material.py
===================================================================
--- branches/soc-2010-moguri/release/scripts/ui/properties_material.py	2010-07-02 09:15:00 UTC (rev 29866)
+++ branches/soc-2010-moguri/release/scripts/ui/properties_material.py	2010-07-02 09:47:10 UTC (rev 29867)
@@ -803,6 +803,8 @@
 
         col.prop(mat, "geometry_input")
         col.prop(mat, "geometry_output")
+
+        col.operator("material.force_update", text="Reload Shaders")
 		
         row = layout.row()
         col = row.column()

Modified: branches/soc-2010-moguri/source/blender/editors/render/render_intern.h
===================================================================
--- branches/soc-2010-moguri/source/blender/editors/render/render_intern.h	2010-07-02 09:15:00 UTC (rev 29866)
+++ branches/soc-2010-moguri/source/blender/editors/render/render_intern.h	2010-07-02 09:47:10 UTC (rev 29867)
@@ -49,6 +49,7 @@
 void MATERIAL_OT_paste(struct wmOperatorType *ot);
 void MATERIAL_OT_uniform_add(struct wmOperatorType *ot);
 void MATERIAL_OT_uniform_remove(struct wmOperatorType *ot);
+void MATERIAL_OT_force_update(struct wmOperatorType *ot);
 
 void SCENE_OT_render_layer_add(struct wmOperatorType *ot);
 void SCENE_OT_render_layer_remove(struct wmOperatorType *ot);

Modified: branches/soc-2010-moguri/source/blender/editors/render/render_ops.c
===================================================================
--- branches/soc-2010-moguri/source/blender/editors/render/render_ops.c	2010-07-02 09:15:00 UTC (rev 29866)
+++ branches/soc-2010-moguri/source/blender/editors/render/render_ops.c	2010-07-02 09:47:10 UTC (rev 29867)
@@ -55,6 +55,7 @@
 	WM_operatortype_append(MATERIAL_OT_paste);
 	WM_operatortype_append(MATERIAL_OT_uniform_add);
 	WM_operatortype_append(MATERIAL_OT_uniform_remove);
+	WM_operatortype_append(MATERIAL_OT_force_update);
 
 	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-07-02 09:15:00 UTC (rev 29866)
+++ branches/soc-2010-moguri/source/blender/editors/render/render_shading.c	2010-07-02 09:47:10 UTC (rev 29867)
@@ -1102,6 +1102,33 @@
 	RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Uniform index to remove ", 0, INT_MAX);
 }
 
+static int force_update_exec(bContext *C, wmOperator *op)
+{
+	Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+	Scene *scene= CTX_data_pointer_get_type(C, "scene", &RNA_Scene).data;
+
+	DAG_id_flush_update(&ma->id, 0);
+	if(scene->gm.matmode == GAME_MAT_GLSL)
+		WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, ma);
+	else
+		WM_main_add_notifier(NC_MATERIAL|ND_SHADING, ma);
+
+	return OPERATOR_FINISHED;
+}
+
+void MATERIAL_OT_force_update(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Force Material Update";
+	ot->idname= "MATERIAL_OT_force_update";
+
+	/* api callbacks */
+	ot->exec= force_update_exec;
+
+	/* flags */
+	ot->flag= OPTYPE_REGISTER;
+}
+
 static short mtexcopied=0; /* must be reset on file load */
 static MTex mtexcopybuf;
 





More information about the Bf-blender-cvs mailing list