[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28145] trunk/blender: BGE: TexFace panel (from patch #21780 from Mitchell Stokes + some changes)

Dalai Felinto dfelinto at gmail.com
Mon Apr 12 05:06:49 CEST 2010


Revision: 28145
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28145
Author:   dfelinto
Date:     2010-04-12 05:06:49 +0200 (Mon, 12 Apr 2010)

Log Message:
-----------
BGE: TexFace panel (from patch #21780 from Mitchell Stokes + some changes)
the patch exposes a rna property to get the active edit mode face. This is a hack.
However it's a small patch (a.k.a. easy to revert later if needed).

The official plan is to wait for BMesh before tackling it properly. Nevertheless TexFace panel is really important for BGE.

Missing: operators to copy the current parameters to other selected faces.

* note: what I changed from the original patch is the UI script. The pool wasn't defined and it was using tabs.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_data_mesh.py
    trunk/blender/source/blender/makesrna/intern/rna_mesh.c
    trunk/blender/source/blenderplayer/bad_level_call_stubs/stubs.c

Modified: trunk/blender/release/scripts/ui/properties_data_mesh.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_data_mesh.py	2010-04-12 02:56:41 UTC (rev 28144)
+++ trunk/blender/release/scripts/ui/properties_data_mesh.py	2010-04-12 03:06:49 UTC (rev 28145)
@@ -281,8 +281,54 @@
         lay = me.active_uv_texture
         if lay:
             layout.prop(lay, "name")
+            
+class DATA_PT_texface(DataButtonsPanel):
+    bl_label = "Texture Face"
 
+    def poll(self, context):
+        ob = context.active_object
+        rd = context.scene.render
+        
+        return (context.mode =='EDIT_MESH') and (rd.engine == 'BLENDER_GAME') \
+        and ob and ob.type in ('MESH')
 
+    def draw(self, context):
+        layout = self.layout
+        col = layout.column()
+        
+        wide_ui = context.region.width > narrowui       
+        me = context.mesh
+        
+        tf = me.faces.active_tface
+        
+        if tf:
+            split = layout.split()
+            col = split.column()
+            
+            col.prop(tf, "tex")
+            col.prop(tf, "light")
+            col.prop(tf, "invisible")
+            col.prop(tf, "collision")
+            
+            col.prop(tf, "shared")
+            col.prop(tf, "twoside")
+            col.prop(tf, "object_color")
+            
+            if wide_ui:
+                col = split.column()
+            
+            col.prop(tf, "halo")
+            col.prop(tf, "billboard")
+            col.prop(tf, "shadow")
+            col.prop(tf, "text")
+            col.prop(tf, "alpha_sort")
+            
+            col = layout.column()
+            col.prop(tf, "transp")
+        else:
+            col.label(text="No UV Texture")
+
+
 class DATA_PT_vertex_colors(DataButtonsPanel):
     bl_label = "Vertex Colors"
 
@@ -315,6 +361,7 @@
     DATA_PT_vertex_groups,
     DATA_PT_shape_keys,
     DATA_PT_uv_texture,
+    DATA_PT_texface,
     DATA_PT_vertex_colors,
 
     DATA_PT_custom_props_mesh]

Modified: trunk/blender/source/blender/makesrna/intern/rna_mesh.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_mesh.c	2010-04-12 02:56:41 UTC (rev 28144)
+++ trunk/blender/source/blender/makesrna/intern/rna_mesh.c	2010-04-12 03:06:49 UTC (rev 28145)
@@ -46,6 +46,8 @@
 #include "BKE_mesh.h"
 #include "BKE_utildefines.h"
 
+#include "ED_mesh.h" /* XXX Bad level call */
+
 #include "WM_api.h"
 #include "WM_types.h"
 
@@ -458,6 +460,22 @@
 	*max= MAX2(0, *max);
 }
 
+static PointerRNA rna_Mesh_active_mtface_get(PointerRNA *ptr)
+{
+	Mesh *me= (Mesh*)ptr->data;
+	EditMesh *em= BKE_mesh_get_editmesh(me);
+	MTFace *tf;
+
+	if (em && EM_texFaceCheck(em))
+	{
+		tf = EM_get_active_mtface(em, NULL, NULL, 1);
+
+		return rna_pointer_inherit_refine(ptr, &RNA_MeshTextureFace, tf);
+	}
+
+	return rna_pointer_inherit_refine(ptr, &RNA_MeshTextureFace, NULL);
+}
+
 static void rna_MeshTextureFace_uv1_get(PointerRNA *ptr, float *values)
 {
 	MTFace *mtface= (MTFace*)ptr->data;
@@ -1599,6 +1617,12 @@
 	prop= RNA_def_property(srna, "active", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "act_face");
 	RNA_def_property_ui_text(prop, "Active Face", "The active face for this mesh");
+
+	prop= RNA_def_property(srna, "active_tface", PROP_POINTER, PROP_UNSIGNED);
+	RNA_def_property_struct_type(prop, "MeshTextureFace");
+	RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_mtface_get", NULL, NULL);
+	RNA_def_property_ui_text(prop, "Active Texture Face", "Active Texture Face");
+	RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
 }
 
 

Modified: trunk/blender/source/blenderplayer/bad_level_call_stubs/stubs.c
===================================================================
--- trunk/blender/source/blenderplayer/bad_level_call_stubs/stubs.c	2010-04-12 02:56:41 UTC (rev 28144)
+++ trunk/blender/source/blenderplayer/bad_level_call_stubs/stubs.c	2010-04-12 03:06:49 UTC (rev 28145)
@@ -248,6 +248,8 @@
 void ED_space_image_size(struct SpaceImage *sima, int *width, int *height){}
 
 void EM_selectmode_set(struct EditMesh *em){}
+int EM_texFaceCheck(struct EditMesh *em){return 0;}
+struct MTFace *EM_get_active_mtface(struct EditMesh *em, struct EditFace **act_efa, struct MCol **mcol, int sloopy){return (struct MTFace *)NULL;}
 void make_editMesh(struct Scene *scene, struct Object *ob){}
 void load_editMesh(struct Scene *scene, struct Object *ob){}
 





More information about the Bf-blender-cvs mailing list