Fixed int/double old-style casts
This commit is contained in:
parent
b51ce3426d
commit
e9fcd6b2a5
38 changed files with 184 additions and 183 deletions
|
@ -53,23 +53,23 @@ unsigned int Color::to32BitABGR() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Color Color::from32BitRGBA(unsigned int col) {
|
Color Color::from32BitRGBA(unsigned int col) {
|
||||||
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
return Color((to_double(col & 0x000000FF)) / 255.0, (to_double((col & 0x0000FF00) >> 8)) / 255.0,
|
||||||
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
(to_double((col & 0x00FF0000) >> 16)) / 255.0, (to_double((col & 0xFF000000) >> 24)) / 255.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color Color::from32BitBGRA(unsigned int col) {
|
Color Color::from32BitBGRA(unsigned int col) {
|
||||||
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
return Color((to_double(col & 0x000000FF)) / 255.0, (to_double((col & 0x0000FF00) >> 8)) / 255.0,
|
||||||
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
(to_double((col & 0x00FF0000) >> 16)) / 255.0, (to_double((col & 0xFF000000) >> 24)) / 255.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color Color::from32BitARGB(unsigned int col) {
|
Color Color::from32BitARGB(unsigned int col) {
|
||||||
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
return Color((to_double(col & 0x000000FF)) / 255.0, (to_double((col & 0x0000FF00) >> 8)) / 255.0,
|
||||||
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
(to_double((col & 0x00FF0000) >> 16)) / 255.0, (to_double((col & 0xFF000000) >> 24)) / 255.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color Color::from32BitABGR(unsigned int col) {
|
Color Color::from32BitABGR(unsigned int col) {
|
||||||
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
return Color((to_double(col & 0x000000FF)) / 255.0, (to_double((col & 0x0000FF00) >> 8)) / 255.0,
|
||||||
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
(to_double((col & 0x00FF0000) >> 16)) / 255.0, (to_double((col & 0xFF000000) >> 24)) / 255.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Color::mask(const Color &mask) {
|
void Color::mask(const Color &mask) {
|
||||||
|
|
|
@ -53,13 +53,13 @@ void ColorProfile::setToneMapping(ToneMappingOperator tonemapper, double exposur
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorProfile::save(PackStream *stream) const {
|
void ColorProfile::save(PackStream *stream) const {
|
||||||
int imapper = (int)mapper;
|
int imapper = trunc_to_int(mapper);
|
||||||
stream->write(&imapper);
|
stream->write(&imapper);
|
||||||
stream->write(&exposure);
|
stream->write(&exposure);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorProfile::load(PackStream *stream) {
|
void ColorProfile::load(PackStream *stream) {
|
||||||
int imapper = (int)mapper;
|
int imapper = trunc_to_int(mapper);
|
||||||
stream->read(&imapper);
|
stream->read(&imapper);
|
||||||
stream->read(&exposure);
|
stream->read(&exposure);
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,9 @@ static double g1[B + B + 2];
|
||||||
|
|
||||||
#define setup(i, b0, b1, r0, r1) \
|
#define setup(i, b0, b1, r0, r1) \
|
||||||
t = vec[i] + N; \
|
t = vec[i] + N; \
|
||||||
b0 = ((int)t) & BM; \
|
b0 = trunc_to_int(t) & BM; \
|
||||||
b1 = (b0 + 1) & BM; \
|
b1 = (b0 + 1) & BM; \
|
||||||
r0 = t - (int)t; \
|
r0 = t - trunc_to_int(t); \
|
||||||
r1 = r0 - 1.;
|
r1 = r0 - 1.;
|
||||||
|
|
||||||
double noisePerlinGet1DValue(double x) {
|
double noisePerlinGet1DValue(double x) {
|
||||||
|
@ -165,14 +165,14 @@ static int noisePerlinInit(void) {
|
||||||
for (i = 0; i < B; i++) {
|
for (i = 0; i < B; i++) {
|
||||||
p[i] = i;
|
p[i] = i;
|
||||||
|
|
||||||
g1[i] = (double)((rand() % (B + B)) - B) / B;
|
g1[i] = to_double((rand() % (B + B)) - B) / B;
|
||||||
|
|
||||||
for (j = 0; j < 2; j++)
|
for (j = 0; j < 2; j++)
|
||||||
g2[i][j] = (double)((rand() % (B + B)) - B) / B;
|
g2[i][j] = to_double((rand() % (B + B)) - B) / B;
|
||||||
_normalize2(g2[i]);
|
_normalize2(g2[i]);
|
||||||
|
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
g3[i][j] = (double)((rand() % (B + B)) - B) / B;
|
g3[i][j] = to_double((rand() % (B + B)) - B) / B;
|
||||||
_normalize3(g3[i]);
|
_normalize3(g3[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ static double _F4;
|
||||||
static double _G4;
|
static double _G4;
|
||||||
|
|
||||||
static inline int _fastfloor(double x) {
|
static inline int _fastfloor(double x) {
|
||||||
int xi = (int)x;
|
int xi = trunc_to_int(x);
|
||||||
return x < xi ? xi - 1 : xi;
|
return x < xi ? xi - 1 : xi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,7 +487,7 @@ const Texture2D *NoiseFunctionSimplex::getValueTexture() {
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
for (int z = 0; z < height; z++) {
|
for (int z = 0; z < height; z++) {
|
||||||
double val = noiseSimplexGet2DValue((double)x, (double)z);
|
double val = noiseSimplexGet2DValue(to_double(x), to_double(z));
|
||||||
_valueTexture->setPixel(x, z, Color(val, val, val));
|
_valueTexture->setPixel(x, z, Color(val, val, val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -507,9 +507,9 @@ const Texture2D *NoiseFunctionSimplex::getNormalTexture() {
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
for (int z = 0; z < height; z++) {
|
for (int z = 0; z < height; z++) {
|
||||||
double vcenter = noiseSimplexGet2DValue(0.01 * (double)x, 0.01 * (double)z);
|
double vcenter = noiseSimplexGet2DValue(0.01 * to_double(x), 0.01 * to_double(z));
|
||||||
double vsouth = noiseSimplexGet2DValue(0.01 * (double)x, 0.01 * (double)z + 0.001);
|
double vsouth = noiseSimplexGet2DValue(0.01 * to_double(x), 0.01 * to_double(z) + 0.001);
|
||||||
double veast = noiseSimplexGet2DValue(0.01 * (double)x + 0.001, 0.01 * (double)z);
|
double veast = noiseSimplexGet2DValue(0.01 * to_double(x) + 0.001, 0.01 * to_double(z));
|
||||||
|
|
||||||
Vector3 normal = Geometry::getNormalFromTriangle(Vector3(0.0, vcenter, 0.0), Vector3(0.0, vsouth, 0.01),
|
Vector3 normal = Geometry::getNormalFromTriangle(Vector3(0.0, vcenter, 0.0), Vector3(0.0, vsouth, 0.01),
|
||||||
Vector3(0.01, veast, 0.0));
|
Vector3(0.01, veast, 0.0));
|
||||||
|
|
|
@ -30,7 +30,7 @@ NoiseGenerator::~NoiseGenerator() {
|
||||||
void NoiseGenerator::save(PackStream *stream) const {
|
void NoiseGenerator::save(PackStream *stream) const {
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
x = (int)function.algorithm;
|
x = static_cast<int>(function.algorithm);
|
||||||
stream->write(&x);
|
stream->write(&x);
|
||||||
stream->write(&function.ridge_factor);
|
stream->write(&function.ridge_factor);
|
||||||
stream->write(&function.curve_factor);
|
stream->write(&function.curve_factor);
|
||||||
|
@ -53,7 +53,7 @@ void NoiseGenerator::load(PackStream *stream) {
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
stream->read(&x);
|
stream->read(&x);
|
||||||
function.algorithm = (NoiseFunctionAlgorithm)x;
|
function.algorithm = static_cast<NoiseFunctionAlgorithm>(x);
|
||||||
stream->read(&function.ridge_factor);
|
stream->read(&function.ridge_factor);
|
||||||
stream->read(&function.curve_factor);
|
stream->read(&function.curve_factor);
|
||||||
|
|
||||||
|
|
|
@ -99,18 +99,18 @@ bool SpaceSegment::iterateOnGrid(SpaceGridIterator &delegate) {
|
||||||
int stepX = diff.x < 0.0 ? -1 : 1;
|
int stepX = diff.x < 0.0 ? -1 : 1;
|
||||||
int stepY = diff.y < 0.0 ? -1 : 1;
|
int stepY = diff.y < 0.0 ? -1 : 1;
|
||||||
int stepZ = diff.z < 0.0 ? -1 : 1;
|
int stepZ = diff.z < 0.0 ? -1 : 1;
|
||||||
int X = (int)floor(start.x);
|
int X = floor_to_int(start.x);
|
||||||
int Y = (int)floor(start.y);
|
int Y = floor_to_int(start.y);
|
||||||
int Z = (int)floor(start.z);
|
int Z = floor_to_int(start.z);
|
||||||
int limitX = (int)floor(end.x) + stepX;
|
int limitX = floor_to_int(end.x) + stepX;
|
||||||
int limitY = (int)floor(end.y) + stepY;
|
int limitY = floor_to_int(end.y) + stepY;
|
||||||
int limitZ = (int)floor(end.z) + stepZ;
|
int limitZ = floor_to_int(end.z) + stepZ;
|
||||||
double tDeltaX = diff.x == 0.0 ? 0.0 : 1.0 / fabs(diff.x);
|
double tDeltaX = diff.x == 0.0 ? 0.0 : 1.0 / fabs(diff.x);
|
||||||
double tDeltaY = diff.y == 0.0 ? 0.0 : 1.0 / fabs(diff.y);
|
double tDeltaY = diff.y == 0.0 ? 0.0 : 1.0 / fabs(diff.y);
|
||||||
double tDeltaZ = diff.z == 0.0 ? 0.0 : 1.0 / fabs(diff.z);
|
double tDeltaZ = diff.z == 0.0 ? 0.0 : 1.0 / fabs(diff.z);
|
||||||
double tMaxX = diff.x == 0.0 ? INFINITY : ((double)(X + (stepX > 0 ? 1 : 0)) - start.x) / diff.x;
|
double tMaxX = diff.x == 0.0 ? INFINITY : (to_double(X + (stepX > 0 ? 1 : 0)) - start.x) / diff.x;
|
||||||
double tMaxY = diff.y == 0.0 ? INFINITY : ((double)(Y + (stepY > 0 ? 1 : 0)) - start.y) / diff.y;
|
double tMaxY = diff.y == 0.0 ? INFINITY : (to_double(Y + (stepY > 0 ? 1 : 0)) - start.y) / diff.y;
|
||||||
double tMaxZ = diff.z == 0.0 ? INFINITY : ((double)(Z + (stepZ > 0 ? 1 : 0)) - start.z) / diff.z;
|
double tMaxZ = diff.z == 0.0 ? INFINITY : (to_double(Z + (stepZ > 0 ? 1 : 0)) - start.z) / diff.z;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (not delegate.onCell(X, Y, Z)) {
|
if (not delegate.onCell(X, Y, Z)) {
|
||||||
|
|
|
@ -47,8 +47,8 @@ Color Texture2D::getNearest(double dx, double dy) const {
|
||||||
if (dy > 1.0)
|
if (dy > 1.0)
|
||||||
dy = 1.0;
|
dy = 1.0;
|
||||||
|
|
||||||
int ix = (int)(dx * (double)(this->xsize - 1));
|
int ix = trunc_to_int(dx * to_double(this->xsize - 1));
|
||||||
int iy = (int)(dy * (double)(this->ysize - 1));
|
int iy = trunc_to_int(dy * to_double(this->ysize - 1));
|
||||||
|
|
||||||
assert(ix >= 0 && ix < this->xsize);
|
assert(ix >= 0 && ix < this->xsize);
|
||||||
assert(iy >= 0 && iy < this->ysize);
|
assert(iy >= 0 && iy < this->ysize);
|
||||||
|
@ -66,20 +66,20 @@ Color Texture2D::getLinear(double dx, double dy) const {
|
||||||
if (dy > 1.0)
|
if (dy > 1.0)
|
||||||
dy = 1.0;
|
dy = 1.0;
|
||||||
|
|
||||||
dx *= (double)(this->xsize - 1);
|
dx *= to_double(this->xsize - 1);
|
||||||
dy *= (double)(this->ysize - 1);
|
dy *= to_double(this->ysize - 1);
|
||||||
|
|
||||||
int ix = (int)floor(dx);
|
int ix = floor_to_int(dx);
|
||||||
if (ix == this->xsize - 1) {
|
if (ix == this->xsize - 1) {
|
||||||
ix--;
|
ix--;
|
||||||
}
|
}
|
||||||
int iy = (int)floor(dy);
|
int iy = floor_to_int(dy);
|
||||||
if (iy == this->ysize - 1) {
|
if (iy == this->ysize - 1) {
|
||||||
iy--;
|
iy--;
|
||||||
}
|
}
|
||||||
|
|
||||||
dx -= (double)ix;
|
dx -= to_double(ix);
|
||||||
dy -= (double)iy;
|
dy -= to_double(iy);
|
||||||
|
|
||||||
Color *data = this->data + iy * this->xsize + ix;
|
Color *data = this->data + iy * this->xsize + ix;
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,9 @@ Color Texture3D::getNearest(double dx, double dy, double dz) const {
|
||||||
if (dz > 1.0)
|
if (dz > 1.0)
|
||||||
dz = 1.0;
|
dz = 1.0;
|
||||||
|
|
||||||
int ix = (int)(dx * (double)(this->xsize - 1));
|
int ix = trunc_to_int(dx * to_double(this->xsize - 1));
|
||||||
int iy = (int)(dy * (double)(this->ysize - 1));
|
int iy = trunc_to_int(dy * to_double(this->ysize - 1));
|
||||||
int iz = (int)(dz * (double)(this->zsize - 1));
|
int iz = trunc_to_int(dz * to_double(this->zsize - 1));
|
||||||
|
|
||||||
assert(ix >= 0 && ix < this->xsize);
|
assert(ix >= 0 && ix < this->xsize);
|
||||||
assert(iy >= 0 && iy < this->ysize);
|
assert(iy >= 0 && iy < this->ysize);
|
||||||
|
@ -80,26 +80,26 @@ Color Texture3D::getLinear(double dx, double dy, double dz) const {
|
||||||
if (dz > 1.0)
|
if (dz > 1.0)
|
||||||
dz = 1.0;
|
dz = 1.0;
|
||||||
|
|
||||||
dx *= (double)(this->xsize - 1);
|
dx *= to_double(this->xsize - 1);
|
||||||
dy *= (double)(this->ysize - 1);
|
dy *= to_double(this->ysize - 1);
|
||||||
dz *= (double)(this->zsize - 1);
|
dz *= to_double(this->zsize - 1);
|
||||||
|
|
||||||
int ix = (int)floor(dx);
|
int ix = floor_to_int(dx);
|
||||||
if (ix == this->xsize - 1) {
|
if (ix == this->xsize - 1) {
|
||||||
ix--;
|
ix--;
|
||||||
}
|
}
|
||||||
int iy = (int)floor(dy);
|
int iy = floor_to_int(dy);
|
||||||
if (iy == this->ysize - 1) {
|
if (iy == this->ysize - 1) {
|
||||||
iy--;
|
iy--;
|
||||||
}
|
}
|
||||||
int iz = (int)floor(dz);
|
int iz = floor_to_int(dz);
|
||||||
if (iz == this->zsize - 1) {
|
if (iz == this->zsize - 1) {
|
||||||
iz--;
|
iz--;
|
||||||
}
|
}
|
||||||
|
|
||||||
dx -= (double)ix;
|
dx -= to_double(ix);
|
||||||
dy -= (double)iy;
|
dy -= to_double(iy);
|
||||||
dz -= (double)iz;
|
dz -= to_double(iz);
|
||||||
|
|
||||||
Color *data = this->data + iz * this->xsize * this->ysize + iy * this->xsize + ix;
|
Color *data = this->data + iz * this->xsize * this->ysize + iy * this->xsize + ix;
|
||||||
|
|
||||||
|
|
|
@ -64,10 +64,10 @@ Color Texture4D::getNearest(double dx, double dy, double dz, double dw) const {
|
||||||
if (dw > 1.0)
|
if (dw > 1.0)
|
||||||
dw = 1.0;
|
dw = 1.0;
|
||||||
|
|
||||||
int ix = (int)(dx * (double)(this->xsize - 1));
|
int ix = trunc_to_int(dx * to_double(this->xsize - 1));
|
||||||
int iy = (int)(dy * (double)(this->ysize - 1));
|
int iy = trunc_to_int(dy * to_double(this->ysize - 1));
|
||||||
int iz = (int)(dz * (double)(this->zsize - 1));
|
int iz = trunc_to_int(dz * to_double(this->zsize - 1));
|
||||||
int iw = (int)(dw * (double)(this->wsize - 1));
|
int iw = trunc_to_int(dw * to_double(this->wsize - 1));
|
||||||
|
|
||||||
assert(ix >= 0 && ix < this->xsize);
|
assert(ix >= 0 && ix < this->xsize);
|
||||||
assert(iy >= 0 && iy < this->ysize);
|
assert(iy >= 0 && iy < this->ysize);
|
||||||
|
@ -96,32 +96,32 @@ Color Texture4D::getLinear(double dx, double dy, double dz, double dw) const {
|
||||||
if (dw > 1.0)
|
if (dw > 1.0)
|
||||||
dw = 1.0;
|
dw = 1.0;
|
||||||
|
|
||||||
dx *= (double)(this->xsize - 1);
|
dx *= to_double(this->xsize - 1);
|
||||||
dy *= (double)(this->ysize - 1);
|
dy *= to_double(this->ysize - 1);
|
||||||
dz *= (double)(this->zsize - 1);
|
dz *= to_double(this->zsize - 1);
|
||||||
dw *= (double)(this->wsize - 1);
|
dw *= to_double(this->wsize - 1);
|
||||||
|
|
||||||
int ix = (int)floor(dx);
|
int ix = floor_to_int(dx);
|
||||||
if (ix == this->xsize - 1) {
|
if (ix == this->xsize - 1) {
|
||||||
ix--;
|
ix--;
|
||||||
}
|
}
|
||||||
int iy = (int)floor(dy);
|
int iy = floor_to_int(dy);
|
||||||
if (iy == this->ysize - 1) {
|
if (iy == this->ysize - 1) {
|
||||||
iy--;
|
iy--;
|
||||||
}
|
}
|
||||||
int iz = (int)floor(dz);
|
int iz = floor_to_int(dz);
|
||||||
if (iz == this->zsize - 1) {
|
if (iz == this->zsize - 1) {
|
||||||
iz--;
|
iz--;
|
||||||
}
|
}
|
||||||
int iw = (int)floor(dw);
|
int iw = floor_to_int(dw);
|
||||||
if (iw == this->wsize - 1) {
|
if (iw == this->wsize - 1) {
|
||||||
iw--;
|
iw--;
|
||||||
}
|
}
|
||||||
|
|
||||||
dx -= (double)ix;
|
dx -= to_double(ix);
|
||||||
dy -= (double)iy;
|
dy -= to_double(iy);
|
||||||
dz -= (double)iz;
|
dz -= to_double(iz);
|
||||||
dw -= (double)iw;
|
dw -= to_double(iw);
|
||||||
|
|
||||||
Color *data = this->data + iw * this->xsize * this->ysize * this->zsize + iz * this->xsize * this->ysize +
|
Color *data = this->data + iw * this->xsize * this->ysize * this->zsize + iz * this->xsize * this->ysize +
|
||||||
iy * this->xsize + ix;
|
iy * this->xsize + ix;
|
||||||
|
|
|
@ -84,7 +84,7 @@ void AtmosphereDefinition::setDayTime(double value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtmosphereDefinition::setDayTime(int hour, int minute, int second) {
|
void AtmosphereDefinition::setDayTime(int hour, int minute, int second) {
|
||||||
setDayTime((double)hour / 24.0 + (double)minute / 1440.0 + (double)second / 86400.0);
|
setDayTime(to_double(hour) / 24.0 + to_double(minute) / 1440.0 + to_double(second) / 86400.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtmosphereDefinition::getHMS(int *hour, int *minute, int *second) const {
|
void AtmosphereDefinition::getHMS(int *hour, int *minute, int *second) const {
|
||||||
|
|
|
@ -179,8 +179,8 @@ void CameraDefinition::rotateRoll(double value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraDefinition::setRenderSize(int width, int height) {
|
void CameraDefinition::setRenderSize(int width, int height) {
|
||||||
this->width = (double)width;
|
this->width = to_double(width);
|
||||||
this->height = (double)height;
|
this->height = to_double(height);
|
||||||
perspective.xratio = this->width / this->height;
|
perspective.xratio = this->width / this->height;
|
||||||
|
|
||||||
validate();
|
validate();
|
||||||
|
@ -236,7 +236,7 @@ int CameraDefinition::isProjectedBoxInView(const BoundingBox &box) const {
|
||||||
double dx = box.xmax - box.xmin;
|
double dx = box.xmax - box.xmin;
|
||||||
double dy = box.ymax - box.ymin;
|
double dy = box.ymax - box.ymin;
|
||||||
|
|
||||||
return (int)ceil(dx) * (int)ceil(dy);
|
return ceil_to_int(dx) * ceil_to_int(dy);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ CloudLayerDefinition *CloudLayerDefinition::newCopy(DefinitionNode *parent) cons
|
||||||
void CloudLayerDefinition::save(PackStream *stream) const {
|
void CloudLayerDefinition::save(PackStream *stream) const {
|
||||||
DefinitionNode::save(stream);
|
DefinitionNode::save(stream);
|
||||||
|
|
||||||
int clouds_type = (int)type;
|
int clouds_type = static_cast<int>(type);
|
||||||
|
|
||||||
stream->write(&clouds_type);
|
stream->write(&clouds_type);
|
||||||
stream->write(&altitude);
|
stream->write(&altitude);
|
||||||
|
@ -51,7 +51,7 @@ void CloudLayerDefinition::load(PackStream *stream) {
|
||||||
int clouds_type;
|
int clouds_type;
|
||||||
|
|
||||||
stream->read(&clouds_type);
|
stream->read(&clouds_type);
|
||||||
type = (CloudsType)clouds_type;
|
type = static_cast<CloudsType>(clouds_type);
|
||||||
stream->read(&altitude);
|
stream->read(&altitude);
|
||||||
stream->read(&scaling);
|
stream->read(&scaling);
|
||||||
stream->read(&coverage);
|
stream->read(&coverage);
|
||||||
|
|
|
@ -142,7 +142,7 @@ int DefinitionNode::getWatcherCount() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefinitionNode::save(PackStream *stream) const {
|
void DefinitionNode::save(PackStream *stream) const {
|
||||||
int children_count = (int)children.size();
|
int children_count = static_cast<int>(children.size());
|
||||||
stream->write(&children_count);
|
stream->write(&children_count);
|
||||||
|
|
||||||
for (auto child : children) {
|
for (auto child : children) {
|
||||||
|
|
|
@ -15,12 +15,12 @@ Layers::~Layers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layers::save(PackStream *stream) const {
|
void Layers::save(PackStream *stream) const {
|
||||||
int layer_count = (int)layers.size();
|
int layer_count = static_cast<int>(layers.size());
|
||||||
stream->write(&layer_count);
|
stream->write(&layer_count);
|
||||||
|
|
||||||
for (int i = 0; i < layer_count; i++) {
|
for (auto &layer: layers) {
|
||||||
stream->write(layers[i]->getName());
|
stream->write(layer->getName());
|
||||||
layers[i]->save(stream);
|
layer->save(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,8 @@ bool PaintedGrid::getInterpolatedValue(double x, double y, double *result) const
|
||||||
int xlow;
|
int xlow;
|
||||||
int ylow;
|
int ylow;
|
||||||
|
|
||||||
xlow = floor(x);
|
xlow = floor_to_int(x);
|
||||||
ylow = floor(y);
|
ylow = floor_to_int(y);
|
||||||
|
|
||||||
int hit = 0;
|
int hit = 0;
|
||||||
for (ix = xlow - 1; ix <= xlow + 2 && !hit; ix++) {
|
for (ix = xlow - 1; ix <= xlow + 2 && !hit; ix++) {
|
||||||
|
@ -62,7 +62,7 @@ bool PaintedGrid::getInterpolatedValue(double x, double y, double *result) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*result = Interpolation::bicubic(stencil, x - (double)xlow, y - (double)ylow);
|
*result = Interpolation::bicubic(stencil, x - to_double(xlow), y - to_double(ylow));
|
||||||
}
|
}
|
||||||
|
|
||||||
return hit;
|
return hit;
|
||||||
|
@ -121,9 +121,9 @@ void PaintedGrid::applyBrush(const PaintedGridBrush &brush, double x, double y,
|
||||||
double dx, dy, influence;
|
double dx, dy, influence;
|
||||||
|
|
||||||
for (ix = xstart; ix <= xend; ix++) {
|
for (ix = xstart; ix <= xend; ix++) {
|
||||||
dx = (double)ix;
|
dx = to_double(ix);
|
||||||
for (iy = ystart; iy <= yend; iy++) {
|
for (iy = ystart; iy <= yend; iy++) {
|
||||||
dy = (double)iy;
|
dy = to_double(iy);
|
||||||
|
|
||||||
influence = brush.getInfluence(x - dx, y - dy);
|
influence = brush.getInfluence(x - dx, y - dy);
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ PaintedGridBrush::PaintedGridBrush(double hard_radius, double smoothed_size, dou
|
||||||
void PaintedGridBrush::getArea(double x, double y, int *xstart, int *ystart, int *xend, int *yend) const {
|
void PaintedGridBrush::getArea(double x, double y, int *xstart, int *ystart, int *xend, int *yend) const {
|
||||||
double s = smoothed_size + hard_radius;
|
double s = smoothed_size + hard_radius;
|
||||||
|
|
||||||
*xstart = (int)floor(x - s);
|
*xstart = floor_to_int(x - s);
|
||||||
*xend = (int)ceil(x + s);
|
*xend = ceil_to_int(x + s);
|
||||||
*ystart = (int)floor(y - s);
|
*ystart = floor_to_int(y - s);
|
||||||
*yend = (int)ceil(y + s);
|
*yend = ceil_to_int(y + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
double PaintedGridBrush::getInfluence(double dx, double dy) const {
|
double PaintedGridBrush::getInfluence(double dx, double dy) const {
|
||||||
|
|
|
@ -37,8 +37,8 @@ void Scenery::validate() {
|
||||||
|
|
||||||
Scenery::FileOperationResult Scenery::saveGlobal(const string &filepath) const {
|
Scenery::FileOperationResult Scenery::saveGlobal(const string &filepath) const {
|
||||||
PackStream stream;
|
PackStream stream;
|
||||||
double app_header = (double)APP_HEADER;
|
double app_header = to_double(APP_HEADER);
|
||||||
double version_header = (double)DATA_VERSION;
|
double version_header = to_double(DATA_VERSION);
|
||||||
|
|
||||||
if (not stream.bindToFile(filepath, true)) {
|
if (not stream.bindToFile(filepath, true)) {
|
||||||
return FILE_OPERATION_IOERROR;
|
return FILE_OPERATION_IOERROR;
|
||||||
|
|
|
@ -74,7 +74,7 @@ double TerrainDefinition::getGridHeight(int x, int z, bool with_painting) {
|
||||||
double h;
|
double h;
|
||||||
|
|
||||||
if (!with_painting || !has_painting || !height_map->getGridValue(x, z, &h)) {
|
if (!with_painting || !has_painting || !height_map->getGridValue(x, z, &h)) {
|
||||||
h = _height_noise->get2DTotal((double)x, (double)z);
|
h = _height_noise->get2DTotal(to_double(x), to_double(z));
|
||||||
}
|
}
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
|
|
|
@ -115,7 +115,7 @@ static void addBranchRecurse(RandomGenerator &random, vector<CappedCylinder> &br
|
||||||
Vector3 new_direction = pivot1.multPoint(direction);
|
Vector3 new_direction = pivot1.multPoint(direction);
|
||||||
for (int i = 0; i < split_count; i++) {
|
for (int i = 0; i < split_count; i++) {
|
||||||
Matrix4 pivot2 =
|
Matrix4 pivot2 =
|
||||||
Matrix4::newRotateAxis(randomizeValue(random, M_PI * 2.0 / (double)split_count, 0.9, 1.1), direction);
|
Matrix4::newRotateAxis(randomizeValue(random, M_PI * 2.0 / to_double(split_count), 0.9, 1.1), direction);
|
||||||
new_direction = pivot2.multPoint(new_direction);
|
new_direction = pivot2.multPoint(new_direction);
|
||||||
|
|
||||||
Vector3 new_base = base.add(direction.scale(randomizeValue(random, length, 0.4, 1.0)));
|
Vector3 new_base = base.add(direction.scale(randomizeValue(random, length, 0.4, 1.0)));
|
||||||
|
|
|
@ -84,7 +84,7 @@ static void testGroundShadowQuality() {
|
||||||
renderer.setQuality(0.2);
|
renderer.setQuality(0.2);
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
// TODO keep same rasterization across renders
|
// TODO keep same rasterization across renders
|
||||||
renderer.getTerrainRenderer()->setQuality((double)i / 5.0);
|
renderer.getTerrainRenderer()->setQuality(to_double(i) / 5.0);
|
||||||
startTestRender(&renderer, "ground_shadow_quality", i);
|
startTestRender(&renderer, "ground_shadow_quality", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ static void testRasterizationQuality() {
|
||||||
renderer.setSize(800, 600);
|
renderer.setSize(800, 600);
|
||||||
renderer.enablePostprocess(false);
|
renderer.enablePostprocess(false);
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
renderer.setQuality((double)i / 5.0);
|
renderer.setQuality(to_double(i) / 5.0);
|
||||||
startTestRender(&renderer, "rasterization_quality", i);
|
startTestRender(&renderer, "rasterization_quality", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ static void testCloudQuality() {
|
||||||
SkyRasterizer rasterizer(&renderer, renderer.getProgressHelper(), 0);
|
SkyRasterizer rasterizer(&renderer, renderer.getProgressHelper(), 0);
|
||||||
renderer.setSoloRasterizer(&rasterizer);
|
renderer.setSoloRasterizer(&rasterizer);
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
renderer.setQuality((double)i / 5.0);
|
renderer.setQuality(to_double(i) / 5.0);
|
||||||
rasterizer.setQuality(0.2);
|
rasterizer.setQuality(0.2);
|
||||||
startTestRender(&renderer, "cloud_quality", i);
|
startTestRender(&renderer, "cloud_quality", i);
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ static void testGodRays() {
|
||||||
|
|
||||||
// quality
|
// quality
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
renderer.setQuality((double)i / 5.0);
|
renderer.setQuality(to_double(i) / 5.0);
|
||||||
rasterizer.setQuality(0.2);
|
rasterizer.setQuality(0.2);
|
||||||
startTestRender(&renderer, "god_rays_quality", i);
|
startTestRender(&renderer, "god_rays_quality", i);
|
||||||
}
|
}
|
||||||
|
@ -175,21 +175,21 @@ static void testGodRays() {
|
||||||
|
|
||||||
// penetration
|
// penetration
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
scenery.getAtmosphere()->childGodRays()->propPenetration()->setValue(0.01 + 0.02 * (double)i);
|
scenery.getAtmosphere()->childGodRays()->propPenetration()->setValue(0.01 + 0.02 * to_double(i));
|
||||||
startTestRender(&renderer, "god_rays_penetration", i);
|
startTestRender(&renderer, "god_rays_penetration", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// resistance
|
// resistance
|
||||||
scenery.getAtmosphere()->childGodRays()->propPenetration()->setValue(0.01);
|
scenery.getAtmosphere()->childGodRays()->propPenetration()->setValue(0.01);
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
scenery.getAtmosphere()->childGodRays()->propResistance()->setValue(0.1 + 0.1 * (double)i);
|
scenery.getAtmosphere()->childGodRays()->propResistance()->setValue(0.1 + 0.1 * to_double(i));
|
||||||
startTestRender(&renderer, "god_rays_resistance", i);
|
startTestRender(&renderer, "god_rays_resistance", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
scenery.getAtmosphere()->childGodRays()->propResistance()->setValue(0.3);
|
scenery.getAtmosphere()->childGodRays()->propResistance()->setValue(0.3);
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
scenery.getAtmosphere()->childGodRays()->propBoost()->setValue(2.0 + 4.0 * (double)i);
|
scenery.getAtmosphere()->childGodRays()->propBoost()->setValue(2.0 + 4.0 * to_double(i));
|
||||||
startTestRender(&renderer, "god_rays_boost", i);
|
startTestRender(&renderer, "god_rays_boost", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ static void testSunNearHorizon() {
|
||||||
renderer.setQuality(0.3);
|
renderer.setQuality(0.3);
|
||||||
|
|
||||||
for (int i = 0; i <= 20; i++) {
|
for (int i = 0; i <= 20; i++) {
|
||||||
scenery.getAtmosphere()->propDayTime()->setValue(0.24 + 0.001 * (double)i);
|
scenery.getAtmosphere()->propDayTime()->setValue(0.24 + 0.001 * to_double(i));
|
||||||
startTestRender(&renderer, "sun_near_horizon", i);
|
startTestRender(&renderer, "sun_near_horizon", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ void OpenGLView::wheelEvent(QWheelEvent *event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
double factor = getSpeedFactor(event);
|
double factor = getSpeedFactor(event);
|
||||||
window->getCamera()->processZoom(0.01 * factor * (double)event->angleDelta().y());
|
window->getCamera()->processZoom(0.01 * factor * to_double(event->angleDelta().y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLView::mousePressEvent(QMouseEvent *event) {
|
void OpenGLView::mousePressEvent(QMouseEvent *event) {
|
||||||
|
|
|
@ -77,12 +77,12 @@ void OpenGLTerrain::initialize() {
|
||||||
// Add terrain chunks
|
// Add terrain chunks
|
||||||
int chunks = 12;
|
int chunks = 12;
|
||||||
double size = 800.0;
|
double size = 800.0;
|
||||||
double chunksize = size / (double)chunks;
|
double chunksize = size / to_double(chunks);
|
||||||
double start = -size / 2.0;
|
double start = -size / 2.0;
|
||||||
for (int i = 0; i < chunks; i++) {
|
for (int i = 0; i < chunks; i++) {
|
||||||
for (int j = 0; j < chunks; j++) {
|
for (int j = 0; j < chunks; j++) {
|
||||||
OpenGLTerrainChunk *chunk = new OpenGLTerrainChunk(renderer, start + chunksize * (double)i,
|
OpenGLTerrainChunk *chunk = new OpenGLTerrainChunk(renderer, start + chunksize * to_double(i),
|
||||||
start + chunksize * (double)j, chunksize, chunks);
|
start + chunksize * to_double(j), chunksize, chunks);
|
||||||
pv->chunks.push_back(chunk);
|
pv->chunks.push_back(chunk);
|
||||||
pv->queue.push_back(chunk);
|
pv->queue.push_back(chunk);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ OpenGLTerrainChunk::OpenGLTerrainChunk(OpenGLRenderer *renderer, double x, doubl
|
||||||
_startx = x;
|
_startx = x;
|
||||||
_startz = z;
|
_startz = z;
|
||||||
_size = size;
|
_size = size;
|
||||||
_overall_step = size * (double)nbchunks;
|
_overall_step = size * to_double(nbchunks);
|
||||||
|
|
||||||
distance_to_camera = 0.0;
|
distance_to_camera = 0.0;
|
||||||
|
|
||||||
|
@ -91,12 +91,12 @@ bool OpenGLTerrainChunk::maintain() {
|
||||||
int new_texture_size = _texture_current_size ? _texture_current_size * 2 : 1;
|
int new_texture_size = _texture_current_size ? _texture_current_size * 2 : 1;
|
||||||
QImage *new_image = new QImage(_texture->scaled(new_texture_size + 1, new_texture_size + 1,
|
QImage *new_image = new QImage(_texture->scaled(new_texture_size + 1, new_texture_size + 1,
|
||||||
Qt::IgnoreAspectRatio, Qt::FastTransformation));
|
Qt::IgnoreAspectRatio, Qt::FastTransformation));
|
||||||
double factor = _size / (double)new_texture_size;
|
double factor = _size / to_double(new_texture_size);
|
||||||
for (int j = 0; j <= new_texture_size; j++) {
|
for (int j = 0; j <= new_texture_size; j++) {
|
||||||
for (int i = 0; i <= new_texture_size; i++) {
|
for (int i = 0; i <= new_texture_size; i++) {
|
||||||
if (_texture_current_size <= 1 || i % 2 != 0 || j % 2 != 0) {
|
if (_texture_current_size <= 1 || i % 2 != 0 || j % 2 != 0) {
|
||||||
double x = _startx + factor * (double)i;
|
double x = _startx + factor * to_double(i);
|
||||||
double z = _startz + factor * (double)j;
|
double z = _startz + factor * to_double(j);
|
||||||
Color color = _renderer->getTexturesRenderer()->applyToTerrain(x, z).final_color;
|
Color color = _renderer->getTexturesRenderer()->applyToTerrain(x, z).final_color;
|
||||||
color.normalize();
|
color.normalize();
|
||||||
new_image->setPixel(i, j, color.to32BitRGBA());
|
new_image->setPixel(i, j, color.to32BitRGBA());
|
||||||
|
@ -159,7 +159,7 @@ void OpenGLTerrainChunk::updatePriority(CameraDefinition *camera) {
|
||||||
// Update priority
|
// Update priority
|
||||||
if (_reset_topology || _reset_texture || (_texture_max_size > 1 && _texture_current_size <= 1) ||
|
if (_reset_topology || _reset_texture || (_texture_max_size > 1 && _texture_current_size <= 1) ||
|
||||||
vertices_level < 8) {
|
vertices_level < 8) {
|
||||||
priority = 1000.0 - (double)vertices_level;
|
priority = 1000.0 - to_double(vertices_level);
|
||||||
} else if (_texture_current_size == _texture_wanted_size) {
|
} else if (_texture_current_size == _texture_wanted_size) {
|
||||||
priority = -1000.0;
|
priority = -1000.0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -213,14 +213,14 @@ void OpenGLTerrainChunk::augmentVertices() {
|
||||||
int next_vertices_level = vertices_level * 2;
|
int next_vertices_level = vertices_level * 2;
|
||||||
|
|
||||||
// TODO Re-use existing vertices from previous level when possible
|
// TODO Re-use existing vertices from previous level when possible
|
||||||
double quad_size = _size / (double)next_vertices_level;
|
double quad_size = _size / to_double(next_vertices_level);
|
||||||
for (int iz = 0; iz < next_vertices_level; iz++) {
|
for (int iz = 0; iz < next_vertices_level; iz++) {
|
||||||
if (interrupt or _reset_topology) {
|
if (interrupt or _reset_topology) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int ix = 0; ix < next_vertices_level; ix++) {
|
for (int ix = 0; ix < next_vertices_level; ix++) {
|
||||||
fillVerticesFromSquare(&next, (iz * next_vertices_level + ix) * 6, _startx + quad_size * (double)ix,
|
fillVerticesFromSquare(&next, (iz * next_vertices_level + ix) * 6, _startx + quad_size * to_double(ix),
|
||||||
_startz + quad_size * (double)iz, quad_size);
|
_startz + quad_size * to_double(iz), quad_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ static inline Matrix4 matrixForIndex(int index) {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return Matrix4::newRotateZ(M_PI_2);
|
return Matrix4::newRotateZ(M_PI_2);
|
||||||
} else if (index < 6) {
|
} else if (index < 6) {
|
||||||
return Matrix4::newRotateY(M_2PI * (double)(index - 1) * 0.2).mult(Matrix4::newRotateZ(M_PI_4));
|
return Matrix4::newRotateY(M_2PI * to_double(index - 1) * 0.2).mult(Matrix4::newRotateZ(M_PI_4));
|
||||||
} else {
|
} else {
|
||||||
return Matrix4::newRotateY(M_2PI * (double)(index - 6) * 0.1);
|
return Matrix4::newRotateY(M_2PI * to_double(index - 6) * 0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,9 +92,9 @@ void OpenGLVegetationImpostor::prepareTexture(const VegetationModelDefinition &m
|
||||||
int starty = py * partsize;
|
int starty = py * partsize;
|
||||||
|
|
||||||
for (int x = 0; x < partsize; x++) {
|
for (int x = 0; x < partsize; x++) {
|
||||||
double dx = (double)x / (double)partsize;
|
double dx = to_double(x) / to_double(partsize);
|
||||||
for (int y = 0; y < partsize; y++) {
|
for (int y = 0; y < partsize; y++) {
|
||||||
double dy = (double)y / (double)partsize;
|
double dy = to_double(y) / to_double(partsize);
|
||||||
|
|
||||||
Vector3 near(5.0, dy - 0.5, -(dx - 0.5));
|
Vector3 near(5.0, dy - 0.5, -(dx - 0.5));
|
||||||
Vector3 far(-5.0, dy - 0.5, -(dx - 0.5));
|
Vector3 far(-5.0, dy - 0.5, -(dx - 0.5));
|
||||||
|
@ -122,10 +122,10 @@ int OpenGLVegetationImpostor::getIndex(const Vector3 &camera, const Vector3 &ins
|
||||||
double angle = diff.phi / M_2PI;
|
double angle = diff.phi / M_2PI;
|
||||||
if (diff.theta > 0.4) {
|
if (diff.theta > 0.4) {
|
||||||
angle = (angle >= 0.9) ? 0.0 : (angle + 0.1);
|
angle = (angle >= 0.9) ? 0.0 : (angle + 0.1);
|
||||||
return 1 + (int)(5.0 * angle);
|
return 1 + trunc_to_int(5.0 * angle);
|
||||||
} else {
|
} else {
|
||||||
angle = (angle >= 0.95) ? 0.0 : (angle + 0.05);
|
angle = (angle >= 0.95) ? 0.0 : (angle + 0.05);
|
||||||
return 6 + (int)(10.0 * angle);
|
return 6 + trunc_to_int(10.0 * angle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ void OpenGLVegetationImpostor::setVertex(int i, float u, float v) {
|
||||||
Matrix4 rotation = matrixForIndex(index);
|
Matrix4 rotation = matrixForIndex(index);
|
||||||
|
|
||||||
Vector3 vertex = rotation.multPoint(Vector3(1.0, u, -(v - 0.5)));
|
Vector3 vertex = rotation.multPoint(Vector3(1.0, u, -(v - 0.5)));
|
||||||
vertices->set(index * 4 + i, vertex, (u + (double)px) / (double)parts, (v + (double)py) / (double)parts);
|
vertices->set(index * 4 + i, vertex, (u + to_double(px)) / to_double(parts), (v + to_double(py)) / to_double(parts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,13 +179,13 @@ static Color _texture4D(Texture4D *tex, double r, double mu, double muS, double
|
||||||
double rho = sqrt(r * r - Rg * Rg);
|
double rho = sqrt(r * r - Rg * Rg);
|
||||||
double rmu = r * mu;
|
double rmu = r * mu;
|
||||||
double delta = rmu * rmu - r * r + Rg * Rg;
|
double delta = rmu * rmu - r * r + Rg * Rg;
|
||||||
Color cst = (rmu < 0.0 && delta > 0.0) ? vec4(1.0, 0.0, 0.0, 0.5 - 0.5 / (double)(RES_MU))
|
Color cst = (rmu < 0.0 && delta > 0.0) ? vec4(1.0, 0.0, 0.0, 0.5 - 0.5 / to_double(RES_MU))
|
||||||
: vec4(-1.0, H * H, H, 0.5 + 0.5 / (double)(RES_MU));
|
: vec4(-1.0, H * H, H, 0.5 + 0.5 / to_double(RES_MU));
|
||||||
double uR = 0.5 / (double)(RES_R) + rho / H * (1.0 - 1.0 / (double)(RES_R));
|
double uR = 0.5 / to_double(RES_R) + rho / H * (1.0 - 1.0 / to_double(RES_R));
|
||||||
double uMu = cst.a + (rmu * cst.r + sqrt(delta + cst.g)) / (rho + cst.b) * (0.5 - 1.0 / (double)(RES_MU));
|
double uMu = cst.a + (rmu * cst.r + sqrt(delta + cst.g)) / (rho + cst.b) * (0.5 - 1.0 / to_double(RES_MU));
|
||||||
double uMuS =
|
double uMuS =
|
||||||
0.5 / (double)(RES_MU_S) +
|
0.5 / to_double(RES_MU_S) +
|
||||||
(atan(max(muS, -0.1975) * tan(1.26 * 1.1)) / 1.1 + (1.0 - 0.26)) * 0.5 * (1.0 - 1.0 / (double)(RES_MU_S));
|
(atan(max(muS, -0.1975) * tan(1.26 * 1.1)) / 1.1 + (1.0 - 0.26)) * 0.5 * (1.0 - 1.0 / to_double(RES_MU_S));
|
||||||
|
|
||||||
return tex->getLinear(uMu, uMuS, nu, uR);
|
return tex->getLinear(uMu, uMuS, nu, uR);
|
||||||
}
|
}
|
||||||
|
@ -311,9 +311,9 @@ static void _texCoordToMuMuSNu(double x, double y, double z, double r, Color dhd
|
||||||
double *nu) {
|
double *nu) {
|
||||||
double d;
|
double d;
|
||||||
|
|
||||||
x /= (double)RES_MU;
|
x /= to_double(RES_MU);
|
||||||
y /= (double)RES_MU_S;
|
y /= to_double(RES_MU_S);
|
||||||
z /= (double)RES_NU;
|
z /= to_double(RES_NU);
|
||||||
|
|
||||||
if (x < 0.5) {
|
if (x < 0.5) {
|
||||||
d = 1.0 - x / 0.5;
|
d = 1.0 - x / 0.5;
|
||||||
|
@ -349,11 +349,11 @@ static void _getTransmittanceRMu(double x, double y, double *r, double *muS) {
|
||||||
|
|
||||||
static double _opticalDepthTransmittance(double H, double r, double mu) {
|
static double _opticalDepthTransmittance(double H, double r, double mu) {
|
||||||
double result = 0.0;
|
double result = 0.0;
|
||||||
double dx = _limit(r, mu) / (double)TRANSMITTANCE_INTEGRAL_SAMPLES;
|
double dx = _limit(r, mu) / to_double(TRANSMITTANCE_INTEGRAL_SAMPLES);
|
||||||
double yi = exp(-(r - Rg) / H);
|
double yi = exp(-(r - Rg) / H);
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; i <= TRANSMITTANCE_INTEGRAL_SAMPLES; ++i) {
|
for (i = 1; i <= TRANSMITTANCE_INTEGRAL_SAMPLES; ++i) {
|
||||||
double xj = (double)i * dx;
|
double xj = to_double(i) * dx;
|
||||||
double yj = exp(-(sqrt(r * r + xj * xj + 2.0 * xj * r * mu) - Rg) / H);
|
double yj = exp(-(sqrt(r * r + xj * xj + 2.0 * xj * r * mu) - Rg) / H);
|
||||||
result += (yi + yj) / 2.0 * dx;
|
result += (yi + yj) / 2.0 * dx;
|
||||||
yi = yj;
|
yi = yj;
|
||||||
|
@ -367,7 +367,7 @@ static void _precomputeTransmittanceTexture() {
|
||||||
for (x = 0; x < TRANSMITTANCE_W; x++) {
|
for (x = 0; x < TRANSMITTANCE_W; x++) {
|
||||||
for (y = 0; y < TRANSMITTANCE_H; y++) {
|
for (y = 0; y < TRANSMITTANCE_H; y++) {
|
||||||
double r, muS;
|
double r, muS;
|
||||||
_getTransmittanceRMu((double)(x + 0.5) / TRANSMITTANCE_W, (double)(y + 0.5) / TRANSMITTANCE_H, &r, &muS);
|
_getTransmittanceRMu(to_double(x + 0.5) / TRANSMITTANCE_W, to_double(y + 0.5) / TRANSMITTANCE_H, &r, &muS);
|
||||||
double depth1 = _opticalDepthTransmittance(HR, r, muS);
|
double depth1 = _opticalDepthTransmittance(HR, r, muS);
|
||||||
double depth2 = _opticalDepthTransmittance(HM, r, muS);
|
double depth2 = _opticalDepthTransmittance(HM, r, muS);
|
||||||
Color trans;
|
Color trans;
|
||||||
|
@ -390,7 +390,7 @@ static void _precomputeIrrDeltaETexture(Texture2D *destination) {
|
||||||
for (y = 0; y < SKY_H; y++) {
|
for (y = 0; y < SKY_H; y++) {
|
||||||
double r, muS;
|
double r, muS;
|
||||||
Color trans, irr;
|
Color trans, irr;
|
||||||
_getIrradianceRMuS((double)x / SKY_W, (double)y / SKY_H, &r, &muS);
|
_getIrradianceRMuS(to_double(x) / SKY_W, to_double(y) / SKY_H, &r, &muS);
|
||||||
trans = _transmittance(r, muS);
|
trans = _transmittance(r, muS);
|
||||||
|
|
||||||
irr.r = trans.r * max(muS, 0.0);
|
irr.r = trans.r * max(muS, 0.0);
|
||||||
|
@ -446,13 +446,13 @@ static void _integrand1(double r, double mu, double muS, double nu, double t, Co
|
||||||
static void _inscatter1(double r, double mu, double muS, double nu, Color *ray, Color *mie) {
|
static void _inscatter1(double r, double mu, double muS, double nu, Color *ray, Color *mie) {
|
||||||
ray->r = ray->g = ray->b = 0.0;
|
ray->r = ray->g = ray->b = 0.0;
|
||||||
mie->r = mie->g = mie->b = 0.0;
|
mie->r = mie->g = mie->b = 0.0;
|
||||||
double dx = _limit(r, mu) / (double)(INSCATTER_INTEGRAL_SAMPLES);
|
double dx = _limit(r, mu) / to_double(INSCATTER_INTEGRAL_SAMPLES);
|
||||||
Color rayi;
|
Color rayi;
|
||||||
Color miei;
|
Color miei;
|
||||||
_integrand1(r, mu, muS, nu, 0.0, &rayi, &miei);
|
_integrand1(r, mu, muS, nu, 0.0, &rayi, &miei);
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; i <= INSCATTER_INTEGRAL_SAMPLES; ++i) {
|
for (i = 1; i <= INSCATTER_INTEGRAL_SAMPLES; ++i) {
|
||||||
double xj = (double)(i)*dx;
|
double xj = to_double(i)*dx;
|
||||||
Color rayj;
|
Color rayj;
|
||||||
Color miej;
|
Color miej;
|
||||||
_integrand1(r, mu, muS, nu, xj, &rayj, &miej);
|
_integrand1(r, mu, muS, nu, xj, &rayj, &miej);
|
||||||
|
@ -492,7 +492,7 @@ static int _inscatter1Worker(ParallelWork *, int layer, void *data) {
|
||||||
Color ray = COLOR_BLACK;
|
Color ray = COLOR_BLACK;
|
||||||
Color mie = COLOR_BLACK;
|
Color mie = COLOR_BLACK;
|
||||||
double mu, muS, nu;
|
double mu, muS, nu;
|
||||||
_texCoordToMuMuSNu((double)x, (double)y, (double)z, r, dhdH, &mu, &muS, &nu);
|
_texCoordToMuMuSNu(to_double(x), to_double(y), to_double(z), r, dhdH, &mu, &muS, &nu);
|
||||||
_inscatter1(r, mu, muS, nu, &ray, &mie);
|
_inscatter1(r, mu, muS, nu, &ray, &mie);
|
||||||
/* store separately Rayleigh and Mie contributions, WITHOUT the phase function factor
|
/* store separately Rayleigh and Mie contributions, WITHOUT the phase function factor
|
||||||
* (cf "Angular precision") */
|
* (cf "Angular precision") */
|
||||||
|
@ -510,8 +510,8 @@ static Color _inscatterS(double r, double mu, double muS, double nu, int first,
|
||||||
Texture4D *deltaSM) {
|
Texture4D *deltaSM) {
|
||||||
Color raymie = COLOR_BLACK;
|
Color raymie = COLOR_BLACK;
|
||||||
|
|
||||||
double dphi = M_PI / (double)(INSCATTER_SPHERICAL_INTEGRAL_SAMPLES);
|
double dphi = M_PI / to_double(INSCATTER_SPHERICAL_INTEGRAL_SAMPLES);
|
||||||
double dtheta = M_PI / (double)(INSCATTER_SPHERICAL_INTEGRAL_SAMPLES);
|
double dtheta = M_PI / to_double(INSCATTER_SPHERICAL_INTEGRAL_SAMPLES);
|
||||||
|
|
||||||
r = clamp(r, Rg, Rt);
|
r = clamp(r, Rg, Rt);
|
||||||
mu = clamp(mu, -1.0, 1.0);
|
mu = clamp(mu, -1.0, 1.0);
|
||||||
|
@ -528,7 +528,7 @@ static Color _inscatterS(double r, double mu, double muS, double nu, int first,
|
||||||
/* integral over 4.PI around x with two nested loops over w directions (theta,phi) -- Eq (7) */
|
/* integral over 4.PI around x with two nested loops over w directions (theta,phi) -- Eq (7) */
|
||||||
int itheta;
|
int itheta;
|
||||||
for (itheta = 0; itheta < INSCATTER_SPHERICAL_INTEGRAL_SAMPLES; ++itheta) {
|
for (itheta = 0; itheta < INSCATTER_SPHERICAL_INTEGRAL_SAMPLES; ++itheta) {
|
||||||
double theta = ((double)(itheta) + 0.5) * dtheta;
|
double theta = (to_double(itheta) + 0.5) * dtheta;
|
||||||
double ctheta = cos(theta);
|
double ctheta = cos(theta);
|
||||||
|
|
||||||
double greflectance = 0.0;
|
double greflectance = 0.0;
|
||||||
|
@ -544,7 +544,7 @@ static Color _inscatterS(double r, double mu, double muS, double nu, int first,
|
||||||
|
|
||||||
int iphi;
|
int iphi;
|
||||||
for (iphi = 0; iphi < 2 * INSCATTER_SPHERICAL_INTEGRAL_SAMPLES; ++iphi) {
|
for (iphi = 0; iphi < 2 * INSCATTER_SPHERICAL_INTEGRAL_SAMPLES; ++iphi) {
|
||||||
double phi = ((double)(iphi) + 0.5) * dphi;
|
double phi = (to_double(iphi) + 0.5) * dphi;
|
||||||
double dw = dtheta * dphi * sin(theta);
|
double dw = dtheta * dphi * sin(theta);
|
||||||
Vector3 w = vec3(cos(phi) * sin(theta), sin(phi) * sin(theta), ctheta);
|
Vector3 w = vec3(cos(phi) * sin(theta), sin(phi) * sin(theta), ctheta);
|
||||||
|
|
||||||
|
@ -619,7 +619,7 @@ static int _jWorker(ParallelWork *, int layer, void *data) {
|
||||||
for (z = 0; z < RES_NU; z++) {
|
for (z = 0; z < RES_NU; z++) {
|
||||||
Color raymie;
|
Color raymie;
|
||||||
double mu, muS, nu;
|
double mu, muS, nu;
|
||||||
_texCoordToMuMuSNu((double)x, (double)y, (double)z, r, dhdH, &mu, &muS, &nu);
|
_texCoordToMuMuSNu(to_double(x), to_double(y), to_double(z), r, dhdH, &mu, &muS, &nu);
|
||||||
raymie = _inscatterS(r, mu, muS, nu, params->first, params->deltaE, params->deltaSR, params->deltaSM);
|
raymie = _inscatterS(r, mu, muS, nu, params->first, params->deltaE, params->deltaSR, params->deltaSM);
|
||||||
params->result->setPixel(x, y, z, layer, raymie);
|
params->result->setPixel(x, y, z, layer, raymie);
|
||||||
}
|
}
|
||||||
|
@ -632,22 +632,22 @@ static int _jWorker(ParallelWork *, int layer, void *data) {
|
||||||
|
|
||||||
void _irradianceNProg(Texture2D *destination, Texture4D *deltaSR, Texture4D *deltaSM, int first) {
|
void _irradianceNProg(Texture2D *destination, Texture4D *deltaSR, Texture4D *deltaSM, int first) {
|
||||||
int x, y;
|
int x, y;
|
||||||
double dphi = M_PI / (double)(IRRADIANCE_INTEGRAL_SAMPLES);
|
double dphi = M_PI / to_double(IRRADIANCE_INTEGRAL_SAMPLES);
|
||||||
double dtheta = M_PI / (double)(IRRADIANCE_INTEGRAL_SAMPLES);
|
double dtheta = M_PI / to_double(IRRADIANCE_INTEGRAL_SAMPLES);
|
||||||
for (x = 0; x < SKY_W; x++) {
|
for (x = 0; x < SKY_W; x++) {
|
||||||
for (y = 0; y < SKY_H; y++) {
|
for (y = 0; y < SKY_H; y++) {
|
||||||
double r, muS;
|
double r, muS;
|
||||||
int iphi;
|
int iphi;
|
||||||
_getIrradianceRMuS((double)x / SKY_W, (double)y / SKY_H, &r, &muS);
|
_getIrradianceRMuS(to_double(x) / SKY_W, to_double(y) / SKY_H, &r, &muS);
|
||||||
Vector3 s = vec3(max(sqrt(1.0 - muS * muS), 0.0), 0.0, muS);
|
Vector3 s = vec3(max(sqrt(1.0 - muS * muS), 0.0), 0.0, muS);
|
||||||
|
|
||||||
Color result = COLOR_BLACK;
|
Color result = COLOR_BLACK;
|
||||||
/* integral over 2.PI around x with two nested loops over w directions (theta,phi) -- Eq (15) */
|
/* integral over 2.PI around x with two nested loops over w directions (theta,phi) -- Eq (15) */
|
||||||
for (iphi = 0; iphi < 2 * IRRADIANCE_INTEGRAL_SAMPLES; ++iphi) {
|
for (iphi = 0; iphi < 2 * IRRADIANCE_INTEGRAL_SAMPLES; ++iphi) {
|
||||||
double phi = ((double)(iphi) + 0.5) * dphi;
|
double phi = (to_double(iphi) + 0.5) * dphi;
|
||||||
int itheta;
|
int itheta;
|
||||||
for (itheta = 0; itheta < IRRADIANCE_INTEGRAL_SAMPLES / 2; ++itheta) {
|
for (itheta = 0; itheta < IRRADIANCE_INTEGRAL_SAMPLES / 2; ++itheta) {
|
||||||
double theta = ((double)(itheta) + 0.5) * dtheta;
|
double theta = (to_double(itheta) + 0.5) * dtheta;
|
||||||
double dw = dtheta * dphi * sin(theta);
|
double dw = dtheta * dphi * sin(theta);
|
||||||
Vector3 w = vec3(cos(phi) * sin(theta), sin(phi) * sin(theta), cos(theta));
|
Vector3 w = vec3(cos(phi) * sin(theta), sin(phi) * sin(theta), cos(theta));
|
||||||
double nu = s.dotProduct(w);
|
double nu = s.dotProduct(w);
|
||||||
|
@ -698,11 +698,11 @@ static Color _integrand2(Texture4D *deltaJ, double r, double mu, double muS, dou
|
||||||
|
|
||||||
static Color _inscatterN(Texture4D *deltaJ, double r, double mu, double muS, double nu) {
|
static Color _inscatterN(Texture4D *deltaJ, double r, double mu, double muS, double nu) {
|
||||||
Color raymie = COLOR_BLACK;
|
Color raymie = COLOR_BLACK;
|
||||||
double dx = _limit(r, mu) / (double)(INSCATTER_INTEGRAL_SAMPLES);
|
double dx = _limit(r, mu) / to_double(INSCATTER_INTEGRAL_SAMPLES);
|
||||||
Color raymiei = _integrand2(deltaJ, r, mu, muS, nu, 0.0);
|
Color raymiei = _integrand2(deltaJ, r, mu, muS, nu, 0.0);
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; i <= INSCATTER_INTEGRAL_SAMPLES; ++i) {
|
for (i = 1; i <= INSCATTER_INTEGRAL_SAMPLES; ++i) {
|
||||||
double xj = (double)(i)*dx;
|
double xj = to_double(i)*dx;
|
||||||
Color raymiej = _integrand2(deltaJ, r, mu, muS, nu, xj);
|
Color raymiej = _integrand2(deltaJ, r, mu, muS, nu, xj);
|
||||||
raymie.r += (raymiei.r + raymiej.r) / 2.0 * dx;
|
raymie.r += (raymiei.r + raymiej.r) / 2.0 * dx;
|
||||||
raymie.g += (raymiei.g + raymiej.g) / 2.0 * dx;
|
raymie.g += (raymiei.g + raymiej.g) / 2.0 * dx;
|
||||||
|
@ -724,7 +724,7 @@ static int _inscatterNWorker(ParallelWork *, int layer, void *data) {
|
||||||
for (y = 0; y < RES_MU_S; y++) {
|
for (y = 0; y < RES_MU_S; y++) {
|
||||||
for (z = 0; z < RES_NU; z++) {
|
for (z = 0; z < RES_NU; z++) {
|
||||||
double mu, muS, nu;
|
double mu, muS, nu;
|
||||||
_texCoordToMuMuSNu((double)x, (double)y, (double)z, r, dhdH, &mu, &muS, &nu);
|
_texCoordToMuMuSNu(to_double(x), to_double(y), to_double(z), r, dhdH, &mu, &muS, &nu);
|
||||||
params->destination->setPixel(x, y, z, layer, _inscatterN(params->deltaJ, r, mu, muS, nu));
|
params->destination->setPixel(x, y, z, layer, _inscatterN(params->deltaJ, r, mu, muS, nu));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -751,7 +751,7 @@ static int _copyInscatterNWorker(ParallelWork *, int layer, void *data) {
|
||||||
for (y = 0; y < RES_MU_S; y++) {
|
for (y = 0; y < RES_MU_S; y++) {
|
||||||
for (z = 0; z < RES_NU; z++) {
|
for (z = 0; z < RES_NU; z++) {
|
||||||
double mu, muS, nu;
|
double mu, muS, nu;
|
||||||
_texCoordToMuMuSNu((double)x, (double)y, (double)z, r, dhdH, &mu, &muS, &nu);
|
_texCoordToMuMuSNu(to_double(x), to_double(y), to_double(z), r, dhdH, &mu, &muS, &nu);
|
||||||
Color col1 = params->source->getPixel(x, y, z, layer);
|
Color col1 = params->source->getPixel(x, y, z, layer);
|
||||||
Color col2 = params->destination->getPixel(x, y, z, layer);
|
Color col2 = params->destination->getPixel(x, y, z, layer);
|
||||||
col2.r += col1.r / _phaseFunctionR(nu);
|
col2.r += col1.r / _phaseFunctionR(nu);
|
||||||
|
|
|
@ -59,8 +59,8 @@ void CanvasPreview::setSize(int real_width, int real_height, int preview_width,
|
||||||
dirty_up = -1;
|
dirty_up = -1;
|
||||||
|
|
||||||
scaled = (real_width != preview_height or real_height != preview_height);
|
scaled = (real_width != preview_height or real_height != preview_height);
|
||||||
factor_x = (double)preview_width / (double)real_width;
|
factor_x = to_double(preview_width) / to_double(real_width);
|
||||||
factor_y = (double)preview_height / (double)real_height;
|
factor_y = to_double(preview_height) / to_double(real_height);
|
||||||
factor = factor_x * factor_y;
|
factor = factor_x * factor_y;
|
||||||
|
|
||||||
lock->release();
|
lock->release();
|
||||||
|
|
|
@ -16,8 +16,8 @@ int OverlayRasterizer::prepareRasterization() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayRasterizer::rasterizeToCanvas(CanvasPortion *canvas) {
|
void OverlayRasterizer::rasterizeToCanvas(CanvasPortion *canvas) {
|
||||||
double width = (double)renderer->render_camera->getWidth();
|
double width = to_double(renderer->render_camera->getWidth());
|
||||||
double height = (double)renderer->render_camera->getHeight();
|
double height = to_double(renderer->render_camera->getHeight());
|
||||||
Vector3 topleft = renderer->unprojectPoint(Vector3(height, 0.0, 1.0));
|
Vector3 topleft = renderer->unprojectPoint(Vector3(height, 0.0, 1.0));
|
||||||
Vector3 bottomleft = renderer->unprojectPoint(Vector3(0.0, 0.0, 1.0));
|
Vector3 bottomleft = renderer->unprojectPoint(Vector3(0.0, 0.0, 1.0));
|
||||||
Vector3 topright = renderer->unprojectPoint(Vector3(height, width, 1.0));
|
Vector3 topright = renderer->unprojectPoint(Vector3(height, width, 1.0));
|
||||||
|
@ -27,8 +27,8 @@ void OverlayRasterizer::rasterizeToCanvas(CanvasPortion *canvas) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Color OverlayRasterizer::shadeFragment(const CanvasFragment &fragment, const CanvasFragment *) const {
|
Color OverlayRasterizer::shadeFragment(const CanvasFragment &fragment, const CanvasFragment *) const {
|
||||||
double width = (double)renderer->render_camera->getWidth() - 1.0;
|
double width = to_double(renderer->render_camera->getWidth() - 1.0);
|
||||||
double height = (double)renderer->render_camera->getHeight() - 1.0;
|
double height = to_double(renderer->render_camera->getHeight() - 1.0);
|
||||||
double relx;
|
double relx;
|
||||||
double rely;
|
double rely;
|
||||||
double x = floor(fragment.getPixel().x);
|
double x = floor(fragment.getPixel().x);
|
||||||
|
@ -42,5 +42,5 @@ Color OverlayRasterizer::shadeFragment(const CanvasFragment &fragment, const Can
|
||||||
rely = 2.0 * ((y - (height - width) * 0.5) / height - 0.5);
|
rely = 2.0 * ((y - (height - width) * 0.5) / height - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
return processPixel((int)x, (int)y, relx, rely);
|
return processPixel(trunc_to_int(x), trunc_to_int(y), relx, rely);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,8 @@ bool Rasterizer::pushProjectedTriangle(CanvasPortion *canvas, const Vector3 &pix
|
||||||
const Vector3 &pixel3, const Vector3 &location1, const Vector3 &location2,
|
const Vector3 &pixel3, const Vector3 &location1, const Vector3 &location2,
|
||||||
const Vector3 &location3) {
|
const Vector3 &location3) {
|
||||||
ScanPoint point1, point2, point3;
|
ScanPoint point1, point2, point3;
|
||||||
double limit_width = (double)(canvas->getWidth() - 1);
|
double limit_width = to_double(canvas->getWidth() - 1);
|
||||||
double limit_height = (double)(canvas->getHeight() - 1);
|
double limit_height = to_double(canvas->getHeight() - 1);
|
||||||
|
|
||||||
Vector3 canvas_offset(canvas->getXOffset(), canvas->getYOffset(), 0.0);
|
Vector3 canvas_offset(canvas->getXOffset(), canvas->getYOffset(), 0.0);
|
||||||
Vector3 dpixel1 = pixel1.sub(canvas_offset);
|
Vector3 dpixel1 = pixel1.sub(canvas_offset);
|
||||||
|
@ -265,8 +265,8 @@ void Rasterizer::scanInterpolate(CameraDefinition *camera, ScanPoint *v1, ScanPo
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rasterizer::pushScanPoint(CanvasPortion *canvas, RenderScanlines *scanlines, ScanPoint *point) {
|
void Rasterizer::pushScanPoint(CanvasPortion *canvas, RenderScanlines *scanlines, ScanPoint *point) {
|
||||||
point->x = (int)floor(point->pixel.x);
|
point->x = floor_to_int(point->pixel.x);
|
||||||
point->y = (int)floor(point->pixel.y);
|
point->y = floor_to_int(point->pixel.y);
|
||||||
|
|
||||||
if (point->x < 0 || point->x >= canvas->getWidth()) {
|
if (point->x < 0 || point->x >= canvas->getWidth()) {
|
||||||
// Point outside scanline range
|
// Point outside scanline range
|
||||||
|
@ -332,7 +332,7 @@ void Rasterizer::pushScanLineEdge(CanvasPortion *canvas, RenderScanlines *scanli
|
||||||
dx = point2->pixel.x - point1->pixel.x;
|
dx = point2->pixel.x - point1->pixel.x;
|
||||||
scanGetDiff(point1, point2, &diff);
|
scanGetDiff(point1, point2, &diff);
|
||||||
for (curx = startx; curx <= endx; curx++) {
|
for (curx = startx; curx <= endx; curx++) {
|
||||||
fx = (double)curx + 0.5;
|
fx = to_double(curx) + 0.5;
|
||||||
if (fx < point1->pixel.x) {
|
if (fx < point1->pixel.x) {
|
||||||
fx = point1->pixel.x;
|
fx = point1->pixel.x;
|
||||||
} else if (fx > point2->pixel.x) {
|
} else if (fx > point2->pixel.x) {
|
||||||
|
@ -341,7 +341,7 @@ void Rasterizer::pushScanLineEdge(CanvasPortion *canvas, RenderScanlines *scanli
|
||||||
fx = fx - point1->pixel.x;
|
fx = fx - point1->pixel.x;
|
||||||
scanInterpolate(renderer->render_camera, point1, &diff, fx / dx, &point);
|
scanInterpolate(renderer->render_camera, point1, &diff, fx / dx, &point);
|
||||||
|
|
||||||
/*point.pixel.x = (double)curx;*/
|
/*point.pixel.x = to_double(curx);*/
|
||||||
|
|
||||||
pushScanPoint(canvas, scanlines, &point);
|
pushScanPoint(canvas, scanlines, &point);
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ void Rasterizer::renderScanLines(CanvasPortion *canvas, RenderScanlines *scanlin
|
||||||
// Down and up are the same
|
// Down and up are the same
|
||||||
current = down;
|
current = down;
|
||||||
} else {
|
} else {
|
||||||
fy = (double)cury + 0.5;
|
fy = to_double(cury) + 0.5;
|
||||||
if (fy < down.pixel.y) {
|
if (fy < down.pixel.y) {
|
||||||
fy = down.pixel.y;
|
fy = down.pixel.y;
|
||||||
} else if (fy > up.pixel.y) {
|
} else if (fy > up.pixel.y) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
RenderProgress::RenderProgress(int count) {
|
RenderProgress::RenderProgress(int count) {
|
||||||
lock = new Mutex();
|
lock = new Mutex();
|
||||||
global = 0.0;
|
global = 0.0;
|
||||||
step = 1.0 / (double)count;
|
step = 1.0 / to_double(count);
|
||||||
start_time = 0;
|
start_time = 0;
|
||||||
end_time = 0;
|
end_time = 0;
|
||||||
reset();
|
reset();
|
||||||
|
@ -37,7 +37,7 @@ void RenderProgress::reset() {
|
||||||
void RenderProgress::add(int value) {
|
void RenderProgress::add(int value) {
|
||||||
lock->acquire();
|
lock->acquire();
|
||||||
|
|
||||||
global += step * (double)value;
|
global += step * to_double(value);
|
||||||
|
|
||||||
lock->release();
|
lock->release();
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ void RenderProgress::enterSub(int count) {
|
||||||
lock->acquire();
|
lock->acquire();
|
||||||
|
|
||||||
subs.push(sub);
|
subs.push(sub);
|
||||||
step /= (double)count;
|
step /= to_double(count);
|
||||||
|
|
||||||
lock->release();
|
lock->release();
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ unsigned long RenderProgress::getDuration() const {
|
||||||
|
|
||||||
unsigned long RenderProgress::estimateRemainingTime() {
|
unsigned long RenderProgress::estimateRemainingTime() {
|
||||||
unsigned long spent = getDuration();
|
unsigned long spent = getDuration();
|
||||||
double speed = (global - prev_est_done) / (double)(spent - prev_est_spent);
|
double speed = (global - prev_est_done) / to_double(spent - prev_est_spent);
|
||||||
|
|
||||||
prev_est_speed = prev_est_speed ? (prev_est_speed * 0.8 + speed * 0.2) : speed;
|
prev_est_speed = prev_est_speed ? (prev_est_speed * 0.8 + speed * 0.2) : speed;
|
||||||
if (spent - prev_est_spent > 5000) {
|
if (spent - prev_est_spent > 5000) {
|
||||||
|
|
|
@ -29,8 +29,8 @@ void SkyRasterizer::rasterizeToCanvas(CanvasPortion *canvas) {
|
||||||
Vector3 vertex1, vertex2, vertex3, vertex4;
|
Vector3 vertex1, vertex2, vertex3, vertex4;
|
||||||
Vector3 camera_location, direction;
|
Vector3 camera_location, direction;
|
||||||
|
|
||||||
step_i = M_PI * 2.0 / (double)res_i;
|
step_i = M_PI * 2.0 / to_double(res_i);
|
||||||
step_j = M_PI / (double)res_j;
|
step_j = M_PI / to_double(res_j);
|
||||||
|
|
||||||
camera_location = renderer->getCameraLocation(VECTOR_ZERO);
|
camera_location = renderer->getCameraLocation(VECTOR_ZERO);
|
||||||
|
|
||||||
|
@ -39,10 +39,10 @@ void SkyRasterizer::rasterizeToCanvas(CanvasPortion *canvas) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_j = (double)(j - res_j / 2) * step_j;
|
current_j = to_double(j - res_j / 2) * step_j;
|
||||||
|
|
||||||
for (i = 0; i < res_i; i++) {
|
for (i = 0; i < res_i; i++) {
|
||||||
current_i = (double)i * step_i;
|
current_i = to_double(i) * step_i;
|
||||||
|
|
||||||
direction.x = SPHERE_SIZE * cos(current_i) * cos(current_j);
|
direction.x = SPHERE_SIZE * cos(current_i) * cos(current_j);
|
||||||
direction.y = SPHERE_SIZE * sin(current_j);
|
direction.y = SPHERE_SIZE * sin(current_j);
|
||||||
|
|
|
@ -65,7 +65,7 @@ double SoftwareCanvasRenderer::getProgress() const {
|
||||||
void SoftwareCanvasRenderer::setConfig(const RenderConfig &config) {
|
void SoftwareCanvasRenderer::setConfig(const RenderConfig &config) {
|
||||||
if (not started) {
|
if (not started) {
|
||||||
setSize(config.width, config.height, config.antialias);
|
setSize(config.width, config.height, config.antialias);
|
||||||
setQuality((double)(config.quality - 1) / 9.0);
|
setQuality(to_double(config.quality - 1) / 9.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ void SoftwareRenderer::setQuality(double quality) {
|
||||||
godrays->setQuality(quality);
|
godrays->setQuality(quality);
|
||||||
|
|
||||||
// TEMP compat with old code
|
// TEMP compat with old code
|
||||||
render_quality = (int)(quality * 9.0) + 1;
|
render_quality = trunc_to_int(quality * 9.0) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color SoftwareRenderer::applyLightingToSurface(const Vector3 &location, const Vector3 &normal,
|
Color SoftwareRenderer::applyLightingToSurface(const Vector3 &location, const Vector3 &normal,
|
||||||
|
@ -147,7 +147,7 @@ double SoftwareRenderer::getPrecision(const Vector3 &location) {
|
||||||
projected.x += 1.0;
|
projected.x += 1.0;
|
||||||
// projected.y += 1.0;
|
// projected.y += 1.0;
|
||||||
|
|
||||||
return render_camera->unproject(projected).sub(location).getNorm(); // / (double)render_quality;
|
return render_camera->unproject(projected).sub(location).getNorm(); // / to_double(render_quality);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 SoftwareRenderer::projectPoint(const Vector3 &point) {
|
Vector3 SoftwareRenderer::projectPoint(const Vector3 &point) {
|
||||||
|
|
|
@ -37,12 +37,12 @@ void TerrainRasterizer::tessellateChunk(CanvasPortion *canvas, TerrainChunkInfo
|
||||||
|
|
||||||
double startx = chunk->point_nw.x;
|
double startx = chunk->point_nw.x;
|
||||||
double startz = chunk->point_nw.z;
|
double startz = chunk->point_nw.z;
|
||||||
double size = (chunk->point_ne.x - chunk->point_nw.x) / (double)detail;
|
double size = (chunk->point_ne.x - chunk->point_nw.x) / to_double(detail);
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
for (i = 0; i < detail; i++) {
|
for (i = 0; i < detail; i++) {
|
||||||
for (j = 0; j < detail; j++) {
|
for (j = 0; j < detail; j++) {
|
||||||
renderQuad(canvas, startx + (double)i * size, startz + (double)j * size, size, water_height);
|
renderQuad(canvas, startx + to_double(i) * size, startz + to_double(j) * size, size, water_height);
|
||||||
}
|
}
|
||||||
progress->add(detail);
|
progress->add(detail);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ void TerrainRasterizer::getChunk(SoftwareRenderer *renderer, TerrainRasterizer::
|
||||||
|
|
||||||
int coverage = renderer->render_camera->isUnprojectedBoxInView(box);
|
int coverage = renderer->render_camera->isUnprojectedBoxInView(box);
|
||||||
if (coverage > 0) {
|
if (coverage > 0) {
|
||||||
chunk->detail_hint = (int)ceil(sqrt((double)coverage) * detail_factor);
|
chunk->detail_hint = ceil_to_int(sqrt(to_double(coverage)) * detail_factor);
|
||||||
if (chunk->detail_hint > max_chunk_detail) {
|
if (chunk->detail_hint > max_chunk_detail) {
|
||||||
chunk->detail_hint = max_chunk_detail;
|
chunk->detail_hint = max_chunk_detail;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ int TerrainRasterizer::performTessellation(CanvasPortion *canvas, bool displaced
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radius_int > 20.0 && chunk_count % 64 == 0 && (double)chunk_factor < radius_int / 20.0) {
|
if (radius_int > 20.0 && chunk_count % 64 == 0 && to_double(chunk_factor) < radius_int / 20.0) {
|
||||||
chunk_count /= 2;
|
chunk_count /= 2;
|
||||||
chunk_factor *= 2;
|
chunk_factor *= 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class VegetationGridIterator : public SpaceGridIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool onCell(int x, int, int z) override {
|
virtual bool onCell(int x, int, int z) override {
|
||||||
result = renderer->getBoundResult(segment, (double)x, (double)z, only_hit);
|
result = renderer->getBoundResult(segment, to_double(x), to_double(z), only_hit);
|
||||||
return not result.hit;
|
return not result.hit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ int WaterRasterizer::performTessellation(CanvasPortion *canvas) {
|
||||||
progress->add(chunk_count - 1);
|
progress->add(chunk_count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radius_int > 20.0 && chunk_count % 64 == 0 && (double)chunk_factor < radius_int / 20.0) {
|
if (radius_int > 20.0 && chunk_count % 64 == 0 && to_double(chunk_factor) < radius_int / 20.0) {
|
||||||
chunk_count /= 2;
|
chunk_count /= 2;
|
||||||
chunk_factor *= 2;
|
chunk_factor *= 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ using namespace std;
|
||||||
|
|
||||||
// Some useful casts
|
// Some useful casts
|
||||||
#define to_double(_x_) (static_cast<double>(_x_))
|
#define to_double(_x_) (static_cast<double>(_x_))
|
||||||
|
#define trunc_to_int(_x_) (static_cast<int>(_x_))
|
||||||
#define round_to_int(_x_) (static_cast<int>(round(_x_)))
|
#define round_to_int(_x_) (static_cast<int>(round(_x_)))
|
||||||
#define floor_to_int(_x_) (static_cast<int>(floor(_x_)))
|
#define floor_to_int(_x_) (static_cast<int>(floor(_x_)))
|
||||||
#define ceil_to_int(_x_) (static_cast<int>(ceil(_x_)))
|
#define ceil_to_int(_x_) (static_cast<int>(ceil(_x_)))
|
||||||
|
|
|
@ -10,13 +10,13 @@ TEST(CanvasPixel, MaxFragments) {
|
||||||
|
|
||||||
// Overflow max fragment count with transparent fragments
|
// Overflow max fragment count with transparent fragments
|
||||||
for (int i = 0; i < MAX_FRAGMENTS_PER_PIXEL * 2; i++) {
|
for (int i = 0; i < MAX_FRAGMENTS_PER_PIXEL * 2; i++) {
|
||||||
pixel.pushFragment(CanvasFragment(true, Vector3(0.0, 0.0, (double)i), Vector3(), 0, false));
|
pixel.pushFragment(CanvasFragment(true, Vector3(0.0, 0.0, to_double(i)), Vector3(), 0, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EQ(MAX_FRAGMENTS_PER_PIXEL, pixel.getFragmentCount());
|
ASSERT_EQ(MAX_FRAGMENTS_PER_PIXEL, pixel.getFragmentCount());
|
||||||
EXPECT_DOUBLE_EQ(pixel.getFragment(0).getZ(), 0.0);
|
EXPECT_DOUBLE_EQ(pixel.getFragment(0).getZ(), 0.0);
|
||||||
EXPECT_EQ(pixel.getFragment(0).getOpaque(), true);
|
EXPECT_EQ(pixel.getFragment(0).getOpaque(), true);
|
||||||
EXPECT_DOUBLE_EQ(pixel.getFragment(MAX_FRAGMENTS_PER_PIXEL - 1).getZ(), (double)(MAX_FRAGMENTS_PER_PIXEL * 2 - 1));
|
EXPECT_DOUBLE_EQ(pixel.getFragment(MAX_FRAGMENTS_PER_PIXEL - 1).getZ(), to_double(MAX_FRAGMENTS_PER_PIXEL * 2 - 1));
|
||||||
EXPECT_EQ(pixel.getFragment(MAX_FRAGMENTS_PER_PIXEL - 1).getOpaque(), false);
|
EXPECT_EQ(pixel.getFragment(MAX_FRAGMENTS_PER_PIXEL - 1).getOpaque(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ TEST(PackStream, All) {
|
||||||
data_i = i;
|
data_i = i;
|
||||||
stream->write(&data_i);
|
stream->write(&data_i);
|
||||||
|
|
||||||
data_d = (double)i;
|
data_d = to_double(i);
|
||||||
stream->write(&data_d);
|
stream->write(&data_d);
|
||||||
|
|
||||||
data_s = "Testing string 0123 (accentué) !";
|
data_s = "Testing string 0123 (accentué) !";
|
||||||
|
@ -35,7 +35,7 @@ TEST(PackStream, All) {
|
||||||
ASSERT_EQ(i, data_i);
|
ASSERT_EQ(i, data_i);
|
||||||
|
|
||||||
stream->read(&data_d);
|
stream->read(&data_d);
|
||||||
ASSERT_DOUBLE_EQ((double)i, data_d);
|
ASSERT_DOUBLE_EQ(to_double(i), data_d);
|
||||||
|
|
||||||
stream->read(buffer, 100);
|
stream->read(buffer, 100);
|
||||||
ASSERT_STREQ("Testing string 0123 (accentué) !", buffer);
|
ASSERT_STREQ("Testing string 0123 (accentué) !", buffer);
|
||||||
|
|
Loading…
Reference in a new issue