revert most doubles back to float and truncate at 6 decimals

This commit is contained in:
Mark Vejvoda
2013-10-03 00:17:51 +00:00
parent 0eeb526e27
commit 9e60723296
22 changed files with 202 additions and 191 deletions

View File

@@ -109,7 +109,7 @@ void ParticleRendererGl::renderSystem(ParticleSystem *ps){
for(int i=0; i<ps->getAliveParticleCount(); ++i){
const Particle *particle= ps->getParticle(i);
float size= particle->getSize()/2.0f;
Vec3f pos= Vec3f(particle->getPos());
Vec3f pos= particle->getPos();
Vec4f color= particle->getColor();
vertexBuffer[bufferIndex] = pos - (rightVector - upVector) * size;
@@ -159,8 +159,8 @@ void ParticleRendererGl::renderSystemLine(ParticleSystem *ps){
particle= ps->getParticle(i);
Vec4f color= particle->getColor();
vertexBuffer[bufferIndex] = Vec3f(particle->getPos());
vertexBuffer[bufferIndex+1] = Vec3f(particle->getLastPos());
vertexBuffer[bufferIndex] = particle->getPos();
vertexBuffer[bufferIndex+1] = particle->getLastPos();
colorBuffer[bufferIndex]= color;
colorBuffer[bufferIndex+1]= color;
@@ -203,8 +203,8 @@ void ParticleRendererGl::renderSystemLineAlpha(ParticleSystem *ps){
particle= ps->getParticle(i);
Vec4f color= particle->getColor();
vertexBuffer[bufferIndex] = Vec3f(particle->getPos());
vertexBuffer[bufferIndex+1] = Vec3f(particle->getLastPos());
vertexBuffer[bufferIndex] = particle->getPos();
vertexBuffer[bufferIndex+1] = particle->getLastPos();
colorBuffer[bufferIndex]= color;
colorBuffer[bufferIndex+1]= color;
@@ -236,11 +236,11 @@ void ParticleRendererGl::renderModel(GameParticleSystem *ps, ModelRenderer *mr){
glPushMatrix();
//translate
Vec3f pos= Vec3f(ps->getPos());
Vec3f pos= ps->getPos();
glTranslatef(pos.x, pos.y, pos.z);
//rotate
Vec3f direction= Vec3f(ps->getDirection());
Vec3f direction= ps->getDirection();
Vec3f flatDirection= Vec3f(direction.x, 0.f, direction.z);
Vec3f rotVector= Vec3f(0.f, 1.f, 0.f).cross(flatDirection);

View File

@@ -80,8 +80,8 @@ 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),6));
float numerator = static_cast<float>(diff + 1) * static_cast<float>(RandomGen::rand(lastCaller));
int res= min + static_cast<int>(truncateDecimal<float>(numerator / static_cast<float>(m),6));
if(res < min || res > max) {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d] res < min || res > max, min = %d, max = %d, res = %d",__FILE__,__FUNCTION__,__LINE__,min,max,res);
@@ -93,16 +93,16 @@ int RandomGen::randRange(int min, int max,string lastCaller) {
return res;
}
double RandomGen::randRange(double min, double max,string lastCaller) {
float RandomGen::randRange(float min, float max,string lastCaller) {
if(min > max) {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d] min > max, min = %f, max = %f",__FILE__,__FUNCTION__,__LINE__,min,max);
throw megaglest_runtime_error(szBuf);
}
double rand01 = static_cast<double>(RandomGen::rand(lastCaller)) / (m-1);
double res= min + (max - min) * rand01;
res = truncateDecimal<double>(res,6);
float rand01 = static_cast<float>(RandomGen::rand(lastCaller)) / (m-1);
float res= min + (max - min) * rand01;
res = truncateDecimal<float>(res,6);
if(res < min || res > max) {
char szBuf[8096]="";

View File

@@ -710,7 +710,7 @@ void copyStringToBuffer(char *buffer, int bufferSize, const string& s){
// ==================== numeric fcs ====================
double saturate(double value) {
float saturate(float value) {
if (value < 0.f){
return 0.f;
}
@@ -740,7 +740,7 @@ int64 clamp(int64 value, int64 min, int64 max){
return value;
}
double clamp(double value, double min, double max) {
float clamp(float value, float min, float max) {
if (value < min) {
return min;
}
@@ -750,7 +750,7 @@ double clamp(double value, double min, double max) {
return value;
}
int round(double f){
int round(float f){
return (int) f;
}