[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22302] branches/blender2.5/blender: Added material game physics options in RNA and layout.

William Reynish william at reynish.com
Fri Aug 7 21:14:51 CEST 2009


Revision: 22302
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22302
Author:   billrey
Date:     2009-08-07 21:14:49 +0200 (Fri, 07 Aug 2009)

Log Message:
-----------
Added material game physics options in RNA and layout. 

Thanks to the new render API system these options don't clutter up the layout when you're not doing games.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_material.py
    branches/blender2.5/blender/source/blender/makesdna/DNA_material_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_material.c

Modified: branches/blender2.5/blender/release/ui/buttons_material.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_material.py	2009-08-07 16:20:19 UTC (rev 22301)
+++ branches/blender2.5/blender/release/ui/buttons_material.py	2009-08-07 19:14:49 UTC (rev 22302)
@@ -141,6 +141,28 @@
 		sub.active = tan.surface_diffuse
 		sub.itemR(tan, "blend_distance", text="Distance")
 		
+class MATERIAL_PT_physics(MaterialButtonsPanel):
+	__label__ = "Physics"
+	COMPAT_ENGINES = set(['BLENDER_GAME'])
+	
+	def draw(self, context):
+		layout = self.layout
+		
+		mat = context.material
+		phys = mat.physics
+		
+		split = layout.split()
+		
+		col = split.column()
+		col.itemR(phys, "distance")
+		col.itemR(phys, "friction")
+		col.itemR(phys, "align_to_normal")
+		
+		col = split.column()
+		col.itemR(phys, "force", slider=True)
+		col.itemR(phys, "elasticity", slider=True)
+		col.itemR(phys, "damp", slider=True)
+		
 class MATERIAL_PT_options(MaterialButtonsPanel):
 	__label__ = "Options"
 	COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
@@ -515,6 +537,7 @@
 bpy.types.register(MATERIAL_PT_raytransp)
 bpy.types.register(MATERIAL_PT_sss)
 bpy.types.register(MATERIAL_PT_halo)
+bpy.types.register(MATERIAL_PT_physics)
 bpy.types.register(MATERIAL_PT_strand)
 bpy.types.register(MATERIAL_PT_options)
 bpy.types.register(MATERIAL_PT_shadows)

Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_material_types.h	2009-08-07 16:20:19 UTC (rev 22301)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_material_types.h	2009-08-07 19:14:49 UTC (rev 22302)
@@ -224,7 +224,7 @@
 #define MA_SPEC_WARDISO		4
 
 /* dynamode */
-#define MA_DRAW_DYNABUTS    1
+#define MA_DRAW_DYNABUTS    1		/* deprecated */
 #define MA_FH_NOR	        2
 
 /* ramps */

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_material.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_material.c	2009-08-07 16:20:19 UTC (rev 22301)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_material.c	2009-08-07 19:14:49 UTC (rev 22302)
@@ -66,6 +66,11 @@
 	return rna_pointer_inherit_refine(ptr, &RNA_MaterialStrand, ptr->id.data);
 }
 
+static PointerRNA rna_Material_physics_get(PointerRNA *ptr)
+{
+	return rna_pointer_inherit_refine(ptr, &RNA_MaterialPhysics, ptr->id.data);
+}
+
 static void rna_Material_type_set(PointerRNA *ptr, int value)
 {
 	Material *ma= (Material*)ptr->data;
@@ -1123,6 +1128,46 @@
 	RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 }
 
+void rna_def_material_physics(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+	
+	srna= RNA_def_struct(brna, "MaterialPhysics", NULL);
+	RNA_def_struct_sdna(srna, "Material");
+	RNA_def_struct_nested(brna, srna, "Material");
+	RNA_def_struct_ui_text(srna, "Material Physics", "Physics settings for a Material datablock.");
+	
+	prop= RNA_def_property(srna, "align_to_normal", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FH_NOR);
+	RNA_def_property_ui_text(prop, "Align to Normal", "Align dynamic game objects along the surface normal, when inside the physics distance area");
+	
+	prop= RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "friction");
+	RNA_def_property_range(prop, 0, 100);
+	RNA_def_property_ui_text(prop, "Friction", "Coulomb friction coeffecient, when inside the physics distance area");
+
+	prop= RNA_def_property(srna, "force", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "fh");
+	RNA_def_property_range(prop, 0, 1);
+	RNA_def_property_ui_text(prop, "Force", "Upward spring force, when inside the physics distance area");
+	
+	prop= RNA_def_property(srna, "elasticity", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "reflect");
+	RNA_def_property_range(prop, 0, 1);
+	RNA_def_property_ui_text(prop, "Elasticity", "Elasticity of collisions");
+	
+	prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "fhdist");
+	RNA_def_property_range(prop, 0, 20);
+	RNA_def_property_ui_text(prop, "Distance", "Distance of the physics area");
+	
+	prop= RNA_def_property(srna, "damp", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "xyfrict");
+	RNA_def_property_range(prop, 0, 1);
+	RNA_def_property_ui_text(prop, "Damping", "Damping of the spring force, when inside the physics distance area");
+}
+
 void RNA_def_material(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -1322,6 +1367,11 @@
 	RNA_def_property_struct_type(prop, "MaterialStrand");
 	RNA_def_property_pointer_funcs(prop, "rna_Material_strand_get", NULL, NULL);
 	RNA_def_property_ui_text(prop, "Strand", "Strand settings for the material.");
+	
+	prop= RNA_def_property(srna, "physics", PROP_POINTER, PROP_NEVER_NULL);
+	RNA_def_property_struct_type(prop, "MaterialPhysics");
+	RNA_def_property_pointer_funcs(prop, "rna_Material_physics_get", NULL, NULL);
+	RNA_def_property_ui_text(prop, "Physics", "Game physics settings.");
 
 	/* nodetree */
 	prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
@@ -1344,6 +1394,7 @@
 	rna_def_material_sss(brna);
 	rna_def_material_mtex(brna);
 	rna_def_material_strand(brna);
+	rna_def_material_physics(brna);
 }
 
 void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *structname)





More information about the Bf-blender-cvs mailing list