diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 0171f331..8c3d7312 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -1414,7 +1414,12 @@ Vec3d Unit::getCurrVector() const{ throw megaglest_runtime_error(szBuf); } - return getCurrVectorFlat() + Vec3d(0.f, truncateDecimal(type->getHeight()/2.f,16), 0.f); + Vec3d result = getCurrVectorFlat() + Vec3d(0.f, type->getHeight() /2.f, 0.f); + result.x = truncateDecimal(result.x,16); + result.y = truncateDecimal(result.y,16); + result.z = truncateDecimal(result.z,16); + + return result; } Vec3d Unit::getCurrVectorFlat() const{ @@ -1423,7 +1428,7 @@ Vec3d Unit::getCurrVectorFlat() const{ double Unit::getProgressAsFloat() const { double result = (static_cast(progress) / static_cast(PROGRESS_SPEED_MULTIPLIER)); - result = truncateDecimal(result); + result = truncateDecimal(result,16); return result; } @@ -1434,17 +1439,21 @@ Vec3d Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) c double y2= computeHeight(curPosValue); if(currSkill->getClass() == scMove) { - v.x= truncateDecimal(lastPosValue.x + getProgressAsFloat() * (curPosValue.x - lastPosValue.x),16); - v.z= truncateDecimal(lastPosValue.y + getProgressAsFloat() * (curPosValue.y - lastPosValue.y),16); - v.y= truncateDecimal(y1 + getProgressAsFloat() * (y2-y1),16); + v.x= lastPosValue.x + getProgressAsFloat() * (curPosValue.x - lastPosValue.x); + v.z= lastPosValue.y + getProgressAsFloat() * (curPosValue.y - lastPosValue.y); + v.y= y1 + getProgressAsFloat() * (y2-y1); } else { v.x= static_cast(curPosValue.x); v.z= static_cast(curPosValue.y); v.y= y2; } - v.x += truncateDecimal(type->getSize() / 2.f - 0.5f,16); - v.z += truncateDecimal(type->getSize() / 2.f - 0.5f,16); + v.x += type->getSize() / 2.f - 0.5f; + v.z += type->getSize() / 2.f - 0.5f; + + v.x = truncateDecimal(v.x,16); + v.y = truncateDecimal(v.y,16); + v.z = truncateDecimal(v.z,16); return v; } @@ -2491,7 +2500,7 @@ void Unit::updateTimedParticles() { for(int i = queuedUnitParticleSystemTypes.size() - 1; i >= 0; i--) { UnitParticleSystemType *pst = queuedUnitParticleSystemTypes[i]; if(pst != NULL) { - if(truncateDecimal(pst->getStartTime()) <= truncateDecimal(getAnimProgressAsFloat())) { + if(truncateDecimal(pst->getStartTime(),16) <= truncateDecimal(getAnimProgressAsFloat(),16)) { //printf("STARTING queued particle system type [%s] [%f] [%f] [%f] [%f]\n",pst->getType().c_str(),truncateDecimal(pst->getStartTime()),truncateDecimal(pst->getEndTime()),truncateDecimal(animProgress),truncateDecimal(lastAnimProgress)); UnitParticleSystem *ups = new UnitParticleSystem(200); @@ -2521,12 +2530,12 @@ void Unit::updateTimedParticles() { if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) { double pst = ps->getStartTime(); double pet = ps->getEndTime(); - double particleStartTime = truncateDecimal(pst); - double particleEndTime = truncateDecimal(pet); + double particleStartTime = truncateDecimal(pst,16); + double particleEndTime = truncateDecimal(pet,16); if(particleStartTime != 0.0 || particleEndTime != 1.0) { //printf("Checking for end particle system #%d [%d] [%f] [%f] [%f] [%f]\n",i,ps->shape,truncateDecimal(ps->getStartTime()),truncateDecimal(ps->getEndTime()),truncateDecimal(animProgress),truncateDecimal(lastAnimProgress)); - double animProgressTime = truncateDecimal(getAnimProgressAsFloat()); + double animProgressTime = truncateDecimal(getAnimProgressAsFloat(),16); if(animProgressTime >= 0.99 || animProgressTime >= particleEndTime) { //printf("ENDING particle system [%d]\n",ps->shape); diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index 5da53464..546f021c 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -1798,14 +1798,36 @@ void ProjectileParticleSystem::setPath(Vec3d startPos, Vec3d endPos){ //compute axis zVector= endPos - startPos; + zVector.x = truncateDecimal(zVector.x,16); + zVector.y = truncateDecimal(zVector.y,16); + zVector.z = truncateDecimal(zVector.z,16); + zVector.normalize(); + zVector.x = truncateDecimal(zVector.x,16); + zVector.y = truncateDecimal(zVector.y,16); + zVector.z = truncateDecimal(zVector.z,16); + yVector= Vec3d(0.0f, 1.0f, 0.0f); xVector= zVector.cross(yVector); + xVector.x = truncateDecimal(xVector.x,16); + xVector.y = truncateDecimal(xVector.y,16); + xVector.z = truncateDecimal(xVector.z,16); //apply offset - startPos+= xVector * offset.x; + startPos += xVector * offset.x; + startPos.x = truncateDecimal(startPos.x,16); + startPos.y = truncateDecimal(startPos.y,16); + startPos.z = truncateDecimal(startPos.z,16); + startPos+= yVector * offset.y; + startPos.x = truncateDecimal(startPos.x,16); + startPos.y = truncateDecimal(startPos.y,16); + startPos.z = truncateDecimal(startPos.z,16); + startPos+= zVector * offset.z; + startPos.x = truncateDecimal(startPos.x,16); + startPos.y = truncateDecimal(startPos.y,16); + startPos.z = truncateDecimal(startPos.z,16); pos= startPos; lastPos= startPos; @@ -1813,9 +1835,20 @@ void ProjectileParticleSystem::setPath(Vec3d startPos, Vec3d endPos){ //recompute axis zVector= endPos - startPos; + zVector.x = truncateDecimal(zVector.x,16); + zVector.y = truncateDecimal(zVector.y,16); + zVector.z = truncateDecimal(zVector.z,16); + zVector.normalize(); + zVector.x = truncateDecimal(zVector.x,16); + zVector.y = truncateDecimal(zVector.y,16); + zVector.z = truncateDecimal(zVector.z,16); + yVector= Vec3d(0.0f, 1.0f, 0.0f); xVector= zVector.cross(yVector); + xVector.x = truncateDecimal(xVector.x,16); + xVector.y = truncateDecimal(xVector.y,16); + xVector.z = truncateDecimal(xVector.z,16); // set members this->startPos= startPos; @@ -1823,7 +1856,15 @@ void ProjectileParticleSystem::setPath(Vec3d startPos, Vec3d endPos){ // direction direction = (endPos - lastPos); + direction.x = truncateDecimal(direction.x,16); + direction.y = truncateDecimal(direction.y,16); + direction.z = truncateDecimal(direction.z,16); + direction.normalize(); + direction.x = truncateDecimal(direction.x,16); + direction.y = truncateDecimal(direction.y,16); + direction.z = truncateDecimal(direction.z,16); + rotateChildren(); }