Another try at satisfying both MSVC and Irix CC...

...with respect to mathematical functions.
This commit is contained in:
Guillaume Melquiond 2005-01-07 23:55:47 +00:00
parent 0a4cecccba
commit a2fa7dd9c6
3 changed files with 13 additions and 5 deletions

View File

@ -1,7 +1,7 @@
#ifndef DISABLE_4786_HPP_INCLUDED
#define DISABLE_4786_HPP_INCLUDED
#ifdef _WIN32
#ifdef _MSC_VER
//disable the warning to let us know about 'this' being used in
//initializer list, since it's a common thing to want to do
@ -23,6 +23,14 @@ warning4786WorkAround() {}
static warning4786WorkAround VariableThatHacksWarning4786IntoBeingMutedForSomeUnknownReason;
//put the mathematical functions where they belong: in the std namespace
//it is necessary for VC6 at least
#include <cmath>
namespace std {
using ::floor;
using ::sqrt;
}
#endif
#endif

View File

@ -133,7 +133,7 @@ height_map generate_height_map(size_t width, size_t height,
if(island_size != 0) {
const size_t diffx = abs(x1 - int(center_x));
const size_t diffy = abs(y1 - int(center_y));
const size_t dist = size_t(sqrt(double(diffx*diffx + diffy*diffy)));
const size_t dist = size_t(std::sqrt(double(diffx*diffx + diffy*diffy)));
is_valley = dist > island_size;
}
@ -149,7 +149,7 @@ height_map generate_height_map(size_t width, size_t height,
const int xdiff = (x2-x1);
const int ydiff = (y2-y1);
const int height = radius - int(sqrt(double(xdiff*xdiff + ydiff*ydiff)));
const int height = radius - int(std::sqrt(double(xdiff*xdiff + ydiff*ydiff)));
if(height > 0) {
if(is_valley) {

View File

@ -187,12 +187,12 @@ surface scale_surface_blended(surface surf, int w, int h)
//we now have a rectangle, (xsrc,ysrc,xratio,yratio) which we
//want to derive the pixel from
for(double xloc = xsrc; xloc < xsrc+xratio; xloc += 1.0) {
const double xsize = minimum<double>(floor(xloc+1.0)-xloc,xsrc+xratio-xloc);
const double xsize = minimum<double>(std::floor(xloc+1.0)-xloc,xsrc+xratio-xloc);
for(double yloc = ysrc; yloc < ysrc+yratio; yloc += 1.0) {
const int xsrcint = maximum<int>(0,minimum<int>(src->w-1,static_cast<int>(xsrc)));
const int ysrcint = maximum<int>(0,minimum<int>(src->h-1,static_cast<int>(ysrc)));
const double ysize = minimum<double>(floor(yloc+1.0)-yloc,ysrc+yratio-yloc);
const double ysize = minimum<double>(std::floor(yloc+1.0)-yloc,ysrc+yratio-yloc);
Uint8 r,g,b,a;