[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28945] branches/soc-2010-moguri/source/ blender: Moved the custom shader information to it' s own struct in DNA_material_types.h: CustomShaderInfo.

Mitchell Stokes mogurijin at gmail.com
Mon May 24 04:23:09 CEST 2010


Revision: 28945
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28945
Author:   moguri
Date:     2010-05-24 04:23:04 +0200 (Mon, 24 May 2010)

Log Message:
-----------
Moved the custom shader information to it's own struct in DNA_material_types.h: CustomShaderInfo. I'm not yet sure if this is better or not than the way it was previously. However, it does offer more flexibility for letting CustomShaderInfo grow.

Modified Paths:
--------------
    branches/soc-2010-moguri/source/blender/blenkernel/intern/material.c
    branches/soc-2010-moguri/source/blender/blenloader/intern/readfile.c
    branches/soc-2010-moguri/source/blender/blenloader/intern/writefile.c
    branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.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/source/blender/blenkernel/intern/material.c
===================================================================
--- branches/soc-2010-moguri/source/blender/blenkernel/intern/material.c	2010-05-24 02:05:23 UTC (rev 28944)
+++ branches/soc-2010-moguri/source/blender/blenkernel/intern/material.c	2010-05-24 02:23:04 UTC (rev 28945)
@@ -86,9 +86,9 @@
 	if(ma->ramp_col) MEM_freeN(ma->ramp_col);
 	if(ma->ramp_spec) MEM_freeN(ma->ramp_spec);
 
-	if(ma->vert_text) MEM_freeN(ma->vert_text);
-	if(ma->frag_text) MEM_freeN(ma->frag_text);
-	if(ma->geom_text) MEM_freeN(ma->geom_text);
+	if(ma->csi.vert_text) MEM_freeN(ma->csi.vert_text);
+	if(ma->csi.frag_text) MEM_freeN(ma->csi.frag_text);
+	if(ma->csi.geom_text) MEM_freeN(ma->csi.geom_text);
 	
 	BKE_free_animdata((ID *)ma);
 	
@@ -192,7 +192,7 @@
 	ma->shade_flag= MA_APPROX_OCCLUSION;
 	ma->preview = NULL;
 
-	ma->cs_flag= 0;
+	ma->csi.flag= 0;
 }
 
 Material *add_material(char *name)

Modified: branches/soc-2010-moguri/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2010-moguri/source/blender/blenloader/intern/readfile.c	2010-05-24 02:05:23 UTC (rev 28944)
+++ branches/soc-2010-moguri/source/blender/blenloader/intern/readfile.c	2010-05-24 02:23:04 UTC (rev 28945)
@@ -2903,9 +2903,9 @@
 	ma->ramp_col= newdataadr(fd, ma->ramp_col);
 	ma->ramp_spec= newdataadr(fd, ma->ramp_spec);
 
-	ma->vert_text= newlibadr(fd, ma->id.lib, ma->vert_text);
-	ma->frag_text= newlibadr(fd, ma->id.lib, ma->frag_text);
-	ma->geom_text= newlibadr(fd, ma->id.lib, ma->geom_text);
+	ma->csi.vert_text= newlibadr(fd, ma->id.lib, ma->csi.vert_text);
+	ma->csi.frag_text= newlibadr(fd, ma->id.lib, ma->csi.frag_text);
+	ma->csi.geom_text= newlibadr(fd, ma->id.lib, ma->csi.geom_text);
 	
 	ma->nodetree= newdataadr(fd, ma->nodetree);
 	if(ma->nodetree)
@@ -11389,9 +11389,9 @@
 	
 	expand_doit(fd, mainvar, ma->ipo); // XXX depreceated - old animation system
 
-	expand_doit(fd, mainvar, ma->vert_text);
+	/*expand_doit(fd, mainvar, ma->vert_text);
 	expand_doit(fd, mainvar, ma->frag_text);
-	expand_doit(fd, mainvar, ma->geom_text);
+	expand_doit(fd, mainvar, ma->geom_text);*/
 	
 	if(ma->adt)
 		expand_animdata(fd, mainvar, ma->adt);

Modified: branches/soc-2010-moguri/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2010-moguri/source/blender/blenloader/intern/writefile.c	2010-05-24 02:05:23 UTC (rev 28944)
+++ branches/soc-2010-moguri/source/blender/blenloader/intern/writefile.c	2010-05-24 02:23:04 UTC (rev 28945)
@@ -1703,9 +1703,9 @@
 			if(ma->ramp_col) writestruct(wd, DATA, "ColorBand", 1, ma->ramp_col);
 			if(ma->ramp_spec) writestruct(wd, DATA, "ColorBand", 1, ma->ramp_spec);
 
-			if(ma->vert_text) writestruct(wd, DATA, "Text", 1, ma->vert_text);
-			if(ma->frag_text) writestruct(wd, DATA, "Text", 1, ma->frag_text);
-			if(ma->geom_text) writestruct(wd, DATA, "Text", 1, ma->geom_text);
+			if(ma->csi.vert_text) writestruct(wd, DATA, "Text", 1, ma->csi.vert_text);
+			if(ma->csi.frag_text) writestruct(wd, DATA, "Text", 1, ma->csi.frag_text);
+			if(ma->csi.geom_text) writestruct(wd, DATA, "Text", 1, ma->csi.geom_text);
 			
 			/* nodetree is integral part of material, no libdata */
 			if(ma->nodetree) {

Modified: branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.c
===================================================================
--- branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.c	2010-05-24 02:05:23 UTC (rev 28944)
+++ branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.c	2010-05-24 02:23:04 UTC (rev 28945)
@@ -217,28 +217,28 @@
 		char *frag=NULL, *vert=NULL, *geom=NULL;
 
 		// Gather information on custom shaders
-		if (material->ma->cs_flag & MA_CS_USE_EXTERNAL)
+		if (material->ma->csi.flag & MA_CS_USE_EXTERNAL)
 		{
 			// Load files
-			if (strcmp(material->ma->vertex_shader, ""))
+			if (strcmp(material->ma->csi.vertex_shader, ""))
 			{
-				vert = gpu_load_shader(material->ma->vertex_shader);
+				vert = gpu_load_shader(material->ma->csi.vertex_shader);
 
 				if (!vert)
 					printf("Error opening vertex shader\n");
 			}
 
-			if (strcmp(material->ma->fragment_shader, ""))
+			if (strcmp(material->ma->csi.fragment_shader, ""))
 			{
-				frag = gpu_load_shader(material->ma->fragment_shader);
+				frag = gpu_load_shader(material->ma->csi.fragment_shader);
 
 				if (!frag)
 					printf("Error opening fragment shader\n");
 			}		
 				
-			if (strcmp(material->ma->geometry_shader, ""))
+			if (strcmp(material->ma->csi.geometry_shader, ""))
 			{
-				geom = gpu_load_shader(material->ma->geometry_shader);
+				geom = gpu_load_shader(material->ma->csi.geometry_shader);
 
 				if (!geom)
 					printf("Error opening geometry shader\n");
@@ -247,25 +247,25 @@
 		else
 		{
 			// Use Text datablocks
-			if (material->ma->vert_text)
+			if (material->ma->csi.vert_text)
 			{
-				vert = txt_to_buf(material->ma->vert_text);
+				vert = txt_to_buf(material->ma->csi.vert_text);
 
 				if (!vert)
 					printf("Error?\n");
 			}
 
-			if (material->ma->frag_text)
+			if (material->ma->csi.frag_text)
 			{
-				frag = txt_to_buf(material->ma->frag_text);
+				frag = txt_to_buf(material->ma->csi.frag_text);
 
 				if (!frag)
 					printf("Error?\n");
 			}
 
-			if (material->ma->geom_text)
+			if (material->ma->csi.geom_text)
 			{
-				geom = txt_to_buf(material->ma->geom_text);
+				geom = txt_to_buf(material->ma->csi.geom_text);
 
 				if (!geom)
 					printf("Error?\n");

Modified: branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h	2010-05-24 02:05:23 UTC (rev 28944)
+++ branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h	2010-05-24 02:23:04 UTC (rev 28945)
@@ -72,6 +72,18 @@
 	float ms_spread;
 } VolumeSettings;
 
+typedef struct CustomShaderInfo {
+	char vertex_shader[64];
+	char fragment_shader[64];
+	char geometry_shader[64];
+
+	struct Text *vert_text;
+	struct Text *frag_text;
+	struct Text *geom_text;
+
+	short flag, pad[3];
+} CustomShaderInfo;
+
 typedef struct Material {
 	ID id;
 	struct AnimData *adt;	/* animation data (must be immediately after id for utilities to use it) */ 
@@ -130,14 +142,9 @@
 	float rms;
 	float darkness;
 	short texco, mapto;
-	char vertex_shader[64];
-	char fragment_shader[64];
-	char geometry_shader[64];
+	
+	struct CustomShaderInfo csi;
 
-	struct Text *vert_text;
-	struct Text *frag_text;
-	struct Text *geom_text;
-	
 	/* ramp colors */
 	struct ColorBand *ramp_col;
 	struct ColorBand *ramp_spec;
@@ -166,7 +173,6 @@
 
 	int mapto_textured;	/* render-time cache to optimise texture lookups */
 	int pad4;
-	short cs_flag, cs_pad[3];
 
 	ListBase gpumaterial;		/* runtime */
 } Material;

Modified: branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c
===================================================================
--- branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c	2010-05-24 02:05:23 UTC (rev 28944)
+++ branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c	2010-05-24 02:23:04 UTC (rev 28945)
@@ -808,6 +808,54 @@
 	RNA_def_property_update(prop, 0, "rna_Material_update");
 }
 
+static void rna_def_material_custom_shaders(StructRNA *srna)
+{
+	PropertyRNA *prop;
+
+	//RNA_def_struct_sdna_from(srna, "CustomShaderInfo", "csi");
+
+	prop= RNA_def_property(srna, "vertex_text", PROP_POINTER, PROP_NONE);
+	RNA_def_property_pointer_sdna(prop, NULL, "csi.vert_text");
+	RNA_def_property_struct_type(prop, "Text");
+	RNA_def_property_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Vertex Shader", "A custom GLSL vertex shader in a text block");
+	RNA_def_property_update(prop, 0, "rna_Material_update");
+
+	prop= RNA_def_property(srna, "geometry_text", PROP_POINTER, PROP_NONE);
+	RNA_def_property_pointer_sdna(prop, NULL, "csi.geom_text");
+	RNA_def_property_struct_type(prop, "Text");
+	RNA_def_property_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Geometry Shader", "A custom GLSL geometry shader in a text block");
+	RNA_def_property_update(prop, 0, "rna_Material_update");
+
+	prop= RNA_def_property(srna, "fragment_text", PROP_POINTER, PROP_NONE);
+	RNA_def_property_pointer_sdna(prop, NULL, "csi.frag_text");
+	RNA_def_property_struct_type(prop, "Text");
+	RNA_def_property_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Fragment Shader", "A custom GLSL fragment shader in a text block");
+	RNA_def_property_update(prop, 0, "rna_Material_update");
+
+	prop= RNA_def_property(srna, "use_external_shaders", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "csi.flag", MA_CS_USE_EXTERNAL);
+	RNA_def_property_ui_text(prop, "Use External Shaders", "Use shaders from files instead of text datablocks.");
+	RNA_def_property_update(prop, 0, "rna_Material_update");
+
+	prop= RNA_def_property(srna, "fragment_shader", PROP_STRING, PROP_NONE);
+	RNA_def_property_string_sdna(prop, NULL, "csi.fragment_shader");
+	RNA_def_property_ui_text(prop, "Fragment Shader", "A custom GLSL fragment shader to use");
+	RNA_def_property_update(prop, 0, "rna_Material_update");
+
+	prop= RNA_def_property(srna, "vertex_shader", PROP_STRING, PROP_NONE);
+	RNA_def_property_string_sdna(prop, NULL, "csi.vertex_shader");
+	RNA_def_property_ui_text(prop, "Vertex Shader", "A custom GLSL vertex shader to use");
+	RNA_def_property_update(prop, 0, "rna_Material_update");
+
+	prop= RNA_def_property(srna, "geometry_shader", PROP_STRING, PROP_NONE);
+	RNA_def_property_string_sdna(prop, NULL, "csi.geometry_shader");
+	RNA_def_property_ui_text(prop, "Geometry Shader", "A custom GLSL geometry shader to use");
+	RNA_def_property_update(prop, 0, "rna_Material_update");
+}
+
 static void rna_def_material_raymirror(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -1508,47 +1556,6 @@
 	RNA_def_property_enum_funcs(prop, NULL, "rna_Material_type_set", NULL);
 	RNA_def_property_update(prop, 0, "rna_Material_draw_update");
 
-	prop= RNA_def_property(srna, "vertex_text", PROP_POINTER, PROP_NONE);
-	RNA_def_property_pointer_sdna(prop, NULL, "vert_text");
-	RNA_def_property_struct_type(prop, "Text");
-	RNA_def_property_flag(prop, PROP_EDITABLE);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list