[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54115] trunk/blender/source/gameengine/ Converter/BL_BlenderDataConversion.cpp: BGE bugfix: Material initial object color working in the game

Dalai Felinto dfelinto at gmail.com
Sun Jan 27 00:52:55 CET 2013


Revision: 54115
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54115
Author:   dfelinto
Date:     2013-01-26 23:52:55 +0000 (Sat, 26 Jan 2013)
Log Message:
-----------
BGE bugfix: Material initial object color working in the game
The object color option in the materials always worked, however the initial color of the object
was never passed to the game.

We are now passing it only, only when the object's mesh has a material that has ((shade_flags & OB_COLOR)).
There reason to not always set the object color is probably due to performance (the m_bUseObjectColor
flag in KX_GameObject). This patch still respect that.

Bug report from Mike Pan, as part of our book nitty-gritties review work.
Bugfix during Vancouver Global Game Jam :)

Modified Paths:
--------------
    trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp

Modified: trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2013-01-26 23:52:41 UTC (rev 54114)
+++ trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2013-01-26 23:52:55 UTC (rev 54115)
@@ -1973,6 +1973,22 @@
 			((ob->gameflag2 & OB_NEVER_DO_ACTIVITY_CULLING)!=0);
 		gameobj->SetIgnoreActivityCulling(ignoreActivityCulling);
 		gameobj->SetOccluder((ob->gameflag & OB_OCCLUDER) != 0, false);
+
+		// we only want obcolor used if there is a material in the mesh
+		// that requires it
+		Material *mat= NULL;
+		bool bUseObjectColor=false;
+		
+		for (int i=0;i<mesh->totcol;i++) {
+			mat=mesh->mat[i];
+			if (!mat) break;
+			if ((mat->shade_flag &= MA_OBCOLOR)) {
+				bUseObjectColor = true;
+				break;
+			}
+		}
+		if (bUseObjectColor)
+			gameobj->SetObjectColor(ob->col);
 	
 		// two options exists for deform: shape keys and armature
 		// only support relative shape key




More information about the Bf-blender-cvs mailing list