Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2012-12-24 07:13:53 +0400
committerMitchell Stokes <mogurijin@gmail.com>2012-12-24 07:13:53 +0400
commita1c9241797b003979c1da747e217e875c497c775 (patch)
treef5be743fa99e6ea7236e848b0f1d04f5c5d5772a
parent119665d5b7b61f1924b4f0bf89fe1cff00017eed (diff)
BGE: "Fix" for issue [#33663] "Objects Share Materials / Textures When Grouped In SingleTexture / MultiTexture Mode" reported by Josiah Lane (solarlune).
This commit adds a UI option in the Render properties to enable the new material caching in the converter. This caching can cause problems with Singletexture and Multitexture materials when texface is being used to handle materials. By default this option is enabled and users with broken games have two options: 1) Fix up their materials so they are properly using textures 2) Disable the material caching and take a speed hit during conversion time Regardless of the setting, caching is always enabled for GLSL materials.
-rw-r--r--release/scripts/startup/bl_ui/properties_game.py1
-rw-r--r--source/blender/makesdna/DNA_scene_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_scene.c5
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp2
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp6
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp13
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.h5
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_ISceneConverter.h4
9 files changed, 37 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/properties_game.py b/release/scripts/startup/bl_ui/properties_game.py
index 42f651de6df..58b6aa6916c 100644
--- a/release/scripts/startup/bl_ui/properties_game.py
+++ b/release/scripts/startup/bl_ui/properties_game.py
@@ -407,6 +407,7 @@ class RENDER_PT_game_system(RenderButtonsPanel, Panel):
col = row.column()
col.prop(gs, "use_frame_rate")
col.prop(gs, "restrict_animation_updates")
+ col.prop(gs, "use_material_caching")
col = row.column()
col.prop(gs, "use_display_lists")
col.active = gs.raster_storage != 'VERTEX_BUFFER_OBJECT'
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 5e06a3084ac..5af116df772 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -693,6 +693,7 @@ typedef struct GameData {
#define GAME_SHOW_MOUSE (1 << 14)
#define GAME_GLSL_NO_COLOR_MANAGEMENT (1 << 15)
#define GAME_SHOW_OBSTACLE_SIMULATION (1 << 16)
+#define GAME_NO_MATERIAL_CACHING (1 << 17)
/* Note: GameData.flag is now an int (max 32 flags). A short could only take 16 flags */
/* GameData.playerflag */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 1ead8e6e975..8a295e883e1 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2776,6 +2776,11 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
"Use extra textures like normal or specular maps for GLSL rendering");
RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update");
+ prop = RNA_def_property(srna, "use_material_caching", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_NO_MATERIAL_CACHING);
+ RNA_def_property_ui_text(prop, "Use Material Caching",
+ "Cache materials in the converter. This is faster, but can cause propblems with older Singletexture and Multitexture games");
+
/* obstacle simulation */
prop = RNA_def_property(srna, "obstacle_simulation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "obstacleSimulation");
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 482700d5958..176dc33d057 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -468,6 +468,8 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
sceneconverter->SetMaterials(true);
if (useglslmat && (gs.matmode == GAME_MAT_GLSL))
sceneconverter->SetGLSLMaterials(true);
+ if (scene->gm.flag & GAME_NO_MATERIAL_CACHING)
+ sceneconverter->SetCacheMaterials(false);
KX_Scene* startscene = new KX_Scene(keyboarddevice,
mousedevice,
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 874bf614413..d0d6f9cb81c 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -922,6 +922,9 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace
/* do Texture Face materials */
Image* bima = (tface)? (Image*)tface->tpage: NULL;
STR_String imastr = (tface)? (bima? (bima)->id.name : "" ) : "";
+
+ if (!converter->GetCacheMaterials())
+ polymat = NULL;
char alpha_blend=0;
short tile=0;
@@ -1044,7 +1047,8 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace
polymat->m_shininess = 35.0;
}
- converter->CachePolyMaterial(ma, polymat);
+ if (converter->GetCacheMaterials())
+ converter->CachePolyMaterial(ma, polymat);
}
}
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index ceaa0a5f5a8..5524612f707 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -131,7 +131,8 @@ KX_BlenderSceneConverter::KX_BlenderSceneConverter(
m_ketsjiEngine(engine),
m_alwaysUseExpandFraming(false),
m_usemat(false),
- m_useglslmat(false)
+ m_useglslmat(false),
+ m_use_mat_cache(true)
{
tag_main(maggie, 0); /* avoid re-tagging later on */
m_newfilename = "";
@@ -488,6 +489,11 @@ void KX_BlenderSceneConverter::SetGLSLMaterials(bool val)
m_useglslmat = val;
}
+void KX_BlenderSceneConverter::SetCacheMaterials(bool val)
+{
+ m_use_mat_cache = val;
+}
+
bool KX_BlenderSceneConverter::GetMaterials()
{
return m_usemat;
@@ -498,6 +504,11 @@ bool KX_BlenderSceneConverter::GetGLSLMaterials()
return m_useglslmat;
}
+bool KX_BlenderSceneConverter::GetCacheMaterials()
+{
+ return m_use_mat_cache;
+}
+
void KX_BlenderSceneConverter::RegisterBlenderMaterial(BL_Material *mat)
{
// First make sure we don't register the material twice
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h
index f7723350eee..06dac1707c5 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.h
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h
@@ -91,6 +91,7 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter
bool m_alwaysUseExpandFraming;
bool m_usemat;
bool m_useglslmat;
+ bool m_use_mat_cache;
public:
KX_BlenderSceneConverter(
@@ -160,6 +161,10 @@ public:
virtual void SetGLSLMaterials(bool val);
virtual bool GetGLSLMaterials();
+ // cache materials during conversion
+ virtual void SetCacheMaterials(bool val);
+ virtual bool GetCacheMaterials();
+
struct Scene* GetBlenderSceneForName(const STR_String& name);
// struct Main* GetMain() { return m_maggie; }
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index 1dcc68c8e75..89d11515bb3 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -703,6 +703,8 @@ bool GPG_Application::startEngine(void)
m_sceneconverter->SetMaterials(true);
if (m_blenderglslmat && (m_globalSettings->matmode == GAME_MAT_GLSL))
m_sceneconverter->SetGLSLMaterials(true);
+ if (m_startScene->gm.flag & GAME_NO_MATERIAL_CACHING)
+ m_sceneconverter->SetCacheMaterials(false);
KX_Scene* startscene = new KX_Scene(m_keyboard,
m_mouse,
diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h
index 7c1d593a81e..616895a8269 100644
--- a/source/gameengine/Ketsji/KX_ISceneConverter.h
+++ b/source/gameengine/Ketsji/KX_ISceneConverter.h
@@ -89,6 +89,10 @@ public:
virtual void SetGLSLMaterials(bool val) =0;
virtual bool GetGLSLMaterials()=0;
+ // cache materials during conversion
+ virtual void SetCacheMaterials(bool val) =0;
+ virtual bool GetCacheMaterials()=0;
+
virtual struct Scene* GetBlenderSceneForName(const STR_String& name)=0;