Increased precision of pfmod<double> by switching from integer divide to double precision divide. Fixes problem with cloud textures at times in the very distant future.

ver1_6_1
Chris Laurel 2008-05-09 18:30:03 +00:00
parent 30c8727d43
commit 180e4fd9c2
1 changed files with 4 additions and 4 deletions

View File

@ -1,14 +1,14 @@
// mathlib.h
//
// Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
// Copyright (C) 2001-2008, Chris Laurel <claurel@shatters.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
#ifndef _MATHLIB_H_
#define _MATHLIB_H_
#ifndef _CELMATH_MATHLIB_H_
#define _CELMATH_MATHLIB_H_
#include <cmath>
#include <stdlib.h>
@ -83,7 +83,7 @@ template<class T> T sign(T x)
// a positive value in the range [ 0, y )
template<class T> T pfmod(T x, T y)
{
int quotient = (int) abs(x / y);
T quotient = std::floor(std::abs(x / y));
if (x < 0.0)
return x + (quotient + 1) * y;
else