[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49053] branches/ge_harmony/source/blender /makesrna/intern/rna_shader.c: Fixing up the shader RNA to avoid reparsing a shader file when it wasn' t needed.
Daniel Stokes
kupomail at gmail.com
Thu Jul 19 06:02:03 CEST 2012
Revision: 49053
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49053
Author: kupoman
Date: 2012-07-19 04:02:02 +0000 (Thu, 19 Jul 2012)
Log Message:
-----------
Fixing up the shader RNA to avoid reparsing a shader file when it wasn't needed. The shader now updates in the viewport automatically when it's values are changed.
Modified Paths:
--------------
branches/ge_harmony/source/blender/makesrna/intern/rna_shader.c
Modified: branches/ge_harmony/source/blender/makesrna/intern/rna_shader.c
===================================================================
--- branches/ge_harmony/source/blender/makesrna/intern/rna_shader.c 2012-07-18 23:27:10 UTC (rev 49052)
+++ branches/ge_harmony/source/blender/makesrna/intern/rna_shader.c 2012-07-19 04:02:02 UTC (rev 49053)
@@ -38,19 +38,34 @@
#include "WM_types.h"
#include "BKE_depsgraph.h"
#include "DNA_scene_types.h"
+#include "DNA_material_types.h"
-static void rna_Shader_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
+static void rna_Shader_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Shader *sh = ptr->id.data;
+ Material *ma;
+ CustomShader *cs;
DAG_id_tag_update(&sh->id, 0);
+ for (ma = bmain->mat.first; ma; ma = ma->id.next) {
+ for (cs = ma->custom_shaders.first; cs; cs = cs->next) {
+ if (strcmp(cs->shader->id.name, sh->id.name) == 0) {
+ DAG_id_tag_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);
+ }
+ }
+ }
+}
+
+static void rna_Shader_source_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ Shader *sh = ptr->id.data;
BKE_shader_read_source(sh);
-
- //if(scene->gm.matmode == GAME_MAT_GLSL)
- // WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, sh);
- //else
- // WM_main_add_notifier(NC_MATERIAL|ND_SHADING, sh);
+ rna_Shader_update(bmain, scene, ptr);
}
static int rna_IntUniform_value_get(struct PointerRNA *ptr)
@@ -277,7 +292,7 @@
RNA_def_property_enum_sdna(prop, NULL, "location");
RNA_def_property_enum_items(prop, prop_shader_loc_items);
RNA_def_property_ui_text(prop, "Location", "Location of the shader to use");
- RNA_def_property_update(prop, 0, "rna_Shader_update");
+ RNA_def_property_update(prop, 0, "rna_Shader_source_update");
prop = RNA_def_property(srna, "filter_location", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "location");
@@ -290,12 +305,12 @@
RNA_def_property_struct_type(prop, "Text");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Source", "The shader text to use");
- RNA_def_property_update(prop, 0, "rna_Shader_update");
+ RNA_def_property_update(prop, 0, "rna_Shader_source_update");
prop = RNA_def_property(srna, "source_path", PROP_STRING, PROP_FILEPATH);
RNA_def_property_string_sdna(prop, NULL, "sourcepath");
RNA_def_property_ui_text(prop, "Source", "The path to the shader to use");
- RNA_def_property_update(prop, 0, "rna_Shader_update");
+ RNA_def_property_update(prop, 0, "rna_Shader_source_update");
prop= RNA_def_property(srna, "uniforms", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "uniforms", NULL);
More information about the Bf-blender-cvs
mailing list