Revision: 49012
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49012
Author: moguri
Date: 2012-07-18 03:56:42 +0000 (Wed, 18 Jul 2012)
Log Message:
-----------
Fix for [#18146] "gap in texture stack with multi UV in GE with GLSL" reported
by Hubert Niecko (szczuro). Places that would check texture slots now check all
the slots, not just the first few. This makes the code more flexible at a
slight (and probably negligible) performance hit.
I'm committing this to Swiss instead of trunk because the fix works off of the
multi-UV code present in Swiss.
Modified Paths:
--------------
branches/soc-2012-swiss_cheese/source/gameengine/Converter/BL_BlenderDataConversion.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Material.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Material.h
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
Modified:
branches/soc-2012-swiss_cheese/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
---
branches/soc-2012-swiss_cheese/source/gameengine/Converter/BL_BlenderDataConversion.cpp
2012-07-17 21:59:20 UTC (rev 49011)
+++
branches/soc-2012-swiss_cheese/source/gameengine/Converter/BL_BlenderDataConversion.cpp
2012-07-18 03:56:42 UTC (rev 49012)
@@ -508,11 +508,11 @@
uvs[0][0] = uvs[1][0] = uvs[2][0] = uvs[3][0] = MT_Point2(0.f,
0.f);
}
- for (int vind = 0; vind<material->num_enabled; vind++)
+ for (int vind = 0; vind<MAXTEX; vind++)
{
BL_Mapping &map = material->mapping[vind];
- if (map.mapping != USEUV) continue;
+ if (!(map.mapping & USEUV)) continue;
//If no UVSet is specified, try grabbing one from the UV/Image
editor
if (map.uvCoName.IsEmpty() && tface)
@@ -562,11 +562,10 @@
const char *tfaceName,
MFace* mface,
MCol* mmcol,
- MTF_localLayer *layers,
bool glslmat)
{
material->Initialize();
- int numchan = -1, texalpha = 0;
+ int texalpha = 0;
bool validmat = (mat!=0);
bool validface = (tface!=0);
@@ -592,7 +591,6 @@
// cast shadows?
material->ras_mode |= ( mat->mode & MA_SHADBUF )?CAST_SHADOW:0;
MTex *mttmp = 0;
- numchan = getNumTexChannels(mat);
int valid_index = 0;
/* In Multitexture use the face texture if and only if
@@ -601,12 +599,9 @@
bool facetex = false;
if (validface && mat->mode &MA_FACETEXTURE)
facetex = true;
-
- numchan = numchan>MAXTEX?MAXTEX:numchan;
- if (facetex && numchan == 0) numchan = 1;
// foreach MTex
- for (int i=0; i<numchan; i++) {
+ for (int i=0; i<MAXTEX; i++) {
// use face tex
if (i==0 && facetex ) {
@@ -906,7 +901,7 @@
bl_mat = new BL_Material();
ConvertMaterial(bl_mat, ma, tface, tfaceName, mface,
mcol,
- layers, converter->GetGLSLMaterials());
+ converter->GetGLSLMaterials());
converter->CacheBlenderMaterial(ma, bl_mat);
}
@@ -1422,7 +1417,7 @@
if(!ma)
ma= &defmaterial;
ConvertMaterial(bl_mat, ma, tface, tfaceName,
mface, mcol,
- layers, converter->GetGLSLMaterials());
+ converter->GetGLSLMaterials());
short type = (bl_mat) ? ((ma->mode &
MA_VERTEXCOLP || bl_mat->glslmat) ? 0 : 1) : 0;
GetRGB(type,mface,mcol,ma,rgb);
Modified:
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Material.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Material.cpp
2012-07-17 21:59:20 UTC (rev 49011)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Material.cpp
2012-07-18 03:56:42 UTC (rev 49012)
@@ -20,15 +20,6 @@
return m?m:0;
}
-int getNumTexChannels( Material *mat )
-{
- int count = -1;
- if (!mat) return -1;
-
- for (count =0; (count < 10) && mat->mtex[count] != 0; count++) {}
- return count;
-}
-
BL_Material::BL_Material()
{
Initialize();
Modified: branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Material.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Material.h
2012-07-17 21:59:20 UTC (rev 49011)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Material.h
2012-07-18 03:56:42 UTC (rev 49012)
@@ -175,7 +175,6 @@
// ------------------------------------
//extern void initBL_Material(BL_Material* mat);
extern MTex* getImageFromMaterial(Material *mat, int index);
-extern int getNumTexChannels( Material *mat );
// ------------------------------------
#endif
Modified:
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
===================================================================
---
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
2012-07-17 21:59:20 UTC (rev 49011)
+++
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
2012-07-18 03:56:42 UTC (rev 49012)
@@ -96,16 +96,11 @@
m_flag |= (mMaterial->glslmat)? RAS_BLENDERGLSL: 0;
m_flag |= ((mMaterial->ras_mode & CAST_SHADOW)!=0)? RAS_CASTSHADOW: 0;
- // figure max
- int enabled = mMaterial->num_enabled;
- int max = BL_Texture::GetMaxUnits();
- mMaterial->num_enabled = enabled>=max?max:enabled;
-
// test the sum of the various modes for equality
// so we can ether accept or reject this material
// as being equal, this is rather important to
// prevent material bleeding
- for (int i=0; i<mMaterial->num_enabled; i++) {
+ for (int i=0; i<BL_Texture::GetMaxUnits(); i++) {
m_multimode += (mMaterial->flag[i] +
mMaterial->blend_mode[i]);
}
m_multimode += mMaterial->IdMode+ (mMaterial->ras_mode & ~(USE_LIGHT));
@@ -169,7 +164,7 @@
// for each unique material...
int i;
- for (i=0; i<mMaterial->num_enabled; i++) {
+ for (i=0; i<BL_Texture::GetMaxUnits(); i++) {
if ( mMaterial->mapping[i].mapping & USEENV ) {
if (!GLEW_ARB_texture_cube_map) {
spit("CubeMap textures not supported");
@@ -181,7 +176,7 @@
}
// If we're using glsl materials, the textures are handled by
bf_gpu, so don't load them twice!
// However, if we're using a custom shader, then we still need
to load the textures ourselves.
- else if (!mMaterial->glslmat || mBlenderShader) {
+ else if (!mMaterial->glslmat || mShader) {
if ( mMaterial->img[i] ) {
if ( ! mTextures[i].InitFromImage(i,
mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 ))
spit("unable to initialize
image("<<i<<") in "<<
@@ -233,7 +228,8 @@
}
BL_Texture::ActivateFirst();
- for (int i=0; i<mMaterial->num_enabled; i++) {
+ for (int i=0; i<BL_Texture::GetMaxUnits(); i++) {
+ if (!mTextures[i].Ok()) continue;
BL_Texture::ActivateUnit(i);
mTextures[i].DeleteTex();
mTextures[i].DisableUnit();
@@ -272,7 +268,7 @@
mShader->ApplyShader();
// for each enabled unit
- for (i=0; i<mMaterial->num_enabled; i++) {
+ for (i=0; i<BL_Texture::GetMaxUnits(); i++) {
if (!mTextures[i].Ok()) continue;
mTextures[i].ActivateTexture();
mTextures[0].SetMapping(mMaterial->mapping[i].mapping);
@@ -346,7 +342,7 @@
}
int mode = 0,i=0;
- for (i=0; (i<mMaterial->num_enabled && i<MAXTEX); i++) {
+ for (i=0; i<BL_Texture::GetMaxUnits(); i++) {
if ( !mTextures[i].Ok() ) continue;
mTextures[i].ActivateTexture();
@@ -638,7 +634,7 @@
ras->SetTexCoordNum(mMaterial->num_enabled);
- for (int i=0; i<mMaterial->num_enabled; i++) {
+ for (int i=0; i<BL_Texture::GetMaxUnits(); i++) {
int mode = mMaterial->mapping[i].mapping;
if ( mode &(USEREFL|USEOBJ))
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs