mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-02 16:31:01 +00:00
ENGINES: Make use of M_PI where possible
This commit is contained in:
parent
cfd6c250cd
commit
49b68d6756
@ -33,16 +33,16 @@ namespace AGSPalRender {
|
||||
#define MAX_STARS 1024
|
||||
#define MAX_DEPTH 64
|
||||
|
||||
#define PI (3.1415926535f)
|
||||
#define HALF_PI (0.5f * PI)
|
||||
#define TWO_PI (2.0f * PI)
|
||||
#define ONE_PI ((float)M_PI)
|
||||
#define HALF_PI (0.5f * ONE_PI)
|
||||
#define TWO_PI (2.0f * ONE_PI)
|
||||
#define TWO_PI_INV (1.0f / TWO_PI)
|
||||
|
||||
const float halfpi = (0.5f * PI);
|
||||
const float twopi = (2.0f * PI);
|
||||
const float halfpi = (0.5f * ONE_PI);
|
||||
const float twopi = (2.0f * ONE_PI);
|
||||
const float twopi_inv = (1.0f / TWO_PI);
|
||||
const float pisquared = PI * PI;
|
||||
const float picubed = PI * PI * PI;
|
||||
const float pisquared = ONE_PI * ONE_PI;
|
||||
const float picubed = ONE_PI * ONE_PI * ONE_PI;
|
||||
|
||||
IAGSEngine *engine;
|
||||
//unsigned char clut[256][256];
|
||||
@ -171,7 +171,7 @@ float q3sqrt(const float x) {
|
||||
|
||||
void Make_Sin_Lut() {
|
||||
for (int angle = 0; angle < 360; angle++) {
|
||||
double rad = (angle * PI) / 180.0;
|
||||
double rad = (angle * ONE_PI) / 180.0;
|
||||
rot_sine_LUT [angle] = static_cast<float>(sin(rad));
|
||||
rot_cos_LUT [angle] = static_cast<float>(cos(rad));
|
||||
}
|
||||
@ -206,7 +206,7 @@ unsigned short root(unsigned short x) {
|
||||
|
||||
float Hill(float x) {
|
||||
const float a0 = 1.0f;
|
||||
const float a2 = 2.0f / PI - 12.0f / (pisquared);
|
||||
const float a2 = 2.0f / ONE_PI - 12.0f / (pisquared);
|
||||
const float a3 = 16.0f / (picubed) - 4.0f / (pisquared);
|
||||
const float xx = x * x;
|
||||
const float xxx = xx * x;
|
||||
@ -224,7 +224,7 @@ float FastSin(float x) {
|
||||
// 4 pieces of hills
|
||||
if (x < halfpi)
|
||||
return Hill(halfpi - x);
|
||||
else if (x < PI)
|
||||
else if (x < ONE_PI)
|
||||
return Hill(x - halfpi);
|
||||
else if (x < 3.0f * halfpi)
|
||||
return -Hill(3.0f * halfpi - x);
|
||||
|
@ -27,7 +27,6 @@ namespace AGS3 {
|
||||
namespace Plugins {
|
||||
namespace AGSPalRender {
|
||||
|
||||
#define PI (3.1415926535f)
|
||||
#define S_WIDTH 320
|
||||
#define S_HEIGHT 160
|
||||
|
||||
@ -333,7 +332,7 @@ void AGSPalRender::Ray_GetPlayerY(ScriptMethodParams ¶ms) {
|
||||
|
||||
void AGSPalRender::Ray_GetPlayerAngle(ScriptMethodParams ¶ms) {
|
||||
double bgrad = atan2(dirY, dirX);
|
||||
int bgdeg = (int)(bgrad / PI * 180.0) + 180;
|
||||
int bgdeg = (int)(bgrad / M_PI * 180.0) + 180;
|
||||
params._result = bgdeg % 360;
|
||||
}
|
||||
|
||||
@ -747,7 +746,7 @@ void AGSPalRender::Raycast_Render(ScriptMethodParams ¶ms) {
|
||||
PARAMS1(int, slot);
|
||||
ambientweight = 0;
|
||||
raycastOn = true;
|
||||
double playerrad = atan2(dirY, dirX) + (2.0 * PI);
|
||||
double playerrad = atan2(dirY, dirX) + (2.0 * M_PI);
|
||||
rendering = true;
|
||||
int32 w = S_WIDTH, h = S_HEIGHT;
|
||||
BITMAP *screen = engine->GetSpriteGraphic(slot);
|
||||
@ -756,7 +755,7 @@ void AGSPalRender::Raycast_Render(ScriptMethodParams ¶ms) {
|
||||
BITMAP *sbBm = engine->GetSpriteGraphic(skybox);
|
||||
if (!sbBm) engine->AbortGame("Raycast_Render: No valid skybox sprite.");
|
||||
if (skybox > 0) {
|
||||
//int bgdeg = (int)((playerrad / PI) * 180.0) + 180;
|
||||
//int bgdeg = (int)((playerrad / M_PI) * 180.0) + 180;
|
||||
int xoffset = (int)(playerrad * 320.0);
|
||||
BITMAP *virtsc = engine->GetVirtualScreen();
|
||||
engine->SetVirtualScreen(screen);
|
||||
|
@ -33,7 +33,6 @@ namespace AGSSnowRain {
|
||||
const unsigned int Magic = 0xCAFE0000;
|
||||
const unsigned int Version = 2;
|
||||
const unsigned int SaveMagic = Magic + Version;
|
||||
const float PI = 3.14159265f;
|
||||
|
||||
|
||||
void View::syncGame(Serializer &s) {
|
||||
@ -99,7 +98,7 @@ void Weather::UpdateWithDrift() {
|
||||
for (i = 0; i < _mAmount * 2; i++) {
|
||||
_mParticles[i].y += _mParticles[i].speed;
|
||||
drift = _mParticles[i].drift * sin((float)(_mParticles[i].y +
|
||||
_mParticles[i].drift_offset) * _mParticles[i].drift_speed * 2.0f * PI / 360.0f);
|
||||
_mParticles[i].drift_offset) * _mParticles[i].drift_speed * 2.0f * M_PI / 360.0f);
|
||||
|
||||
if (signum(_mWindSpeed) == signum(drift))
|
||||
_mParticles[i].x += _mWindSpeed;
|
||||
|
@ -45,7 +45,6 @@ namespace Griffon {
|
||||
#define MINCURSEL 7
|
||||
#define MAXCURSEL 16
|
||||
#define SY 25
|
||||
#define PI 3.141593
|
||||
|
||||
void GriffonEngine::title(int mode) {
|
||||
const char *optionTitles[4] = {
|
||||
@ -128,7 +127,7 @@ void GriffonEngine::title(int mode) {
|
||||
else
|
||||
drawString(_videoBuffer, "(c) 2005 by Daniel 'Syn9' Kennedy", 28, 224, 4);
|
||||
|
||||
rc.left = (int16)(x - 16 - 4 * cos(2 * PI * _itemyloc / 16));
|
||||
rc.left = (int16)(x - 16 - 4 * cos(2 * M_PI * _itemyloc / 16));
|
||||
rc.top = (int16)(y - 4 + 16 * cursel);
|
||||
|
||||
_itemImg[15]->blendBlitTo(*_videoBuffer, rc.left, rc.top);
|
||||
@ -311,8 +310,8 @@ void GriffonEngine::configMenu() {
|
||||
_videoBuffer->fillRect(Common::Rect(0, 0, _videoBuffer->w, _videoBuffer->h), 0);
|
||||
_videoBuffer2->fillRect(Common::Rect(0, 0, _videoBuffer2->w, _videoBuffer2->h), 0);
|
||||
|
||||
rcDest.left = 256 + 256 * cos(PI / 180 * _cloudAngle * 40);
|
||||
rcDest.top = 192 + 192 * sin(PI / 180 * _cloudAngle * 40);
|
||||
rcDest.left = 256 + 256 * cos(M_PI / 180 * _cloudAngle * 40);
|
||||
rcDest.top = 192 + 192 * sin(M_PI / 180 * _cloudAngle * 40);
|
||||
rcDest.setWidth(320);
|
||||
rcDest.setHeight(240);
|
||||
|
||||
@ -374,7 +373,7 @@ void GriffonEngine::configMenu() {
|
||||
curselt += 1;
|
||||
|
||||
Common::Rect rc;
|
||||
rc.left = 148 + 3 * cos(2 * PI * _itemyloc / 16.0);
|
||||
rc.left = 148 + 3 * cos(2 * M_PI * _itemyloc / 16.0);
|
||||
rc.top = sy + 8 * curselt - 4;
|
||||
|
||||
_itemImg[15]->blendBlitTo(*_videoBuffer, rc.left, rc.top);
|
||||
@ -656,8 +655,8 @@ void GriffonEngine::saveLoadNew() {
|
||||
do {
|
||||
_videoBuffer->fillRect(Common::Rect(0, 0, _videoBuffer->w, _videoBuffer->h), 0);
|
||||
|
||||
rcDest.left = 256 + 256 * cos(PI / 180 * _cloudAngle * 40);
|
||||
rcDest.top = 192 + 192 * sin(PI / 180 * _cloudAngle * 40);
|
||||
rcDest.left = 256 + 256 * cos(M_PI / 180 * _cloudAngle * 40);
|
||||
rcDest.top = 192 + 192 * sin(M_PI / 180 * _cloudAngle * 40);
|
||||
rcDest.setWidth(320);
|
||||
rcDest.setHeight(240);
|
||||
|
||||
@ -812,11 +811,11 @@ void GriffonEngine::saveLoadNew() {
|
||||
break;
|
||||
}
|
||||
|
||||
rcDest.left += (int16)(2 + 2 * sin(2 * PI * _itemyloc / 16));
|
||||
rcDest.left += (int16)(2 + 2 * sin(2 * M_PI * _itemyloc / 16));
|
||||
}
|
||||
|
||||
if (curRow > 0) {
|
||||
rcDest.left = (int16)(0 + 2 * sin(2 * PI * _itemyloc / 16));
|
||||
rcDest.left = (int16)(0 + 2 * sin(2 * M_PI * _itemyloc / 16));
|
||||
rcDest.top = (int16)(53 + (curRow - 1) * 48);
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ void Actor::actorDoAction(int action) {
|
||||
|
||||
_vm->_pathFind->reset(0, px, pz, theta);
|
||||
|
||||
float t = ((270.0f - theta) * PI2) / 360.0f;
|
||||
float t = ((270.0f - theta) * M_PI * 2) / 360.0f;
|
||||
float ox = cos(t);
|
||||
float oz = sin(t);
|
||||
|
||||
|
@ -2401,8 +2401,6 @@ Management of "Use with"
|
||||
#define WITH 1
|
||||
|
||||
|
||||
#define PI 3.1415927f
|
||||
#define PI2 6.2831853f
|
||||
#define EPSILON 0.007f
|
||||
#define MAXSTEP 1000
|
||||
#define MAXPATHNODES 50
|
||||
|
@ -699,7 +699,7 @@ void PathFinding3D::setPosition(int num) {
|
||||
ox /= t;
|
||||
oz /= t;
|
||||
|
||||
float theta = _vm->sinCosAngle(ox, oz) * 180.0f / PI;
|
||||
float theta = _vm->sinCosAngle(ox, oz) * 180.0f / M_PI;
|
||||
if (_vm->floatComp(theta, 360.0f) >= 0) // theta >= 360.0f
|
||||
theta -= 360.0f;
|
||||
if (_vm->floatComp(theta, 0.0f) == -1) // theta < 0.0f
|
||||
@ -764,7 +764,7 @@ void PathFinding3D::lookAt(float x, float z) {
|
||||
ox /= t;
|
||||
oz /= t;
|
||||
|
||||
float theta = _vm->sinCosAngle(ox, oz) * 180.0f / PI;
|
||||
float theta = _vm->sinCosAngle(ox, oz) * 180.0f / M_PI;
|
||||
if (_vm->floatComp(theta, 360.0f) >= 0) //theta >= 360.0f
|
||||
theta -= 360.0f;
|
||||
if (_vm->floatComp(theta, 0.0f) == -1) // theta < 0.0f
|
||||
@ -1004,7 +1004,7 @@ void PathFinding3D::buildFramelist() {
|
||||
ox /= approx;
|
||||
oz /= approx;
|
||||
|
||||
theta = _vm->sinCosAngle(ox, oz) * 180.0f / PI + 180.0f;
|
||||
theta = _vm->sinCosAngle(ox, oz) * 180.0f / M_PI + 180.0f;
|
||||
if (_vm->floatComp(theta, 360.0f) >= 0)
|
||||
theta -= 360.0f;
|
||||
if (_vm->floatComp(theta, 0.0f) == -1)
|
||||
@ -1055,7 +1055,7 @@ void PathFinding3D::buildFramelist() {
|
||||
|
||||
curLen = sqrt(_step[index]._dx * _step[index]._dx + _step[index]._dz * _step[index]._dz);
|
||||
|
||||
theta = ((270.0f - theta) * PI) / 180.0f;
|
||||
theta = ((270.0f - theta) * M_PI) / 180.0f;
|
||||
ox = cos(theta) * curLen;
|
||||
oz = sin(theta) * curLen;
|
||||
|
||||
@ -1094,7 +1094,7 @@ void PathFinding3D::buildFramelist() {
|
||||
|
||||
curLen = sqrt(_step[index - 1]._dx * _step[index - 1]._dx + _step[index - 1]._dz * _step[index - 1]._dz);
|
||||
|
||||
oldTheta = ((270.0f - oldTheta) * PI) / 180.0f;
|
||||
oldTheta = ((270.0f - oldTheta) * M_PI) / 180.0f;
|
||||
ox = cos(oldTheta) * curLen;
|
||||
oz = sin(oldTheta) * curLen;
|
||||
|
||||
@ -1116,7 +1116,7 @@ void PathFinding3D::buildFramelist() {
|
||||
|
||||
curLen = sqrt(_step[index]._dx * _step[index]._dx + _step[index]._dz * _step[index]._dz);
|
||||
|
||||
theta = ((270.0f - theta) * PI) / 180.0f;
|
||||
theta = ((270.0f - theta) * M_PI) / 180.0f;
|
||||
ox = cos(theta) * curLen;
|
||||
oz = sin(theta) * curLen;
|
||||
|
||||
|
@ -502,7 +502,7 @@ void Renderer3D::calcCharacterPoints() {
|
||||
actor->_area[4] = 32000;
|
||||
actor->_area[5] = -32000;
|
||||
|
||||
float t = (actor->_theta * PI2) / 360.0;
|
||||
float t = (actor->_theta * M_PI * 2) / 360.0;
|
||||
float cost = cos(t);
|
||||
float sint = sin(t);
|
||||
|
||||
@ -561,7 +561,7 @@ void Renderer3D::calcCharacterPoints() {
|
||||
pa1 /= t;
|
||||
pa2 /= t;
|
||||
|
||||
tz = acos((pa0 * l0) + (pa1 * l1) + (pa2 * l2)) * 360.0 / PI2;
|
||||
tz = acos((pa0 * l0) + (pa1 * l1) + (pa2 * l2)) * 360.0 / (M_PI * 2);
|
||||
tz = CLIP(tz, 0.f, 180.f);
|
||||
|
||||
// tx falloff
|
||||
@ -613,7 +613,7 @@ void Renderer3D::calcCharacterPoints() {
|
||||
pa1 = curVertex->_ny;
|
||||
pa2 = curVertex->_nz;
|
||||
|
||||
lint = (int)((acos(pa0 * l0 + pa1 * l1 + pa2 * l2) * 360.0) / PI);
|
||||
lint = (int)((acos(pa0 * l0 + pa1 * l1 + pa2 * l2) * 360.0) / M_PI);
|
||||
lint = CLIP(lint, 0, 180);
|
||||
|
||||
_vVertex[j]._angle -= (180 - lint);
|
||||
|
@ -184,7 +184,7 @@ float TrecisionEngine::sinCosAngle(float sinus, float cosinus) {
|
||||
return (float)acos(cosinus);
|
||||
|
||||
// 3 quad
|
||||
return PI2 - (float)acos(cosinus);
|
||||
return (M_PI * 2) - (float)acos(cosinus);
|
||||
}
|
||||
|
||||
void TrecisionEngine::processTime() {
|
||||
|
@ -25,10 +25,6 @@
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define INLINE __inline
|
||||
#elif defined(__GNUC__)
|
||||
@ -1127,7 +1123,7 @@ static int init_tables(void)
|
||||
for (i=0; i<SIN_LEN; i++)
|
||||
{
|
||||
/* non-standard sinus */
|
||||
m = sin( ((i*2)+1) * PI / SIN_LEN ); /* checked against the real chip */
|
||||
m = sin( ((i*2)+1) * M_PI / SIN_LEN ); /* checked against the real chip */
|
||||
|
||||
/* we never reach zero here due to ((i*2)+1) */
|
||||
|
||||
|
@ -25,10 +25,6 @@
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define INLINE __inline
|
||||
#elif defined(__GNUC__)
|
||||
@ -936,7 +932,7 @@ int OplClass::init_tables(void) {
|
||||
|
||||
for (i = 0; i < SIN_LEN; i++) {
|
||||
/* non-standard sinus */
|
||||
m = sin(((i * 2) + 1) * PI / SIN_LEN); /* checked against the real chip */
|
||||
m = sin(((i * 2) + 1) * M_PI / SIN_LEN); /* checked against the real chip */
|
||||
|
||||
/* we never reach zero here due to ((i*2)+1) */
|
||||
|
||||
|
@ -28,11 +28,6 @@
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
|
||||
#define SPKR_VOLUME 5000
|
||||
//#define SPKR_SHIFT 8
|
||||
#define SPKR_SPEED (float)((SPKR_VOLUME*2)/0.070f)
|
||||
|
Loading…
x
Reference in New Issue
Block a user