diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index e7f3e6419..36b92222c 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -1478,6 +1478,10 @@ Vec3f Unit::getCurrVector() const{ } Vec3f result = getCurrVectorFlat() + Vec3f(0.f, type->getHeight() / 2.f, 0.f); + result.x = truncateDecimal(result.x,6); + result.y = truncateDecimal(result.y,6); + result.z = truncateDecimal(result.z,6); + return result; } @@ -1503,15 +1507,26 @@ Vec3f Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) c v.x = lastPosValue.x + progressAsFloat * (curPosValue.x - lastPosValue.x); v.z = lastPosValue.y + progressAsFloat * (curPosValue.y - lastPosValue.y); v.y = y1 + progressAsFloat * (y2-y1); + + v.x = truncateDecimal(v.x,6); + v.y = truncateDecimal(v.y,6); + v.z = truncateDecimal(v.z,6); } else { v.x = static_cast(curPosValue.x); v.z = static_cast(curPosValue.y); v.y = y2; + + v.x = truncateDecimal(v.x,6); + v.y = truncateDecimal(v.y,6); + v.z = truncateDecimal(v.z,6); } v.x += type->getSize() / 2.f - 0.5f; v.z += type->getSize() / 2.f - 0.5f; + v.x = truncateDecimal(v.x,6); + v.z = truncateDecimal(v.z,6); + return v; } @@ -3405,7 +3420,8 @@ float Unit::computeHeight(const Vec2i &pos) const { float height= map->getCell(pos)->getHeight(); if(currField == fAir) { - const float airHeight=game->getWorld()->getTileset()->getAirHeight(); + float airHeight = game->getWorld()->getTileset()->getAirHeight(); + airHeight = truncateDecimal(airHeight,6); height += airHeight; height = truncateDecimal(height,6); @@ -4311,6 +4327,8 @@ std::string Unit::toString(bool crcMode) const { } result += "pathFindRefreshCellCount = " + intToStr(pathFindRefreshCellCount) + "\n"; + result += "currentPathFinderDesiredFinalPos = " + currentPathFinderDesiredFinalPos.getString() + "\n"; + result += "lastStuckFrame = " + uIntToStr(lastStuckFrame) + "\n"; result += "lastStuckPos = " + lastStuckPos.getString() + "\n"; @@ -5292,7 +5310,7 @@ Checksum Unit::getCRC() { //CauseOfDeathType causeOfDeath; //uint32 pathfindFailedConsecutiveFrameCount; - //Vec2i currentPathFinderDesiredFinalPos; + crcForUnit.addString(this->currentPathFinderDesiredFinalPos.getString()); crcForUnit.addInt(random.getLastNumber()); if(this->random.getLastCaller() != "") { diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index b7e801b93..5dd9e7e90 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -1788,9 +1788,17 @@ void ProjectileParticleSystem::update(){ pos= flatPos; #ifdef USE_STREFLOP pos+= xVector * streflop::cos(static_cast(relative * trajectoryFrequency * targetVector.length())) * trajectoryScale; + pos.x = truncateDecimal(pos.x,6); + pos.y = truncateDecimal(pos.y,6); + pos.z = truncateDecimal(pos.z,6); + pos+= yVector * streflop::sin(static_cast(relative * trajectoryFrequency * targetVector.length())) * trajectoryScale; #else pos+= xVector * cos(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale; + pos.x = truncateDecimal(pos.x,6); + pos.y = truncateDecimal(pos.y,6); + pos.z = truncateDecimal(pos.z,6); + pos+= yVector * sin(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale; #endif pos.x = truncateDecimal(pos.x,6); @@ -1804,7 +1812,11 @@ void ProjectileParticleSystem::update(){ break; } - direction= pos - lastPos; + direction= (pos - lastPos); + direction.x = truncateDecimal(direction.x,6); + direction.y = truncateDecimal(direction.y,6); + direction.z = truncateDecimal(direction.z,6); + direction.normalize(); direction.x = truncateDecimal(direction.x,6); direction.y = truncateDecimal(direction.y,6); @@ -1908,6 +1920,13 @@ void ProjectileParticleSystem::updateParticle(Particle *p){ } void ProjectileParticleSystem::setPath(Vec3f startPos, Vec3f endPos) { + startPos.x = truncateDecimal(startPos.x,6); + startPos.y = truncateDecimal(startPos.y,6); + startPos.z = truncateDecimal(startPos.z,6); + + endPos.x = truncateDecimal(endPos.x,6); + endPos.y = truncateDecimal(endPos.y,6); + endPos.z = truncateDecimal(endPos.z,6); //compute axis zVector= endPos - startPos; @@ -2172,7 +2191,15 @@ void SplashParticleSystem::initParticle(Particle *p, int particleIndex){ p->speed= Vec3f(horizontalSpreadA * random.randRange(-1.0f, 1.0f) + horizontalSpreadB, verticalSpreadA * random.randRange(-1.0f, 1.0f) + verticalSpreadB, horizontalSpreadA * random.randRange(-1.0f, 1.0f) + horizontalSpreadB); + p->speed.x = truncateDecimal(p->speed.x,6); + p->speed.y = truncateDecimal(p->speed.y,6); + p->speed.z = truncateDecimal(p->speed.z,6); + p->speed.normalize(); + p->speed.x = truncateDecimal(p->speed.x,6); + p->speed.y = truncateDecimal(p->speed.y,6); + p->speed.z = truncateDecimal(p->speed.z,6); + p->speed= p->speed * speed; p->speed.x = truncateDecimal(p->speed.x,6); p->speed.y = truncateDecimal(p->speed.y,6);