Fix phd_sin() and phd_cos()

This commit is contained in:
asasas9500 2020-10-05 22:24:57 -03:00
parent 54f6db166b
commit 6fc9bd9890
79 changed files with 597 additions and 601 deletions

View file

@ -1025,9 +1025,9 @@ void LaraUnderWater(ITEM_INFO* item, COLL_INFO* coll)//4BFB4, 4C418 (F)
AnimateLara(item); AnimateLara(item);
item->pos.xPos += phd_cos(item->pos.xRot) * (item->fallspeed * phd_sin(item->pos.yRot) >> (W2V_SHIFT + 2)) >> W2V_SHIFT; item->pos.xPos += phd_cos(item->pos.xRot) * item->fallspeed * phd_sin(item->pos.yRot) / 4;
item->pos.yPos -= item->fallspeed * phd_sin(item->pos.xRot) >> (W2V_SHIFT + 2); item->pos.yPos -= item->fallspeed * phd_sin(item->pos.xRot) / 4;
item->pos.zPos += phd_cos(item->pos.xRot) * (item->fallspeed * phd_cos(item->pos.yRot) >> (W2V_SHIFT + 2)) >> W2V_SHIFT; item->pos.zPos += phd_cos(item->pos.xRot) * item->fallspeed * phd_cos(item->pos.yRot) / 4;
LaraBaddieCollision(item, coll); LaraBaddieCollision(item, coll);
@ -1083,8 +1083,8 @@ void LaraSurface(ITEM_INFO* item, COLL_INFO* coll)//4D684, 4DAE8 (F)
AnimateLara(item); AnimateLara(item);
item->pos.xPos += item->fallspeed * phd_sin(item->pos.yRot + Lara.moveAngle) >> (W2V_SHIFT + 2); item->pos.xPos += item->fallspeed * phd_sin(item->pos.yRot + Lara.moveAngle) / 4;
item->pos.zPos += item->fallspeed * phd_cos(item->pos.yRot + Lara.moveAngle) >> (W2V_SHIFT + 2); item->pos.zPos += item->fallspeed * phd_cos(item->pos.yRot + Lara.moveAngle) / 4;
LaraBaddieCollision(item, coll); LaraBaddieCollision(item, coll);
@ -1293,11 +1293,11 @@ void AnimateLara(ITEM_INFO* item)
if (!Lara.isMoving) // TokyoSU: i dont know why but it's wreid, in TR3 only the 2 first line there is used and worked fine ! if (!Lara.isMoving) // TokyoSU: i dont know why but it's wreid, in TR3 only the 2 first line there is used and worked fine !
{ {
item->pos.xPos += item->speed * phd_sin(item->pos.yRot + Lara.moveAngle) >> W2V_SHIFT; item->pos.xPos += item->speed * phd_sin(item->pos.yRot + Lara.moveAngle);
item->pos.zPos += item->speed * phd_cos(item->pos.yRot + Lara.moveAngle) >> W2V_SHIFT; item->pos.zPos += item->speed * phd_cos(item->pos.yRot + Lara.moveAngle);
item->pos.xPos += lateral * phd_sin(item->pos.yRot + Lara.moveAngle + ANGLE(90)) >> W2V_SHIFT; item->pos.xPos += lateral * phd_sin(item->pos.yRot + Lara.moveAngle + ANGLE(90));
item->pos.zPos += lateral * phd_cos(item->pos.yRot + Lara.moveAngle + ANGLE(90)) >> W2V_SHIFT; item->pos.zPos += lateral * phd_cos(item->pos.yRot + Lara.moveAngle + ANGLE(90));
} }
// Update matrices // Update matrices

View file

@ -83,8 +83,8 @@ void LaraDeflectEdgeJump(ITEM_INFO* item, COLL_INFO* coll)//12904, 129B4 (F)
item->pos.yRot -= ANGLE(5.0f); item->pos.yRot -= ANGLE(5.0f);
break; break;
case CT_CLAMP: case CT_CLAMP:
item->pos.xPos -= (100 * 4 * phd_sin(coll->facing)) >> W2V_SHIFT; item->pos.xPos -= 400 * phd_sin(coll->facing);
item->pos.zPos -= (100 * 4 * phd_cos(coll->facing)) >> W2V_SHIFT; item->pos.zPos -= 400 * phd_cos(coll->facing);
item->speed = 0; item->speed = 0;
coll->midFloor = 0; coll->midFloor = 0;

View file

@ -198,9 +198,9 @@ void lara_as_all4s(ITEM_INFO* item, COLL_INFO* coll)//14970, 14A78 (F)
s.z = LaraItem->pos.zPos; s.z = LaraItem->pos.zPos;
s.roomNumber = LaraItem->roomNumber; s.roomNumber = LaraItem->roomNumber;
d.x = s.x + (768 * phd_sin(LaraItem->pos.yRot) >> W2V_SHIFT); d.x = s.x + 768 * phd_sin(LaraItem->pos.yRot);
d.y = s.y + 160; d.y = s.y + 160;
d.z = s.z + (768 * phd_cos(LaraItem->pos.yRot) >> W2V_SHIFT); d.z = s.z + 768 * phd_cos(LaraItem->pos.yRot);
if (LOS(&s, &d) && item->animNumber != LA_CROUCH_TO_CRAWL_START && item->animNumber != LA_CROUCH_TO_CRAWL_CONTINUE) if (LOS(&s, &d) && item->animNumber != LA_CROUCH_TO_CRAWL_START && item->animNumber != LA_CROUCH_TO_CRAWL_CONTINUE)
{ {
@ -224,9 +224,9 @@ void lara_as_all4s(ITEM_INFO* item, COLL_INFO* coll)//14970, 14A78 (F)
s.z = LaraItem->pos.zPos; s.z = LaraItem->pos.zPos;
s.roomNumber = LaraItem->roomNumber; s.roomNumber = LaraItem->roomNumber;
d.x = s.x + (768 * phd_sin(LaraItem->pos.yRot) >> W2V_SHIFT); d.x = s.x + 768 * phd_sin(LaraItem->pos.yRot);
d.y = s.y + 160; d.y = s.y + 160;
d.z = s.z + (768 * phd_cos(LaraItem->pos.yRot) >> W2V_SHIFT); d.z = s.z + 768 * phd_cos(LaraItem->pos.yRot);
if (LOS(&s, &d) && item->animNumber != LA_CROUCH_TO_CRAWL_START && item->animNumber != LA_CROUCH_TO_CRAWL_CONTINUE)// && EnableCrawlFlex3clickE == true) if (LOS(&s, &d) && item->animNumber != LA_CROUCH_TO_CRAWL_START && item->animNumber != LA_CROUCH_TO_CRAWL_CONTINUE)// && EnableCrawlFlex3clickE == true)
{ {
@ -248,9 +248,9 @@ void lara_as_all4s(ITEM_INFO* item, COLL_INFO* coll)//14970, 14A78 (F)
s.z = LaraItem->pos.zPos; s.z = LaraItem->pos.zPos;
s.roomNumber = LaraItem->roomNumber; s.roomNumber = LaraItem->roomNumber;
d.x = s.x + (768 * phd_sin(LaraItem->pos.yRot) >> W2V_SHIFT); d.x = s.x + 768 * phd_sin(LaraItem->pos.yRot);
d.y = s.y + 160; d.y = s.y + 160;
d.z = s.z + (768 * phd_cos(LaraItem->pos.yRot) >> W2V_SHIFT); d.z = s.z + 768 * phd_cos(LaraItem->pos.yRot);
if (LOS(&s, &d) && item->animNumber != LA_CROUCH_TO_CRAWL_START && item->animNumber != LA_CROUCH_TO_CRAWL_CONTINUE)// && EnableCrawlFlex2clickE == true) if (LOS(&s, &d) && item->animNumber != LA_CROUCH_TO_CRAWL_START && item->animNumber != LA_CROUCH_TO_CRAWL_CONTINUE)// && EnableCrawlFlex2clickE == true)
{ {
@ -271,9 +271,9 @@ void lara_as_all4s(ITEM_INFO* item, COLL_INFO* coll)//14970, 14A78 (F)
s.z = LaraItem->pos.zPos; s.z = LaraItem->pos.zPos;
s.roomNumber = LaraItem->roomNumber; s.roomNumber = LaraItem->roomNumber;
d.x = s.x + (768 * phd_sin(LaraItem->pos.yRot) >> W2V_SHIFT); d.x = s.x + 768 * phd_sin(LaraItem->pos.yRot);
d.y = s.y + 160; d.y = s.y + 160;
d.z = s.z + (768 * phd_cos(LaraItem->pos.yRot) >> W2V_SHIFT); d.z = s.z + 768 * phd_cos(LaraItem->pos.yRot);
if (LOS(&s, &d) && item->animNumber != LA_CROUCH_TO_CRAWL_START && item->animNumber != LA_CROUCH_TO_CRAWL_CONTINUE)// && EnableCrawlFlex1clickE == true) if (LOS(&s, &d) && item->animNumber != LA_CROUCH_TO_CRAWL_START && item->animNumber != LA_CROUCH_TO_CRAWL_CONTINUE)// && EnableCrawlFlex1clickE == true)
{ {
@ -400,13 +400,13 @@ void lara_col_all4s(ITEM_INFO* item, COLL_INFO* coll)//14B40, 14C74 (F)
int x = item->pos.xPos; int x = item->pos.xPos;
int z = item->pos.zPos; int z = item->pos.zPos;
item->pos.xPos += 128 * phd_sin(item->pos.yRot - ANGLE(90.0f)) >> W2V_SHIFT; item->pos.xPos += 128 * phd_sin(item->pos.yRot - ANGLE(90.0f));
item->pos.zPos += 128 * phd_cos(item->pos.yRot - ANGLE(90.0f)) >> W2V_SHIFT; item->pos.zPos += 128 * phd_cos(item->pos.yRot - ANGLE(90.0f));
heightl = LaraFloorFront(item, item->pos.yRot, -300); heightl = LaraFloorFront(item, item->pos.yRot, -300);
item->pos.xPos += 256 * phd_sin(item->pos.yRot + ANGLE(90.0f)) >> W2V_SHIFT; item->pos.xPos += 256 * phd_sin(item->pos.yRot + ANGLE(90.0f));
item->pos.zPos += 256 * phd_cos(item->pos.yRot + ANGLE(90.0f)) >> W2V_SHIFT; item->pos.zPos += 256 * phd_cos(item->pos.yRot + ANGLE(90.0f));
heightr = LaraFloorFront(item, item->pos.yRot, -300); heightr = LaraFloorFront(item, item->pos.yRot, -300);
@ -431,8 +431,8 @@ void lara_col_all4s(ITEM_INFO* item, COLL_INFO* coll)//14B40, 14C74 (F)
int x = item->pos.xPos; int x = item->pos.xPos;
int z = item->pos.zPos; int z = item->pos.zPos;
item->pos.xPos -= 100 * phd_sin(coll->facing) >> W2V_SHIFT; item->pos.xPos -= 100 * phd_sin(coll->facing);
item->pos.zPos -= 100 * phd_cos(coll->facing) >> W2V_SHIFT; item->pos.zPos -= 100 * phd_cos(coll->facing);
tmp = GetCollidedObjects(item, 100, 1, &tmp1, &tmp2, 0); tmp = GetCollidedObjects(item, 100, 1, &tmp1, &tmp2, 0);

View file

@ -837,7 +837,8 @@ FireWeaponType FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, sho
void find_target_point(ITEM_INFO* item, GAME_VECTOR* target) // (F) (D) void find_target_point(ITEM_INFO* item, GAME_VECTOR* target) // (F) (D)
{ {
BOUNDING_BOX* bounds; BOUNDING_BOX* bounds;
int x, y, z, c, s; int x, y, z;
float c, s;
bounds = (BOUNDING_BOX*)GetBestFrame(item); bounds = (BOUNDING_BOX*)GetBestFrame(item);
x = (int)(bounds->X1 + bounds->X2) / 2; x = (int)(bounds->X1 + bounds->X2) / 2;
@ -846,9 +847,9 @@ void find_target_point(ITEM_INFO* item, GAME_VECTOR* target) // (F) (D)
c = phd_cos(item->pos.yRot); c = phd_cos(item->pos.yRot);
s = phd_sin(item->pos.yRot); s = phd_sin(item->pos.yRot);
target->x = item->pos.xPos + ((c * x + s * z) >> W2V_SHIFT); target->x = item->pos.xPos + c * x + s * z;
target->y = item->pos.yPos + y; target->y = item->pos.yPos + y;
target->z = item->pos.zPos + ((c * z - s * x) >> W2V_SHIFT); target->z = item->pos.zPos + c * z - s * x;
target->roomNumber = item->roomNumber; target->roomNumber = item->roomNumber;
} }

View file

@ -44,8 +44,8 @@ void FlareControl(short itemNumber) // (AF) (D)
int oldY = item->pos.yPos; int oldY = item->pos.yPos;
int oldZ = item->pos.zPos; int oldZ = item->pos.zPos;
int xv = item->speed * phd_sin(item->pos.yRot) >> W2V_SHIFT; int xv = item->speed * phd_sin(item->pos.yRot);
int zv = item->speed * phd_cos(item->pos.yRot) >> W2V_SHIFT; int zv = item->speed * phd_cos(item->pos.yRot);
item->pos.xPos += xv; item->pos.xPos += xv;
item->pos.zPos += zv; item->pos.zPos += zv;
@ -328,8 +328,8 @@ void CreateFlare(short objectNum, int thrown) // (F) (D)
{ {
flag = true; flag = true;
item->pos.yRot = LaraItem->pos.yRot + ANGLE(180); item->pos.yRot = LaraItem->pos.yRot + ANGLE(180);
item->pos.xPos = LaraItem->pos.xPos + (320 * phd_sin(item->pos.yRot) >> W2V_SHIFT); item->pos.xPos = LaraItem->pos.xPos + 320 * phd_sin(item->pos.yRot);
item->pos.zPos = LaraItem->pos.zPos + (320 * phd_cos(item->pos.yRot) >> W2V_SHIFT); item->pos.zPos = LaraItem->pos.zPos + 320 * phd_cos(item->pos.yRot);
item->roomNumber = LaraItem->roomNumber; item->roomNumber = LaraItem->roomNumber;
} }
else else

View file

@ -256,9 +256,9 @@ void lara_as_pbleapoff(ITEM_INFO* item, COLL_INFO* coll)//1D244, 1D3D8 (F)
if (item->frameNumber == g_Level.Anims[item->animNumber].frameEnd) if (item->frameNumber == g_Level.Anims[item->animNumber].frameEnd)
{ {
item->pos.xPos += 700 * phd_sin(item->pos.yRot) >> W2V_SHIFT; item->pos.xPos += 700 * phd_sin(item->pos.yRot);
item->pos.yPos -= 361; item->pos.yPos -= 361;
item->pos.zPos += 700 * phd_cos(item->pos.yRot) >> W2V_SHIFT; item->pos.zPos += 700 * phd_cos(item->pos.yRot);
item->animNumber = LA_REACH; item->animNumber = LA_REACH;
item->frameNumber = g_Level.Anims[item->animNumber].frameBase; item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
@ -677,8 +677,8 @@ void lara_col_polestat(ITEM_INFO* item, COLL_INFO* coll)//16DFC, 16F30 (F)
} }
else else
{ {
item->pos.xPos -= (phd_sin(item->pos.yRot)) << 6 >> W2V_SHIFT; item->pos.xPos -= phd_sin(item->pos.yRot) * 64;
item->pos.zPos -= (phd_cos(item->pos.yRot)) << 6 >> W2V_SHIFT; item->pos.zPos -= phd_cos(item->pos.yRot) * 64;
item->goalAnimState = LS_FREEFALL; item->goalAnimState = LS_FREEFALL;
} }
} }

View file

@ -93,8 +93,8 @@ void FireHarpoon()
item->pos.zRot = 0; item->pos.zRot = 0;
item->fallspeed = (short)(-HARPOON_SPEED * phd_sin(item->pos.xRot) >> W2V_SHIFT); item->fallspeed = -HARPOON_SPEED * phd_sin(item->pos.xRot);
item->speed = (short)(HARPOON_SPEED * phd_cos(item->pos.xRot) >> W2V_SHIFT); item->speed = HARPOON_SPEED * phd_cos(item->pos.xRot);
item->hitPoints = HARPOON_TIME; item->hitPoints = HARPOON_TIME;
AddActiveItem(itemNumber); AddActiveItem(itemNumber);
@ -166,8 +166,8 @@ void ControlHarpoonBolt(short itemNumber)
item->pos.xRot -= ANGLE(1); item->pos.xRot -= ANGLE(1);
if (item->pos.xRot < -16384) if (item->pos.xRot < -16384)
item->pos.xRot = -16384; item->pos.xRot = -16384;
item->fallspeed = (short)(-HARPOON_SPEED * phd_sin(item->pos.xRot) >> W2V_SHIFT); item->fallspeed = -HARPOON_SPEED * phd_sin(item->pos.xRot);
item->speed = (short)(HARPOON_SPEED * phd_cos(item->pos.xRot) >> W2V_SHIFT); item->speed = HARPOON_SPEED * phd_cos(item->pos.xRot);
aboveWater = true; aboveWater = true;
} }
else else
@ -176,15 +176,15 @@ void ControlHarpoonBolt(short itemNumber)
if ((Wibble & 15) == 0) if ((Wibble & 15) == 0)
CreateBubble((PHD_VECTOR*)& item->pos, item->roomNumber, 0, 0, BUBBLE_FLAG_CLUMP | BUBBLE_FLAG_HIGH_AMPLITUDE, 0, 0, 0); // CHECK CreateBubble((PHD_VECTOR*)& item->pos, item->roomNumber, 0, 0, BUBBLE_FLAG_CLUMP | BUBBLE_FLAG_HIGH_AMPLITUDE, 0, 0, 0); // CHECK
TriggerRocketSmoke(item->pos.xPos, item->pos.yPos, item->pos.zPos, 64); TriggerRocketSmoke(item->pos.xPos, item->pos.yPos, item->pos.zPos, 64);
item->fallspeed = (short)(-(HARPOON_SPEED >> 1) * phd_sin(item->pos.xRot) >> W2V_SHIFT); item->fallspeed = -HARPOON_SPEED * phd_sin(item->pos.xRot) / 2;
item->speed = (short)((HARPOON_SPEED >> 1) * phd_cos(item->pos.xRot) >> W2V_SHIFT); item->speed = HARPOON_SPEED * phd_cos(item->pos.xRot) / 2;
aboveWater = false; aboveWater = false;
} }
// Update bolt's position // Update bolt's position
item->pos.xPos += ((item->speed * phd_cos(item->pos.xRot) >> W2V_SHIFT) * phd_sin(item->pos.yRot)) >> W2V_SHIFT; item->pos.xPos += item->speed * phd_cos(item->pos.xRot) * phd_sin(item->pos.yRot);
item->pos.yPos += item->speed * phd_sin(-item->pos.xRot) >> W2V_SHIFT; item->pos.yPos += item->speed * phd_sin(-item->pos.xRot);
item->pos.zPos += ((item->speed * phd_cos(item->pos.xRot) >> W2V_SHIFT) * phd_cos(item->pos.yRot)) >> W2V_SHIFT; item->pos.zPos += item->speed * phd_cos(item->pos.xRot) * phd_cos(item->pos.yRot);
roomNumber = item->roomNumber; roomNumber = item->roomNumber;
FLOOR_INFO * floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber); FLOOR_INFO * floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
@ -356,7 +356,7 @@ void FireGrenade()
} }
item->speed = GRENADE_SPEED; item->speed = GRENADE_SPEED;
item->fallspeed = (-512 * phd_sin(item->pos.xRot)) >> W2V_SHIFT; item->fallspeed = -512 * phd_sin(item->pos.xRot);
item->currentAnimState = item->pos.xRot; item->currentAnimState = item->pos.xRot;
item->goalAnimState = item->pos.yRot; item->goalAnimState = item->pos.yRot;
item->requiredAnimState = 0; item->requiredAnimState = 0;
@ -437,7 +437,7 @@ void ControlGrenade(short itemNumber)
newGrenade->pos.yRot = GetRandomControl() * 2; newGrenade->pos.yRot = GetRandomControl() * 2;
newGrenade->pos.zRot = 0; newGrenade->pos.zRot = 0;
newGrenade->speed = 64; newGrenade->speed = 64;
newGrenade->fallspeed = -64 * phd_sin(newGrenade->pos.xRot) >> W2V_SHIFT; newGrenade->fallspeed = -64 * phd_sin(newGrenade->pos.xRot);
newGrenade->currentAnimState = newGrenade->pos.xRot; newGrenade->currentAnimState = newGrenade->pos.xRot;
newGrenade->goalAnimState = newGrenade->pos.yRot; newGrenade->goalAnimState = newGrenade->pos.yRot;
newGrenade->requiredAnimState = 0; newGrenade->requiredAnimState = 0;
@ -521,9 +521,9 @@ void ControlGrenade(short itemNumber)
} }
// Update grenade position // Update grenade position
xv = ((item->speed * phd_sin(item->goalAnimState)) >> W2V_SHIFT); xv = item->speed * phd_sin(item->goalAnimState);
yv = item->fallspeed; yv = item->fallspeed;
zv = ((item->speed * phd_cos(item->goalAnimState)) >> W2V_SHIFT); zv = item->speed * phd_cos(item->goalAnimState);
item->pos.xPos += xv; item->pos.xPos += xv;
item->pos.yPos += yv; item->pos.yPos += yv;
@ -799,10 +799,10 @@ void ControlRocket(short itemNumber)
} }
// Update rocket's position // Update rocket's position
short speed = (item->speed * phd_cos(item->pos.xRot)) >> W2V_SHIFT; short speed = item->speed * phd_cos(item->pos.xRot);
item->pos.xPos += (speed * phd_sin(item->pos.yRot)) >> W2V_SHIFT; item->pos.xPos += speed * phd_sin(item->pos.yRot);
item->pos.yPos += -((item->speed * phd_sin(item->pos.xRot)) >> W2V_SHIFT); item->pos.yPos += -item->speed * phd_sin(item->pos.xRot);
item->pos.zPos += (speed * phd_cos(item->pos.yRot)) >> W2V_SHIFT; item->pos.zPos += speed * phd_cos(item->pos.yRot);
bool explode = false; bool explode = false;
@ -1271,9 +1271,9 @@ void ControlCrossbowBolt(short itemNumber)
} }
// Update bolt's position // Update bolt's position
item->pos.xPos += ((item->speed * phd_cos(item->pos.xRot) >> W2V_SHIFT) * phd_sin(item->pos.yRot)) >> W2V_SHIFT; item->pos.xPos += item->speed * phd_cos(item->pos.xRot) * phd_sin(item->pos.yRot);
item->pos.yPos += item->speed * phd_sin(-item->pos.xRot) >> W2V_SHIFT; item->pos.yPos += item->speed * phd_sin(-item->pos.xRot);
item->pos.zPos += ((item->speed * phd_cos(item->pos.xRot) >> W2V_SHIFT) * phd_cos(item->pos.yRot)) >> W2V_SHIFT; item->pos.zPos += item->speed * phd_cos(item->pos.xRot) * phd_cos(item->pos.yRot);
roomNumber = item->roomNumber; roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber); FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
@ -1726,9 +1726,10 @@ void SomeSparkEffect(int x, int y, int z, int count)
spark->sLife = 24; spark->sLife = 24;
spark->transType = COLADD; spark->transType = COLADD;
spark->friction = 5; spark->friction = 5;
spark->xVel = -128 * phd_sin(GetRandomControl()); int random = GetRandomControl() & 0xFFF;
spark->xVel = -128 * phd_sin(random << 4);
spark->yVel = -640 - (byte)GetRandomControl(); spark->yVel = -640 - (byte)GetRandomControl();
spark->zVel = -128 * phd_cos(GetRandomControl()); spark->zVel = 128 * phd_cos(random << 4);
spark->flags = 0; spark->flags = 0;
spark->x = x + (spark->xVel >> 3); spark->x = x + (spark->xVel >> 3);
spark->y = y - (spark->yVel >> 5); spark->y = y - (spark->yVel >> 5);

View file

@ -137,8 +137,8 @@ void LaraSlideEdgeJump(ITEM_INFO* item, COLL_INFO* coll)//12B18, 12BC8 (F)
break; break;
case CT_CLAMP: case CT_CLAMP:
item->pos.zPos -= (400 * phd_cos(coll->facing)) >> W2V_SHIFT; item->pos.zPos -= 400 * phd_cos(coll->facing);
item->pos.xPos -= (400 * phd_sin(coll->facing)) >> W2V_SHIFT; item->pos.xPos -= 400 * phd_sin(coll->facing);
item->speed = 0; item->speed = 0;

View file

@ -33,8 +33,8 @@ void LaraWaterCurrent(COLL_INFO* coll) // (F) (D)
OBJECT_VECTOR* sink = &FixedCameras[Lara.currentActive - 1]; OBJECT_VECTOR* sink = &FixedCameras[Lara.currentActive - 1];
short angle = mGetAngle(sink->x, sink->z, LaraItem->pos.xPos, LaraItem->pos.zPos); short angle = mGetAngle(sink->x, sink->z, LaraItem->pos.xPos, LaraItem->pos.zPos);
Lara.currentXvel += ((sink->data * (phd_sin(angle - ANGLE(90)) / 4) >> 2) - Lara.currentXvel) >> 4; Lara.currentXvel += (sink->data * 1024 * phd_sin(angle - ANGLE(90)) - Lara.currentXvel) / 16;
Lara.currentZvel += ((sink->data * (phd_cos(angle - ANGLE(90)) / 4) >> 2) - Lara.currentZvel) >> 4; Lara.currentZvel += (sink->data * 1024 * phd_cos(angle - ANGLE(90)) - Lara.currentZvel) / 16;
LaraItem->pos.yPos += (sink->y - LaraItem->pos.yPos) >> 4; LaraItem->pos.yPos += (sink->y - LaraItem->pos.yPos) >> 4;
} }
@ -522,7 +522,7 @@ void LaraSwimCollision(ITEM_INFO* item, COLL_INFO* coll)//4B608, 4BA6C
coll->facing = item->pos.yRot; coll->facing = item->pos.yRot;
} }
short height = 762 * phd_sin(item->pos.xRot) >> W2V_SHIFT; short height = 762 * phd_sin(item->pos.xRot);
height = abs(height); height = abs(height);
if (height < ((LaraDrawType == LARA_DIVESUIT) << 6) + 200) if (height < ((LaraDrawType == LARA_DIVESUIT) << 6) + 200)

View file

@ -958,8 +958,8 @@ int TestHangSwingIn(ITEM_INFO* item, short angle)//14104, 141B4 (F)
z += 256; z += 256;
}*/ }*/
z += (phd_cos(angle) * STEP_SIZE) >> W2V_SHIFT; z += phd_cos(angle) * STEP_SIZE;
x += (phd_sin(angle) * STEP_SIZE) >> W2V_SHIFT; x += phd_sin(angle) * STEP_SIZE;
floor = GetFloor(x, y, z, &roomNum); floor = GetFloor(x, y, z, &roomNum);
h = GetFloorHeight(floor, x, y, z); h = GetFloorHeight(floor, x, y, z);
@ -1177,9 +1177,9 @@ short LaraFloorFront(ITEM_INFO* item, short ang, int dist) // (F) (D)
{ {
short room = item->roomNumber; short room = item->roomNumber;
int x = item->pos.xPos + ((dist * phd_sin(ang)) >> W2V_SHIFT); int x = item->pos.xPos + dist * phd_sin(ang);
int y = item->pos.yPos - 762; int y = item->pos.yPos - 762;
int z = item->pos.zPos + ((dist * phd_cos(ang)) >> W2V_SHIFT); int z = item->pos.zPos + dist * phd_cos(ang);
int height = GetFloorHeight(GetFloor(x, y, z, &room), x, y, z); int height = GetFloorHeight(GetFloor(x, y, z, &room), x, y, z);
@ -1193,9 +1193,9 @@ short LaraCeilingFront(ITEM_INFO* item, short ang, int dist, int h) // (F) (D)
{ {
short room = item->roomNumber; short room = item->roomNumber;
int x = item->pos.xPos + ((dist * phd_sin(ang)) >> W2V_SHIFT); int x = item->pos.xPos + dist * phd_sin(ang);
int y = item->pos.yPos - h; int y = item->pos.yPos - h;
int z = item->pos.zPos + ((dist * phd_cos(ang)) >> W2V_SHIFT); int z = item->pos.zPos + dist * phd_cos(ang);
int height = GetCeiling(GetFloor(x, y, z, &room), x, y, z); int height = GetCeiling(GetFloor(x, y, z, &room), x, y, z);

View file

@ -1387,8 +1387,8 @@ void FindAITargetObject(CREATURE_INFO* creature, short objectNumber)
if (!(creature->aiTarget.flags & 0x20)) if (!(creature->aiTarget.flags & 0x20))
{ {
creature->aiTarget.pos.xPos += phd_sin(creature->aiTarget.pos.yRot) >> 4; creature->aiTarget.pos.xPos += phd_sin(creature->aiTarget.pos.yRot) * 1024;
creature->aiTarget.pos.zPos += phd_cos(creature->aiTarget.pos.yRot) >> 4; creature->aiTarget.pos.zPos += phd_cos(creature->aiTarget.pos.yRot) * 1024;
} }
} }
} }
@ -1437,13 +1437,13 @@ void CreatureAIInfo(ITEM_INFO* item, AI_INFO* info)
if (enemy == LaraItem) if (enemy == LaraItem)
{ {
x = (enemy->pos.xPos + (enemy->speed * PREDICTIVE_SCALE_FACTOR * phd_sin(LaraItem->pos.yRot + Lara.moveAngle) >> W2V_SHIFT)) - (item->pos.xPos + (obj->pivotLength * phd_sin(item->pos.yRot) >> W2V_SHIFT)); x = enemy->pos.xPos + enemy->speed * PREDICTIVE_SCALE_FACTOR * phd_sin(LaraItem->pos.yRot + Lara.moveAngle) - item->pos.xPos + obj->pivotLength * phd_sin(item->pos.yRot);
z = (enemy->pos.zPos + (enemy->speed * PREDICTIVE_SCALE_FACTOR * phd_cos(LaraItem->pos.yRot + Lara.moveAngle) >> W2V_SHIFT)) - (item->pos.zPos + (obj->pivotLength * phd_cos(item->pos.yRot) >> W2V_SHIFT)); z = enemy->pos.zPos + enemy->speed * PREDICTIVE_SCALE_FACTOR * phd_cos(LaraItem->pos.yRot + Lara.moveAngle) - item->pos.zPos + obj->pivotLength * phd_cos(item->pos.yRot);
} }
else else
{ {
x = (enemy->pos.xPos + (enemy->speed * PREDICTIVE_SCALE_FACTOR * phd_sin(enemy->pos.yRot) >> W2V_SHIFT)) - (item->pos.xPos + (obj->pivotLength * phd_sin(item->pos.yRot) >> W2V_SHIFT)); x = enemy->pos.xPos + enemy->speed * PREDICTIVE_SCALE_FACTOR * phd_sin(enemy->pos.yRot) - item->pos.xPos + obj->pivotLength * phd_sin(item->pos.yRot);
z = (enemy->pos.zPos + (enemy->speed * PREDICTIVE_SCALE_FACTOR * phd_cos(enemy->pos.yRot) >> W2V_SHIFT)) - (item->pos.zPos + (obj->pivotLength * phd_cos(item->pos.yRot) >> W2V_SHIFT)); z = enemy->pos.zPos + enemy->speed * PREDICTIVE_SCALE_FACTOR * phd_cos(enemy->pos.yRot) - item->pos.zPos + obj->pivotLength * phd_cos(item->pos.yRot);
} }
y = item->pos.yPos - enemy->pos.yPos; y = item->pos.yPos - enemy->pos.yPos;
@ -1961,8 +1961,8 @@ void AdjustStopperFlag(ITEM_INFO* item, int dir, int set)
FLOOR_INFO* floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z); FLOOR_INFO* floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z);
floor->stopper = set; floor->stopper = set;
x = item->pos.xPos + ((1024 * phd_sin(dir)) >> W2V_SHIFT); x = item->pos.xPos + 1024 * phd_sin(dir);
z = item->pos.zPos + ((1024 * phd_cos(dir)) >> W2V_SHIFT); z = item->pos.zPos + 1024 * phd_cos(dir);
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
GetFloor(x, item->pos.yPos, z, &roomNumber); GetFloor(x, item->pos.yPos, z, &roomNumber);

View file

@ -340,9 +340,9 @@ void MoveCamera(GAME_VECTOR* ideal, int speed)
else else
{ {
short angle = phd_atan(Camera.target.z - Camera.pos.z, Camera.target.x - Camera.pos.x); short angle = phd_atan(Camera.target.z - Camera.pos.z, Camera.target.x - Camera.pos.x);
Camera.mikePos.x = Camera.pos.x + (PhdPerspective * phd_sin(angle) >> W2V_SHIFT); Camera.mikePos.x = Camera.pos.x + PhdPerspective * phd_sin(angle);
Camera.mikePos.y = Camera.pos.y; Camera.mikePos.y = Camera.pos.y;
Camera.mikePos.z = Camera.pos.z + (PhdPerspective * phd_cos(angle) >> W2V_SHIFT); Camera.mikePos.z = Camera.pos.z + PhdPerspective * phd_cos(angle);
Camera.oldType = Camera.type; Camera.oldType = Camera.type;
} }
} }
@ -362,7 +362,7 @@ void ChaseCamera(ITEM_INFO* item)
else if (Camera.actualElevation < -ANGLE(85)) else if (Camera.actualElevation < -ANGLE(85))
Camera.actualElevation = -ANGLE(85); Camera.actualElevation = -ANGLE(85);
int distance = Camera.targetDistance * phd_cos(Camera.actualElevation) >> W2V_SHIFT; int distance = Camera.targetDistance * phd_cos(Camera.actualElevation);
GetFloor(Camera.target.x, Camera.target.y, Camera.target.z, &Camera.target.roomNumber); GetFloor(Camera.target.x, Camera.target.y, Camera.target.z, &Camera.target.roomNumber);
if (g_Level.Rooms[Camera.target.roomNumber].flags & ENV_FLAG_SWAMP) if (g_Level.Rooms[Camera.target.roomNumber].flags & ENV_FLAG_SWAMP)
@ -392,7 +392,7 @@ void ChaseCamera(ITEM_INFO* item)
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
Ideals[i].y = Camera.target.y + (Camera.targetDistance * phd_sin(Camera.actualElevation) >> W2V_SHIFT); Ideals[i].y = Camera.target.y + Camera.targetDistance * phd_sin(Camera.actualElevation);
} }
int farthest = 0x7FFFFFFF; int farthest = 0x7FFFFFFF;
@ -412,8 +412,8 @@ void ChaseCamera(ITEM_INFO* item)
angle = (i - 1) * ANGLE(90); angle = (i - 1) * ANGLE(90);
} }
Ideals[i].x = Camera.target.x - ((distance * phd_sin(angle)) >> W2V_SHIFT); Ideals[i].x = Camera.target.x - distance * phd_sin(angle);
Ideals[i].z = Camera.target.z - ((distance * phd_cos(angle)) >> W2V_SHIFT); Ideals[i].z = Camera.target.z - distance * phd_cos(angle);
Ideals[i].roomNumber = Camera.target.roomNumber; Ideals[i].roomNumber = Camera.target.roomNumber;
if (mgLOS(&Camera.target, &Ideals[i], 200)) if (mgLOS(&Camera.target, &Ideals[i], 200))
@ -579,11 +579,11 @@ void CombatCamera(ITEM_INFO* item)
UpdateCameraElevation(); UpdateCameraElevation();
Camera.targetDistance = 1536; Camera.targetDistance = 1536;
int distance = Camera.targetDistance * phd_cos(Camera.actualElevation) >> W2V_SHIFT; int distance = Camera.targetDistance * phd_cos(Camera.actualElevation);
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
Ideals[i].y = Camera.target.y + (Camera.targetDistance * phd_sin(Camera.actualElevation) >> W2V_SHIFT); Ideals[i].y = Camera.target.y + Camera.targetDistance * phd_sin(Camera.actualElevation);
} }
int farthest = 0x7FFFFFFF; int farthest = 0x7FFFFFFF;
@ -603,8 +603,8 @@ void CombatCamera(ITEM_INFO* item)
angle = (i - 1) * ANGLE(90); angle = (i - 1) * ANGLE(90);
} }
Ideals[i].x = Camera.target.x - ((distance * phd_sin(angle)) >> W2V_SHIFT); Ideals[i].x = Camera.target.x - distance * phd_sin(angle);
Ideals[i].z = Camera.target.z - ((distance * phd_cos(angle)) >> W2V_SHIFT); Ideals[i].z = Camera.target.z - distance * phd_cos(angle);
Ideals[i].roomNumber = Camera.target.roomNumber; Ideals[i].roomNumber = Camera.target.roomNumber;
if (mgLOS(&Camera.target, &Ideals[i], 200)) if (mgLOS(&Camera.target, &Ideals[i], 200))
@ -1119,8 +1119,8 @@ void LookCamera(ITEM_INFO* item)
else else
{ {
Camera.actualAngle = phd_atan(Camera.target.z - Camera.pos.z, Camera.target.x - Camera.pos.x); Camera.actualAngle = phd_atan(Camera.target.z - Camera.pos.z, Camera.target.x - Camera.pos.x);
Camera.mikePos.x = Camera.pos.x + ((PhdPerspective * phd_sin(Camera.actualAngle)) >> W2V_SHIFT); Camera.mikePos.x = Camera.pos.x + PhdPerspective * phd_sin(Camera.actualAngle);
Camera.mikePos.z = Camera.pos.z + ((PhdPerspective * phd_cos(Camera.actualAngle)) >> W2V_SHIFT); Camera.mikePos.z = Camera.pos.z + PhdPerspective * phd_cos(Camera.actualAngle);
Camera.mikePos.y = Camera.pos.y; Camera.mikePos.y = Camera.pos.y;
} }
@ -1214,11 +1214,11 @@ void BinocularCamera(ITEM_INFO* item)
Camera.pos.z = z; Camera.pos.z = z;
Camera.pos.roomNumber = roomNumber; Camera.pos.roomNumber = roomNumber;
int l = 20736 * phd_cos(headXrot) >> W2V_SHIFT; int l = 20736 * phd_cos(headXrot);
int tx = x + (l * phd_sin(LaraItem->pos.yRot + headYrot) >> W2V_SHIFT); int tx = x + l * phd_sin(LaraItem->pos.yRot + headYrot);
int ty = y - (20736 * phd_sin(headXrot) >> W2V_SHIFT); int ty = y - 20736 * phd_sin(headXrot);
int tz = z + (l * phd_cos(LaraItem->pos.yRot + headYrot) >> W2V_SHIFT); int tz = z + l * phd_cos(LaraItem->pos.yRot + headYrot);
if (Camera.oldType == FIXED_CAMERA) if (Camera.oldType == FIXED_CAMERA)
{ {
@ -1264,8 +1264,8 @@ void BinocularCamera(ITEM_INFO* item)
else else
{ {
Camera.actualAngle = phd_atan(Camera.target.z - Camera.pos.z, Camera.target.x - Camera.pos.x); Camera.actualAngle = phd_atan(Camera.target.z - Camera.pos.z, Camera.target.x - Camera.pos.x);
Camera.mikePos.x = Camera.pos.x + ((PhdPerspective * phd_sin(Camera.actualAngle)) >> W2V_SHIFT); Camera.mikePos.x = Camera.pos.x + PhdPerspective * phd_sin(Camera.actualAngle);
Camera.mikePos.z = Camera.pos.z + ((PhdPerspective * phd_cos(Camera.actualAngle)) >> W2V_SHIFT); Camera.mikePos.z = Camera.pos.z + PhdPerspective * phd_cos(Camera.actualAngle);
Camera.mikePos.y = Camera.pos.y; Camera.mikePos.y = Camera.pos.y;
} }
@ -1694,8 +1694,8 @@ void CalculateCamera()
else else
{ {
int shift = (bounds->X1 + bounds->X2 + bounds->Z1 + bounds->Z2) / 4; int shift = (bounds->X1 + bounds->X2 + bounds->Z1 + bounds->Z2) / 4;
x = item->pos.xPos + (shift * phd_sin(item->pos.yRot) >> W2V_SHIFT); x = item->pos.xPos + shift * phd_sin(item->pos.yRot);
z = item->pos.zPos + (shift * phd_cos(item->pos.yRot) >> W2V_SHIFT); z = item->pos.zPos + shift * phd_cos(item->pos.yRot);
Camera.target.x = x; Camera.target.x = x;
Camera.target.z = z; Camera.target.z = z;

View file

@ -133,7 +133,7 @@ int GetCollidedObjects(ITEM_INFO* collidingItem, int radius, int onlyVisible, IT
short roomsArray[255]; short roomsArray[255];
short numRooms; short numRooms;
short numItems = 0, numMeshes = 0; short numItems = 0, numMeshes = 0;
int c, s; float c, s;
int rx, rz; int rx, rz;
// Collect all the rooms where to check // Collect all the rooms where to check
@ -158,8 +158,8 @@ int GetCollidedObjects(ITEM_INFO* collidingItem, int radius, int onlyVisible, IT
{ {
s = phd_sin(mesh->yRot); s = phd_sin(mesh->yRot);
c = phd_cos(mesh->yRot); c = phd_cos(mesh->yRot);
rx = ((collidingItem->pos.xPos - mesh->x) * c - s * (collidingItem->pos.zPos - mesh->z)) >> W2V_SHIFT; rx = (collidingItem->pos.xPos - mesh->x) * c - s * (collidingItem->pos.zPos - mesh->z);
rz = ((collidingItem->pos.zPos - mesh->z) * c + s * (collidingItem->pos.xPos - mesh->x)) >> W2V_SHIFT; rz = (collidingItem->pos.zPos - mesh->z) * c + s * (collidingItem->pos.xPos - mesh->x);
if (radius + rx + STEP_SIZE/2 >= staticMesh->collisionBox.X1 && rx - radius - STEP_SIZE/2 <= staticMesh->collisionBox.X2) if (radius + rx + STEP_SIZE/2 >= staticMesh->collisionBox.X1 && rx - radius - STEP_SIZE/2 <= staticMesh->collisionBox.X2)
{ {
@ -231,11 +231,11 @@ int GetCollidedObjects(ITEM_INFO* collidingItem, int radius, int onlyVisible, IT
&& collidingItem->pos.yPos + radius + 128 >= item->pos.yPos + framePtr->boundingBox.Y1 && collidingItem->pos.yPos + radius + 128 >= item->pos.yPos + framePtr->boundingBox.Y1
&& collidingItem->pos.yPos - radius - 128 <= item->pos.yPos + framePtr->boundingBox.Y2) && collidingItem->pos.yPos - radius - 128 <= item->pos.yPos + framePtr->boundingBox.Y2)
{ {
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
int rx = (dx * c - s * dz) >> W2V_SHIFT; int rx = dx * c - s * dz;
int rz = (dz * c + s * dx) >> W2V_SHIFT; int rz = dz * c + s * dx;
if (item->objectNumber == ID_TURN_SWITCH) if (item->objectNumber == ID_TURN_SWITCH)
{ {
@ -280,14 +280,14 @@ int TestWithGlobalCollisionBounds(ITEM_INFO* item, ITEM_INFO* lara, COLL_INFO* c
if (item->pos.yPos + GlobalCollisionBounds.Y1 >= framePtr->boundingBox.Y2) if (item->pos.yPos + GlobalCollisionBounds.Y1 >= framePtr->boundingBox.Y2)
return false; return false;
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
int dx = lara->pos.xPos - item->pos.xPos; int dx = lara->pos.xPos - item->pos.xPos;
int dz = lara->pos.zPos - item->pos.zPos; int dz = lara->pos.zPos - item->pos.zPos;
int x = (c * dx - s * dz) >> W2V_SHIFT; int x = c * dx - s * dz;
int z = (c * dz + s * dx) >> W2V_SHIFT; int z = c * dz + s * dx;
if (x < GlobalCollisionBounds.X1 - coll->radius || if (x < GlobalCollisionBounds.X1 - coll->radius ||
x > GlobalCollisionBounds.X2 + coll->radius || x > GlobalCollisionBounds.X2 + coll->radius ||
@ -326,11 +326,10 @@ void TestForObjectOnLedge(ITEM_INFO* item, COLL_INFO* coll)//2A940(<), 2AB68(<)
s.roomNumber = LaraItem->roomNumber; s.roomNumber = LaraItem->roomNumber;
GAME_VECTOR d; GAME_VECTOR d;
d.x = 0; d.x = s.x + phd_sin(LaraItem->pos.yRot) * 768;
d.x = (s.x + ((phd_sin(LaraItem->pos.yRot) << 1) + phd_sin(LaraItem->pos.yRot))) >> 4;
d.y = s.y; d.y = s.y;
d.z = (s.z + ((phd_cos(LaraItem->pos.yRot) << 1) + phd_cos(LaraItem->pos.yRot))) >> 4; d.z = s.z + phd_cos(LaraItem->pos.yRot) * 768;
LOS(&s, &d); LOS(&s, &d);
PHD_VECTOR v; PHD_VECTOR v;
@ -465,15 +464,15 @@ int TestBoundsCollideStatic(BOUNDING_BOX* bounds, PHD_3DPOS* pos, int radius)
if (pos->yPos + bounds->Y1 >= LaraItem->pos.yPos + frame->boundingBox.Y2) if (pos->yPos + bounds->Y1 >= LaraItem->pos.yPos + frame->boundingBox.Y2)
return false; return false;
int c, s; float c, s;
int x, z, dx, dz; int x, z, dx, dz;
c = phd_cos(pos->yRot); c = phd_cos(pos->yRot);
s = phd_sin(pos->yRot); s = phd_sin(pos->yRot);
x = LaraItem->pos.xPos - pos->xPos; x = LaraItem->pos.xPos - pos->xPos;
z = LaraItem->pos.zPos - pos->zPos; z = LaraItem->pos.zPos - pos->zPos;
dx = (c * x - s * z) >> W2V_SHIFT; dx = c * x - s * z;
dz = (c * z + s * x) >> W2V_SHIFT; dz = c * z + s * x;
if (dx <= radius + bounds->X2 if (dx <= radius + bounds->X2
&& dx >= bounds->X1 - radius && dx >= bounds->X1 - radius
@ -490,7 +489,7 @@ int TestBoundsCollideStatic(BOUNDING_BOX* bounds, PHD_3DPOS* pos, int radius)
int ItemPushLaraStatic(ITEM_INFO* item, BOUNDING_BOX* bounds, PHD_3DPOS* pos, COLL_INFO* coll) int ItemPushLaraStatic(ITEM_INFO* item, BOUNDING_BOX* bounds, PHD_3DPOS* pos, COLL_INFO* coll)
{ {
int c, s; float c, s;
int dx, dz, rx, rz, minX, maxX, minZ, maxZ; int dx, dz, rx, rz, minX, maxX, minZ, maxZ;
int left, right, top, bottom; int left, right, top, bottom;
short oldFacing; short oldFacing;
@ -499,8 +498,8 @@ int ItemPushLaraStatic(ITEM_INFO* item, BOUNDING_BOX* bounds, PHD_3DPOS* pos, CO
s = phd_sin(pos->yRot); s = phd_sin(pos->yRot);
dx = LaraItem->pos.xPos - pos->xPos; dx = LaraItem->pos.xPos - pos->xPos;
dz = LaraItem->pos.zPos - pos->zPos; dz = LaraItem->pos.zPos - pos->zPos;
rx = (c * dx - s * dz) >> W2V_SHIFT; rx = c * dx - s * dz;
rz = (c * dz + s * dx) >> W2V_SHIFT; rz = c * dz + s * dx;
minX = bounds->X1 - coll->radius; minX = bounds->X1 - coll->radius;
maxX = bounds->X2 + coll->radius; maxX = bounds->X2 + coll->radius;
minZ = bounds->Z1 - coll->radius; minZ = bounds->Z1 - coll->radius;
@ -528,8 +527,8 @@ int ItemPushLaraStatic(ITEM_INFO* item, BOUNDING_BOX* bounds, PHD_3DPOS* pos, CO
else else
rz -= bottom; rz -= bottom;
item->pos.xPos = pos->xPos + ((c * rx + s * rz) >> W2V_SHIFT); item->pos.xPos = pos->xPos + c * rx + s * rz;
item->pos.zPos = pos->zPos + ((c * rz - s * rx) >> W2V_SHIFT); item->pos.zPos = pos->zPos + c * rz - s * rx;
coll->badPos = NO_BAD_POS; coll->badPos = NO_BAD_POS;
coll->badNeg = -STEPUP_HEIGHT; coll->badNeg = -STEPUP_HEIGHT;
@ -565,7 +564,7 @@ int ItemPushLaraStatic(ITEM_INFO* item, BOUNDING_BOX* bounds, PHD_3DPOS* pos, CO
int ItemPushLara(ITEM_INFO* item, ITEM_INFO* l, COLL_INFO* coll, int spazon, char bigpush) int ItemPushLara(ITEM_INFO* item, ITEM_INFO* l, COLL_INFO* coll, int spazon, char bigpush)
{ {
int c, s; float c, s;
int dx, dz, rx, rz, minX, maxX, minZ, maxZ; int dx, dz, rx, rz, minX, maxX, minZ, maxZ;
int left, right, bottom, top; int left, right, bottom, top;
BOUNDING_BOX* bounds; BOUNDING_BOX* bounds;
@ -575,8 +574,8 @@ int ItemPushLara(ITEM_INFO* item, ITEM_INFO* l, COLL_INFO* coll, int spazon, cha
s = phd_sin(item->pos.yRot); s = phd_sin(item->pos.yRot);
dx = LaraItem->pos.xPos - item->pos.xPos; dx = LaraItem->pos.xPos - item->pos.xPos;
dz = LaraItem->pos.zPos - item->pos.zPos; dz = LaraItem->pos.zPos - item->pos.zPos;
rx = (c * dx - s * dz) >> W2V_SHIFT; rx = c * dx - s * dz;
rz = (c * dz + s * dx) >> W2V_SHIFT; rz = c * dz + s * dx;
if (bigpush & 2) if (bigpush & 2)
bounds = &GlobalCollisionBounds; bounds = &GlobalCollisionBounds;
@ -619,16 +618,16 @@ int ItemPushLara(ITEM_INFO* item, ITEM_INFO* l, COLL_INFO* coll, int spazon, cha
else else
rz -= bottom; rz -= bottom;
l->pos.xPos = item->pos.xPos + ((c * rx + s * rz) >> W2V_SHIFT); l->pos.xPos = item->pos.xPos + c * rx + s * rz;
l->pos.zPos = item->pos.zPos + ((c * rz - s * rx) >> W2V_SHIFT); l->pos.zPos = item->pos.zPos + c * rz - s * rx;
if (spazon && bounds->Y2 - bounds->Y1 > STEP_SIZE) if (spazon && bounds->Y2 - bounds->Y1 > STEP_SIZE)
{ {
rx = (bounds->X1 + bounds->X2) / 2; rx = (bounds->X1 + bounds->X2) / 2;
rz = (bounds->Z1 + bounds->Z2) / 2; rz = (bounds->Z1 + bounds->Z2) / 2;
dx -= (c * rx + s * rz) >> W2V_SHIFT; dx -= c * rx + s * rz;
dz -= (c * rz - s * rx) >> W2V_SHIFT; dz -= c * rz - s * rx;
Lara.hitDirection = (l->pos.yRot - phd_atan(dz, dz) - ANGLE(135)) >> W2V_SHIFT; Lara.hitDirection = (l->pos.yRot - phd_atan(dz, dz) - ANGLE(135)) >> W2V_SHIFT;
@ -959,7 +958,7 @@ int TestBoundsCollide(ITEM_INFO* item, ITEM_INFO* l, int radius)
{ {
BOUNDING_BOX* bounds; BOUNDING_BOX* bounds;
BOUNDING_BOX* laraBounds; BOUNDING_BOX* laraBounds;
int c, s; float c, s;
int x, z; int x, z;
int dx, dz; int dx, dz;
@ -974,8 +973,8 @@ int TestBoundsCollide(ITEM_INFO* item, ITEM_INFO* l, int radius)
s = phd_sin(item->pos.yRot); s = phd_sin(item->pos.yRot);
x = l->pos.xPos - item->pos.xPos; x = l->pos.xPos - item->pos.xPos;
z = l->pos.zPos - item->pos.zPos; z = l->pos.zPos - item->pos.zPos;
dx = (c * x - s * z) >> W2V_SHIFT; dx = c * x - s * z;
dz = (c * z + s * x) >> W2V_SHIFT; dz = c * z + s * x;
if (dx >= bounds->X1 - radius if (dx >= bounds->X1 - radius
&& dx <= radius + bounds->X2 && dx <= radius + bounds->X2
@ -993,7 +992,7 @@ int TestBoundsCollide(ITEM_INFO* item, ITEM_INFO* l, int radius)
void CreatureCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) void CreatureCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
{ {
ITEM_INFO* item = &g_Level.Items[itemNum]; ITEM_INFO* item = &g_Level.Items[itemNum];
int c, s; float c, s;
int x, z, rx, rz; int x, z, rx, rz;
ANIM_FRAME* frame; ANIM_FRAME* frame;
@ -1019,7 +1018,7 @@ void CreatureCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
if (frame->boundingBox.Y2 - frame->boundingBox.Y1 > STEP_SIZE) if (frame->boundingBox.Y2 - frame->boundingBox.Y1 > STEP_SIZE)
{ {
int angle = (l->pos.yRot - phd_atan(z - ((c * rx - s * rz) >> W2V_SHIFT), x - ((c * rx + s * rz) >> W2V_SHIFT)) - ANGLE(135)) >> W2V_SHIFT; int angle = (l->pos.yRot - phd_atan(z - c * rx - s * rz, x - c * rx + s * rz) - ANGLE(135)) >> W2V_SHIFT;
Lara.hitDirection = (short)angle; Lara.hitDirection = (short)angle;
// TODO: check if a second Lara.hitFrame++; is required there ! // TODO: check if a second Lara.hitFrame++; is required there !
Lara.hitFrame++; Lara.hitFrame++;
@ -1127,8 +1126,8 @@ void GetCollisionInfo(COLL_INFO* coll, int xPos, int yPos, int zPos, int roomNum
break; break;
}*/ }*/
XFront = (phd_sin(coll->facing) * coll->radius) >> (W2V_SHIFT); XFront = phd_sin(coll->facing) * coll->radius;
ZFront = (phd_cos(coll->facing) * coll->radius) >> (W2V_SHIFT); ZFront = phd_cos(coll->facing) * coll->radius;
xleft = -ZFront; xleft = -ZFront;
zleft = XFront; zleft = XFront;
xright = ZFront; xright = ZFront;
@ -1620,8 +1619,8 @@ void CalcItemToFloorRotation(ITEM_INFO* item, int radiusDivide)
radiusZ = bounds->Z2 / radiusDivide; // need divide in any case else it's too much ! radiusZ = bounds->Z2 / radiusDivide; // need divide in any case else it's too much !
ratioXZ = radiusZ / radiusX; ratioXZ = radiusZ / radiusX;
frontX = (phd_sin(item->pos.yRot) * radiusZ) >> W2V_SHIFT; frontX = phd_sin(item->pos.yRot) * radiusZ;
frontZ = (phd_cos(item->pos.yRot) * radiusZ) >> W2V_SHIFT; frontZ = phd_cos(item->pos.yRot) * radiusZ;
leftX = -frontZ * ratioXZ; leftX = -frontZ * ratioXZ;
leftZ = frontX * ratioXZ; leftZ = frontX * ratioXZ;
rightX = frontZ * ratioXZ; rightX = frontZ * ratioXZ;

View file

@ -1346,12 +1346,12 @@ short GetDoor(FLOOR_INFO *floor)
void TranslateItem(ITEM_INFO *item, int x, int y, int z) void TranslateItem(ITEM_INFO *item, int x, int y, int z)
{ {
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
item->pos.xPos += (c * x + s * z) >> W2V_SHIFT; item->pos.xPos += c * x + s * z;
item->pos.yPos += y; item->pos.yPos += y;
item->pos.zPos += (-s * x + c * z) >> W2V_SHIFT; item->pos.zPos += -s * x + c * z;
} }
int GetWaterSurface(int x, int y, int z, short roomNumber) int GetWaterSurface(int x, int y, int z, short roomNumber)
@ -2958,11 +2958,11 @@ void AnimateItem(ITEM_INFO *item)
lateral >>= 16; lateral >>= 16;
} }
item->pos.xPos += item->speed * phd_sin(item->pos.yRot) >> W2V_SHIFT; item->pos.xPos += item->speed * phd_sin(item->pos.yRot);
item->pos.zPos += item->speed * phd_cos(item->pos.yRot) >> W2V_SHIFT; item->pos.zPos += item->speed * phd_cos(item->pos.yRot);
item->pos.xPos += lateral * phd_sin(item->pos.yRot + ANGLE(90)) >> W2V_SHIFT; item->pos.xPos += lateral * phd_sin(item->pos.yRot + ANGLE(90));
item->pos.zPos += lateral * phd_cos(item->pos.yRot + ANGLE(90)) >> W2V_SHIFT; item->pos.zPos += lateral * phd_cos(item->pos.yRot + ANGLE(90));
// Update matrices // Update matrices
short itemNumber = item - g_Level.Items.data(); short itemNumber = item - g_Level.Items.data();

View file

@ -327,8 +327,8 @@ void ControlWaterfallMist(short itemNumber) // ControlWaterfallMist
ITEM_INFO* item = &g_Level.Items[itemNumber]; ITEM_INFO* item = &g_Level.Items[itemNumber];
int x, z; int x, z;
x = item->pos.xPos - (phd_sin(item->pos.yRot + ANGLE(180)) >> 5) + ((phd_sin(item->pos.yRot - ANGLE(90)) * 256) >> W2V_SHIFT); x = item->pos.xPos - phd_sin(item->pos.yRot + ANGLE(180)) * 512 + phd_sin(item->pos.yRot - ANGLE(90)) * 256;
z = item->pos.zPos - (phd_cos(item->pos.yRot + ANGLE(180)) >> 5) + ((phd_cos(item->pos.yRot - ANGLE(90)) * 256) >> W2V_SHIFT); z = item->pos.zPos - phd_cos(item->pos.yRot + ANGLE(180)) * 512 + phd_cos(item->pos.yRot - ANGLE(90)) * 256;
TriggerWaterfallMist(x, item->pos.yPos, z, item->pos.yRot + ANGLE(180)); TriggerWaterfallMist(x, item->pos.yPos, z, item->pos.yRot + ANGLE(180));
SoundEffect(SFX_WATERFALL_LOOP, &item->pos, 0); SoundEffect(SFX_WATERFALL_LOOP, &item->pos, 0);

View file

@ -1083,9 +1083,9 @@ void TriggerWaterfallMist(int x, int y, int z, int angle)
spark->life = spark->sLife = (GetRandomControl() & 3) + 6; spark->life = spark->sLife = (GetRandomControl() & 3) + 6;
spark->fadeToBlack = spark->life - 4; spark->fadeToBlack = spark->life - 4;
dl = ((dh + (GlobalCounter << 6)) % 1536) + (GetRandomControl() & 0x3F) - 32; dl = ((dh + (GlobalCounter << 6)) % 1536) + (GetRandomControl() & 0x3F) - 32;
spark->x = dl * phd_sin(ang1) >> W2V_SHIFT + (GetRandomControl() & 0xF) + x - 8; spark->x = dl * phd_sin(ang1) + (GetRandomControl() & 0xF) + x - 8;
spark->y = (GetRandomControl() & 0xF) + y - 8; spark->y = (GetRandomControl() & 0xF) + y - 8;
spark->z = dl * phd_cos(ang1) >> W2V_SHIFT + (GetRandomControl() & 0xF) + z - 8; spark->z = dl * phd_cos(ang1) + (GetRandomControl() & 0xF) + z - 8;
spark->xVel = 0; spark->xVel = 0;
spark->zVel = 0; spark->zVel = 0;
spark->friction = 0; spark->friction = 0;
@ -1117,11 +1117,11 @@ void TriggerWaterfallMist(int x, int y, int z, int angle)
spark->life = spark->sLife = (GetRandomControl() & 3) + 6; spark->life = spark->sLife = (GetRandomControl() & 3) + 6;
spark->fadeToBlack = spark->life - 1; spark->fadeToBlack = spark->life - 1;
dl = GetRandomControl() % 1408 + 64; dl = GetRandomControl() % 1408 + 64;
spark->x = dl * phd_sin(ang1) >> W2V_SHIFT + (GetRandomControl() & 0x1F) + x - 16; spark->x = dl * phd_sin(ang1) + (GetRandomControl() & 0x1F) + x - 16;
spark->y = (GetRandomControl() & 0xF) + y - 8; spark->y = (GetRandomControl() & 0xF) + y - 8;
spark->xVel = 0; spark->xVel = 0;
spark->zVel = 0; spark->zVel = 0;
spark->z = dl * phd_cos(ang1) >> W2V_SHIFT + (GetRandomControl() & 0x1F) + z - 16; spark->z = dl * phd_cos(ang1) + (GetRandomControl() & 0x1F) + z - 16;
spark->friction = 0; spark->friction = 0;
spark->flags = 10; spark->flags = 10;
spark->yVel = GetRandomControl() & 0x100 + (GetRandomControl() & 0x7F) + 128; spark->yVel = GetRandomControl() & 0x100 + (GetRandomControl() & 0x7F) + 128;

View file

@ -203,8 +203,8 @@ void TorchControl(short itemNumber) // (F) (D)
item->pos.zRot = 0; item->pos.zRot = 0;
} }
int xv = item->speed * phd_sin(item->pos.yRot) >> W2V_SHIFT; int xv = item->speed * phd_sin(item->pos.yRot);
int zv = item->speed * phd_cos(item->pos.yRot) >> W2V_SHIFT; int zv = item->speed * phd_cos(item->pos.yRot);
item->pos.xPos += xv; item->pos.xPos += xv;
item->pos.zPos += zv; item->pos.zPos += zv;

View file

@ -225,8 +225,8 @@ void HairControl(int cutscene, int ponytail, ANIM_FRAME* framePtr)
WindAngle = (WindAngle + ((DWindAngle - WindAngle) >> 3)) & 0x1FFE; WindAngle = (WindAngle + ((DWindAngle - WindAngle) >> 3)) & 0x1FFE;
SmokeWindX = Wind * phd_sin(WindAngle << 3) >> 14; SmokeWindX = Wind * phd_sin(WindAngle << 3);
SmokeWindZ = Wind * phd_cos(WindAngle << 3) >> 14; SmokeWindZ = Wind * phd_cos(WindAngle << 3);
for (int i = 1; i < HAIR_SEGMENTS + 1; i++, bone += 4) for (int i = 1; i < HAIR_SEGMENTS + 1; i++, bone += 4)
{ {

View file

@ -51,10 +51,10 @@ void ControlMissile(short fxNumber)
if (fx->objectNumber == ID_SCUBA_HARPOON && !(g_Level.Rooms[fx->roomNumber].flags & 1) && fx->pos.xRot > -0x3000) if (fx->objectNumber == ID_SCUBA_HARPOON && !(g_Level.Rooms[fx->roomNumber].flags & 1) && fx->pos.xRot > -0x3000)
fx->pos.xRot -= ONE_DEGREE; fx->pos.xRot -= ONE_DEGREE;
fx->pos.yPos += (fx->speed * phd_sin(-fx->pos.xRot) >> W2V_SHIFT); fx->pos.yPos += fx->speed * phd_sin(-fx->pos.xRot);
speed = fx->speed * phd_cos(fx->pos.xRot) >> W2V_SHIFT; speed = fx->speed * phd_cos(fx->pos.xRot);
fx->pos.zPos += (speed * phd_cos(fx->pos.yRot) >> W2V_SHIFT); fx->pos.zPos += speed * phd_cos(fx->pos.yRot);
fx->pos.xPos += (speed * phd_sin(fx->pos.yRot) >> W2V_SHIFT); fx->pos.xPos += speed * phd_sin(fx->pos.yRot);
roomNumber = fx->roomNumber; roomNumber = fx->roomNumber;
floor = GetFloor(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, &roomNumber); floor = GetFloor(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, &roomNumber);
@ -144,8 +144,8 @@ void ControlNatlaGun(short fx_number)
/* If first frame, then start another explosion at next position */ /* If first frame, then start another explosion at next position */
if (fx->frameNumber == -1) if (fx->frameNumber == -1)
{ {
z = fx->pos.zPos + (fx->speed * phd_cos(fx->pos.yRot) >> W2V_SHIFT); z = fx->pos.zPos + fx->speed * phd_cos(fx->pos.yRot);
x = fx->pos.xPos + (fx->speed * phd_sin(fx->pos.yRot) >> W2V_SHIFT); x = fx->pos.xPos + fx->speed * phd_sin(fx->pos.yRot);
y = fx->pos.yPos; y = fx->pos.yPos;
roomNumber = fx->roomNumber; roomNumber = fx->roomNumber;
floor = GetFloor(x, y, z, &roomNumber); floor = GetFloor(x, y, z, &roomNumber);

View file

@ -19,7 +19,7 @@ int ShotLara(ITEM_INFO* item, AI_INFO* info, BITE_INFO* gun, short extra_rotatio
if (info->distance <= SQUARE(8192) && Targetable(item, info)) if (info->distance <= SQUARE(8192) && Targetable(item, info))
{ {
int distance = phd_sin(info->enemyFacing) * enemy->speed >> W2V_SHIFT * SQUARE(8192) / 300; int distance = phd_sin(info->enemyFacing) * enemy->speed * SQUARE(8192) / 300;
distance = info->distance + SQUARE(distance); distance = info->distance + SQUARE(distance);
if (distance <= SQUARE(8192)) if (distance <= SQUARE(8192))
{ {

View file

@ -178,7 +178,7 @@ void RopeCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll) // (F) (D)
if (TrInput & IN_ACTION && Lara.gunStatus == LG_NO_ARMS && (l->currentAnimState == LS_REACH || l->currentAnimState == LS_JUMP_UP) && l->gravityStatus && l->fallspeed > 0 && rope->active) if (TrInput & IN_ACTION && Lara.gunStatus == LG_NO_ARMS && (l->currentAnimState == LS_REACH || l->currentAnimState == LS_JUMP_UP) && l->gravityStatus && l->fallspeed > 0 && rope->active)
{ {
frame = GetBoundsAccurate(l); frame = GetBoundsAccurate(l);
segment = _0x0046D200(rope, l->pos.xPos, l->pos.yPos + frame->Y1 + 512, l->pos.zPos + ((int)(frame->Z2 * phd_cos(l->pos.yRot)) >> W2V_SHIFT), l->currentAnimState == LS_REACH ? 128 : 320); segment = _0x0046D200(rope, l->pos.xPos, l->pos.yPos + frame->Y1 + 512, l->pos.zPos + frame->Z2 * phd_cos(l->pos.yRot), l->currentAnimState == LS_REACH ? 128 : 320);
if (segment >= 0) if (segment >= 0)
{ {
if (l->currentAnimState == LS_REACH) if (l->currentAnimState == LS_REACH)
@ -390,9 +390,9 @@ int _0x0046D200(ROPE_STRUCT* rope, int x, int y, int z, int radius) // (F) (D)
void ApplyVelocityToRope(int node, short angle, short n) // (F) (D) void ApplyVelocityToRope(int node, short angle, short n) // (F) (D)
{ {
SetPendulumVelocity( SetPendulumVelocity(
(unsigned short) n * phd_sin(angle) >> 2, (unsigned short) n * phd_sin(angle) * 4096,
0, 0,
(unsigned short) n * phd_cos(angle) >> 2); /* @ORIGINAL_BUG: casting n to unsigned short results in the rope glitch */ (unsigned short) n * phd_cos(angle) * 4096); /* @ORIGINAL_BUG: casting n to unsigned short results in the rope glitch */
} }
void SetPendulumVelocity(int x, int y, int z) // (F) (D) void SetPendulumVelocity(int x, int y, int z) // (F) (D)
@ -702,11 +702,11 @@ void DelAlignLaraToRope(ITEM_INFO* item) // (F) (D)
diff2.x = diff.x; diff2.x = diff.x;
diff2.y = diff.y; diff2.y = diff.y;
diff2.z = diff.z; diff2.z = diff.z;
ScaleVector(&vec3, phd_cos(ropeY), &vec3); ScaleVector(&vec3, 16384 * phd_cos(ropeY), &vec3);
ScaleVector(&diff2, DotProduct(&diff2, &vec2), &diff2); ScaleVector(&diff2, DotProduct(&diff2, &vec2), &diff2);
ScaleVector(&diff2, 4096 - phd_cos(ropeY), &diff2); ScaleVector(&diff2, 4096 - 16384 * phd_cos(ropeY), &diff2);
CrossProduct(&diff, &vec2, &vec4); CrossProduct(&diff, &vec2, &vec4);
ScaleVector(&vec4, phd_sin(ropeY), &vec4); ScaleVector(&vec4, 16384 * phd_sin(ropeY), &vec4);
diff2.x += vec3.x; diff2.x += vec3.x;
diff2.y += vec3.y; diff2.y += vec3.y;
diff2.z += vec3.z; diff2.z += vec3.z;

View file

@ -584,8 +584,8 @@ void TurnSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
item->animNumber = Objects[item->objectNumber].animIndex + 4; item->animNumber = Objects[item->objectNumber].animIndex + 4;
item->frameNumber = g_Level.Anims[item->animNumber].frameBase; item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
item->itemFlags[0] = 1; item->itemFlags[0] = 1;
ForcedFixedCamera.x = item->pos.xPos - (1024 * phd_sin(item->pos.yRot) >> W2V_SHIFT); ForcedFixedCamera.x = item->pos.xPos - 1024 * phd_sin(item->pos.yRot);
ForcedFixedCamera.z = item->pos.zPos - (1024 * phd_cos(item->pos.yRot) >> W2V_SHIFT); ForcedFixedCamera.z = item->pos.zPos - 1024 * phd_cos(item->pos.yRot);
Lara.isMoving = 0; Lara.isMoving = 0;
Lara.headYrot = 0; Lara.headYrot = 0;
Lara.headXrot = 0; Lara.headXrot = 0;
@ -626,8 +626,8 @@ void TurnSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
flag = 1; flag = 1;
l->frameNumber = g_Level.Anims[319].frameBase; l->frameNumber = g_Level.Anims[319].frameBase;
item->itemFlags[0] = 2; item->itemFlags[0] = 2;
ForcedFixedCamera.x = item->pos.xPos + (1024 * phd_sin(item->pos.yRot) >> W2V_SHIFT); ForcedFixedCamera.x = item->pos.xPos + 1024 * phd_sin(item->pos.yRot);
ForcedFixedCamera.z = item->pos.zPos + (1024 * phd_cos(item->pos.yRot) >> W2V_SHIFT); ForcedFixedCamera.z = item->pos.zPos + 1024 * phd_cos(item->pos.yRot);
} }
else else
{ {
@ -854,9 +854,9 @@ void UnderwaterSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
AddActiveItem(itemNum); AddActiveItem(itemNum);
ForcedFixedCamera.x = item->pos.xPos - 1024 * phd_sin(item->pos.yRot + ANGLE(90)) >> W2V_SHIFT; ForcedFixedCamera.x = item->pos.xPos - 1024 * phd_sin(item->pos.yRot + ANGLE(90));
ForcedFixedCamera.y = item->pos.yPos - 1024; ForcedFixedCamera.y = item->pos.yPos - 1024;
ForcedFixedCamera.z = item->pos.zPos - 1024 * phd_cos(item->pos.yRot + ANGLE(90)) >> W2V_SHIFT; ForcedFixedCamera.z = item->pos.zPos - 1024 * phd_cos(item->pos.yRot + ANGLE(90));
ForcedFixedCamera.roomNumber = item->roomNumber; ForcedFixedCamera.roomNumber = item->roomNumber;
return; return;
@ -885,9 +885,9 @@ void UnderwaterSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
AddActiveItem(itemNum); AddActiveItem(itemNum);
ForcedFixedCamera.x = item->pos.xPos - 1024 * phd_sin(item->pos.yRot + ANGLE(90)) >> W2V_SHIFT; ForcedFixedCamera.x = item->pos.xPos - 1024 * phd_sin(item->pos.yRot + ANGLE(90));
ForcedFixedCamera.y = item->pos.yPos - 1024; ForcedFixedCamera.y = item->pos.yPos - 1024;
ForcedFixedCamera.z = item->pos.zPos - 1024 * phd_cos(item->pos.yRot + ANGLE(90)) >> W2V_SHIFT; ForcedFixedCamera.z = item->pos.zPos - 1024 * phd_cos(item->pos.yRot + ANGLE(90));
ForcedFixedCamera.roomNumber = item->roomNumber; ForcedFixedCamera.roomNumber = item->roomNumber;
} }
} }

View file

@ -684,8 +684,8 @@ void TriggerBlood(int x, int y, int z, int unk, int num)// (F)
blood->z = (GetRandomControl() & 0x1F) + z - 16; blood->z = (GetRandomControl() & 0x1F) + z - 16;
int a = (unk == -1 ? GetRandomControl() : (GetRandomControl() & 0x1F) + unk - 16) & 0xFFF; int a = (unk == -1 ? GetRandomControl() : (GetRandomControl() & 0x1F) + unk - 16) & 0xFFF;
int b = GetRandomControl() & 0xF; int b = GetRandomControl() & 0xF;
blood->zVel = b * phd_cos(a << 4) >> 9; blood->zVel = b * phd_cos(a << 4) * 32;
blood->xVel = -b * phd_sin(a << 4) >> 9; blood->xVel = -b * phd_sin(a << 4) * 32;
blood->friction = 4; blood->friction = 4;
blood->yVel = -((GetRandomControl() & 0xFF) + 128); blood->yVel = -((GetRandomControl() & 0xFF) + 128);
blood->rotAng = GetRandomControl() & 0xFFF; blood->rotAng = GetRandomControl() & 0xFFF;
@ -949,9 +949,9 @@ void UpdateGunShells()
gs->pos.yRot += gs->speed * ANGLE(1); gs->pos.yRot += gs->speed * ANGLE(1);
gs->pos.zRot += ANGLE(23); gs->pos.zRot += ANGLE(23);
gs->pos.xPos += gs->speed * phd_sin(gs->dirXrot) >> W2V_SHIFT; gs->pos.xPos += gs->speed * phd_sin(gs->dirXrot);
gs->pos.yPos += gs->fallspeed; gs->pos.yPos += gs->fallspeed;
gs->pos.zPos += gs->speed * phd_cos(gs->dirXrot) >> W2V_SHIFT; gs->pos.zPos += gs->speed * phd_cos(gs->dirXrot);
FLOOR_INFO* floor = GetFloor(gs->pos.xPos, gs->pos.yPos, gs->pos.zPos, &gs->roomNumber); FLOOR_INFO* floor = GetFloor(gs->pos.xPos, gs->pos.yPos, gs->pos.zPos, &gs->roomNumber);
if (g_Level.Rooms[gs->roomNumber].flags & ENV_FLAG_WATER if (g_Level.Rooms[gs->roomNumber].flags & ENV_FLAG_WATER
@ -1028,9 +1028,9 @@ void AddWaterSparks(int x, int y, int z, int num)
spark->sLife = 24; spark->sLife = 24;
spark->transType = COLADD; spark->transType = COLADD;
int random = GetRandomControl() & 0xFFF; int random = GetRandomControl() & 0xFFF;
spark->xVel = -phd_sin(random << 4) >> 7; spark->xVel = -phd_sin(random << 4) * 128;
spark->yVel = -640 - GetRandomControl(); spark->yVel = -640 - GetRandomControl();
spark->zVel = phd_cos(random << 4) >> 7; spark->zVel = phd_cos(random << 4) * 128;
spark->friction = 5; spark->friction = 5;
spark->flags = SP_NONE; spark->flags = SP_NONE;
spark->x = x + (spark->xVel >> 3); spark->x = x + (spark->xVel >> 3);
@ -1374,9 +1374,9 @@ void TriggerShockwaveHitEffect(int x, int y, int z, byte r, byte g, byte b, shor
spark->life = spark->sLife = (GetRandomControl() & 3) + 16; spark->life = spark->sLife = (GetRandomControl() & 3) + 16;
int speed = (GetRandomControl() & 0xF) + vel; int speed = (GetRandomControl() & 0xF) + vel;
spark->xVel = speed * 16 * phd_sin(rot) >> W2V_SHIFT; spark->xVel = speed * 16 * phd_sin(rot);
spark->yVel = -512 - (GetRandomControl() & 0x1FF); spark->yVel = -512 - (GetRandomControl() & 0x1FF);
spark->zVel = speed * 16 * phd_cos(rot) >> W2V_SHIFT; spark->zVel = speed * 16 * phd_cos(rot);
short angle; short angle;
if (GetRandomControl() & 1) if (GetRandomControl() & 1)
@ -1385,8 +1385,8 @@ void TriggerShockwaveHitEffect(int x, int y, int z, byte r, byte g, byte b, shor
angle = rot - ANGLE(90); angle = rot - ANGLE(90);
int shift = (GetRandomControl() & 0x1FF) - 256; int shift = (GetRandomControl() & 0x1FF) - 256;
x += (shift * phd_sin(angle) >> W2V_SHIFT); x += shift * phd_sin(angle);
z += (shift * phd_cos(angle) >> W2V_SHIFT); z += shift * phd_cos(angle);
spark->x = (GetRandomControl() & 0x1F) + x - 16; spark->x = (GetRandomControl() & 0x1F) + x - 16;
spark->y = (GetRandomControl() & 0x1F) + y - 16; spark->y = (GetRandomControl() & 0x1F) + y - 16;
@ -1689,9 +1689,9 @@ void TriggerSmallSplash(int x, int y, int z, int num)
angle = GetRandomControl() << 3; angle = GetRandomControl() << 3;
sptr->xVel = -phd_sin(angle) >> 5; sptr->xVel = -phd_sin(angle) * 512;
sptr->yVel = -640 - (GetRandomControl() & 0xFF); sptr->yVel = -640 - (GetRandomControl() & 0xFF);
sptr->zVel = phd_cos(angle) >> 5; sptr->zVel = phd_cos(angle) * 512;
sptr->friction = 5; sptr->friction = 5;
sptr->flags = 0; sptr->flags = 0;

View file

@ -917,9 +917,9 @@ void FlameEmitter3Control(short itemNumber)
{ {
if (item->triggerFlags == 2 || item->triggerFlags == 4) if (item->triggerFlags == 2 || item->triggerFlags == 4)
{ {
dest.x = item->pos.xPos + 2048 * phd_sin(item->pos.yRot - ANGLE(180)) >> W2V_SHIFT; dest.x = item->pos.xPos + 2048 * phd_sin(item->pos.yRot + ANGLE(180));
dest.y = item->pos.yPos; dest.y = item->pos.yPos;
dest.z = item->pos.zPos + 2048 * phd_cos(item->pos.yRot - ANGLE(180)) >> W2V_SHIFT; dest.z = item->pos.zPos + 2048 * phd_cos(item->pos.yRot + ANGLE(180));
if (GetRandomControl() & 3) if (GetRandomControl() & 3)
{ {

View file

@ -323,15 +323,14 @@ const Vector3 getRandomVectorInCone(const Vector3& direction, const float angleD
return result; return result;
} }
// FIXME: game code still expects << 2 >> W2V_SHIFT so we multiply by 16384.0f float phd_sin(short a)
int phd_sin(short a)
{ {
return (sin(TO_RAD(a)) * 16384.0f); return sin(TO_RAD(a));
} }
int phd_cos(short a) float phd_cos(short a)
{ {
return (cos(TO_RAD(a)) * 16384.0f); return cos(TO_RAD(a));
} }
int mGetAngle(int x1, int y1, int x2, int y2) int mGetAngle(int x1, int y1, int x2, int y2)

View file

@ -36,8 +36,8 @@ short ANGLE(float angle);
float TO_DEGREES(short angle); float TO_DEGREES(short angle);
float TO_RAD(short angle); float TO_RAD(short angle);
int phd_sin(short a); float phd_sin(short a);
int phd_cos(short a); float phd_cos(short a);
// returns a float between 0-1 // returns a float between 0-1
const float frand(); const float frand();

View file

@ -270,10 +270,10 @@ void BubblesControl(short fxNum)
int oldY = fx->pos.yPos; int oldY = fx->pos.yPos;
int oldZ = fx->pos.zPos; int oldZ = fx->pos.zPos;
int c = fx->speed * phd_cos(fx->pos.xRot) >> W2V_SHIFT; int c = fx->speed * phd_cos(fx->pos.xRot);
fx->pos.xPos += c * phd_sin(fx->pos.yRot) >> W2V_SHIFT; fx->pos.xPos += c * phd_sin(fx->pos.yRot);
fx->pos.yPos += fx->speed * phd_sin(-fx->pos.xRot) >> W2V_SHIFT; fx->pos.yPos += fx->speed * phd_sin(-fx->pos.xRot);
fx->pos.zPos += c * phd_cos(fx->pos.yRot) >> W2V_SHIFT; fx->pos.zPos += c * phd_cos(fx->pos.yRot);
short roomNumber = fx->roomNumber; short roomNumber = fx->roomNumber;
FLOOR_INFO* floor = GetFloor(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, &roomNumber); FLOOR_INFO* floor = GetFloor(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, &roomNumber);

View file

@ -207,9 +207,9 @@ void UpdateLocusts(void)
locust->pos.xRot += shiftXrot; locust->pos.xRot += shiftXrot;
} }
locust->pos.xPos += (locust->randomRotation * phd_cos(locust->pos.xRot) >> W2V_SHIFT) * phd_sin(locust->pos.yRot) >> W2V_SHIFT; locust->pos.xPos += locust->randomRotation * phd_cos(locust->pos.xRot) * phd_sin(locust->pos.yRot);
locust->pos.yPos += locust->randomRotation * phd_sin(-locust->pos.xRot) >> W2V_SHIFT; locust->pos.yPos += locust->randomRotation * phd_sin(-locust->pos.xRot);
locust->pos.zPos += (locust->randomRotation * phd_cos(locust->pos.xRot) >> W2V_SHIFT) * phd_cos(locust->pos.yRot) >> W2V_SHIFT; locust->pos.zPos += locust->randomRotation * phd_cos(locust->pos.xRot) * phd_cos(locust->pos.yRot);
if (ItemNearTarget(&locust->pos, locust->target, CLICK(1) / 2)) if (ItemNearTarget(&locust->pos, locust->target, CLICK(1) / 2))
{ {
TriggerBlood(locust->pos.xPos, locust->pos.yPos, locust->pos.zPos, 2 * GetRandomControl(), 2); TriggerBlood(locust->pos.xPos, locust->pos.yPos, locust->pos.zPos, 2 * GetRandomControl(), 2);

View file

@ -55,9 +55,9 @@ void CeilingTrapDoorCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll)
item->goalAnimState = 1; item->goalAnimState = 1;
UseForcedFixedCamera = 1; UseForcedFixedCamera = 1;
ForcedFixedCamera.x = item->pos.xPos - phd_sin(item->pos.yRot) / 16; ForcedFixedCamera.x = item->pos.xPos - phd_sin(item->pos.yRot) * 1024;
ForcedFixedCamera.y = item->pos.yPos + 1024; ForcedFixedCamera.y = item->pos.yPos + 1024;
ForcedFixedCamera.z = item->pos.zPos - phd_cos(item->pos.yRot) / 16; ForcedFixedCamera.z = item->pos.zPos - phd_cos(item->pos.yRot) * 1024;
ForcedFixedCamera.roomNumber = item->roomNumber; ForcedFixedCamera.roomNumber = item->roomNumber;
} }
else else
@ -96,11 +96,11 @@ void FloorTrapDoorCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll)
item->goalAnimState = 1; item->goalAnimState = 1;
UseForcedFixedCamera = 1; UseForcedFixedCamera = 1;
ForcedFixedCamera.x = item->pos.xPos - phd_sin(item->pos.yRot) / 8; ForcedFixedCamera.x = item->pos.xPos - phd_sin(item->pos.yRot) * 2048;
ForcedFixedCamera.y = item->pos.yPos - 2048; ForcedFixedCamera.y = item->pos.yPos - 2048;
if (ForcedFixedCamera.y < g_Level.Rooms[item->roomNumber].maxceiling) if (ForcedFixedCamera.y < g_Level.Rooms[item->roomNumber].maxceiling)
ForcedFixedCamera.y = g_Level.Rooms[item->roomNumber].maxceiling; ForcedFixedCamera.y = g_Level.Rooms[item->roomNumber].maxceiling;
ForcedFixedCamera.z = item->pos.zPos - phd_cos(item->pos.yRot) / 8; ForcedFixedCamera.z = item->pos.zPos - phd_cos(item->pos.yRot) * 2048;
ForcedFixedCamera.roomNumber = item->roomNumber; ForcedFixedCamera.roomNumber = item->roomNumber;
} }
else else

View file

@ -174,8 +174,9 @@ static void createDragonBone(short front_number)
void DragonCollision(short itemNum, ITEM_INFO* laraitem, COLL_INFO* coll) void DragonCollision(short itemNum, ITEM_INFO* laraitem, COLL_INFO* coll)
{ {
ITEM_INFO* item; ITEM_INFO* item;
int c, s, rx, rz, shift, side_shift, angle; int rx, rz, shift, side_shift, angle;
int anim, frame; int anim, frame;
float c, s;
/* If Lara has collided with correct bit of dragon, then start him up */ /* If Lara has collided with correct bit of dragon, then start him up */
item = &g_Level.Items[itemNum]; item = &g_Level.Items[itemNum];
@ -194,10 +195,10 @@ void DragonCollision(short itemNum, ITEM_INFO* laraitem, COLL_INFO* coll)
s = phd_sin(item->pos.yRot); s = phd_sin(item->pos.yRot);
/* See if Lara within leg space of dragon; if so use different collision to sphere stuff */ /* See if Lara within leg space of dragon; if so use different collision to sphere stuff */
side_shift = (rx * s + rz * c) >> W2V_SHIFT; side_shift = rx * s + rz * c;
if (side_shift > DRAGON_LCOL&& side_shift < DRAGON_RCOL) if (side_shift > DRAGON_LCOL&& side_shift < DRAGON_RCOL)
{ {
shift = (rx * c - rz * s) >> W2V_SHIFT; shift = rx * c - rz * s;
if (shift <= DRAGON_CLOSE && shift >= DRAGON_FAR) if (shift <= DRAGON_CLOSE && shift >= DRAGON_FAR)
return; return;
@ -259,8 +260,8 @@ void DragonCollision(short itemNum, ITEM_INFO* laraitem, COLL_INFO* coll)
else else
shift = DRAGON_FAR - shift; shift = DRAGON_FAR - shift;
laraitem->pos.xPos += shift * c >> W2V_SHIFT; laraitem->pos.xPos += shift * c;
laraitem->pos.zPos -= shift * s >> W2V_SHIFT; laraitem->pos.zPos -= shift * s;
return; return;
} }

View file

@ -31,10 +31,10 @@ void KnifeControl(short fxNum)
fx->counter--; fx->counter--;
} }
speed = (fx->speed * phd_cos(fx->pos.xRot)) >> W2V_SHIFT; speed = fx->speed * phd_cos(fx->pos.xRot);
fx->pos.zPos += (speed * phd_cos(fx->pos.yRot)) >> W2V_SHIFT; fx->pos.zPos += speed * phd_cos(fx->pos.yRot);
fx->pos.xPos += (speed * phd_sin(fx->pos.yRot)) >> W2V_SHIFT; fx->pos.xPos += speed * phd_sin(fx->pos.yRot);
fx->pos.yPos += (fx->speed * phd_sin(-fx->pos.xRot) >> W2V_SHIFT); fx->pos.yPos += fx->speed * phd_sin(-fx->pos.xRot);
roomNumber = fx->roomNumber; roomNumber = fx->roomNumber;
floor = GetFloor(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, &roomNumber); floor = GetFloor(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, &roomNumber);

View file

@ -26,8 +26,8 @@ void SpinningBladeControl(short itemNumber)
{ {
if (item->goalAnimState != 1) if (item->goalAnimState != 1)
{ {
int x = item->pos.xPos + (WALL_SIZE * 3 / 2 * phd_sin(item->pos.yRot) >> W2V_SHIFT); int x = item->pos.xPos + WALL_SIZE * 3 * phd_sin(item->pos.yRot) / 2;
int z = item->pos.zPos + (WALL_SIZE * 3 / 2 * phd_cos(item->pos.yRot) >> W2V_SHIFT); int z = item->pos.zPos + WALL_SIZE * 3 * phd_cos(item->pos.yRot) / 2;
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(x, item->pos.yPos, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, item->pos.yPos, z, &roomNumber);

View file

@ -175,9 +175,9 @@ void SpeedBoatGetOff(ITEM_INFO* boat)
LaraItem->pos.xRot = LaraItem->pos.zRot = 0; LaraItem->pos.xRot = LaraItem->pos.zRot = 0;
Lara.Vehicle = NO_ITEM; Lara.Vehicle = NO_ITEM;
int x = LaraItem->pos.xPos + (360 * phd_sin(LaraItem->pos.yRot) >> W2V_SHIFT); int x = LaraItem->pos.xPos + 360 * phd_sin(LaraItem->pos.yRot);
int y = LaraItem->pos.yPos - 90; int y = LaraItem->pos.yPos - 90;
int z = LaraItem->pos.zPos + (360 * phd_cos(LaraItem->pos.yRot) >> W2V_SHIFT); int z = LaraItem->pos.zPos + 360 * phd_cos(LaraItem->pos.yRot);
short roomNumber = LaraItem->roomNumber; short roomNumber = LaraItem->roomNumber;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);
@ -206,9 +206,9 @@ bool SpeedBoatCanGetOff(int direction)
else else
angle = v->pos.yRot + ANGLE(90); angle = v->pos.yRot + ANGLE(90);
int x = v->pos.xPos + (GETOFF_DIST * phd_sin(angle) >> W2V_SHIFT); int x = v->pos.xPos + GETOFF_DIST * phd_sin(angle);
int y = v->pos.yPos; int y = v->pos.yPos;
int z = v->pos.zPos + (GETOFF_DIST * phd_cos(angle) >> W2V_SHIFT); int z = v->pos.zPos + GETOFF_DIST * phd_cos(angle);
short roomNumber = v->roomNumber; short roomNumber = v->roomNumber;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);
@ -237,8 +237,7 @@ int SpeedBoatCheckGeton(short itemNum, COLL_INFO* coll)
ITEM_INFO* boat = &g_Level.Items[itemNum]; ITEM_INFO* boat = &g_Level.Items[itemNum];
int dist = ((LaraItem->pos.zPos - boat->pos.zPos) * phd_cos(-boat->pos.yRot) - int dist = (LaraItem->pos.zPos - boat->pos.zPos) * phd_cos(-boat->pos.yRot) - (LaraItem->pos.xPos - boat->pos.xPos) * phd_sin(-boat->pos.yRot);
(LaraItem->pos.xPos - boat->pos.xPos) * phd_sin(-boat->pos.yRot)) >> W2V_SHIFT;
if (dist > 200) if (dist > 200)
return 0; return 0;
@ -294,14 +293,13 @@ int SpeedBoatTestWaterHeight(ITEM_INFO* item, int zOff, int xOff, PHD_VECTOR* po
// Moves the vector in 'pos' to the required test position too // Moves the vector in 'pos' to the required test position too
// Get y pos correctly, but don't bother changing zOff and xOff using x_rot and z_rot // Get y pos correctly, but don't bother changing zOff and xOff using x_rot and z_rot
pos->y = item->pos.yPos - (zOff * phd_sin(item->pos.xRot) >> W2V_SHIFT) + pos->y = item->pos.yPos - zOff * phd_sin(item->pos.xRot) + xOff * phd_sin(item->pos.zRot);
(xOff * phd_sin(item->pos.zRot) >> W2V_SHIFT);
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
pos->x = item->pos.xPos + ((zOff * s + xOff * c) >> W2V_SHIFT); pos->x = item->pos.xPos + zOff * s + xOff * c;
pos->z = item->pos.zPos + ((zOff * c - xOff * s) >> W2V_SHIFT); pos->z = item->pos.zPos + zOff * c - xOff * s;
// Try to get water height; if none get ground height instead // Try to get water height; if none get ground height instead
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
@ -467,11 +465,11 @@ int SpeedBoatGetCollisionAnim(ITEM_INFO* skidoo, PHD_VECTOR* moved)
if (moved->x || moved->z) if (moved->x || moved->z)
{ {
// Get direction of movement relative to facing // Get direction of movement relative to facing
int s = phd_sin(skidoo->pos.yRot); float s = phd_sin(skidoo->pos.yRot);
int c = phd_cos(skidoo->pos.yRot); float c = phd_cos(skidoo->pos.yRot);
int front = (moved->z * c + moved->x * s) >> W2V_SHIFT; int front = moved->z * c + moved->x * s;
int side = (-moved->z * s + moved->x * c) >> W2V_SHIFT; int side = -moved->z * s + moved->x * c;
if (abs(front) > abs(side)) if (abs(front) > abs(side))
{ {
@ -565,8 +563,8 @@ int SpeedBoatDynamics(short itemNum)
binfo->tiltAngle = binfo->boatTurn * 6; binfo->tiltAngle = binfo->boatTurn * 6;
// Move boat according to speed // Move boat according to speed
boat->pos.xPos += boat->speed * phd_sin(boat->pos.yRot) >> W2V_SHIFT; boat->pos.xPos += boat->speed * phd_sin(boat->pos.yRot);
boat->pos.zPos += boat->speed * phd_cos(boat->pos.yRot) >> W2V_SHIFT; boat->pos.zPos += boat->speed * phd_cos(boat->pos.yRot);
/*if (boat->speed >= 0) /*if (boat->speed >= 0)
binfo->propRot += (boat->speed * ANGLE(3)); binfo->propRot += (boat->speed * ANGLE(3));
@ -574,17 +572,17 @@ int SpeedBoatDynamics(short itemNum)
binfo->propRot += ANGLE(33);*/ binfo->propRot += ANGLE(33);*/
// Slide boat according to tilts (to avoid getting stuck on slopes) // Slide boat according to tilts (to avoid getting stuck on slopes)
slip = BOAT_SIDE_SLIP * phd_sin(boat->pos.zRot) >> W2V_SHIFT; slip = BOAT_SIDE_SLIP * phd_sin(boat->pos.zRot);
if (!slip && boat->pos.zRot) if (!slip && boat->pos.zRot)
slip = (boat->pos.zRot > 0) ? 1 : -1; slip = (boat->pos.zRot > 0) ? 1 : -1;
boat->pos.xPos += slip * phd_sin(boat->pos.yRot) >> W2V_SHIFT; boat->pos.xPos += slip * phd_sin(boat->pos.yRot);
boat->pos.zPos -= slip * phd_cos(boat->pos.yRot) >> W2V_SHIFT; boat->pos.zPos -= slip * phd_cos(boat->pos.yRot);
slip = BOAT_SLIP * phd_sin(boat->pos.xRot) >> W2V_SHIFT; slip = BOAT_SLIP * phd_sin(boat->pos.xRot);
if (!slip && boat->pos.xRot) if (!slip && boat->pos.xRot)
slip = (boat->pos.xRot > 0) ? 1 : -1; slip = (boat->pos.xRot > 0) ? 1 : -1;
boat->pos.xPos -= slip * phd_sin(boat->pos.yRot) >> W2V_SHIFT; boat->pos.xPos -= slip * phd_sin(boat->pos.yRot);
boat->pos.zPos -= slip * phd_cos(boat->pos.yRot) >> W2V_SHIFT; boat->pos.zPos -= slip * phd_cos(boat->pos.yRot);
// Remember desired position in case of collisions moving us about // Remember desired position in case of collisions moving us about
moved.x = boat->pos.xPos; moved.x = boat->pos.xPos;
@ -636,7 +634,7 @@ int SpeedBoatDynamics(short itemNum)
// Check final movement if slipped or collided and adjust speed // Check final movement if slipped or collided and adjust speed
if (slip || collide) if (slip || collide)
{ {
newspeed = ((boat->pos.zPos - old.z) * phd_cos(boat->pos.yRot) + (boat->pos.xPos - old.x) * phd_sin(boat->pos.yRot)) >> W2V_SHIFT; newspeed = (boat->pos.zPos - old.z) * phd_cos(boat->pos.yRot) + (boat->pos.xPos - old.x) * phd_sin(boat->pos.yRot);
if (boat->speed > BOAT_MAX_SPEED + BOAT_ACCELERATION && newspeed < boat->speed - 10) if (boat->speed > BOAT_MAX_SPEED + BOAT_ACCELERATION && newspeed < boat->speed - 10)
{ {

View file

@ -226,9 +226,9 @@ bool SkidooCheckGetOffOK(int direction)
else else
angle = skidoo->pos.yRot - 0x4000; angle = skidoo->pos.yRot - 0x4000;
int x = skidoo->pos.xPos - (SKIDOO_GETOFF_DIST * phd_sin(angle) >> W2V_SHIFT); int x = skidoo->pos.xPos - SKIDOO_GETOFF_DIST * phd_sin(angle);
int y = skidoo->pos.yPos; int y = skidoo->pos.yPos;
int z = skidoo->pos.zPos - (SKIDOO_GETOFF_DIST * phd_cos(angle) >> W2V_SHIFT); int z = skidoo->pos.zPos - SKIDOO_GETOFF_DIST * phd_cos(angle);
short roomNumber = skidoo->roomNumber; short roomNumber = skidoo->roomNumber;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);
@ -266,8 +266,8 @@ bool SkidooCheckGetOff()
LaraItem->animNumber = LA_STAND_SOLID; LaraItem->animNumber = LA_STAND_SOLID;
LaraItem->frameNumber = g_Level.Anims[LaraItem->animNumber].frameBase; LaraItem->frameNumber = g_Level.Anims[LaraItem->animNumber].frameBase;
LaraItem->currentAnimState = LaraItem->goalAnimState = LS_STOP; LaraItem->currentAnimState = LaraItem->goalAnimState = LS_STOP;
LaraItem->pos.xPos -= SKIDOO_GETOFF_DIST * phd_sin(LaraItem->pos.yRot) >> W2V_SHIFT; LaraItem->pos.xPos -= SKIDOO_GETOFF_DIST * phd_sin(LaraItem->pos.yRot);
LaraItem->pos.zPos -= SKIDOO_GETOFF_DIST * phd_cos(LaraItem->pos.yRot) >> W2V_SHIFT; LaraItem->pos.zPos -= SKIDOO_GETOFF_DIST * phd_cos(LaraItem->pos.yRot);
LaraItem->pos.xRot = LaraItem->pos.zRot = 0; LaraItem->pos.xRot = LaraItem->pos.zRot = 0;
Lara.Vehicle = NO_ITEM; Lara.Vehicle = NO_ITEM;
Lara.gunStatus = LG_NO_ARMS; Lara.gunStatus = LG_NO_ARMS;
@ -457,11 +457,11 @@ int GetSkidooCollisionAnim(ITEM_INFO* skidoo, PHD_VECTOR* moved)
if (moved->x || moved->z) if (moved->x || moved->z)
{ {
// Get direction of movement relative to facing // Get direction of movement relative to facing
int s = phd_sin(skidoo->pos.yRot); float s = phd_sin(skidoo->pos.yRot);
int c = phd_cos(skidoo->pos.yRot); float c = phd_cos(skidoo->pos.yRot);
int side = (-moved->z * s + moved->x * c) >> W2V_SHIFT; int side = -moved->z * s + moved->x * c;
int front = (moved->z * c + moved->x * s) >> W2V_SHIFT; int front = moved->z * c + moved->x * s;
if (abs(front) > abs(side)) if (abs(front) > abs(side))
{ {
@ -681,14 +681,13 @@ void SkidooCollision(short itemNum, ITEM_INFO* litem, COLL_INFO* coll)
int TestSkidooHeight(ITEM_INFO* item, int zOff, int xOff, PHD_VECTOR* pos) int TestSkidooHeight(ITEM_INFO* item, int zOff, int xOff, PHD_VECTOR* pos)
{ {
pos->y = item->pos.yPos - (zOff * phd_sin(item->pos.xRot) >> W2V_SHIFT) + pos->y = item->pos.yPos - zOff * phd_sin(item->pos.xRot) + xOff * phd_sin(item->pos.zRot);
(xOff * phd_sin(item->pos.zRot) >> W2V_SHIFT);
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
pos->x = item->pos.xPos + ((zOff * s + xOff * c) >> W2V_SHIFT); pos->x = item->pos.xPos + zOff * s + xOff * c;
pos->z = item->pos.zPos + ((zOff * c - xOff * s) >> W2V_SHIFT); pos->z = item->pos.zPos + zOff * c - xOff * s;
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(pos->x, pos->y, pos->z, &roomNumber); FLOOR_INFO* floor = GetFloor(pos->x, pos->y, pos->z, &roomNumber);
@ -877,22 +876,22 @@ int SkidooDynamics(ITEM_INFO* skidoo)
skidoo->pos.yRot += skinfo->skidooTurn + skinfo->extraRotation; skidoo->pos.yRot += skinfo->skidooTurn + skinfo->extraRotation;
// Move skidoo according to speed // Move skidoo according to speed
skidoo->pos.zPos += skidoo->speed * phd_cos(skinfo->momentumAngle) >> W2V_SHIFT; skidoo->pos.zPos += skidoo->speed * phd_cos(skinfo->momentumAngle);
skidoo->pos.xPos += skidoo->speed * phd_sin(skinfo->momentumAngle) >> W2V_SHIFT; skidoo->pos.xPos += skidoo->speed * phd_sin(skinfo->momentumAngle);
// Slide skidoo according to tilts (to avoid getting stuck on slopes) // Slide skidoo according to tilts (to avoid getting stuck on slopes)
int slip = SKIDOO_SLIP * phd_sin(skidoo->pos.xRot) >> W2V_SHIFT; int slip = SKIDOO_SLIP * phd_sin(skidoo->pos.xRot);
if (abs(slip) > SKIDOO_SLIP / 2) if (abs(slip) > SKIDOO_SLIP / 2)
{ {
skidoo->pos.zPos -= slip * phd_cos(skidoo->pos.yRot) >> W2V_SHIFT; skidoo->pos.zPos -= slip * phd_cos(skidoo->pos.yRot);
skidoo->pos.xPos -= slip * phd_sin(skidoo->pos.yRot) >> W2V_SHIFT; skidoo->pos.xPos -= slip * phd_sin(skidoo->pos.yRot);
} }
slip = SKIDOO_SLIP_SIDE * phd_sin(skidoo->pos.zRot) >> W2V_SHIFT; slip = SKIDOO_SLIP_SIDE * phd_sin(skidoo->pos.zRot);
if (abs(slip) > SKIDOO_SLIP_SIDE / 2) if (abs(slip) > SKIDOO_SLIP_SIDE / 2)
{ {
skidoo->pos.zPos -= slip * phd_sin(skidoo->pos.yRot) >> W2V_SHIFT; skidoo->pos.zPos -= slip * phd_sin(skidoo->pos.yRot);
skidoo->pos.xPos += slip * phd_cos(skidoo->pos.yRot) >> W2V_SHIFT; skidoo->pos.xPos += slip * phd_cos(skidoo->pos.yRot);
} }
// Remember desired position in case of collisions moving us about // Remember desired position in case of collisions moving us about
@ -935,7 +934,7 @@ int SkidooDynamics(ITEM_INFO* skidoo)
// Check final actual movement; if speed is more than halved then reduce to zero // Check final actual movement; if speed is more than halved then reduce to zero
if (collide) if (collide)
{ {
int newspeed = ((skidoo->pos.zPos - old.z) * phd_cos(skinfo->momentumAngle) + (skidoo->pos.xPos - old.x) * phd_sin(skinfo->momentumAngle)) >> W2V_SHIFT; int newspeed = (skidoo->pos.zPos - old.z) * phd_cos(skinfo->momentumAngle) + (skidoo->pos.xPos - old.x) * phd_sin(skinfo->momentumAngle);
if (skidoo->speed > SKIDOO_MAX_SPEED + SKIDOO_ACCELERATION && newspeed < skidoo->speed - 10) if (skidoo->speed > SKIDOO_MAX_SPEED + SKIDOO_ACCELERATION && newspeed < skidoo->speed - 10)
{ {
LaraItem->hitPoints -= (skidoo->speed - newspeed) / 2; LaraItem->hitPoints -= (skidoo->speed - newspeed) / 2;

View file

@ -258,8 +258,8 @@ void ControlFish(short itemNumber)
int x = fish->x; int x = fish->x;
int z = fish->z; int z = fish->z;
x -= fish->speed * phd_sin(fish->angle << 4) >> 15; x -= fish->speed * phd_sin(fish->angle << 4) / 2;
z += fish->speed * phd_cos(fish->angle << 4) >> 15; z += fish->speed * phd_cos(fish->angle << 4) / 2;
if (pirahnaAttack == 0) if (pirahnaAttack == 0)
{ {
@ -436,8 +436,8 @@ void ControlFish(short itemNumber)
fish->swim += (fish->speed >> 4) + (fish->speed >> 5); fish->swim += (fish->speed >> 4) + (fish->speed >> 5);
fish->swim &= 63; fish->swim &= 63;
x = fish->x - fish->speed * phd_sin(fish->angle << 4) >> 15; x = fish->x - fish->speed * phd_sin(fish->angle << 4) / 2;
z = fish->z + fish->speed * phd_cos(fish->angle << 4) >> 15; z = fish->z + fish->speed * phd_cos(fish->angle << 4) / 2;
if (z < -32000) if (z < -32000)
z = -32000; z = -32000;

View file

@ -190,19 +190,19 @@ static short TriggerFlameThrower(ITEM_INFO* item, BITE_INFO* bite, short speed)
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
speed = (GetRandomControl() % (speed << 2)) + 32; speed = (GetRandomControl() % (speed << 2)) + 32;
velocity = (speed * phd_cos(fx->pos.xRot)) >> W2V_SHIFT; velocity = speed * phd_cos(fx->pos.xRot);
xv = (velocity * phd_sin(fx->pos.yRot)) >> W2V_SHIFT; xv = velocity * phd_sin(fx->pos.yRot);
yv = -((speed * phd_sin(fx->pos.xRot)) >> W2V_SHIFT); yv = -speed * phd_sin(fx->pos.xRot);
zv = (velocity * phd_cos(fx->pos.yRot)) >> W2V_SHIFT; zv = velocity * phd_cos(fx->pos.yRot);
TriggerFlamethrowerFlame(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, xv << 5, yv << 5, zv << 5, -1); TriggerFlamethrowerFlame(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, xv << 5, yv << 5, zv << 5, -1);
} }
velocity = ((speed << 1) * phd_cos(fx->pos.xRot)) >> W2V_SHIFT; velocity = (speed << 1) * phd_cos(fx->pos.xRot);
zv = (velocity * phd_cos(fx->pos.yRot)) >> W2V_SHIFT; zv = velocity * phd_cos(fx->pos.yRot);
xv = (velocity * phd_sin(fx->pos.yRot)) >> W2V_SHIFT; xv = velocity * phd_sin(fx->pos.yRot);
yv = -(((speed << 1) * phd_sin(fx->pos.xRot)) >> W2V_SHIFT); yv = -(speed << 1) * phd_sin(fx->pos.xRot);
TriggerFlamethrowerFlame(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, xv << 5, yv << 5, zv << 5, -2); TriggerFlamethrowerFlame(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, xv << 5, yv << 5, zv << 5, -2);
} }

View file

@ -154,9 +154,9 @@ void MPGunControl(short itemNumber)
angle = CreatureTurn(item, creature->maximumTurn); angle = CreatureTurn(item, creature->maximumTurn);
int x = item->pos.xPos + (WALL_SIZE * phd_sin(item->pos.yRot + laraInfo.angle) >> W2V_SHIFT); int x = item->pos.xPos + WALL_SIZE * phd_sin(item->pos.yRot + laraInfo.angle);
int y = item->pos.yPos; int y = item->pos.yPos;
int z = item->pos.zPos + (WALL_SIZE * phd_cos(item->pos.yRot + laraInfo.angle) >> W2V_SHIFT); int z = item->pos.zPos + WALL_SIZE * phd_cos(item->pos.yRot + laraInfo.angle);
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);

View file

@ -52,10 +52,10 @@ void ScubaHarpoonControl(short itemNum)
int ox = item->pos.xPos; int ox = item->pos.xPos;
int oz = item->pos.zPos; int oz = item->pos.zPos;
short speed = (item->speed * phd_cos(item->pos.xRot)) >> W2V_SHIFT; short speed = item->speed * phd_cos(item->pos.xRot);
item->pos.zPos += (speed * phd_cos(item->pos.yRot)) >> W2V_SHIFT; item->pos.zPos += speed * phd_cos(item->pos.yRot);
item->pos.xPos += (speed * phd_sin(item->pos.yRot)) >> W2V_SHIFT; item->pos.xPos += speed * phd_sin(item->pos.yRot);
item->pos.yPos += -((item->speed * phd_sin(item->pos.xRot)) >> W2V_SHIFT); item->pos.yPos += -item->speed * phd_sin(item->pos.xRot);
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber); FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);

View file

@ -240,8 +240,8 @@ void ShivaControl(short itemNum)
if (shiva->mood == ESCAPE_MOOD) if (shiva->mood == ESCAPE_MOOD)
{ {
roomNumber = item->roomNumber; roomNumber = item->roomNumber;
x = item->pos.xPos + (WALL_SIZE * phd_sin(item->pos.yRot + 0x8000) >> W2V_SHIFT); x = item->pos.xPos + WALL_SIZE * phd_sin(item->pos.yRot + 0x8000);
z = item->pos.zPos + (WALL_SIZE * phd_cos(item->pos.yRot + 0x8000) >> W2V_SHIFT); z = item->pos.zPos + WALL_SIZE * phd_cos(item->pos.yRot + 0x8000);
floor = GetFloor(x, item->pos.yPos, z, &roomNumber); floor = GetFloor(x, item->pos.yPos, z, &roomNumber);
if (!shiva->flags && floor->box != NO_BOX && !(g_Level.Boxes[floor->box].flags & BLOCKABLE)) if (!shiva->flags && floor->box != NO_BOX && !(g_Level.Boxes[floor->box].flags & BLOCKABLE))

View file

@ -361,8 +361,8 @@ void ControlTonyFireBall(short fxNumber)
if (fx->fallspeed > 512) if (fx->fallspeed > 512)
fx->fallspeed = 512; fx->fallspeed = 512;
fx->pos.yPos += fx->fallspeed >> 1; fx->pos.yPos += fx->fallspeed >> 1;
fx->pos.zPos += (fx->speed * phd_cos(fx->pos.yRot) >> W2V_SHIFT); fx->pos.zPos += fx->speed * phd_cos(fx->pos.yRot);
fx->pos.xPos += (fx->speed * phd_sin(fx->pos.yRot) >> W2V_SHIFT); fx->pos.xPos += fx->speed * phd_sin(fx->pos.yRot);
if (Wibble & 4) if (Wibble & 4)
TriggerFireBallFlame(fxNumber, (TonyFlameType)fx->flag1, (short)((old_x - fx->pos.xPos) << 3), (short)((old_y - fx->pos.yPos) << 3), (short)((old_z - fx->pos.zPos) << 3)); TriggerFireBallFlame(fxNumber, (TonyFlameType)fx->flag1, (short)((old_x - fx->pos.xPos) << 3), (short)((old_y - fx->pos.yPos) << 3), (short)((old_z - fx->pos.zPos) << 3));
} }

View file

@ -14,17 +14,16 @@
long TrainTestHeight(ITEM_INFO *item, long x, long z, short *room_number) long TrainTestHeight(ITEM_INFO *item, long x, long z, short *room_number)
{ {
long s, c; float s, c;
PHD_VECTOR pos; PHD_VECTOR pos;
FLOOR_INFO *floor; FLOOR_INFO *floor;
c = phd_cos(item->pos.yRot); c = phd_cos(item->pos.yRot);
s = phd_sin(item->pos.yRot); s = phd_sin(item->pos.yRot);
pos.x = item->pos.xPos + (((z * s) + (x * c)) >> W2V_SHIFT); pos.x = item->pos.xPos + z * s + x * c;
pos.y = item->pos.yPos - (z * phd_sin(item->pos.xRot) >> W2V_SHIFT) pos.y = item->pos.yPos - z * phd_sin(item->pos.xRot) + x * phd_sin(item->pos.zRot);
+ (x * phd_sin(item->pos.zRot) >> W2V_SHIFT); pos.z = item->pos.zPos + z * c - x * s;
pos.z = item->pos.zPos + (((z * c) - (x * s)) >> W2V_SHIFT);
*room_number = item->roomNumber; *room_number = item->roomNumber;
floor = GetFloor(pos.x, pos.y, pos.z, room_number); floor = GetFloor(pos.x, pos.y, pos.z, room_number);
@ -34,9 +33,10 @@ long TrainTestHeight(ITEM_INFO *item, long x, long z, short *room_number)
void TrainControl(short trainNum) void TrainControl(short trainNum)
{ {
ITEM_INFO *train; ITEM_INFO *train;
long s, c, fh, rh; long fh, rh;
FLOOR_INFO *floor; FLOOR_INFO *floor;
short roomNum; short roomNum;
float s, c;
train = &g_Level.Items[trainNum]; train = &g_Level.Items[trainNum];
@ -49,8 +49,8 @@ void TrainControl(short trainNum)
c = phd_cos(train->pos.yRot); c = phd_cos(train->pos.yRot);
s = phd_sin(train->pos.yRot); s = phd_sin(train->pos.yRot);
train->pos.xPos += ((train->itemFlags[1] * s) >> W2V_SHIFT); train->pos.xPos += train->itemFlags[1] * s;
train->pos.zPos += ((train->itemFlags[1] * c) >> W2V_SHIFT); train->pos.zPos += train->itemFlags[1] * c;
rh = TrainTestHeight(train, 0, 5120, &roomNum); rh = TrainTestHeight(train, 0, 5120, &roomNum);
train->pos.yPos = fh = TrainTestHeight(train, 0, 0, &roomNum); train->pos.yPos = fh = TrainTestHeight(train, 0, 0, &roomNum);
@ -71,7 +71,7 @@ void TrainControl(short trainNum)
train->pos.xRot = -(rh - fh) << 1; train->pos.xRot = -(rh - fh) << 1;
TriggerDynamicLight(train->pos.xPos + ((3072 * s) >> W2V_SHIFT), train->pos.yPos, train->pos.zPos + ((3072 * c) >> W2V_SHIFT), 16, 31, 31, 31); TriggerDynamicLight(train->pos.xPos + 3072 * s, train->pos.yPos, train->pos.zPos + 3072 * c, 16, 31, 31, 31);
if (train->itemFlags[1] != TRAIN_VEL) if (train->itemFlags[1] != TRAIN_VEL)
{ {
@ -80,10 +80,10 @@ void TrainControl(short trainNum)
if (!UseForcedFixedCamera) if (!UseForcedFixedCamera)
{ {
ForcedFixedCamera.x = train->pos.xPos + ((8192 * s) >> W2V_SHIFT), ForcedFixedCamera.x = train->pos.xPos + 8192 * s;
ForcedFixedCamera.z = train->pos.zPos + ((8192 * c) >> W2V_SHIFT), ForcedFixedCamera.z = train->pos.zPos + 8192 * c;
roomNum = train->roomNumber; roomNum = train->roomNumber;
floor = GetFloor(ForcedFixedCamera.x, train->pos.yPos - 512, ForcedFixedCamera.z, &roomNum); floor = GetFloor(ForcedFixedCamera.x, train->pos.yPos - 512, ForcedFixedCamera.z, &roomNum);
ForcedFixedCamera.y = GetFloorHeight(floor, ForcedFixedCamera.x, train->pos.yPos - 512, ForcedFixedCamera.z); ForcedFixedCamera.y = GetFloorHeight(floor, ForcedFixedCamera.x, train->pos.yPos - 512, ForcedFixedCamera.z);
@ -99,7 +99,8 @@ void TrainControl(short trainNum)
void TrainCollision(short trainNum, ITEM_INFO *larA, COLL_INFO *coll) void TrainCollision(short trainNum, ITEM_INFO *larA, COLL_INFO *coll)
{ {
ITEM_INFO *train; ITEM_INFO *train;
long s, c, x, z; long x, z;
float s, c;
train = &g_Level.Items[trainNum]; train = &g_Level.Items[trainNum];
@ -137,8 +138,8 @@ void TrainCollision(short trainNum, ITEM_INFO *larA, COLL_INFO *coll)
c = phd_cos(train->pos.yRot); c = phd_cos(train->pos.yRot);
s = phd_sin(train->pos.yRot); s = phd_sin(train->pos.yRot);
x = larA->pos.xPos + ((256 * s) >> W2V_SHIFT); x = larA->pos.xPos + 256 * s;
z = larA->pos.zPos + ((256 * c) >> W2V_SHIFT); z = larA->pos.zPos + 256 * c;
DoLotsOfBlood(x, larA->pos.yPos - 512, z, 1024, train->pos.yRot, larA->roomNumber, 15); DoLotsOfBlood(x, larA->pos.yPos - 512, z, 1024, train->pos.yRot, larA->roomNumber, 15);

View file

@ -107,11 +107,11 @@ void KayakDoWake(ITEM_INFO* v, short xoff, short zoff, short rotate)
if (WakePts[CurrentStartWake][rotate].life) if (WakePts[CurrentStartWake][rotate].life)
return; return;
int s = phd_sin(v->pos.yRot); float s = phd_sin(v->pos.yRot);
int c = phd_cos(v->pos.yRot); float c = phd_cos(v->pos.yRot);
int x = v->pos.xPos + (((zoff * s) + (xoff * c)) >> W2V_SHIFT); int x = v->pos.xPos + zoff * s + xoff * c;
int z = v->pos.zPos + (((zoff * c) - (xoff * s)) >> W2V_SHIFT); int z = v->pos.zPos + zoff * c - xoff * s;
short angle1, angle2; short angle1, angle2;
@ -147,10 +147,10 @@ void KayakDoWake(ITEM_INFO* v, short xoff, short zoff, short rotate)
} }
} }
xv[0] = (WAKE_SPEED * phd_sin(angle1)) >> W2V_SHIFT; xv[0] = WAKE_SPEED * phd_sin(angle1);
zv[0] = (WAKE_SPEED * phd_cos(angle1)) >> W2V_SHIFT; zv[0] = WAKE_SPEED * phd_cos(angle1);
xv[1] = ((WAKE_SPEED + 2) * phd_sin(angle2)) >> W2V_SHIFT; xv[1] = (WAKE_SPEED + 2) * phd_sin(angle2);
zv[1] = ((WAKE_SPEED + 2) * phd_cos(angle2)) >> W2V_SHIFT; zv[1] = (WAKE_SPEED + 2) * phd_cos(angle2);
WakePts[CurrentStartWake][rotate].y = v->pos.yPos + KAYAK_DRAW_SHIFT; WakePts[CurrentStartWake][rotate].y = v->pos.yPos + KAYAK_DRAW_SHIFT;
WakePts[CurrentStartWake][rotate].life = 0x40; WakePts[CurrentStartWake][rotate].life = 0x40;
@ -173,11 +173,11 @@ void KayakDoWake(ITEM_INFO* v, short xoff, short zoff, short rotate)
void KayakDoRipple(ITEM_INFO* v, short xoff, short zoff) void KayakDoRipple(ITEM_INFO* v, short xoff, short zoff)
{ {
int s = phd_sin(v->pos.yRot); float s = phd_sin(v->pos.yRot);
int c = phd_cos(v->pos.yRot); float c = phd_cos(v->pos.yRot);
int x = v->pos.xPos + (((zoff * s) + (xoff * c)) >> W2V_SHIFT); int x = v->pos.xPos + zoff * s + xoff * c;
int z = v->pos.zPos + (((zoff * c) - (xoff * s)) >> W2V_SHIFT); int z = v->pos.zPos + zoff * c - xoff * s;
short roomNumber = v->roomNumber; short roomNumber = v->roomNumber;
FLOOR_INFO* floor = GetFloor(x, v->pos.yPos, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, v->pos.yPos, z, &roomNumber);
@ -338,11 +338,11 @@ int KayakGetCollisionAnim(ITEM_INFO* v, int xdiff, int zdiff)
if ((xdiff) || (zdiff)) if ((xdiff) || (zdiff))
{ {
int s = phd_sin(v->pos.yRot); float s = phd_sin(v->pos.yRot);
int c = phd_cos(v->pos.yRot); float c = phd_cos(v->pos.yRot);
int front = ((zdiff * c) + (xdiff * s)) >> W2V_SHIFT; int front = zdiff * c + xdiff * s;
int side = ((-zdiff * s) + (xdiff * c)) >> W2V_SHIFT; int side = -zdiff * s + xdiff * c;
if (abs(front) > abs(side)) if (abs(front) > abs(side))
{ {
@ -448,8 +448,8 @@ void KayakDoCurrent(ITEM_INFO* item)
int dz = target.z - LaraItem->pos.zPos; int dz = target.z - LaraItem->pos.zPos;
int speed = FixedCameras[sinkval].data; int speed = FixedCameras[sinkval].data;
dx = phd_sin(angle << 4) * speed / 16; dx = phd_sin(angle << 4) * speed * 1024;
dz = phd_cos(angle << 4) * speed / 16; dz = phd_cos(angle << 4) * speed * 1024;
Lara.currentXvel += (dx - Lara.currentXvel) / 16; Lara.currentXvel += (dx - Lara.currentXvel) / 16;
Lara.currentZvel += (dz - Lara.currentZvel) / 16; Lara.currentZvel += (dz - Lara.currentZvel) / 16;
@ -659,8 +659,8 @@ void KayakToBackground(ITEM_INFO* v, KAYAK_INFO* Kayak)
v->pos.yRot += (Kayak->Rot >> 16); v->pos.yRot += (Kayak->Rot >> 16);
v->pos.xPos += (v->speed * phd_sin(v->pos.yRot)) >> W2V_SHIFT; v->pos.xPos += v->speed * phd_sin(v->pos.yRot);
v->pos.zPos += (v->speed * phd_cos(v->pos.yRot)) >> W2V_SHIFT; v->pos.zPos += v->speed * phd_cos(v->pos.yRot);
KayakDoCurrent(v); KayakDoCurrent(v);
@ -753,8 +753,7 @@ void KayakToBackground(ITEM_INFO* v, KAYAK_INFO* Kayak)
{ {
int newspeed; int newspeed;
newspeed = ((v->pos.zPos - oldpos[8].z) * phd_cos(v->pos.yRot) newspeed = (v->pos.zPos - oldpos[8].z) * phd_cos(v->pos.yRot) + (v->pos.xPos - oldpos[8].x) * phd_sin(v->pos.yRot);
+ (v->pos.xPos - oldpos[8].x) * phd_sin(v->pos.yRot)) >> W2V_SHIFT;
newspeed *= 256; newspeed *= 256;

View file

@ -70,15 +70,15 @@ static int TestMinecartHeight(ITEM_INFO* v, int x, int z)
{ {
PHD_VECTOR pos; PHD_VECTOR pos;
FLOOR_INFO* floor; FLOOR_INFO* floor;
int s, c; float s, c;
short roomNumber; short roomNumber;
c = phd_cos(v->pos.yRot); c = phd_cos(v->pos.yRot);
s = phd_sin(v->pos.yRot); s = phd_sin(v->pos.yRot);
pos.x = v->pos.xPos + (((z * s) + (x * c)) >> W2V_SHIFT); pos.x = v->pos.xPos + z * s + x * c;
pos.y = v->pos.yPos - (z * phd_sin(v->pos.xRot) >> W2V_SHIFT) + (x * phd_sin(v->pos.zRot) >> W2V_SHIFT); pos.y = v->pos.yPos - z * phd_sin(v->pos.xRot) + x * phd_sin(v->pos.zRot);
pos.z = v->pos.zPos + (((z * c) - (x * s)) >> W2V_SHIFT); pos.z = v->pos.zPos + z * c - x * s;
roomNumber = v->roomNumber; roomNumber = v->roomNumber;
floor = GetFloor(pos.x, pos.y, pos.z, &roomNumber); floor = GetFloor(pos.x, pos.y, pos.z, &roomNumber);
@ -91,9 +91,9 @@ static short GetCollision(ITEM_INFO* v, short ang, int dist, short* ceiling)
int x, y, z, height, cheight; int x, y, z, height, cheight;
short roomNumber; short roomNumber;
x = v->pos.xPos + ((phd_sin(ang) * dist) >> W2V_SHIFT); x = v->pos.xPos + phd_sin(ang) * dist;
y = v->pos.yPos - LARA_HITE; y = v->pos.yPos - LARA_HITE;
z = v->pos.zPos + ((phd_cos(ang) * dist) >> W2V_SHIFT); z = v->pos.zPos + phd_cos(ang) * dist;
roomNumber = v->roomNumber; roomNumber = v->roomNumber;
floor = GetFloor(x, y, z, &roomNumber); floor = GetFloor(x, y, z, &roomNumber);
@ -156,9 +156,9 @@ static bool CanGetOut(int direction)
angle = v->pos.yRot - 0x4000; angle = v->pos.yRot - 0x4000;
x = v->pos.xPos - (GETOFF_DIST * phd_sin(angle) >> W2V_SHIFT); x = v->pos.xPos - GETOFF_DIST * phd_sin(angle);
y = v->pos.yPos; y = v->pos.yPos;
z = v->pos.zPos - (GETOFF_DIST * phd_cos(angle) >> W2V_SHIFT); z = v->pos.zPos - GETOFF_DIST * phd_cos(angle);
roomNumber = v->roomNumber; roomNumber = v->roomNumber;
floor = GetFloor(x, y, z, &roomNumber); floor = GetFloor(x, y, z, &roomNumber);
@ -363,7 +363,7 @@ static void MoveCart(ITEM_INFO* v, ITEM_INFO* l, CART_INFO* cart)
// move cart around corners // move cart around corners
if (cart->Flags & (CF_TURNINGL | CF_TURNINGR)) if (cart->Flags & (CF_TURNINGL | CF_TURNINGR))
{ {
int x, z; float x, z;
unsigned short quad, deg; unsigned short quad, deg;
if ((cart->TurnLen += (v->speed * 3)) > ANGLE(90)) if ((cart->TurnLen += (v->speed * 3)) > ANGLE(90))
@ -414,15 +414,15 @@ static void MoveCart(ITEM_INFO* v, ITEM_INFO* l, CART_INFO* cart)
z = -z; z = -z;
} }
v->pos.xPos = cart->TurnX + ((x * 3584) >> W2V_SHIFT); v->pos.xPos = cart->TurnX + x * 3584;
v->pos.zPos = cart->TurnZ + ((z * 3584) >> W2V_SHIFT); v->pos.zPos = cart->TurnZ + z * 3584;
} }
} }
else else
{ {
// move cart normally // move cart normally
v->pos.xPos += (v->speed * phd_sin(v->pos.yRot)) >> W2V_SHIFT; v->pos.xPos += v->speed * phd_sin(v->pos.yRot);
v->pos.zPos += (v->speed * phd_cos(v->pos.yRot)) >> W2V_SHIFT; v->pos.zPos += v->speed * phd_cos(v->pos.yRot);
} }
// tilt cart on slopes // tilt cart on slopes
@ -698,8 +698,8 @@ static void DoUserInput(ITEM_INFO* v, ITEM_INFO* l, CART_INFO* cart)
if ((Wibble & 7) == 0) if ((Wibble & 7) == 0)
SoundEffect(SFX_TR3_QUAD_FRONT_IMPACT, &v->pos, 2); SoundEffect(SFX_TR3_QUAD_FRONT_IMPACT, &v->pos, 2);
v->pos.xPos += (TURN_DEATH_VEL * phd_sin(v->pos.yRot)) >> W2V_SHIFT; v->pos.xPos += TURN_DEATH_VEL * phd_sin(v->pos.yRot);
v->pos.zPos += (TURN_DEATH_VEL * phd_cos(v->pos.yRot)) >> W2V_SHIFT; v->pos.zPos += TURN_DEATH_VEL * phd_cos(v->pos.yRot);
} }
else else
{ {

View file

@ -171,9 +171,9 @@ static int CanQuadbikeGetOff(int direction)
else else
angle = item->pos.yRot + ANGLE(90); angle = item->pos.yRot + ANGLE(90);
int x = item->pos.xPos + (512 * phd_sin(angle) >> W2V_SHIFT); int x = item->pos.xPos + 512 * phd_sin(angle);
int y = item->pos.yPos; int y = item->pos.yPos;
int z = item->pos.zPos + (512 * phd_cos(angle) >> W2V_SHIFT); int z = item->pos.zPos + 512 * phd_cos(angle);
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);
@ -214,8 +214,8 @@ static int QuadCheckGetOff()
LaraItem->animNumber = LA_STAND_SOLID; LaraItem->animNumber = LA_STAND_SOLID;
LaraItem->frameNumber = GF(LaraItem->animNumber, 0); LaraItem->frameNumber = GF(LaraItem->animNumber, 0);
LaraItem->currentAnimState = LaraItem->goalAnimState = LS_STOP; LaraItem->currentAnimState = LaraItem->goalAnimState = LS_STOP;
LaraItem->pos.xPos -= GETOFF_DISTANCE * phd_sin(LaraItem->pos.yRot) >> W2V_SHIFT; LaraItem->pos.xPos -= GETOFF_DISTANCE * phd_sin(LaraItem->pos.yRot);
LaraItem->pos.zPos -= GETOFF_DISTANCE * phd_cos(LaraItem->pos.yRot) >> W2V_SHIFT; LaraItem->pos.zPos -= GETOFF_DISTANCE * phd_cos(LaraItem->pos.yRot);
LaraItem->pos.xRot = LaraItem->pos.zRot = 0; LaraItem->pos.xRot = LaraItem->pos.zRot = 0;
Lara.Vehicle = NO_ITEM; Lara.Vehicle = NO_ITEM;
Lara.gunStatus = LG_NO_ARMS; Lara.gunStatus = LG_NO_ARMS;
@ -362,10 +362,10 @@ static int GetQuadCollisionAnim(ITEM_INFO* item, PHD_VECTOR* p)
if (p->x || p->z) if (p->x || p->z)
{ {
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
int front = ((p->z * c) + (p->x * s)) >> W2V_SHIFT; int front = p->z * c + p->x * s;
int side = ((-p->z * s) + (p->x * c)) >> W2V_SHIFT; int side = -p->z * s + p->x * c;
if (abs(front) > abs(side)) if (abs(front) > abs(side))
{ {
@ -388,13 +388,13 @@ static int GetQuadCollisionAnim(ITEM_INFO* item, PHD_VECTOR* p)
static int TestQuadHeight(ITEM_INFO* item, int dz, int dx, PHD_VECTOR* pos) static int TestQuadHeight(ITEM_INFO* item, int dz, int dx, PHD_VECTOR* pos)
{ {
pos->y = item->pos.yPos - (dz * phd_sin(item->pos.xRot) >> W2V_SHIFT) + (dx * phd_sin(item->pos.zRot) >> W2V_SHIFT); pos->y = item->pos.yPos - dz * phd_sin(item->pos.xRot) + dx * phd_sin(item->pos.zRot);
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
pos->z = item->pos.zPos + ((dz * c - dx * s) >> W2V_SHIFT); pos->z = item->pos.zPos + dz * c - dx * s;
pos->x = item->pos.xPos + ((dz * s + dx * c) >> W2V_SHIFT); pos->x = item->pos.xPos + dz * s + dx * c;
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(pos->x, pos->y, pos->z, &roomNumber); FLOOR_INFO* floor = GetFloor(pos->x, pos->y, pos->z, &roomNumber);
@ -640,29 +640,29 @@ static int QuadDynamics(ITEM_INFO* item)
int height = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos); int height = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
int speed = 0; int speed = 0;
if (item->pos.yPos >= height) if (item->pos.yPos >= height)
speed = (item->speed * phd_cos(item->pos.xRot)) >> W2V_SHIFT; speed = item->speed * phd_cos(item->pos.xRot);
else else
speed = item->speed; speed = item->speed;
item->pos.zPos += (speed * phd_cos(quad->momentumAngle)) >> W2V_SHIFT; item->pos.zPos += speed * phd_cos(quad->momentumAngle);
item->pos.xPos += (speed * phd_sin(quad->momentumAngle)) >> W2V_SHIFT; item->pos.xPos += speed * phd_sin(quad->momentumAngle);
slip = QUAD_SLIP * phd_sin(item->pos.xRot) >> W2V_SHIFT; slip = QUAD_SLIP * phd_sin(item->pos.xRot);
if (abs(slip) > QUAD_SLIP / 2) if (abs(slip) > QUAD_SLIP / 2)
{ {
if (slip > 0) if (slip > 0)
slip -= 10; slip -= 10;
else else
slip += 10; slip += 10;
item->pos.zPos -= slip * phd_cos(item->pos.yRot) >> W2V_SHIFT; item->pos.zPos -= slip * phd_cos(item->pos.yRot);
item->pos.xPos -= slip * phd_sin(item->pos.yRot) >> W2V_SHIFT; item->pos.xPos -= slip * phd_sin(item->pos.yRot);
} }
slip = QUAD_SLIP_SIDE * phd_sin(item->pos.zRot) >> W2V_SHIFT; slip = QUAD_SLIP_SIDE * phd_sin(item->pos.zRot);
if (abs(slip) > QUAD_SLIP_SIDE / 2) if (abs(slip) > QUAD_SLIP_SIDE / 2)
{ {
item->pos.zPos -= slip * phd_sin(item->pos.yRot) >> W2V_SHIFT; item->pos.zPos -= slip * phd_sin(item->pos.yRot);
item->pos.xPos += slip * phd_cos(item->pos.yRot) >> W2V_SHIFT; item->pos.xPos += slip * phd_cos(item->pos.yRot);
} }
moved.x = item->pos.xPos; moved.x = item->pos.xPos;
@ -738,7 +738,7 @@ static int QuadDynamics(ITEM_INFO* item)
if (collide) if (collide)
{ {
newspeed = ((item->pos.zPos - old.z) * phd_cos(quad->momentumAngle) + (item->pos.xPos - old.x) * phd_sin(quad->momentumAngle)) >> W2V_SHIFT; newspeed = (item->pos.zPos - old.z) * phd_cos(quad->momentumAngle) + (item->pos.xPos - old.x) * phd_sin(quad->momentumAngle);
newspeed <<= 8; newspeed <<= 8;
@ -1240,8 +1240,8 @@ static void TriggerQuadExhaustSmoke(int x, int y, int z, short angle, int speed,
spark->x = x + ((GetRandomControl() & 15) - 8); spark->x = x + ((GetRandomControl() & 15) - 8);
spark->y = y + ((GetRandomControl() & 15) - 8); spark->y = y + ((GetRandomControl() & 15) - 8);
spark->z = z + ((GetRandomControl() & 15) - 8); spark->z = z + ((GetRandomControl() & 15) - 8);
int zv = (speed * phd_cos(angle)) >> (W2V_SHIFT + 2); int zv = speed * phd_cos(angle) / 4;
int xv = (speed * phd_sin(angle)) >> (W2V_SHIFT + 2); int xv = speed * phd_sin(angle) / 4;
spark->xVel = xv + ((GetRandomControl() & 255) - 128); spark->xVel = xv + ((GetRandomControl() & 255) - 128);
spark->yVel = -(GetRandomControl() & 7) - 8; spark->yVel = -(GetRandomControl() & 7) - 8;
spark->zVel = zv + ((GetRandomControl() & 255) - 128); spark->zVel = zv + ((GetRandomControl() & 255) - 128);

View file

@ -70,7 +70,7 @@ int RubberBoatCheckGeton(short itemNum, COLL_INFO *coll)
xDelta = LaraItem->pos.xPos - boat->pos.xPos; xDelta = LaraItem->pos.xPos - boat->pos.xPos;
zDelta = LaraItem->pos.zPos - boat->pos.zPos; zDelta = LaraItem->pos.zPos - boat->pos.zPos;
dist = ((zDelta * phd_cos(-boat->pos.yRot)) - (xDelta * phd_sin(-boat->pos.yRot))) >> W2V_SHIFT; dist = zDelta * phd_cos(-boat->pos.yRot) - xDelta * phd_sin(-boat->pos.yRot);
if (dist > 512) return 0; if (dist > 512) return 0;
@ -119,17 +119,17 @@ int RubberBoatCheckGeton(short itemNum, COLL_INFO *coll)
static long TestWaterHeight(ITEM_INFO *item, long zOff, long xOff, PHD_VECTOR *pos) static long TestWaterHeight(ITEM_INFO *item, long zOff, long xOff, PHD_VECTOR *pos)
{ {
FLOOR_INFO *floor; FLOOR_INFO *floor;
long s, c, height; long height;
short roomNum; short roomNum;
float s, c;
pos->y = item->pos.yPos - (zOff * phd_sin(item->pos.xRot) >> W2V_SHIFT) + pos->y = item->pos.yPos - zOff * phd_sin(item->pos.xRot) + xOff * phd_sin(item->pos.zRot);
(xOff * phd_sin(item->pos.zRot) >> W2V_SHIFT);
c = phd_cos(item->pos.yRot); c = phd_cos(item->pos.yRot);
s = phd_sin(item->pos.yRot); s = phd_sin(item->pos.yRot);
pos->z = item->pos.zPos + ((zOff *c - xOff * s) >> W2V_SHIFT); pos->z = item->pos.zPos + zOff * c - xOff * s;
pos->x = item->pos.xPos + ((zOff *s + xOff * c) >> W2V_SHIFT); pos->x = item->pos.xPos + zOff * s + xOff * c;
roomNum = item->roomNumber; roomNum = item->roomNumber;
GetFloor(pos->x, pos->y, pos->z, &roomNum); GetFloor(pos->x, pos->y, pos->z, &roomNum);
@ -290,7 +290,8 @@ static int DoRubberBoatShift2(ITEM_INFO *skidoo, PHD_VECTOR *pos, PHD_VECTOR *ol
static int GetRubberBoatCollisionAnim(ITEM_INFO *rubber, PHD_VECTOR *moved) static int GetRubberBoatCollisionAnim(ITEM_INFO *rubber, PHD_VECTOR *moved)
{ {
long c, s, front, side; long front, side;
float c, s;
moved->x = rubber->pos.xPos - moved->x; moved->x = rubber->pos.xPos - moved->x;
moved->z = rubber->pos.zPos - moved->z; moved->z = rubber->pos.zPos - moved->z;
@ -299,8 +300,8 @@ static int GetRubberBoatCollisionAnim(ITEM_INFO *rubber, PHD_VECTOR *moved)
{ {
c = phd_cos(rubber->pos.yRot); c = phd_cos(rubber->pos.yRot);
s = phd_sin(rubber->pos.yRot); s = phd_sin(rubber->pos.yRot);
front = (moved->z * c + moved->x * s) >> W2V_SHIFT; front = moved->z * c + moved->x * s;
side = (-moved->z * s + moved->x * c) >> W2V_SHIFT; side = -moved->z * s + moved->x * c;
if (abs(front) > abs(side)) if (abs(front) > abs(side))
{ {
@ -380,25 +381,25 @@ static int RubberBoatDynamics(short boat_number)
binfo->tiltAngle = binfo->boatTurn * 6; binfo->tiltAngle = binfo->boatTurn * 6;
/* Move boat according to speed */ /* Move boat according to speed */
boat->pos.zPos += boat->speed * phd_cos(boat->pos.yRot) >> W2V_SHIFT; boat->pos.zPos += boat->speed * phd_cos(boat->pos.yRot);
boat->pos.xPos += boat->speed * phd_sin(boat->pos.yRot) >> W2V_SHIFT; boat->pos.xPos += boat->speed * phd_sin(boat->pos.yRot);
if (boat->speed >= 0) if (boat->speed >= 0)
binfo->propRot += (boat->speed * (ONE_DEGREE * 3)) + (ONE_DEGREE << 1); binfo->propRot += (boat->speed * (ONE_DEGREE * 3)) + (ONE_DEGREE << 1);
else else
binfo->propRot += ONE_DEGREE * 33; binfo->propRot += ONE_DEGREE * 33;
/* Slide boat according to tilts (to avoid getting stuck on slopes) */ /* Slide boat according to tilts (to avoid getting stuck on slopes) */
slip = RUBBER_BOAT_SIDE_SLIP * phd_sin(boat->pos.zRot) >> W2V_SHIFT; slip = RUBBER_BOAT_SIDE_SLIP * phd_sin(boat->pos.zRot);
if (!slip && boat->pos.zRot) if (!slip && boat->pos.zRot)
slip = (boat->pos.zRot > 0) ? 1 : -1; slip = (boat->pos.zRot > 0) ? 1 : -1;
boat->pos.zPos -= slip * phd_sin(boat->pos.yRot) >> W2V_SHIFT; boat->pos.zPos -= slip * phd_sin(boat->pos.yRot);
boat->pos.xPos += slip * phd_cos(boat->pos.yRot) >> W2V_SHIFT; boat->pos.xPos += slip * phd_cos(boat->pos.yRot);
slip = RUBBER_BOAT_SLIP * phd_sin(boat->pos.xRot) >> W2V_SHIFT; slip = RUBBER_BOAT_SLIP * phd_sin(boat->pos.xRot);
if (!slip && boat->pos.xRot) if (!slip && boat->pos.xRot)
slip = (boat->pos.xRot > 0) ? 1 : -1; slip = (boat->pos.xRot > 0) ? 1 : -1;
boat->pos.zPos -= slip * phd_cos(boat->pos.yRot) >> W2V_SHIFT; boat->pos.zPos -= slip * phd_cos(boat->pos.yRot);
boat->pos.xPos -= slip * phd_sin(boat->pos.yRot) >> W2V_SHIFT; boat->pos.xPos -= slip * phd_sin(boat->pos.yRot);
/* Remember desired position in case of collisions moving us about */ /* Remember desired position in case of collisions moving us about */
moved.x = boat->pos.xPos; moved.x = boat->pos.xPos;
@ -448,10 +449,7 @@ static int RubberBoatDynamics(short boat_number)
/* Check final movement if slipped or collided and adjust speed */ /* Check final movement if slipped or collided and adjust speed */
if (slip || collide) if (slip || collide)
{ {
//## newspeed = (boat->pos.zPos - old.z) * phd_cos(boat->pos.yRot) + (boat->pos.xPos - old.x) * phd_sin(boat->pos.yRot) >> W2V_SHIFT; newspeed = (boat->pos.zPos - old.z) * phd_cos(boat->pos.yRot) + (boat->pos.xPos - old.x) * phd_sin(boat->pos.yRot);
newspeed = ((boat->pos.zPos - old.z) * phd_cos(boat->pos.yRot)
+ (boat->pos.xPos - old.x) * phd_sin(boat->pos.yRot))
>> W2V_SHIFT;
if (Lara.Vehicle == boat_number && boat->speed > RUBBER_BOAT_MAX_SPEED + RUBBER_BOAT_ACCELERATION && newspeed < boat->speed - 10) if (Lara.Vehicle == boat_number && boat->speed > RUBBER_BOAT_MAX_SPEED + RUBBER_BOAT_ACCELERATION && newspeed < boat->speed - 10)
{ {
@ -714,9 +712,9 @@ static int CanGetOffRubberBoat(int direction)
else else
angle = boat->pos.yRot + ANGLE(90); angle = boat->pos.yRot + ANGLE(90);
x = boat->pos.xPos + (1024 * phd_sin(angle) >> W2V_SHIFT); x = boat->pos.xPos + 1024 * phd_sin(angle);
y = boat->pos.yPos; y = boat->pos.yPos;
z = boat->pos.zPos + (1024 * phd_cos(angle) >> W2V_SHIFT); z = boat->pos.zPos + 1024 * phd_cos(angle);
roomNum = boat->roomNumber; roomNum = boat->roomNumber;
floor = GetFloor(x, y, z, &roomNum); floor = GetFloor(x, y, z, &roomNum);
@ -853,8 +851,8 @@ static void TriggerRubberBoatMist(long x, long y, long z, long speed, short angl
sptr->x = x * ((GetRandomControl() & 15) - 8); sptr->x = x * ((GetRandomControl() & 15) - 8);
sptr->y = y * ((GetRandomControl() & 15) - 8); sptr->y = y * ((GetRandomControl() & 15) - 8);
sptr->z = z * ((GetRandomControl() & 15) - 8); sptr->z = z * ((GetRandomControl() & 15) - 8);
zv = (speed * phd_cos(angle)) >> (W2V_SHIFT + 2); zv = speed * phd_cos(angle) / 4;
xv = (speed * phd_sin(angle)) >> (W2V_SHIFT + 2); xv = speed * phd_sin(angle) / 4;
sptr->xVel = xv + ((GetRandomControl() & 127) - 64); sptr->xVel = xv + ((GetRandomControl() & 127) - 64);
sptr->yVel = (speed << 3) + (speed << 2); sptr->yVel = (speed << 3) + (speed << 2);
sptr->zVel = zv + ((GetRandomControl() & 127) - 64); sptr->zVel = zv + ((GetRandomControl() & 127) - 64);
@ -909,9 +907,9 @@ void RubberBoatDoGetOff(ITEM_INFO* boat)
Lara.Vehicle = NO_ITEM; Lara.Vehicle = NO_ITEM;
roomNum = LaraItem->roomNumber; roomNum = LaraItem->roomNumber;
x = LaraItem->pos.xPos + (360 * phd_sin(LaraItem->pos.yRot) >> W2V_SHIFT); x = LaraItem->pos.xPos + 360 * phd_sin(LaraItem->pos.yRot);
y = LaraItem->pos.yPos - 90; y = LaraItem->pos.yPos - 90;
z = LaraItem->pos.zPos + (360 * phd_cos(LaraItem->pos.yRot) >> W2V_SHIFT); z = LaraItem->pos.zPos + 360 * phd_cos(LaraItem->pos.yRot);
floor = GetFloor(x, y, z, &roomNum); floor = GetFloor(x, y, z, &roomNum);
if (GetFloorHeight(floor, x, y, z) >= y - 256) if (GetFloorHeight(floor, x, y, z) >= y - 256)
{ {

View file

@ -118,8 +118,8 @@ static void FireSubHarpoon(ITEM_INFO* v)
item->pos.yRot = v->pos.yRot; item->pos.yRot = v->pos.yRot;
item->pos.zRot = 0; item->pos.zRot = 0;
item->fallspeed = (short)(-HARPOON_SPEED * phd_sin(item->pos.xRot) >> W2V_SHIFT); item->fallspeed = -HARPOON_SPEED * phd_sin(item->pos.xRot);
item->speed = (short)(HARPOON_SPEED * phd_cos(item->pos.xRot) >> W2V_SHIFT); item->speed = HARPOON_SPEED * phd_cos(item->pos.xRot);
item->hitPoints = HARPOON_TIME; item->hitPoints = HARPOON_TIME;
item->itemFlags[0] = 1; item->itemFlags[0] = 1;
@ -162,8 +162,8 @@ static void TriggerSubMist(long x, long y, long z, long speed, short angle)
sptr->x = x + ((GetRandomControl() & 15) - 8); sptr->x = x + ((GetRandomControl() & 15) - 8);
sptr->y = y + ((GetRandomControl() & 15) - 8); sptr->y = y + ((GetRandomControl() & 15) - 8);
sptr->z = z + ((GetRandomControl() & 15) - 8); sptr->z = z + ((GetRandomControl() & 15) - 8);
zv = (speed * phd_cos(angle)) >> (W2V_SHIFT + 2); zv = speed * phd_cos(angle) / 4;
xv = (speed * phd_sin(angle)) >> (W2V_SHIFT + 2); xv = speed * phd_sin(angle) / 4;
sptr->xVel = xv + ((GetRandomControl() & 127) - 64); sptr->xVel = xv + ((GetRandomControl() & 127) - 64);
sptr->yVel = 0; sptr->yVel = 0;
sptr->zVel = zv + ((GetRandomControl() & 127) - 64); sptr->zVel = zv + ((GetRandomControl() & 127) - 64);
@ -280,10 +280,10 @@ static int CanGetOff(ITEM_INFO* v)
return 0; return 0;
yangle = v->pos.yRot + ANGLE(180); yangle = v->pos.yRot + ANGLE(180);
speed = (GETOFF_DIST * phd_cos(v->pos.xRot)) >> W2V_SHIFT; speed = GETOFF_DIST * phd_cos(v->pos.xRot);
x = v->pos.xPos + (speed * phd_sin(yangle) >> W2V_SHIFT); x = v->pos.xPos + speed * phd_sin(yangle);
z = v->pos.zPos + (speed * phd_cos(yangle) >> W2V_SHIFT); z = v->pos.zPos + speed * phd_cos(yangle);
y = v->pos.yPos - ((GETOFF_DIST * phd_sin(-v->pos.xRot)) >> W2V_SHIFT); y = v->pos.yPos - GETOFF_DIST * phd_sin(-v->pos.xRot);
roomNumber = v->roomNumber; roomNumber = v->roomNumber;
floor = GetFloor(x, y, z, &roomNumber); floor = GetFloor(x, y, z, &roomNumber);
@ -386,8 +386,8 @@ static void DoCurrent(ITEM_INFO* item)
dz = target.z - LaraItem->pos.zPos; dz = target.z - LaraItem->pos.zPos;
speed = FixedCameras[sinkval].data; speed = FixedCameras[sinkval].data;
dx = phd_sin(angle << 4) * speed >> 4; dx = phd_sin(angle << 4) * speed * 1024;
dz = phd_cos(angle << 4) * speed >> 4; dz = phd_cos(angle << 4) * speed * 1024;
Lara.currentXvel += (dx - Lara.currentXvel) >> 4; Lara.currentXvel += (dx - Lara.currentXvel) >> 4;
Lara.currentZvel += (dz - Lara.currentZvel) >> 4; Lara.currentZvel += (dz - Lara.currentZvel) >> 4;
@ -425,7 +425,7 @@ static void BackgroundCollision(ITEM_INFO* v, ITEM_INFO* l, SUB_INFO* sub)
else else
coll->facing = Lara.moveAngle = v->pos.yRot - ANGLE(180); coll->facing = Lara.moveAngle = v->pos.yRot - ANGLE(180);
height = phd_sin(v->pos.xRot) * SUB_LENGTH >> W2V_SHIFT; height = phd_sin(v->pos.xRot) * SUB_LENGTH;
if (height < 0) if (height < 0)
height = -height; height = -height;
if (height < 200) if (height < 200)
@ -878,9 +878,9 @@ int SubControl(void)
else if (v->pos.xRot < -UPDOWN_LIMIT) else if (v->pos.xRot < -UPDOWN_LIMIT)
v->pos.xRot = -UPDOWN_LIMIT; v->pos.xRot = -UPDOWN_LIMIT;
v->pos.xPos += (((phd_sin(v->pos.yRot) * v->speed) >> W2V_SHIFT)* phd_cos(v->pos.xRot)) >> W2V_SHIFT; v->pos.xPos += phd_sin(v->pos.yRot) * v->speed * phd_cos(v->pos.xRot);
v->pos.yPos -= (phd_sin(v->pos.xRot) * v->speed) >> W2V_SHIFT; v->pos.yPos -= phd_sin(v->pos.xRot) * v->speed;
v->pos.zPos += (((phd_cos(v->pos.yRot) * v->speed) >> W2V_SHIFT)* phd_cos(v->pos.xRot)) >> W2V_SHIFT; v->pos.zPos += phd_cos(v->pos.yRot) * v->speed * phd_cos(v->pos.xRot);
} }
/* -------- determine if vehicle is near the surface */ /* -------- determine if vehicle is near the surface */

View file

@ -236,8 +236,8 @@ void InitialiseBaddy(short itemNum)
item->frameNumber = g_Level.Anims[item->animNumber].frameBase; item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
item->goalAnimState = STATE_BADDY_CLIMB_4_CLICKS; item->goalAnimState = STATE_BADDY_CLIMB_4_CLICKS;
item->currentAnimState = STATE_BADDY_CLIMB_4_CLICKS; item->currentAnimState = STATE_BADDY_CLIMB_4_CLICKS;
item->pos.xPos += phd_sin(item->pos.yRot) * (STEP_SIZE * 4) >> W2V_SHIFT; item->pos.xPos += phd_sin(item->pos.yRot) * (STEP_SIZE * 4);
item->pos.zPos += phd_cos(item->pos.yRot) * (STEP_SIZE * 4) >> W2V_SHIFT; item->pos.zPos += phd_cos(item->pos.yRot) * (STEP_SIZE * 4);
return; return;
} }
@ -248,8 +248,8 @@ void InitialiseBaddy(short itemNum)
item->frameNumber = g_Level.Anims[item->animNumber].frameBase; item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
item->goalAnimState = STATE_BADDY_CROUCH; item->goalAnimState = STATE_BADDY_CROUCH;
item->currentAnimState = STATE_BADDY_CROUCH; item->currentAnimState = STATE_BADDY_CROUCH;
item->pos.xPos += phd_sin(item->pos.yRot) * (STEP_SIZE * 4) >> W2V_SHIFT; item->pos.xPos += phd_sin(item->pos.yRot) * (STEP_SIZE * 4);
item->pos.zPos += phd_cos(item->pos.yRot) * (STEP_SIZE * 4) >> W2V_SHIFT; item->pos.zPos += phd_cos(item->pos.yRot) * (STEP_SIZE * 4);
item->itemFlags[3] = ocb; item->itemFlags[3] = ocb;
return; return;
@ -298,8 +298,8 @@ void BaddyControl(short itemNum)
int y = item->pos.yPos; int y = item->pos.yPos;
int z = item->pos.zPos; int z = item->pos.zPos;
int dx = 942 * phd_sin(item->pos.yRot) >> W2V_SHIFT; int dx = 942 * phd_sin(item->pos.yRot);
int dz = 942 * phd_cos(item->pos.yRot) >> W2V_SHIFT; int dz = 942 * phd_cos(item->pos.yRot);
x += dx; x += dx;
z += dz; z += dz;
@ -492,8 +492,8 @@ void BaddyControl(short itemNum)
jump = false; jump = false;
} }
dx = 942 * phd_sin(item->pos.yRot + ANGLE(45)) >> W2V_SHIFT; dx = 942 * phd_sin(item->pos.yRot + ANGLE(45));
dz = 942 * phd_cos(item->pos.yRot + ANGLE(45)) >> W2V_SHIFT; dz = 942 * phd_cos(item->pos.yRot + ANGLE(45));
x = item->pos.xPos + dx; x = item->pos.xPos + dx;
y = item->pos.yPos; y = item->pos.yPos;
@ -503,8 +503,8 @@ void BaddyControl(short itemNum)
floor = GetFloor(x, y, z, &roomNumber); floor = GetFloor(x, y, z, &roomNumber);
int height4 = GetFloorHeight(floor, x, y, z); int height4 = GetFloorHeight(floor, x, y, z);
dx = 942 * phd_sin(item->pos.yRot + ANGLE(78.75f)) >> W2V_SHIFT; dx = 942 * phd_sin(item->pos.yRot + ANGLE(78.75f));
dz = 942 * phd_cos(item->pos.yRot + ANGLE(78.75f)) >> W2V_SHIFT; dz = 942 * phd_cos(item->pos.yRot + ANGLE(78.75f));
x = item->pos.xPos + dx; x = item->pos.xPos + dx;
y = item->pos.yPos; y = item->pos.yPos;
@ -523,8 +523,8 @@ void BaddyControl(short itemNum)
jump = false; jump = false;
} }
dx = 942 * phd_sin(item->pos.yRot - ANGLE(45)) >> W2V_SHIFT; dx = 942 * phd_sin(item->pos.yRot - ANGLE(45));
dz = 942 * phd_cos(item->pos.yRot - ANGLE(45)) >> W2V_SHIFT; dz = 942 * phd_cos(item->pos.yRot - ANGLE(45));
x = item->pos.xPos + dx; x = item->pos.xPos + dx;
y = item->pos.yPos; y = item->pos.yPos;
@ -534,8 +534,8 @@ void BaddyControl(short itemNum)
floor = GetFloor(x, y, z, &roomNumber); floor = GetFloor(x, y, z, &roomNumber);
int height6 = GetFloorHeight(floor, x, y, z); int height6 = GetFloorHeight(floor, x, y, z);
dx = 942 * phd_sin(item->pos.yRot - ANGLE(78.75f)) >> W2V_SHIFT; dx = 942 * phd_sin(item->pos.yRot - ANGLE(78.75f));
dz = 942 * phd_cos(item->pos.yRot - ANGLE(78.75f)) >> W2V_SHIFT; dz = 942 * phd_cos(item->pos.yRot - ANGLE(78.75f));
x = item->pos.xPos + dx; x = item->pos.xPos + dx;
y = item->pos.yPos; y = item->pos.yPos;

View file

@ -50,16 +50,16 @@ void ScorpionControl(short itemNumber)
short joint3 = 0; short joint3 = 0;
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
int x = item->pos.xPos + 682 * phd_sin(item->pos.yRot) >> W2V_SHIFT; int x = item->pos.xPos + 682 * phd_sin(item->pos.yRot);
int z = item->pos.zPos + 682 * phd_cos(item->pos.yRot) >> W2V_SHIFT; int z = item->pos.zPos + 682 * phd_cos(item->pos.yRot);
FLOOR_INFO* floor = GetFloor(x, item->pos.yPos, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, item->pos.yPos, z, &roomNumber);
int height1 = GetFloorHeight(floor, x, item->pos.yPos, z); int height1 = GetFloorHeight(floor, x, item->pos.yPos, z);
if (abs(item->pos.yPos - height1) > 512) if (abs(item->pos.yPos - height1) > 512)
height1 = item->pos.yPos; height1 = item->pos.yPos;
x = item->pos.xPos - 682 * phd_sin(item->pos.yRot) >> W2V_SHIFT; x = item->pos.xPos - 682 * phd_sin(item->pos.yRot);
z = item->pos.zPos - 682 * phd_cos(item->pos.yRot) >> W2V_SHIFT; z = item->pos.zPos - 682 * phd_cos(item->pos.yRot);
floor = GetFloor(x, item->pos.yPos, z, &roomNumber); floor = GetFloor(x, item->pos.yPos, z, &roomNumber);
int height2 = GetFloorHeight(floor, x, item->pos.yPos, z); int height2 = GetFloorHeight(floor, x, item->pos.yPos, z);
@ -68,16 +68,16 @@ void ScorpionControl(short itemNumber)
short angle1 = phd_atan(1344, height2 - height1); short angle1 = phd_atan(1344, height2 - height1);
x = item->pos.xPos - 682 * phd_sin(item->pos.yRot) >> W2V_SHIFT; x = item->pos.xPos - 682 * phd_sin(item->pos.yRot);
z = item->pos.zPos + 682 * phd_cos(item->pos.yRot) >> W2V_SHIFT; z = item->pos.zPos + 682 * phd_cos(item->pos.yRot);
floor = GetFloor(x, item->pos.yPos, z, &roomNumber); floor = GetFloor(x, item->pos.yPos, z, &roomNumber);
int height3 = GetFloorHeight(floor, x, item->pos.yPos, z); int height3 = GetFloorHeight(floor, x, item->pos.yPos, z);
if (abs(item->pos.yPos - height3) > 512) if (abs(item->pos.yPos - height3) > 512)
height3 = item->pos.yPos; height3 = item->pos.yPos;
x = item->pos.xPos + 682 * phd_sin(item->pos.yRot) >> W2V_SHIFT; x = item->pos.xPos + 682 * phd_sin(item->pos.yRot);
z = item->pos.zPos - 682 * phd_cos(item->pos.yRot) >> W2V_SHIFT; z = item->pos.zPos - 682 * phd_cos(item->pos.yRot);
floor = GetFloor(x, item->pos.yPos, z, &roomNumber); floor = GetFloor(x, item->pos.yPos, z, &roomNumber);
int height4 = GetFloorHeight(floor, x, item->pos.yPos, z); int height4 = GetFloorHeight(floor, x, item->pos.yPos, z);

View file

@ -207,9 +207,9 @@ static void DemigodHammerAttack(int x, int y, int z, int something)
spark->x = (GetRandomControl() & 0x1F) + x - 16; spark->x = (GetRandomControl() & 0x1F) + x - 16;
spark->y = (GetRandomControl() & 0x1F) + y - 16; spark->y = (GetRandomControl() & 0x1F) + y - 16;
spark->z = (GetRandomControl() & 0x1F) + z - 16; spark->z = (GetRandomControl() & 0x1F) + z - 16;
spark->xVel = (byte)(GetRandomControl() + 256) * phd_sin(angle) >> W2V_SHIFT; spark->xVel = (byte)(GetRandomControl() + 256) * phd_sin(angle);
spark->yVel = -32 - (GetRandomControl() & 0x3F); spark->yVel = -32 - (GetRandomControl() & 0x3F);
spark->zVel = (byte)(GetRandomControl() + 256) * phd_cos(angle) >> W2V_SHIFT; spark->zVel = (byte)(GetRandomControl() + 256) * phd_cos(angle);
spark->friction = 9; spark->friction = 9;
if (GetRandomControl() & 1) if (GetRandomControl() & 1)

View file

@ -31,9 +31,9 @@ void EnemyJeepLaunchGrenade(ITEM_INFO* item)
grenadeItem->pos.yRot = item->pos.yRot + -ANGLE(180); grenadeItem->pos.yRot = item->pos.yRot + -ANGLE(180);
grenadeItem->pos.zRot = 0; grenadeItem->pos.zRot = 0;
grenadeItem->pos.xPos = item->pos.xPos + (1024 * phd_sin(grenadeItem->pos.yRot) >> W2V_SHIFT); grenadeItem->pos.xPos = item->pos.xPos + 1024 * phd_sin(grenadeItem->pos.yRot);
grenadeItem->pos.yPos = item->pos.yPos - 768; grenadeItem->pos.yPos = item->pos.yPos - 768;
grenadeItem->pos.zPos = item->pos.xPos + (1024 * phd_cos(grenadeItem->pos.yRot) >> W2V_SHIFT); grenadeItem->pos.zPos = item->pos.xPos + 1024 * phd_cos(grenadeItem->pos.yRot);
SmokeCountL = 32; SmokeCountL = 32;
SmokeWeapon = 5; SmokeWeapon = 5;
@ -54,7 +54,7 @@ void EnemyJeepLaunchGrenade(ITEM_INFO* item)
grenadeItem->speed = 32; grenadeItem->speed = 32;
grenadeItem->currentAnimState = grenadeItem->pos.xRot; grenadeItem->currentAnimState = grenadeItem->pos.xRot;
grenadeItem->fallspeed = -32 * phd_sin(grenadeItem->pos.xRot) >> W2V_SHIFT; grenadeItem->fallspeed = -32 * phd_sin(grenadeItem->pos.xRot);
grenadeItem->goalAnimState = grenadeItem->pos.yRot; grenadeItem->goalAnimState = grenadeItem->pos.yRot;
grenadeItem->requiredAnimState = 0; grenadeItem->requiredAnimState = 0;
grenadeItem->hitPoints = 120; grenadeItem->hitPoints = 120;
@ -96,8 +96,8 @@ void EnemyJeepControl(short itemNumber)
int y = item->pos.yPos; int y = item->pos.yPos;
int z = item->pos.zPos; int z = item->pos.zPos;
int dx = 682 * phd_sin(item->pos.yRot) >> W2V_SHIFT; int dx = 682 * phd_sin(item->pos.yRot);
int dz = 682 * phd_cos(item->pos.yRot) >> W2V_SHIFT; int dz = 682 * phd_cos(item->pos.yRot);
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(x - dz, y, z - dx, &roomNumber); FLOOR_INFO* floor = GetFloor(x - dz, y, z - dx, &roomNumber);
@ -337,8 +337,8 @@ void EnemyJeepControl(short itemNumber)
target->boxNumber = aiObject->boxNumber; target->boxNumber = aiObject->boxNumber;
if (!(aiObject->flags & 0x20)) if (!(aiObject->flags & 0x20))
{ {
target->pos.xPos += 256 * phd_sin(target->pos.yRot) >> W2V_SHIFT; target->pos.xPos += 256 * phd_sin(target->pos.yRot);
target->pos.zPos += 256 * phd_cos(target->pos.yRot) >> W2V_SHIFT; target->pos.zPos += 256 * phd_cos(target->pos.yRot);
} }
} }
} }
@ -366,8 +366,8 @@ void EnemyJeepControl(short itemNumber)
if (item->itemFlags[0] < 0) if (item->itemFlags[0] < 0)
item->itemFlags[0] = 0; item->itemFlags[0] = 0;
dx = item->itemFlags[0] * phd_sin(-2 - xRot / 512) >> W2V_SHIFT; dx = item->itemFlags[0] * phd_sin(-2 - xRot / 512);
dz = item->itemFlags[0] * phd_cos(-2 - xRot / 512) >> W2V_SHIFT; dz = item->itemFlags[0] * phd_cos(-2 - xRot / 512);
item->pos.xPos += dx / 64; item->pos.xPos += dx / 64;
item->pos.zPos += dz / 64; item->pos.zPos += dz / 64;

View file

@ -45,8 +45,8 @@ static void HorsemanSparks(PHD_VECTOR* pos, int param1, int num)
spark->flags = SP_NONE; spark->flags = SP_NONE;
spark->gravity = (r >> 7) & 0x1F; spark->gravity = (r >> 7) & 0x1F;
spark->maxYvel = 0; spark->maxYvel = 0;
spark->zVel = phd_cos((r & 0x7FF) + param1 - 1024) >> 2; spark->zVel = phd_cos((r & 0x7FF) + param1 - 1024) * 4096;
spark->xVel = -phd_sin((r & 0x7FF) + param1 - 1024) >> 2; spark->xVel = -phd_sin((r & 0x7FF) + param1 - 1024) * 4096;
} }
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
@ -87,8 +87,8 @@ static void HorsemanSparks(PHD_VECTOR* pos, int param1, int num)
spark->dSize = spark->sSize / 2; spark->dSize = spark->sSize / 2;
spark->flags = 26; spark->flags = 26;
spark->maxYvel = 0; spark->maxYvel = 0;
spark->zVel = phd_cos((r & 0x7FF) + param1 - 1024) >> 2; spark->zVel = phd_cos((r & 0x7FF) + param1 - 1024) * 4096;
spark->xVel = -phd_sin((r & 0x7FF) + param1 - 1024) >> 2; spark->xVel = -phd_sin((r & 0x7FF) + param1 - 1024) * 4096;
} }
} }
@ -172,16 +172,16 @@ void HorsemanControl(short itemNumber)
y = horseItem->pos.yPos; y = horseItem->pos.yPos;
z = horseItem->pos.zPos; z = horseItem->pos.zPos;
x = horseItem->pos.xPos + 341 * phd_sin(horseItem->pos.yRot) >> 14; x = horseItem->pos.xPos + 341 * phd_sin(horseItem->pos.yRot);
y = horseItem->pos.yPos; y = horseItem->pos.yPos;
z = horseItem->pos.zPos + 341 * phd_cos(horseItem->pos.yRot) >> 14; z = horseItem->pos.zPos + 341 * phd_cos(horseItem->pos.yRot);
floor = GetFloor(x, y, z, &roomNumber); floor = GetFloor(x, y, z, &roomNumber);
height1 = GetFloorHeight(floor, x, y, z); height1 = GetFloorHeight(floor, x, y, z);
x = horseItem->pos.xPos - 341 * phd_sin(horseItem->pos.yRot) >> 14; x = horseItem->pos.xPos - 341 * phd_sin(horseItem->pos.yRot);
y = horseItem->pos.yPos; y = horseItem->pos.yPos;
z = horseItem->pos.zPos - 341 * phd_cos(horseItem->pos.yRot) >> 14; z = horseItem->pos.zPos - 341 * phd_cos(horseItem->pos.yRot);
floor = GetFloor(x, y, z, &roomNumber); floor = GetFloor(x, y, z, &roomNumber);
height2 = GetFloorHeight(floor, x, y, z); height2 = GetFloorHeight(floor, x, y, z);

View file

@ -140,9 +140,9 @@ void UpdateLittleBeetles()
int oldy = beetle->pos.yPos; int oldy = beetle->pos.yPos;
int oldz = beetle->pos.zPos; int oldz = beetle->pos.zPos;
beetle->pos.xPos += beetle->speed * phd_sin(beetle->pos.yRot) >> W2V_SHIFT; beetle->pos.xPos += beetle->speed * phd_sin(beetle->pos.yRot);
beetle->pos.yPos += beetle->fallspeed; beetle->pos.yPos += beetle->fallspeed;
beetle->pos.zPos += beetle->speed * phd_cos(beetle->pos.yRot) >> W2V_SHIFT; beetle->pos.zPos += beetle->speed * phd_cos(beetle->pos.yRot);
beetle->fallspeed += GRAVITY; beetle->fallspeed += GRAVITY;

View file

@ -592,9 +592,9 @@ void SasDragBlokeCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* c)
{ {
if (item->frameNumber == g_Level.Anims[item->animNumber].frameEnd) if (item->frameNumber == g_Level.Anims[item->animNumber].frameEnd)
{ {
int x = l->pos.xPos - (512 * phd_sin(l->pos.yRot) >> W2V_SHIFT); int x = l->pos.xPos - 512 * phd_sin(l->pos.yRot);
int y = l->pos.yPos; int y = l->pos.yPos;
int z = l->pos.xPos - (512 * phd_cos(l->pos.yRot) >> W2V_SHIFT); int z = l->pos.xPos - 512 * phd_cos(l->pos.yRot);
short roomNumber = l->roomNumber; short roomNumber = l->roomNumber;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);

View file

@ -146,7 +146,7 @@ void SentryGunControl(short itemNum)
{ {
// Throw fire // Throw fire
SentryGunThrowFire(item); SentryGunThrowFire(item);
c = phd_sin((GlobalCounter & 0x1F) << 11) >> 2; c = phd_sin((GlobalCounter & 0x1F) << 11) * 4096;
} }
else else
{ {

View file

@ -40,8 +40,8 @@ void SethaControl(short itemNumber)
int y = item->pos.yPos; int y = item->pos.yPos;
int z = item->pos.zPos; int z = item->pos.zPos;
int dx = 870 * phd_sin(item->pos.yRot) >> W2V_SHIFT; int dx = 870 * phd_sin(item->pos.yRot);
int dz = 870 * phd_cos(item->pos.yRot) >> W2V_SHIFT; int dz = 870 * phd_cos(item->pos.yRot);
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);

View file

@ -52,9 +52,9 @@ static void WakeUpSkeleton(ITEM_INFO* item)
spark->x = fx->pos.xPos; spark->x = fx->pos.xPos;
spark->y = fx->pos.yPos; spark->y = fx->pos.yPos;
spark->z = fx->pos.zPos; spark->z = fx->pos.zPos;
spark->xVel = phd_sin(fx->pos.yRot) >> 2; spark->xVel = phd_sin(fx->pos.yRot) * 4096;
spark->yVel = 0; spark->yVel = 0;
spark->zVel = phd_cos(fx->pos.yRot) >> 2; spark->zVel = phd_cos(fx->pos.yRot) * 4096;
spark->transType = COLADD; spark->transType = COLADD;
spark->friction = 68; spark->friction = 68;
spark->flags = 26; spark->flags = 26;
@ -139,8 +139,8 @@ void SkeletonControl(short itemNumber)
int y = item->pos.yPos; int y = item->pos.yPos;
int z = item->pos.zPos; int z = item->pos.zPos;
int dx = 870 * phd_sin(item->pos.yRot) >> 14; int dx = 870 * phd_sin(item->pos.yRot);
int dz = 870 * phd_cos(item->pos.yRot) >> 14; int dz = 870 * phd_cos(item->pos.yRot);
x += dx; x += dx;
z += dz; z += dz;
@ -256,8 +256,8 @@ void SkeletonControl(short itemNumber)
} }
else else
{ {
dx = 870 * phd_sin(item->pos.yRot + ANGLE(45)) >> 14; dx = 870 * phd_sin(item->pos.yRot + ANGLE(45));
dz = 870 * phd_cos(item->pos.yRot + ANGLE(45)) >> 14; dz = 870 * phd_cos(item->pos.yRot + ANGLE(45));
x = item->pos.xPos + dx; x = item->pos.xPos + dx;
y = item->pos.yPos; y = item->pos.yPos;
@ -267,8 +267,8 @@ void SkeletonControl(short itemNumber)
floor = GetFloor(x, y, z, &roomNumber); floor = GetFloor(x, y, z, &roomNumber);
int height4 = GetFloorHeight(floor, x, y, z); int height4 = GetFloorHeight(floor, x, y, z);
dx = 870 * phd_sin(item->pos.yRot + 14336) >> 14; dx = 870 * phd_sin(item->pos.yRot + 14336);
dz = 870 * phd_cos(item->pos.yRot + 14336) >> 14; dz = 870 * phd_cos(item->pos.yRot + 14336);
x = item->pos.xPos + dx; x = item->pos.xPos + dx;
y = item->pos.yPos; y = item->pos.yPos;
@ -287,8 +287,8 @@ void SkeletonControl(short itemNumber)
someFlag2 = false; someFlag2 = false;
} }
dx = 870 * phd_sin(item->pos.yRot - 8192) >> 14; dx = 870 * phd_sin(item->pos.yRot - 8192);
dz = 870 * phd_cos(item->pos.yRot - 8192) >> 14; dz = 870 * phd_cos(item->pos.yRot - 8192);
x = item->pos.xPos + dx; x = item->pos.xPos + dx;
y = item->pos.yPos; y = item->pos.yPos;
@ -298,8 +298,8 @@ void SkeletonControl(short itemNumber)
floor = GetFloor(x, y, z, &roomNumber); floor = GetFloor(x, y, z, &roomNumber);
int height6 = GetFloorHeight(floor, x, y, z); int height6 = GetFloorHeight(floor, x, y, z);
dx = 870 * phd_sin(item->pos.yRot - 14336) >> 14; dx = 870 * phd_sin(item->pos.yRot - 14336);
dz = 870 * phd_cos(item->pos.yRot - 14336) >> 14; dz = 870 * phd_cos(item->pos.yRot - 14336);
x = item->pos.xPos + dx; x = item->pos.xPos + dx;
y = item->pos.yPos; y = item->pos.yPos;

View file

@ -32,9 +32,9 @@ void SphinxControl(short itemNumber)
CREATURE_INFO* creature = (CREATURE_INFO*)item->data; CREATURE_INFO* creature = (CREATURE_INFO*)item->data;
OBJECT_INFO* obj = &Objects[item->objectNumber]; OBJECT_INFO* obj = &Objects[item->objectNumber];
int x = item->pos.xPos + 614 * phd_sin(item->pos.yRot) >> W2V_SHIFT; int x = item->pos.xPos + 614 * phd_sin(item->pos.yRot);
int y = item->pos.yPos; int y = item->pos.yPos;
int z = item->pos.zPos + 614 * phd_cos(item->pos.yRot) >> W2V_SHIFT; int z = item->pos.zPos + 614 * phd_cos(item->pos.yRot);
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);
@ -61,9 +61,9 @@ void SphinxControl(short itemNumber)
} }
} }
x = item->pos.xPos - 614 * phd_sin(item->pos.yRot) >> W2V_SHIFT; x = item->pos.xPos - 614 * phd_sin(item->pos.yRot);
y = item->pos.yPos; y = item->pos.yPos;
z = item->pos.zPos - 614 * phd_cos(item->pos.yRot) >> W2V_SHIFT; z = item->pos.zPos - 614 * phd_cos(item->pos.yRot);
roomNumber = item->roomNumber; roomNumber = item->roomNumber;

View file

@ -82,8 +82,8 @@ void VonCroyControl(short itemNumber)
int x = item->pos.xPos; int x = item->pos.xPos;
int z = item->pos.zPos; int z = item->pos.zPos;
int dx = 808 * phd_sin(item->pos.yRot) >> W2V_SHIFT; int dx = 808 * phd_sin(item->pos.yRot);
int dz = 808 * phd_cos(item->pos.yRot) >> W2V_SHIFT; int dz = 808 * phd_cos(item->pos.yRot);
x += dx; x += dx;
z += dz; z += dz;

View file

@ -161,9 +161,9 @@ void WraithControl(short itemNumber)
oldY = item->pos.yPos; oldY = item->pos.yPos;
oldZ = item->pos.zPos; oldZ = item->pos.zPos;
item->pos.xPos += item->speed * phd_sin(item->pos.yRot) >> W2V_SHIFT; item->pos.xPos += item->speed * phd_sin(item->pos.yRot);
item->pos.yPos += item->speed * phd_sin(item->pos.xRot) >> W2V_SHIFT; item->pos.yPos += item->speed * phd_sin(item->pos.xRot);
item->pos.zPos += item->speed * phd_cos(item->pos.yRot) >> W2V_SHIFT; item->pos.zPos += item->speed * phd_cos(item->pos.yRot);
IsRoomOutsideNo = NO_ROOM; IsRoomOutsideNo = NO_ROOM;
IsRoomOutside(item->pos.xPos, item->pos.yPos, item->pos.zPos); IsRoomOutside(item->pos.xPos, item->pos.yPos, item->pos.zPos);
@ -541,9 +541,9 @@ void WraithWallsEffect(int x, int y, int z, short yrot, short objNumber)
spark->z = (GetRandomControl() & 0x1F) + z - 16; spark->z = (GetRandomControl() & 0x1F) + z - 16;
short rot = yrot + GetRandomControl() - ANGLE(90); short rot = yrot + GetRandomControl() - ANGLE(90);
short velocity = ((GetRandomControl() & 0x3FF) + 1024); short velocity = ((GetRandomControl() & 0x3FF) + 1024);
spark->xVel = velocity * phd_sin(rot) >> W2V_SHIFT; spark->xVel = velocity * phd_sin(rot);
spark->yVel = (GetRandomControl() & 0x7F) - 64; spark->yVel = (GetRandomControl() & 0x7F) - 64;
spark->zVel = velocity * phd_cos(rot) >> W2V_SHIFT; spark->zVel = velocity * phd_cos(rot);
spark->friction = 4; spark->friction = 4;
spark->flags = SP_EXPDEF | SP_DEF | SP_SCALE; spark->flags = SP_EXPDEF | SP_DEF | SP_SCALE;
spark->maxYvel = 0; spark->maxYvel = 0;

View file

@ -9,8 +9,8 @@ void InitialiseSlicerDicer(short itemNum)
{ {
ITEM_INFO* item = &g_Level.Items[itemNum]; ITEM_INFO* item = &g_Level.Items[itemNum];
int dx = phd_sin(item->pos.yRot + ANGLE(90.0f)) >> 5; int dx = phd_sin(item->pos.yRot + ANGLE(90.0f)) * 512;
int dz = phd_cos(item->pos.yRot + ANGLE(90.0f)) >> 5; int dz = phd_cos(item->pos.yRot + ANGLE(90.0f)) * 512;
item->pos.xPos += dx; item->pos.xPos += dx;
item->pos.zPos += dz; item->pos.zPos += dz;
@ -28,7 +28,7 @@ void SlicerDicerControl(short itemNum)
SoundEffect(SFX_TR4_METAL_SCRAPE_LOOP1, &item->pos, 0); SoundEffect(SFX_TR4_METAL_SCRAPE_LOOP1, &item->pos, 0);
SoundEffect(SFX_TR4_METAL_SCRAPE_LOOP, &item->pos, 0); SoundEffect(SFX_TR4_METAL_SCRAPE_LOOP, &item->pos, 0);
int factor = (9 * phd_cos(item->triggerFlags) << 9 >> W2V_SHIFT) * phd_cos(item->pos.yRot) >> W2V_SHIFT; int factor = 4608 * phd_cos(item->triggerFlags) * phd_cos(item->pos.yRot);
item->pos.xPos = (item->itemFlags[0] << 8) + factor; item->pos.xPos = (item->itemFlags[0] << 8) + factor;
item->pos.yPos = (item->itemFlags[1] << 8) - 4608 * phd_sin(item->triggerFlags); item->pos.yPos = (item->itemFlags[1] << 8) - 4608 * phd_sin(item->triggerFlags);

View file

@ -14,8 +14,8 @@ void ControlSpikyWall(short itemNum)
/* Move wall */ /* Move wall */
if (TriggerActive(item) && item->status != ITEM_DEACTIVATED) if (TriggerActive(item) && item->status != ITEM_DEACTIVATED)
{ {
int x = item->pos.xPos + phd_sin(item->pos.yRot) >> WALL_SHIFT; int x = item->pos.xPos + phd_sin(item->pos.yRot);
int z = item->pos.zPos + phd_cos(item->pos.yRot) >> WALL_SHIFT; int z = item->pos.zPos + phd_cos(item->pos.yRot);
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(x, item->pos.yPos, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, item->pos.yPos, z, &roomNumber);

View file

@ -70,13 +70,13 @@ extern Inventory g_Inventory;
static int TestJeepHeight(ITEM_INFO* item, int dz, int dx, PHD_VECTOR* pos) static int TestJeepHeight(ITEM_INFO* item, int dz, int dx, PHD_VECTOR* pos)
{ {
pos->y = item->pos.yPos - (dz * phd_sin(item->pos.xRot) >> W2V_SHIFT) + (dx * phd_sin(item->pos.zRot) >> W2V_SHIFT); pos->y = item->pos.yPos - dz * phd_sin(item->pos.xRot) + dx * phd_sin(item->pos.zRot);
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
pos->z = item->pos.zPos + ((dz * c - dx * s) >> W2V_SHIFT); pos->z = item->pos.zPos + dz * c - dx * s;
pos->x = item->pos.xPos + ((dz * s + dx * c) >> W2V_SHIFT); pos->x = item->pos.xPos + dz * s + dx * c;
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(pos->x, pos->y, pos->z, &roomNumber); FLOOR_INFO* floor = GetFloor(pos->x, pos->y, pos->z, &roomNumber);
@ -243,9 +243,9 @@ static int JeepCanGetOff()
short angle = item->pos.yRot + 0x4000; short angle = item->pos.yRot + 0x4000;
int x = item->pos.xPos - (JEEP_GETOFF_DISTANCE * phd_sin(angle) >> W2V_SHIFT); int x = item->pos.xPos - JEEP_GETOFF_DISTANCE * phd_sin(angle);
int y = item->pos.yPos; int y = item->pos.yPos;
int z = item->pos.zPos - (JEEP_GETOFF_DISTANCE * phd_cos(angle) >> W2V_SHIFT); int z = item->pos.zPos - JEEP_GETOFF_DISTANCE * phd_cos(angle);
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);
@ -301,9 +301,9 @@ static void TriggerJeepExhaustSmoke(int x, int y, int z, short angle, short spee
spark->x = (GetRandomControl() & 0xF) + x - 8; spark->x = (GetRandomControl() & 0xF) + x - 8;
spark->y = (GetRandomControl() & 0xF) + y - 8; spark->y = (GetRandomControl() & 0xF) + y - 8;
spark->z = (GetRandomControl() & 0xF) + z - 8; spark->z = (GetRandomControl() & 0xF) + z - 8;
spark->xVel = speed * phd_sin(angle) >> (W2V_SHIFT + 2); spark->xVel = speed * phd_sin(angle) / 4;
spark->yVel = -8 - (GetRandomControl() & 7); spark->yVel = -8 - (GetRandomControl() & 7);
spark->zVel = speed * phd_cos(angle) >> (W2V_SHIFT + 2); spark->zVel = speed * phd_cos(angle) / 4;
spark->friction = 4; spark->friction = 4;
if (GetRandomControl() & 1) if (GetRandomControl() & 1)
@ -367,8 +367,8 @@ static int JeepCheckGetOff()
LaraItem->frameNumber = g_Level.Anims[LaraItem->animNumber].frameBase; LaraItem->frameNumber = g_Level.Anims[LaraItem->animNumber].frameBase;
LaraItem->goalAnimState = LS_STOP; LaraItem->goalAnimState = LS_STOP;
LaraItem->currentAnimState = LS_STOP; LaraItem->currentAnimState = LS_STOP;
LaraItem->pos.xPos -= JEEP_GETOFF_DISTANCE * phd_sin(LaraItem->pos.yRot) >> W2V_SHIFT; LaraItem->pos.xPos -= JEEP_GETOFF_DISTANCE * phd_sin(LaraItem->pos.yRot);
LaraItem->pos.zPos -= JEEP_GETOFF_DISTANCE * phd_cos(LaraItem->pos.yRot) >> W2V_SHIFT; LaraItem->pos.zPos -= JEEP_GETOFF_DISTANCE * phd_cos(LaraItem->pos.yRot);
LaraItem->pos.xRot = 0; LaraItem->pos.xRot = 0;
LaraItem->pos.zRot = 0; LaraItem->pos.zRot = 0;
Lara.Vehicle = NO_ITEM; Lara.Vehicle = NO_ITEM;
@ -487,10 +487,10 @@ static int GetJeepCollisionAnim(ITEM_INFO* item, PHD_VECTOR* p)
if (p->x || p->z) if (p->x || p->z)
{ {
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
int front = ((p->z * c) + (p->x * s)) >> W2V_SHIFT; int front = p->z * c + p->x * s;
int side = (-(p->z * s) + (p->x * c)) >> W2V_SHIFT; int side = -p->z * s + p->x * c;
if (abs(front) > abs(side)) if (abs(front) > abs(side))
{ {
@ -716,15 +716,15 @@ static int JeepDynamics(ITEM_INFO* item)
if (item->pos.yPos < height) if (item->pos.yPos < height)
speed = item->speed; speed = item->speed;
else else
speed = item->speed * phd_cos(item->pos.xRot) >> W2V_SHIFT; speed = item->speed * phd_cos(item->pos.xRot);
item->pos.xPos += (speed * phd_sin(jeep->momentumAngle)) >> W2V_SHIFT; item->pos.xPos += speed * phd_sin(jeep->momentumAngle);
item->pos.zPos += (speed * phd_cos(jeep->momentumAngle)) >> W2V_SHIFT; item->pos.zPos += speed * phd_cos(jeep->momentumAngle);
int slip = 0; int slip = 0;
if (item->pos.yPos >= height) if (item->pos.yPos >= height)
{ {
slip = JEEP_SLIP * phd_sin(item->pos.xRot) >> W2V_SHIFT; slip = JEEP_SLIP * phd_sin(item->pos.xRot);
if (abs(slip) > 16) if (abs(slip) > 16)
{ {
@ -736,20 +736,20 @@ static int JeepDynamics(ITEM_INFO* item)
jeep->velocity = slip; jeep->velocity = slip;
} }
slip = JEEP_SLIP_SIDE * phd_sin(item->pos.zRot) >> W2V_SHIFT; slip = JEEP_SLIP_SIDE * phd_sin(item->pos.zRot);
if (abs(slip) > JEEP_SLIP_SIDE / 4) if (abs(slip) > JEEP_SLIP_SIDE / 4)
{ {
JeepNoGetOff = 1; JeepNoGetOff = 1;
if (slip >= 0) if (slip >= 0)
{ {
item->pos.xPos += (slip - 24) * phd_sin(item->pos.yRot + ANGLE(90)) >> W2V_SHIFT; item->pos.xPos += (slip - 24) * phd_sin(item->pos.yRot + ANGLE(90));
item->pos.zPos += (slip - 24) * phd_cos(item->pos.yRot + ANGLE(90)) >> W2V_SHIFT; item->pos.zPos += (slip - 24) * phd_cos(item->pos.yRot + ANGLE(90));
} }
else else
{ {
item->pos.xPos += (slip - 24) * phd_sin(item->pos.yRot - ANGLE(90)) >> W2V_SHIFT; item->pos.xPos += (slip - 24) * phd_sin(item->pos.yRot - ANGLE(90));
item->pos.zPos += (slip - 24) * phd_cos(item->pos.yRot - ANGLE(90)) >> W2V_SHIFT; item->pos.zPos += (slip - 24) * phd_cos(item->pos.yRot - ANGLE(90));
} }
} }
} }
@ -832,7 +832,7 @@ static int JeepDynamics(ITEM_INFO* item)
if (collide) if (collide)
{ {
newspeed = ((item->pos.zPos - oldPos.z) * phd_cos(jeep->momentumAngle) + (item->pos.xPos - oldPos.x) * phd_sin(jeep->momentumAngle)) >> W2V_SHIFT; newspeed = (item->pos.zPos - oldPos.z) * phd_cos(jeep->momentumAngle) + (item->pos.xPos - oldPos.x) * phd_sin(jeep->momentumAngle);
newspeed <<= 8; newspeed <<= 8;
if ((&g_Level.Items[Lara.Vehicle] == item) && (jeep->velocity == JEEP_MAX_SPEED) && (newspeed < (JEEP_MAX_SPEED - 10))) if ((&g_Level.Items[Lara.Vehicle] == item) && (jeep->velocity == JEEP_MAX_SPEED) && (newspeed < (JEEP_MAX_SPEED - 10)))

View file

@ -98,13 +98,13 @@ void InitialiseMotorbike(short itemNumber)
static int TestMotorbikeHeight(ITEM_INFO* item, int dz, int dx, PHD_VECTOR* pos) static int TestMotorbikeHeight(ITEM_INFO* item, int dz, int dx, PHD_VECTOR* pos)
{ {
pos->y = item->pos.yPos - (dz * phd_sin(item->pos.xRot) >> W2V_SHIFT) + (dx * phd_sin(item->pos.zRot) >> W2V_SHIFT); pos->y = item->pos.yPos - dz * phd_sin(item->pos.xRot) + dx * phd_sin(item->pos.zRot);
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
pos->z = item->pos.zPos + ((dz * c - dx * s) >> W2V_SHIFT); pos->z = item->pos.zPos + dz * c - dx * s;
pos->x = item->pos.xPos + ((dz * s + dx * c) >> W2V_SHIFT); pos->x = item->pos.xPos + dz * s + dx * c;
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(pos->x, pos->y, pos->z, &roomNumber); FLOOR_INFO* floor = GetFloor(pos->x, pos->y, pos->z, &roomNumber);
@ -391,9 +391,9 @@ static void TriggerMotorbikeExhaustSmoke(int x, int y, int z, short angle, short
sptr->x = x + (GetRandomControl() & 0xF) - 8; sptr->x = x + (GetRandomControl() & 0xF) - 8;
sptr->y = y + (GetRandomControl() & 0xF) - 8; sptr->y = y + (GetRandomControl() & 0xF) - 8;
sptr->z = z + (GetRandomControl() & 0xF) - 8; sptr->z = z + (GetRandomControl() & 0xF) - 8;
sptr->xVel = (speed * phd_sin(angle)) >> 16; sptr->xVel = speed * phd_sin(angle) / 4;
sptr->yVel = (GetRandomControl() & 7) - 8; sptr->yVel = (GetRandomControl() & 7) - 8;
sptr->zVel = (speed * phd_cos(angle)) >> 16; sptr->zVel = speed * phd_cos(angle) / 4;
sptr->friction = 4; sptr->friction = 4;
if (GetRandomControl() & 1) if (GetRandomControl() & 1)
@ -521,8 +521,8 @@ static int MotorBikeCheckGetOff(void)
LaraItem->frameNumber = g_Level.Anims[LaraItem->animNumber].frameBase; LaraItem->frameNumber = g_Level.Anims[LaraItem->animNumber].frameBase;
LaraItem->goalAnimState = LS_STOP; LaraItem->goalAnimState = LS_STOP;
LaraItem->currentAnimState = LS_STOP; LaraItem->currentAnimState = LS_STOP;
LaraItem->pos.xPos -= 2 * phd_sin(item->pos.yRot) >> W2V_SHIFT; LaraItem->pos.xPos -= 2 * phd_sin(item->pos.yRot);
LaraItem->pos.zPos -= 2 * phd_cos(item->pos.yRot) >> W2V_SHIFT; LaraItem->pos.zPos -= 2 * phd_cos(item->pos.yRot);
LaraItem->pos.xRot = 0; LaraItem->pos.xRot = 0;
LaraItem->pos.zRot = 0; LaraItem->pos.zRot = 0;
Lara.Vehicle = NO_ITEM; Lara.Vehicle = NO_ITEM;
@ -600,10 +600,10 @@ static int GetMotorbikeCollisionAnim(ITEM_INFO* item, PHD_VECTOR* pos)
if (pos->x || pos->z) if (pos->x || pos->z)
{ {
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
int front = ((pos->z * c) + (pos->x * s)) >> W2V_SHIFT; int front = pos->z * c + pos->x * s;
int side = (-(pos->z * s) + (pos->x * c)) >> W2V_SHIFT; int side = -pos->z * s + pos->x * c;
if (abs(front) > abs(side)) if (abs(front) > abs(side))
{ {
@ -720,19 +720,19 @@ static int MotorBikeDynamics(ITEM_INFO* item)
floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &room_number); floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &room_number);
height = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos); height = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
if (item->pos.yPos >= height) if (item->pos.yPos >= height)
speed = (item->speed * phd_cos(item->pos.xRot)) >> W2V_SHIFT; speed = item->speed * phd_cos(item->pos.xRot);
else else
speed = item->speed; speed = item->speed;
item->pos.zPos += (speed * phd_cos(motorbike->momentumAngle)) >> W2V_SHIFT; item->pos.zPos += speed * phd_cos(motorbike->momentumAngle);
item->pos.xPos += (speed * phd_sin(motorbike->momentumAngle)) >> W2V_SHIFT; item->pos.xPos += speed * phd_sin(motorbike->momentumAngle);
if (item->pos.yPos >= height) if (item->pos.yPos >= height)
{ {
short anglex = 100 * phd_sin(item->pos.xRot) >> W2V_SHIFT; short anglex = 100 * phd_sin(item->pos.xRot);
if (abs(anglex) > 16) if (abs(anglex) > 16)
{ {
short anglex2 = 100 * phd_sin(item->pos.xRot) >> W2V_SHIFT; short anglex2 = 100 * phd_sin(item->pos.xRot);
if (anglex < 0) if (anglex < 0)
anglex2 = -anglex; anglex2 = -anglex;
if (anglex2 > 24) if (anglex2 > 24)
@ -741,7 +741,7 @@ static int MotorBikeDynamics(ITEM_INFO* item)
motorbike->velocity -= anglex; motorbike->velocity -= anglex;
} }
short anglez = 100 * phd_sin(item->pos.zRot) >> W2V_SHIFT; short anglez = 100 * phd_sin(item->pos.zRot);
if (abs(anglez) > 32) if (abs(anglez) > 32)
{ {
short ang, angabs; short ang, angabs;
@ -751,8 +751,8 @@ static int MotorBikeDynamics(ITEM_INFO* item)
else else
ang = item->pos.yRot - 0x4000; ang = item->pos.yRot - 0x4000;
angabs = abs(anglez) - 24; angabs = abs(anglez) - 24;
item->pos.xPos += angabs * phd_sin(ang) >> W2V_SHIFT; item->pos.xPos += angabs * phd_sin(ang);
item->pos.zPos += angabs * phd_cos(ang) >> W2V_SHIFT; item->pos.zPos += angabs * phd_cos(ang);
} }
} }
@ -841,7 +841,7 @@ static int MotorBikeDynamics(ITEM_INFO* item)
collide = GetMotorbikeCollisionAnim(item, &moved); collide = GetMotorbikeCollisionAnim(item, &moved);
if (collide) if (collide)
{ {
newspeed = ((item->pos.zPos - oldpos.z) * phd_cos(motorbike->momentumAngle) + (item->pos.xPos - oldpos.x) * phd_sin(motorbike->momentumAngle)) >> 6; newspeed = ((item->pos.zPos - oldpos.z) * phd_cos(motorbike->momentumAngle) + (item->pos.xPos - oldpos.x) * phd_sin(motorbike->momentumAngle)) * 256;
if (&g_Level.Items[Lara.Vehicle] == item && motorbike->velocity >= 0x8000 && newspeed < (motorbike->velocity - 10)) if (&g_Level.Items[Lara.Vehicle] == item && motorbike->velocity >= 0x8000 && newspeed < (motorbike->velocity - 10))
{ {
LaraItem->hitPoints -= (motorbike->velocity - newspeed) >> 7; LaraItem->hitPoints -= (motorbike->velocity - newspeed) >> 7;
@ -870,9 +870,9 @@ static BOOL MotorbikeCanGetOff(void)
item = &g_Level.Items[Lara.Vehicle]; item = &g_Level.Items[Lara.Vehicle];
angle = item->pos.yRot + 0x4000; angle = item->pos.yRot + 0x4000;
x = item->pos.xPos + ((500 * phd_sin(angle)) >> W2V_SHIFT); x = item->pos.xPos + 500 * phd_sin(angle);
y = item->pos.yPos; y = item->pos.yPos;
z = item->pos.zPos + ((500 * phd_cos(angle)) >> W2V_SHIFT); z = item->pos.zPos + 500 * phd_cos(angle);
room_number = item->roomNumber; room_number = item->roomNumber;
floor = GetFloor(x, y, z, &room_number); floor = GetFloor(x, y, z, &room_number);

View file

@ -201,11 +201,11 @@ void UpdateBats()
bat->pos.xRot += xAngle; bat->pos.xRot += xAngle;
} }
int sp = bat->speed * phd_cos(bat->pos.xRot) >> W2V_SHIFT; int sp = bat->speed * phd_cos(bat->pos.xRot);
bat->pos.xPos += sp * phd_sin(bat->pos.yRot) >> W2V_SHIFT; bat->pos.xPos += sp * phd_sin(bat->pos.yRot);
bat->pos.yPos += bat->speed * phd_sin(-bat->pos.xRot) >> W2V_SHIFT; bat->pos.yPos += bat->speed * phd_sin(-bat->pos.xRot);
bat->pos.zPos += sp * phd_cos(bat->pos.yRot) >> W2V_SHIFT; bat->pos.zPos += sp * phd_cos(bat->pos.yRot);
if ((i % 2 == 0) if ((i % 2 == 0)
&& bat->pos.xPos > x1 && bat->pos.xPos > x1

View file

@ -21,9 +21,9 @@ void DartControl(short itemNumber)
} }
else else
{ {
item->pos.xPos += item->speed * phd_sin(item->pos.yRot) >> W2V_SHIFT; item->pos.xPos += item->speed * phd_sin(item->pos.yRot);
item->pos.yPos -= item->speed * phd_sin(item->pos.xRot) >> W2V_SHIFT; item->pos.yPos -= item->speed * phd_sin(item->pos.xRot);
item->pos.xPos += item->speed * phd_cos(item->pos.yRot) >> W2V_SHIFT; item->pos.xPos += item->speed * phd_cos(item->pos.yRot);
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber); FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);

View file

@ -147,9 +147,9 @@ void UpdateRats()
int oldY = rat->pos.yPos; int oldY = rat->pos.yPos;
int oldZ = rat->pos.zPos; int oldZ = rat->pos.zPos;
rat->pos.xPos += rat->speed * phd_sin(rat->pos.yRot) >> W2V_SHIFT; rat->pos.xPos += rat->speed * phd_sin(rat->pos.yRot);
rat->pos.yPos += rat->fallspeed; rat->pos.yPos += rat->fallspeed;
rat->pos.zPos += rat->speed * phd_cos(rat->pos.yRot) >> W2V_SHIFT; rat->pos.zPos += rat->speed * phd_cos(rat->pos.yRot);
rat->fallspeed += GRAVITY; rat->fallspeed += GRAVITY;

View file

@ -149,9 +149,9 @@ void UpdateSpiders()
int y = spider->pos.yPos; int y = spider->pos.yPos;
int z = spider->pos.zPos; int z = spider->pos.zPos;
spider->pos.xPos += spider->speed * phd_sin(spider->pos.yRot) >> W2V_SHIFT; spider->pos.xPos += spider->speed * phd_sin(spider->pos.yRot);
spider->pos.yPos += spider->fallspeed; spider->pos.yPos += spider->fallspeed;
spider->pos.zPos += spider->speed * phd_cos(spider->pos.yRot) >> W2V_SHIFT; spider->pos.zPos += spider->speed * phd_cos(spider->pos.yRot);
spider->fallspeed += GRAVITY; spider->fallspeed += GRAVITY;
int dx = LaraItem->pos.xPos - spider->pos.xPos; int dx = LaraItem->pos.xPos - spider->pos.xPos;

View file

@ -34,8 +34,8 @@ void InitialiseChef(short itemNumber)
item->goalAnimState = STATE_CHEF_COOKING; item->goalAnimState = STATE_CHEF_COOKING;
item->currentAnimState = STATE_CHEF_COOKING; item->currentAnimState = STATE_CHEF_COOKING;
item->frameNumber = g_Level.Anims[item->animNumber].frameBase; item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
item->pos.xPos += 192 * phd_sin(item->pos.yRot) >> W2V_SHIFT; item->pos.xPos += 192 * phd_sin(item->pos.yRot);
item->pos.zPos += 192 * phd_cos(item->pos.yRot) >> W2V_SHIFT; item->pos.zPos += 192 * phd_cos(item->pos.yRot);
} }
void ControlChef(short itemNumber) void ControlChef(short itemNumber)

View file

@ -93,8 +93,8 @@ void HitmanControl(short itemNumber)
int x = item->pos.xPos; int x = item->pos.xPos;
int z = item->pos.zPos; int z = item->pos.zPos;
int dx = 808 * phd_sin(item->pos.yRot) >> W2V_SHIFT; int dx = 808 * phd_sin(item->pos.yRot);
int dz = 808 * phd_cos(item->pos.yRot) >> W2V_SHIFT; int dz = 808 * phd_cos(item->pos.yRot);
x += dx; x += dx;
z += dz; z += dz;

View file

@ -140,8 +140,8 @@ void InitialiseGuard(short itemNum)
case 9: case 9:
item->goalAnimState = STATE_GUARD_USE_COMPUTER; item->goalAnimState = STATE_GUARD_USE_COMPUTER;
item->animNumber = anim + 59; item->animNumber = anim + 59;
item->pos.xPos -= phd_sin(item->pos.yRot); // 4 * not exist there ?? item->pos.xPos -= 512 * phd_sin(item->pos.yRot);
item->pos.zPos -= phd_cos(item->pos.yRot); // 4 * not exist there ?? item->pos.zPos -= 512 * phd_cos(item->pos.yRot);
break; break;
case 8: case 8:
item->goalAnimState = STATE_GUARD_HUNTING_IDLE; item->goalAnimState = STATE_GUARD_HUNTING_IDLE;
@ -166,8 +166,8 @@ void InitialiseSniper(short itemNum)
item->goalAnimState = STATE_SNIPER_STOP; item->goalAnimState = STATE_SNIPER_STOP;
item->currentAnimState = STATE_SNIPER_STOP; item->currentAnimState = STATE_SNIPER_STOP;
item->pos.yPos += STEP_SIZE * 2; item->pos.yPos += STEP_SIZE * 2;
item->pos.xPos += phd_sin(item->pos.yRot); item->pos.xPos += 1024 * phd_sin(item->pos.yRot + ANGLE(90));
item->pos.zPos += phd_cos(item->pos.yRot); item->pos.zPos += 1024 * phd_cos(item->pos.yRot + ANGLE(90));
} }
void InitialiseGuardLaser(short itemNum) void InitialiseGuardLaser(short itemNum)
@ -205,8 +205,8 @@ void GuardControl(short itemNum)
short joint0 = 0; short joint0 = 0;
int x = item->pos.xPos; int x = item->pos.xPos;
int z = item->pos.zPos; int z = item->pos.zPos;
int dx = 870 * phd_sin(item->pos.yRot) >> W2V_SHIFT; int dx = 870 * phd_sin(item->pos.yRot);
int dz = 870 * phd_cos(item->pos.yRot) >> W2V_SHIFT; int dz = 870 * phd_cos(item->pos.yRot);
x += dx; x += dx;
z += dz; z += dz;
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
@ -1018,8 +1018,8 @@ void Mafia2Control(short itemNum)
int x = item->pos.xPos; int x = item->pos.xPos;
int y = item->pos.yPos; int y = item->pos.yPos;
int z = item->pos.zPos; int z = item->pos.zPos;
int dx = 870 * phd_sin(item->pos.yRot) >> W2V_SHIFT; int dx = 870 * phd_sin(item->pos.yRot);
int dz = 870 * phd_cos(item->pos.yRot) >> W2V_SHIFT; int dz = 870 * phd_cos(item->pos.yRot);
x += dx; x += dx;
z += dz; z += dz;
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;

View file

@ -239,7 +239,7 @@ void LaserHeadControl(short itemNumber)
} }
} }
item->pos.yPos = item->itemFlags[1] - ((192 - item->speed) * phd_sin(item->itemFlags[2]) >> W2V_SHIFT); item->pos.yPos = item->itemFlags[1] - (192 - item->speed) * phd_sin(item->itemFlags[2]);
item->itemFlags[2] += ONE_DEGREE * item->speed; item->itemFlags[2] += ONE_DEGREE * item->speed;
if (!(GlobalCounter & 7)) if (!(GlobalCounter & 7))
@ -281,7 +281,7 @@ void LaserHeadControl(short itemNumber)
else else
{ {
item->triggerFlags++; item->triggerFlags++;
item->pos.yPos = item->itemFlags[1] - (128 * phd_sin(item->itemFlags[2]) >> W2V_SHIFT); item->pos.yPos = item->itemFlags[1] - 128 * phd_sin(item->itemFlags[2]);
item->itemFlags[2] += ANGLE(3); item->itemFlags[2] += ANGLE(3);
// Get guardian head's position // Get guardian head's position
@ -338,10 +338,10 @@ void LaserHeadControl(short itemNumber)
else else
yRot = 2 * GetRandomControl(); yRot = 2 * GetRandomControl();
int v = ((GetRandomControl() & 0x1FFF) + 8192); int v = ((GetRandomControl() & 0x1FFF) + 8192);
int c = v * phd_cos(-xRot) >> W2V_SHIFT; int c = v * phd_cos(-xRot);
dest.x = src.x + (c * phd_sin(yRot) >> W2V_SHIFT); dest.x = src.x + c * phd_sin(yRot);
dest.y = src.y + (v * phd_sin(-xRot) >> W2V_SHIFT); dest.y = src.y + v * phd_sin(-xRot);
dest.z = src.z + (c * phd_cos(yRot) >> W2V_SHIFT); dest.z = src.z + c * phd_cos(yRot);
if (condition) if (condition)
{ {
@ -375,11 +375,11 @@ void LaserHeadControl(short itemNumber)
if (JustLoaded) if (JustLoaded)
{ {
int c = 8192 * phd_cos(item->pos.xRot + 3328) >> W2V_SHIFT; int c = 8192 * phd_cos(item->pos.xRot + 3328);
dest.x = LaserHeadData.target.x = src.x + (c * phd_sin(item->pos.yRot) >> W2V_SHIFT); dest.x = LaserHeadData.target.x = src.x + c * phd_sin(item->pos.yRot);
dest.y = LaserHeadData.target.y = src.y + (8192 * phd_sin(3328 - item->pos.xRot) >> W2V_SHIFT); dest.y = LaserHeadData.target.y = src.y + 8192 * phd_sin(3328 - item->pos.xRot);
dest.z = LaserHeadData.target.z = src.z + (c * phd_cos(item->pos.yRot) >> W2V_SHIFT); dest.z = LaserHeadData.target.z = src.z + c * phd_cos(item->pos.yRot);
} }
else else
{ {
@ -471,10 +471,10 @@ void LaserHeadControl(short itemNumber)
src.z = 0; src.z = 0;
GetJointAbsPosition(item, (PHD_VECTOR*)& src, GuardianMeshes[i]); GetJointAbsPosition(item, (PHD_VECTOR*)& src, GuardianMeshes[i]);
int c = 8192 * phd_cos(angles[1]) >> W2V_SHIFT; int c = 8192 * phd_cos(angles[1]);
dest.x = src.x + (c * phd_sin(item->pos.yRot) >> W2V_SHIFT); dest.x = src.x + c * phd_sin(item->pos.yRot);
dest.y = src.y + (8192 * phd_sin(-angles[1]) >> W2V_SHIFT); dest.y = src.y + 8192 * phd_sin(-angles[1]);
dest.z = src.z + (c * phd_cos(item->pos.yRot) >> W2V_SHIFT); dest.z = src.z + c * phd_cos(item->pos.yRot);
if (item->itemFlags[3] != 90 if (item->itemFlags[3] != 90
&& LaserHeadData.fireArcs[j] != NULL) && LaserHeadData.fireArcs[j] != NULL)

View file

@ -273,8 +273,8 @@ void InitialiseRomanStatue(short itemNum)
item->currentAnimState = 13; item->currentAnimState = 13;
item->frameNumber = g_Level.Anims[item->animNumber].frameBase; item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
item->status = ITEM_NOT_ACTIVE; item->status = ITEM_NOT_ACTIVE;
item->pos.xPos += 486 * phd_sin(item->pos.yRot + ANGLE(90.0f)) >> W2V_SHIFT; item->pos.xPos += 486 * phd_sin(item->pos.yRot + ANGLE(90.0f));
item->pos.zPos += 486 * phd_cos(item->pos.yRot + ANGLE(90.0f)) >> W2V_SHIFT; item->pos.zPos += 486 * phd_cos(item->pos.yRot + ANGLE(90.0f));
ZeroMemory(&RomanStatueData, sizeof(ROMAN_STATUE_STRUCT)); ZeroMemory(&RomanStatueData, sizeof(ROMAN_STATUE_STRUCT));
} }

View file

@ -403,8 +403,8 @@ void ChaffFlareControl(short itemNumber)
item->pos.zRot += ANGLE(5); item->pos.zRot += ANGLE(5);
} }
int dx = item->speed * phd_sin(item->pos.yRot) >> W2V_SHIFT; int dx = item->speed * phd_sin(item->pos.yRot);
int dz = item->speed * phd_cos(item->pos.yRot) >> W2V_SHIFT; int dz = item->speed * phd_cos(item->pos.yRot);
item->pos.xPos += dx; item->pos.xPos += dx;
item->pos.zPos += dz; item->pos.zPos += dz;
@ -569,11 +569,11 @@ void TorpedoControl(short itemNumber)
item->pos.zRot += 16 * item->speed; item->pos.zRot += 16 * item->speed;
int c = item->speed * phd_cos(item->pos.xRot) >> W2V_SHIFT; int c = item->speed * phd_cos(item->pos.xRot);
item->pos.xPos += c * phd_sin(item->pos.yRot) >> W2V_SHIFT; item->pos.xPos += c * phd_sin(item->pos.yRot);
item->pos.yPos += item->speed * phd_sin(-item->pos.xRot) >> W2V_SHIFT; item->pos.yPos += item->speed * phd_sin(-item->pos.xRot);
item->pos.zPos += c * phd_cos(item->pos.yRot) >> W2V_SHIFT; item->pos.zPos += c * phd_cos(item->pos.yRot);
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber); FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);

View file

@ -16,7 +16,7 @@ void PulseLightControl(short itemNumber)
{ {
item->itemFlags[0] -= 1024; item->itemFlags[0] -= 1024;
long pulse = 256 * phd_sin(item->itemFlags[0] + 4 * (item->pos.yPos & 0x3FFF)) >> W2V_SHIFT; long pulse = 256 * phd_sin(item->itemFlags[0] + 4 * (item->pos.yPos & 0x3FFF));
pulse = abs(pulse); pulse = abs(pulse);
if (pulse > 255) if (pulse > 255)
pulse = 255; pulse = 255;
@ -41,9 +41,9 @@ void TriggerAlertLight(int x, int y, int z, int r, int g, int b, int angle, shor
source.z = z; source.z = z;
GetFloor(x, y, z, &room); GetFloor(x, y, z, &room);
source.roomNumber = room; source.roomNumber = room;
target.x = x + phd_sin(16 * angle); target.x = x + 16384 * phd_sin(16 * angle);
target.y = y; target.y = y;
target.z = z + phd_cos(16 * angle); target.z = z + 16384 * phd_cos(16 * angle);
if (!LOS(&source, &target)) if (!LOS(&source, &target))
TriggerDynamicLight(target.x, target.y, target.z, falloff, r, g, b); TriggerDynamicLight(target.x, target.y, target.z, falloff, r, g, b);
} }
@ -70,9 +70,9 @@ void StrobeLightControl(short itemNumber)
12); 12);
TriggerDynamicLight( TriggerDynamicLight(
item->pos.xPos + 256 * phd_sin(item->pos.yRot + 22528) >> W2V_SHIFT, item->pos.xPos + 256 * phd_sin(item->pos.yRot + 22528),
item->pos.yPos - 768, item->pos.yPos - 768,
item->pos.zPos + 256 * phd_cos(item->pos.yRot + 22528) >> W2V_SHIFT, item->pos.zPos + 256 * phd_cos(item->pos.yRot + 22528),
8, 8,
r, g, b); r, g, b);
} }

View file

@ -34,9 +34,9 @@ void ControlBodyPart(short fxNumber)
fx->fallspeed += 2; fx->fallspeed += 2;
} }
fx->pos.xPos += fx->speed * phd_sin(fx->pos.yRot) >> W2V_SHIFT; fx->pos.xPos += fx->speed * phd_sin(fx->pos.yRot);
fx->pos.yPos += fx->fallspeed; fx->pos.yPos += fx->fallspeed;
fx->pos.zPos += fx->speed * phd_cos(fx->pos.yRot) >> W2V_SHIFT; fx->pos.zPos += fx->speed * phd_cos(fx->pos.yRot);
short roomNumber = fx->roomNumber; short roomNumber = fx->roomNumber;
FLOOR_INFO* floor = GetFloor(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, &roomNumber); FLOOR_INFO* floor = GetFloor(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, &roomNumber);

View file

@ -105,11 +105,11 @@ void MissileControl(short itemNumber)
int y = fx->pos.yPos; int y = fx->pos.yPos;
int z = fx->pos.zPos; int z = fx->pos.zPos;
int c = fx->speed * phd_cos(fx->pos.xRot) >> W2V_SHIFT; int c = fx->speed * phd_cos(fx->pos.xRot);
fx->pos.xPos += c * phd_sin(fx->pos.yRot) >> W2V_SHIFT; fx->pos.xPos += c * phd_sin(fx->pos.yRot);
fx->pos.yPos += fx->speed * phd_sin(-fx->pos.xRot) >> W2V_SHIFT; fx->pos.yPos += fx->speed * phd_sin(-fx->pos.xRot);
fx->pos.zPos += c * phd_cos(fx->pos.yRot) >> W2V_SHIFT; fx->pos.zPos += c * phd_cos(fx->pos.yRot);
short roomNumber = fx->roomNumber; short roomNumber = fx->roomNumber;
FLOOR_INFO* floor = GetFloor(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, &roomNumber); FLOOR_INFO* floor = GetFloor(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, &roomNumber);

View file

@ -428,8 +428,8 @@ void ClassicRollingBallControl(short itemNum)
ydist = 1024; ydist = 1024;
} }
x = item->pos.xPos + (dist * phd_sin(item->pos.yRot) >> W2V_SHIFT); x = item->pos.xPos + dist * phd_sin(item->pos.yRot);
z = item->pos.zPos + (dist * phd_cos(item->pos.yRot) >> W2V_SHIFT); z = item->pos.zPos + dist * phd_cos(item->pos.yRot);
floor = GetFloor(x, item->pos.yPos, z, &roomNum); floor = GetFloor(x, item->pos.yPos, z, &roomNum);
y1 = GetFloorHeight(floor, x, item->pos.yPos, z); y1 = GetFloorHeight(floor, x, item->pos.yPos, z);

View file

@ -85,11 +85,11 @@ void ControlDeathSlide(short itemNumber)
if (item->fallspeed < 100) if (item->fallspeed < 100)
item->fallspeed += 5; item->fallspeed += 5;
int c = phd_cos(item->pos.yRot); float c = phd_cos(item->pos.yRot);
int s = phd_sin(item->pos.yRot); float s = phd_sin(item->pos.yRot);
item->pos.zPos += item->fallspeed * c >> W2V_SHIFT; item->pos.zPos += item->fallspeed * c;
item->pos.xPos += item->fallspeed * s >> W2V_SHIFT; item->pos.xPos += item->fallspeed * s;
item->pos.yPos += item->fallspeed >> 2; item->pos.yPos += item->fallspeed >> 2;
short roomNumber = item->roomNumber; short roomNumber = item->roomNumber;
@ -104,9 +104,9 @@ void ControlDeathSlide(short itemNumber)
LaraItem->pos.zPos = item->pos.zPos; LaraItem->pos.zPos = item->pos.zPos;
} }
int x = item->pos.xPos + (1024 * s >> W2V_SHIFT); int x = item->pos.xPos + 1024 * s;
int y = item->pos.yPos + 64; int y = item->pos.yPos + 64;
int z = item->pos.zPos + (1024 * c >> W2V_SHIFT); int z = item->pos.zPos + 1024 * c;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber); FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);

View file

@ -66,8 +66,8 @@ static void VentilatorEffect(BOUNDING_BOX* bounds, int intensity, short rot, int
int factor = 3 * (bounds->X2 - bounds->X1) / 8; int factor = 3 * (bounds->X2 - bounds->X1) / 8;
short angle = 2 * GetRandomControl(); short angle = 2 * GetRandomControl();
spark->x = ((bounds->X1 + bounds->X2) / 2) + ((GetRandomControl() % factor) * phd_sin(angle) >> W2V_SHIFT); spark->x = ((bounds->X1 + bounds->X2) / 2) + (GetRandomControl() % factor) * phd_sin(angle);
spark->z = ((bounds->Z1 + bounds->Z2) / 2) + ((GetRandomControl() % factor) * phd_cos(angle) >> W2V_SHIFT); spark->z = ((bounds->Z1 + bounds->Z2) / 2) + (GetRandomControl() % factor) * phd_cos(angle);
if (intensity >= 0) if (intensity >= 0)
spark->y = bounds->Y2; spark->y = bounds->Y2;
@ -92,8 +92,8 @@ static void VentilatorEffect(BOUNDING_BOX* bounds, int intensity, short rot, int
else else
spark->z = bounds->Z1; spark->z = bounds->Z1;
spark->x = ((bounds->X1 + bounds->X2) / 2) + ((GetRandomControl() % factor) * phd_cos(angle) >> W2V_SHIFT); spark->x = ((bounds->X1 + bounds->X2) / 2) + (GetRandomControl() % factor) * phd_cos(angle);
spark->y += (GetRandomControl() % factor) * phd_sin(angle) >> W2V_SHIFT; spark->y += (GetRandomControl() % factor) * phd_sin(angle);
spark->xVel = 0; spark->xVel = 0;
spark->zVel = 16 * intensity * ((GetRandomControl() & 0x1F) + 224); spark->zVel = 16 * intensity * ((GetRandomControl() & 0x1F) + 224);
} }
@ -104,8 +104,8 @@ static void VentilatorEffect(BOUNDING_BOX* bounds, int intensity, short rot, int
else else
spark->x = bounds->X1; spark->x = bounds->X1;
spark->y += (GetRandomControl() % factor) * phd_sin(angle) >> W2V_SHIFT; spark->y += (GetRandomControl() % factor) * phd_sin(angle);
spark->z = ((bounds->Z1 + bounds->Z2) / 2) + ((GetRandomControl() % factor) * phd_cos(angle) >> W2V_SHIFT); spark->z = ((bounds->Z1 + bounds->Z2) / 2) + (GetRandomControl() % factor) * phd_cos(angle);
spark->zVel = 0; spark->zVel = 0;
spark->xVel = 16 * intensity * ((GetRandomControl() & 0x1F) + 224); spark->xVel = 16 * intensity * ((GetRandomControl() & 0x1F) + 224);
} }