From c88a14f9e336007955746dfd288ebfc0a0acf51d Mon Sep 17 00:00:00 2001 From: rt Date: Sat, 2 Mar 2013 22:21:50 +0100 Subject: [PATCH] Revert "move footprint scale-factor to GlobalConstants" This reverts commit df50be21ffe927f40ece3b9454c86d0e289eda73. --- rts/Sim/Features/FeatureHandler.cpp | 4 ++-- rts/Sim/Misc/GlobalConstants.h | 9 --------- rts/Sim/Misc/NanoPieceCache.cpp | 2 +- rts/Sim/Misc/NanoPieceCache.h | 4 +--- rts/Sim/MoveTypes/MoveDefHandler.cpp | 5 +++-- rts/Sim/Units/UnitDef.cpp | 15 ++++++++++----- 6 files changed, 17 insertions(+), 22 deletions(-) diff --git a/rts/Sim/Features/FeatureHandler.cpp b/rts/Sim/Features/FeatureHandler.cpp index 7e047b604cf..244c93d0b88 100644 --- a/rts/Sim/Features/FeatureHandler.cpp +++ b/rts/Sim/Features/FeatureHandler.cpp @@ -160,8 +160,8 @@ FeatureDef* CFeatureHandler::CreateFeatureDef(const LuaTable& fdTable, const std fd->upright = fdTable.GetBool("upright", false); - fd->xsize = std::max(1 * SPRING_FOOTPRINT_SCALE, fdTable.GetInt("footprintX", 1) * SPRING_FOOTPRINT_SCALE); - fd->zsize = std::max(1 * SPRING_FOOTPRINT_SCALE, fdTable.GetInt("footprintZ", 1) * SPRING_FOOTPRINT_SCALE); + fd->xsize = std::max(1 * 2, fdTable.GetInt("footprintX", 1) * 2); + fd->zsize = std::max(1 * 2, fdTable.GetInt("footprintZ", 1) * 2); const float minMass = CSolidObject::MINIMUM_MASS; const float maxMass = CSolidObject::MAXIMUM_MASS; diff --git a/rts/Sim/Misc/GlobalConstants.h b/rts/Sim/Misc/GlobalConstants.h index ca54c03ad34..c32ccbb2fb8 100644 --- a/rts/Sim/Misc/GlobalConstants.h +++ b/rts/Sim/Misc/GlobalConstants.h @@ -10,15 +10,6 @@ */ const int SQUARE_SIZE = 8; -/** - * @brief footprint scale - * - * Multiplier for {Unit, Feature, MoveDef} footprint sizes which are - * assumed to be expressed in "TA units". The resolution of Spring's - * blocking-map is twice that of TA's. - */ -const int SPRING_FOOTPRINT_SCALE = 2; - /** * conversion factor from elmos to meters */ diff --git a/rts/Sim/Misc/NanoPieceCache.cpp b/rts/Sim/Misc/NanoPieceCache.cpp index 7f8054e9f6a..471c16edbea 100644 --- a/rts/Sim/Misc/NanoPieceCache.cpp +++ b/rts/Sim/Misc/NanoPieceCache.cpp @@ -16,7 +16,7 @@ int NanoPieceCache::GetNanoPiece(CUnitScript* ownerScript) { nanoPiece = nanoPieces[rnd % cnt]; } - if (lastNanoPieceCnt <= MAX_QUERYNANOPIECE_CALLS) { + if (lastNanoPieceCnt <= 30) { // only do so 30 times and then use the cache const int scriptPiece = ownerScript->QueryNanoPiece(); const int modelPiece = ownerScript->ScriptToModel(scriptPiece); diff --git a/rts/Sim/Misc/NanoPieceCache.h b/rts/Sim/Misc/NanoPieceCache.h index 9a8cf3a8e9a..b7d6ac0477f 100644 --- a/rts/Sim/Misc/NanoPieceCache.h +++ b/rts/Sim/Misc/NanoPieceCache.h @@ -24,14 +24,12 @@ struct NanoPieceCache { const std::vector& GetNanoPieces() const { return nanoPieces; } std::vector& GetNanoPieces() { return nanoPieces; } - void StopPolling() { lastNanoPieceCnt = MAX_QUERYNANOPIECE_CALLS * 2; } + void StopPolling() { lastNanoPieceCnt = 1e6; } private: // model-piece indices std::vector nanoPieces; - static const int MAX_QUERYNANOPIECE_CALLS = 30; - int lastNanoPieceCnt; int curBuildPowerMask; }; diff --git a/rts/Sim/MoveTypes/MoveDefHandler.cpp b/rts/Sim/MoveTypes/MoveDefHandler.cpp index 59ca259bd80..bcaa4e548a4 100644 --- a/rts/Sim/MoveTypes/MoveDefHandler.cpp +++ b/rts/Sim/MoveTypes/MoveDefHandler.cpp @@ -279,12 +279,13 @@ MoveDef::MoveDef(const LuaTable& moveTable, int moveDefID) { const int xsizeDef = std::max(1, moveTable.GetInt("footprintX", 1)); const int zsizeDef = std::max(1, moveTable.GetInt("footprintZ", xsizeDef)); + const int scale = 2; // make all mobile footprints point-symmetric in heightmap space // (meaning that only non-even dimensions are possible and each // footprint always has a unique center square) - xsize = xsizeDef * SPRING_FOOTPRINT_SCALE; - zsize = zsizeDef * SPRING_FOOTPRINT_SCALE; + xsize = xsizeDef * scale; + zsize = zsizeDef * scale; xsize -= ((xsize & 1)? 0: 1); zsize -= ((zsize & 1)? 0: 1); // precalculated data for MoveMath diff --git a/rts/Sim/Units/UnitDef.cpp b/rts/Sim/Units/UnitDef.cpp index f278dc6fae1..b33acb739b7 100644 --- a/rts/Sim/Units/UnitDef.cpp +++ b/rts/Sim/Units/UnitDef.cpp @@ -626,8 +626,14 @@ UnitDef::UnitDef(const LuaTable& udTable, const std::string& unitName, int id) activateWhenBuilt = udTable.GetBool("activateWhenBuilt", false); onoffable = udTable.GetBool("onoffable", false); - xsize = std::max(1 * SPRING_FOOTPRINT_SCALE, (udTable.GetInt("footprintX", 1) * SPRING_FOOTPRINT_SCALE)); - zsize = std::max(1 * SPRING_FOOTPRINT_SCALE, (udTable.GetInt("footprintZ", 1) * SPRING_FOOTPRINT_SCALE)); + // footprint sizes are assumed to be expressed in TA-engine units; + // Spring's heightmap resolution is double the footprint (yardmap) + // resolution, so we scale the values (which are not allowed to be + // 0) + // NOTE that this is done for the FeatureDef and MoveDef footprints + // as well + xsize = std::max(1 * 2, (udTable.GetInt("footprintX", 1) * 2)); + zsize = std::max(1 * 2, (udTable.GetInt("footprintZ", 1) * 2)); if (IsImmobileUnit()) { CreateYardMap(udTable.GetString("yardMap", "")); @@ -834,11 +840,10 @@ void UnitDef::CreateYardMap(std::string yardMapStr) LOG_L(L_WARNING, "%s: Given yardmap requires "_STPF_" extra char(s)!", name.c_str(), defYardMap.size() - ymCopyIdx); if (!unknownChars.empty()) - LOG_L(L_WARNING, "%s: Given yardmap contains unknown char(s) \"%s\"!", name.c_str(), unknownChars.c_str()); + LOG_L(L_WARNING, "%s: Given yardmap unknown char(s) \"%s\"!", name.c_str(), unknownChars.c_str()); // write the final yardmap at blocking-map resolution - // (in case of a high-res map this becomes a 1:1 copy, - // otherwise the given yardmap will be upsampled) + // in case of a high-res map, this becomes a 1:1 copy for (unsigned int bmz = 0; bmz < zsize; bmz++) { for (unsigned int bmx = 0; bmx < xsize; bmx++) { const unsigned int yardMapIdx = (bmx >> (1 - highResMap)) + ((bmz >> (1 - highResMap)) * hxsize);