Skip to content

Commit

Permalink
Revert "move footprint scale-factor to GlobalConstants"
Browse files Browse the repository at this point in the history
This reverts commit df50be2.
  • Loading branch information
rt committed Mar 2, 2013
1 parent d9a92f0 commit c88a14f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
4 changes: 2 additions & 2 deletions rts/Sim/Features/FeatureHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions rts/Sim/Misc/GlobalConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Misc/NanoPieceCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions rts/Sim/Misc/NanoPieceCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ struct NanoPieceCache {
const std::vector<int>& GetNanoPieces() const { return nanoPieces; }
std::vector<int>& GetNanoPieces() { return nanoPieces; }

void StopPolling() { lastNanoPieceCnt = MAX_QUERYNANOPIECE_CALLS * 2; }
void StopPolling() { lastNanoPieceCnt = 1e6; }

private:
// model-piece indices
std::vector<int> nanoPieces;

static const int MAX_QUERYNANOPIECE_CALLS = 30;

int lastNanoPieceCnt;
int curBuildPowerMask;
};
Expand Down
5 changes: 3 additions & 2 deletions rts/Sim/MoveTypes/MoveDefHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions rts/Sim/Units/UnitDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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", ""));
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c88a14f

Please sign in to comment.