diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index 5d7f0ae13..b0c1acf24 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -1340,7 +1340,7 @@ void MainWindow::loadParticle(string path) { (*it)->setValues(ups); if(size > 0) { //getCurrVectorFlat() + Vec3f(0.f, type->getHeight()/2.f, 0.f); - Vec3f vec = Vec3f(0.f, height / 2.f, 0.f); + Vec3d vec = Vec3d(0.f, height / 2.f, 0.f); ups->setPos(vec); } //ups->setFactionColor(getFaction()->getTexture()->getPixmap()->getPixel3f(0,0)); @@ -1453,10 +1453,10 @@ void MainWindow::loadProjectileParticle(string path) { ProjectileParticleSystem *ps = (*it)->create(NULL); if(size > 0) { - Vec3f vec = Vec3f(0.f, height / 2.f, 0.f); + Vec3d vec = Vec3d(0.f, height / 2.f, 0.f); //ps->setPos(vec); - Vec3f vec2 = Vec3f(size * 2.f, height * 2.f, height * 2.f); + Vec3d vec2 = Vec3d(size * 2.f, height * 2.f, height * 2.f); ps->setPath(vec, vec2); } ps->setFactionColor(renderer->getPlayerColorTexture(playerColor)->getPixmap()->getPixel3f(0,0)); diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 514c10d03..f2ae12d99 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -1416,14 +1416,14 @@ void Game::init(bool initForPreviewOnly) { logger.add(Lang::getInstance().get("LogScreenGameLoadingCreatingRainParticles","",true), true); weatherParticleSystem= new RainParticleSystem(); weatherParticleSystem->setSpeed(12.f / GameConstants::updateFps); - weatherParticleSystem->setPos(gameCamera.getPos()); + weatherParticleSystem->setPos(Vec3d(gameCamera.getPos())); renderer.manageParticleSystem(weatherParticleSystem, rsGame); } else if(world.getTileset()->getWeather() == wSnowy) { logger.add(Lang::getInstance().get("LogScreenGameLoadingCreatingSnowParticles","",true), true); weatherParticleSystem= new SnowParticleSystem(1200); weatherParticleSystem->setSpeed(1.5f / GameConstants::updateFps); - weatherParticleSystem->setPos(gameCamera.getPos()); + weatherParticleSystem->setPos(Vec3d(gameCamera.getPos())); weatherParticleSystem->setTexture(coreData.getSnowTexture()); renderer.manageParticleSystem(weatherParticleSystem, rsGame); } @@ -2141,24 +2141,16 @@ void Game::update() { } if(currentCameraFollowUnit!=NULL){ - Vec3f c=currentCameraFollowUnit->getCurrVector(); + Vec3d c=currentCameraFollowUnit->getCurrVector(); int rotation=currentCameraFollowUnit->getRotation(); - float angle=rotation+180; + double angle=rotation+180; - -//#ifdef USE_STREFLOP -// c.z=c.z+4*streflop::cosf(static_cast(degToRad(angle))); -// c.x=c.x+4*streflop::sinf(static_cast(degToRad(angle))); -//#else -// c.z=c.z+4*cosf(degToRad(angle)); -// c.x=c.x+4*sinf(degToRad(angle)); -//#endif c.z=c.z+4*std::cos(degToRad(angle)); c.x=c.x+4*std::sin(degToRad(angle)); c.y=c.y+currentCameraFollowUnit->getType()->getHeight()/2.f+2.0f; - getGameCameraPtr()->setPos(c); + getGameCameraPtr()->setPos(Vec3f(c)); rotation=(540-rotation)%360; getGameCameraPtr()->rotateToVH(18.0f,rotation); @@ -2198,7 +2190,7 @@ void Game::update() { //Particle systems if(weatherParticleSystem != NULL) { - weatherParticleSystem->setPos(gameCamera.getPos()); + weatherParticleSystem->setPos(Vec3d(gameCamera.getPos())); } if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld [weather particle updating i = %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis(),i); @@ -4448,7 +4440,7 @@ void Game::startCameraFollowUnit() { if(currentUnit != NULL) { currentCameraFollowUnit = currentUnit; getGameCameraPtr()->setState(GameCamera::sUnit); - getGameCameraPtr()->setPos(currentCameraFollowUnit->getCurrVector()); + getGameCameraPtr()->setPos(Vec3f(currentCameraFollowUnit->getCurrVector())); int rotation=currentCameraFollowUnit->getRotation(); getGameCameraPtr()->stop(); diff --git a/source/glest_game/graphics/particle_type.h b/source/glest_game/graphics/particle_type.h index dea1436db..2c4605f71 100644 --- a/source/glest_game/graphics/particle_type.h +++ b/source/glest_game/graphics/particle_type.h @@ -59,7 +59,7 @@ protected: Model *model; float modelCycle; string primitive; - Vec3f offset; + Vec3d offset; Vec4f color; Vec4f colorNoEnergy; float size; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 85c553f96..b85ab757f 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -1054,11 +1054,11 @@ void Renderer::setupLighting() { Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex]; if(world->toRenderUnit(unit) && - unit->getCurrVector().dist(gameCamera->getPos()) < maxLightDist && + unit->getCurrVector().dist(Vec3d(gameCamera->getPos())) < maxLightDist && unit->getType()->getLight() && unit->isOperative()) { //printf("$$$ Show light for faction: %s # %d / %d for Unit [%d - %s]\n",world->getFaction(i)->getType()->getName().c_str(),lightCount,maxLights,unit->getId(),unit->getFullName().c_str()); - Vec4f pos= Vec4f(unit->getCurrVector()); + Vec4f pos= Vec4f(Vec3f(unit->getCurrVector())); pos.y+=4.f; GLenum lightEnum= GL_LIGHT0 + lightCount; @@ -4878,7 +4878,7 @@ void Renderer::renderTeamColorCircle(){ for(int visibleUnitIndex = 0; visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) { Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex]; - Vec3f currVec= unit->getCurrVectorFlat(); + Vec3f currVec= Vec3f(unit->getCurrVectorFlat()); Vec3f color=unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0); glColor4f(color.x, color.y, color.z, 0.7f); renderSelectionCircle(currVec, unit->getType()->getSize(), 0.8f, 0.05f); @@ -4933,7 +4933,7 @@ void Renderer::renderSpecialHighlightUnits(std::mapgetCurrVectorFlat(); + Vec3f currVec= Vec3f(unit->getCurrVectorFlat()); renderSelectionCircle(currVec, unit->getType()->getSize(), radius, thickness); } } @@ -4957,7 +4957,7 @@ void Renderer::renderTeamColorPlane(){ for(int visibleUnitIndex = 0; visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex){ Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex]; - Vec3f currVec= unit->getCurrVectorFlat(); + Vec3f currVec= Vec3f(unit->getCurrVectorFlat()); renderTeamColorEffect(currVec,visibleUnitIndex,unit->getType()->getSize(), unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0),texture); } @@ -5074,7 +5074,7 @@ void Renderer::renderUnits(const int renderFps) { glPushMatrix(); //translate - Vec3f currVec= unit->getCurrVectorFlat(); + Vec3f currVec= Vec3f(unit->getCurrVectorFlat()); glTranslatef(currVec.x, currVec.y, currVec.z); //rotate @@ -5245,7 +5245,7 @@ void Renderer::renderMorphEffects(){ initialized=true; } - Vec3f currVec= unit->getCurrVectorFlat(); + Vec3f currVec= Vec3f(unit->getCurrVectorFlat()); currVec=Vec3f(currVec.x,currVec.y+0.3f,currVec.z); if(mType->getField() == fAir && unit->getType()->getField()== fLand) { currVec=Vec3f(currVec.x,currVec.y+game->getWorld()->getTileset()->getAirHeight(),currVec.z); @@ -5299,7 +5299,7 @@ void Renderer::renderSelectionEffects() { const Unit *unit= selection->getUnit(i); if(unit != NULL) { //translate - Vec3f currVec= unit->getCurrVectorFlat(); + Vec3f currVec= Vec3f(unit->getCurrVectorFlat()); currVec.y+= 0.3f; //selection circle @@ -5335,7 +5335,7 @@ void Renderer::renderSelectionEffects() { if(i == 0) { lastPosValue = curPosValue; } - Vec3f currVec2 = unit->getVectorFlat(lastPosValue,curPosValue); + Vec3f currVec2 = Vec3f(unit->getVectorFlat(lastPosValue,curPosValue)); currVec2.y+= 0.3f; renderSelectionCircle(currVec2, 1, selectionCircleRadius); //renderSelectionCircle(currVec2, unit->getType()->getSize(), selectionCircleRadius); @@ -5367,7 +5367,7 @@ void Renderer::renderSelectionEffects() { int findUnitId = effect.currentAttackBoostUnits[i]; Unit *affectedUnit = game->getWorld()->findUnitById(findUnitId); if(affectedUnit != NULL) { - Vec3f currVecBoost = affectedUnit->getCurrVectorFlat(); + Vec3f currVecBoost = Vec3f(affectedUnit->getCurrVectorFlat()); currVecBoost.y += 0.3f; renderSelectionCircle(currVecBoost, affectedUnit->getType()->getSize(), 1.f); @@ -5413,7 +5413,7 @@ void Renderer::renderSelectionEffects() { Vec3f arrowTarget; Command *c= unit->getCurrCommand(); if(c->getUnit() != NULL) { - arrowTarget= c->getUnit()->getCurrVectorFlat(); + arrowTarget= Vec3f(c->getUnit()->getCurrVectorFlat()); } else { Vec2i pos= c->getPos(); @@ -5422,7 +5422,7 @@ void Renderer::renderSelectionEffects() { arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y); } - renderArrow(unit->getCurrVectorFlat(), arrowTarget, arrowColor, 0.3f); + renderArrow(Vec3f(unit->getCurrVectorFlat()), arrowTarget, arrowColor, 0.3f); } } @@ -5432,7 +5432,7 @@ void Renderer::renderSelectionEffects() { map->clampPos(pos); Vec3f arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y); - renderArrow(unit->getCurrVectorFlat(), arrowTarget, Vec3f(0.f, 0.f, 1.f), 0.3f); + renderArrow(Vec3f(unit->getCurrVectorFlat()), arrowTarget, Vec3f(0.f, 0.f, 1.f), 0.3f); } } } @@ -5450,7 +5450,7 @@ void Renderer::renderSelectionEffects() { glColor4f(1.f, 0.f, 0.f, highlight); } - Vec3f v= unit->getCurrVectorFlat(); + Vec3f v= Vec3f(unit->getCurrVectorFlat()); v.y+= 0.3f; renderSelectionCircle(v, unit->getType()->getSize(), 0.5f+0.4f*highlight ); } @@ -6714,7 +6714,7 @@ void Renderer::selectUsingFrustumSelection(Selection::UnitContainer &units, visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) { Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex]; if(unit != NULL && unit->isAlive()) { - Vec3f unitPos = unit->getCurrVector(); + Vec3d unitPos = unit->getCurrVector(); bool insideQuad = CubeInFrustum(quadSelectionCacheItem.frustumData, unitPos.x, unitPos.y, unitPos.z, unit->getType()->getSize()); if(insideQuad == true) { @@ -7486,7 +7486,7 @@ vector Renderer::renderUnitsFast(bool renderingShadows, bool colorPickin glPushMatrix(); //translate - Vec3f currVec= unit->getCurrVectorFlat(); + Vec3f currVec= Vec3f(unit->getCurrVectorFlat()); glTranslatef(currVec.x, currVec.y, currVec.z); //rotate diff --git a/source/glest_game/graphics/unit_particle_type.cpp b/source/glest_game/graphics/unit_particle_type.cpp index 75f187a3c..fb07b29e8 100644 --- a/source/glest_game/graphics/unit_particle_type.cpp +++ b/source/glest_game/graphics/unit_particle_type.cpp @@ -172,7 +172,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin // delay if(particleSystemNode->hasChild("delay")) { const XmlNode* delayNode = particleSystemNode->getChild("delay"); - const float delay_secs = delayNode->getAttribute("value")->getFloatValue(); + const double delay_secs = delayNode->getAttribute("value")->getFloatValue(); if(delay_secs < 0) throw megaglest_runtime_error("particle effect delay cannot be negative"); delay = (int)delay_secs * GameConstants::updateFps; @@ -183,7 +183,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin // lifetime if(particleSystemNode->hasChild("lifetime")) { const XmlNode* lifetimeNode = particleSystemNode->getChild("lifetime"); - const float lifetime_secs = lifetimeNode->getAttribute("value")->getFloatValue(); + const double lifetime_secs = lifetimeNode->getAttribute("value")->getFloatValue(); if(lifetime_secs < 0 && lifetime_secs != -1) throw megaglest_runtime_error("particle effect lifetime cannot be negative (-1 means inherited from parent particle)"); lifetime = (int)lifetime_secs * GameConstants::updateFps; @@ -300,13 +300,13 @@ void UnitParticleSystemType::saveGame(XmlNode *rootNode) { // UnitParticleSystem::Shape shape; unitParticleSystemTypeNode->addAttribute("shape",intToStr(shape), mapTagReplacements); // float angle; - unitParticleSystemTypeNode->addAttribute("angle",floatToStr(angle,16), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("angle",doubleToStr(angle,16), mapTagReplacements); // float radius; - unitParticleSystemTypeNode->addAttribute("radius",floatToStr(radius,16), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("radius",doubleToStr(radius,16), mapTagReplacements); // float minRadius; - unitParticleSystemTypeNode->addAttribute("minRadius",floatToStr(minRadius,16), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("minRadius",doubleToStr(minRadius,16), mapTagReplacements); // float emissionRateFade; - unitParticleSystemTypeNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade,16), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,16), mapTagReplacements); // Vec3f direction; unitParticleSystemTypeNode->addAttribute("direction",direction.getString(), mapTagReplacements); // bool relative; @@ -330,9 +330,9 @@ void UnitParticleSystemType::saveGame(XmlNode *rootNode) { // int lifetime; unitParticleSystemTypeNode->addAttribute("lifetime",intToStr(lifetime), mapTagReplacements); // float startTime; - unitParticleSystemTypeNode->addAttribute("startTime",floatToStr(startTime,16), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("startTime",doubleToStr(startTime,16), mapTagReplacements); // float endTime; - unitParticleSystemTypeNode->addAttribute("endTime",floatToStr(endTime,16), mapTagReplacements); + unitParticleSystemTypeNode->addAttribute("endTime",doubleToStr(endTime,16), mapTagReplacements); } }}//end mamespace diff --git a/source/glest_game/graphics/unit_particle_type.h b/source/glest_game/graphics/unit_particle_type.h index 17ed52322..b2a9ceac4 100644 --- a/source/glest_game/graphics/unit_particle_type.h +++ b/source/glest_game/graphics/unit_particle_type.h @@ -52,11 +52,11 @@ using Shared::Xml::XmlNode; class UnitParticleSystemType: public ParticleSystemType { protected: UnitParticleSystem::Shape shape; - float angle; - float radius; - float minRadius; - float emissionRateFade; - Vec3f direction; + double angle; + double radius; + double minRadius; + double emissionRateFade; + Vec3d direction; bool relative; bool relativeDirection; bool fixed; @@ -67,8 +67,8 @@ protected: bool radiusBasedStartenergy; int delay; int lifetime; - float startTime; - float endTime; + double startTime; + double endTime; public: UnitParticleSystemType(); @@ -81,10 +81,10 @@ public: std::map > > &loadedFileList,string parentLoader, string techtreePath); - void setStartTime(float startTime) { this->startTime = startTime; } - float getStartTime() const { return this->startTime; } - void setEndTime(float endTime) { this->endTime = endTime; } - float getEndTime() const { return this->endTime; } + void setStartTime(double startTime) { this->startTime = startTime; } + double getStartTime() const { return this->startTime; } + void setEndTime(double endTime) { this->endTime = endTime; } + double getEndTime() const { return this->endTime; } const void setValues (UnitParticleSystem *uts); bool hasTexture() const { return(texture != NULL); } diff --git a/source/glest_game/gui/gui.cpp b/source/glest_game/gui/gui.cpp index c124c1564..e2ad73680 100644 --- a/source/glest_game/gui/gui.cpp +++ b/source/glest_game/gui/gui.cpp @@ -305,7 +305,7 @@ void Gui::mouseUpLeftGraphics(int x, int y) { if(selection.isCommandable() && random.randRange(0, 1)==0){ SoundRenderer::getInstance().playFx( selection.getFrontUnit()->getType()->getSelectionSound(), - selection.getFrontUnit()->getCurrVector(), + Vec3f(selection.getFrontUnit()->getCurrVector()), gameCamera->getPos()); } selectionQuad.disable(); @@ -477,7 +477,7 @@ void Gui::giveDefaultOrders(int x, int y,const Unit *targetUnit, bool paintMouse if(random.randRange(0, 1)==0){ SoundRenderer::getInstance().playFx( selection.getFrontUnit()->getType()->getCommandSound(), - selection.getFrontUnit()->getCurrVector(), + Vec3f(selection.getFrontUnit()->getCurrVector()), gameCamera->getPos()); } } @@ -532,7 +532,7 @@ void Gui::giveTwoClickOrders(int x, int y , bool prepared) { if(random.randRange(0, 1) == 0) { SoundRenderer::getInstance().playFx( selection.getFrontUnit()->getType()->getCommandSound(), - selection.getFrontUnit()->getCurrVector(), + Vec3f(selection.getFrontUnit()->getCurrVector()), gameCamera->getPos()); } } @@ -540,7 +540,7 @@ void Gui::giveTwoClickOrders(int x, int y , bool prepared) { void Gui::centerCameraOnSelection() { if(selection.isEmpty() == false) { - Vec3f refPos= selection.getRefPos(); + Vec3d refPos= selection.getRefPos(); gameCamera->centerXZ(refPos.x, refPos.z); } } diff --git a/source/glest_game/gui/selection.cpp b/source/glest_game/gui/selection.cpp index 9286e1484..ae8eb9c8d 100644 --- a/source/glest_game/gui/selection.cpp +++ b/source/glest_game/gui/selection.cpp @@ -186,7 +186,7 @@ bool Selection::isMeetable() const{ selectedUnits.front()->getType()->getMeetingPoint(); } -Vec3f Selection::getRefPos() const{ +Vec3d Selection::getRefPos() const{ return getFrontUnit()->getCurrVector(); } diff --git a/source/glest_game/gui/selection.h b/source/glest_game/gui/selection.h index 293cbb85f..e193595e3 100644 --- a/source/glest_game/gui/selection.h +++ b/source/glest_game/gui/selection.h @@ -85,7 +85,7 @@ public: const Unit *getUnit(int i) const {return selectedUnits[i];} Unit *getUnitPtr(int i) {return selectedUnits[i];} const Unit *getFrontUnit() const {return selectedUnits.front();} - Vec3f getRefPos() const; + Vec3d getRefPos() const; bool hasUnit(const Unit* unit) const; void assignGroup(int groupIndex,const UnitContainer *pUnits=NULL); diff --git a/source/glest_game/menu/menu_background.cpp b/source/glest_game/menu/menu_background.cpp index 1d4638a66..317afc1b0 100644 --- a/source/glest_game/menu/menu_background.cpp +++ b/source/glest_game/menu/menu_background.cpp @@ -160,7 +160,7 @@ void MenuBackground::createRainParticleSystem() { rps->setSpeed(12.f/GameConstants::updateFps); rps->setEmissionRate(25); rps->setWind(-90.f, 4.f/GameConstants::updateFps); - rps->setPos(Vec3f(0.f, 25.f, 0.f)); + rps->setPos(Vec3d(0.f, 25.f, 0.f)); rps->setColor(Vec4f(1.f, 1.f, 1.f, 0.2f)); rps->setRadius(30.f); diff --git a/source/glest_game/type_instances/object.cpp b/source/glest_game/type_instances/object.cpp index ca2507b8d..ea2e09e96 100644 --- a/source/glest_game/type_instances/object.cpp +++ b/source/glest_game/type_instances/object.cpp @@ -109,7 +109,7 @@ void Object::initParticlesFromTypes(const ModelParticleSystemTypes *particleType UnitParticleSystem *ups= new UnitParticleSystem(200); ups->setParticleOwner(this); (*it)->setValues(ups); - ups->setPos(this->pos); + ups->setPos(Vec3d(this->pos)); ups->setRotation(this->rotation); ups->setFactionColor(Vec3f(0, 0, 0)); ups->setVisible(false); @@ -132,7 +132,7 @@ void Object::setHeight(float height) { for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it != unitParticleSystems.end(); ++it) { bool particleValid = Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame); if(particleValid == true) { - (*it)->setPos(this->pos); + (*it)->setPos(Vec3d(this->pos)); } } } diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 539e33a05..0171f3314 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -453,7 +453,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, this->map= map; this->targetRef = NULL; this->targetField = fLand; - this->targetVec = Vec3f(0.0); + this->targetVec = Vec3d(0.0); this->targetPos = Vec2i(0); this->lastRenderFrame = 0; this->visible = true; @@ -700,7 +700,7 @@ Vec2i Unit::getCenteredPos() const { return pos + Vec2i(type->getSize()/2, type->getSize()/2); } -Vec2f Unit::getFloatCenteredPos() const { +Vec2d Unit::getFloatCenteredPos() const { static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); MutexSafeWrapper safeMutex(mutexCommands,mutexOwnerId); @@ -710,7 +710,7 @@ Vec2f Unit::getFloatCenteredPos() const { throw megaglest_runtime_error(szBuf); } - return Vec2f(pos.x-0.5f+type->getSize()/2.f, pos.y-0.5f+type->getSize()/2.f); + return Vec2d(pos.x-0.5f+type->getSize()/2.f, pos.y-0.5f+type->getSize()/2.f); } Vec2i Unit::getCellPos() const { @@ -1275,10 +1275,6 @@ void Unit::setTargetPos(const Vec2i &targetPos) { #endif targetRef= NULL; - //this->targetField = fLand; - //this->targetVec = Vec3f(0.0); - //this->targetPos = Vec2i(0); - this->targetPos= targetPos; map->clampPos(this->targetPos); @@ -1411,17 +1407,17 @@ bool Unit::checkModelStateInfoForNewHpValue() { return result; } -Vec3f Unit::getCurrVector() const{ +Vec3d Unit::getCurrVector() const{ if(type == NULL) { char szBuf[8096]=""; snprintf(szBuf,8096,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->toString().c_str()); throw megaglest_runtime_error(szBuf); } - return getCurrVectorFlat() + Vec3f(0.f, truncateDecimal(type->getHeight()/2.f), 0.f); + return getCurrVectorFlat() + Vec3d(0.f, truncateDecimal(type->getHeight()/2.f,16), 0.f); } -Vec3f Unit::getCurrVectorFlat() const{ +Vec3d Unit::getCurrVectorFlat() const{ return getVectorFlat(lastPos, pos); } @@ -1431,24 +1427,24 @@ double Unit::getProgressAsFloat() const { return result; } -Vec3f Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const { - Vec3f v; +Vec3d Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const { + Vec3d v; double y1= computeHeight(lastPosValue); double y2= computeHeight(curPosValue); if(currSkill->getClass() == scMove) { - v.x= truncateDecimal(lastPosValue.x + getProgressAsFloat() * (curPosValue.x - lastPosValue.x)); - v.z= truncateDecimal(lastPosValue.y + getProgressAsFloat() * (curPosValue.y - lastPosValue.y)); - v.y= truncateDecimal(y1 + getProgressAsFloat() * (y2-y1)); + 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); } 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); - v.z += truncateDecimal(type->getSize() / 2.f - 0.5f); + v.x += truncateDecimal(type->getSize() / 2.f - 0.5f,16); + v.z += truncateDecimal(type->getSize() / 2.f - 0.5f,16); return v; } @@ -3348,19 +3344,19 @@ double Unit::computeHeight(const Vec2i &pos) const { if(currField == fAir) { const double airHeight=game->getWorld()->getTileset()->getAirHeight(); height += airHeight; - height = truncateDecimal(height); + height = truncateDecimal(height,16); Unit *unit = map->getCell(pos)->getUnit(fLand); if(unit != NULL && unit->getType()->getHeight() > airHeight) { height += (std::min((double)unit->getType()->getHeight(),Tileset::standardAirHeight * 3) - airHeight); - height = truncateDecimal(height); + height = truncateDecimal(height,16); } else { SurfaceCell *sc = map->getSurfaceCell(map->toSurfCoords(pos)); if(sc != NULL && sc->getObject() != NULL && sc->getObject()->getType() != NULL) { if(sc->getObject()->getType()->getHeight() > airHeight) { height += (std::min((double)sc->getObject()->getType()->getHeight(),Tileset::standardAirHeight * 3) - airHeight); - height = truncateDecimal(height); + height = truncateDecimal(height,16); } } } @@ -3376,7 +3372,7 @@ void Unit::updateTarget(){ //update target pos targetPos= target->getCellPos(); Vec2i relPos= targetPos - pos; - Vec2f relPosf= Vec2f((float)relPos.x, (float)relPos.y); + Vec2d relPosf= Vec2d((float)relPos.x, (float)relPos.y); #ifdef USE_STREFLOP targetRotation= radToDeg(streflop::atan2(static_cast(relPosf.x), static_cast(relPosf.y))); #else @@ -3823,8 +3819,8 @@ void Unit::startDamageParticles() { ups->setColor(Vec4f(0.115f, 0.115f, 0.115f, 0.22f)); ups->setPos(getCurrVector()); ups->setBlendMode(ups->strToBlendMode("black")); - ups->setOffset(Vec3f(0,2,0)); - ups->setDirection(Vec3f(0,1,-0.2f)); + ups->setOffset(Vec3d(0,2,0)); + ups->setDirection(Vec3d(0,1,-0.2f)); ups->setRadius(type->getSize()/3.f); ups->setShape(Shared::Graphics::UnitParticleSystem::sLinear); ups->setTexture(CoreData::getInstance().getFireTexture()); @@ -3845,7 +3841,7 @@ void Unit::startDamageParticles() { checkCustomizedParticleTriggers(false); } -void Unit::setTargetVec(const Vec3f &targetVec) { +void Unit::setTargetVec(const Vec3d &targetVec) { this->targetVec= targetVec; logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__); } @@ -4687,7 +4683,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction * // Vec2i targetPos; //absolute target pos result->targetPos = Vec2i::strToVec2(unitNode->getAttribute("targetPos")->getValue()); // Vec3f targetVec; - result->targetVec = Vec3f::strToVec3(unitNode->getAttribute("targetVec")->getValue()); + result->targetVec = Vec3d::strToVec3(unitNode->getAttribute("targetVec")->getValue()); // Vec2i meetingPos; result->meetingPos = Vec2i::strToVec2(unitNode->getAttribute("meetingPos")->getValue()); // @@ -4905,26 +4901,6 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction * //ups->setTexture(CoreData::getInstance().getFireTexture()); result->smokeParticleSystems.push_back(ups); -// UnitParticleSystem *ups= new UnitParticleSystem(400); -// ups->setColorNoEnergy(Vec4f(0.0f, 0.0f, 0.0f, 0.13f)); -// ups->setColor(Vec4f(0.115f, 0.115f, 0.115f, 0.22f)); -// ups->setPos(result->getCurrVector()); -// ups->setBlendMode(ups->strToBlendMode("black")); -// ups->setOffset(Vec3f(0,2,0)); -// ups->setDirection(Vec3f(0,1,-0.2f)); -// ups->setRadius(result->type->getSize()/3.f); -// ups->setShape(Shared::Graphics::UnitParticleSystem::sLinear); -// ups->setTexture(CoreData::getInstance().getFireTexture()); -// const Game *game = Renderer::getInstance().getGame(); -// ups->setSpeed(2.0f / game->getWorld()->getUpdateFps(result->getFactionIndex())); -// ups->setGravity(0.0004f); -// ups->setEmissionRate(1); -// ups->setMaxParticleEnergy(150); -// ups->setSizeNoEnergy(result->type->getSize()*0.6f); -// ups->setParticleSize(result->type->getSize()*0.8f); -// result->smokeParticleSystems.push_back(ups); - - //Renderer::getInstance().manageParticleSystem(result->fire, rsGame); Renderer::getInstance().addToDeferredParticleSystemList(make_pair(ups, rsGame)); //printf("Loading smoke particles:\n[%s]\n",ups->toString().c_str()); diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index 03883d07b..53b59a187 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -368,7 +368,7 @@ private: Vec2i pos; Vec2i lastPos; Vec2i targetPos; //absolute target pos - Vec3f targetVec; + Vec3d targetVec; Vec2i meetingPos; double lastRotation; //in degrees @@ -536,7 +536,7 @@ public: double getEpRatio() const; inline bool getToBeUndertaken() const {return toBeUndertaken;} inline Vec2i getTargetPos() const {return targetPos;} - inline Vec3f getTargetVec() const {return targetVec;} + inline Vec3d getTargetVec() const {return targetVec;} inline Field getTargetField() const {return targetField;} inline Vec2i getMeetingPos() const {return meetingPos;} inline Faction *getFaction() const {return faction;} @@ -574,7 +574,7 @@ public: Vec2i getPosWithCellMapSet() const; inline Vec2i getLastPos() const {return lastPos;} Vec2i getCenteredPos() const; - Vec2f getFloatCenteredPos() const; + Vec2d getFloatCenteredPos() const; Vec2i getCellPos() const; //is @@ -613,7 +613,7 @@ public: void refreshPos(); void setTargetPos(const Vec2i &targetPos); void setTarget(const Unit *unit); - void setTargetVec(const Vec3f &targetVec); + void setTargetVec(const Vec3d &targetVec); void setMeetingPos(const Vec2i &meetingPos); void setVisible(const bool visible); inline bool getVisible() const { return visible; } @@ -621,9 +621,9 @@ public: //render related const Model *getCurrentModel(); Model *getCurrentModelPtr(); - Vec3f getCurrVector() const; - Vec3f getCurrVectorFlat() const; - Vec3f getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const; + Vec3d getCurrVector() const; + Vec3d getCurrVectorFlat() const; + Vec3d getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const; //command related bool anyCommand(bool validateCommandtype=false) const; diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 418457efc..c1b403b2e 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -123,7 +123,7 @@ bool UnitUpdater::updateUnit(Unit *unit) { if(soundStartTime >= unit->getLastAnimProgressAsFloat() && soundStartTime < unit->getAnimProgressAsFloat()) { if(map->getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(world->getThisTeamIndex()) || (game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) { - soundRenderer.playFx(currSkill->getSound(), unit->getCurrVector(), gameCamera->getPos()); + soundRenderer.playFx(currSkill->getSound(), Vec3f(unit->getCurrVector()), gameCamera->getPos()); } } } @@ -276,7 +276,7 @@ bool UnitUpdater::updateUnit(Unit *unit) { if(Config::getInstance().getBool("DisableWaterSounds","false") == false) { soundRenderer.playFx( CoreData::getInstance().getWaterSound(), - unit->getCurrVector(), + Vec3f(unit->getCurrVector()), gameCamera->getPos() ); @@ -931,7 +931,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) { (game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) { SoundRenderer::getInstance().playFx( bct->getStartSound(), - unit->getCurrVector(), + Vec3f(unit->getCurrVector()), gameCamera->getPos()); } @@ -1023,7 +1023,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) { (game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) { SoundRenderer::getInstance().playFx( bct->getBuiltSound(), - unit->getCurrVector(), + Vec3f(unit->getCurrVector()), gameCamera->getPos()); } } @@ -2296,8 +2296,8 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){ ParticleSystemTypeProjectile *pstProj= ast->getProjParticleType(); ParticleSystemTypeSplash *pstSplash= ast->getSplashParticleType(); - Vec3f startPos= unit->getCurrVector(); - Vec3f endPos= unit->getTargetVec(); + Vec3d startPos= unit->getCurrVector(); + Vec3d endPos= unit->getTargetVec(); //make particle system const SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getPos())); @@ -2490,7 +2490,7 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr, //aux vars int size = unit->getType()->getSize(); Vec2i center = unit->getPos(); - Vec2f floatCenter = unit->getFloatCenteredPos(); + Vec2d floatCenter = unit->getFloatCenteredPos(); //bool foundInCache = true; if(findCachedCellsEnemies(center,range,size,enemies,ast, @@ -2502,9 +2502,9 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr, for(int j = center.y - range; j < center.y + range + size; ++j) { //cells inside map and in range #ifdef USE_STREFLOP - if(map->isInside(i, j) && streflop::floor(static_cast(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range+1)){ + if(map->isInside(i, j) && streflop::floor(static_cast(floatCenter.dist(Vec2d((double)i, (double)j)))) <= (range+1)){ #else - if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){ + if(map->isInside(i, j) && floor(floatCenter.dist(Vec2d((double)i, (double)j))) <= (range+1)){ #endif Cell *cell = map->getCell(i,j); findEnemiesForCell(ast,cell,unit,commandTarget,enemies); @@ -2595,7 +2595,7 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr, if(evalMode == false && onlyEnemyUnits == false && enemyUnit->getTeam() != world->getThisTeamIndex()) { - Vec2f enemyFloatCenter = enemyUnit->getFloatCenteredPos(); + Vec2d enemyFloatCenter = enemyUnit->getFloatCenteredPos(); // find nearest Attack and cleanup old dates AttackWarningData *nearest = NULL; double currentDistance = 0.f; @@ -2684,7 +2684,7 @@ vector UnitUpdater::enemyUnitsOnRange(const Unit *unit,const AttackSkillT //aux vars int size = unit->getType()->getSize(); Vec2i center = unit->getPosNotThreadSafe(); - Vec2f floatCenter = unit->getFloatCenteredPos(); + Vec2d floatCenter = unit->getFloatCenteredPos(); //bool foundInCache = true; if(findCachedCellsEnemies(center,range,size,enemies,ast, @@ -2696,9 +2696,9 @@ vector UnitUpdater::enemyUnitsOnRange(const Unit *unit,const AttackSkillT for(int j = center.y - range; j < center.y + range + size; ++j) { //cells inside map and in range #ifdef USE_STREFLOP - if(map->isInside(i, j) && streflop::floor(static_cast(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range+1)){ + if(map->isInside(i, j) && streflop::floor(static_cast(floatCenter.dist(Vec2d((double)i, (double)j)))) <= (range+1)){ #else - if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){ + if(map->isInside(i, j) && floor(floatCenter.dist(Vec2d((double)i, (double)j))) <= (range+1)){ #endif Cell *cell = map->getCell(i,j); findEnemiesForCell(ast,cell,unit,commandTarget,enemies); @@ -2744,7 +2744,7 @@ vector UnitUpdater::findUnitsInRange(const Unit *unit, int radius) { //aux vars int size = unit->getType()->getSize(); Vec2i center = unit->getPosNotThreadSafe(); - Vec2f floatCenter = unit->getFloatCenteredPos(); + Vec2d floatCenter = unit->getFloatCenteredPos(); //nearby cells //UnitRangeCellsLookupItem cacheItem; @@ -2752,9 +2752,9 @@ vector UnitUpdater::findUnitsInRange(const Unit *unit, int radius) { for(int j = center.y - range; j < center.y + range + size; ++j) { //cells inside map and in range #ifdef USE_STREFLOP - if(map->isInside(i, j) && streflop::floor(static_cast(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range+1)){ + if(map->isInside(i, j) && streflop::floor(static_cast(floatCenter.dist(Vec2d((double)i, (double)j)))) <= (range+1)){ #else - if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){ + if(map->isInside(i, j) && floor(floatCenter.dist(Vec2d((double)i, (double)j))) <= (range+1)){ #endif Cell *cell = map->getCell(i,j); findUnitsForCell(cell,unit,units); @@ -2866,7 +2866,7 @@ void ParticleDamager::update(ParticleSystem *particleSystem) { //play sound StaticSound *projSound= ast->getProjSound(); if(particleSystem->getVisible() && projSound != NULL) { - SoundRenderer::getInstance().playFx(projSound, attacker->getCurrVector(), gameCamera->getPos()); + SoundRenderer::getInstance().playFx(projSound, Vec3f(attacker->getCurrVector()), gameCamera->getPos()); } } particleSystem->setObserver(NULL); diff --git a/source/glest_game/world/unit_updater.h b/source/glest_game/world/unit_updater.h index 02a15004f..807ebe83b 100644 --- a/source/glest_game/world/unit_updater.h +++ b/source/glest_game/world/unit_updater.h @@ -55,7 +55,7 @@ public: class AttackWarningData { public: - Vec2f attackPosition; + Vec2d attackPosition; int lastFrameCount; }; diff --git a/source/shared_lib/include/graphics/particle.h b/source/shared_lib/include/graphics/particle.h index 0b906c673..e81a2fa96 100644 --- a/source/shared_lib/include/graphics/particle.h +++ b/source/shared_lib/include/graphics/particle.h @@ -45,10 +45,10 @@ class Model; class Particle { public: //attributes - Vec3f pos; - Vec3f lastPos; - Vec3f speed; - Vec3f accel; + Vec3d pos; + Vec3d lastPos; + Vec3d speed; + Vec3d accel; Vec4f color; double size; int energy; @@ -59,10 +59,10 @@ public: energy = 0; } //get - Vec3f getPos() const {return pos;} - Vec3f getLastPos() const {return lastPos;} - Vec3f getSpeed() const {return speed;} - Vec3f getAccel() const {return accel;} + Vec3d getPos() const {return pos;} + Vec3d getLastPos() const {return lastPos;} + Vec3d getSpeed() const {return speed;} + Vec3d getAccel() const {return accel;} Vec4f getColor() const {return color;} double getSize() const {return size;} int getEnergy() const {return energy;} @@ -135,7 +135,7 @@ protected: int textureFileLoadDeferredComponents; Texture *texture; - Vec3f pos; + Vec3d pos; Vec4f color; Vec4f colorNoEnergy; double emissionRate; @@ -166,7 +166,7 @@ public: State getState() const {return state;} BlendMode getBlendMode() const {return blendMode;} Texture *getTexture() const {return texture;} - Vec3f getPos() const {return pos;} + Vec3d getPos() const {return pos;} Particle *getParticle(int i) {return &particles[i];} const Particle *getParticle(int i) const {return &particles[i];} int getAliveParticleCount() const {return aliveParticleCount;} @@ -181,7 +181,7 @@ public: //set virtual void setState(State state); void setTexture(Texture *texture); - virtual void setPos(Vec3f pos); + virtual void setPos(Vec3d pos); void setColor(Vec4f color); void setColorNoEnergy(Vec4f color); void setEmissionRate(double emissionRate); @@ -237,7 +237,7 @@ protected: class FireParticleSystem: public ParticleSystem{ private: double radius; - Vec3f windSpeed; + Vec3d windSpeed; public: FireParticleSystem(int particleCount= 2000); @@ -280,8 +280,8 @@ public: ParticleSystem* getChild(int i); void addChild(UnitParticleSystem* child); void removeChild(UnitParticleSystem* child); - void setPos(Vec3f pos); - void setOffset(Vec3f offset); + void setPos(Vec3d pos); + void setOffset(Vec3d offset); void setModel(Model *model) {this->model= model;} virtual void render(ParticleRenderer *pr, ModelRenderer *mr); double getTween() { return tween; } // 0.0 -> 1.0 for animation of model @@ -289,7 +289,7 @@ public: virtual string getModelFileLoadDeferred(); void setPrimitive(Primitive primitive) {this->primitive= primitive;} - Vec3f getDirection() const {return direction;} + Vec3d getDirection() const {return direction;} void setModelCycle(double modelCycle) {this->modelCycle= modelCycle;} virtual void saveGame(XmlNode *rootNode); @@ -307,8 +307,8 @@ protected: string modelFileLoadDeferred; Model *model; double modelCycle; - Vec3f offset; - Vec3f direction; + Vec3d offset; + Vec3d direction; double tween; GameParticleSystem(int particleCount); @@ -327,10 +327,10 @@ public: private: double radius; double minRadius; - Vec3f windSpeed; - Vec3f cRotation; - Vec3f fixedAddition; - Vec3f oldPosition; + Vec3d windSpeed; + Vec3d cRotation; + Vec3d fixedAddition; + Vec3d oldPosition; bool energyUp; double startTime; double endTime; @@ -385,7 +385,7 @@ public: void setWind(double windAngle, double windSpeed); - void setDirection(Vec3f direction) {this->direction= direction;} + void setDirection(Vec3d direction) {this->direction= direction;} void setSizeNoEnergy(double sizeNoEnergy) {this->sizeNoEnergy= sizeNoEnergy;} void setGravity(double gravity) {this->gravity= gravity;} void setRotation(double rotation); @@ -404,7 +404,7 @@ public: void setLifetime(int lifetime) {this->lifetime= lifetime;} void setParent(GameParticleSystem* parent) {this->parent= parent;} GameParticleSystem* getParent() const {return parent;} - void setParentDirection(Vec3f parentDirection); + void setParentDirection(Vec3d parentDirection); static Shape strToShape(const string& str); @@ -422,7 +422,7 @@ public: class RainParticleSystem: public ParticleSystem{ private: - Vec3f windSpeed; + Vec3d windSpeed; double radius; public: @@ -449,7 +449,7 @@ public: class SnowParticleSystem: public ParticleSystem{ private: - Vec3f windSpeed; + Vec3d windSpeed; double radius; public: @@ -514,14 +514,14 @@ public: private: SplashParticleSystem *nextParticleSystem; - Vec3f lastPos; - Vec3f startPos; - Vec3f endPos; - Vec3f flatPos; + Vec3d lastPos; + Vec3d startPos; + Vec3d endPos; + Vec3d flatPos; - Vec3f xVector; - Vec3f yVector; - Vec3f zVector; + Vec3d xVector; + Vec3d yVector; + Vec3d zVector; Trajectory trajectory; double trajectorySpeed; @@ -550,7 +550,7 @@ public: void setTrajectoryScale(double trajectoryScale) {this->trajectoryScale= trajectoryScale;} void setTrajectoryFrequency(double trajectoryFrequency) {this->trajectoryFrequency= trajectoryFrequency;} - void setPath(Vec3f startPos, Vec3f endPos); + void setPath(Vec3d startPos, Vec3d endPos); static Trajectory strToTrajectory(const string &str); diff --git a/source/shared_lib/sources/graphics/gl/particle_renderer_gl.cpp b/source/shared_lib/sources/graphics/gl/particle_renderer_gl.cpp index bc0d5bd2a..f5f68e881 100644 --- a/source/shared_lib/sources/graphics/gl/particle_renderer_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/particle_renderer_gl.cpp @@ -109,7 +109,7 @@ void ParticleRendererGl::renderSystem(ParticleSystem *ps){ for(int i=0; igetAliveParticleCount(); ++i){ const Particle *particle= ps->getParticle(i); float size= particle->getSize()/2.0f; - Vec3f pos= particle->getPos(); + Vec3f pos= Vec3f(particle->getPos()); Vec4f color= particle->getColor(); vertexBuffer[bufferIndex] = pos - (rightVector - upVector) * size; @@ -159,8 +159,8 @@ void ParticleRendererGl::renderSystemLine(ParticleSystem *ps){ particle= ps->getParticle(i); Vec4f color= particle->getColor(); - vertexBuffer[bufferIndex] = particle->getPos(); - vertexBuffer[bufferIndex+1] = particle->getLastPos(); + vertexBuffer[bufferIndex] = Vec3f(particle->getPos()); + vertexBuffer[bufferIndex+1] = Vec3f(particle->getLastPos()); colorBuffer[bufferIndex]= color; colorBuffer[bufferIndex+1]= color; @@ -203,8 +203,8 @@ void ParticleRendererGl::renderSystemLineAlpha(ParticleSystem *ps){ particle= ps->getParticle(i); Vec4f color= particle->getColor(); - vertexBuffer[bufferIndex] = particle->getPos(); - vertexBuffer[bufferIndex+1] = particle->getLastPos(); + vertexBuffer[bufferIndex] = Vec3f(particle->getPos()); + vertexBuffer[bufferIndex+1] = Vec3f(particle->getLastPos()); colorBuffer[bufferIndex]= color; colorBuffer[bufferIndex+1]= color; @@ -236,29 +236,17 @@ void ParticleRendererGl::renderModel(GameParticleSystem *ps, ModelRenderer *mr){ glPushMatrix(); //translate - Vec3f pos= ps->getPos(); + Vec3f pos= Vec3f(ps->getPos()); glTranslatef(pos.x, pos.y, pos.z); //rotate - Vec3f direction= ps->getDirection(); + Vec3f direction= Vec3f(ps->getDirection()); Vec3f flatDirection= Vec3f(direction.x, 0.f, direction.z); Vec3f rotVector= Vec3f(0.f, 1.f, 0.f).cross(flatDirection); -//#ifdef USE_STREFLOP -// float angleV= radToDeg(streflop::atan2(static_cast(flatDirection.length()), static_cast(direction.y))) - 90.f; -//#else -// float angleV= radToDeg(atan2(flatDirection.length(), direction.y)) - 90.f; -//#endif - float angleV= radToDeg(std::atan2(flatDirection.length(), (double)direction.y)) - 90.f; glRotatef(angleV, rotVector.x, rotVector.y, rotVector.z); -//#ifdef USE_STREFLOP -// float angleH= radToDeg(streflop::atan2(static_cast(direction.x), static_cast(direction.z))); -//#else -// float angleH= radToDeg(atan2(direction.x, direction.z)); -//#endif - float angleH= radToDeg(std::atan2(direction.x, direction.z)); glRotatef(angleH, 0.f, 1.f, 0.f); diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index 29c5d32ca..5da534641 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -65,13 +65,13 @@ void Particle::loadGame(const XmlNode *rootNode) { //particleNode = aiNode->getAttribute("startLoc")->getIntValue(); // Vec3f pos; - pos = Vec3f::strToVec3(particleNode->getAttribute("pos")->getValue()); + pos = Vec3d::strToVec3(particleNode->getAttribute("pos")->getValue()); // Vec3f lastPos; - lastPos = Vec3f::strToVec3(particleNode->getAttribute("lastPos")->getValue()); + lastPos = Vec3d::strToVec3(particleNode->getAttribute("lastPos")->getValue()); // Vec3f speed; - speed = Vec3f::strToVec3(particleNode->getAttribute("speed")->getValue()); + speed = Vec3d::strToVec3(particleNode->getAttribute("speed")->getValue()); // Vec3f accel; - accel = Vec3f::strToVec3(particleNode->getAttribute("accel")->getValue()); + accel = Vec3d::strToVec3(particleNode->getAttribute("accel")->getValue()); // Vec4f color; color = Vec4f::strToVec4(particleNode->getAttribute("color")->getValue()); // float size; @@ -112,7 +112,7 @@ ParticleSystem::ParticleSystem(int particleCount) { //this->particleCount= particles.size(); maxParticleEnergy= 250; varParticleEnergy= 50; - pos= Vec3f(0.0f); + pos= Vec3d(0.0f); color= Vec4f(1.0f); colorNoEnergy= Vec4f(0.0f); emissionRate= 15.0f; @@ -251,7 +251,7 @@ void ParticleSystem::setTexture(Texture *texture){ this->texture= texture; } -void ParticleSystem::setPos(Vec3f pos){ +void ParticleSystem::setPos(Vec3d pos){ this->pos= pos; for(int i=getChildCount()-1; i>=0; i--) getChild(i)->setPos(pos); @@ -485,7 +485,7 @@ void ParticleSystem::loadGame(const XmlNode *rootNode) { } // Vec3f pos; - pos = Vec3f::strToVec3(particleSystemNode->getAttribute("pos")->getValue()); + pos = Vec3d::strToVec3(particleSystemNode->getAttribute("pos")->getValue()); // Vec4f color; color = Vec4f::strToVec4(particleSystemNode->getAttribute("color")->getValue()); // Vec4f colorNoEnergy; @@ -601,8 +601,8 @@ Particle * ParticleSystem::createParticle(){ void ParticleSystem::initParticle(Particle *p, int particleIndex){ p->pos= pos; p->lastPos= p->pos; - p->speed= Vec3f(0.0f); - p->accel= Vec3f(0.0f); + p->speed= Vec3d(0.0f); + p->accel= Vec3d(0.0f); p->color= Vec4f(1.0f, 1.0f, 1.0f, 1.0); p->size= particleSize; p->energy= maxParticleEnergy + random.randRange(-varParticleEnergy, varParticleEnergy); @@ -647,7 +647,7 @@ FireParticleSystem::FireParticleSystem(int particleCount) : radius= 0.5f; speed= 0.01f; - windSpeed= Vec3f(0.0f); + windSpeed= Vec3d(0.0f); setParticleSize(0.6f); setColorNoEnergy(Vec4f(1.0f, 0.5f, 0.0f, 1.0f)); @@ -676,10 +676,10 @@ void FireParticleSystem::initParticle(Particle *p, int particleIndex){ p->color= colorNoEnergy * 0.5f + colorNoEnergy * 0.5f * radRatio; p->energy= static_cast (maxParticleEnergy * radRatio) + random.randRange(-varParticleEnergy, varParticleEnergy); - p->pos= Vec3f(pos.x + x, pos.y + random.randRange(-radius / 2, radius / 2), pos.z + y); + p->pos= Vec3d(pos.x + x, pos.y + random.randRange(-radius / 2, radius / 2), pos.z + y); p->lastPos= pos; p->size= particleSize; - p->speed= Vec3f(0, speed + speed * random.randRange(-0.5f, 0.5f), 0) + windSpeed; + p->speed= Vec3d(0, speed + speed * random.randRange(-0.5f, 0.5f), 0) + windSpeed; } void FireParticleSystem::updateParticle(Particle *p){ @@ -744,7 +744,7 @@ void FireParticleSystem::loadGame(const XmlNode *rootNode) { // float radius; radius = fireParticleSystemNode->getAttribute("radius")->getFloatValue(); // Vec3f windSpeed; - windSpeed = Vec3f::strToVec3(fireParticleSystemNode->getAttribute("windSpeed")->getValue()); + windSpeed = Vec3d::strToVec3(fireParticleSystemNode->getAttribute("windSpeed")->getValue()); } Checksum FireParticleSystem::getCRC() { @@ -810,18 +810,18 @@ void GameParticleSystem::removeChild(UnitParticleSystem* child){ children.erase(it); } -void GameParticleSystem::setPos(Vec3f pos){ +void GameParticleSystem::setPos(Vec3d pos){ this->pos= pos; positionChildren(); } void GameParticleSystem::positionChildren() { - Vec3f child_pos = pos - offset; + Vec3d child_pos = pos - offset; for(int i=getChildCount()-1; i>=0; i--) getChild(i)->setPos(child_pos); } -void GameParticleSystem::setOffset(Vec3f offset){ +void GameParticleSystem::setOffset(Vec3d offset){ this->offset= offset; positionChildren(); } @@ -870,7 +870,7 @@ void GameParticleSystem::setTween(double relative,double absolute) { } } - tween = truncateDecimal(tween); + tween = truncateDecimal(tween,16); if(tween < 0.0f || tween > 1.0f) { //printf("In [%s::%s Line: %d] WARNING setting tween to [%f] clamping tween, modelCycle [%f] absolute [%f] relative [%f]\n",__FILE__,__FUNCTION__,__LINE__,tween,modelCycle,absolute,relative); //assert(tween >= 0.0f && tween <= 1.0f); @@ -952,9 +952,9 @@ void GameParticleSystem::loadGame(const XmlNode *rootNode) { //gameParticleSystemNode->addAttribute("modelCycle",floatToStr(modelCycle), mapTagReplacements); modelCycle = gameParticleSystemNode->getAttribute("modelCycle")->getFloatValue(); // Vec3f offset; - offset = Vec3f::strToVec3(gameParticleSystemNode->getAttribute("offset")->getValue()); + offset = Vec3d::strToVec3(gameParticleSystemNode->getAttribute("offset")->getValue()); // Vec3f direction; - direction = Vec3f::strToVec3(gameParticleSystemNode->getAttribute("direction")->getValue()); + direction = Vec3d::strToVec3(gameParticleSystemNode->getAttribute("direction")->getValue()); // float tween; tween = gameParticleSystemNode->getAttribute("tween")->getFloatValue(); } @@ -992,7 +992,7 @@ UnitParticleSystem::UnitParticleSystem(int particleCount) : GameParticleSystem(particleCount), parent(NULL) { radius= 0.5f; speed= 0.01f; - windSpeed= Vec3f(0.0f); + windSpeed= Vec3d(0.0f); minRadius = 0.0; setParticleSize(0.6f); @@ -1014,8 +1014,8 @@ UnitParticleSystem::UnitParticleSystem(int particleCount) : isVisibleAtDay= true; isDaylightAffected= false; - cRotation= Vec3f(1.0f, 1.0f, 1.0f); - fixedAddition= Vec3f(0.0f, 0.0f, 0.0f); + cRotation= Vec3d(1.0f, 1.0f, 1.0f); + fixedAddition= Vec3d(0.0f, 0.0f, 0.0f); //prepare system for given staticParticleCount if(staticParticleCount > 0){ emissionState= (double) staticParticleCount; @@ -1108,7 +1108,7 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){ p->lastPos= pos; oldPosition= pos; p->size= particleSize; - p->accel= Vec3f(0.0f, -gravity, 0.0f); + p->accel= Vec3d(0.0f, -gravity, 0.0f); // work out where we start for our shape (set speed and pos) switch(shape){ @@ -1116,9 +1116,9 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){ angle = (double)random.randRange(0,360); // fall through case sConical:{ - Vec2f horiz = Vec2f(1,0).rotate(ang); - Vec2f vert = Vec2f(1,0).rotate(degToRad(angle)); - Vec3f start = Vec3f(horiz.x*vert.y,vert.x,horiz.y).getNormalized(); // close enough + Vec2d horiz = Vec2d(1,0).rotate(ang); + Vec2d vert = Vec2d(1,0).rotate(degToRad(angle)); + Vec3d start = Vec3d(horiz.x*vert.y,vert.x,horiz.y).getNormalized(); // close enough p->speed = start * speed; start = start * random.randRange(minRadius,radius); p->pos = pos + offset + start; @@ -1133,25 +1133,25 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){ #endif const double rad= degToRad(rotation); if(!relative){ - p->pos= Vec3f(pos.x + x + offset.x, pos.y + random.randRange(-radius / 2, radius / 2) + offset.y, pos.z + y + p->pos= Vec3d(pos.x + x + offset.x, pos.y + random.randRange(-radius / 2, radius / 2) + offset.y, pos.z + y + offset.z); } else{// rotate it according to rotation #ifdef USE_STREFLOP - p->pos= Vec3f(pos.x+x+offset.z*streflop::sinf(static_cast(rad))+offset.x*streflop::cosf(static_cast(rad)), pos.y+random.randRange(-radius/2, radius/2)+offset.y, pos.z+y+(offset.z*streflop::cosf(static_cast(rad))-offset.x*streflop::sinf(static_cast(rad)))); + p->pos= Vec3d(pos.x+x+offset.z*streflop::sinf(static_cast(rad))+offset.x*streflop::cosf(static_cast(rad)), pos.y+random.randRange(-radius/2, radius/2)+offset.y, pos.z+y+(offset.z*streflop::cosf(static_cast(rad))-offset.x*streflop::sinf(static_cast(rad)))); #else - p->pos= Vec3f(pos.x + x + offset.z * sinf(rad) + offset.x * cosf(rad), pos.y + random.randRange(-radius / 2, + p->pos= Vec3d(pos.x + x + offset.z * sinf(rad) + offset.x * cosf(rad), pos.y + random.randRange(-radius / 2, radius / 2) + offset.y, pos.z + y + (offset.z * cosf(rad) - offset.x * sinf(rad))); #endif } - p->speed= Vec3f(direction.x + direction.x * random.randRange(-0.5f, 0.5f), direction.y + direction.y + p->speed= Vec3d(direction.x + direction.x * random.randRange(-0.5f, 0.5f), direction.y + direction.y * random.randRange(-0.5f, 0.5f), direction.z + direction.z * random.randRange(-0.5f, 0.5f)); p->speed= p->speed * speed; if(relative && relativeDirection){ #ifdef USE_STREFLOP - p->speed=Vec3f(p->speed.z*streflop::sinf(static_cast(rad))+p->speed.x*streflop::cosf(static_cast(rad)),p->speed.y,(p->speed.z*streflop::cosf(static_cast(rad))-p->speed.x*streflop::sinf(static_cast(rad)))); + p->speed=Vec3d(p->speed.z*streflop::sinf(static_cast(rad))+p->speed.x*streflop::cosf(static_cast(rad)),p->speed.y,(p->speed.z*streflop::cosf(static_cast(rad))-p->speed.x*streflop::sinf(static_cast(rad)))); #else - p->speed= Vec3f(p->speed.z * sinf(rad) + p->speed.x * cosf(rad), p->speed.y, (p->speed.z * cosf(rad) + p->speed= Vec3d(p->speed.z * sinf(rad) + p->speed.x * cosf(rad), p->speed.y, (p->speed.z * cosf(rad) - p->speed.x * sinf(rad))); #endif } @@ -1175,7 +1175,7 @@ void UnitParticleSystem::update(){ } } if(fixed){ - fixedAddition= Vec3f(pos.x - oldPosition.x, pos.y - oldPosition.y, pos.z - oldPosition.z); + fixedAddition= Vec3d(pos.x - oldPosition.x, pos.y - oldPosition.y, pos.z - oldPosition.z); oldPosition= pos; } ParticleSystem::update(); @@ -1323,13 +1323,13 @@ void UnitParticleSystem::loadGame(const XmlNode *rootNode) { // float minRadius; minRadius = unitParticleSystemNode->getAttribute("minRadius")->getFloatValue(); // Vec3f windSpeed; - windSpeed = Vec3f::strToVec3(unitParticleSystemNode->getAttribute("windSpeed")->getValue()); + windSpeed = Vec3d::strToVec3(unitParticleSystemNode->getAttribute("windSpeed")->getValue()); // Vec3f cRotation; - windSpeed = Vec3f::strToVec3(unitParticleSystemNode->getAttribute("cRotation")->getValue()); + windSpeed = Vec3d::strToVec3(unitParticleSystemNode->getAttribute("cRotation")->getValue()); // Vec3f fixedAddition; - fixedAddition = Vec3f::strToVec3(unitParticleSystemNode->getAttribute("fixedAddition")->getValue()); + fixedAddition = Vec3d::strToVec3(unitParticleSystemNode->getAttribute("fixedAddition")->getValue()); // Vec3f oldPosition; - oldPosition = Vec3f::strToVec3(unitParticleSystemNode->getAttribute("oldPosition")->getValue()); + oldPosition = Vec3d::strToVec3(unitParticleSystemNode->getAttribute("oldPosition")->getValue()); // bool energyUp; energyUp = unitParticleSystemNode->getAttribute("energyUp")->getIntValue() != 0; // float startTime; @@ -1450,9 +1450,9 @@ void RainParticleSystem::initParticle(Particle *p, int particleIndex){ p->color= color; p->energy= 10000; - p->pos= Vec3f(pos.x + x, pos.y, pos.z + y); + p->pos= Vec3d(pos.x + x, pos.y, pos.z + y); p->lastPos= p->pos; - p->speed= Vec3f(random.randRange(-speed / 10, speed / 10), -speed, random.randRange(-speed / 10, speed / 10)) + p->speed= Vec3d(random.randRange(-speed / 10, speed / 10), -speed, random.randRange(-speed / 10, speed / 10)) + windSpeed; } @@ -1517,9 +1517,9 @@ void SnowParticleSystem::initParticle(Particle *p, int particleIndex){ p->color= color; p->energy= 10000; - p->pos= Vec3f(pos.x + x, pos.y, pos.z + y); + p->pos= Vec3d(pos.x + x, pos.y, pos.z + y); p->lastPos= p->pos; - p->speed= Vec3f(0.0f, -speed, 0.0f) + windSpeed; + p->speed= Vec3d(0.0f, -speed, 0.0f) + windSpeed; p->speed.x+= random.randRange(-0.005f, 0.005f); p->speed.y+= random.randRange(-0.005f, 0.005f); } @@ -1653,24 +1653,24 @@ void ProjectileParticleSystem::update(){ if(state == sPlay){ lastPos = pos; - flatPos += zVector * truncateDecimal(trajectorySpeed); - flatPos.x = truncateDecimal(flatPos.x); - flatPos.y = truncateDecimal(flatPos.y); - flatPos.z = truncateDecimal(flatPos.z); + flatPos += zVector * truncateDecimal(trajectorySpeed,16); + flatPos.x = truncateDecimal(flatPos.x,16); + flatPos.y = truncateDecimal(flatPos.y,16); + flatPos.z = truncateDecimal(flatPos.z,16); - Vec3f targetVector = endPos - startPos; - targetVector.x = truncateDecimal(targetVector.x); - targetVector.y = truncateDecimal(targetVector.y); - targetVector.z = truncateDecimal(targetVector.z); + Vec3d targetVector = endPos - startPos; + targetVector.x = truncateDecimal(targetVector.x,16); + targetVector.y = truncateDecimal(targetVector.y,16); + targetVector.z = truncateDecimal(targetVector.z,16); - Vec3f currentVector = flatPos - startPos; - currentVector.x = truncateDecimal(currentVector.x); - currentVector.y = truncateDecimal(currentVector.y); - currentVector.z = truncateDecimal(currentVector.z); + Vec3d currentVector = flatPos - startPos; + currentVector.x = truncateDecimal(currentVector.x,16); + currentVector.y = truncateDecimal(currentVector.y,16); + currentVector.z = truncateDecimal(currentVector.z,16); // ratio double relative= clamp(currentVector.length() / targetVector.length(), 0.0f, 1.0f); - relative = truncateDecimal(relative); + relative = truncateDecimal(relative,16); //printf("Update particle targetVector [%s][%f] currentVector [%s][%f] relative = %f\n",targetVector.getString().c_str(),targetVector.length(),currentVector.getString().c_str(),currentVector.length(),relative); @@ -1693,12 +1693,12 @@ void ProjectileParticleSystem::update(){ break; case tParabolic: { - double scaledT = truncateDecimal(2.0f * (relative - 0.5f)); - double paraboleY = truncateDecimal((1.0f - scaledT * scaledT) * trajectoryScale); + double scaledT = truncateDecimal(2.0f * (relative - 0.5f),16); + double paraboleY = truncateDecimal((1.0f - scaledT * scaledT) * trajectoryScale,16); pos= flatPos; pos.y += paraboleY; - pos.y = truncateDecimal(pos.y); + pos.y = truncateDecimal(pos.y,16); } break; @@ -1711,9 +1711,9 @@ void ProjectileParticleSystem::update(){ pos+= xVector * cos(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale; pos+= yVector * sin(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale; #endif - pos.x = truncateDecimal(pos.x); - pos.y = truncateDecimal(pos.y); - pos.z = truncateDecimal(pos.z); + pos.x = truncateDecimal(pos.x,16); + pos.y = truncateDecimal(pos.y,16); + pos.z = truncateDecimal(pos.z,16); } break; @@ -1724,16 +1724,16 @@ void ProjectileParticleSystem::update(){ direction= pos - lastPos; direction.normalize(); - direction.x = truncateDecimal(direction.x); - direction.y = truncateDecimal(direction.y); - direction.z = truncateDecimal(direction.z); + direction.x = truncateDecimal(direction.x,16); + direction.y = truncateDecimal(direction.y,16); + direction.z = truncateDecimal(direction.z,16); // trigger update of child particles positionChildren(); rotateChildren(); //arrive destination - arriveDestinationDistance = truncateDecimal(flatPos.dist(endPos)); + arriveDestinationDistance = truncateDecimal(flatPos.dist(endPos),16); if(arriveDestinationDistance < 0.5f) { fade(); model= NULL; @@ -1757,11 +1757,11 @@ void ProjectileParticleSystem::update(){ void ProjectileParticleSystem::rotateChildren() { //### only on horizontal plane :( #ifdef USE_STREFLOP - double rotation = truncateDecimal(streflop::atan2(static_cast(direction.x), static_cast(direction.z))); + double rotation = truncateDecimal(streflop::atan2(static_cast(direction.x), static_cast(direction.z)),16); #else - double rotation = truncateDecimal(atan2(direction.x, direction.z)); + double rotation = truncateDecimal(atan2(direction.x, direction.z),16); #endif - rotation = truncateDecimal(radToDeg(rotation)); + rotation = truncateDecimal(radToDeg(rotation),16); for(Children::iterator it = children.begin(); it != children.end(); ++it) (*it)->setRotation(rotation); } @@ -1771,20 +1771,20 @@ void ProjectileParticleSystem::initParticle(Particle *p, int particleIndex){ ParticleSystem::initParticle(p, particleIndex); double t= static_cast (particleIndex) / emissionRate; - t = truncateDecimal(t); + t = truncateDecimal(t,16); p->pos= pos + (lastPos - pos) * t; p->lastPos= lastPos; - p->speed= Vec3f(random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f)) + p->speed= Vec3d(random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f)) * speed; - p->accel= Vec3f(0.0f, -gravity, 0.0f); + p->accel= Vec3d(0.0f, -gravity, 0.0f); updateParticle(p); } void ProjectileParticleSystem::updateParticle(Particle *p){ double energyRatio= clamp(static_cast (p->energy) / maxParticleEnergy, 0.f, 1.f); - energyRatio = truncateDecimal(energyRatio); + energyRatio = truncateDecimal(energyRatio,16); p->lastPos+= p->speed; p->pos+= p->speed; @@ -1794,12 +1794,12 @@ void ProjectileParticleSystem::updateParticle(Particle *p){ p->energy--; } -void ProjectileParticleSystem::setPath(Vec3f startPos, Vec3f endPos){ +void ProjectileParticleSystem::setPath(Vec3d startPos, Vec3d endPos){ //compute axis zVector= endPos - startPos; zVector.normalize(); - yVector= Vec3f(0.0f, 1.0f, 0.0f); + yVector= Vec3d(0.0f, 1.0f, 0.0f); xVector= zVector.cross(yVector); //apply offset @@ -1814,7 +1814,7 @@ void ProjectileParticleSystem::setPath(Vec3f startPos, Vec3f endPos){ //recompute axis zVector= endPos - startPos; zVector.normalize(); - yVector= Vec3f(0.0f, 1.0f, 0.0f); + yVector= Vec3d(0.0f, 1.0f, 0.0f); xVector= zVector.cross(yVector); // set members @@ -1894,20 +1894,20 @@ void ProjectileParticleSystem::loadGame(const XmlNode *rootNode) { nextParticleSystem->loadGame(splashParticleSystemNode); } // Vec3f lastPos; - lastPos = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("lastPos")->getValue()); + lastPos = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("lastPos")->getValue()); // Vec3f startPos; - startPos = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("startPos")->getValue()); + startPos = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("startPos")->getValue()); // Vec3f endPos; - endPos = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("endPos")->getValue()); + endPos = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("endPos")->getValue()); // Vec3f flatPos; - flatPos = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("flatPos")->getValue()); + flatPos = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("flatPos")->getValue()); // // Vec3f xVector; - xVector = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("xVector")->getValue()); + xVector = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("xVector")->getValue()); // Vec3f yVector; - yVector = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("yVector")->getValue()); + yVector = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("yVector")->getValue()); // Vec3f zVector; - zVector = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("zVector")->getValue()); + zVector = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("zVector")->getValue()); // Trajectory trajectory; trajectory = static_cast(projectileParticleSystemNode->getAttribute("trajectory")->getIntValue()); // float trajectorySpeed; @@ -1990,7 +1990,7 @@ void SplashParticleSystem::update() { emissionRate -= emissionRateFade; double t = 1.0f - ((emissionRate + startEmissionRate) / (startEmissionRate * 2.0f)); - t = truncateDecimal(t); + t = truncateDecimal(t,16); t= clamp(t, 0.0f, 1.0f); setTween(t,t); @@ -2008,13 +2008,13 @@ void SplashParticleSystem::initParticle(Particle *p, int particleIndex){ p->size= particleSize; p->color= color; - p->speed= Vec3f(horizontalSpreadA * random.randRange(-1.0f, 1.0f) + horizontalSpreadB, verticalSpreadA + p->speed= Vec3d(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.normalize(); p->speed= p->speed * speed; - p->accel= Vec3f(0.0f, -gravity, 0.0f); + p->accel= Vec3d(0.0f, -gravity, 0.0f); } void SplashParticleSystem::updateParticle(Particle *p){