diff --git a/src/Engine/Options.cpp b/src/Engine/Options.cpp index 2de0de3b85..7ec75371c9 100644 --- a/src/Engine/Options.cpp +++ b/src/Engine/Options.cpp @@ -178,6 +178,7 @@ void create() _info.push_back(OptionInfo("canSellLiveAliens", &canSellLiveAliens, false, "STR_CANSELLLIVEALIENS", "STR_GEOSCAPE")); _info.push_back(OptionInfo("anytimePsiTraining", &anytimePsiTraining, false, "STR_ANYTIMEPSITRAINING", "STR_GEOSCAPE")); _info.push_back(OptionInfo("globeSeasons", &globeSeasons, false, "STR_GLOBESEASONS", "STR_GEOSCAPE")); + _info.push_back(OptionInfo("globeSurfaceCache", &globeSurfaceCache, false, "STR_GLOBESURFACECACHE", "STR_GEOSCAPE")); _info.push_back(OptionInfo("psiStrengthEval", &psiStrengthEval, false, "STR_PSISTRENGTHEVAL", "STR_GEOSCAPE")); _info.push_back(OptionInfo("canTransferCraftsWhileAirborne", &canTransferCraftsWhileAirborne, false, "STR_CANTRANSFERCRAFTSWHILEAIRBORNE", "STR_GEOSCAPE")); // When the craft can reach the destination base with its fuel _info.push_back(OptionInfo("retainCorpses", &retainCorpses, false, "STR_RETAINCORPSES", "STR_GEOSCAPE")); diff --git a/src/Engine/Options.inc.h b/src/Engine/Options.inc.h index 4a520ad094..690e71ad78 100644 --- a/src/Engine/Options.inc.h +++ b/src/Engine/Options.inc.h @@ -21,7 +21,8 @@ OPT SDLKey keyOk, keyCancel, keyScreenshot, keyFps, keyQuickLoad, keyQuickSave; // Geoscape options OPT int geoClockSpeed, dogfightSpeed, geoScrollSpeed, geoDragScrollButton, geoscapeScale; -OPT bool includePrimeStateInSavedLayout, anytimePsiTraining, weaponSelfDestruction, retainCorpses, craftLaunchAlways, globeSeasons, globeDetail, globeRadarLines, globeFlightPaths, globeAllRadarsOnBaseBuild, +OPT bool includePrimeStateInSavedLayout, anytimePsiTraining, weaponSelfDestruction, retainCorpses, craftLaunchAlways, + globeSurfaceCache, globeSeasons, globeDetail, globeRadarLines, globeFlightPaths, globeAllRadarsOnBaseBuild, storageLimitsEnforced, canSellLiveAliens, canTransferCraftsWhileAirborne, customInitialBase, aggressiveRetaliation, geoDragScrollInvert, allowBuildingQueue, showFundsOnGeoscape, psiStrengthEval, allowPsiStrengthImprovement, fieldPromotions, meetingPoint; OPT SDLKey keyGeoLeft, keyGeoRight, keyGeoUp, keyGeoDown, keyGeoZoomIn, keyGeoZoomOut, keyGeoSpeed1, keyGeoSpeed2, keyGeoSpeed3, keyGeoSpeed4, keyGeoSpeed5, keyGeoSpeed6, diff --git a/src/Geoscape/Globe.cpp b/src/Geoscape/Globe.cpp index 067e9572eb..e2343101fe 100644 --- a/src/Geoscape/Globe.cpp +++ b/src/Geoscape/Globe.cpp @@ -244,6 +244,15 @@ struct CreateShadow } }; +struct CreateShadowWithoutCache +{ + static inline void func(Uint8& dest, const helper::Offset& offset, const Cord& sun, const Sint16& noise, const int& radius) + { + Cord earth = static_data.circle_norm(0., 0., radius, offset.x, offset.y); + CreateShadow::func(dest, earth, sun, noise, 0); + } +}; + }//namespace @@ -976,14 +985,25 @@ Cord Globe::getSunDirection(double lon, double lat) const void Globe::drawShadow() { - ShaderMove earth = ShaderMove(_earthData[_zoom], getWidth(), getHeight()); - ShaderRepeat noise = ShaderRepeat(_randomNoiseData, static_data.random_surf_size, static_data.random_surf_size); + if (Options::globeSurfaceCache) + { + ShaderMove earth = ShaderMove(_earthData[_zoom], getWidth(), getHeight()); + ShaderRepeat noise = ShaderRepeat(_randomNoiseData, static_data.random_surf_size, static_data.random_surf_size); - earth.setMove(_cenX-getWidth()/2, _cenY-getHeight()/2); + earth.setMove(_cenX-getWidth()/2, _cenY-getHeight()/2); - lock(); - ShaderDraw(ShaderSurface(this), earth, ShaderScalar(getSunDirection(_cenLon, _cenLat)), noise); - unlock(); + lock(); + ShaderDraw(ShaderSurface(this), earth, ShaderScalar(getSunDirection(_cenLon, _cenLat)), noise); + unlock(); + } + else + { + ShaderRepeat noise = ShaderRepeat(_randomNoiseData, static_data.random_surf_size, static_data.random_surf_size); + + lock(); + ShaderDraw(ShaderSurface(this), helper::Offset(_cenX, _cenY), ShaderScalar(getSunDirection(_cenLon, _cenLat)), noise, ShaderScalar(_zoomRadius[_zoom])); + unlock(); + } } @@ -1876,17 +1896,24 @@ void Globe::setupRadii(int width, int height) _radius = _zoomRadius[_zoom]; _radiusStep = (_zoomRadius[DOGFIGHT_ZOOM] - _zoomRadius[0]) / 10.0; - _earthData.resize(_zoomRadius.size()); - //filling normal field for each radius + if (Options::globeSurfaceCache) + { + _earthData.resize(_zoomRadius.size()); + //filling normal field for each radius - for (size_t r = 0; r<_zoomRadius.size(); ++r) + for (size_t r = 0; r<_zoomRadius.size(); ++r) + { + _earthData[r].resize(width * height); + for (int j=0; j