From 65a3ce6e86f1618c9278430bafd9432dedec370d Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Thu, 27 Nov 2014 15:28:49 -0800 Subject: [PATCH] - fix loading of deferred system particles --- data/glest_game | 2 +- source/glest_game/global/core_data.cpp | 16 ++++++++-------- source/glest_game/global/core_data.h | 2 +- source/glest_game/graphics/renderer.cpp | 6 ++++++ source/glest_game/type_instances/unit.cpp | 12 ++++++++---- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/data/glest_game b/data/glest_game index 3de3304f..929c6bac 160000 --- a/data/glest_game +++ b/data/glest_game @@ -1 +1 @@ -Subproject commit 3de3304fd08fed556c5bfee168fcaa64bbf75612 +Subproject commit 929c6bac3c2654aa549aaecd589cdc15a0abdd61 diff --git a/source/glest_game/global/core_data.cpp b/source/glest_game/global/core_data.cpp index e0945aea..3c415309 100644 --- a/source/glest_game/global/core_data.cpp +++ b/source/glest_game/global/core_data.cpp @@ -117,30 +117,30 @@ void CoreData::cleanup() { waterSounds.getSoundsPtr()->clear(); } -Texture2D *CoreData::getTextureBySystemId(TextureSystemType type) const { +Texture2D *CoreData::getTextureBySystemId(TextureSystemType type) { Texture2D *result = NULL; switch(type) { case tsyst_logoTexture: - result = logoTexture; + result = getLogoTexture(); break; //std::vector logoTextureList; case tsyst_backgroundTexture: - result = backgroundTexture; + result = getBackgroundTexture(); break; case tsyst_fireTexture: - result = fireTexture; + result = getFireTexture(); break; case tsyst_teamColorTexture: - result = teamColorTexture; + result = getTeamColorTexture(); break; case tsyst_snowTexture: - result = snowTexture; + result = getSnowTexture(); break; case tsyst_waterSplashTexture: - result = waterSplashTexture; + result = getWaterSplashTexture(); break; case tsyst_customTexture: - result = customTexture; + result = getCustomTexture(); break; case tsyst_buttonSmallTexture: result = buttonSmallTexture; diff --git a/source/glest_game/global/core_data.h b/source/glest_game/global/core_data.h index d0ce3afa..f8e41559 100644 --- a/source/glest_game/global/core_data.h +++ b/source/glest_game/global/core_data.h @@ -152,7 +152,7 @@ public: void loadFonts(); // Textures - Texture2D *getTextureBySystemId(TextureSystemType type) const; + Texture2D *getTextureBySystemId(TextureSystemType type); Texture2D *getBackgroundTexture(); Texture2D *getFireTexture(); diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 85662aea..21ccd667 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -582,10 +582,15 @@ void Renderer::manageDeferredParticleSystems() { CoreData::TextureSystemType textureSystemId = static_cast( ps->getTextureFileLoadDeferredSystemId()); + + //printf("Load DEFERRED particle i = %d textureSystemId = %d\n",i,textureSystemId); + if(textureSystemId != CoreData::tsyst_NONE) { Texture2D *texture= CoreData::getInstance().getTextureBySystemId(textureSystemId); //printf("Loading texture from system [%d] [%p]\n",textureSystemId,texture); ps->setTexture(texture); + + //printf("#2 Load DEFERRED particle i = %d textureSystemId = %d, texture = %p\n",i,textureSystemId,texture); } else { Texture2D *texture= newTexture2D(rs); @@ -601,6 +606,7 @@ void Renderer::manageDeferredParticleSystems() { texture->load(textureFile); ps->setTexture(texture); } + //printf("#3 Load DEFERRED particle i = %d textureSystemId = %d, texture = %p\n",i,textureSystemId,texture); } } if(dynamic_cast(ps) != NULL) { diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 3ff791e3..da6ab3be 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -5263,6 +5263,8 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction * //result->fire->setTexture(CoreData::getInstance().getFireTexture()); result->fireParticleSystems.push_back(result->fire); + //printf("Load MAIN fire particle result->fire = %p\n",result->fire); + Renderer::getInstance().addToDeferredParticleSystemList(make_pair(result->fire, rsGame)); } @@ -5387,16 +5389,18 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction * for(int i = 0; i < (int)unitParticleSystemNodeList.size(); ++i) { XmlNode *node = unitParticleSystemNodeList[i]; - if(linkFireIndex != i) { + if(result->fire == NULL || linkFireIndex != i) { FireParticleSystem *ups = new FireParticleSystem(); ups->setParticleOwner(result); ups->loadGame(node); //ups->setTexture(CoreData::getInstance().getFireTexture()); result->fireParticleSystems.push_back(ups); - //if(linkFireIndex >= 0 && linkFireIndex == i) { - // result->fire = ups; - //} + //printf("Load fire particle i = %d linkFireIndex = %d result->fire = %p ups = %p\n",i,linkFireIndex,result->fire,ups); + + if(result->fire == NULL && linkFireIndex >= 0 && linkFireIndex == i) { + result->fire = ups; + } Renderer::getInstance().addToDeferredParticleSystemList(make_pair(ups, rsGame)); } }