- change a bunch of floats to double and remove path from particle texture

This commit is contained in:
Mark Vejvoda 2013-09-25 00:17:11 +00:00
parent 11471243ea
commit 525e0da652
8 changed files with 237 additions and 237 deletions

View File

@ -388,7 +388,7 @@ void UnitAttackBoostEffectOriginator::saveGame(XmlNode *rootNode) {
// class Unit // class Unit
// ===================================================== // =====================================================
const float Unit::ANIMATION_SPEED_MULTIPLIER = 100000.f; const double Unit::ANIMATION_SPEED_MULTIPLIER = 100000.f;
//const float Unit::PROGRESS_SPEED_MULTIPLIER = 100000.f; //const float Unit::PROGRESS_SPEED_MULTIPLIER = 100000.f;
const int64 Unit::PROGRESS_SPEED_MULTIPLIER = 100000; const int64 Unit::PROGRESS_SPEED_MULTIPLIER = 100000;
@ -496,7 +496,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
alive= true; alive= true;
if (type->hasSkillClass(scBeBuilt) == false) { if (type->hasSkillClass(scBeBuilt) == false) {
float rot= 0.f; double rot= 0.f;
random.init(id); random.init(id);
rot+= random.randRange(-5, 5,intToStr(__LINE__)); rot+= random.randRange(-5, 5,intToStr(__LINE__));
rotation= rot; rotation= rot;
@ -726,15 +726,15 @@ Vec2i Unit::getCellPos() const {
//find nearest pos to center that is free //find nearest pos to center that is free
Vec2i centeredPos= getCenteredPos(); Vec2i centeredPos= getCenteredPos();
float nearestDist= -1.f; double nearestDist= -1.f;
Vec2i nearestPos= pos; Vec2i nearestPos= pos;
for(int i=0; i<type->getSize(); ++i){ for(int i=0; i<type->getSize(); ++i){
for(int j=0; j<type->getSize(); ++j){ for(int j=0; j<type->getSize(); ++j){
if(type->getCellMapCell(i, j, modelFacing)){ if(type->getCellMapCell(i, j, modelFacing)){
Vec2i currPos= pos + Vec2i(i, j); Vec2i currPos= pos + Vec2i(i, j);
float dist= currPos.dist(centeredPos); double dist= currPos.dist(centeredPos);
if(nearestDist==-1.f || dist<nearestDist){ if(nearestDist == -1.f || dist < nearestDist) {
nearestDist= dist; nearestDist= dist;
nearestPos= currPos; nearestPos= currPos;
} }
@ -815,11 +815,11 @@ void Unit::calculateXZRotation(){
} }
} }
float Unit::getRotationZ() const{ double Unit::getRotationZ() const{
return rotationZ; return rotationZ;
} }
float Unit::getRotationX() const{ double Unit::getRotationX() const{
return rotationX; return rotationX;
} }
@ -836,7 +836,7 @@ int Unit::getProductionPercent() const{
return -1; return -1;
} }
float Unit::getProgressRatio() const{ double Unit::getProgressRatio() const{
if(anyCommand()){ if(anyCommand()){
const ProducibleType *produced= commands.front()->getCommandType()->getProduced(); const ProducibleType *produced= commands.front()->getCommandType()->getProduced();
if(produced != NULL){ if(produced != NULL){
@ -844,28 +844,28 @@ float Unit::getProgressRatio() const{
return 0.f; return 0.f;
} }
float help = progress2; double help = progress2;
return clamp(help / produced->getProductionTime(), 0.f, 1.f); return clamp(help / produced->getProductionTime(), 0.f, 1.f);
} }
} }
return -1; return -1;
} }
float Unit::getHpRatio() const { double Unit::getHpRatio() const {
if(type == NULL) { if(type == NULL) {
char szBuf[8096]=""; 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()); 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); throw megaglest_runtime_error(szBuf);
} }
float maxHpAllowed = type->getTotalMaxHp(&totalUpgrade); double maxHpAllowed = type->getTotalMaxHp(&totalUpgrade);
if(maxHpAllowed == 0.f) { if(maxHpAllowed == 0.f) {
return 0.f; return 0.f;
} }
return clamp(static_cast<float>(hp) / maxHpAllowed, 0.f, 1.f); return clamp(static_cast<double>(hp) / maxHpAllowed, 0.f, 1.f);
} }
float Unit::getEpRatio() const { double Unit::getEpRatio() const {
if(type == NULL) { if(type == NULL) {
char szBuf[8096]=""; 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()); snprintf(szBuf,8096,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->toString().c_str());
@ -876,11 +876,11 @@ float Unit::getEpRatio() const {
return 0.f; return 0.f;
} }
else { else {
float maxEpAllowed = type->getTotalMaxEp(&totalUpgrade); double maxEpAllowed = type->getTotalMaxEp(&totalUpgrade);
if(maxEpAllowed == 0.f) { if(maxEpAllowed == 0.f) {
return 0.f; return 0.f;
} }
return clamp(static_cast<float>(ep) / maxEpAllowed, 0.f, 1.f); return clamp(static_cast<double>(ep) / maxEpAllowed, 0.f, 1.f);
} }
} }
@ -1225,7 +1225,7 @@ FowAlphaCellsLookupItem Unit::getFogOfWarRadius(bool useCache) const {
Vec2i surfPos= Map::toSurfCoords(sightpos); Vec2i surfPos= Map::toSurfCoords(sightpos);
//compute max alpha //compute max alpha
float maxAlpha= 0.0f; double maxAlpha= 0.0f;
if(surfPos.x > 1 && surfPos.y > 1 && surfPos.x < map->getSurfaceW() -2 && surfPos.y < map->getSurfaceH() -2) { if(surfPos.x > 1 && surfPos.y > 1 && surfPos.x < map->getSurfaceW() -2 && surfPos.y < map->getSurfaceH() -2) {
maxAlpha= 1.f; maxAlpha= 1.f;
} }
@ -1234,8 +1234,8 @@ FowAlphaCellsLookupItem Unit::getFogOfWarRadius(bool useCache) const {
} }
//compute alpha //compute alpha
float alpha = maxAlpha; double alpha = maxAlpha;
float dist = this->getPosNotThreadSafe().dist(sightpos); double dist = this->getPosNotThreadSafe().dist(sightpos);
if(dist > sightRange) { if(dist > sightRange) {
alpha= clamp(1.f-(dist - sightRange) / (World::indirectSightRange), 0.f, maxAlpha); alpha= clamp(1.f-(dist - sightRange) / (World::indirectSightRange), 0.f, maxAlpha);
} }
@ -1425,30 +1425,30 @@ Vec3f Unit::getCurrVectorFlat() const{
return getVectorFlat(lastPos, pos); return getVectorFlat(lastPos, pos);
} }
float Unit::getProgressAsFloat() const { double Unit::getProgressAsFloat() const {
float result = (static_cast<float>(progress) / static_cast<float>(PROGRESS_SPEED_MULTIPLIER)); double result = (static_cast<double>(progress) / static_cast<double>(PROGRESS_SPEED_MULTIPLIER));
result = truncateDecimal<float>(result); result = truncateDecimal<double>(result);
return result; return result;
} }
Vec3f Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const { Vec3f Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const {
Vec3f v; Vec3f v;
float y1= computeHeight(lastPosValue); double y1= computeHeight(lastPosValue);
float y2= computeHeight(curPosValue); double y2= computeHeight(curPosValue);
if(currSkill->getClass() == scMove) { if(currSkill->getClass() == scMove) {
v.x= truncateDecimal<float>(lastPosValue.x + getProgressAsFloat() * (curPosValue.x - lastPosValue.x)); v.x= truncateDecimal<double>(lastPosValue.x + getProgressAsFloat() * (curPosValue.x - lastPosValue.x));
v.z= truncateDecimal<float>(lastPosValue.y + getProgressAsFloat() * (curPosValue.y - lastPosValue.y)); v.z= truncateDecimal<double>(lastPosValue.y + getProgressAsFloat() * (curPosValue.y - lastPosValue.y));
v.y= truncateDecimal<float>(y1 + getProgressAsFloat() * (y2-y1)); v.y= truncateDecimal<double>(y1 + getProgressAsFloat() * (y2-y1));
} }
else { else {
v.x= static_cast<float>(curPosValue.x); v.x= static_cast<double>(curPosValue.x);
v.z= static_cast<float>(curPosValue.y); v.z= static_cast<double>(curPosValue.y);
v.y= y2; v.y= y2;
} }
v.x += truncateDecimal<float>(type->getSize() / 2.f - 0.5f); v.x += truncateDecimal<double>(type->getSize() / 2.f - 0.5f);
v.z += truncateDecimal<float>(type->getSize() / 2.f - 0.5f); v.z += truncateDecimal<double>(type->getSize() / 2.f - 0.5f);
return v; return v;
} }
@ -2022,8 +2022,8 @@ int64 Unit::getHeightFactor(int64 speedMultiplier) {
throw megaglest_runtime_error("targetCell == NULL"); throw megaglest_runtime_error("targetCell == NULL");
} }
int64 heightDiff= ((truncateDecimal<float>(unitCell->getHeight(),2) * speedMultiplier) - int64 heightDiff= ((truncateDecimal<double>(unitCell->getHeight(),2) * speedMultiplier) -
(truncateDecimal<float>(targetCell->getHeight(),2) * speedMultiplier)); (truncateDecimal<double>(targetCell->getHeight(),2) * speedMultiplier));
//heightFactor= clamp(speedMultiplier + heightDiff / (5.f * speedMultiplier), 0.2f * speedMultiplier, 5.f * speedMultiplier); //heightFactor= clamp(speedMultiplier + heightDiff / (5.f * speedMultiplier), 0.2f * speedMultiplier, 5.f * speedMultiplier);
heightFactor= clamp(speedMultiplier + heightDiff / (5 * speedMultiplier), (2 * (speedMultiplier / 10)), 5 * speedMultiplier); heightFactor= clamp(speedMultiplier + heightDiff / (5 * speedMultiplier), (2 * (speedMultiplier / 10)), 5 * speedMultiplier);
} }
@ -2327,7 +2327,7 @@ bool Unit::update() {
//printf("Test progress = %d for unit [%d - %s]\n",progress,id,getType()->getName().c_str()); //printf("Test progress = %d for unit [%d - %s]\n",progress,id,getType()->getName().c_str());
if(isAnimProgressBound() == true) { if(isAnimProgressBound() == true) {
float targetProgress=0; double targetProgress=0;
if(currSkill->getClass() == scBeBuilt) { if(currSkill->getClass() == scBeBuilt) {
targetProgress = this->getHpRatio(); targetProgress = this->getHpRatio();
} }
@ -2341,10 +2341,10 @@ bool Unit::update() {
targetProgress = this->getProgressRatio(); targetProgress = this->getProgressRatio();
} }
float targetProgressIntValue = targetProgress * ANIMATION_SPEED_MULTIPLIER; double targetProgressIntValue = targetProgress * ANIMATION_SPEED_MULTIPLIER;
if(this->animProgress < targetProgressIntValue) { if(this->animProgress < targetProgressIntValue) {
float diff = targetProgressIntValue - this->animProgress; double diff = targetProgressIntValue - this->animProgress;
float progressIncrease = static_cast<float>(this->animProgress) + diff / static_cast<float>(GameConstants::updateFps); double progressIncrease = static_cast<double>(this->animProgress) + diff / static_cast<double>(GameConstants::updateFps);
// Ensure we increment at least a value of 1 of the action will be stuck infinitely // Ensure we increment at least a value of 1 of the action will be stuck infinitely
if(diff > 0.f && GameConstants::updateFps > 0 && progressIncrease == 0.f) { if(diff > 0.f && GameConstants::updateFps > 0 && progressIncrease == 0.f) {
progressIncrease = 1.f; progressIncrease = 1.f;
@ -2389,7 +2389,7 @@ bool Unit::update() {
rotation= lastRotation + (targetRotation - lastRotation) * rotation= lastRotation + (targetRotation - lastRotation) *
getProgressAsFloat() * rotFactor; getProgressAsFloat() * rotFactor;
else { else {
float rotationTerm = targetRotation > lastRotation ? -360.f: +360.f; double rotationTerm = targetRotation > lastRotation ? -360.f: +360.f;
rotation = lastRotation + (targetRotation - lastRotation + rotationTerm) * rotation = lastRotation + (targetRotation - lastRotation + rotationTerm) *
getProgressAsFloat() * rotFactor; getProgressAsFloat() * rotFactor;
} }
@ -2523,8 +2523,8 @@ void Unit::updateTimedParticles() {
UnitParticleSystem *ps = unitParticleSystems[i]; UnitParticleSystem *ps = unitParticleSystems[i];
if(ps != NULL) { if(ps != NULL) {
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) { if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
float pst = ps->getStartTime(); double pst = ps->getStartTime();
float pet = ps->getEndTime(); double pet = ps->getEndTime();
double particleStartTime = truncateDecimal<double>(pst); double particleStartTime = truncateDecimal<double>(pst);
double particleEndTime = truncateDecimal<double>(pet); double particleEndTime = truncateDecimal<double>(pet);
@ -3334,7 +3334,7 @@ bool Unit::morph(const MorphCommandType *mct) {
// ==================== PRIVATE ==================== // ==================== PRIVATE ====================
float Unit::computeHeight(const Vec2i &pos) const { double Unit::computeHeight(const Vec2i &pos) const {
//printf("CRASHING FOR UNIT: %d alive = %d\n",this->getId(),this->isAlive()); //printf("CRASHING FOR UNIT: %d alive = %d\n",this->getId(),this->isAlive());
//printf("[%s]\n",this->getType()->getName().c_str()); //printf("[%s]\n",this->getType()->getName().c_str());
if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) { if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) {
@ -3343,24 +3343,24 @@ float Unit::computeHeight(const Vec2i &pos) const {
throw megaglest_runtime_error("#7 Invalid path position = " + pos.getString()); throw megaglest_runtime_error("#7 Invalid path position = " + pos.getString());
} }
float height= map->getCell(pos)->getHeight(); double height= map->getCell(pos)->getHeight();
if(currField == fAir) { if(currField == fAir) {
const float airHeight=game->getWorld()->getTileset()->getAirHeight(); const double airHeight=game->getWorld()->getTileset()->getAirHeight();
height += airHeight; height += airHeight;
height = truncateDecimal<float>(height); height = truncateDecimal<double>(height);
Unit *unit = map->getCell(pos)->getUnit(fLand); Unit *unit = map->getCell(pos)->getUnit(fLand);
if(unit != NULL && unit->getType()->getHeight() > airHeight) { if(unit != NULL && unit->getType()->getHeight() > airHeight) {
height += (std::min((float)unit->getType()->getHeight(),Tileset::standardAirHeight * 3) - airHeight); height += (std::min((double)unit->getType()->getHeight(),Tileset::standardAirHeight * 3) - airHeight);
height = truncateDecimal<float>(height); height = truncateDecimal<double>(height);
} }
else { else {
SurfaceCell *sc = map->getSurfaceCell(map->toSurfCoords(pos)); SurfaceCell *sc = map->getSurfaceCell(map->toSurfCoords(pos));
if(sc != NULL && sc->getObject() != NULL && sc->getObject()->getType() != NULL) { if(sc != NULL && sc->getObject() != NULL && sc->getObject()->getType() != NULL) {
if(sc->getObject()->getType()->getHeight() > airHeight) { if(sc->getObject()->getType()->getHeight() > airHeight) {
height += (std::min((float)sc->getObject()->getType()->getHeight(),Tileset::standardAirHeight * 3) - airHeight); height += (std::min((double)sc->getObject()->getType()->getHeight(),Tileset::standardAirHeight * 3) - airHeight);
height = truncateDecimal<float>(height); height = truncateDecimal<double>(height);
} }
} }
} }
@ -4158,10 +4158,10 @@ std::string Unit::toString(bool crcMode) const {
result += "\n"; result += "\n";
result += "networkCRCLogInfo = " + networkCRCLogInfo; result += "networkCRCLogInfo = " + networkCRCLogInfo;
result += "\n"; result += "\n";
if(crcMode == false) {
result += " lastAnimProgress = " + intToStr(this->lastAnimProgress); result += " lastAnimProgress = " + intToStr(this->lastAnimProgress);
result += " animProgress = " + intToStr(this->animProgress); result += " animProgress = " + intToStr(this->animProgress);
if(crcMode == false) { result += " highlight = " + doubleToStr(this->highlight,16);
result += " highlight = " + floatToStr(this->highlight,16);
} }
result += " progress2 = " + intToStr(this->progress2); result += " progress2 = " + intToStr(this->progress2);
result += " kills = " + intToStr(this->kills); result += " kills = " + intToStr(this->kills);
@ -4190,9 +4190,9 @@ std::string Unit::toString(bool crcMode) const {
result += "\n"; result += "\n";
if(crcMode == false) { if(crcMode == false) {
result += " lastRotation = " + floatToStr(this->lastRotation,16); result += " lastRotation = " + doubleToStr(this->lastRotation,16);
result += " targetRotation = " + floatToStr(this->targetRotation,16); result += " targetRotation = " + doubleToStr(this->targetRotation,16);
result += " rotation = " + floatToStr(this->rotation,16); result += " rotation = " + doubleToStr(this->rotation,16);
} }
if(loadType != NULL) { if(loadType != NULL) {
@ -4300,7 +4300,7 @@ void Unit::saveGame(XmlNode *rootNode) {
// float animProgress; //between 0 and 1 // float animProgress; //between 0 and 1
unitNode->addAttribute("animProgress",intToStr(animProgress), mapTagReplacements); unitNode->addAttribute("animProgress",intToStr(animProgress), mapTagReplacements);
// float highlight; // float highlight;
unitNode->addAttribute("highlight",floatToStr(highlight,16), mapTagReplacements); unitNode->addAttribute("highlight",doubleToStr(highlight,16), mapTagReplacements);
// int progress2; // int progress2;
unitNode->addAttribute("progress2",intToStr(progress2), mapTagReplacements); unitNode->addAttribute("progress2",intToStr(progress2), mapTagReplacements);
// int kills; // int kills;
@ -4330,19 +4330,19 @@ void Unit::saveGame(XmlNode *rootNode) {
unitNode->addAttribute("meetingPos",meetingPos.getString(), mapTagReplacements); unitNode->addAttribute("meetingPos",meetingPos.getString(), mapTagReplacements);
// //
// float lastRotation; //in degrees // float lastRotation; //in degrees
unitNode->addAttribute("lastRotation",floatToStr(lastRotation,16), mapTagReplacements); unitNode->addAttribute("lastRotation",doubleToStr(lastRotation,16), mapTagReplacements);
// float targetRotation; // float targetRotation;
unitNode->addAttribute("targetRotation",floatToStr(targetRotation,16), mapTagReplacements); unitNode->addAttribute("targetRotation",doubleToStr(targetRotation,16), mapTagReplacements);
// float rotation; // float rotation;
unitNode->addAttribute("rotation",floatToStr(rotation,16), mapTagReplacements); unitNode->addAttribute("rotation",doubleToStr(rotation,16), mapTagReplacements);
// float targetRotationZ; // float targetRotationZ;
unitNode->addAttribute("targetRotationZ",floatToStr(targetRotationZ,16), mapTagReplacements); unitNode->addAttribute("targetRotationZ",doubleToStr(targetRotationZ,16), mapTagReplacements);
// float targetRotationX; // float targetRotationX;
unitNode->addAttribute("targetRotationX",floatToStr(targetRotationX,16), mapTagReplacements); unitNode->addAttribute("targetRotationX",doubleToStr(targetRotationX,16), mapTagReplacements);
// float rotationZ; // float rotationZ;
unitNode->addAttribute("rotationZ",floatToStr(rotationZ,16), mapTagReplacements); unitNode->addAttribute("rotationZ",doubleToStr(rotationZ,16), mapTagReplacements);
// float rotationX; // float rotationX;
unitNode->addAttribute("rotationX",floatToStr(rotationX,16), mapTagReplacements); unitNode->addAttribute("rotationX",doubleToStr(rotationX,16), mapTagReplacements);
// const UnitType *type; // const UnitType *type;
unitNode->addAttribute("type",type->getName(false), mapTagReplacements); unitNode->addAttribute("type",type->getName(false), mapTagReplacements);

View File

@ -330,7 +330,7 @@ private:
static std::map<Unit *,bool> mapMemoryList; static std::map<Unit *,bool> mapMemoryList;
#endif #endif
static const float ANIMATION_SPEED_MULTIPLIER; static const double ANIMATION_SPEED_MULTIPLIER;
static const int64 PROGRESS_SPEED_MULTIPLIER; static const int64 PROGRESS_SPEED_MULTIPLIER;
public: public:
@ -353,7 +353,7 @@ private:
int64 progress; //between 0 and 1 int64 progress; //between 0 and 1
int64 lastAnimProgress; //between 0 and 1 int64 lastAnimProgress; //between 0 and 1
int64 animProgress; //between 0 and 1 int64 animProgress; //between 0 and 1
float highlight; double highlight;
int32 progress2; int32 progress2;
int32 kills; int32 kills;
int32 enemyKills; int32 enemyKills;
@ -371,13 +371,13 @@ private:
Vec3f targetVec; Vec3f targetVec;
Vec2i meetingPos; Vec2i meetingPos;
float lastRotation; //in degrees double lastRotation; //in degrees
float targetRotation; double targetRotation;
float rotation; double rotation;
float targetRotationZ; double targetRotationZ;
float targetRotationX; double targetRotationX;
float rotationZ; double rotationZ;
float rotationX; double rotationX;
const UnitType *preMorph_type; const UnitType *preMorph_type;
const UnitType *type; const UnitType *type;
@ -517,10 +517,10 @@ public:
//inline int getLastAnimProgress() const {return lastAnimProgress;} //inline int getLastAnimProgress() const {return lastAnimProgress;}
//inline int getAnimProgress() const {return animProgress;} //inline int getAnimProgress() const {return animProgress;}
inline float getLastAnimProgressAsFloat() const {return static_cast<float>(lastAnimProgress) / ANIMATION_SPEED_MULTIPLIER;} inline double getLastAnimProgressAsFloat() const {return static_cast<double>(lastAnimProgress) / ANIMATION_SPEED_MULTIPLIER;}
inline float getAnimProgressAsFloat() const {return static_cast<float>(animProgress) / ANIMATION_SPEED_MULTIPLIER;} inline double getAnimProgressAsFloat() const {return static_cast<double>(animProgress) / ANIMATION_SPEED_MULTIPLIER;}
inline float getHightlight() const {return highlight;} inline double getHightlight() const {return highlight;}
inline int getProgress2() const {return progress2;} inline int getProgress2() const {return progress2;}
inline int getFactionIndex() const { inline int getFactionIndex() const {
return faction->getIndex(); return faction->getIndex();
@ -531,9 +531,9 @@ public:
inline int getHp() const {return hp;} inline int getHp() const {return hp;}
inline int getEp() const {return ep;} inline int getEp() const {return ep;}
int getProductionPercent() const; int getProductionPercent() const;
float getProgressRatio() const; double getProgressRatio() const;
float getHpRatio() const; double getHpRatio() const;
float getEpRatio() const; double getEpRatio() const;
inline bool getToBeUndertaken() const {return toBeUndertaken;} inline bool getToBeUndertaken() const {return toBeUndertaken;}
inline Vec2i getTargetPos() const {return targetPos;} inline Vec2i getTargetPos() const {return targetPos;}
inline Vec3f getTargetVec() const {return targetVec;} inline Vec3f getTargetVec() const {return targetVec;}
@ -546,9 +546,9 @@ public:
inline const SkillType *getCurrSkill() const {return currSkill;} inline const SkillType *getCurrSkill() const {return currSkill;}
inline const TotalUpgrade *getTotalUpgrade() const {return &totalUpgrade;} inline const TotalUpgrade *getTotalUpgrade() const {return &totalUpgrade;}
inline float getRotation() const {return rotation;} inline double getRotation() const {return rotation;}
float getRotationX() const; double getRotationX() const;
float getRotationZ() const; double getRotationZ() const;
ParticleSystem *getFire() const; ParticleSystem *getFire() const;
inline int getKills() const {return kills;} inline int getKills() const {return kills;}
inline int getEnemyKills() const {return enemyKills;} inline int getEnemyKills() const {return enemyKills;}
@ -742,7 +742,7 @@ public:
std::string toString(bool crcMode=false) const; std::string toString(bool crcMode=false) const;
bool needToUpdate(); bool needToUpdate();
float getProgressAsFloat() const; double getProgressAsFloat() const;
int64 getUpdateProgress(); int64 getUpdateProgress();
int64 getDiagonalFactor(); int64 getDiagonalFactor();
int64 getHeightFactor(int64 speedMultiplier=PROGRESS_SPEED_MULTIPLIER); int64 getHeightFactor(int64 speedMultiplier=PROGRESS_SPEED_MULTIPLIER);
@ -794,7 +794,7 @@ private:
void addNetworkCRCDecHp(string info) { } void addNetworkCRCDecHp(string info) { }
string getNetworkCRCDecHpList() const; string getNetworkCRCDecHpList() const;
float computeHeight(const Vec2i &pos) const; double computeHeight(const Vec2i &pos) const;
void calculateXZRotation(); void calculateXZRotation();
void updateTarget(); void updateTarget();
void clearCommands(); void clearCommands();

View File

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

View File

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

View File

@ -50,7 +50,7 @@ public:
Vec3f speed; Vec3f speed;
Vec3f accel; Vec3f accel;
Vec4f color; Vec4f color;
float size; double size;
int energy; int energy;
public: public:
@ -64,7 +64,7 @@ public:
Vec3f getSpeed() const {return speed;} Vec3f getSpeed() const {return speed;}
Vec3f getAccel() const {return accel;} Vec3f getAccel() const {return accel;}
Vec4f getColor() const {return color;} Vec4f getColor() const {return color;}
float getSize() const {return size;} double getSize() const {return size;}
int getEnergy() const {return energy;} int getEnergy() const {return energy;}
void saveGame(XmlNode *rootNode); void saveGame(XmlNode *rootNode);
@ -138,12 +138,12 @@ protected:
Vec3f pos; Vec3f pos;
Vec4f color; Vec4f color;
Vec4f colorNoEnergy; Vec4f colorNoEnergy;
float emissionRate; double emissionRate;
float emissionState; double emissionState;
int maxParticleEnergy; int maxParticleEnergy;
int varParticleEnergy; int varParticleEnergy;
float particleSize; double particleSize;
float speed; double speed;
Vec3f factionColor; Vec3f factionColor;
bool teamcolorNoEnergy; bool teamcolorNoEnergy;
bool teamcolorEnergy; bool teamcolorEnergy;
@ -184,11 +184,11 @@ public:
virtual void setPos(Vec3f pos); virtual void setPos(Vec3f pos);
void setColor(Vec4f color); void setColor(Vec4f color);
void setColorNoEnergy(Vec4f color); void setColorNoEnergy(Vec4f color);
void setEmissionRate(float emissionRate); void setEmissionRate(double emissionRate);
void setMaxParticleEnergy(int maxParticleEnergy); void setMaxParticleEnergy(int maxParticleEnergy);
void setVarParticleEnergy(int varParticleEnergy); void setVarParticleEnergy(int varParticleEnergy);
void setParticleSize(float particleSize); void setParticleSize(double particleSize);
void setSpeed(float speed); void setSpeed(double speed);
virtual void setActive(bool active); virtual void setActive(bool active);
void setObserver(ParticleObserver *particleObserver); void setObserver(ParticleObserver *particleObserver);
virtual void setVisible(bool visible); virtual void setVisible(bool visible);
@ -236,7 +236,7 @@ protected:
class FireParticleSystem: public ParticleSystem{ class FireParticleSystem: public ParticleSystem{
private: private:
float radius; double radius;
Vec3f windSpeed; Vec3f windSpeed;
public: public:
@ -249,8 +249,8 @@ public:
virtual void updateParticle(Particle *p); virtual void updateParticle(Particle *p);
//set params //set params
void setRadius(float radius); void setRadius(double radius);
void setWind(float windAngle, float windSpeed); void setWind(double windAngle, double windSpeed);
virtual void saveGame(XmlNode *rootNode); virtual void saveGame(XmlNode *rootNode);
virtual void loadGame(const XmlNode *rootNode); virtual void loadGame(const XmlNode *rootNode);
@ -284,13 +284,13 @@ public:
void setOffset(Vec3f offset); void setOffset(Vec3f offset);
void setModel(Model *model) {this->model= model;} void setModel(Model *model) {this->model= model;}
virtual void render(ParticleRenderer *pr, ModelRenderer *mr); virtual void render(ParticleRenderer *pr, ModelRenderer *mr);
float getTween() { return tween; } // 0.0 -> 1.0 for animation of model double getTween() { return tween; } // 0.0 -> 1.0 for animation of model
Model *getModel() const {return model;} Model *getModel() const {return model;}
virtual string getModelFileLoadDeferred(); virtual string getModelFileLoadDeferred();
void setPrimitive(Primitive primitive) {this->primitive= primitive;} void setPrimitive(Primitive primitive) {this->primitive= primitive;}
Vec3f getDirection() const {return direction;} Vec3f getDirection() const {return direction;}
void setModelCycle(float modelCycle) {this->modelCycle= modelCycle;} void setModelCycle(double modelCycle) {this->modelCycle= modelCycle;}
virtual void saveGame(XmlNode *rootNode); virtual void saveGame(XmlNode *rootNode);
virtual void loadGame(const XmlNode *rootNode); virtual void loadGame(const XmlNode *rootNode);
@ -306,14 +306,14 @@ protected:
string modelFileLoadDeferred; string modelFileLoadDeferred;
Model *model; Model *model;
float modelCycle; double modelCycle;
Vec3f offset; Vec3f offset;
Vec3f direction; Vec3f direction;
float tween; double tween;
GameParticleSystem(int particleCount); GameParticleSystem(int particleCount);
void positionChildren(); void positionChildren();
void setTween(float relative,float absolute); void setTween(double relative,double absolute);
}; };
// ===================================================== // =====================================================
@ -325,15 +325,15 @@ public:
static bool isNight; static bool isNight;
static Vec3f lightColor; static Vec3f lightColor;
private: private:
float radius; double radius;
float minRadius; double minRadius;
Vec3f windSpeed; Vec3f windSpeed;
Vec3f cRotation; Vec3f cRotation;
Vec3f fixedAddition; Vec3f fixedAddition;
Vec3f oldPosition; Vec3f oldPosition;
bool energyUp; bool energyUp;
float startTime; double startTime;
float endTime; double endTime;
public: public:
enum Shape{ enum Shape{
@ -345,10 +345,10 @@ public:
bool relativeDirection; bool relativeDirection;
bool fixed; bool fixed;
Shape shape; Shape shape;
float angle; double angle;
float sizeNoEnergy; double sizeNoEnergy;
float gravity; double gravity;
float rotation; double rotation;
bool isVisibleAtNight; bool isVisibleAtNight;
bool isVisibleAtDay; bool isVisibleAtDay;
bool isDaylightAffected; bool isDaylightAffected;
@ -356,7 +356,7 @@ public:
int staticParticleCount; int staticParticleCount;
int delay; int delay;
int lifetime; int lifetime;
float emissionRateFade; double emissionRateFade;
GameParticleSystem* parent; GameParticleSystem* parent;
public: public:
@ -373,22 +373,22 @@ public:
virtual void fade(); virtual void fade();
virtual void render(ParticleRenderer *pr, ModelRenderer *mr); virtual void render(ParticleRenderer *pr, ModelRenderer *mr);
virtual void setStartTime(float startTime) { this->startTime = startTime; } virtual void setStartTime(double startTime) { this->startTime = startTime; }
virtual float getStartTime() const { return this->startTime; } virtual double getStartTime() const { return this->startTime; }
virtual void setEndTime(float endTime) { this->endTime = endTime; } virtual void setEndTime(double endTime) { this->endTime = endTime; }
virtual float getEndTime() const { return this->endTime; } virtual double getEndTime() const { return this->endTime; }
//set params //set params
void setRadius(float radius) {this->radius= radius;} void setRadius(double radius) {this->radius= radius;}
void setMinRadius(float minRadius) {this->minRadius= minRadius;} void setMinRadius(double minRadius) {this->minRadius= minRadius;}
void setEmissionRateFade(float emissionRateFade) {this->emissionRateFade= emissionRateFade;} void setEmissionRateFade(double emissionRateFade) {this->emissionRateFade= emissionRateFade;}
void setWind(float windAngle, float windSpeed); void setWind(double windAngle, double windSpeed);
void setDirection(Vec3f direction) {this->direction= direction;} void setDirection(Vec3f direction) {this->direction= direction;}
void setSizeNoEnergy(float sizeNoEnergy) {this->sizeNoEnergy= sizeNoEnergy;} void setSizeNoEnergy(double sizeNoEnergy) {this->sizeNoEnergy= sizeNoEnergy;}
void setGravity(float gravity) {this->gravity= gravity;} void setGravity(double gravity) {this->gravity= gravity;}
void setRotation(float rotation); void setRotation(double rotation);
void setRelative(bool relative) {this->relative= relative;} void setRelative(bool relative) {this->relative= relative;}
void setRelativeDirection(bool relativeDirection) {this->relativeDirection= relativeDirection;} void setRelativeDirection(bool relativeDirection) {this->relativeDirection= relativeDirection;}
void setFixed(bool fixed) {this->fixed= fixed;} void setFixed(bool fixed) {this->fixed= fixed;}
@ -399,7 +399,7 @@ public:
void setIsVisibleAtDay(bool value) {this->isVisibleAtDay= value;} void setIsVisibleAtDay(bool value) {this->isVisibleAtDay= value;}
void setRadiusBasedStartenergy(bool value) {this->radiusBasedStartenergy= value;} void setRadiusBasedStartenergy(bool value) {this->radiusBasedStartenergy= value;}
void setShape(Shape shape) {this->shape= shape;} void setShape(Shape shape) {this->shape= shape;}
void setAngle(float angle) {this->angle= angle;} void setAngle(double angle) {this->angle= angle;}
void setDelay(int delay) {this->delay= delay;} void setDelay(int delay) {this->delay= delay;}
void setLifetime(int lifetime) {this->lifetime= lifetime;} void setLifetime(int lifetime) {this->lifetime= lifetime;}
void setParent(GameParticleSystem* parent) {this->parent= parent;} void setParent(GameParticleSystem* parent) {this->parent= parent;}
@ -423,7 +423,7 @@ public:
class RainParticleSystem: public ParticleSystem{ class RainParticleSystem: public ParticleSystem{
private: private:
Vec3f windSpeed; Vec3f windSpeed;
float radius; double radius;
public: public:
RainParticleSystem(int particleCount= 4000); RainParticleSystem(int particleCount= 4000);
@ -435,8 +435,8 @@ public:
virtual void initParticle(Particle *p, int particleIndex); virtual void initParticle(Particle *p, int particleIndex);
virtual bool deathTest(Particle *p); virtual bool deathTest(Particle *p);
void setRadius(float radius); void setRadius(double radius);
void setWind(float windAngle, float windSpeed); void setWind(double windAngle, double windSpeed);
virtual string toString() const; virtual string toString() const;
@ -450,7 +450,7 @@ public:
class SnowParticleSystem: public ParticleSystem{ class SnowParticleSystem: public ParticleSystem{
private: private:
Vec3f windSpeed; Vec3f windSpeed;
float radius; double radius;
public: public:
SnowParticleSystem(int particleCount= 4000); SnowParticleSystem(int particleCount= 4000);
@ -460,8 +460,8 @@ public:
virtual void initParticle(Particle *p, int particleIndex); virtual void initParticle(Particle *p, int particleIndex);
virtual bool deathTest(Particle *p); virtual bool deathTest(Particle *p);
void setRadius(float radius); void setRadius(double radius);
void setWind(float windAngle, float windSpeed); void setWind(double windAngle, double windSpeed);
virtual string toString() const; virtual string toString() const;
@ -477,15 +477,15 @@ public:
class AttackParticleSystem: public GameParticleSystem { class AttackParticleSystem: public GameParticleSystem {
protected: protected:
float sizeNoEnergy; double sizeNoEnergy;
float gravity; double gravity;
public: public:
AttackParticleSystem(int particleCount); AttackParticleSystem(int particleCount);
virtual ParticleSystemType getParticleSystemType() const { return pst_ProjectileParticleSystem;} virtual ParticleSystemType getParticleSystemType() const { return pst_ProjectileParticleSystem;}
void setSizeNoEnergy(float sizeNoEnergy) {this->sizeNoEnergy= sizeNoEnergy;} void setSizeNoEnergy(double sizeNoEnergy) {this->sizeNoEnergy= sizeNoEnergy;}
void setGravity(float gravity) {this->gravity= gravity;} void setGravity(double gravity) {this->gravity= gravity;}
virtual void initParticleSystem() {} // opportunity to do any initialization when the system has been created and all settings set virtual void initParticleSystem() {} // opportunity to do any initialization when the system has been created and all settings set

View File

@ -43,7 +43,7 @@ public:
void init(int seed); void init(int seed);
int randRange(int min, int max,std::string lastCaller=""); int randRange(int min, int max,std::string lastCaller="");
float randRange(float min, float max,std::string lastCaller=""); double randRange(double min, double max,std::string lastCaller="");
int getLastNumber() const { return lastNumber; } int getLastNumber() const { return lastNumber; }
void setLastNumber(int value) { lastNumber = value; } void setLastNumber(int value) { lastNumber = value; }

View File

@ -55,7 +55,7 @@ void Particle::saveGame(XmlNode *rootNode) {
// Vec4f color; // Vec4f color;
particleNode->addAttribute("color",color.getString(), mapTagReplacements); particleNode->addAttribute("color",color.getString(), mapTagReplacements);
// float size; // float size;
particleNode->addAttribute("size",floatToStr(size,16), mapTagReplacements); particleNode->addAttribute("size",doubleToStr(size,16), mapTagReplacements);
// int energy; // int energy;
particleNode->addAttribute("energy",intToStr(energy), mapTagReplacements); particleNode->addAttribute("energy",intToStr(energy), mapTagReplacements);
} }
@ -216,7 +216,7 @@ void ParticleSystem::update(){
Particle *p= createParticle(); Particle *p= createParticle();
initParticle(p, i); initParticle(p, i);
} }
emissionState= emissionState - (float) emissionIntValue; emissionState = emissionState - (double) emissionIntValue;
} }
} }
} }
@ -265,7 +265,7 @@ void ParticleSystem::setColorNoEnergy(Vec4f colorNoEnergy){
this->colorNoEnergy= colorNoEnergy; this->colorNoEnergy= colorNoEnergy;
} }
void ParticleSystem::setEmissionRate(float emissionRate){ void ParticleSystem::setEmissionRate(double emissionRate){
this->emissionRate= emissionRate; this->emissionRate= emissionRate;
} }
@ -277,11 +277,11 @@ void ParticleSystem::setVarParticleEnergy(int varParticleEnergy){
this->varParticleEnergy= varParticleEnergy; this->varParticleEnergy= varParticleEnergy;
} }
void ParticleSystem::setParticleSize(float particleSize){ void ParticleSystem::setParticleSize(double particleSize){
this->particleSize= particleSize; this->particleSize= particleSize;
} }
void ParticleSystem::setSpeed(float speed){ void ParticleSystem::setSpeed(double speed){
this->speed= speed; this->speed= speed;
} }
@ -329,17 +329,17 @@ string ParticleSystem::toString() const {
result += "\ntextureFileLoadDeferredComponents = " + intToStr(textureFileLoadDeferredComponents); result += "\ntextureFileLoadDeferredComponents = " + intToStr(textureFileLoadDeferredComponents);
if(texture != NULL) { if(texture != NULL) {
result += "\ntexture = " + texture->getPath(); result += "\ntexture = " + extractFileFromDirectoryPath(texture->getPath());
} }
result += "\npos = " + pos.getString(); result += "\npos = " + pos.getString();
result += "\ncolor = " + color.getString(); result += "\ncolor = " + color.getString();
result += "\ncolorNoEnergy = " + colorNoEnergy.getString(); result += "\ncolorNoEnergy = " + colorNoEnergy.getString();
result += "\nemissionRate = " + floatToStr(emissionRate,16); result += "\nemissionRate = " + doubleToStr(emissionRate,16);
result += "\nemissionState = " + floatToStr(emissionState,16); result += "\nemissionState = " + doubleToStr(emissionState,16);
result += "\nmaxParticleEnergy = " + intToStr(maxParticleEnergy); result += "\nmaxParticleEnergy = " + intToStr(maxParticleEnergy);
result += "\nvarParticleEnergy = " + intToStr(varParticleEnergy); result += "\nvarParticleEnergy = " + intToStr(varParticleEnergy);
result += "\nparticleSize = " + floatToStr(particleSize,16); result += "\nparticleSize = " + doubleToStr(particleSize,16);
result += "\nspeed = " + floatToStr(speed,16); result += "\nspeed = " + doubleToStr(speed,16);
result += "\nfactionColor = " + factionColor.getString(); result += "\nfactionColor = " + factionColor.getString();
result += "\nteamcolorNoEnergy = " + intToStr(teamcolorNoEnergy); result += "\nteamcolorNoEnergy = " + intToStr(teamcolorNoEnergy);
result += "\nteamcolorEnergy = " + intToStr(teamcolorEnergy); result += "\nteamcolorEnergy = " + intToStr(teamcolorEnergy);
@ -392,17 +392,17 @@ void ParticleSystem::saveGame(XmlNode *rootNode) {
// Vec4f colorNoEnergy; // Vec4f colorNoEnergy;
particleSystemNode->addAttribute("colorNoEnergy",colorNoEnergy.getString(), mapTagReplacements); particleSystemNode->addAttribute("colorNoEnergy",colorNoEnergy.getString(), mapTagReplacements);
// float emissionRate; // float emissionRate;
particleSystemNode->addAttribute("emissionRate",floatToStr(emissionRate,16), mapTagReplacements); particleSystemNode->addAttribute("emissionRate",doubleToStr(emissionRate,16), mapTagReplacements);
// float emissionState; // float emissionState;
particleSystemNode->addAttribute("emissionState",floatToStr(emissionState,16), mapTagReplacements); particleSystemNode->addAttribute("emissionState",doubleToStr(emissionState,16), mapTagReplacements);
// int maxParticleEnergy; // int maxParticleEnergy;
particleSystemNode->addAttribute("maxParticleEnergy",intToStr(maxParticleEnergy), mapTagReplacements); particleSystemNode->addAttribute("maxParticleEnergy",intToStr(maxParticleEnergy), mapTagReplacements);
// int varParticleEnergy; // int varParticleEnergy;
particleSystemNode->addAttribute("varParticleEnergy",intToStr(varParticleEnergy), mapTagReplacements); particleSystemNode->addAttribute("varParticleEnergy",intToStr(varParticleEnergy), mapTagReplacements);
// float particleSize; // float particleSize;
particleSystemNode->addAttribute("particleSize",floatToStr(particleSize,16), mapTagReplacements); particleSystemNode->addAttribute("particleSize",doubleToStr(particleSize,16), mapTagReplacements);
// float speed; // float speed;
particleSystemNode->addAttribute("speed",floatToStr(speed,16), mapTagReplacements); particleSystemNode->addAttribute("speed",doubleToStr(speed,16), mapTagReplacements);
// Vec3f factionColor; // Vec3f factionColor;
particleSystemNode->addAttribute("factionColor",factionColor.getString(), mapTagReplacements); particleSystemNode->addAttribute("factionColor",factionColor.getString(), mapTagReplacements);
// bool teamcolorNoEnergy; // bool teamcolorNoEnergy;
@ -656,21 +656,21 @@ FireParticleSystem::FireParticleSystem(int particleCount) :
void FireParticleSystem::initParticle(Particle *p, int particleIndex){ void FireParticleSystem::initParticle(Particle *p, int particleIndex){
ParticleSystem::initParticle(p, particleIndex); ParticleSystem::initParticle(p, particleIndex);
float ang= random.randRange(-2.0f * pi, 2.0f * pi); double ang= random.randRange(-2.0f * pi, 2.0f * pi);
#ifdef USE_STREFLOP #ifdef USE_STREFLOP
float mod= streflop::fabsf(static_cast<streflop::Simple>(random.randRange(-radius, radius))); double mod= streflop::fabsf(static_cast<streflop::Simple>(random.randRange(-radius, radius)));
float x= streflop::sinf(static_cast<streflop::Simple>(ang))*mod; double x= streflop::sinf(static_cast<streflop::Simple>(ang))*mod;
float y= streflop::cosf(static_cast<streflop::Simple>(ang))*mod; double y= streflop::cosf(static_cast<streflop::Simple>(ang))*mod;
float radRatio= streflop::sqrtf(static_cast<streflop::Simple>(mod/radius)); double radRatio= streflop::sqrtf(static_cast<streflop::Simple>(mod/radius));
#else #else
float mod= fabsf(random.randRange(-radius, radius)); double mod= fabsf(random.randRange(-radius, radius));
float x= sinf(ang) * mod; double x= sinf(ang) * mod;
float y= cosf(ang) * mod; double y= cosf(ang) * mod;
float radRatio= sqrtf((mod / radius)); double radRatio= sqrtf((mod / radius));
#endif #endif
p->color= colorNoEnergy * 0.5f + colorNoEnergy * 0.5f * radRatio; p->color= colorNoEnergy * 0.5f + colorNoEnergy * 0.5f * radRatio;
@ -702,18 +702,18 @@ string FireParticleSystem::toString() const {
string result = ParticleSystem::toString(); string result = ParticleSystem::toString();
result += "\nFireParticleSystem "; result += "\nFireParticleSystem ";
result += "\nradius = " + floatToStr(radius); result += "\nradius = " + doubleToStr(radius);
result += "\nwindSpeed = " + windSpeed.getString(); result += "\nwindSpeed = " + windSpeed.getString();
return result; return result;
} }
// ================= SET PARAMS ==================== // ================= SET PARAMS ====================
void FireParticleSystem::setRadius(float radius){ void FireParticleSystem::setRadius(double radius){
this->radius= radius; this->radius= radius;
} }
void FireParticleSystem::setWind(float windAngle, float windSpeed){ void FireParticleSystem::setWind(double windAngle, double windSpeed) {
#ifdef USE_STREFLOP #ifdef USE_STREFLOP
this->windSpeed.x= streflop::sinf(static_cast<streflop::Simple>(degToRad(windAngle)))*windSpeed; this->windSpeed.x= streflop::sinf(static_cast<streflop::Simple>(degToRad(windAngle)))*windSpeed;
this->windSpeed.y= 0.0f; this->windSpeed.y= 0.0f;
@ -732,7 +732,7 @@ void FireParticleSystem::saveGame(XmlNode *rootNode) {
ParticleSystem::saveGame(fireParticleSystemNode); ParticleSystem::saveGame(fireParticleSystemNode);
// float radius; // float radius;
fireParticleSystemNode->addAttribute("radius",floatToStr(radius,16), mapTagReplacements); fireParticleSystemNode->addAttribute("radius",doubleToStr(radius,16), mapTagReplacements);
// Vec3f windSpeed; // Vec3f windSpeed;
fireParticleSystemNode->addAttribute("windSpeed",windSpeed.getString(), mapTagReplacements); fireParticleSystemNode->addAttribute("windSpeed",windSpeed.getString(), mapTagReplacements);
} }
@ -845,7 +845,7 @@ void GameParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr){
} }
} }
void GameParticleSystem::setTween(float relative,float absolute) { void GameParticleSystem::setTween(double relative,double absolute) {
if(model) { if(model) {
// animation? // animation?
//printf("#1 Particle model meshcount [%d] modelCycle = %f, relative = %f, absolute = %f\n",model->getMeshCount(),modelCycle,relative,absolute); //printf("#1 Particle model meshcount [%d] modelCycle = %f, relative = %f, absolute = %f\n",model->getMeshCount(),modelCycle,relative,absolute);
@ -870,7 +870,7 @@ void GameParticleSystem::setTween(float relative,float absolute) {
} }
} }
truncateDecimal<float>(tween); tween = truncateDecimal<double>(tween);
if(tween < 0.0f || tween > 1.0f) { 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); //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); //assert(tween >= 0.0f && tween <= 1.0f);
@ -908,13 +908,13 @@ void GameParticleSystem::saveGame(XmlNode *rootNode) {
gameParticleSystemNode->addAttribute("model",model->getFileName(), mapTagReplacements); gameParticleSystemNode->addAttribute("model",model->getFileName(), mapTagReplacements);
} }
// float modelCycle; // float modelCycle;
gameParticleSystemNode->addAttribute("modelCycle",floatToStr(modelCycle,16), mapTagReplacements); gameParticleSystemNode->addAttribute("modelCycle",doubleToStr(modelCycle,16), mapTagReplacements);
// Vec3f offset; // Vec3f offset;
gameParticleSystemNode->addAttribute("offset",offset.getString(), mapTagReplacements); gameParticleSystemNode->addAttribute("offset",offset.getString(), mapTagReplacements);
// Vec3f direction; // Vec3f direction;
gameParticleSystemNode->addAttribute("direction",direction.getString(), mapTagReplacements); gameParticleSystemNode->addAttribute("direction",direction.getString(), mapTagReplacements);
// float tween; // float tween;
gameParticleSystemNode->addAttribute("tween",floatToStr(tween,16), mapTagReplacements); gameParticleSystemNode->addAttribute("tween",doubleToStr(tween,16), mapTagReplacements);
} }
void GameParticleSystem::loadGame(const XmlNode *rootNode) { void GameParticleSystem::loadGame(const XmlNode *rootNode) {
const XmlNode *gameParticleSystemNode = rootNode->getChild("GameParticleSystem"); const XmlNode *gameParticleSystemNode = rootNode->getChild("GameParticleSystem");
@ -974,10 +974,10 @@ string GameParticleSystem::toString() const {
//string modelFileLoadDeferred; //string modelFileLoadDeferred;
//Model *model; //Model *model;
result += "\nmodelCycle = " + floatToStr(modelCycle); result += "\nmodelCycle = " + doubleToStr(modelCycle);
result += "\noffset = " + offset.getString(); result += "\noffset = " + offset.getString();
result += "\ndirection = " + direction.getString(); result += "\ndirection = " + direction.getString();
result += "\ntween = " + floatToStr(tween); result += "\ntween = " + doubleToStr(tween);
return result; return result;
} }
@ -1018,7 +1018,7 @@ UnitParticleSystem::UnitParticleSystem(int particleCount) :
fixedAddition= Vec3f(0.0f, 0.0f, 0.0f); fixedAddition= Vec3f(0.0f, 0.0f, 0.0f);
//prepare system for given staticParticleCount //prepare system for given staticParticleCount
if(staticParticleCount > 0){ if(staticParticleCount > 0){
emissionState= (float) staticParticleCount; emissionState= (double) staticParticleCount;
} }
energyUp= false; energyUp= false;
@ -1052,7 +1052,7 @@ void UnitParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr) {
GameParticleSystem::render(pr,mr); GameParticleSystem::render(pr,mr);
} }
void UnitParticleSystem::setRotation(float rotation){ void UnitParticleSystem::setRotation(double rotation){
this->rotation= rotation; this->rotation= rotation;
for(Children::iterator it= children.begin(); it != children.end(); ++it) for(Children::iterator it= children.begin(); it != children.end(); ++it)
(*it)->setRotation(rotation); (*it)->setRotation(rotation);
@ -1082,13 +1082,13 @@ UnitParticleSystem::Shape UnitParticleSystem::strToShape(const string& str){
void UnitParticleSystem::initParticle(Particle *p, int particleIndex){ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
ParticleSystem::initParticle(p, particleIndex); ParticleSystem::initParticle(p, particleIndex);
const float ang= random.randRange(-2.0f * pi, 2.0f * pi); const double ang= random.randRange(-2.0f * pi, 2.0f * pi);
#ifdef USE_STREFLOP #ifdef USE_STREFLOP
const float mod= streflop::fabsf(static_cast<streflop::Simple>(random.randRange(-radius, radius))); const double mod= streflop::fabsf(static_cast<streflop::Simple>(random.randRange(-radius, radius)));
const float radRatio= streflop::sqrtf(static_cast<streflop::Simple>(mod/radius)); const double radRatio= streflop::sqrtf(static_cast<streflop::Simple>(mod/radius));
#else #else
const float mod= fabsf(random.randRange(-radius, radius)); const double mod= fabsf(random.randRange(-radius, radius));
const float radRatio= sqrtf(mod / radius); const double radRatio= sqrtf(mod / radius);
#endif #endif
p->color= color; p->color= color;
if(isDaylightAffected==true) if(isDaylightAffected==true)
@ -1113,7 +1113,7 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
// work out where we start for our shape (set speed and pos) // work out where we start for our shape (set speed and pos)
switch(shape){ switch(shape){
case sSpherical: case sSpherical:
angle = (float)random.randRange(0,360); angle = (double)random.randRange(0,360);
// fall through // fall through
case sConical:{ case sConical:{
Vec2f horiz = Vec2f(1,0).rotate(ang); Vec2f horiz = Vec2f(1,0).rotate(ang);
@ -1125,13 +1125,13 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
} break; } break;
case sLinear:{ case sLinear:{
#ifdef USE_STREFLOP #ifdef USE_STREFLOP
float x= streflop::sinf(static_cast<streflop::Simple>(ang))*mod; double x= streflop::sinf(static_cast<streflop::Simple>(ang))*mod;
float y= streflop::cosf(static_cast<streflop::Simple>(ang))*mod; double y= streflop::cosf(static_cast<streflop::Simple>(ang))*mod;
#else #else
float x= sinf(ang) * mod; double x= sinf(ang) * mod;
float y= cosf(ang) * mod; double y= cosf(ang) * mod;
#endif #endif
const float rad= degToRad(rotation); const double rad= degToRad(rotation);
if(!relative){ 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= Vec3f(pos.x + x + offset.x, pos.y + random.randRange(-radius / 2, radius / 2) + offset.y, pos.z + y
+ offset.z); + offset.z);
@ -1182,10 +1182,10 @@ void UnitParticleSystem::update(){
} }
void UnitParticleSystem::updateParticle(Particle *p){ void UnitParticleSystem::updateParticle(Particle *p){
float energyRatio; double energyRatio;
if(alternations > 0){ if(alternations > 0){
int interval= (maxParticleEnergy / alternations); int interval= (maxParticleEnergy / alternations);
float moduloValue= (float)((int)(static_cast<float> (p->energy)) % interval); double moduloValue= (double)((int)(static_cast<double> (p->energy)) % interval);
if(moduloValue < interval / 2){ if(moduloValue < interval / 2){
energyRatio= (interval - moduloValue) / interval; energyRatio= (interval - moduloValue) / interval;
@ -1196,7 +1196,7 @@ void UnitParticleSystem::updateParticle(Particle *p){
energyRatio= clamp(energyRatio, 0.f, 1.f); energyRatio= clamp(energyRatio, 0.f, 1.f);
} }
else{ else{
energyRatio= clamp(static_cast<float> (p->energy) / maxParticleEnergy, 0.f, 1.f); energyRatio= clamp(static_cast<double> (p->energy) / maxParticleEnergy, 0.f, 1.f);
} }
p->lastPos+= p->speed; p->lastPos+= p->speed;
@ -1238,7 +1238,7 @@ void UnitParticleSystem::updateParticle(Particle *p){
// ================= SET PARAMS ==================== // ================= SET PARAMS ====================
void UnitParticleSystem::setWind(float windAngle, float windSpeed){ void UnitParticleSystem::setWind(double windAngle, double windSpeed){
#ifdef USE_STREFLOP #ifdef USE_STREFLOP
this->windSpeed.x= streflop::sinf(static_cast<streflop::Simple>(degToRad(windAngle)))*windSpeed; this->windSpeed.x= streflop::sinf(static_cast<streflop::Simple>(degToRad(windAngle)))*windSpeed;
this->windSpeed.y= 0.0f; this->windSpeed.y= 0.0f;
@ -1257,9 +1257,9 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) {
GameParticleSystem::saveGame(unitParticleSystemNode); GameParticleSystem::saveGame(unitParticleSystemNode);
// float radius; // float radius;
unitParticleSystemNode->addAttribute("radius",floatToStr(radius,16), mapTagReplacements); unitParticleSystemNode->addAttribute("radius",doubleToStr(radius,16), mapTagReplacements);
// float minRadius; // float minRadius;
unitParticleSystemNode->addAttribute("minRadius",floatToStr(minRadius,16), mapTagReplacements); unitParticleSystemNode->addAttribute("minRadius",doubleToStr(minRadius,16), mapTagReplacements);
// Vec3f windSpeed; // Vec3f windSpeed;
unitParticleSystemNode->addAttribute("windSpeed",windSpeed.getString(), mapTagReplacements); unitParticleSystemNode->addAttribute("windSpeed",windSpeed.getString(), mapTagReplacements);
// Vec3f cRotation; // Vec3f cRotation;
@ -1271,9 +1271,9 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) {
// bool energyUp; // bool energyUp;
unitParticleSystemNode->addAttribute("energyUp",intToStr(energyUp), mapTagReplacements); unitParticleSystemNode->addAttribute("energyUp",intToStr(energyUp), mapTagReplacements);
// float startTime; // float startTime;
unitParticleSystemNode->addAttribute("startTime",floatToStr(startTime,16), mapTagReplacements); unitParticleSystemNode->addAttribute("startTime",doubleToStr(startTime,16), mapTagReplacements);
// float endTime; // float endTime;
unitParticleSystemNode->addAttribute("endTime",floatToStr(endTime,16), mapTagReplacements); unitParticleSystemNode->addAttribute("endTime",doubleToStr(endTime,16), mapTagReplacements);
// bool relative; // bool relative;
unitParticleSystemNode->addAttribute("relative",intToStr(relative), mapTagReplacements); unitParticleSystemNode->addAttribute("relative",intToStr(relative), mapTagReplacements);
// bool relativeDirection; // bool relativeDirection;
@ -1283,13 +1283,13 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) {
// Shape shape; // Shape shape;
unitParticleSystemNode->addAttribute("shape",intToStr(shape), mapTagReplacements); unitParticleSystemNode->addAttribute("shape",intToStr(shape), mapTagReplacements);
// float angle; // float angle;
unitParticleSystemNode->addAttribute("angle",floatToStr(angle,16), mapTagReplacements); unitParticleSystemNode->addAttribute("angle",doubleToStr(angle,16), mapTagReplacements);
// float sizeNoEnergy; // float sizeNoEnergy;
unitParticleSystemNode->addAttribute("sizeNoEnergy",floatToStr(sizeNoEnergy,16), mapTagReplacements); unitParticleSystemNode->addAttribute("sizeNoEnergy",doubleToStr(sizeNoEnergy,16), mapTagReplacements);
// float gravity; // float gravity;
unitParticleSystemNode->addAttribute("gravity",floatToStr(gravity,16), mapTagReplacements); unitParticleSystemNode->addAttribute("gravity",doubleToStr(gravity,16), mapTagReplacements);
// float rotation; // float rotation;
unitParticleSystemNode->addAttribute("rotation",floatToStr(rotation,16), mapTagReplacements); unitParticleSystemNode->addAttribute("rotation",doubleToStr(rotation,16), mapTagReplacements);
// bool isVisibleAtNight; // bool isVisibleAtNight;
unitParticleSystemNode->addAttribute("isVisibleAtNight",intToStr(isVisibleAtNight), mapTagReplacements); unitParticleSystemNode->addAttribute("isVisibleAtNight",intToStr(isVisibleAtNight), mapTagReplacements);
// bool isVisibleAtDay; // bool isVisibleAtDay;
@ -1305,7 +1305,7 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) {
// int lifetime; // int lifetime;
unitParticleSystemNode->addAttribute("lifetime",intToStr(lifetime), mapTagReplacements); unitParticleSystemNode->addAttribute("lifetime",intToStr(lifetime), mapTagReplacements);
// float emissionRateFade; // float emissionRateFade;
unitParticleSystemNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade,16), mapTagReplacements); unitParticleSystemNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,16), mapTagReplacements);
// GameParticleSystem* parent; // GameParticleSystem* parent;
//if(parent != NULL) { //if(parent != NULL) {
// parent->saveGame(unitParticleSystemNode); // parent->saveGame(unitParticleSystemNode);
@ -1393,24 +1393,24 @@ string UnitParticleSystem::toString() const {
string result = ParticleSystem::toString(); string result = ParticleSystem::toString();
result += "\nUnitParticleSystem "; result += "\nUnitParticleSystem ";
result += "\nradius = " + floatToStr(radius); result += "\nradius = " + doubleToStr(radius);
result += "\nminRadius = " + floatToStr(minRadius); result += "\nminRadius = " + doubleToStr(minRadius);
result += "\nwindSpeed = " + windSpeed.getString(); result += "\nwindSpeed = " + windSpeed.getString();
result += "\ncRotation = " + cRotation.getString(); result += "\ncRotation = " + cRotation.getString();
result += "\nfixedAddition = " + fixedAddition.getString(); result += "\nfixedAddition = " + fixedAddition.getString();
result += "\noldPosition = " + oldPosition.getString(); result += "\noldPosition = " + oldPosition.getString();
result += "\nenergyUp = " + intToStr(energyUp); result += "\nenergyUp = " + intToStr(energyUp);
result += "\nstartTime = " + floatToStr(startTime); result += "\nstartTime = " + doubleToStr(startTime);
result += "\nendTime = " + floatToStr(endTime); result += "\nendTime = " + doubleToStr(endTime);
result += "\nrelative = " + intToStr(relative); result += "\nrelative = " + intToStr(relative);
result += "\nrelativeDirection = " + intToStr(relativeDirection); result += "\nrelativeDirection = " + intToStr(relativeDirection);
result += "\nfixed = " + intToStr(fixed); result += "\nfixed = " + intToStr(fixed);
result += "\nshape = " + intToStr(shape); result += "\nshape = " + intToStr(shape);
result += "\nangle = " + floatToStr(angle); result += "\nangle = " + doubleToStr(angle);
result += "\nsizeNoEnergy = " + floatToStr(sizeNoEnergy); result += "\nsizeNoEnergy = " + doubleToStr(sizeNoEnergy);
result += "\ngravity = " + floatToStr(gravity); result += "\ngravity = " + doubleToStr(gravity);
result += "\nrotation = " + floatToStr(rotation); result += "\nrotation = " + doubleToStr(rotation);
result += "\nisVisibleAtNight = " + intToStr(isVisibleAtNight); result += "\nisVisibleAtNight = " + intToStr(isVisibleAtNight);
result += "\nisVisibleAtDay = " + intToStr(isVisibleAtDay); result += "\nisVisibleAtDay = " + intToStr(isVisibleAtDay);
result += "\nisDaylightAffected = " + intToStr(isDaylightAffected); result += "\nisDaylightAffected = " + intToStr(isDaylightAffected);
@ -1418,7 +1418,7 @@ string UnitParticleSystem::toString() const {
result += "\nstaticParticleCount = " + intToStr(staticParticleCount); result += "\nstaticParticleCount = " + intToStr(staticParticleCount);
result += "\ndelay = " + intToStr(delay); result += "\ndelay = " + intToStr(delay);
result += "\nlifetime = " + intToStr(lifetime); result += "\nlifetime = " + intToStr(lifetime);
result += "\nemissionRateFade = " + floatToStr(emissionRateFade); result += "\nemissionRateFade = " + doubleToStr(emissionRateFade);
//GameParticleSystem* parent; //GameParticleSystem* parent;
return result; return result;
@ -1445,8 +1445,8 @@ void RainParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr){
void RainParticleSystem::initParticle(Particle *p, int particleIndex){ void RainParticleSystem::initParticle(Particle *p, int particleIndex){
ParticleSystem::initParticle(p, particleIndex); ParticleSystem::initParticle(p, particleIndex);
float x= random.randRange(-radius, radius); double x= random.randRange(-radius, radius);
float y= random.randRange(-radius, radius); double y= random.randRange(-radius, radius);
p->color= color; p->color= color;
p->energy= 10000; p->energy= 10000;
@ -1460,12 +1460,12 @@ bool RainParticleSystem::deathTest(Particle *p){
return p->pos.y < 0; return p->pos.y < 0;
} }
void RainParticleSystem::setRadius(float radius){ void RainParticleSystem::setRadius(double radius) {
this->radius= radius; this->radius= radius;
} }
void RainParticleSystem::setWind(float windAngle, float windSpeed){ void RainParticleSystem::setWind(double windAngle, double windSpeed){
#ifdef USE_STREFLOP #ifdef USE_STREFLOP
this->windSpeed.x= streflop::sinf(static_cast<streflop::Simple>(degToRad(windAngle)))*windSpeed; this->windSpeed.x= streflop::sinf(static_cast<streflop::Simple>(degToRad(windAngle)))*windSpeed;
this->windSpeed.y= 0.0f; this->windSpeed.y= 0.0f;
@ -1488,7 +1488,7 @@ string RainParticleSystem::toString() const {
result += "\nRainParticleSystem "; result += "\nRainParticleSystem ";
result += "\nwindSpeed = " + windSpeed.getString(); result += "\nwindSpeed = " + windSpeed.getString();
result += "\nradius = " + floatToStr(radius); result += "\nradius = " + doubleToStr(radius);
return result; return result;
} }
@ -1512,8 +1512,8 @@ void SnowParticleSystem::initParticle(Particle *p, int particleIndex){
ParticleSystem::initParticle(p, particleIndex); ParticleSystem::initParticle(p, particleIndex);
float x= random.randRange(-radius, radius); double x= random.randRange(-radius, radius);
float y= random.randRange(-radius, radius); double y= random.randRange(-radius, radius);
p->color= color; p->color= color;
p->energy= 10000; p->energy= 10000;
@ -1528,11 +1528,11 @@ bool SnowParticleSystem::deathTest(Particle *p){
return p->pos.y < 0; return p->pos.y < 0;
} }
void SnowParticleSystem::setRadius(float radius){ void SnowParticleSystem::setRadius(double radius){
this->radius= radius; this->radius= radius;
} }
void SnowParticleSystem::setWind(float windAngle, float windSpeed){ void SnowParticleSystem::setWind(double windAngle, double windSpeed){
#ifdef USE_STREFLOP #ifdef USE_STREFLOP
this->windSpeed.x= streflop::sinf(static_cast<streflop::Simple>(degToRad(windAngle)))*windSpeed; this->windSpeed.x= streflop::sinf(static_cast<streflop::Simple>(degToRad(windAngle)))*windSpeed;
this->windSpeed.y= 0.0f; this->windSpeed.y= 0.0f;
@ -1555,7 +1555,7 @@ string SnowParticleSystem::toString() const {
result += "\nSnowParticleSystem "; result += "\nSnowParticleSystem ";
result += "\nwindSpeed = " + windSpeed.getString(); result += "\nwindSpeed = " + windSpeed.getString();
result += "\nradius = " + floatToStr(radius); result += "\nradius = " + doubleToStr(radius);
return result; return result;
} }
@ -1578,9 +1578,9 @@ void AttackParticleSystem::saveGame(XmlNode *rootNode) {
GameParticleSystem::saveGame(attackParticleSystemNode); GameParticleSystem::saveGame(attackParticleSystemNode);
// float sizeNoEnergy; // float sizeNoEnergy;
attackParticleSystemNode->addAttribute("sizeNoEnergy",floatToStr(sizeNoEnergy,16), mapTagReplacements); attackParticleSystemNode->addAttribute("sizeNoEnergy",doubleToStr(sizeNoEnergy,16), mapTagReplacements);
// float gravity; // float gravity;
attackParticleSystemNode->addAttribute("gravity",floatToStr(gravity,16), mapTagReplacements); attackParticleSystemNode->addAttribute("gravity",doubleToStr(gravity,16), mapTagReplacements);
} }
void AttackParticleSystem::loadGame(const XmlNode *rootNode) { void AttackParticleSystem::loadGame(const XmlNode *rootNode) {
@ -1604,8 +1604,8 @@ string AttackParticleSystem::toString() const {
string result = ParticleSystem::toString(); string result = ParticleSystem::toString();
result += "\nAttackParticleSystem "; result += "\nAttackParticleSystem ";
result += "\nsizeNoEnergy = " + floatToStr(sizeNoEnergy); result += "\nsizeNoEnergy = " + doubleToStr(sizeNoEnergy);
result += "\ngravity = " + floatToStr(gravity); result += "\ngravity = " + doubleToStr(gravity);
return result; return result;
} }
@ -1681,7 +1681,7 @@ void ProjectileParticleSystem::update(){
//#endif //#endif
//printf("#a currentVector.length() = %f, targetVector.length() = %f, relative = %f, absolute = %f, trajectorySpeed = %f\n",currentVector.length(),targetVector.length(),relative,absolute,trajectorySpeed); //printf("#a currentVector.length() = %f, targetVector.length() = %f, relative = %f, absolute = %f, trajectorySpeed = %f\n",currentVector.length(),targetVector.length(),relative,absolute,trajectorySpeed);
float absolute = relative; double absolute = relative;
setTween(relative,absolute); setTween(relative,absolute);
@ -1870,12 +1870,12 @@ void ProjectileParticleSystem::saveGame(XmlNode *rootNode) {
// Trajectory trajectory; // Trajectory trajectory;
projectileParticleSystemNode->addAttribute("trajectory",intToStr(trajectory), mapTagReplacements); projectileParticleSystemNode->addAttribute("trajectory",intToStr(trajectory), mapTagReplacements);
// float trajectorySpeed; // float trajectorySpeed;
projectileParticleSystemNode->addAttribute("trajectorySpeed",floatToStr(trajectorySpeed,16), mapTagReplacements); projectileParticleSystemNode->addAttribute("trajectorySpeed",doubleToStr(trajectorySpeed,16), mapTagReplacements);
// //parabolic // //parabolic
// float trajectoryScale; // float trajectoryScale;
projectileParticleSystemNode->addAttribute("trajectoryScale",floatToStr(trajectoryScale,16), mapTagReplacements); projectileParticleSystemNode->addAttribute("trajectoryScale",doubleToStr(trajectoryScale,16), mapTagReplacements);
// float trajectoryFrequency; // float trajectoryFrequency;
projectileParticleSystemNode->addAttribute("trajectoryFrequency",floatToStr(trajectoryFrequency,16), mapTagReplacements); projectileParticleSystemNode->addAttribute("trajectoryFrequency",doubleToStr(trajectoryFrequency,16), mapTagReplacements);
} }
void ProjectileParticleSystem::loadGame(const XmlNode *rootNode) { void ProjectileParticleSystem::loadGame(const XmlNode *rootNode) {
@ -2018,7 +2018,7 @@ void SplashParticleSystem::initParticle(Particle *p, int particleIndex){
} }
void SplashParticleSystem::updateParticle(Particle *p){ void SplashParticleSystem::updateParticle(Particle *p){
float energyRatio= clamp(static_cast<float> (p->energy) / maxParticleEnergy, 0.f, 1.f); double energyRatio= clamp(static_cast<double> (p->energy) / maxParticleEnergy, 0.f, 1.f);
p->lastPos= p->pos; p->lastPos= p->pos;
p->pos= p->pos + p->speed; p->pos= p->pos + p->speed;

View File

@ -101,7 +101,7 @@ int RandomGen::randRange(int min, int max,string lastCaller) {
return res; return res;
} }
float RandomGen::randRange(float min, float max,string lastCaller) { double RandomGen::randRange(double min, double max,string lastCaller) {
//assert(min<=max); //assert(min<=max);
if(min > max) { if(min > max) {
char szBuf[8096]=""; char szBuf[8096]="";
@ -112,9 +112,9 @@ float RandomGen::randRange(float min, float max,string lastCaller) {
//#ifdef USE_STREFLOP //#ifdef USE_STREFLOP
// float res = streflop::Random<true, false, float>(min, max, randomState); // streflop // float res = streflop::Random<true, false, float>(min, max, randomState); // streflop
//#else //#else
float rand01= static_cast<float>(RandomGen::rand(lastCaller))/(m-1); double rand01= static_cast<double>(RandomGen::rand(lastCaller))/(m-1);
float res= min+(max-min)*rand01; double res= min+(max-min)*rand01;
res = truncateDecimal<float>(res); res = truncateDecimal<double>(res);
//#endif //#endif
//assert(res>=min && res<=max); //assert(res>=min && res<=max);