- attempt to see if this makes stability better

This commit is contained in:
Mark Vejvoda 2013-10-02 20:22:10 +00:00
parent ee6eadb0d8
commit dc503d6340
33 changed files with 692 additions and 712 deletions

View File

@ -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);
Vec3d vec = Vec3d(0.f, height / 2.f, 0.f);
Vec3f vec = Vec3f(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) {
Vec3d vec = Vec3d(0.f, height / 2.f, 0.f);
Vec3f vec = Vec3f(0.f, height / 2.f, 0.f);
//ps->setPos(vec);
Vec3d vec2 = Vec3d(size * 2.f, height * 2.f, height * 2.f);
Vec3f vec2 = Vec3f(size * 2.f, height * 2.f, height * 2.f);
ps->setPath(vec, vec2);
}
ps->setFactionColor(renderer->getPlayerColorTexture(playerColor)->getPixmap()->getPixel3f(0,0));

View File

@ -1639,7 +1639,7 @@ void PathFinder::saveGame(XmlNode *rootNode) {
nodePoolNode->addAttribute("next",intToStr(nextIdx), mapTagReplacements);
int prevIdx = findNodeIndex(curNode->prev, factionState.nodePool);
nodePoolNode->addAttribute("prev",intToStr(prevIdx), mapTagReplacements);
nodePoolNode->addAttribute("heuristic",doubleToStr(curNode->heuristic,10), mapTagReplacements);
nodePoolNode->addAttribute("heuristic",doubleToStr(curNode->heuristic,6), mapTagReplacements);
nodePoolNode->addAttribute("exploredCell",intToStr(curNode->exploredCell), mapTagReplacements);
}

View File

@ -1418,14 +1418,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(Vec3d(gameCamera.getPos()));
weatherParticleSystem->setPos(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(Vec3d(gameCamera.getPos()));
weatherParticleSystem->setPos(gameCamera.getPos());
weatherParticleSystem->setTexture(coreData.getSnowTexture());
renderer.manageParticleSystem(weatherParticleSystem, rsGame);
}
@ -2143,7 +2143,7 @@ void Game::update() {
}
if(currentCameraFollowUnit!=NULL){
Vec3d c=currentCameraFollowUnit->getCurrVector();
Vec3f c=currentCameraFollowUnit->getCurrVector();
int rotation=currentCameraFollowUnit->getRotation();
double angle=rotation+180;
@ -2192,7 +2192,7 @@ void Game::update() {
//Particle systems
if(weatherParticleSystem != NULL) {
weatherParticleSystem->setPos(Vec3d(gameCamera.getPos()));
weatherParticleSystem->setPos(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);
@ -6242,7 +6242,7 @@ string Game::saveGame(string name, string path) {
//bool showFullConsole;
//bool mouseMoved;
//float scrollSpeed;
gameNode->addAttribute("scrollSpeed",floatToStr(scrollSpeed,10), mapTagReplacements);
gameNode->addAttribute("scrollSpeed",floatToStr(scrollSpeed,6), mapTagReplacements);
//bool camLeftButtonDown;
//bool camRightButtonDown;
//bool camUpButtonDown;
@ -6336,8 +6336,8 @@ string Game::saveGame(string name, string path) {
HighlightSpecialUnitInfo &info = iterMap->second;
XmlNode *infoNode = unitHighlightListNode->addChild("info");
infoNode->addAttribute("unitid",intToStr(iterMap->first), mapTagReplacements);
infoNode->addAttribute("radius",floatToStr(info.radius,10), mapTagReplacements);
infoNode->addAttribute("thickness",floatToStr(info.thickness,10), mapTagReplacements);
infoNode->addAttribute("radius",floatToStr(info.radius,6), mapTagReplacements);
infoNode->addAttribute("thickness",floatToStr(info.thickness,6), mapTagReplacements);
infoNode->addAttribute("color",info.color.getString(), mapTagReplacements);
}

View File

@ -466,18 +466,18 @@ void GameCamera::saveGame(XmlNode *rootNode) {
gamecameraNode->addAttribute("destPos",destPos.getString(), mapTagReplacements);
//
// float hAng; //YZ plane positive -Z axis
gamecameraNode->addAttribute("hAng",floatToStr(hAng,10), mapTagReplacements);
gamecameraNode->addAttribute("hAng",floatToStr(hAng,6), mapTagReplacements);
// float vAng; //XZ plane positive +Z axis
gamecameraNode->addAttribute("vAng",floatToStr(vAng,10), mapTagReplacements);
gamecameraNode->addAttribute("vAng",floatToStr(vAng,6), mapTagReplacements);
// float lastHAng;
gamecameraNode->addAttribute("lastHAng",floatToStr(lastHAng,10), mapTagReplacements);
gamecameraNode->addAttribute("lastHAng",floatToStr(lastHAng,6), mapTagReplacements);
// float lastVAng;
gamecameraNode->addAttribute("lastVAng",floatToStr(lastVAng,10), mapTagReplacements);
gamecameraNode->addAttribute("lastVAng",floatToStr(lastVAng,6), mapTagReplacements);
// Vec2f destAng;
gamecameraNode->addAttribute("destAng",destAng.getString(), mapTagReplacements);
// float rotate;
gamecameraNode->addAttribute("rotate",floatToStr(rotate,10), mapTagReplacements);
gamecameraNode->addAttribute("rotate",floatToStr(rotate,6), mapTagReplacements);
// Vec3f move;
gamecameraNode->addAttribute("move",move.getString(), mapTagReplacements);
// State state;
@ -488,24 +488,24 @@ void GameCamera::saveGame(XmlNode *rootNode) {
gamecameraNode->addAttribute("limitY",intToStr(limitY), mapTagReplacements);
// //config
// float speed;
gamecameraNode->addAttribute("speed",floatToStr(speed,10), mapTagReplacements);
gamecameraNode->addAttribute("speed",floatToStr(speed,6), mapTagReplacements);
// bool clampBounds;
gamecameraNode->addAttribute("clampBounds",intToStr(clampBounds), mapTagReplacements);
// //float maxRenderDistance;
// float maxHeight;
gamecameraNode->addAttribute("maxHeight",floatToStr(maxHeight,10), mapTagReplacements);
gamecameraNode->addAttribute("maxHeight",floatToStr(maxHeight,6), mapTagReplacements);
// float minHeight;
gamecameraNode->addAttribute("minHeight",floatToStr(minHeight,10), mapTagReplacements);
gamecameraNode->addAttribute("minHeight",floatToStr(minHeight,6), mapTagReplacements);
// //float maxCameraDist;
// //float minCameraDist;
// float minVAng;
gamecameraNode->addAttribute("minVAng",floatToStr(minVAng,10), mapTagReplacements);
gamecameraNode->addAttribute("minVAng",floatToStr(minVAng,6), mapTagReplacements);
// float maxVAng;
gamecameraNode->addAttribute("maxVAng",floatToStr(maxVAng,10), mapTagReplacements);
gamecameraNode->addAttribute("maxVAng",floatToStr(maxVAng,6), mapTagReplacements);
// float fov;
gamecameraNode->addAttribute("fov",floatToStr(fov,10), mapTagReplacements);
gamecameraNode->addAttribute("fov",floatToStr(fov,6), mapTagReplacements);
// float calculatedDefault;
gamecameraNode->addAttribute("calculatedDefault",floatToStr(calculatedDefault,10), mapTagReplacements);
gamecameraNode->addAttribute("calculatedDefault",floatToStr(calculatedDefault,6), mapTagReplacements);
// std::map<float, std::map<float, std::map<Vec3f, Quad2i> > > cacheVisibleQuad;
// int MaxVisibleQuadItemCache;
gamecameraNode->addAttribute("MaxVisibleQuadItemCache",intToStr(MaxVisibleQuadItemCache), mapTagReplacements);

View File

@ -179,7 +179,7 @@ void Stats::saveGame(XmlNode *rootNode) {
// ControlType control;
statsNodePlayer->addAttribute("control",intToStr(stat.control), mapTagReplacements);
// float resourceMultiplier;
statsNodePlayer->addAttribute("resourceMultiplier",floatToStr(stat.resourceMultiplier,10), mapTagReplacements);
statsNodePlayer->addAttribute("resourceMultiplier",floatToStr(stat.resourceMultiplier,6), mapTagReplacements);
// string factionTypeName;
statsNodePlayer->addAttribute("factionTypeName",stat.factionTypeName, mapTagReplacements);
// FactionPersonalityType personalityType;
@ -211,7 +211,7 @@ void Stats::saveGame(XmlNode *rootNode) {
statsNode->addAttribute("thisFactionIndex",intToStr(thisFactionIndex), mapTagReplacements);
//
// float worldTimeElapsed;
statsNode->addAttribute("worldTimeElapsed",floatToStr(worldTimeElapsed,10), mapTagReplacements);
statsNode->addAttribute("worldTimeElapsed",floatToStr(worldTimeElapsed,6), mapTagReplacements);
// int framesPlayed;
statsNode->addAttribute("framesPlayed",intToStr(framesPlayed), mapTagReplacements);
// int framesToCalculatePlaytime;

View File

@ -327,7 +327,7 @@ void ParticleSystemType::saveGame(XmlNode *rootNode) {
// Texture2D *texture;
// Model *model;
// float modelCycle;
particleSystemTypeNode->addAttribute("modelCycle",doubleToStr(modelCycle,10), mapTagReplacements);
particleSystemTypeNode->addAttribute("modelCycle",floatToStr(modelCycle,6), mapTagReplacements);
// string primitive;
particleSystemTypeNode->addAttribute("primitive",primitive, mapTagReplacements);
// Vec3f offset;
@ -337,15 +337,15 @@ void ParticleSystemType::saveGame(XmlNode *rootNode) {
// Vec4f colorNoEnergy;
particleSystemTypeNode->addAttribute("colorNoEnergy",colorNoEnergy.getString(), mapTagReplacements);
// float size;
particleSystemTypeNode->addAttribute("size",doubleToStr(size,10), mapTagReplacements);
particleSystemTypeNode->addAttribute("size",floatToStr(size,6), mapTagReplacements);
// float sizeNoEnergy;
particleSystemTypeNode->addAttribute("sizeNoEnergy",doubleToStr(sizeNoEnergy,10), mapTagReplacements);
particleSystemTypeNode->addAttribute("sizeNoEnergy",floatToStr(sizeNoEnergy,6), mapTagReplacements);
// float speed;
particleSystemTypeNode->addAttribute("speed",doubleToStr(speed,10), mapTagReplacements);
particleSystemTypeNode->addAttribute("speed",floatToStr(speed,6), mapTagReplacements);
// float gravity;
particleSystemTypeNode->addAttribute("gravity",doubleToStr(gravity,10), mapTagReplacements);
particleSystemTypeNode->addAttribute("gravity",floatToStr(gravity,6), mapTagReplacements);
// float emissionRate;
particleSystemTypeNode->addAttribute("emissionRate",doubleToStr(emissionRate,10), mapTagReplacements);
particleSystemTypeNode->addAttribute("emissionRate",floatToStr(emissionRate,6), mapTagReplacements);
// int energyMax;
particleSystemTypeNode->addAttribute("energyMax",intToStr(energyMax), mapTagReplacements);
// int energyVar;
@ -413,7 +413,7 @@ void ParticleSystemTypeProjectile::load(const XmlNode* particleFileNode, const s
//trajectory speed
const XmlNode *tajectorySpeedNode= tajectoryNode->getChild("speed");
trajectorySpeed= tajectorySpeedNode->getAttribute("value")->getFloatValue() / (double)GameConstants::updateFps;
trajectorySpeed= tajectorySpeedNode->getAttribute("value")->getFloatValue() / (float)GameConstants::updateFps;
//printf("[%s] trajectorySpeed = %f\n",path.c_str(),trajectorySpeed);
if(trajectory=="parabolic" || trajectory=="spiral"){
@ -466,11 +466,11 @@ void ParticleSystemTypeProjectile::saveGame(XmlNode *rootNode) {
// string trajectory;
particleSystemTypeProjectileNode->addAttribute("trajectory",trajectory, mapTagReplacements);
// float trajectorySpeed;
particleSystemTypeProjectileNode->addAttribute("trajectorySpeed",doubleToStr(trajectorySpeed,10), mapTagReplacements);
particleSystemTypeProjectileNode->addAttribute("trajectorySpeed",floatToStr(trajectorySpeed,6), mapTagReplacements);
// float trajectoryScale;
particleSystemTypeProjectileNode->addAttribute("trajectoryScale",doubleToStr(trajectoryScale,10), mapTagReplacements);
particleSystemTypeProjectileNode->addAttribute("trajectoryScale",floatToStr(trajectoryScale,6), mapTagReplacements);
// float trajectoryFrequency;
particleSystemTypeProjectileNode->addAttribute("trajectoryFrequency",doubleToStr(trajectoryFrequency,10), mapTagReplacements);
particleSystemTypeProjectileNode->addAttribute("trajectoryFrequency",floatToStr(trajectoryFrequency,6), mapTagReplacements);
}
// ===========================================================
@ -549,15 +549,15 @@ void ParticleSystemTypeSplash::saveGame(XmlNode *rootNode) {
XmlNode *particleSystemTypeSplashNode = rootNode->addChild("ParticleSystemTypeSplash");
// float emissionRateFade;
particleSystemTypeSplashNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,10), mapTagReplacements);
particleSystemTypeSplashNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade,6), mapTagReplacements);
// float verticalSpreadA;
particleSystemTypeSplashNode->addAttribute("verticalSpreadA",doubleToStr(verticalSpreadA,10), mapTagReplacements);
particleSystemTypeSplashNode->addAttribute("verticalSpreadA",floatToStr(verticalSpreadA,6), mapTagReplacements);
// float verticalSpreadB;
particleSystemTypeSplashNode->addAttribute("verticalSpreadB",doubleToStr(verticalSpreadB,10), mapTagReplacements);
particleSystemTypeSplashNode->addAttribute("verticalSpreadB",floatToStr(verticalSpreadB,6), mapTagReplacements);
// float horizontalSpreadA;
particleSystemTypeSplashNode->addAttribute("horizontalSpreadA",doubleToStr(horizontalSpreadA,10), mapTagReplacements);
particleSystemTypeSplashNode->addAttribute("horizontalSpreadA",floatToStr(horizontalSpreadA,6), mapTagReplacements);
// float horizontalSpreadB;
particleSystemTypeSplashNode->addAttribute("horizontalSpreadB",doubleToStr(horizontalSpreadB,10), mapTagReplacements);
particleSystemTypeSplashNode->addAttribute("horizontalSpreadB",floatToStr(horizontalSpreadB,6), mapTagReplacements);
}
}}//end mamespace

View File

@ -57,16 +57,16 @@ protected:
string type;
Texture2D *texture;
Model *model;
double modelCycle;
float modelCycle;
string primitive;
Vec3d offset;
Vec3f offset;
Vec4f color;
Vec4f colorNoEnergy;
double size;
double sizeNoEnergy;
double speed;
double gravity;
double emissionRate;
int size;
int sizeNoEnergy;
float speed;
float gravity;
int emissionRate;
int energyMax;
int energyVar;
string mode;
@ -123,9 +123,9 @@ protected:
class ParticleSystemTypeProjectile: public ParticleSystemType{
private:
string trajectory;
double trajectorySpeed;
double trajectoryScale;
double trajectoryFrequency;
float trajectorySpeed;
float trajectoryScale;
float trajectoryFrequency;
public:
ParticleSystemTypeProjectile();
@ -153,11 +153,11 @@ public:
virtual void saveGame(XmlNode *rootNode);
private:
double emissionRateFade;
double verticalSpreadA;
double verticalSpreadB;
double horizontalSpreadA;
double horizontalSpreadB;
float emissionRateFade;
float verticalSpreadA;
float verticalSpreadB;
float horizontalSpreadA;
float horizontalSpreadB;
};
}}//end namespace

View File

@ -1054,7 +1054,7 @@ void Renderer::setupLighting() {
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
if(world->toRenderUnit(unit) &&
unit->getCurrVector().dist(Vec3d(gameCamera->getPos())) < maxLightDist &&
unit->getCurrVector().dist(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());
@ -6662,7 +6662,7 @@ void Renderer::selectUsingFrustumSelection(Selection::UnitContainer &units,
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
if(unit != NULL && unit->isAlive()) {
Vec3d unitPos = unit->getCurrVector();
Vec3f unitPos = unit->getCurrVector();
bool insideQuad = CubeInFrustum(quadSelectionCacheItem.frustumData,
unitPos.x, unitPos.y, unitPos.z, unit->getType()->getSize());
if(insideQuad == true) {

View File

@ -172,7 +172,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
// delay
if(particleSystemNode->hasChild("delay")) {
const XmlNode* delayNode = particleSystemNode->getChild("delay");
const double delay_secs = delayNode->getAttribute("value")->getFloatValue();
const float 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 double lifetime_secs = lifetimeNode->getAttribute("value")->getFloatValue();
const float 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",doubleToStr(angle,10), mapTagReplacements);
unitParticleSystemTypeNode->addAttribute("angle",floatToStr(angle,6), mapTagReplacements);
// float radius;
unitParticleSystemTypeNode->addAttribute("radius",doubleToStr(radius,10), mapTagReplacements);
unitParticleSystemTypeNode->addAttribute("radius",floatToStr(radius,6), mapTagReplacements);
// float minRadius;
unitParticleSystemTypeNode->addAttribute("minRadius",doubleToStr(minRadius,10), mapTagReplacements);
unitParticleSystemTypeNode->addAttribute("minRadius",floatToStr(minRadius,6), mapTagReplacements);
// float emissionRateFade;
unitParticleSystemTypeNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,10), mapTagReplacements);
unitParticleSystemTypeNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade,6), 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",doubleToStr(startTime,10), mapTagReplacements);
unitParticleSystemTypeNode->addAttribute("startTime",floatToStr(startTime,6), mapTagReplacements);
// float endTime;
unitParticleSystemTypeNode->addAttribute("endTime",doubleToStr(endTime,10), mapTagReplacements);
unitParticleSystemTypeNode->addAttribute("endTime",floatToStr(endTime,6), mapTagReplacements);
}
}}//end mamespace

View File

@ -52,11 +52,11 @@ using Shared::Xml::XmlNode;
class UnitParticleSystemType: public ParticleSystemType {
protected:
UnitParticleSystem::Shape shape;
double angle;
double radius;
double minRadius;
double emissionRateFade;
Vec3d direction;
float angle;
float radius;
float minRadius;
float emissionRateFade;
Vec3f direction;
bool relative;
bool relativeDirection;
bool fixed;
@ -67,8 +67,8 @@ protected:
bool radiusBasedStartenergy;
int delay;
int lifetime;
double startTime;
double endTime;
float startTime;
float endTime;
public:
UnitParticleSystemType();
@ -81,10 +81,10 @@ public:
std::map<string,vector<pair<string, string> > > &loadedFileList,string parentLoader,
string techtreePath);
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; }
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; }
const void setValues (UnitParticleSystem *uts);
bool hasTexture() const { return(texture != NULL); }

View File

@ -540,7 +540,7 @@ void Gui::giveTwoClickOrders(int x, int y , bool prepared) {
void Gui::centerCameraOnSelection() {
if(selection.isEmpty() == false) {
Vec3d refPos= selection.getRefPos();
Vec3f refPos= selection.getRefPos();
gameCamera->centerXZ(refPos.x, refPos.z);
}
}

View File

@ -186,7 +186,7 @@ bool Selection::isMeetable() const{
selectedUnits.front()->getType()->getMeetingPoint();
}
Vec3d Selection::getRefPos() const{
Vec3f Selection::getRefPos() const{
return getFrontUnit()->getCurrVector();
}

View File

@ -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();}
Vec3d getRefPos() const;
Vec3f getRefPos() const;
bool hasUnit(const Unit* unit) const;
void assignGroup(int groupIndex,const UnitContainer *pUnits=NULL);

View File

@ -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(Vec3d(0.f, 25.f, 0.f));
rps->setPos(Vec3f(0.f, 25.f, 0.f));
rps->setColor(Vec4f(1.f, 1.f, 1.f, 0.2f));
rps->setRadius(30.f);

View File

@ -34,7 +34,7 @@ ObjectStateInterface *Object::stateCallback=NULL;
// class Object
// =====================================================
Object::Object(ObjectType *objectType, const Vec3d &pos, const Vec2i &mapPos) : BaseColorPickEntity() {
Object::Object(ObjectType *objectType, const Vec3f &pos, const Vec2i &mapPos) : BaseColorPickEntity() {
RandomGen random;
random.init(static_cast<int>(pos.x * pos.z));
@ -44,7 +44,7 @@ Object::Object(ObjectType *objectType, const Vec3d &pos, const Vec2i &mapPos) :
highlight= 0.f;
animated= false;
this->mapPos = mapPos;
this->pos= pos + Vec3d(random.randRange(-0.6f, 0.6f), 0.0f, random.randRange(-0.6f, 0.6f));
this->pos= pos + Vec3f(random.randRange(-0.6f, 0.6f), 0.0f, random.randRange(-0.6f, 0.6f));
rotation= random.randRange(0.f, 360.f);
if(objectType!=NULL){
variation = random.randRange(0, objectType->getModelCount()-1);
@ -126,7 +126,7 @@ void Object::end(ParticleSystem *particleSystem) {
}
}
void Object::setHeight(double height) {
void Object::setHeight(float height) {
pos.y = height;
for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it != unitParticleSystems.end(); ++it) {
@ -153,17 +153,17 @@ void Object::update() {
// printf("#1 Object updating [%s] Speed [%d] animProgress [%f]\n",this->objectType->getTilesetModelType(variation)->getModel()->getFileName().c_str(),objectType->getTilesetModelType(variation)->getAnimSpeed(),animProgress);
if(objectType != NULL && objectType->getTilesetModelType(variation) != NULL) {
double heightFactor = 1.f;
const double speedDivider= 100.f;
double speedDenominator = (speedDivider * GameConstants::updateFps);
float heightFactor = 1.f;
const float speedDivider= 100.f;
float speedDenominator = (speedDivider * GameConstants::updateFps);
// smooth TwoFrameanimations
double f=1.0f;
float f=1.0f;
if(objectType->getTilesetModelType(variation)->getSmoothTwoFrameAnim()==true){
f=abs(std::sin(animProgress*2*3.16))+0.4f;
}
double newAnimProgress = animProgress + f*(((double)objectType->getTilesetModelType(variation)->getAnimSpeed() * heightFactor) / speedDenominator);
float newAnimProgress = animProgress + f*(((float)objectType->getTilesetModelType(variation)->getAnimSpeed() * heightFactor) / speedDenominator);
animProgress = newAnimProgress;
if(animProgress > 1.f) {
@ -256,7 +256,7 @@ void Object::saveGame(XmlNode *rootNode) {
// Vec3f pos;
objectNode->addAttribute("pos",pos.getString(), mapTagReplacements);
// float rotation;
objectNode->addAttribute("rotation",doubleToStr(rotation,10), mapTagReplacements);
objectNode->addAttribute("rotation",floatToStr(rotation,6), mapTagReplacements);
// int variation;
objectNode->addAttribute("variation",intToStr(variation), mapTagReplacements);
// int lastRenderFrame;
@ -288,7 +288,7 @@ void Object::loadGame(const XmlNode *rootNode,const TechTree *techTree) {
resource->loadGame(objectNode,0,techTree);
}
// Vec3f pos;
pos = Vec3d::strToVec3(objectNode->getAttribute("pos")->getValue());
pos = Vec3f::strToVec3(objectNode->getAttribute("pos")->getValue());
// float rotation;
rotation = objectNode->getAttribute("rotation")->getFloatValue();
// int variation;

View File

@ -57,20 +57,20 @@ private:
ObjectType *objectType;
vector<UnitParticleSystem*> unitParticleSystems;
Resource *resource;
Vec3d pos;
double rotation;
Vec3f pos;
float rotation;
int variation;
int lastRenderFrame;
Vec2i mapPos;
bool visible;
bool animated;
double animProgress;
float animProgress;
float highlight;
static ObjectStateInterface *stateCallback;
public:
Object(ObjectType *objectType, const Vec3d &pos, const Vec2i &mapPos);
Object(ObjectType *objectType, const Vec3f &pos, const Vec2i &mapPos);
virtual ~Object();
void end(); //to kill particles
@ -80,10 +80,10 @@ public:
const ObjectType *getType() const {return objectType;}
Resource *getResource() const {return resource;}
Vec3d getPos() const {return pos;}
Vec3f getPos() const {return pos;}
bool isVisible() const {return visible;}
const Vec3d & getConstPos() const {return pos;}
double getRotation() const {return rotation;}
const Vec3f & getConstPos() const {return pos;}
float getRotation() const {return rotation;}
const Model *getModel() const;
Model *getModelPtr() const;
bool getWalkable() const;
@ -94,7 +94,7 @@ public:
void resetHighlight();
void setResource(const ResourceType *resourceType, const Vec2i &pos);
void setHeight(double height);
void setHeight(float height);
void setVisible(bool visible);
int getLastRenderFrame() const { return lastRenderFrame; }
@ -104,7 +104,7 @@ public:
void updateHighlight();
void update();
double getAnimProgress() const { return animProgress;}
float getAnimProgress() const { return animProgress;}
virtual string getUniquePickName() const;
void saveGame(XmlNode *rootNode);

View File

@ -453,7 +453,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
this->map= map;
this->targetRef = NULL;
this->targetField = fLand;
this->targetVec = Vec3d(0.0);
this->targetVec = Vec3f(0.0);
this->targetPos = Vec2i(0);
this->lastRenderFrame = 0;
this->visible = true;
@ -496,9 +496,9 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
alive= true;
if (type->hasSkillClass(scBeBuilt) == false) {
double rot= 0.f;
float rot= 0.f;
random.init(id);
rot+= random.randRange(-5, 5,intToStr(__LINE__));
rot += random.randRange(-5, 5,intToStr(__LINE__));
rotation= rot;
lastRotation= rot;
targetRotation= rot;
@ -700,7 +700,7 @@ Vec2i Unit::getCenteredPos() const {
return pos + Vec2i(type->getSize()/2, type->getSize()/2);
}
Vec2d Unit::getFloatCenteredPos() const {
Vec2f Unit::getFloatCenteredPos() const {
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(mutexCommands,mutexOwnerId);
@ -710,7 +710,7 @@ Vec2d Unit::getFloatCenteredPos() const {
throw megaglest_runtime_error(szBuf);
}
return Vec2d(pos.x-0.5f+type->getSize()/2.f, pos.y-0.5f+type->getSize()/2.f);
return Vec2f(pos.x-0.5f+type->getSize()/2.f, pos.y-0.5f+type->getSize()/2.f);
}
Vec2i Unit::getCellPos() const {
@ -815,11 +815,11 @@ void Unit::calculateXZRotation(){
}
}
double Unit::getRotationZ() const{
float Unit::getRotationZ() const{
return rotationZ;
}
double Unit::getRotationX() const{
float Unit::getRotationX() const{
return rotationX;
}
@ -1267,13 +1267,13 @@ void Unit::setTargetPos(const Vec2i &targetPos) {
Vec2i relPos= targetPos - pos;
//map->clampPos(relPos);
Vec2d relPosf= Vec2d((double)relPos.x, (double)relPos.y);
Vec2f relPosf= Vec2f((float)relPos.x, (float)relPos.y);
#ifdef USE_STREFLOP
targetRotation= radToDeg(streflop::atan2(static_cast<streflop::Simple>(relPosf.x), static_cast<streflop::Simple>(relPosf.y)));
#else
targetRotation= radToDeg(atan2(relPosf.x, relPosf.y));
#endif
targetRotation = truncateDecimal<double>(targetRotation,10);
targetRotation = truncateDecimal<float>(targetRotation,6);
targetRef= NULL;
@ -1409,60 +1409,48 @@ bool Unit::checkModelStateInfoForNewHpValue() {
return result;
}
Vec3d Unit::getCurrVector() const{
Vec3f 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);
}
Vec3d result = getCurrVectorFlat() + Vec3d(0.f, type->getHeight() /2.f, 0.f);
result.x = truncateDecimal<double>(result.x,10);
result.y = truncateDecimal<double>(result.y,10);
result.z = truncateDecimal<double>(result.z,10);
Vec3f result = getCurrVectorFlat() + Vec3f(0.f, type->getHeight() / 2.f, 0.f);
return result;
}
Vec3d Unit::getCurrVectorFlat() const{
Vec3f Unit::getCurrVectorFlat() const{
return getVectorFlat(lastPos, pos);
}
double Unit::getProgressAsFloat() const {
double result = (static_cast<double>(progress) / static_cast<double>(PROGRESS_SPEED_MULTIPLIER));
result = truncateDecimal<double>(result,10);
result = truncateDecimal<double>(result,6);
return result;
}
Vec3d Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const {
Vec3d v;
Vec3f Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const {
Vec3f v;
double y1= computeHeight(lastPosValue);
double y2= computeHeight(curPosValue);
float y1= computeHeight(lastPosValue);
float y2= computeHeight(curPosValue);
if(currSkill->getClass() == scMove) {
double progressAsDouble = getProgressAsFloat();
float progressAsFloat = getProgressAsFloat();
v.x= lastPosValue.x + progressAsDouble * (curPosValue.x - lastPosValue.x);
v.z= lastPosValue.y + progressAsDouble * (curPosValue.y - lastPosValue.y);
v.y= y1 + progressAsDouble * (y2-y1);
v.x = lastPosValue.x + progressAsFloat * (curPosValue.x - lastPosValue.x);
v.z = lastPosValue.y + progressAsFloat * (curPosValue.y - lastPosValue.y);
v.y = y1 + progressAsFloat * (y2-y1);
}
else {
v.x= static_cast<double>(curPosValue.x);
v.z= static_cast<double>(curPosValue.y);
v.y= y2;
v.x = static_cast<float>(curPosValue.x);
v.z = static_cast<float>(curPosValue.y);
v.y = y2;
}
v.x = truncateDecimal<double>(v.x,10);
v.y = truncateDecimal<double>(v.y,10);
v.z = truncateDecimal<double>(v.z,10);
v.x += type->getSize() / 2.f - 0.5f;
v.z += type->getSize() / 2.f - 0.5f;
v.x = truncateDecimal<double>(v.x,10);
v.y = truncateDecimal<double>(v.y,10);
v.z = truncateDecimal<double>(v.z,10);
return v;
}
@ -2402,8 +2390,8 @@ bool Unit::update() {
rotation= lastRotation + (targetRotation - lastRotation) *
getProgressAsFloat() * rotFactor;
else {
double rotationTerm = targetRotation > lastRotation ? -360.f: +360.f;
rotation = lastRotation + (targetRotation - lastRotation + rotationTerm) *
float rotationTerm = targetRotation > lastRotation ? -360.f: +360.f;
rotation = lastRotation + (targetRotation - lastRotation + rotationTerm) *
getProgressAsFloat() * rotFactor;
}
}
@ -2508,7 +2496,7 @@ void Unit::updateTimedParticles() {
for(int i = queuedUnitParticleSystemTypes.size() - 1; i >= 0; i--) {
UnitParticleSystemType *pst = queuedUnitParticleSystemTypes[i];
if(pst != NULL) {
if(truncateDecimal<double>(pst->getStartTime(),10) <= truncateDecimal<double>(getAnimProgressAsFloat(),10)) {
if(truncateDecimal<float>(pst->getStartTime(),6) <= truncateDecimal<float>(getAnimProgressAsFloat(),6)) {
UnitParticleSystem *ups = new UnitParticleSystem(200);
ups->setParticleOwner(this);
@ -2535,13 +2523,13 @@ void Unit::updateTimedParticles() {
UnitParticleSystem *ps = unitParticleSystems[i];
if(ps != NULL) {
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
double pst = ps->getStartTime();
double pet = ps->getEndTime();
double particleStartTime = truncateDecimal<double>(pst,10);
double particleEndTime = truncateDecimal<double>(pet,10);
float pst = ps->getStartTime();
float pet = ps->getEndTime();
float particleStartTime = truncateDecimal<float>(pst,6);
float particleEndTime = truncateDecimal<float>(pet,6);
if(particleStartTime != 0.0 || particleEndTime != 1.0) {
double animProgressTime = truncateDecimal<double>(getAnimProgressAsFloat(),10);
float animProgressTime = truncateDecimal<float>(getAnimProgressAsFloat(),6);
if(animProgressTime >= 0.99 || animProgressTime >= particleEndTime) {
ps->fade();
@ -3343,7 +3331,7 @@ bool Unit::morph(const MorphCommandType *mct) {
// ==================== PRIVATE ====================
double Unit::computeHeight(const Vec2i &pos) const {
float Unit::computeHeight(const Vec2i &pos) const {
//printf("CRASHING FOR UNIT: %d alive = %d\n",this->getId(),this->isAlive());
//printf("[%s]\n",this->getType()->getName().c_str());
if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) {
@ -3352,26 +3340,25 @@ double Unit::computeHeight(const Vec2i &pos) const {
throw megaglest_runtime_error("#7 Invalid path position = " + pos.getString());
}
double height= map->getCell(pos)->getHeight();
height = truncateDecimal<double>(height,10);
float height= map->getCell(pos)->getHeight();
if(currField == fAir) {
const double airHeight=game->getWorld()->getTileset()->getAirHeight();
const float airHeight=game->getWorld()->getTileset()->getAirHeight();
height += airHeight;
height = truncateDecimal<double>(height,10);
height = truncateDecimal<float>(height,6);
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<double>(height,10);
height += (std::min((float)unit->getType()->getHeight(),Tileset::standardAirHeight * 3) - airHeight);
height = truncateDecimal<float>(height,6);
}
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<double>(height,10);
height += (std::min((float)sc->getObject()->getType()->getHeight(),Tileset::standardAirHeight * 3) - airHeight);
height = truncateDecimal<float>(height,6);
}
}
}
@ -3387,20 +3374,13 @@ void Unit::updateTarget(){
//update target pos
targetPos= target->getCellPos();
Vec2i relPos= targetPos - pos;
Vec2d relPosf= Vec2d((double)relPos.x, (double)relPos.y);
Vec2f relPosf= Vec2f((float)relPos.x, (float)relPos.y);
#ifdef USE_STREFLOP
targetRotation= radToDeg(streflop::atan2(static_cast<streflop::Simple>(relPosf.x), static_cast<streflop::Simple>(relPosf.y)));
#else
targetRotation= radToDeg(atan2(relPosf.x, relPosf.y));
#endif
targetRotation = truncateDecimal<double>(targetRotation,10);
//update target vec
targetVec= target->getCurrVector();
//if(getFrameCount() % 40 == 0) {
//logSynchData(string(__FILE__) + string("::") + string(__FUNCTION__) + string(" Line: ") + intToStr(__LINE__));
//logSynchData();
//}
}
}
@ -3835,8 +3815,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(Vec3d(0,2,0));
ups->setDirection(Vec3d(0,1,-0.2f));
ups->setOffset(Vec3f(0,2,0));
ups->setDirection(Vec3f(0,1,-0.2f));
ups->setRadius(type->getSize()/3.f);
ups->setShape(Shared::Graphics::UnitParticleSystem::sLinear);
ups->setTexture(CoreData::getInstance().getFireTexture());
@ -3857,7 +3837,7 @@ void Unit::startDamageParticles() {
checkCustomizedParticleTriggers(false);
}
void Unit::setTargetVec(const Vec3d &targetVec) {
void Unit::setTargetVec(const Vec3f &targetVec) {
this->targetVec= targetVec;
logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
}
@ -4173,7 +4153,7 @@ std::string Unit::toString(bool crcMode) const {
if(crcMode == false) {
result += " lastAnimProgress = " + intToStr(this->lastAnimProgress);
result += " animProgress = " + intToStr(this->animProgress);
result += " highlight = " + doubleToStr(this->highlight,10);
result += " highlight = " + floatToStr(this->highlight,6);
}
result += " progress2 = " + intToStr(this->progress2);
result += " kills = " + intToStr(this->kills);
@ -4202,9 +4182,9 @@ std::string Unit::toString(bool crcMode) const {
result += "\n";
if(crcMode == false) {
result += " lastRotation = " + doubleToStr(this->lastRotation,10);
result += " targetRotation = " + doubleToStr(this->targetRotation,10);
result += " rotation = " + doubleToStr(this->rotation,10);
result += " lastRotation = " + floatToStr(this->lastRotation,6);
result += " targetRotation = " + floatToStr(this->targetRotation,6);
result += " rotation = " + floatToStr(this->rotation,6);
}
if(loadType != NULL) {
@ -4312,7 +4292,7 @@ void Unit::saveGame(XmlNode *rootNode) {
// float animProgress; //between 0 and 1
unitNode->addAttribute("animProgress",intToStr(animProgress), mapTagReplacements);
// float highlight;
unitNode->addAttribute("highlight",doubleToStr(highlight,10), mapTagReplacements);
unitNode->addAttribute("highlight",floatToStr(highlight,6), mapTagReplacements);
// int progress2;
unitNode->addAttribute("progress2",intToStr(progress2), mapTagReplacements);
// int kills;
@ -4342,19 +4322,19 @@ void Unit::saveGame(XmlNode *rootNode) {
unitNode->addAttribute("meetingPos",meetingPos.getString(), mapTagReplacements);
//
// float lastRotation; //in degrees
unitNode->addAttribute("lastRotation",doubleToStr(lastRotation,10), mapTagReplacements);
unitNode->addAttribute("lastRotation",floatToStr(lastRotation,6), mapTagReplacements);
// float targetRotation;
unitNode->addAttribute("targetRotation",doubleToStr(targetRotation,10), mapTagReplacements);
unitNode->addAttribute("targetRotation",floatToStr(targetRotation,6), mapTagReplacements);
// float rotation;
unitNode->addAttribute("rotation",doubleToStr(rotation,10), mapTagReplacements);
unitNode->addAttribute("rotation",floatToStr(rotation,6), mapTagReplacements);
// float targetRotationZ;
unitNode->addAttribute("targetRotationZ",doubleToStr(targetRotationZ,10), mapTagReplacements);
unitNode->addAttribute("targetRotationZ",floatToStr(targetRotationZ,6), mapTagReplacements);
// float targetRotationX;
unitNode->addAttribute("targetRotationX",doubleToStr(targetRotationX,10), mapTagReplacements);
unitNode->addAttribute("targetRotationX",floatToStr(targetRotationX,6), mapTagReplacements);
// float rotationZ;
unitNode->addAttribute("rotationZ",doubleToStr(rotationZ,10), mapTagReplacements);
unitNode->addAttribute("rotationZ",floatToStr(rotationZ,6), mapTagReplacements);
// float rotationX;
unitNode->addAttribute("rotationX",doubleToStr(rotationX,10), mapTagReplacements);
unitNode->addAttribute("rotationX",floatToStr(rotationX,6), mapTagReplacements);
// const UnitType *type;
unitNode->addAttribute("type",type->getName(false), mapTagReplacements);
@ -4699,7 +4679,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 = Vec3d::strToVec3(unitNode->getAttribute("targetVec")->getValue());
result->targetVec = Vec3f::strToVec3(unitNode->getAttribute("targetVec")->getValue());
// Vec2i meetingPos;
result->meetingPos = Vec2i::strToVec2(unitNode->getAttribute("meetingPos")->getValue());
//

View File

@ -353,7 +353,7 @@ private:
int64 progress; //between 0 and 1
int64 lastAnimProgress; //between 0 and 1
int64 animProgress; //between 0 and 1
double highlight;
float highlight;
int32 progress2;
int32 kills;
int32 enemyKills;
@ -368,16 +368,16 @@ private:
Vec2i pos;
Vec2i lastPos;
Vec2i targetPos; //absolute target pos
Vec3d targetVec;
Vec3f targetVec;
Vec2i meetingPos;
double lastRotation; //in degrees
double targetRotation;
double rotation;
double targetRotationZ;
double targetRotationX;
double rotationZ;
double rotationX;
float lastRotation; //in degrees
float targetRotation;
float rotation;
float targetRotationZ;
float targetRotationX;
float rotationZ;
float rotationX;
const UnitType *preMorph_type;
const UnitType *type;
@ -520,7 +520,7 @@ public:
inline double getLastAnimProgressAsFloat() const {return static_cast<double>(lastAnimProgress) / ANIMATION_SPEED_MULTIPLIER;}
inline double getAnimProgressAsFloat() const {return static_cast<double>(animProgress) / ANIMATION_SPEED_MULTIPLIER;}
inline double getHightlight() const {return highlight;}
inline float getHightlight() const {return highlight;}
inline int getProgress2() const {return progress2;}
inline int getFactionIndex() const {
return faction->getIndex();
@ -536,7 +536,7 @@ public:
double getEpRatio() const;
inline bool getToBeUndertaken() const {return toBeUndertaken;}
inline Vec2i getTargetPos() const {return targetPos;}
inline Vec3d getTargetVec() const {return targetVec;}
inline Vec3f getTargetVec() const {return targetVec;}
inline Field getTargetField() const {return targetField;}
inline Vec2i getMeetingPos() const {return meetingPos;}
inline Faction *getFaction() const {return faction;}
@ -546,9 +546,9 @@ public:
inline const SkillType *getCurrSkill() const {return currSkill;}
inline const TotalUpgrade *getTotalUpgrade() const {return &totalUpgrade;}
inline double getRotation() const {return rotation;}
double getRotationX() const;
double getRotationZ() const;
inline float getRotation() const {return rotation;}
float getRotationX() const;
float getRotationZ() const;
ParticleSystem *getFire() const;
inline int getKills() const {return kills;}
inline int getEnemyKills() const {return enemyKills;}
@ -574,7 +574,7 @@ public:
Vec2i getPosWithCellMapSet() const;
inline Vec2i getLastPos() const {return lastPos;}
Vec2i getCenteredPos() const;
Vec2d getFloatCenteredPos() const;
Vec2f 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 Vec3d &targetVec);
void setTargetVec(const Vec3f &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();
Vec3d getCurrVector() const;
Vec3d getCurrVectorFlat() const;
Vec3d getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const;
Vec3f getCurrVector() const;
Vec3f getCurrVectorFlat() const;
Vec3f getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const;
//command related
bool anyCommand(bool validateCommandtype=false) const;
@ -794,7 +794,7 @@ private:
void addNetworkCRCDecHp(string info) { }
string getNetworkCRCDecHpList() const;
double computeHeight(const Vec2i &pos) const;
float computeHeight(const Vec2i &pos) const;
void calculateXZRotation();
void updateTarget();
void clearCommands();

View File

@ -665,7 +665,7 @@ void SkillType::saveGame(XmlNode *rootNode) {
//
// SoundContainer sounds;
// float soundStartTime;
skillTypeNode->addAttribute("soundStartTime",doubleToStr(soundStartTime,10), mapTagReplacements);
skillTypeNode->addAttribute("soundStartTime",floatToStr(soundStartTime,6), mapTagReplacements);
// RandomGen random;
skillTypeNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements);
// AttackBoost attackBoost;
@ -897,7 +897,7 @@ void AttackSkillType::saveGame(XmlNode *rootNode) {
attackFieldsNode->addAttribute("value",intToStr(attackFields[i]), mapTagReplacements);
}
// float attackStartTime;
attackSkillTypeNode->addAttribute("attackStartTime",doubleToStr(attackStartTime,10), mapTagReplacements);
attackSkillTypeNode->addAttribute("attackStartTime",floatToStr(attackStartTime,6), mapTagReplacements);
// string spawnUnit;
attackSkillTypeNode->addAttribute("spawnUnit",spawnUnit, mapTagReplacements);
// int spawnUnitcount;
@ -1220,7 +1220,7 @@ void FogOfWarSkillType::saveGame(XmlNode *rootNode) {
fogSkillTypeNode->addAttribute("enable-fog",intToStr(fowEnable), mapTagReplacements);
fogSkillTypeNode->addAttribute("apply-team",intToStr(applyToTeam), mapTagReplacements);
fogSkillTypeNode->addAttribute("duration",doubleToStr(durationTime,10), mapTagReplacements);
fogSkillTypeNode->addAttribute("duration",floatToStr(durationTime,6), mapTagReplacements);
}
// =====================================================

View File

@ -137,7 +137,7 @@ protected:
vector<AnimationAttributes> animationAttributes;
SoundContainer sounds;
double soundStartTime;
float soundStartTime;
RandomGen random;
AttackBoost attackBoost;
@ -177,7 +177,7 @@ public:
int getAnimSpeed() const {return animSpeed;}
Model *getAnimation(double animProgress=0, const Unit *unit=NULL, int *lastAnimationIndex=NULL, int *animationRandomCycleCount=NULL) const;
StaticSound *getSound() const {return sounds.getRandSound();}
double getSoundStartTime() const {return soundStartTime;}
float getSoundStartTime() const {return soundStartTime;}
bool isAttackBoostEnabled() const { return attackBoost.enabled; }
const AttackBoost * getAttackBoost() const { return &attackBoost; }
@ -226,7 +226,7 @@ private:
int attackRange;
const AttackType *attackType;
bool attackFields[fieldCount];
double attackStartTime;
float attackStartTime;
string spawnUnit;
int spawnUnitcount;
@ -253,7 +253,7 @@ public:
inline int getAttackRange() const {return attackRange;}
inline const AttackType *getAttackType() const {return attackType;}
inline bool getAttackField(Field field) const {return attackFields[field];}
inline double getAttackStartTime() const {return attackStartTime;}
inline float getAttackStartTime() const {return attackStartTime;}
inline string getSpawnUnit() const {return spawnUnit;}
inline int getSpawnUnitCount() const {return spawnUnitcount;}
@ -419,13 +419,13 @@ class FogOfWarSkillType: public SkillType {
private:
bool fowEnable;
bool applyToTeam;
double durationTime;
float durationTime;
public:
FogOfWarSkillType();
bool getFowEnable() const {return fowEnable;}
bool getApplyToTeam() const {return applyToTeam;}
double getDurationTime() const {return durationTime;}
float getDurationTime() const {return durationTime;}
virtual void load(const XmlNode *sn, const XmlNode *attackBoostsNode, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,

View File

@ -1080,7 +1080,7 @@ std::string UnitType::toString() const {
result += " sight = " + intToStr(sight);
result += " size = " + intToStr(size);
result += " height = " + intToStr(height);
result += " rotatedBuildPos = " + doubleToStr(rotatedBuildPos,10);
result += " rotatedBuildPos = " + floatToStr(rotatedBuildPos,6);
result += " rotationAllowed = " + intToStr(rotationAllowed);
if(cellMap != NULL) {

View File

@ -123,7 +123,7 @@ private:
int sight;
int size; //size in cells
int height;
double rotatedBuildPos;
float rotatedBuildPos;
bool rotationAllowed;
//cellmap
@ -249,8 +249,8 @@ public:
const CommandType* findCommandTypeById(int id) const;
string getCommandTypeListDesc() const;
inline double getRotatedBuildPos() { return rotatedBuildPos; }
inline void setRotatedBuildPos(double value) { rotatedBuildPos = value; }
inline float getRotatedBuildPos() { return rotatedBuildPos; }
inline void setRotatedBuildPos(float value) { rotatedBuildPos = value; }
//other
virtual string getReqDesc(bool translatedValue) const;

View File

@ -93,7 +93,7 @@ void Cell::saveGame(XmlNode *rootNode, int index) const {
}
// float height;
cellNode->addAttribute("height",doubleToStr(getHeight(),10), mapTagReplacements);
cellNode->addAttribute("height",floatToStr(getHeight(),6), mapTagReplacements);
}
}
@ -374,10 +374,10 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
heightFactor= header.heightFactor;
if(heightFactor>100){
heightFactor=heightFactor/100;
heightFactor = truncateDecimal<double>(heightFactor,10);
heightFactor = truncateDecimal<float>(heightFactor,6);
}
waterLevel= static_cast<double>((header.waterLevel-0.01f)/heightFactor);
waterLevel = truncateDecimal<double>(waterLevel,10);
waterLevel= static_cast<float>((header.waterLevel-0.01f)/heightFactor);
waterLevel = truncateDecimal<float>(waterLevel,6);
title= header.title;
maxPlayers= header.maxFactions;
@ -395,8 +395,8 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
else if(header.version==2){
//desc = header.version2.short_desc;
if(header.version2.cliffLevel > 0 && header.version2.cliffLevel < 5000){
cliffLevel=static_cast<double>((header.version2.cliffLevel-0.01f)/(heightFactor),10);
cliffLevel = truncateDecimal<double>(cliffLevel,10);
cliffLevel=static_cast<float>((header.version2.cliffLevel-0.01f)/(heightFactor),6);
cliffLevel = truncateDecimal<float>(cliffLevel,6);
}
if(header.version2.cameraHeight > 0 && header.version2.cameraHeight < 5000) {
cameraHeight = header.version2.cameraHeight;
@ -481,7 +481,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
sc->setObject(NULL);
}
else if(objNumber <= Tileset::objCount) {
Object *o= new Object(tileset->getObjectType(objNumber-1), Vec3d(sc->getVertex()),Vec2i(i, j));
Object *o= new Object(tileset->getObjectType(objNumber-1), sc->getVertex(),Vec2i(i, j));
sc->setObject(o);
for(int k = 0; k < techTree->getResourceTypeCount(); ++k) {
const ResourceType *rt= techTree->getResourceType(k);
@ -492,7 +492,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
}
else{
const ResourceType *rt= techTree->getTechResourceType(objNumber - Tileset::objCount) ;
Object *o= new Object(NULL, Vec3d(sc->getVertex()),Vec2i(i, j));
Object *o= new Object(NULL, sc->getVertex(),Vec2i(i, j));
o->setResource(rt, Vec2i(i, j));
sc->setObject(o);
}
@ -1532,7 +1532,7 @@ void Map::prepareTerrain(const Unit *unit) {
// ==================== compute ====================
void Map::flatternTerrain(const Unit *unit){
double refHeight= getSurfaceCell(toSurfCoords(unit->getCenteredPos()))->getHeight();
float refHeight= getSurfaceCell(toSurfCoords(unit->getCenteredPos()))->getHeight();
for(int i=-1; i<=unit->getType()->getSize(); ++i){
for(int j=-1; j<=unit->getType()->getSize(); ++j){
Vec2i pos= unit->getPosNotThreadSafe()+Vec2i(i, j);
@ -1641,7 +1641,7 @@ void Map::smoothSurface(Tileset *tileset) {
}
if (formerObject == NULL) {
Object *o = new Object(tileset->getObjectType(9),
Vec3d(getSurfaceCell(i, j)->getVertex()),
getSurfaceCell(i, j)->getVertex(),
Vec2i(i,j));
getSurfaceCell(i, j)->setObject(o);
}
@ -1733,11 +1733,11 @@ void Map::saveGame(XmlNode *rootNode) const {
// string title;
mapNode->addAttribute("title",title, mapTagReplacements);
// float waterLevel;
mapNode->addAttribute("waterLevel",doubleToStr(waterLevel,10), mapTagReplacements);
mapNode->addAttribute("waterLevel",floatToStr(waterLevel,6), mapTagReplacements);
// float heightFactor;
mapNode->addAttribute("heightFactor",doubleToStr(heightFactor,10), mapTagReplacements);
mapNode->addAttribute("heightFactor",floatToStr(heightFactor,6), mapTagReplacements);
// float cliffLevel;
mapNode->addAttribute("cliffLevel",doubleToStr(cliffLevel,10), mapTagReplacements);
mapNode->addAttribute("cliffLevel",floatToStr(cliffLevel,6), mapTagReplacements);
// int cameraHeight;
mapNode->addAttribute("cameraHeight",intToStr(cameraHeight), mapTagReplacements);
// int w;
@ -1817,7 +1817,7 @@ void Map::saveGame(XmlNode *rootNode) const {
// Checksum checksumValue;
// mapNode->addAttribute("checksumValue",intToStr(checksumValue.getSum()), mapTagReplacements);
// float maxMapHeight;
mapNode->addAttribute("maxMapHeight",doubleToStr(maxMapHeight,10), mapTagReplacements);
mapNode->addAttribute("maxMapHeight",floatToStr(maxMapHeight,6), mapTagReplacements);
// string mapFile;
mapNode->addAttribute("mapFile",mapFile, mapTagReplacements);
}

View File

@ -58,7 +58,7 @@ class Cell {
private:
Unit *units[fieldCount]; //units on this cell
Unit *unitsWithEmptyCellMap[fieldCount]; //units with an empty cellmap on this cell
double height;
float height;
private:
Cell(Cell&);
@ -70,11 +70,11 @@ public:
//get
inline Unit *getUnit(int field) const { if(field >= fieldCount) { throw megaglest_runtime_error("Invalid field value" + intToStr(field));} return units[field];}
inline Unit *getUnitWithEmptyCellMap(int field) const { if(field >= fieldCount) { throw megaglest_runtime_error("Invalid field value" + intToStr(field));} return unitsWithEmptyCellMap[field];}
inline double getHeight() const {return truncateDecimal<double>(height,10);}
inline float getHeight() const {return truncateDecimal<float>(height,6);}
inline void setUnit(int field, Unit *unit) { if(field >= fieldCount) { throw megaglest_runtime_error("Invalid field value" + intToStr(field));} units[field]= unit;}
inline void setUnitWithEmptyCellMap(int field, Unit *unit) { if(field >= fieldCount) { throw megaglest_runtime_error("Invalid field value" + intToStr(field));} unitsWithEmptyCellMap[field]= unit;}
inline void setHeight(double height) {this->height = truncateDecimal<double>(height,10);}
inline void setHeight(float height) {this->height = truncateDecimal<float>(height,6);}
inline bool isFree(Field field) const {
Unit *unit = getUnit(field);
@ -213,9 +213,9 @@ public:
private:
string title;
double waterLevel;
double heightFactor;
double cliffLevel;
float waterLevel;
float heightFactor;
float cliffLevel;
int cameraHeight;
int w;
int h;
@ -228,7 +228,7 @@ private:
SurfaceCell *surfaceCells;
Vec2i *startLocations;
Checksum checksumValue;
double maxMapHeight;
float maxMapHeight;
string mapFile;
private:
@ -296,11 +296,11 @@ public:
inline int getSurfaceW() const {return surfaceW;}
inline int getSurfaceH() const {return surfaceH;}
inline int getMaxPlayers() const {return maxPlayers;}
inline double getHeightFactor() const {return truncateDecimal<double>(heightFactor,10);}
inline double getWaterLevel() const {return truncateDecimal<double>(waterLevel,10);}
inline double getCliffLevel() const {return truncateDecimal<double>(cliffLevel,10);}
inline float getHeightFactor() const {return truncateDecimal<float>(heightFactor,6);}
inline float getWaterLevel() const {return truncateDecimal<float>(waterLevel,6);}
inline float getCliffLevel() const {return truncateDecimal<float>(cliffLevel,6);}
inline int getCameraHeight() const {return cameraHeight;}
inline double getMaxMapHeight() const {return truncateDecimal<double>(maxMapHeight,10);}
inline float getMaxMapHeight() const {return truncateDecimal<float>(maxMapHeight,6);}
Vec2i getStartLocation(int locationIndex) const;
inline bool getSubmerged(const SurfaceCell *sc) const {return sc->getHeight()<waterLevel;}
inline bool getSubmerged(const Cell *c) const {return c->getHeight()<waterLevel;}

View File

@ -29,8 +29,8 @@ using namespace Shared::Graphics;
namespace Glest{ namespace Game{
const double Tileset::standardAirHeight= 5.0f;
const double Tileset::standardShadowIntensity= 0.2f;
const float Tileset::standardAirHeight= 5.0f;
const float Tileset::standardShadowIntensity= 0.2f;
// =====================================================
// class AmbientSounds
// =====================================================
@ -433,15 +433,15 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
//weather
const XmlNode *weatherNode= parametersNode->getChild("weather");
double sunnyProb= weatherNode->getAttribute("sun")->getFloatValue(0.f, 1.f);
double rainyProb= weatherNode->getAttribute("rain")->getFloatValue(0.f, 1.f) + sunnyProb;
float sunnyProb= weatherNode->getAttribute("sun")->getFloatValue(0.f, 1.f);
float rainyProb= weatherNode->getAttribute("rain")->getFloatValue(0.f, 1.f) + sunnyProb;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
#ifdef USE_STREFLOP
double rnd= streflop::fabs(static_cast<streflop::Simple>(random.randRange(-1.f, 1.f)));
float rnd= streflop::fabs(static_cast<streflop::Simple>(random.randRange(-1.f, 1.f)));
#else
double rnd= fabs(random.randRange(-1.f, 1.f));
float rnd= fabs(random.randRange(-1.f, 1.f));
#endif
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -505,7 +505,7 @@ void Tileset::addSurfTex(int leftUp, int rightUp, int leftDown, int rightDown, V
//center textures
if(leftUp == rightUp && leftUp == leftDown && leftUp == rightDown) {
//texture variation according to probability
double r= random.randRange(0.f, 1.f);
float r= random.randRange(0.f, 1.f);
const Pixmap2D *pixmap = NULL;
if(surfProbs[leftUp][0] < 0) {
@ -514,7 +514,7 @@ void Tileset::addSurfTex(int leftUp, int rightUp, int leftDown, int rightDown, V
pixmap = getSurfPixmap(leftUp, (mapY % parts) * parts + (mapX % parts));
}
else {
double max= 0.f;
float max= 0.f;
int var= 0;
for(int i=0; i < surfProbs[leftUp].size(); ++i) {
max += surfProbs[leftUp][i];

View File

@ -120,8 +120,8 @@ public:
static const int surfCount= 6;
static const int objCount= 10;
static const int transitionVars= 2; //number or different transition textures
static const double standardAirHeight;
static const double standardShadowIntensity;
static const float standardAirHeight;
static const float standardShadowIntensity;
public:
typedef vector<float> SurfProbs;
@ -142,13 +142,13 @@ private:
bool waterEffects;
bool fog;
int fogMode;
double fogDensity;
float fogDensity;
Vec3f fogColor;
Vec3f sunLightColor;
Vec3f moonLightColor;
double shadowIntensity;
float shadowIntensity;
Weather weather;
double airHeight;
float airHeight;
AmbientSounds ambientSounds;
Checksum checksumValue;
@ -178,7 +178,7 @@ public:
Checksum * getChecksumValue() { return &checksumValue; }
//get
double getAirHeight()const {return airHeight;}
float getAirHeight()const {return airHeight;}
const SurfaceAtlas *getSurfaceAtlas() const {return &surfaceAtlas;}
ObjectType *getObjectType(int i) {return &objectTypes[i];}
float getSurfProb(int surf, int var) const {return surfProbs[surf][var];}
@ -186,11 +186,11 @@ public:
bool getWaterEffects() const {return waterEffects;}
bool getFog() const {return fog;}
int getFogMode() const {return fogMode;}
double getFogDensity() const {return fogDensity;}
float getFogDensity() const {return fogDensity;}
const Vec3f &getFogColor() const {return fogColor;}
const Vec3f &getSunLightColor() const {return sunLightColor;}
const Vec3f &getMoonLightColor() const {return moonLightColor;}
double getShadowIntense()const {return shadowIntensity;}
float getShadowIntense()const {return shadowIntensity;}
Weather getWeather() const {return weather;}
void setWeather(Weather value) { weather = value; }

View File

@ -160,12 +160,12 @@ void TimeFlow::saveGame(XmlNode *rootNode) {
// bool firstTime;
// Tileset *tileset;
// float time;
timeflowNode->addAttribute("time",floatToStr(time,10), mapTagReplacements);
timeflowNode->addAttribute("time",floatToStr(time,6), mapTagReplacements);
// float lastTime;
timeflowNode->addAttribute("lastTime",floatToStr(lastTime,10), mapTagReplacements);
timeflowNode->addAttribute("lastTime",floatToStr(lastTime,6), mapTagReplacements);
// float timeInc;
//printf("#2 timeInc = %f\n",timeInc);
timeflowNode->addAttribute("timeInc",floatToStr(timeInc,10), mapTagReplacements);
timeflowNode->addAttribute("timeInc",floatToStr(timeInc,6), mapTagReplacements);
//printf("#3 timeInc = %f\n",timeInc);
}

View File

@ -119,7 +119,7 @@ bool UnitUpdater::updateUnit(Unit *unit) {
//play skill sound
const SkillType *currSkill= unit->getCurrSkill();
if(currSkill->getSound() != NULL) {
double soundStartTime= currSkill->getSoundStartTime();
float soundStartTime= currSkill->getSoundStartTime();
if(soundStartTime >= unit->getLastAnimProgressAsFloat() && soundStartTime < unit->getAnimProgressAsFloat()) {
if(map->getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(world->getThisTeamIndex()) ||
(game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) {
@ -138,9 +138,9 @@ bool UnitUpdater::updateUnit(Unit *unit) {
if(unit->getCurrSkill()->getClass() == scAttack) {
const AttackSkillType *ast= static_cast<const AttackSkillType*>(unit->getCurrSkill());
double attackStartTime = truncateDecimal<double>(ast->getAttackStartTime(),10);
double lastAnimProgress = truncateDecimal<double>(unit->getLastAnimProgressAsFloat(),10);
double animProgress = truncateDecimal<double>(unit->getAnimProgressAsFloat(),10);
float attackStartTime = truncateDecimal<float>(ast->getAttackStartTime(),6);
float lastAnimProgress = truncateDecimal<float>(unit->getLastAnimProgressAsFloat(),6);
float animProgress = truncateDecimal<float>(unit->getAnimProgressAsFloat(),6);
bool startAttackParticleSystemNow = (attackStartTime >= lastAnimProgress && attackStartTime < animProgress);
char szBuf[8096]="";
@ -2211,7 +2211,7 @@ void UnitUpdater::hit(Unit *attacker, const AttackSkillType* ast, const Vec2i &t
scriptManager->onUnitAttacking(attacker);
double distance = pci.getPos().dist(targetPos);
distance = truncateDecimal<double>(distance,10);
distance = truncateDecimal<double>(distance,6);
damage(attacker, ast, attacked, distance);
}
}
@ -2241,7 +2241,7 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac
int var = ast->getAttackVar();
int armor = attacked->getType()->getTotalArmor(attacked->getTotalUpgrade());
double damageMultiplier = world->getTechTree()->getDamageMultiplier(ast->getAttackType(), attacked->getType()->getArmorType());
damageMultiplier = truncateDecimal<double>(damageMultiplier,10);
damageMultiplier = truncateDecimal<double>(damageMultiplier,6);
//compute damage
//damage += random.randRange(-var, var);
@ -2249,7 +2249,7 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac
damage /= distance+1;
damage -= armor;
damage *= damageMultiplier;
damage = truncateDecimal<double>(damage,10);
damage = truncateDecimal<double>(damage,6);
if(damage < 1) {
damage= 1;
@ -2296,8 +2296,8 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
ParticleSystemTypeProjectile *pstProj= ast->getProjParticleType();
ParticleSystemTypeSplash *pstSplash= ast->getSplashParticleType();
Vec3d startPos= unit->getCurrVector();
Vec3d endPos= unit->getTargetVec();
Vec3f startPos= unit->getCurrVector();
Vec3f 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();
Vec2d floatCenter = unit->getFloatCenteredPos();
Vec2f 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<streflop::Simple>(floatCenter.dist(Vec2d((double)i, (double)j)))) <= (range+1)){
if(map->isInside(i, j) && streflop::floor(static_cast<streflop::Simple>(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range+1)){
#else
if(map->isInside(i, j) && floor(floatCenter.dist(Vec2d((double)i, (double)j))) <= (range+1)){
if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)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()) {
Vec2d enemyFloatCenter = enemyUnit->getFloatCenteredPos();
Vec2f enemyFloatCenter = enemyUnit->getFloatCenteredPos();
// find nearest Attack and cleanup old dates
AttackWarningData *nearest = NULL;
double currentDistance = 0.f;
@ -2684,7 +2684,7 @@ vector<Unit*> UnitUpdater::enemyUnitsOnRange(const Unit *unit,const AttackSkillT
//aux vars
int size = unit->getType()->getSize();
Vec2i center = unit->getPosNotThreadSafe();
Vec2d floatCenter = unit->getFloatCenteredPos();
Vec2f floatCenter = unit->getFloatCenteredPos();
//bool foundInCache = true;
if(findCachedCellsEnemies(center,range,size,enemies,ast,
@ -2696,9 +2696,9 @@ vector<Unit*> 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<streflop::Simple>(floatCenter.dist(Vec2d((double)i, (double)j)))) <= (range+1)){
if(map->isInside(i, j) && streflop::floor(static_cast<streflop::Simple>(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range+1)){
#else
if(map->isInside(i, j) && floor(floatCenter.dist(Vec2d((double)i, (double)j))) <= (range+1)){
if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){
#endif
Cell *cell = map->getCell(i,j);
findEnemiesForCell(ast,cell,unit,commandTarget,enemies);
@ -2744,7 +2744,7 @@ vector<Unit*> UnitUpdater::findUnitsInRange(const Unit *unit, int radius) {
//aux vars
int size = unit->getType()->getSize();
Vec2i center = unit->getPosNotThreadSafe();
Vec2d floatCenter = unit->getFloatCenteredPos();
Vec2f floatCenter = unit->getFloatCenteredPos();
//nearby cells
//UnitRangeCellsLookupItem cacheItem;
@ -2752,9 +2752,9 @@ vector<Unit*> 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<streflop::Simple>(floatCenter.dist(Vec2d((double)i, (double)j)))) <= (range+1)){
if(map->isInside(i, j) && streflop::floor(static_cast<streflop::Simple>(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range+1)){
#else
if(map->isInside(i, j) && floor(floatCenter.dist(Vec2d((double)i, (double)j))) <= (range+1)){
if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){
#endif
Cell *cell = map->getCell(i,j);
findUnitsForCell(cell,unit,units);
@ -2817,7 +2817,7 @@ void UnitUpdater::saveGame(XmlNode *rootNode) {
// RandomGen random;
//unitupdaterNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements);
// float attackWarnRange;
unitupdaterNode->addAttribute("attackWarnRange",doubleToStr(attackWarnRange,10), mapTagReplacements);
unitupdaterNode->addAttribute("attackWarnRange",floatToStr(attackWarnRange,6), mapTagReplacements);
// AttackWarnings attackWarnings;
//
// Mutex mutexUnitRangeCellsLookupItemCache;

View File

@ -55,7 +55,7 @@ public:
class AttackWarningData {
public:
Vec2d attackPosition;
Vec2f attackPosition;
int lastFrameCount;
};
@ -81,7 +81,7 @@ private:
Game *game;
//RandomGen random;
Mutex mutexAttackWarnings;
double attackWarnRange;
float attackWarnRange;
AttackWarnings attackWarnings;
Mutex mutexUnitRangeCellsLookupItemCache;

View File

@ -45,12 +45,12 @@ class Model;
class Particle {
public:
//attributes
Vec3d pos;
Vec3d lastPos;
Vec3d speed;
Vec3d accel;
Vec3f pos;
Vec3f lastPos;
Vec3f speed;
Vec3f accel;
Vec4f color;
double size;
float size;
int energy;
public:
@ -59,12 +59,12 @@ public:
energy = 0;
}
//get
Vec3d getPos() const {return pos;}
Vec3d getLastPos() const {return lastPos;}
Vec3d getSpeed() const {return speed;}
Vec3d getAccel() const {return accel;}
Vec3f getPos() const {return pos;}
Vec3f getLastPos() const {return lastPos;}
Vec3f getSpeed() const {return speed;}
Vec3f getAccel() const {return accel;}
Vec4f getColor() const {return color;}
double getSize() const {return size;}
float getSize() const {return size;}
int getEnergy() const {return energy;}
void saveGame(XmlNode *rootNode);
@ -135,15 +135,15 @@ protected:
int textureFileLoadDeferredComponents;
Texture *texture;
Vec3d pos;
Vec3f pos;
Vec4f color;
Vec4f colorNoEnergy;
double emissionRate;
double emissionState;
float emissionRate;
float emissionState;
int maxParticleEnergy;
int varParticleEnergy;
double particleSize;
double speed;
float particleSize;
float speed;
Vec3f factionColor;
bool teamcolorNoEnergy;
bool teamcolorEnergy;
@ -166,7 +166,7 @@ public:
State getState() const {return state;}
BlendMode getBlendMode() const {return blendMode;}
Texture *getTexture() const {return texture;}
Vec3d getPos() const {return pos;}
Vec3f 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,14 +181,14 @@ public:
//set
virtual void setState(State state);
void setTexture(Texture *texture);
virtual void setPos(Vec3d pos);
virtual void setPos(Vec3f pos);
void setColor(Vec4f color);
void setColorNoEnergy(Vec4f color);
void setEmissionRate(double emissionRate);
void setEmissionRate(float emissionRate);
void setMaxParticleEnergy(int maxParticleEnergy);
void setVarParticleEnergy(int varParticleEnergy);
void setParticleSize(double particleSize);
void setSpeed(double speed);
void setParticleSize(float particleSize);
void setSpeed(float speed);
virtual void setActive(bool active);
void setObserver(ParticleObserver *particleObserver);
virtual void setVisible(bool visible);
@ -236,8 +236,8 @@ protected:
class FireParticleSystem: public ParticleSystem{
private:
double radius;
Vec3d windSpeed;
float radius;
Vec3f windSpeed;
public:
FireParticleSystem(int particleCount= 2000);
@ -249,8 +249,8 @@ public:
virtual void updateParticle(Particle *p);
//set params
void setRadius(double radius);
void setWind(double windAngle, double windSpeed);
void setRadius(float radius);
void setWind(float windAngle, float windSpeed);
virtual void saveGame(XmlNode *rootNode);
virtual void loadGame(const XmlNode *rootNode);
@ -280,17 +280,17 @@ public:
ParticleSystem* getChild(int i);
void addChild(UnitParticleSystem* child);
void removeChild(UnitParticleSystem* child);
void setPos(Vec3d pos);
void setOffset(Vec3d offset);
void setPos(Vec3f pos);
void setOffset(Vec3f 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
float getTween() { return tween; } // 0.0 -> 1.0 for animation of model
Model *getModel() const {return model;}
virtual string getModelFileLoadDeferred();
void setPrimitive(Primitive primitive) {this->primitive= primitive;}
Vec3d getDirection() const {return direction;}
void setModelCycle(double modelCycle) {this->modelCycle= modelCycle;}
Vec3f getDirection() const {return direction;}
void setModelCycle(float modelCycle) {this->modelCycle= modelCycle;}
virtual void saveGame(XmlNode *rootNode);
virtual void loadGame(const XmlNode *rootNode);
@ -306,14 +306,14 @@ protected:
string modelFileLoadDeferred;
Model *model;
double modelCycle;
Vec3d offset;
Vec3d direction;
double tween;
float modelCycle;
Vec3f offset;
Vec3f direction;
float tween;
GameParticleSystem(int particleCount);
void positionChildren();
void setTween(double relative,double absolute);
void setTween(float relative,float absolute);
};
// =====================================================
@ -325,15 +325,15 @@ public:
static bool isNight;
static Vec3f lightColor;
private:
double radius;
double minRadius;
Vec3d windSpeed;
Vec3d cRotation;
Vec3d fixedAddition;
Vec3d oldPosition;
float radius;
float minRadius;
Vec3f windSpeed;
Vec3f cRotation;
Vec3f fixedAddition;
Vec3f oldPosition;
bool energyUp;
double startTime;
double endTime;
float startTime;
float endTime;
public:
enum Shape{
@ -345,10 +345,10 @@ public:
bool relativeDirection;
bool fixed;
Shape shape;
double angle;
double sizeNoEnergy;
double gravity;
double rotation;
float angle;
float sizeNoEnergy;
float gravity;
float rotation;
bool isVisibleAtNight;
bool isVisibleAtDay;
bool isDaylightAffected;
@ -356,7 +356,7 @@ public:
int staticParticleCount;
int delay;
int lifetime;
double emissionRateFade;
float emissionRateFade;
GameParticleSystem* parent;
public:
@ -373,22 +373,22 @@ public:
virtual void fade();
virtual void render(ParticleRenderer *pr, ModelRenderer *mr);
virtual void setStartTime(double startTime) { this->startTime = startTime; }
virtual double getStartTime() const { return this->startTime; }
virtual void setEndTime(double endTime) { this->endTime = endTime; }
virtual double getEndTime() const { return this->endTime; }
virtual void setStartTime(float startTime) { this->startTime = startTime; }
virtual float getStartTime() const { return this->startTime; }
virtual void setEndTime(float endTime) { this->endTime = endTime; }
virtual float getEndTime() const { return this->endTime; }
//set params
void setRadius(double radius) {this->radius= radius;}
void setMinRadius(double minRadius) {this->minRadius= minRadius;}
void setEmissionRateFade(double emissionRateFade) {this->emissionRateFade= emissionRateFade;}
void setRadius(float radius) {this->radius= radius;}
void setMinRadius(float minRadius) {this->minRadius= minRadius;}
void setEmissionRateFade(float emissionRateFade) {this->emissionRateFade= emissionRateFade;}
void setWind(double windAngle, double windSpeed);
void setWind(float windAngle, float windSpeed);
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);
void setDirection(Vec3f direction) {this->direction= direction;}
void setSizeNoEnergy(float sizeNoEnergy) {this->sizeNoEnergy= sizeNoEnergy;}
void setGravity(float gravity) {this->gravity= gravity;}
void setRotation(float rotation);
void setRelative(bool relative) {this->relative= relative;}
void setRelativeDirection(bool relativeDirection) {this->relativeDirection= relativeDirection;}
void setFixed(bool fixed) {this->fixed= fixed;}
@ -399,12 +399,12 @@ public:
void setIsVisibleAtDay(bool value) {this->isVisibleAtDay= value;}
void setRadiusBasedStartenergy(bool value) {this->radiusBasedStartenergy= value;}
void setShape(Shape shape) {this->shape= shape;}
void setAngle(double angle) {this->angle= angle;}
void setAngle(float angle) {this->angle= angle;}
void setDelay(int delay) {this->delay= delay;}
void setLifetime(int lifetime) {this->lifetime= lifetime;}
void setParent(GameParticleSystem* parent) {this->parent= parent;}
GameParticleSystem* getParent() const {return parent;}
void setParentDirection(Vec3d parentDirection);
void setParentDirection(Vec3f parentDirection);
static Shape strToShape(const string& str);
@ -422,8 +422,8 @@ public:
class RainParticleSystem: public ParticleSystem{
private:
Vec3d windSpeed;
double radius;
Vec3f windSpeed;
float radius;
public:
RainParticleSystem(int particleCount= 4000);
@ -435,8 +435,8 @@ public:
virtual void initParticle(Particle *p, int particleIndex);
virtual bool deathTest(Particle *p);
void setRadius(double radius);
void setWind(double windAngle, double windSpeed);
void setRadius(float radius);
void setWind(float windAngle, float windSpeed);
virtual string toString() const;
@ -449,8 +449,8 @@ public:
class SnowParticleSystem: public ParticleSystem{
private:
Vec3d windSpeed;
double radius;
Vec3f windSpeed;
float radius;
public:
SnowParticleSystem(int particleCount= 4000);
@ -460,8 +460,8 @@ public:
virtual void initParticle(Particle *p, int particleIndex);
virtual bool deathTest(Particle *p);
void setRadius(double radius);
void setWind(double windAngle, double windSpeed);
void setRadius(float radius);
void setWind(float windAngle, float windSpeed);
virtual string toString() const;
@ -477,15 +477,15 @@ public:
class AttackParticleSystem: public GameParticleSystem {
protected:
double sizeNoEnergy;
double gravity;
float sizeNoEnergy;
float gravity;
public:
AttackParticleSystem(int particleCount);
virtual ParticleSystemType getParticleSystemType() const { return pst_ProjectileParticleSystem;}
void setSizeNoEnergy(double sizeNoEnergy) {this->sizeNoEnergy= sizeNoEnergy;}
void setGravity(double gravity) {this->gravity= gravity;}
void setSizeNoEnergy(float sizeNoEnergy) {this->sizeNoEnergy= sizeNoEnergy;}
void setGravity(float gravity) {this->gravity= gravity;}
virtual void initParticleSystem() {} // opportunity to do any initialization when the system has been created and all settings set
@ -514,23 +514,23 @@ public:
private:
SplashParticleSystem *nextParticleSystem;
Vec3d lastPos;
Vec3d startPos;
Vec3d endPos;
Vec3d flatPos;
Vec3f lastPos;
Vec3f startPos;
Vec3f endPos;
Vec3f flatPos;
Vec3d xVector;
Vec3d yVector;
Vec3d zVector;
Vec3f xVector;
Vec3f yVector;
Vec3f zVector;
Trajectory trajectory;
double trajectorySpeed;
float trajectorySpeed;
//parabolic
double trajectoryScale;
double trajectoryFrequency;
float trajectoryScale;
float trajectoryFrequency;
double arriveDestinationDistance;
float arriveDestinationDistance;
void rotateChildren();
public:
@ -546,11 +546,11 @@ public:
virtual void updateParticle(Particle *p);
void setTrajectory(Trajectory trajectory) {this->trajectory= trajectory;}
void setTrajectorySpeed(double trajectorySpeed) {this->trajectorySpeed= trajectorySpeed;}
void setTrajectoryScale(double trajectoryScale) {this->trajectoryScale= trajectoryScale;}
void setTrajectoryFrequency(double trajectoryFrequency) {this->trajectoryFrequency= trajectoryFrequency;}
void setTrajectorySpeed(float trajectorySpeed) {this->trajectorySpeed= trajectorySpeed;}
void setTrajectoryScale(float trajectoryScale) {this->trajectoryScale= trajectoryScale;}
void setTrajectoryFrequency(float trajectoryFrequency) {this->trajectoryFrequency= trajectoryFrequency;}
void setPath(Vec3d startPos, Vec3d endPos);
void setPath(Vec3f startPos, Vec3f endPos);
static Trajectory strToTrajectory(const string &str);
@ -573,13 +573,13 @@ public:
private:
ProjectileParticleSystem *prevParticleSystem;
double emissionRateFade;
double verticalSpreadA;
double verticalSpreadB;
double horizontalSpreadA;
double horizontalSpreadB;
float emissionRateFade;
float verticalSpreadA;
float verticalSpreadB;
float horizontalSpreadA;
float horizontalSpreadB;
double startEmissionRate;
float startEmissionRate;
public:
SplashParticleSystem(int particleCount= 1000);
@ -591,11 +591,11 @@ public:
virtual void initParticleSystem();
void setEmissionRateFade(double emissionRateFade) {this->emissionRateFade= emissionRateFade;}
void setVerticalSpreadA(double verticalSpreadA) {this->verticalSpreadA= verticalSpreadA;}
void setVerticalSpreadB(double verticalSpreadB) {this->verticalSpreadB= verticalSpreadB;}
void setHorizontalSpreadA(double horizontalSpreadA) {this->horizontalSpreadA= horizontalSpreadA;}
void setHorizontalSpreadB(double horizontalSpreadB) {this->horizontalSpreadB= horizontalSpreadB;}
void setEmissionRateFade(float emissionRateFade) {this->emissionRateFade= emissionRateFade;}
void setVerticalSpreadA(float verticalSpreadA) {this->verticalSpreadA= verticalSpreadA;}
void setVerticalSpreadB(float verticalSpreadB) {this->verticalSpreadB= verticalSpreadB;}
void setHorizontalSpreadA(float horizontalSpreadA) {this->horizontalSpreadA= horizontalSpreadA;}
void setHorizontalSpreadB(float horizontalSpreadB) {this->horizontalSpreadB= horizontalSpreadB;}
virtual void saveGame(XmlNode *rootNode);
virtual void loadGame(const XmlNode *rootNode);

File diff suppressed because it is too large Load Diff

View File

@ -519,7 +519,7 @@ void Properties::setBool(const string &key, bool value){
}
void Properties::setFloat(const string &key, float value){
setString(key, floatToStr(value,10));
setString(key, floatToStr(value,6));
}
void Properties::setString(const string &key, const string &value){

View File

@ -81,7 +81,7 @@ int RandomGen::randRange(int min, int max,string lastCaller) {
int diff= max-min;
double numerator = static_cast<double>(diff + 1) * static_cast<double>(RandomGen::rand(lastCaller));
int res= min + static_cast<int>(truncateDecimal<double>(numerator / static_cast<double>(m),10));
int res= min + static_cast<int>(truncateDecimal<double>(numerator / static_cast<double>(m),6));
if(res < min || res > max) {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d] res < min || res > max, min = %d, max = %d, res = %d",__FILE__,__FUNCTION__,__LINE__,min,max,res);
@ -102,7 +102,7 @@ double RandomGen::randRange(double min, double max,string lastCaller) {
double rand01 = static_cast<double>(RandomGen::rand(lastCaller)) / (m-1);
double res= min + (max - min) * rand01;
res = truncateDecimal<double>(res,10);
res = truncateDecimal<double>(res,6);
if(res < min || res > max) {
char szBuf[8096]="";