- attempt to fix additional oos issues
This commit is contained in:
parent
dc944b2a79
commit
de8b083329
|
@ -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,16), mapTagReplacements);
|
||||
nodePoolNode->addAttribute("heuristic",doubleToStr(curNode->heuristic,10), mapTagReplacements);
|
||||
nodePoolNode->addAttribute("exploredCell",intToStr(curNode->exploredCell), mapTagReplacements);
|
||||
}
|
||||
|
||||
|
|
|
@ -6242,7 +6242,7 @@ string Game::saveGame(string name, string path) {
|
|||
//bool showFullConsole;
|
||||
//bool mouseMoved;
|
||||
//float scrollSpeed;
|
||||
gameNode->addAttribute("scrollSpeed",floatToStr(scrollSpeed,16), mapTagReplacements);
|
||||
gameNode->addAttribute("scrollSpeed",floatToStr(scrollSpeed,10), 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,16), mapTagReplacements);
|
||||
infoNode->addAttribute("thickness",floatToStr(info.thickness,16), mapTagReplacements);
|
||||
infoNode->addAttribute("radius",floatToStr(info.radius,10), mapTagReplacements);
|
||||
infoNode->addAttribute("thickness",floatToStr(info.thickness,10), mapTagReplacements);
|
||||
infoNode->addAttribute("color",info.color.getString(), mapTagReplacements);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("hAng",floatToStr(hAng,10), mapTagReplacements);
|
||||
// float vAng; //XZ plane positive +Z axis
|
||||
gamecameraNode->addAttribute("vAng",floatToStr(vAng,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("vAng",floatToStr(vAng,10), mapTagReplacements);
|
||||
// float lastHAng;
|
||||
gamecameraNode->addAttribute("lastHAng",floatToStr(lastHAng,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("lastHAng",floatToStr(lastHAng,10), mapTagReplacements);
|
||||
|
||||
// float lastVAng;
|
||||
gamecameraNode->addAttribute("lastVAng",floatToStr(lastVAng,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("lastVAng",floatToStr(lastVAng,10), mapTagReplacements);
|
||||
// Vec2f destAng;
|
||||
gamecameraNode->addAttribute("destAng",destAng.getString(), mapTagReplacements);
|
||||
// float rotate;
|
||||
gamecameraNode->addAttribute("rotate",floatToStr(rotate,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("rotate",floatToStr(rotate,10), 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,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("speed",floatToStr(speed,10), mapTagReplacements);
|
||||
// bool clampBounds;
|
||||
gamecameraNode->addAttribute("clampBounds",intToStr(clampBounds), mapTagReplacements);
|
||||
// //float maxRenderDistance;
|
||||
// float maxHeight;
|
||||
gamecameraNode->addAttribute("maxHeight",floatToStr(maxHeight,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("maxHeight",floatToStr(maxHeight,10), mapTagReplacements);
|
||||
// float minHeight;
|
||||
gamecameraNode->addAttribute("minHeight",floatToStr(minHeight,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("minHeight",floatToStr(minHeight,10), mapTagReplacements);
|
||||
// //float maxCameraDist;
|
||||
// //float minCameraDist;
|
||||
// float minVAng;
|
||||
gamecameraNode->addAttribute("minVAng",floatToStr(minVAng,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("minVAng",floatToStr(minVAng,10), mapTagReplacements);
|
||||
// float maxVAng;
|
||||
gamecameraNode->addAttribute("maxVAng",floatToStr(maxVAng,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("maxVAng",floatToStr(maxVAng,10), mapTagReplacements);
|
||||
// float fov;
|
||||
gamecameraNode->addAttribute("fov",floatToStr(fov,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("fov",floatToStr(fov,10), mapTagReplacements);
|
||||
// float calculatedDefault;
|
||||
gamecameraNode->addAttribute("calculatedDefault",floatToStr(calculatedDefault,16), mapTagReplacements);
|
||||
gamecameraNode->addAttribute("calculatedDefault",floatToStr(calculatedDefault,10), mapTagReplacements);
|
||||
// std::map<float, std::map<float, std::map<Vec3f, Quad2i> > > cacheVisibleQuad;
|
||||
// int MaxVisibleQuadItemCache;
|
||||
gamecameraNode->addAttribute("MaxVisibleQuadItemCache",intToStr(MaxVisibleQuadItemCache), mapTagReplacements);
|
||||
|
|
|
@ -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,16), mapTagReplacements);
|
||||
statsNodePlayer->addAttribute("resourceMultiplier",floatToStr(stat.resourceMultiplier,10), 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,16), mapTagReplacements);
|
||||
statsNode->addAttribute("worldTimeElapsed",floatToStr(worldTimeElapsed,10), mapTagReplacements);
|
||||
// int framesPlayed;
|
||||
statsNode->addAttribute("framesPlayed",intToStr(framesPlayed), mapTagReplacements);
|
||||
// int framesToCalculatePlaytime;
|
||||
|
|
|
@ -327,7 +327,7 @@ void ParticleSystemType::saveGame(XmlNode *rootNode) {
|
|||
// Texture2D *texture;
|
||||
// Model *model;
|
||||
// float modelCycle;
|
||||
particleSystemTypeNode->addAttribute("modelCycle",doubleToStr(modelCycle,16), mapTagReplacements);
|
||||
particleSystemTypeNode->addAttribute("modelCycle",doubleToStr(modelCycle,10), 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,16), mapTagReplacements);
|
||||
particleSystemTypeNode->addAttribute("size",doubleToStr(size,10), mapTagReplacements);
|
||||
// float sizeNoEnergy;
|
||||
particleSystemTypeNode->addAttribute("sizeNoEnergy",doubleToStr(sizeNoEnergy,16), mapTagReplacements);
|
||||
particleSystemTypeNode->addAttribute("sizeNoEnergy",doubleToStr(sizeNoEnergy,10), mapTagReplacements);
|
||||
// float speed;
|
||||
particleSystemTypeNode->addAttribute("speed",doubleToStr(speed,16), mapTagReplacements);
|
||||
particleSystemTypeNode->addAttribute("speed",doubleToStr(speed,10), mapTagReplacements);
|
||||
// float gravity;
|
||||
particleSystemTypeNode->addAttribute("gravity",doubleToStr(gravity,16), mapTagReplacements);
|
||||
particleSystemTypeNode->addAttribute("gravity",doubleToStr(gravity,10), mapTagReplacements);
|
||||
// float emissionRate;
|
||||
particleSystemTypeNode->addAttribute("emissionRate",doubleToStr(emissionRate,16), mapTagReplacements);
|
||||
particleSystemTypeNode->addAttribute("emissionRate",doubleToStr(emissionRate,10), mapTagReplacements);
|
||||
// int energyMax;
|
||||
particleSystemTypeNode->addAttribute("energyMax",intToStr(energyMax), mapTagReplacements);
|
||||
// int energyVar;
|
||||
|
@ -466,11 +466,11 @@ void ParticleSystemTypeProjectile::saveGame(XmlNode *rootNode) {
|
|||
// string trajectory;
|
||||
particleSystemTypeProjectileNode->addAttribute("trajectory",trajectory, mapTagReplacements);
|
||||
// float trajectorySpeed;
|
||||
particleSystemTypeProjectileNode->addAttribute("trajectorySpeed",doubleToStr(trajectorySpeed,16), mapTagReplacements);
|
||||
particleSystemTypeProjectileNode->addAttribute("trajectorySpeed",doubleToStr(trajectorySpeed,10), mapTagReplacements);
|
||||
// float trajectoryScale;
|
||||
particleSystemTypeProjectileNode->addAttribute("trajectoryScale",doubleToStr(trajectoryScale,16), mapTagReplacements);
|
||||
particleSystemTypeProjectileNode->addAttribute("trajectoryScale",doubleToStr(trajectoryScale,10), mapTagReplacements);
|
||||
// float trajectoryFrequency;
|
||||
particleSystemTypeProjectileNode->addAttribute("trajectoryFrequency",doubleToStr(trajectoryFrequency,16), mapTagReplacements);
|
||||
particleSystemTypeProjectileNode->addAttribute("trajectoryFrequency",doubleToStr(trajectoryFrequency,10), mapTagReplacements);
|
||||
}
|
||||
|
||||
// ===========================================================
|
||||
|
@ -549,15 +549,15 @@ void ParticleSystemTypeSplash::saveGame(XmlNode *rootNode) {
|
|||
XmlNode *particleSystemTypeSplashNode = rootNode->addChild("ParticleSystemTypeSplash");
|
||||
|
||||
// float emissionRateFade;
|
||||
particleSystemTypeSplashNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,16), mapTagReplacements);
|
||||
particleSystemTypeSplashNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,10), mapTagReplacements);
|
||||
// float verticalSpreadA;
|
||||
particleSystemTypeSplashNode->addAttribute("verticalSpreadA",doubleToStr(verticalSpreadA,16), mapTagReplacements);
|
||||
particleSystemTypeSplashNode->addAttribute("verticalSpreadA",doubleToStr(verticalSpreadA,10), mapTagReplacements);
|
||||
// float verticalSpreadB;
|
||||
particleSystemTypeSplashNode->addAttribute("verticalSpreadB",doubleToStr(verticalSpreadB,16), mapTagReplacements);
|
||||
particleSystemTypeSplashNode->addAttribute("verticalSpreadB",doubleToStr(verticalSpreadB,10), mapTagReplacements);
|
||||
// float horizontalSpreadA;
|
||||
particleSystemTypeSplashNode->addAttribute("horizontalSpreadA",doubleToStr(horizontalSpreadA,16), mapTagReplacements);
|
||||
particleSystemTypeSplashNode->addAttribute("horizontalSpreadA",doubleToStr(horizontalSpreadA,10), mapTagReplacements);
|
||||
// float horizontalSpreadB;
|
||||
particleSystemTypeSplashNode->addAttribute("horizontalSpreadB",doubleToStr(horizontalSpreadB,16), mapTagReplacements);
|
||||
particleSystemTypeSplashNode->addAttribute("horizontalSpreadB",doubleToStr(horizontalSpreadB,10), mapTagReplacements);
|
||||
}
|
||||
|
||||
}}//end mamespace
|
||||
|
|
|
@ -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,16), mapTagReplacements);
|
||||
unitParticleSystemTypeNode->addAttribute("angle",doubleToStr(angle,10), mapTagReplacements);
|
||||
// float radius;
|
||||
unitParticleSystemTypeNode->addAttribute("radius",doubleToStr(radius,16), mapTagReplacements);
|
||||
unitParticleSystemTypeNode->addAttribute("radius",doubleToStr(radius,10), mapTagReplacements);
|
||||
// float minRadius;
|
||||
unitParticleSystemTypeNode->addAttribute("minRadius",doubleToStr(minRadius,16), mapTagReplacements);
|
||||
unitParticleSystemTypeNode->addAttribute("minRadius",doubleToStr(minRadius,10), mapTagReplacements);
|
||||
// float emissionRateFade;
|
||||
unitParticleSystemTypeNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,16), mapTagReplacements);
|
||||
unitParticleSystemTypeNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,10), 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,16), mapTagReplacements);
|
||||
unitParticleSystemTypeNode->addAttribute("startTime",doubleToStr(startTime,10), mapTagReplacements);
|
||||
// float endTime;
|
||||
unitParticleSystemTypeNode->addAttribute("endTime",doubleToStr(endTime,16), mapTagReplacements);
|
||||
unitParticleSystemTypeNode->addAttribute("endTime",doubleToStr(endTime,10), mapTagReplacements);
|
||||
}
|
||||
|
||||
}}//end mamespace
|
||||
|
|
|
@ -256,7 +256,7 @@ void Object::saveGame(XmlNode *rootNode) {
|
|||
// Vec3f pos;
|
||||
objectNode->addAttribute("pos",pos.getString(), mapTagReplacements);
|
||||
// float rotation;
|
||||
objectNode->addAttribute("rotation",doubleToStr(rotation,16), mapTagReplacements);
|
||||
objectNode->addAttribute("rotation",doubleToStr(rotation,10), mapTagReplacements);
|
||||
// int variation;
|
||||
objectNode->addAttribute("variation",intToStr(variation), mapTagReplacements);
|
||||
// int lastRenderFrame;
|
||||
|
|
|
@ -1273,7 +1273,7 @@ void Unit::setTargetPos(const Vec2i &targetPos) {
|
|||
#else
|
||||
targetRotation= radToDeg(atan2(relPosf.x, relPosf.y));
|
||||
#endif
|
||||
targetRotation = truncateDecimal<double>(targetRotation,16);
|
||||
targetRotation = truncateDecimal<double>(targetRotation,10);
|
||||
|
||||
targetRef= NULL;
|
||||
|
||||
|
@ -1417,9 +1417,9 @@ Vec3d Unit::getCurrVector() const{
|
|||
}
|
||||
|
||||
Vec3d result = getCurrVectorFlat() + Vec3d(0.f, type->getHeight() /2.f, 0.f);
|
||||
result.x = truncateDecimal<double>(result.x,16);
|
||||
result.y = truncateDecimal<double>(result.y,16);
|
||||
result.z = truncateDecimal<double>(result.z,16);
|
||||
result.x = truncateDecimal<double>(result.x,10);
|
||||
result.y = truncateDecimal<double>(result.y,10);
|
||||
result.z = truncateDecimal<double>(result.z,10);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1430,7 +1430,7 @@ Vec3d Unit::getCurrVectorFlat() const{
|
|||
|
||||
double Unit::getProgressAsFloat() const {
|
||||
double result = (static_cast<double>(progress) / static_cast<double>(PROGRESS_SPEED_MULTIPLIER));
|
||||
result = truncateDecimal<double>(result,16);
|
||||
result = truncateDecimal<double>(result,10);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1452,16 +1452,16 @@ Vec3d Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) c
|
|||
v.z= static_cast<double>(curPosValue.y);
|
||||
v.y= y2;
|
||||
}
|
||||
v.x = truncateDecimal<double>(v.x,16);
|
||||
v.y = truncateDecimal<double>(v.y,16);
|
||||
v.z = truncateDecimal<double>(v.z,16);
|
||||
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,16);
|
||||
v.y = truncateDecimal<double>(v.y,16);
|
||||
v.z = truncateDecimal<double>(v.z,16);
|
||||
v.x = truncateDecimal<double>(v.x,10);
|
||||
v.y = truncateDecimal<double>(v.y,10);
|
||||
v.z = truncateDecimal<double>(v.z,10);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
@ -2508,7 +2508,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(),16) <= truncateDecimal<double>(getAnimProgressAsFloat(),16)) {
|
||||
if(truncateDecimal<double>(pst->getStartTime(),10) <= truncateDecimal<double>(getAnimProgressAsFloat(),10)) {
|
||||
|
||||
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
||||
ups->setParticleOwner(this);
|
||||
|
@ -2537,11 +2537,11 @@ void Unit::updateTimedParticles() {
|
|||
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||
double pst = ps->getStartTime();
|
||||
double pet = ps->getEndTime();
|
||||
double particleStartTime = truncateDecimal<double>(pst,16);
|
||||
double particleEndTime = truncateDecimal<double>(pet,16);
|
||||
double particleStartTime = truncateDecimal<double>(pst,10);
|
||||
double particleEndTime = truncateDecimal<double>(pet,10);
|
||||
|
||||
if(particleStartTime != 0.0 || particleEndTime != 1.0) {
|
||||
double animProgressTime = truncateDecimal<double>(getAnimProgressAsFloat(),16);
|
||||
double animProgressTime = truncateDecimal<double>(getAnimProgressAsFloat(),10);
|
||||
if(animProgressTime >= 0.99 || animProgressTime >= particleEndTime) {
|
||||
|
||||
ps->fade();
|
||||
|
@ -3353,25 +3353,25 @@ double Unit::computeHeight(const Vec2i &pos) const {
|
|||
}
|
||||
|
||||
double height= map->getCell(pos)->getHeight();
|
||||
height = truncateDecimal<double>(height,16);
|
||||
height = truncateDecimal<double>(height,10);
|
||||
|
||||
if(currField == fAir) {
|
||||
const double airHeight=game->getWorld()->getTileset()->getAirHeight();
|
||||
|
||||
height += airHeight;
|
||||
height = truncateDecimal<double>(height,16);
|
||||
height = truncateDecimal<double>(height,10);
|
||||
|
||||
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,16);
|
||||
height = truncateDecimal<double>(height,10);
|
||||
}
|
||||
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,16);
|
||||
height = truncateDecimal<double>(height,10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3393,7 +3393,7 @@ void Unit::updateTarget(){
|
|||
#else
|
||||
targetRotation= radToDeg(atan2(relPosf.x, relPosf.y));
|
||||
#endif
|
||||
targetRotation = truncateDecimal<double>(targetRotation,16);
|
||||
targetRotation = truncateDecimal<double>(targetRotation,10);
|
||||
//update target vec
|
||||
targetVec= target->getCurrVector();
|
||||
|
||||
|
@ -4173,7 +4173,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,16);
|
||||
result += " highlight = " + doubleToStr(this->highlight,10);
|
||||
}
|
||||
result += " progress2 = " + intToStr(this->progress2);
|
||||
result += " kills = " + intToStr(this->kills);
|
||||
|
@ -4202,9 +4202,9 @@ std::string Unit::toString(bool crcMode) const {
|
|||
result += "\n";
|
||||
|
||||
if(crcMode == false) {
|
||||
result += " lastRotation = " + doubleToStr(this->lastRotation,16);
|
||||
result += " targetRotation = " + doubleToStr(this->targetRotation,16);
|
||||
result += " rotation = " + doubleToStr(this->rotation,16);
|
||||
result += " lastRotation = " + doubleToStr(this->lastRotation,10);
|
||||
result += " targetRotation = " + doubleToStr(this->targetRotation,10);
|
||||
result += " rotation = " + doubleToStr(this->rotation,10);
|
||||
}
|
||||
|
||||
if(loadType != NULL) {
|
||||
|
@ -4312,7 +4312,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,16), mapTagReplacements);
|
||||
unitNode->addAttribute("highlight",doubleToStr(highlight,10), mapTagReplacements);
|
||||
// int progress2;
|
||||
unitNode->addAttribute("progress2",intToStr(progress2), mapTagReplacements);
|
||||
// int kills;
|
||||
|
@ -4342,19 +4342,19 @@ void Unit::saveGame(XmlNode *rootNode) {
|
|||
unitNode->addAttribute("meetingPos",meetingPos.getString(), mapTagReplacements);
|
||||
//
|
||||
// float lastRotation; //in degrees
|
||||
unitNode->addAttribute("lastRotation",doubleToStr(lastRotation,16), mapTagReplacements);
|
||||
unitNode->addAttribute("lastRotation",doubleToStr(lastRotation,10), mapTagReplacements);
|
||||
// float targetRotation;
|
||||
unitNode->addAttribute("targetRotation",doubleToStr(targetRotation,16), mapTagReplacements);
|
||||
unitNode->addAttribute("targetRotation",doubleToStr(targetRotation,10), mapTagReplacements);
|
||||
// float rotation;
|
||||
unitNode->addAttribute("rotation",doubleToStr(rotation,16), mapTagReplacements);
|
||||
unitNode->addAttribute("rotation",doubleToStr(rotation,10), mapTagReplacements);
|
||||
// float targetRotationZ;
|
||||
unitNode->addAttribute("targetRotationZ",doubleToStr(targetRotationZ,16), mapTagReplacements);
|
||||
unitNode->addAttribute("targetRotationZ",doubleToStr(targetRotationZ,10), mapTagReplacements);
|
||||
// float targetRotationX;
|
||||
unitNode->addAttribute("targetRotationX",doubleToStr(targetRotationX,16), mapTagReplacements);
|
||||
unitNode->addAttribute("targetRotationX",doubleToStr(targetRotationX,10), mapTagReplacements);
|
||||
// float rotationZ;
|
||||
unitNode->addAttribute("rotationZ",doubleToStr(rotationZ,16), mapTagReplacements);
|
||||
unitNode->addAttribute("rotationZ",doubleToStr(rotationZ,10), mapTagReplacements);
|
||||
// float rotationX;
|
||||
unitNode->addAttribute("rotationX",doubleToStr(rotationX,16), mapTagReplacements);
|
||||
unitNode->addAttribute("rotationX",doubleToStr(rotationX,10), mapTagReplacements);
|
||||
// const UnitType *type;
|
||||
unitNode->addAttribute("type",type->getName(false), mapTagReplacements);
|
||||
|
||||
|
|
|
@ -665,7 +665,7 @@ void SkillType::saveGame(XmlNode *rootNode) {
|
|||
//
|
||||
// SoundContainer sounds;
|
||||
// float soundStartTime;
|
||||
skillTypeNode->addAttribute("soundStartTime",doubleToStr(soundStartTime,16), mapTagReplacements);
|
||||
skillTypeNode->addAttribute("soundStartTime",doubleToStr(soundStartTime,10), 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,16), mapTagReplacements);
|
||||
attackSkillTypeNode->addAttribute("attackStartTime",doubleToStr(attackStartTime,10), 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,16), mapTagReplacements);
|
||||
fogSkillTypeNode->addAttribute("duration",doubleToStr(durationTime,10), mapTagReplacements);
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
|
|
|
@ -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,16);
|
||||
result += " rotatedBuildPos = " + doubleToStr(rotatedBuildPos,10);
|
||||
result += " rotationAllowed = " + intToStr(rotationAllowed);
|
||||
|
||||
if(cellMap != NULL) {
|
||||
|
|
|
@ -93,7 +93,7 @@ void Cell::saveGame(XmlNode *rootNode, int index) const {
|
|||
}
|
||||
|
||||
// float height;
|
||||
cellNode->addAttribute("height",doubleToStr(getHeight(),16), mapTagReplacements);
|
||||
cellNode->addAttribute("height",doubleToStr(getHeight(),10), 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,16);
|
||||
heightFactor = truncateDecimal<double>(heightFactor,10);
|
||||
}
|
||||
waterLevel= static_cast<double>((header.waterLevel-0.01f)/heightFactor);
|
||||
waterLevel = truncateDecimal<double>(waterLevel,16);
|
||||
waterLevel = truncateDecimal<double>(waterLevel,10);
|
||||
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),16);
|
||||
cliffLevel = truncateDecimal<double>(cliffLevel,16);
|
||||
cliffLevel=static_cast<double>((header.version2.cliffLevel-0.01f)/(heightFactor),10);
|
||||
cliffLevel = truncateDecimal<double>(cliffLevel,10);
|
||||
}
|
||||
if(header.version2.cameraHeight > 0 && header.version2.cameraHeight < 5000) {
|
||||
cameraHeight = header.version2.cameraHeight;
|
||||
|
@ -1733,11 +1733,11 @@ void Map::saveGame(XmlNode *rootNode) const {
|
|||
// string title;
|
||||
mapNode->addAttribute("title",title, mapTagReplacements);
|
||||
// float waterLevel;
|
||||
mapNode->addAttribute("waterLevel",doubleToStr(waterLevel,16), mapTagReplacements);
|
||||
mapNode->addAttribute("waterLevel",doubleToStr(waterLevel,10), mapTagReplacements);
|
||||
// float heightFactor;
|
||||
mapNode->addAttribute("heightFactor",doubleToStr(heightFactor,16), mapTagReplacements);
|
||||
mapNode->addAttribute("heightFactor",doubleToStr(heightFactor,10), mapTagReplacements);
|
||||
// float cliffLevel;
|
||||
mapNode->addAttribute("cliffLevel",doubleToStr(cliffLevel,16), mapTagReplacements);
|
||||
mapNode->addAttribute("cliffLevel",doubleToStr(cliffLevel,10), 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,16), mapTagReplacements);
|
||||
mapNode->addAttribute("maxMapHeight",doubleToStr(maxMapHeight,10), mapTagReplacements);
|
||||
// string mapFile;
|
||||
mapNode->addAttribute("mapFile",mapFile, mapTagReplacements);
|
||||
}
|
||||
|
|
|
@ -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,16);}
|
||||
inline double getHeight() const {return truncateDecimal<double>(height,10);}
|
||||
|
||||
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,16);}
|
||||
inline void setHeight(double height) {this->height = truncateDecimal<double>(height,10);}
|
||||
|
||||
inline bool isFree(Field field) const {
|
||||
Unit *unit = getUnit(field);
|
||||
|
@ -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,16);}
|
||||
inline double getWaterLevel() const {return truncateDecimal<double>(waterLevel,16);}
|
||||
inline double getCliffLevel() const {return truncateDecimal<double>(cliffLevel,16);}
|
||||
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 int getCameraHeight() const {return cameraHeight;}
|
||||
inline double getMaxMapHeight() const {return truncateDecimal<double>(maxMapHeight,16);}
|
||||
inline double getMaxMapHeight() const {return truncateDecimal<double>(maxMapHeight,10);}
|
||||
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;}
|
||||
|
|
|
@ -160,12 +160,12 @@ void TimeFlow::saveGame(XmlNode *rootNode) {
|
|||
// bool firstTime;
|
||||
// Tileset *tileset;
|
||||
// float time;
|
||||
timeflowNode->addAttribute("time",floatToStr(time,16), mapTagReplacements);
|
||||
timeflowNode->addAttribute("time",floatToStr(time,10), mapTagReplacements);
|
||||
// float lastTime;
|
||||
timeflowNode->addAttribute("lastTime",floatToStr(lastTime,16), mapTagReplacements);
|
||||
timeflowNode->addAttribute("lastTime",floatToStr(lastTime,10), mapTagReplacements);
|
||||
// float timeInc;
|
||||
//printf("#2 timeInc = %f\n",timeInc);
|
||||
timeflowNode->addAttribute("timeInc",floatToStr(timeInc,16), mapTagReplacements);
|
||||
timeflowNode->addAttribute("timeInc",floatToStr(timeInc,10), mapTagReplacements);
|
||||
//printf("#3 timeInc = %f\n",timeInc);
|
||||
}
|
||||
|
||||
|
|
|
@ -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(),16);
|
||||
double lastAnimProgress = truncateDecimal<double>(unit->getLastAnimProgressAsFloat(),16);
|
||||
double animProgress = truncateDecimal<double>(unit->getAnimProgressAsFloat(),16);
|
||||
double attackStartTime = truncateDecimal<double>(ast->getAttackStartTime(),10);
|
||||
double lastAnimProgress = truncateDecimal<double>(unit->getLastAnimProgressAsFloat(),10);
|
||||
double animProgress = truncateDecimal<double>(unit->getAnimProgressAsFloat(),10);
|
||||
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,16);
|
||||
distance = truncateDecimal<double>(distance,10);
|
||||
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,16);
|
||||
damageMultiplier = truncateDecimal<double>(damageMultiplier,10);
|
||||
|
||||
//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,16);
|
||||
damage = truncateDecimal<double>(damage,10);
|
||||
|
||||
if(damage < 1) {
|
||||
damage= 1;
|
||||
|
@ -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,16), mapTagReplacements);
|
||||
unitupdaterNode->addAttribute("attackWarnRange",doubleToStr(attackWarnRange,10), mapTagReplacements);
|
||||
// AttackWarnings attackWarnings;
|
||||
//
|
||||
// Mutex mutexUnitRangeCellsLookupItemCache;
|
||||
|
|
|
@ -55,7 +55,7 @@ void Particle::saveGame(XmlNode *rootNode) {
|
|||
// Vec4f color;
|
||||
particleNode->addAttribute("color",color.getString(), mapTagReplacements);
|
||||
// float size;
|
||||
particleNode->addAttribute("size",doubleToStr(size,16), mapTagReplacements);
|
||||
particleNode->addAttribute("size",doubleToStr(size,10), mapTagReplacements);
|
||||
// int energy;
|
||||
particleNode->addAttribute("energy",intToStr(energy), mapTagReplacements);
|
||||
}
|
||||
|
@ -186,30 +186,30 @@ Checksum ParticleSystem::getCRC() {
|
|||
// =============== VIRTUAL ======================
|
||||
|
||||
//updates all living particles and creates new ones
|
||||
void ParticleSystem::update(){
|
||||
if(aliveParticleCount > (int) particles.size()){
|
||||
void ParticleSystem::update() {
|
||||
if(aliveParticleCount > (int) particles.size()) {
|
||||
throw megaglest_runtime_error("aliveParticleCount >= particles.size()");
|
||||
}
|
||||
if(particleSystemStartDelay>0){
|
||||
if(particleSystemStartDelay > 0) {
|
||||
particleSystemStartDelay--;
|
||||
}
|
||||
else if(state != sPause){
|
||||
for(int i= 0; i < aliveParticleCount; ++i){
|
||||
else if(state != sPause) {
|
||||
for(int i= 0; i < aliveParticleCount; ++i) {
|
||||
updateParticle(&particles[i]);
|
||||
|
||||
if(deathTest(&particles[i])){
|
||||
if(deathTest(&particles[i])) {
|
||||
|
||||
//kill the particle
|
||||
killParticle(&particles[i]);
|
||||
|
||||
//maintain alive particles at front of the array
|
||||
if(aliveParticleCount > 0){
|
||||
if(aliveParticleCount > 0) {
|
||||
particles[i]= particles[aliveParticleCount];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(state != ParticleSystem::sFade){
|
||||
if(state != ParticleSystem::sFade) {
|
||||
emissionState= emissionState + emissionRate;
|
||||
int emissionIntValue= (int) emissionState;
|
||||
for(int i= 0; i < emissionIntValue; i++){
|
||||
|
@ -217,21 +217,22 @@ void ParticleSystem::update(){
|
|||
initParticle(p, i);
|
||||
}
|
||||
emissionState = emissionState - (double) emissionIntValue;
|
||||
emissionState = truncateDecimal<double>(emissionState,10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr){
|
||||
if(active){
|
||||
if(active) {
|
||||
pr->renderSystem(this);
|
||||
}
|
||||
}
|
||||
|
||||
ParticleSystem::BlendMode ParticleSystem::strToBlendMode(const string &str){
|
||||
if(str == "normal"){
|
||||
if(str == "normal") {
|
||||
return bmOne;
|
||||
}
|
||||
else if(str == "black"){
|
||||
else if(str == "black") {
|
||||
return bmOneMinusAlpha;
|
||||
}
|
||||
else{
|
||||
|
@ -267,6 +268,7 @@ void ParticleSystem::setColorNoEnergy(Vec4f colorNoEnergy){
|
|||
|
||||
void ParticleSystem::setEmissionRate(double emissionRate){
|
||||
this->emissionRate= emissionRate;
|
||||
this->emissionRate = truncateDecimal<double>(this->emissionRate,10);
|
||||
}
|
||||
|
||||
void ParticleSystem::setMaxParticleEnergy(int maxParticleEnergy){
|
||||
|
@ -279,10 +281,12 @@ void ParticleSystem::setVarParticleEnergy(int varParticleEnergy){
|
|||
|
||||
void ParticleSystem::setParticleSize(double particleSize){
|
||||
this->particleSize= particleSize;
|
||||
this->particleSize = truncateDecimal<double>(this->particleSize,10);
|
||||
}
|
||||
|
||||
void ParticleSystem::setSpeed(double speed){
|
||||
this->speed= speed;
|
||||
this->speed = truncateDecimal<double>(this->speed,10);
|
||||
}
|
||||
|
||||
void ParticleSystem::setActive(bool active){
|
||||
|
@ -301,8 +305,9 @@ ParticleSystem* ParticleSystem::getChild(int i){
|
|||
|
||||
void ParticleSystem::setVisible(bool visible){
|
||||
this->visible= visible;
|
||||
for(int i=getChildCount()-1; i>=0; i--)
|
||||
for(int i=getChildCount()-1; i>=0; i--) {
|
||||
getChild(i)->setVisible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
string ParticleSystem::toString() const {
|
||||
|
@ -334,12 +339,12 @@ string ParticleSystem::toString() const {
|
|||
result += "\npos = " + pos.getString();
|
||||
result += "\ncolor = " + color.getString();
|
||||
result += "\ncolorNoEnergy = " + colorNoEnergy.getString();
|
||||
result += "\nemissionRate = " + doubleToStr(emissionRate,16);
|
||||
result += "\nemissionState = " + doubleToStr(emissionState,16);
|
||||
result += "\nemissionRate = " + doubleToStr(emissionRate,10);
|
||||
result += "\nemissionState = " + doubleToStr(emissionState,10);
|
||||
result += "\nmaxParticleEnergy = " + intToStr(maxParticleEnergy);
|
||||
result += "\nvarParticleEnergy = " + intToStr(varParticleEnergy);
|
||||
result += "\nparticleSize = " + doubleToStr(particleSize,16);
|
||||
result += "\nspeed = " + doubleToStr(speed,16);
|
||||
result += "\nparticleSize = " + doubleToStr(particleSize,10);
|
||||
result += "\nspeed = " + doubleToStr(speed,10);
|
||||
result += "\nfactionColor = " + factionColor.getString();
|
||||
result += "\nteamcolorNoEnergy = " + intToStr(teamcolorNoEnergy);
|
||||
result += "\nteamcolorEnergy = " + intToStr(teamcolorEnergy);
|
||||
|
@ -392,17 +397,17 @@ void ParticleSystem::saveGame(XmlNode *rootNode) {
|
|||
// Vec4f colorNoEnergy;
|
||||
particleSystemNode->addAttribute("colorNoEnergy",colorNoEnergy.getString(), mapTagReplacements);
|
||||
// float emissionRate;
|
||||
particleSystemNode->addAttribute("emissionRate",doubleToStr(emissionRate,16), mapTagReplacements);
|
||||
particleSystemNode->addAttribute("emissionRate",doubleToStr(emissionRate,10), mapTagReplacements);
|
||||
// float emissionState;
|
||||
particleSystemNode->addAttribute("emissionState",doubleToStr(emissionState,16), mapTagReplacements);
|
||||
particleSystemNode->addAttribute("emissionState",doubleToStr(emissionState,10), mapTagReplacements);
|
||||
// int maxParticleEnergy;
|
||||
particleSystemNode->addAttribute("maxParticleEnergy",intToStr(maxParticleEnergy), mapTagReplacements);
|
||||
// int varParticleEnergy;
|
||||
particleSystemNode->addAttribute("varParticleEnergy",intToStr(varParticleEnergy), mapTagReplacements);
|
||||
// float particleSize;
|
||||
particleSystemNode->addAttribute("particleSize",doubleToStr(particleSize,16), mapTagReplacements);
|
||||
particleSystemNode->addAttribute("particleSize",doubleToStr(particleSize,10), mapTagReplacements);
|
||||
// float speed;
|
||||
particleSystemNode->addAttribute("speed",doubleToStr(speed,16), mapTagReplacements);
|
||||
particleSystemNode->addAttribute("speed",doubleToStr(speed,10), mapTagReplacements);
|
||||
// Vec3f factionColor;
|
||||
particleSystemNode->addAttribute("factionColor",factionColor.getString(), mapTagReplacements);
|
||||
// bool teamcolorNoEnergy;
|
||||
|
@ -547,8 +552,8 @@ void ParticleSystem::fade(){
|
|||
}
|
||||
}
|
||||
|
||||
int ParticleSystem::isEmpty() const{
|
||||
assert(aliveParticleCount>=0);
|
||||
int ParticleSystem::isEmpty() const {
|
||||
//assert(aliveParticleCount>=0);
|
||||
return aliveParticleCount == 0 && state != sPause;
|
||||
}
|
||||
|
||||
|
@ -556,10 +561,10 @@ int ParticleSystem::isEmpty() const{
|
|||
|
||||
// if there is one dead particle it returns it else, return the particle with
|
||||
// less energy
|
||||
Particle * ParticleSystem::createParticle(){
|
||||
Particle * ParticleSystem::createParticle() {
|
||||
|
||||
//if any dead particles
|
||||
if(aliveParticleCount < particleCount){
|
||||
if(aliveParticleCount < particleCount) {
|
||||
++aliveParticleCount;
|
||||
return &particles[aliveParticleCount - 1];
|
||||
}
|
||||
|
@ -575,51 +580,31 @@ Particle * ParticleSystem::createParticle(){
|
|||
}
|
||||
}
|
||||
return &particles[minEnergyParticle];
|
||||
|
||||
/*
|
||||
//if any dead particles
|
||||
if(aliveParticleCount < particleCount) {
|
||||
++aliveParticleCount;
|
||||
return &particles[aliveParticleCount-1];
|
||||
}
|
||||
|
||||
//if not
|
||||
int minEnergy = particles[0].energy;
|
||||
int minEnergyParticle = 0;
|
||||
|
||||
for(int i = 0; i < particleCount; ++i){
|
||||
if(particles[i].energy < minEnergy){
|
||||
minEnergy = particles[i].energy;
|
||||
minEnergyParticle = i;
|
||||
}
|
||||
}
|
||||
|
||||
return &particles[minEnergyParticle];
|
||||
*/
|
||||
}
|
||||
|
||||
void ParticleSystem::initParticle(Particle *p, int particleIndex){
|
||||
void ParticleSystem::initParticle(Particle *p, int particleIndex) {
|
||||
p->pos= pos;
|
||||
p->lastPos= p->pos;
|
||||
p->speed= Vec3d(0.0f);
|
||||
p->accel= Vec3d(0.0f);
|
||||
p->color= Vec4f(1.0f, 1.0f, 1.0f, 1.0);
|
||||
p->size= particleSize;
|
||||
p->size = truncateDecimal<double>(p->size,10);
|
||||
p->energy= maxParticleEnergy + random.randRange(-varParticleEnergy, varParticleEnergy);
|
||||
}
|
||||
|
||||
void ParticleSystem::updateParticle(Particle *p){
|
||||
void ParticleSystem::updateParticle(Particle *p) {
|
||||
p->lastPos= p->pos;
|
||||
p->pos= p->pos + p->speed;
|
||||
p->speed= p->speed + p->accel;
|
||||
p->energy--;
|
||||
}
|
||||
|
||||
bool ParticleSystem::deathTest(Particle *p){
|
||||
bool ParticleSystem::deathTest(Particle *p) {
|
||||
return p->energy <= 0;
|
||||
}
|
||||
|
||||
void ParticleSystem::killParticle(Particle *p){
|
||||
void ParticleSystem::killParticle(Particle *p) {
|
||||
aliveParticleCount--;
|
||||
}
|
||||
|
||||
|
@ -677,16 +662,16 @@ void FireParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
p->energy= static_cast<int> (maxParticleEnergy * radRatio)
|
||||
+ random.randRange(-varParticleEnergy, varParticleEnergy);
|
||||
p->pos= Vec3d(pos.x + x, pos.y + random.randRange(-radius / 2, radius / 2), pos.z + y);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,16);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,16);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,16);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,10);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,10);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,10);
|
||||
|
||||
p->lastPos= pos;
|
||||
p->size= particleSize;
|
||||
p->speed= Vec3d(0, speed + speed * random.randRange(-0.5f, 0.5f), 0) + windSpeed;
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
|
||||
}
|
||||
|
||||
|
@ -703,9 +688,9 @@ void FireParticleSystem::updateParticle(Particle *p){
|
|||
p->color.w*= 0.98f;
|
||||
|
||||
p->speed.x*= 1.001f;
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
|
||||
}
|
||||
|
||||
|
@ -735,9 +720,9 @@ void FireParticleSystem::setWind(double windAngle, double windSpeed) {
|
|||
this->windSpeed.z= cosf(degToRad(windAngle)) * windSpeed;
|
||||
#endif
|
||||
|
||||
this->windSpeed.x = truncateDecimal<double>(this->windSpeed.x,16);
|
||||
this->windSpeed.y = truncateDecimal<double>(this->windSpeed.y,16);
|
||||
this->windSpeed.z = truncateDecimal<double>(this->windSpeed.z,16);
|
||||
this->windSpeed.x = truncateDecimal<double>(this->windSpeed.x,10);
|
||||
this->windSpeed.y = truncateDecimal<double>(this->windSpeed.y,10);
|
||||
this->windSpeed.z = truncateDecimal<double>(this->windSpeed.z,10);
|
||||
}
|
||||
|
||||
void FireParticleSystem::saveGame(XmlNode *rootNode) {
|
||||
|
@ -747,7 +732,7 @@ void FireParticleSystem::saveGame(XmlNode *rootNode) {
|
|||
ParticleSystem::saveGame(fireParticleSystemNode);
|
||||
|
||||
// float radius;
|
||||
fireParticleSystemNode->addAttribute("radius",doubleToStr(radius,16), mapTagReplacements);
|
||||
fireParticleSystemNode->addAttribute("radius",doubleToStr(radius,10), mapTagReplacements);
|
||||
// Vec3f windSpeed;
|
||||
fireParticleSystemNode->addAttribute("windSpeed",windSpeed.getString(), mapTagReplacements);
|
||||
}
|
||||
|
@ -885,7 +870,7 @@ void GameParticleSystem::setTween(double relative,double absolute) {
|
|||
}
|
||||
}
|
||||
|
||||
tween = truncateDecimal<double>(tween,16);
|
||||
tween = truncateDecimal<double>(tween,10);
|
||||
if(tween < 0.0f || tween > 1.0f) {
|
||||
//printf("In [%s::%s Line: %d] WARNING setting tween to [%f] clamping tween, modelCycle [%f] absolute [%f] relative [%f]\n",__FILE__,__FUNCTION__,__LINE__,tween,modelCycle,absolute,relative);
|
||||
//assert(tween >= 0.0f && tween <= 1.0f);
|
||||
|
@ -923,13 +908,13 @@ void GameParticleSystem::saveGame(XmlNode *rootNode) {
|
|||
gameParticleSystemNode->addAttribute("model",model->getFileName(), mapTagReplacements);
|
||||
}
|
||||
// float modelCycle;
|
||||
gameParticleSystemNode->addAttribute("modelCycle",doubleToStr(modelCycle,16), mapTagReplacements);
|
||||
gameParticleSystemNode->addAttribute("modelCycle",doubleToStr(modelCycle,10), mapTagReplacements);
|
||||
// Vec3f offset;
|
||||
gameParticleSystemNode->addAttribute("offset",offset.getString(), mapTagReplacements);
|
||||
// Vec3f direction;
|
||||
gameParticleSystemNode->addAttribute("direction",direction.getString(), mapTagReplacements);
|
||||
// float tween;
|
||||
gameParticleSystemNode->addAttribute("tween",doubleToStr(tween,16), mapTagReplacements);
|
||||
gameParticleSystemNode->addAttribute("tween",doubleToStr(tween,10), mapTagReplacements);
|
||||
}
|
||||
void GameParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||
const XmlNode *gameParticleSystemNode = rootNode->getChild("GameParticleSystem");
|
||||
|
@ -1126,9 +1111,9 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
oldPosition= pos;
|
||||
p->size= particleSize;
|
||||
p->accel= Vec3d(0.0f, -gravity, 0.0f);
|
||||
p->accel.x = truncateDecimal<double>(p->accel.x,16);
|
||||
p->accel.y = truncateDecimal<double>(p->accel.y,16);
|
||||
p->accel.z = truncateDecimal<double>(p->accel.z,16);
|
||||
p->accel.x = truncateDecimal<double>(p->accel.x,10);
|
||||
p->accel.y = truncateDecimal<double>(p->accel.y,10);
|
||||
p->accel.z = truncateDecimal<double>(p->accel.z,10);
|
||||
|
||||
// work out where we start for our shape (set speed and pos)
|
||||
switch(shape){
|
||||
|
@ -1140,15 +1125,15 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
Vec2d vert = Vec2d(1,0).rotate(degToRad(angle));
|
||||
Vec3d start = Vec3d(horiz.x*vert.y,vert.x,horiz.y).getNormalized(); // close enough
|
||||
p->speed = start * speed;
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
|
||||
start = start * random.randRange(minRadius,radius);
|
||||
p->pos = pos + offset + start;
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,16);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,16);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,16);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,10);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,10);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,10);
|
||||
|
||||
} break;
|
||||
case sLinear:{
|
||||
|
@ -1164,9 +1149,9 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
p->pos= Vec3d(pos.x + x + offset.x, pos.y +
|
||||
random.randRange(-radius / 2, radius / 2) + offset.y,
|
||||
pos.z + y + offset.z);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,16);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,16);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,16);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,10);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,10);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,10);
|
||||
|
||||
}
|
||||
else {// rotate it according to rotation
|
||||
|
@ -1177,18 +1162,18 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
radius / 2) + offset.y, pos.z + y + (offset.z * cosf(rad) - offset.x * sinf(rad)));
|
||||
#endif
|
||||
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,16);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,16);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,16);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,10);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,10);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,10);
|
||||
|
||||
}
|
||||
p->speed= Vec3d(direction.x + direction.x * random.randRange(-0.5f, 0.5f), direction.y + direction.y
|
||||
* random.randRange(-0.5f, 0.5f), direction.z + direction.z * random.randRange(-0.5f, 0.5f));
|
||||
p->speed= p->speed * speed;
|
||||
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
|
||||
if(relative && relativeDirection) {
|
||||
#ifdef USE_STREFLOP
|
||||
|
@ -1203,9 +1188,9 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
p->speed.y, (p->speed.z * cosf(rad) - p->speed.x * sinf(rad)));
|
||||
#endif
|
||||
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
}
|
||||
} break;
|
||||
default: throw megaglest_runtime_error("bad shape");
|
||||
|
@ -1222,7 +1207,7 @@ void UnitParticleSystem::update(){
|
|||
}
|
||||
if(state != sPause) {
|
||||
emissionRate-= emissionRateFade;
|
||||
emissionRate = truncateDecimal<double>(emissionRate,16);
|
||||
emissionRate = truncateDecimal<double>(emissionRate,10);
|
||||
|
||||
if(parent && emissionRate < 0.0f) {
|
||||
fade();
|
||||
|
@ -1230,9 +1215,9 @@ void UnitParticleSystem::update(){
|
|||
}
|
||||
if(fixed) {
|
||||
fixedAddition= Vec3d(pos.x - oldPosition.x, pos.y - oldPosition.y, pos.z - oldPosition.z);
|
||||
fixedAddition.x = truncateDecimal<double>(fixedAddition.x,16);
|
||||
fixedAddition.y = truncateDecimal<double>(fixedAddition.y,16);
|
||||
fixedAddition.z = truncateDecimal<double>(fixedAddition.z,16);
|
||||
fixedAddition.x = truncateDecimal<double>(fixedAddition.x,10);
|
||||
fixedAddition.y = truncateDecimal<double>(fixedAddition.y,10);
|
||||
fixedAddition.z = truncateDecimal<double>(fixedAddition.z,10);
|
||||
|
||||
oldPosition= pos;
|
||||
}
|
||||
|
@ -1257,33 +1242,33 @@ void UnitParticleSystem::updateParticle(Particle *p){
|
|||
energyRatio= clamp(static_cast<double> (p->energy) / maxParticleEnergy, 0.f, 1.f);
|
||||
}
|
||||
|
||||
energyRatio = truncateDecimal<double>(energyRatio,16);
|
||||
energyRatio = truncateDecimal<double>(energyRatio,10);
|
||||
|
||||
p->lastPos += p->speed;
|
||||
p->lastPos.x = truncateDecimal<double>(p->lastPos.x,16);
|
||||
p->lastPos.y = truncateDecimal<double>(p->lastPos.y,16);
|
||||
p->lastPos.z = truncateDecimal<double>(p->lastPos.z,16);
|
||||
p->lastPos.x = truncateDecimal<double>(p->lastPos.x,10);
|
||||
p->lastPos.y = truncateDecimal<double>(p->lastPos.y,10);
|
||||
p->lastPos.z = truncateDecimal<double>(p->lastPos.z,10);
|
||||
|
||||
p->pos += p->speed;
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,16);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,16);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,16);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,10);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,10);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,10);
|
||||
|
||||
if(fixed) {
|
||||
p->lastPos += fixedAddition;
|
||||
p->lastPos.x = truncateDecimal<double>(p->lastPos.x,16);
|
||||
p->lastPos.y = truncateDecimal<double>(p->lastPos.y,16);
|
||||
p->lastPos.z = truncateDecimal<double>(p->lastPos.z,16);
|
||||
p->lastPos.x = truncateDecimal<double>(p->lastPos.x,10);
|
||||
p->lastPos.y = truncateDecimal<double>(p->lastPos.y,10);
|
||||
p->lastPos.z = truncateDecimal<double>(p->lastPos.z,10);
|
||||
|
||||
p->pos += fixedAddition;
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,16);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,16);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,16);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,10);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,10);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,10);
|
||||
}
|
||||
p->speed += p->accel;
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
|
||||
p->color= color * energyRatio + colorNoEnergy * (1.0f - energyRatio);
|
||||
if(isDaylightAffected==true) {
|
||||
|
@ -1292,7 +1277,7 @@ void UnitParticleSystem::updateParticle(Particle *p){
|
|||
p->color.z=p->color.z*lightColor.z;
|
||||
}
|
||||
p->size= particleSize * energyRatio + sizeNoEnergy * (1.0f - energyRatio);
|
||||
p->size = truncateDecimal<double>(p->size,16);
|
||||
p->size = truncateDecimal<double>(p->size,10);
|
||||
|
||||
if(state == ParticleSystem::sFade || staticParticleCount < 1){
|
||||
p->energy--;
|
||||
|
@ -1329,9 +1314,9 @@ void UnitParticleSystem::setWind(double windAngle, double windSpeed){
|
|||
this->windSpeed.z= cosf(degToRad(windAngle)) * windSpeed;
|
||||
#endif
|
||||
|
||||
this->windSpeed.x = truncateDecimal<double>(this->windSpeed.x,16);
|
||||
this->windSpeed.y = truncateDecimal<double>(this->windSpeed.y,16);
|
||||
this->windSpeed.z = truncateDecimal<double>(this->windSpeed.z,16);
|
||||
this->windSpeed.x = truncateDecimal<double>(this->windSpeed.x,10);
|
||||
this->windSpeed.y = truncateDecimal<double>(this->windSpeed.y,10);
|
||||
this->windSpeed.z = truncateDecimal<double>(this->windSpeed.z,10);
|
||||
}
|
||||
|
||||
void UnitParticleSystem::saveGame(XmlNode *rootNode) {
|
||||
|
@ -1341,9 +1326,9 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) {
|
|||
GameParticleSystem::saveGame(unitParticleSystemNode);
|
||||
|
||||
// float radius;
|
||||
unitParticleSystemNode->addAttribute("radius",doubleToStr(radius,16), mapTagReplacements);
|
||||
unitParticleSystemNode->addAttribute("radius",doubleToStr(radius,10), mapTagReplacements);
|
||||
// float minRadius;
|
||||
unitParticleSystemNode->addAttribute("minRadius",doubleToStr(minRadius,16), mapTagReplacements);
|
||||
unitParticleSystemNode->addAttribute("minRadius",doubleToStr(minRadius,10), mapTagReplacements);
|
||||
// Vec3f windSpeed;
|
||||
unitParticleSystemNode->addAttribute("windSpeed",windSpeed.getString(), mapTagReplacements);
|
||||
// Vec3f cRotation;
|
||||
|
@ -1355,9 +1340,9 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) {
|
|||
// bool energyUp;
|
||||
unitParticleSystemNode->addAttribute("energyUp",intToStr(energyUp), mapTagReplacements);
|
||||
// float startTime;
|
||||
unitParticleSystemNode->addAttribute("startTime",doubleToStr(startTime,16), mapTagReplacements);
|
||||
unitParticleSystemNode->addAttribute("startTime",doubleToStr(startTime,10), mapTagReplacements);
|
||||
// float endTime;
|
||||
unitParticleSystemNode->addAttribute("endTime",doubleToStr(endTime,16), mapTagReplacements);
|
||||
unitParticleSystemNode->addAttribute("endTime",doubleToStr(endTime,10), mapTagReplacements);
|
||||
// bool relative;
|
||||
unitParticleSystemNode->addAttribute("relative",intToStr(relative), mapTagReplacements);
|
||||
// bool relativeDirection;
|
||||
|
@ -1367,13 +1352,13 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) {
|
|||
// Shape shape;
|
||||
unitParticleSystemNode->addAttribute("shape",intToStr(shape), mapTagReplacements);
|
||||
// float angle;
|
||||
unitParticleSystemNode->addAttribute("angle",doubleToStr(angle,16), mapTagReplacements);
|
||||
unitParticleSystemNode->addAttribute("angle",doubleToStr(angle,10), mapTagReplacements);
|
||||
// float sizeNoEnergy;
|
||||
unitParticleSystemNode->addAttribute("sizeNoEnergy",doubleToStr(sizeNoEnergy,16), mapTagReplacements);
|
||||
unitParticleSystemNode->addAttribute("sizeNoEnergy",doubleToStr(sizeNoEnergy,10), mapTagReplacements);
|
||||
// float gravity;
|
||||
unitParticleSystemNode->addAttribute("gravity",doubleToStr(gravity,16), mapTagReplacements);
|
||||
unitParticleSystemNode->addAttribute("gravity",doubleToStr(gravity,10), mapTagReplacements);
|
||||
// float rotation;
|
||||
unitParticleSystemNode->addAttribute("rotation",doubleToStr(rotation,16), mapTagReplacements);
|
||||
unitParticleSystemNode->addAttribute("rotation",doubleToStr(rotation,10), mapTagReplacements);
|
||||
// bool isVisibleAtNight;
|
||||
unitParticleSystemNode->addAttribute("isVisibleAtNight",intToStr(isVisibleAtNight), mapTagReplacements);
|
||||
// bool isVisibleAtDay;
|
||||
|
@ -1389,7 +1374,7 @@ void UnitParticleSystem::saveGame(XmlNode *rootNode) {
|
|||
// int lifetime;
|
||||
unitParticleSystemNode->addAttribute("lifetime",intToStr(lifetime), mapTagReplacements);
|
||||
// float emissionRateFade;
|
||||
unitParticleSystemNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,16), mapTagReplacements);
|
||||
unitParticleSystemNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,10), mapTagReplacements);
|
||||
// GameParticleSystem* parent;
|
||||
//if(parent != NULL) {
|
||||
// parent->saveGame(unitParticleSystemNode);
|
||||
|
@ -1535,16 +1520,16 @@ void RainParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
p->color= color;
|
||||
p->energy= 10000;
|
||||
p->pos= Vec3d(pos.x + x, pos.y, pos.z + y);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,16);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,16);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,16);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,10);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,10);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,10);
|
||||
|
||||
p->lastPos= p->pos;
|
||||
p->speed= Vec3d(random.randRange(-speed / 10, speed / 10), -speed,
|
||||
random.randRange(-speed / 10, speed / 10)) + windSpeed;
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
}
|
||||
|
||||
bool RainParticleSystem::deathTest(Particle *p){
|
||||
|
@ -1566,9 +1551,9 @@ void RainParticleSystem::setWind(double windAngle, double windSpeed){
|
|||
this->windSpeed.z= cosf(degToRad(windAngle)) * windSpeed;
|
||||
#endif
|
||||
|
||||
this->windSpeed.x = truncateDecimal<double>(this->windSpeed.x,16);
|
||||
this->windSpeed.y = truncateDecimal<double>(this->windSpeed.y,16);
|
||||
this->windSpeed.z = truncateDecimal<double>(this->windSpeed.z,16);
|
||||
this->windSpeed.x = truncateDecimal<double>(this->windSpeed.x,10);
|
||||
this->windSpeed.y = truncateDecimal<double>(this->windSpeed.y,10);
|
||||
this->windSpeed.z = truncateDecimal<double>(this->windSpeed.z,10);
|
||||
}
|
||||
|
||||
Checksum RainParticleSystem::getCRC() {
|
||||
|
@ -1612,18 +1597,18 @@ void SnowParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
p->color= color;
|
||||
p->energy= 10000;
|
||||
p->pos= Vec3d(pos.x + x, pos.y, pos.z + y);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,16);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,16);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,16);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,10);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,10);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,10);
|
||||
|
||||
p->lastPos= p->pos;
|
||||
p->speed= Vec3d(0.0f, -speed, 0.0f) + windSpeed;
|
||||
p->speed.x+= random.randRange(-0.005f, 0.005f);
|
||||
p->speed.y+= random.randRange(-0.005f, 0.005f);
|
||||
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
}
|
||||
|
||||
bool SnowParticleSystem::deathTest(Particle *p){
|
||||
|
@ -1645,9 +1630,9 @@ void SnowParticleSystem::setWind(double windAngle, double windSpeed){
|
|||
this->windSpeed.z= cosf(degToRad(windAngle)) * windSpeed;
|
||||
#endif
|
||||
|
||||
this->windSpeed.x = truncateDecimal<double>(this->windSpeed.x,16);
|
||||
this->windSpeed.y = truncateDecimal<double>(this->windSpeed.y,16);
|
||||
this->windSpeed.z = truncateDecimal<double>(this->windSpeed.z,16);
|
||||
this->windSpeed.x = truncateDecimal<double>(this->windSpeed.x,10);
|
||||
this->windSpeed.y = truncateDecimal<double>(this->windSpeed.y,10);
|
||||
this->windSpeed.z = truncateDecimal<double>(this->windSpeed.z,10);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1685,9 +1670,9 @@ void AttackParticleSystem::saveGame(XmlNode *rootNode) {
|
|||
GameParticleSystem::saveGame(attackParticleSystemNode);
|
||||
|
||||
// float sizeNoEnergy;
|
||||
attackParticleSystemNode->addAttribute("sizeNoEnergy",doubleToStr(sizeNoEnergy,16), mapTagReplacements);
|
||||
attackParticleSystemNode->addAttribute("sizeNoEnergy",doubleToStr(sizeNoEnergy,10), mapTagReplacements);
|
||||
// float gravity;
|
||||
attackParticleSystemNode->addAttribute("gravity",doubleToStr(gravity,16), mapTagReplacements);
|
||||
attackParticleSystemNode->addAttribute("gravity",doubleToStr(gravity,10), mapTagReplacements);
|
||||
|
||||
}
|
||||
void AttackParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||
|
@ -1760,24 +1745,24 @@ void ProjectileParticleSystem::update(){
|
|||
if(state == sPlay){
|
||||
|
||||
lastPos = pos;
|
||||
flatPos += zVector * truncateDecimal<double>(trajectorySpeed,16);
|
||||
flatPos.x = truncateDecimal<double>(flatPos.x,16);
|
||||
flatPos.y = truncateDecimal<double>(flatPos.y,16);
|
||||
flatPos.z = truncateDecimal<double>(flatPos.z,16);
|
||||
flatPos += zVector * truncateDecimal<double>(trajectorySpeed,10);
|
||||
flatPos.x = truncateDecimal<double>(flatPos.x,10);
|
||||
flatPos.y = truncateDecimal<double>(flatPos.y,10);
|
||||
flatPos.z = truncateDecimal<double>(flatPos.z,10);
|
||||
|
||||
Vec3d targetVector = endPos - startPos;
|
||||
targetVector.x = truncateDecimal<double>(targetVector.x,16);
|
||||
targetVector.y = truncateDecimal<double>(targetVector.y,16);
|
||||
targetVector.z = truncateDecimal<double>(targetVector.z,16);
|
||||
targetVector.x = truncateDecimal<double>(targetVector.x,10);
|
||||
targetVector.y = truncateDecimal<double>(targetVector.y,10);
|
||||
targetVector.z = truncateDecimal<double>(targetVector.z,10);
|
||||
|
||||
Vec3d currentVector = flatPos - startPos;
|
||||
currentVector.x = truncateDecimal<double>(currentVector.x,16);
|
||||
currentVector.y = truncateDecimal<double>(currentVector.y,16);
|
||||
currentVector.z = truncateDecimal<double>(currentVector.z,16);
|
||||
currentVector.x = truncateDecimal<double>(currentVector.x,10);
|
||||
currentVector.y = truncateDecimal<double>(currentVector.y,10);
|
||||
currentVector.z = truncateDecimal<double>(currentVector.z,10);
|
||||
|
||||
// ratio
|
||||
double relative= clamp(currentVector.length() / targetVector.length(), 0.0f, 1.0f);
|
||||
relative = truncateDecimal<double>(relative,16);
|
||||
relative = truncateDecimal<double>(relative,10);
|
||||
|
||||
//printf("Update particle targetVector [%s][%f] currentVector [%s][%f] relative = %f\n",targetVector.getString().c_str(),targetVector.length(),currentVector.getString().c_str(),currentVector.length(),relative);
|
||||
|
||||
|
@ -1800,12 +1785,12 @@ void ProjectileParticleSystem::update(){
|
|||
break;
|
||||
|
||||
case tParabolic: {
|
||||
double scaledT = truncateDecimal<double>(2.0f * (relative - 0.5f),16);
|
||||
double paraboleY = truncateDecimal<double>((1.0f - scaledT * scaledT) * trajectoryScale,16);
|
||||
double scaledT = truncateDecimal<double>(2.0f * (relative - 0.5f),10);
|
||||
double paraboleY = truncateDecimal<double>((1.0f - scaledT * scaledT) * trajectoryScale,10);
|
||||
|
||||
pos= flatPos;
|
||||
pos.y += paraboleY;
|
||||
pos.y = truncateDecimal<double>(pos.y,16);
|
||||
pos.y = truncateDecimal<double>(pos.y,10);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1818,9 +1803,9 @@ void ProjectileParticleSystem::update(){
|
|||
pos+= xVector * cos(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
||||
pos+= yVector * sin(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
||||
#endif
|
||||
pos.x = truncateDecimal<double>(pos.x,16);
|
||||
pos.y = truncateDecimal<double>(pos.y,16);
|
||||
pos.z = truncateDecimal<double>(pos.z,16);
|
||||
pos.x = truncateDecimal<double>(pos.x,10);
|
||||
pos.y = truncateDecimal<double>(pos.y,10);
|
||||
pos.z = truncateDecimal<double>(pos.z,10);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1831,16 +1816,16 @@ void ProjectileParticleSystem::update(){
|
|||
|
||||
direction= pos - lastPos;
|
||||
direction.normalize();
|
||||
direction.x = truncateDecimal<double>(direction.x,16);
|
||||
direction.y = truncateDecimal<double>(direction.y,16);
|
||||
direction.z = truncateDecimal<double>(direction.z,16);
|
||||
direction.x = truncateDecimal<double>(direction.x,10);
|
||||
direction.y = truncateDecimal<double>(direction.y,10);
|
||||
direction.z = truncateDecimal<double>(direction.z,10);
|
||||
|
||||
// trigger update of child particles
|
||||
positionChildren();
|
||||
rotateChildren();
|
||||
|
||||
//arrive destination
|
||||
arriveDestinationDistance = truncateDecimal<double>(flatPos.dist(endPos),16);
|
||||
arriveDestinationDistance = truncateDecimal<double>(flatPos.dist(endPos),10);
|
||||
if(arriveDestinationDistance < 0.5f) {
|
||||
fade();
|
||||
model= NULL;
|
||||
|
@ -1864,11 +1849,11 @@ void ProjectileParticleSystem::update(){
|
|||
void ProjectileParticleSystem::rotateChildren() {
|
||||
//### only on horizontal plane :(
|
||||
#ifdef USE_STREFLOP
|
||||
double rotation = truncateDecimal<double>(streflop::atan2(static_cast<streflop::Simple>(direction.x), static_cast<streflop::Simple>(direction.z)),16);
|
||||
double rotation = truncateDecimal<double>(streflop::atan2(static_cast<streflop::Simple>(direction.x), static_cast<streflop::Simple>(direction.z)),10);
|
||||
#else
|
||||
double rotation = truncateDecimal<double>(atan2(direction.x, direction.z),16);
|
||||
double rotation = truncateDecimal<double>(atan2(direction.x, direction.z),10);
|
||||
#endif
|
||||
rotation = truncateDecimal<double>(radToDeg(rotation),16);
|
||||
rotation = truncateDecimal<double>(radToDeg(rotation),10);
|
||||
for(Children::iterator it = children.begin(); it != children.end(); ++it)
|
||||
(*it)->setRotation(rotation);
|
||||
}
|
||||
|
@ -1878,50 +1863,50 @@ void ProjectileParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
ParticleSystem::initParticle(p, particleIndex);
|
||||
|
||||
double t= static_cast<double> (particleIndex) / emissionRate;
|
||||
t = truncateDecimal<double>(t,16);
|
||||
t = truncateDecimal<double>(t,10);
|
||||
|
||||
p->pos= pos + (lastPos - pos) * t;
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,16);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,16);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,16);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,10);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,10);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,10);
|
||||
|
||||
p->lastPos= lastPos;
|
||||
p->speed= Vec3d(random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f),
|
||||
random.randRange(-0.1f, 0.1f)) * speed;
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
|
||||
p->accel= Vec3d(0.0f, -gravity, 0.0f);
|
||||
p->accel.x = truncateDecimal<double>(p->accel.x,16);
|
||||
p->accel.y = truncateDecimal<double>(p->accel.y,16);
|
||||
p->accel.z = truncateDecimal<double>(p->accel.z,16);
|
||||
p->accel.x = truncateDecimal<double>(p->accel.x,10);
|
||||
p->accel.y = truncateDecimal<double>(p->accel.y,10);
|
||||
p->accel.z = truncateDecimal<double>(p->accel.z,10);
|
||||
|
||||
updateParticle(p);
|
||||
}
|
||||
|
||||
void ProjectileParticleSystem::updateParticle(Particle *p){
|
||||
double energyRatio= clamp(static_cast<double> (p->energy) / maxParticleEnergy, 0.f, 1.f);
|
||||
energyRatio = truncateDecimal<double>(energyRatio,16);
|
||||
energyRatio = truncateDecimal<double>(energyRatio,10);
|
||||
|
||||
p->lastPos += p->speed;
|
||||
p->lastPos.x = truncateDecimal<double>(p->lastPos.x,16);
|
||||
p->lastPos.y = truncateDecimal<double>(p->lastPos.y,16);
|
||||
p->lastPos.z = truncateDecimal<double>(p->lastPos.z,16);
|
||||
p->lastPos.x = truncateDecimal<double>(p->lastPos.x,10);
|
||||
p->lastPos.y = truncateDecimal<double>(p->lastPos.y,10);
|
||||
p->lastPos.z = truncateDecimal<double>(p->lastPos.z,10);
|
||||
|
||||
p->pos += p->speed;
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,16);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,16);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,16);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,10);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,10);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,10);
|
||||
|
||||
p->speed += p->accel;
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
|
||||
p->color= color * energyRatio + colorNoEnergy * (1.0f - energyRatio);
|
||||
p->size = particleSize * energyRatio + sizeNoEnergy * (1.0f - energyRatio);
|
||||
p->size = truncateDecimal<double>(p->size,16);
|
||||
p->size = truncateDecimal<double>(p->size,10);
|
||||
p->energy--;
|
||||
}
|
||||
|
||||
|
@ -1929,36 +1914,36 @@ void ProjectileParticleSystem::setPath(Vec3d startPos, Vec3d endPos){
|
|||
|
||||
//compute axis
|
||||
zVector= endPos - startPos;
|
||||
zVector.x = truncateDecimal<double>(zVector.x,16);
|
||||
zVector.y = truncateDecimal<double>(zVector.y,16);
|
||||
zVector.z = truncateDecimal<double>(zVector.z,16);
|
||||
zVector.x = truncateDecimal<double>(zVector.x,10);
|
||||
zVector.y = truncateDecimal<double>(zVector.y,10);
|
||||
zVector.z = truncateDecimal<double>(zVector.z,10);
|
||||
|
||||
zVector.normalize();
|
||||
zVector.x = truncateDecimal<double>(zVector.x,16);
|
||||
zVector.y = truncateDecimal<double>(zVector.y,16);
|
||||
zVector.z = truncateDecimal<double>(zVector.z,16);
|
||||
zVector.x = truncateDecimal<double>(zVector.x,10);
|
||||
zVector.y = truncateDecimal<double>(zVector.y,10);
|
||||
zVector.z = truncateDecimal<double>(zVector.z,10);
|
||||
|
||||
yVector= Vec3d(0.0f, 1.0f, 0.0f);
|
||||
xVector= zVector.cross(yVector);
|
||||
xVector.x = truncateDecimal<double>(xVector.x,16);
|
||||
xVector.y = truncateDecimal<double>(xVector.y,16);
|
||||
xVector.z = truncateDecimal<double>(xVector.z,16);
|
||||
xVector.x = truncateDecimal<double>(xVector.x,10);
|
||||
xVector.y = truncateDecimal<double>(xVector.y,10);
|
||||
xVector.z = truncateDecimal<double>(xVector.z,10);
|
||||
|
||||
//apply offset
|
||||
startPos += xVector * offset.x;
|
||||
startPos.x = truncateDecimal<double>(startPos.x,16);
|
||||
startPos.y = truncateDecimal<double>(startPos.y,16);
|
||||
startPos.z = truncateDecimal<double>(startPos.z,16);
|
||||
startPos.x = truncateDecimal<double>(startPos.x,10);
|
||||
startPos.y = truncateDecimal<double>(startPos.y,10);
|
||||
startPos.z = truncateDecimal<double>(startPos.z,10);
|
||||
|
||||
startPos+= yVector * offset.y;
|
||||
startPos.x = truncateDecimal<double>(startPos.x,16);
|
||||
startPos.y = truncateDecimal<double>(startPos.y,16);
|
||||
startPos.z = truncateDecimal<double>(startPos.z,16);
|
||||
startPos.x = truncateDecimal<double>(startPos.x,10);
|
||||
startPos.y = truncateDecimal<double>(startPos.y,10);
|
||||
startPos.z = truncateDecimal<double>(startPos.z,10);
|
||||
|
||||
startPos+= zVector * offset.z;
|
||||
startPos.x = truncateDecimal<double>(startPos.x,16);
|
||||
startPos.y = truncateDecimal<double>(startPos.y,16);
|
||||
startPos.z = truncateDecimal<double>(startPos.z,16);
|
||||
startPos.x = truncateDecimal<double>(startPos.x,10);
|
||||
startPos.y = truncateDecimal<double>(startPos.y,10);
|
||||
startPos.z = truncateDecimal<double>(startPos.z,10);
|
||||
|
||||
pos= startPos;
|
||||
lastPos= startPos;
|
||||
|
@ -1966,20 +1951,20 @@ void ProjectileParticleSystem::setPath(Vec3d startPos, Vec3d endPos){
|
|||
|
||||
//recompute axis
|
||||
zVector= endPos - startPos;
|
||||
zVector.x = truncateDecimal<double>(zVector.x,16);
|
||||
zVector.y = truncateDecimal<double>(zVector.y,16);
|
||||
zVector.z = truncateDecimal<double>(zVector.z,16);
|
||||
zVector.x = truncateDecimal<double>(zVector.x,10);
|
||||
zVector.y = truncateDecimal<double>(zVector.y,10);
|
||||
zVector.z = truncateDecimal<double>(zVector.z,10);
|
||||
|
||||
zVector.normalize();
|
||||
zVector.x = truncateDecimal<double>(zVector.x,16);
|
||||
zVector.y = truncateDecimal<double>(zVector.y,16);
|
||||
zVector.z = truncateDecimal<double>(zVector.z,16);
|
||||
zVector.x = truncateDecimal<double>(zVector.x,10);
|
||||
zVector.y = truncateDecimal<double>(zVector.y,10);
|
||||
zVector.z = truncateDecimal<double>(zVector.z,10);
|
||||
|
||||
yVector= Vec3d(0.0f, 1.0f, 0.0f);
|
||||
xVector= zVector.cross(yVector);
|
||||
xVector.x = truncateDecimal<double>(xVector.x,16);
|
||||
xVector.y = truncateDecimal<double>(xVector.y,16);
|
||||
xVector.z = truncateDecimal<double>(xVector.z,16);
|
||||
xVector.x = truncateDecimal<double>(xVector.x,10);
|
||||
xVector.y = truncateDecimal<double>(xVector.y,10);
|
||||
xVector.z = truncateDecimal<double>(xVector.z,10);
|
||||
|
||||
// set members
|
||||
this->startPos= startPos;
|
||||
|
@ -1987,14 +1972,14 @@ void ProjectileParticleSystem::setPath(Vec3d startPos, Vec3d endPos){
|
|||
|
||||
// direction
|
||||
direction = (endPos - lastPos);
|
||||
direction.x = truncateDecimal<double>(direction.x,16);
|
||||
direction.y = truncateDecimal<double>(direction.y,16);
|
||||
direction.z = truncateDecimal<double>(direction.z,16);
|
||||
direction.x = truncateDecimal<double>(direction.x,10);
|
||||
direction.y = truncateDecimal<double>(direction.y,10);
|
||||
direction.z = truncateDecimal<double>(direction.z,10);
|
||||
|
||||
direction.normalize();
|
||||
direction.x = truncateDecimal<double>(direction.x,16);
|
||||
direction.y = truncateDecimal<double>(direction.y,16);
|
||||
direction.z = truncateDecimal<double>(direction.z,16);
|
||||
direction.x = truncateDecimal<double>(direction.x,10);
|
||||
direction.y = truncateDecimal<double>(direction.y,10);
|
||||
direction.z = truncateDecimal<double>(direction.z,10);
|
||||
|
||||
rotateChildren();
|
||||
}
|
||||
|
@ -2042,12 +2027,12 @@ void ProjectileParticleSystem::saveGame(XmlNode *rootNode) {
|
|||
// Trajectory trajectory;
|
||||
projectileParticleSystemNode->addAttribute("trajectory",intToStr(trajectory), mapTagReplacements);
|
||||
// float trajectorySpeed;
|
||||
projectileParticleSystemNode->addAttribute("trajectorySpeed",doubleToStr(trajectorySpeed,16), mapTagReplacements);
|
||||
projectileParticleSystemNode->addAttribute("trajectorySpeed",doubleToStr(trajectorySpeed,10), mapTagReplacements);
|
||||
// //parabolic
|
||||
// float trajectoryScale;
|
||||
projectileParticleSystemNode->addAttribute("trajectoryScale",doubleToStr(trajectoryScale,16), mapTagReplacements);
|
||||
projectileParticleSystemNode->addAttribute("trajectoryScale",doubleToStr(trajectoryScale,10), mapTagReplacements);
|
||||
// float trajectoryFrequency;
|
||||
projectileParticleSystemNode->addAttribute("trajectoryFrequency",doubleToStr(trajectoryFrequency,16), mapTagReplacements);
|
||||
projectileParticleSystemNode->addAttribute("trajectoryFrequency",doubleToStr(trajectoryFrequency,10), mapTagReplacements);
|
||||
}
|
||||
|
||||
void ProjectileParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||
|
@ -2160,10 +2145,10 @@ void SplashParticleSystem::update() {
|
|||
ParticleSystem::update();
|
||||
if(state != sPause) {
|
||||
emissionRate -= emissionRateFade;
|
||||
emissionRate = truncateDecimal<double>(emissionRate,16);
|
||||
emissionRate = truncateDecimal<double>(emissionRate,10);
|
||||
|
||||
double t = 1.0f - ((emissionRate + startEmissionRate) / (startEmissionRate * 2.0f));
|
||||
t = truncateDecimal<double>(t,16);
|
||||
t = truncateDecimal<double>(t,10);
|
||||
|
||||
t= clamp(t, 0.0f, 1.0f);
|
||||
setTween(t,t);
|
||||
|
@ -2186,14 +2171,14 @@ void SplashParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
+ horizontalSpreadB);
|
||||
p->speed.normalize();
|
||||
p->speed= p->speed * speed;
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
|
||||
p->accel= Vec3d(0.0f, -gravity, 0.0f);
|
||||
p->accel.x = truncateDecimal<double>(p->accel.x,16);
|
||||
p->accel.y = truncateDecimal<double>(p->accel.y,16);
|
||||
p->accel.z = truncateDecimal<double>(p->accel.z,16);
|
||||
p->accel.x = truncateDecimal<double>(p->accel.x,10);
|
||||
p->accel.y = truncateDecimal<double>(p->accel.y,10);
|
||||
p->accel.z = truncateDecimal<double>(p->accel.z,10);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2202,19 +2187,19 @@ void SplashParticleSystem::updateParticle(Particle *p){
|
|||
|
||||
p->lastPos= p->pos;
|
||||
p->pos= p->pos + p->speed;
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,16);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,16);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,16);
|
||||
p->pos.x = truncateDecimal<double>(p->pos.x,10);
|
||||
p->pos.y = truncateDecimal<double>(p->pos.y,10);
|
||||
p->pos.z = truncateDecimal<double>(p->pos.z,10);
|
||||
|
||||
p->speed= p->speed + p->accel;
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,16);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,16);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,16);
|
||||
p->speed.x = truncateDecimal<double>(p->speed.x,10);
|
||||
p->speed.y = truncateDecimal<double>(p->speed.y,10);
|
||||
p->speed.z = truncateDecimal<double>(p->speed.z,10);
|
||||
|
||||
p->energy--;
|
||||
p->color= color * energyRatio + colorNoEnergy * (1.0f - energyRatio);
|
||||
p->size= particleSize * energyRatio + sizeNoEnergy * (1.0f - energyRatio);
|
||||
p->size = truncateDecimal<double>(p->size,16);
|
||||
p->size = truncateDecimal<double>(p->size,10);
|
||||
}
|
||||
|
||||
void SplashParticleSystem::saveGame(XmlNode *rootNode) {
|
||||
|
@ -2229,18 +2214,18 @@ void SplashParticleSystem::saveGame(XmlNode *rootNode) {
|
|||
}
|
||||
|
||||
// float emissionRateFade;
|
||||
splashParticleSystemNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,16), mapTagReplacements);
|
||||
splashParticleSystemNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,10), mapTagReplacements);
|
||||
// float verticalSpreadA;
|
||||
splashParticleSystemNode->addAttribute("verticalSpreadA",doubleToStr(verticalSpreadA,16), mapTagReplacements);
|
||||
splashParticleSystemNode->addAttribute("verticalSpreadA",doubleToStr(verticalSpreadA,10), mapTagReplacements);
|
||||
// float verticalSpreadB;
|
||||
splashParticleSystemNode->addAttribute("verticalSpreadB",doubleToStr(verticalSpreadB,16), mapTagReplacements);
|
||||
splashParticleSystemNode->addAttribute("verticalSpreadB",doubleToStr(verticalSpreadB,10), mapTagReplacements);
|
||||
// float horizontalSpreadA;
|
||||
splashParticleSystemNode->addAttribute("horizontalSpreadA",doubleToStr(horizontalSpreadA,16), mapTagReplacements);
|
||||
splashParticleSystemNode->addAttribute("horizontalSpreadA",doubleToStr(horizontalSpreadA,10), mapTagReplacements);
|
||||
// float horizontalSpreadB;
|
||||
splashParticleSystemNode->addAttribute("horizontalSpreadB",doubleToStr(horizontalSpreadB,16), mapTagReplacements);
|
||||
splashParticleSystemNode->addAttribute("horizontalSpreadB",doubleToStr(horizontalSpreadB,10), mapTagReplacements);
|
||||
//
|
||||
// float startEmissionRate;
|
||||
splashParticleSystemNode->addAttribute("startEmissionRate",doubleToStr(startEmissionRate,16), mapTagReplacements);
|
||||
splashParticleSystemNode->addAttribute("startEmissionRate",doubleToStr(startEmissionRate,10), mapTagReplacements);
|
||||
}
|
||||
|
||||
void SplashParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||
|
|
|
@ -519,7 +519,7 @@ void Properties::setBool(const string &key, bool value){
|
|||
}
|
||||
|
||||
void Properties::setFloat(const string &key, float value){
|
||||
setString(key, floatToStr(value,16));
|
||||
setString(key, floatToStr(value,10));
|
||||
}
|
||||
|
||||
void Properties::setString(const string &key, const string &value){
|
||||
|
|
|
@ -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),16));
|
||||
int res= min + static_cast<int>(truncateDecimal<double>(numerator / static_cast<double>(m),10));
|
||||
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,16);
|
||||
res = truncateDecimal<double>(res,10);
|
||||
|
||||
if(res < min || res > max) {
|
||||
char szBuf[8096]="";
|
||||
|
|
Loading…
Reference in New Issue