Add GetWaterSurface(), GetWaterDepth() and GetWaterHeight() overrides; cleanup

This commit is contained in:
Sezz 2022-02-01 21:46:58 +11:00
parent dc080b8298
commit 9c6003cd39
10 changed files with 70 additions and 63 deletions

View file

@ -450,8 +450,8 @@ void LaraControl(ITEM_INFO* item, COLL_INFO* coll)
bool isWater = TestEnvironment(ENV_FLAG_WATER, item); bool isWater = TestEnvironment(ENV_FLAG_WATER, item);
bool isSwamp = TestEnvironment(ENV_FLAG_SWAMP, item); bool isSwamp = TestEnvironment(ENV_FLAG_SWAMP, item);
int waterDepth = GetWaterDepth(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber); int waterDepth = GetWaterDepth(item);
int waterHeight = GetWaterHeight(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber); int waterHeight = GetWaterHeight(item);
int heightFromWater; int heightFromWater;
if (waterHeight != NO_HEIGHT) if (waterHeight != NO_HEIGHT)
@ -520,7 +520,7 @@ void LaraControl(ITEM_INFO* item, COLL_INFO* coll)
info->waterStatus = LW_WADE; info->waterStatus = LW_WADE;
// Make splash ONLY within this particular threshold before swim depth while airborne (WadeSplash() above interferes otherwise). // Make splash ONLY within this particular threshold before swim depth while airborne (WadeSplash() above interferes otherwise).
if (waterDepth > (SWIM_DEPTH - STEP_SIZE) && if (waterDepth > (SWIM_DEPTH - CLICK(1)) &&
!isSwamp && !isSwamp &&
item->airborne) item->airborne)
{ {
@ -547,13 +547,13 @@ void LaraControl(ITEM_INFO* item, COLL_INFO* coll)
case LW_UNDERWATER: case LW_UNDERWATER:
if (isWater || if (isWater ||
waterDepth == DEEP_WATER || waterDepth == DEEP_WATER ||
abs(heightFromWater) >= STEP_SIZE || abs(heightFromWater) >= CLICK(1) ||
item->animNumber == LA_UNDERWATER_RESURFACE || item->animNumber == LA_UNDERWATER_RESURFACE ||
item->animNumber == LA_ONWATER_DIVE) item->animNumber == LA_ONWATER_DIVE)
{ {
if (!isWater) if (!isWater)
{ {
if (waterDepth == DEEP_WATER || abs(heightFromWater) >= STEP_SIZE) if (waterDepth == DEEP_WATER || abs(heightFromWater) >= CLICK(1))
{ {
SetAnimation(item, LA_FALL_START); SetAnimation(item, LA_FALL_START);
item->speed = item->fallspeed / 4; item->speed = item->fallspeed / 4;
@ -948,7 +948,7 @@ void LaraUnderWater(ITEM_INFO* item, COLL_INFO* coll)
coll->Setup.LowerFloorBound = NO_LOWER_BOUND; coll->Setup.LowerFloorBound = NO_LOWER_BOUND;
coll->Setup.UpperFloorBound = -(LARA_RAD_UNDERWATER + (LARA_RAD_UNDERWATER / 3)); coll->Setup.UpperFloorBound = -(LARA_RAD_UNDERWATER + (LARA_RAD_UNDERWATER / 3));
coll->Setup.LowerCeilingBound = LARA_RAD_UNDERWATER + (LARA_RAD_UNDERWATER / 3); coll->Setup.LowerCeilingBound = LARA_RAD_UNDERWATER + (LARA_RAD_UNDERWATER / 3);
coll->Setup.UpperCeilingBound = MAX_HEIGHT; coll->Setup.UpperCeilingBound = NO_UPPER_BOUND;
coll->Setup.OldPosition.x = item->pos.xPos; coll->Setup.OldPosition.x = item->pos.xPos;
coll->Setup.OldPosition.y = item->pos.yPos; coll->Setup.OldPosition.y = item->pos.yPos;
@ -1057,7 +1057,7 @@ void LaraSurface(ITEM_INFO* item, COLL_INFO* coll)
coll->Setup.LowerFloorBound = NO_LOWER_BOUND; coll->Setup.LowerFloorBound = NO_LOWER_BOUND;
coll->Setup.UpperFloorBound = -CLICK(0.5f); coll->Setup.UpperFloorBound = -CLICK(0.5f);
coll->Setup.LowerCeilingBound = LARA_RAD; coll->Setup.LowerCeilingBound = LARA_RAD;
coll->Setup.UpperCeilingBound = MAX_HEIGHT; coll->Setup.UpperCeilingBound = NO_UPPER_BOUND;
coll->Setup.OldPosition.x = item->pos.xPos; coll->Setup.OldPosition.x = item->pos.xPos;
coll->Setup.OldPosition.y = item->pos.yPos; coll->Setup.OldPosition.y = item->pos.yPos;

View file

@ -108,8 +108,8 @@ void lara_col_crouch_idle(ITEM_INFO* item, COLL_INFO* coll)
item->fallspeed = 0; item->fallspeed = 0;
coll->Setup.Height = LARA_HEIGHT_CRAWL; coll->Setup.Height = LARA_HEIGHT_CRAWL;
coll->Setup.ForwardAngle = item->pos.yRot; coll->Setup.ForwardAngle = item->pos.yRot;
coll->Setup.LowerFloorBound = STEP_SIZE - 1; coll->Setup.LowerFloorBound = CLICK(1) - 1;
coll->Setup.UpperFloorBound = -(STEP_SIZE - 1); coll->Setup.UpperFloorBound = -(CLICK(1) - 1);
coll->Setup.LowerCeilingBound = 0; coll->Setup.LowerCeilingBound = 0;
coll->Setup.FloorSlopeIsWall = true; coll->Setup.FloorSlopeIsWall = true;
coll->Setup.FloorSlopeIsPit = true; coll->Setup.FloorSlopeIsPit = true;
@ -180,8 +180,8 @@ void lara_col_crouch_roll(ITEM_INFO* item, COLL_INFO* coll)
item->airborne = 0; item->airborne = 0;
item->fallspeed = 0; item->fallspeed = 0;
coll->Setup.Height = LARA_HEIGHT_CRAWL; coll->Setup.Height = LARA_HEIGHT_CRAWL;
coll->Setup.LowerFloorBound = STEP_SIZE - 1; coll->Setup.LowerFloorBound = CLICK(1) - 1;
coll->Setup.UpperFloorBound = -(STEP_SIZE - 1); coll->Setup.UpperFloorBound = -(CLICK(1) - 1);
coll->Setup.ForwardAngle = item->pos.yRot; coll->Setup.ForwardAngle = item->pos.yRot;
coll->Setup.LowerCeilingBound = 0; coll->Setup.LowerCeilingBound = 0;
coll->Setup.FloorSlopeIsWall = true; coll->Setup.FloorSlopeIsWall = true;
@ -448,8 +448,8 @@ void lara_col_crawl_idle(ITEM_INFO* item, COLL_INFO* coll)
coll->Setup.ForwardAngle = info->moveAngle; coll->Setup.ForwardAngle = info->moveAngle;
coll->Setup.Radius = LARA_RAD_CRAWL; coll->Setup.Radius = LARA_RAD_CRAWL;
coll->Setup.Height = LARA_HEIGHT_CRAWL; coll->Setup.Height = LARA_HEIGHT_CRAWL;
coll->Setup.LowerFloorBound = STEP_SIZE - 1; coll->Setup.LowerFloorBound = CLICK(1) - 1;
coll->Setup.UpperFloorBound = -(STEP_SIZE - 1); coll->Setup.UpperFloorBound = -(CLICK(1) - 1);
coll->Setup.LowerCeilingBound = LARA_HEIGHT_CRAWL; coll->Setup.LowerCeilingBound = LARA_HEIGHT_CRAWL;
coll->Setup.FloorSlopeIsWall = true; coll->Setup.FloorSlopeIsWall = true;
coll->Setup.FloorSlopeIsPit = true; coll->Setup.FloorSlopeIsPit = true;
@ -547,8 +547,8 @@ void lara_col_crawl_forward(ITEM_INFO* item, COLL_INFO* coll)
item->fallspeed = 0; item->fallspeed = 0;
coll->Setup.Radius = LARA_RAD_CRAWL; coll->Setup.Radius = LARA_RAD_CRAWL;
coll->Setup.Height = LARA_HEIGHT_CRAWL; coll->Setup.Height = LARA_HEIGHT_CRAWL;
coll->Setup.LowerFloorBound = STEP_SIZE - 1; // Offset of 1 is required or Lara will crawl up/down steps. coll->Setup.LowerFloorBound = CLICK(1) - 1; // Offset of 1 is required or Lara will crawl up/down steps.
coll->Setup.UpperFloorBound = -(STEP_SIZE - 1); // TODO: Stepping approach is different from walk/run because crawl step anims do not submerge Lara. Resolve this someday. @Sezz 2021.10.31 coll->Setup.UpperFloorBound = -(CLICK(1) - 1); // TODO: Stepping approach is different from walk/run because crawl step anims do not submerge Lara. Resolve this someday. @Sezz 2021.10.31
coll->Setup.LowerCeilingBound = LARA_HEIGHT_CRAWL; coll->Setup.LowerCeilingBound = LARA_HEIGHT_CRAWL;
coll->Setup.FloorSlopeIsPit = true; coll->Setup.FloorSlopeIsPit = true;
coll->Setup.FloorSlopeIsWall = true; coll->Setup.FloorSlopeIsWall = true;
@ -644,8 +644,8 @@ void lara_col_crawl_back(ITEM_INFO* item, COLL_INFO* coll)
item->fallspeed = 0; item->fallspeed = 0;
coll->Setup.Radius = LARA_RAD_CRAWL; coll->Setup.Radius = LARA_RAD_CRAWL;
coll->Setup.Height = LARA_HEIGHT_CRAWL; coll->Setup.Height = LARA_HEIGHT_CRAWL;
coll->Setup.LowerFloorBound = STEP_SIZE - 1; // Offset of 1 is required or Lara will crawl up/down steps. coll->Setup.LowerFloorBound = CLICK(1) - 1; // Offset of 1 is required or Lara will crawl up/down steps.
coll->Setup.UpperFloorBound = -(STEP_SIZE - 1); coll->Setup.UpperFloorBound = -(CLICK(1) - 1);
coll->Setup.LowerCeilingBound = LARA_HEIGHT_CRAWL; coll->Setup.LowerCeilingBound = LARA_HEIGHT_CRAWL;
coll->Setup.FloorSlopeIsPit = true; coll->Setup.FloorSlopeIsPit = true;
coll->Setup.FloorSlopeIsWall = true; coll->Setup.FloorSlopeIsWall = true;
@ -815,7 +815,7 @@ void lara_col_crawl_to_hang(ITEM_INFO* item, COLL_INFO* coll)
coll->Setup.LowerCeilingBound = BAD_JUMP_CEILING; coll->Setup.LowerCeilingBound = BAD_JUMP_CEILING;
coll->Setup.ForwardAngle = info->moveAngle; coll->Setup.ForwardAngle = info->moveAngle;
MoveItem(item, item->pos.yRot, -STEP_SIZE); MoveItem(item, item->pos.yRot, -CLICK(1));
GetCollisionInfo(coll, item); GetCollisionInfo(coll, item);
SnapItemToLedge(item, coll); SnapItemToLedge(item, coll);
SetAnimation(item, LA_REACH_TO_HANG, 12); SetAnimation(item, LA_REACH_TO_HANG, 12);

View file

@ -804,10 +804,10 @@ void lara_col_swan_dive(ITEM_INFO* item, COLL_INFO* coll)
SetAnimation(item, LA_SPRINT_TO_CROUCH_LEFT, 10); SetAnimation(item, LA_SPRINT_TO_CROUCH_LEFT, 10);
if (!info->keepLow) // HACK: If Lara landed on the edge, shift forward to avoid standing up or falling out. if (!info->keepLow) // HACK: If Lara landed on the edge, shift forward to avoid standing up or falling out.
MoveItem(item, coll->Setup.ForwardAngle, STEP_SIZE / 2); MoveItem(item, coll->Setup.ForwardAngle, CLICK(0.5f));
} }
else [[likely]] else [[likely]]
SetAnimation(item, LA_SWANDIVE_ROLL, 0); SetAnimation(item, LA_SWANDIVE_ROLL);
item->fallspeed = 0; item->fallspeed = 0;
item->airborne = false; item->airborne = false;

View file

@ -2142,7 +2142,7 @@ bool TestLaraJumpTolerance(ITEM_INFO* item, COLL_INFO* coll, JumpTestSetup testS
if (((probe.Position.Floor - y) >= -STEPUP_HEIGHT || // Within highest floor bound... if (((probe.Position.Floor - y) >= -STEPUP_HEIGHT || // Within highest floor bound...
probe.Position.FloorSlope) && // OR surface is a slope. TODO: May fail when coming to a slope from the side. probe.Position.FloorSlope) && // OR surface is a slope. TODO: May fail when coming to a slope from the side.
((probe.Position.Ceiling - y) < -(coll->Setup.Height + (LARA_HEADROOM * 0.7f)) || // Ceiling height is permissive... ((probe.Position.Ceiling - y) < -(coll->Setup.Height + (LARA_HEADROOM * 0.8f)) || // Ceiling height is permissive...
((probe.Position.Ceiling - y) < -coll->Setup.Height && // OR ceiling is level with Lara's head ((probe.Position.Ceiling - y) < -coll->Setup.Height && // OR ceiling is level with Lara's head
(probe.Position.Floor - y) >= CLICK(0.5f))) && // AND there is a drop below. (probe.Position.Floor - y) >= CLICK(0.5f))) && // AND there is a drop below.
!isWading && // Not wading in water (if applicable). !isWading && // Not wading in water (if applicable).

View file

@ -310,7 +310,7 @@ void CreatureUnderwater(ITEM_INFO* item, int depth)
} }
else else
{ {
wh = GetWaterHeight(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber); wh = GetWaterHeight(item);
} }
int y = wh + waterLevel; int y = wh + waterLevel;
@ -344,7 +344,7 @@ void CreatureFloat(short itemNumber)
item->hitPoints = NOT_TARGETABLE; item->hitPoints = NOT_TARGETABLE;
item->pos.xRot = 0; item->pos.xRot = 0;
waterLevel = GetWaterHeight(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber); waterLevel = GetWaterHeight(item);
y = item->pos.yPos; y = item->pos.yPos;
if (y > waterLevel) if (y > waterLevel)

View file

@ -675,6 +675,11 @@ GAME_STATUS DoLevel(int index, std::string ambient, bool loadFromSavegame)
} }
} }
int GetWaterSurface(ITEM_INFO* item)
{
return GetWaterSurface(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber);
}
int GetWaterSurface(int x, int y, int z, short roomNumber) int GetWaterSurface(int x, int y, int z, short roomNumber)
{ {
ROOM_INFO *room = &g_Level.Rooms[roomNumber]; ROOM_INFO *room = &g_Level.Rooms[roomNumber];
@ -856,6 +861,11 @@ int ExplodeItemNode(ITEM_INFO *item, int Node, int NoXZVel, int bits)
return 0; return 0;
} }
int GetWaterDepth(ITEM_INFO* item)
{
return GetWaterDepth(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber);
}
int GetWaterDepth(int x, int y, int z, short roomNumber) int GetWaterDepth(int x, int y, int z, short roomNumber)
{ {
FLOOR_INFO* floor; FLOOR_INFO* floor;
@ -931,6 +941,11 @@ int GetWaterDepth(int x, int y, int z, short roomNumber)
} }
} }
int GetWaterHeight(ITEM_INFO* item)
{
return GetWaterHeight(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber);
}
int GetWaterHeight(int x, int y, int z, short roomNumber) int GetWaterHeight(int x, int y, int z, short roomNumber)
{ {
ROOM_INFO *r = &g_Level.Rooms[roomNumber]; ROOM_INFO *r = &g_Level.Rooms[roomNumber];

View file

@ -85,8 +85,11 @@ void AlterFloorHeight(ITEM_INFO* item, int height);
int GetFloorHeight(FLOOR_INFO* floor, int x, int y, int z); int GetFloorHeight(FLOOR_INFO* floor, int x, int y, int z);
FLOOR_INFO* GetFloor(int x, int y, int z, short* roomNumber); FLOOR_INFO* GetFloor(int x, int y, int z, short* roomNumber);
int GetCeiling(FLOOR_INFO* floor, int x, int y, int z); int GetCeiling(FLOOR_INFO* floor, int x, int y, int z);
int GetWaterSurface(ITEM_INFO* item);
int GetWaterSurface(int x, int y, int z, short roomNumber); int GetWaterSurface(int x, int y, int z, short roomNumber);
int GetWaterDepth(ITEM_INFO* item);
int GetWaterDepth(int x, int y, int z, short roomNumber); int GetWaterDepth(int x, int y, int z, short roomNumber);
int GetWaterHeight(ITEM_INFO* item);
int GetWaterHeight(int x, int y, int z, short roomNumber); int GetWaterHeight(int x, int y, int z, short roomNumber);
int GetDistanceToFloor(int itemNumber, bool precise = true); int GetDistanceToFloor(int itemNumber, bool precise = true);

View file

@ -930,10 +930,7 @@ void SpeedBoatControl(short itemNum)
int heightFrontLeft = SpeedBoatTestWaterHeight(sBoatItem, BOAT_FRONT, -BOAT_SIDE, &frontLeft); int heightFrontLeft = SpeedBoatTestWaterHeight(sBoatItem, BOAT_FRONT, -BOAT_SIDE, &frontLeft);
int heightFrontRight = SpeedBoatTestWaterHeight(sBoatItem, BOAT_FRONT, BOAT_SIDE, &frontRight); int heightFrontRight = SpeedBoatTestWaterHeight(sBoatItem, BOAT_FRONT, BOAT_SIDE, &frontRight);
auto roomNum = sBoatItem->roomNumber; auto probe = GetCollisionResult(sBoatItem);
auto floor = GetFloor(sBoatItem->pos.xPos, sBoatItem->pos.yPos, sBoatItem->pos.zPos, &roomNum);
auto height = GetFloorHeight(floor, sBoatItem->pos.xPos, sBoatItem->pos.yPos, sBoatItem->pos.zPos);
auto ceiling = GetCeiling(floor, sBoatItem->pos.xPos, sBoatItem->pos.yPos, sBoatItem->pos.zPos);
if (laraInfo->Vehicle == itemNum) if (laraInfo->Vehicle == itemNum)
{ {
@ -941,7 +938,7 @@ void SpeedBoatControl(short itemNum)
TestTriggers(sBoatItem, false); TestTriggers(sBoatItem, false);
} }
auto water = GetWaterHeight(sBoatItem->pos.xPos, sBoatItem->pos.yPos, sBoatItem->pos.zPos, roomNum); auto water = GetWaterHeight(sBoatItem->pos.xPos, sBoatItem->pos.yPos, sBoatItem->pos.zPos, probe.RoomNumber);
sBoatInfo->water = water; sBoatInfo->water = water;
if (laraInfo->Vehicle == itemNum && laraItem->hitPoints > 0) if (laraInfo->Vehicle == itemNum && laraItem->hitPoints > 0)
@ -977,9 +974,9 @@ void SpeedBoatControl(short itemNum)
sBoatInfo->boatTurn = 0; sBoatInfo->boatTurn = 0;
} }
sBoatItem->floor = height - 5; sBoatItem->floor = probe.Position.Floor - 5;
if (sBoatInfo->water == NO_HEIGHT) if (sBoatInfo->water == NO_HEIGHT)
sBoatInfo->water = height; sBoatInfo->water = probe.Position.Floor;
else else
sBoatInfo->water -= 5; sBoatInfo->water -= 5;
@ -990,14 +987,14 @@ void SpeedBoatControl(short itemNum)
if (ofs - sBoatItem->fallspeed > 32 && sBoatItem->fallspeed == 0 && water != NO_HEIGHT) if (ofs - sBoatItem->fallspeed > 32 && sBoatItem->fallspeed == 0 && water != NO_HEIGHT)
SpeedBoatSplash(sBoatItem, ofs - sBoatItem->fallspeed, water); SpeedBoatSplash(sBoatItem, ofs - sBoatItem->fallspeed, water);
height = (frontLeft.y + frontRight.y); probe.Position.Floor = (frontLeft.y + frontRight.y);
if (height < 0) if (probe.Position.Floor < 0)
height = -(abs(height) / 2); probe.Position.Floor = -(abs(probe.Position.Floor) / 2);
else else
height /= 2; probe.Position.Floor /= 2;
short xRot = phd_atan(BOAT_FRONT, sBoatItem->pos.yPos - height); short xRot = phd_atan(BOAT_FRONT, sBoatItem->pos.yPos - probe.Position.Floor);
short zRot = phd_atan(BOAT_SIDE, height - frontLeft.y); short zRot = phd_atan(BOAT_SIDE, probe.Position.Floor - frontLeft.y);
sBoatItem->pos.xRot += ((xRot - sBoatItem->pos.xRot) / 2); sBoatItem->pos.xRot += ((xRot - sBoatItem->pos.xRot) / 2);
sBoatItem->pos.zRot += ((zRot - sBoatItem->pos.zRot) / 2); sBoatItem->pos.zRot += ((zRot - sBoatItem->pos.zRot) / 2);
@ -1011,10 +1008,10 @@ void SpeedBoatControl(short itemNum)
{ {
SpeedBoatAnimation(laraItem, sBoatItem, collide); SpeedBoatAnimation(laraItem, sBoatItem, collide);
if (roomNum != sBoatItem->roomNumber) if (probe.RoomNumber != sBoatItem->roomNumber)
{ {
ItemNewRoom(laraInfo->Vehicle, roomNum); ItemNewRoom(laraInfo->Vehicle, probe.RoomNumber);
ItemNewRoom(laraInfo->itemNumber, roomNum); ItemNewRoom(laraInfo->itemNumber, probe.RoomNumber);
} }
sBoatItem->pos.zRot += sBoatInfo->tiltAngle; sBoatItem->pos.zRot += sBoatInfo->tiltAngle;
@ -1038,8 +1035,8 @@ void SpeedBoatControl(short itemNum)
} }
else else
{ {
if (roomNum != sBoatItem->roomNumber) if (probe.RoomNumber != sBoatItem->roomNumber)
ItemNewRoom(itemNum, roomNum); ItemNewRoom(itemNum, probe.RoomNumber);
sBoatItem->pos.zRot += sBoatInfo->tiltAngle; sBoatItem->pos.zRot += sBoatInfo->tiltAngle;
} }

View file

@ -1306,10 +1306,7 @@ int QuadBikeControl(ITEM_INFO* lara, COLL_INFO* coll)
bool collide = QuadDynamics(lara, quad); bool collide = QuadDynamics(lara, quad);
short roomNumber = quad->roomNumber; auto probe = GetCollisionResult(quad);
FLOOR_INFO* floor = GetFloor(quad->pos.xPos, quad->pos.yPos, quad->pos.zPos, &roomNumber);
auto height = GetFloorHeight(floor, quad->pos.xPos, quad->pos.yPos, quad->pos.zPos);
auto ceiling = GetCeiling(floor, quad->pos.xPos, quad->pos.yPos, quad->pos.zPos);
PHD_VECTOR frontLeft; PHD_VECTOR frontLeft;
PHD_VECTOR frontRight; PHD_VECTOR frontRight;
@ -1342,7 +1339,7 @@ int QuadBikeControl(ITEM_INFO* lara, COLL_INFO* coll)
break; break;
default: default:
drive = QuadUserControl(quad, height, &pitch); drive = QuadUserControl(quad, probe.Position.Floor, &pitch);
break; break;
} }
@ -1367,7 +1364,7 @@ int QuadBikeControl(ITEM_INFO* lara, COLL_INFO* coll)
quadInfo->pitch = 0; quadInfo->pitch = 0;
} }
quad->floor = height; quad->floor = probe.Position.Floor;
rotadd = quadInfo->velocity / 4; rotadd = quadInfo->velocity / 4;
quadInfo->rearRot -= rotadd; quadInfo->rearRot -= rotadd;
@ -1376,29 +1373,24 @@ int QuadBikeControl(ITEM_INFO* lara, COLL_INFO* coll)
quadInfo->leftFallspeed = DoQuadDynamics(floorHeightLeft, quadInfo->leftFallspeed, (int*)&frontLeft.y); quadInfo->leftFallspeed = DoQuadDynamics(floorHeightLeft, quadInfo->leftFallspeed, (int*)&frontLeft.y);
quadInfo->rightFallspeed = DoQuadDynamics(floorHeightRight, quadInfo->rightFallspeed, (int*)&frontRight.y); quadInfo->rightFallspeed = DoQuadDynamics(floorHeightRight, quadInfo->rightFallspeed, (int*)&frontRight.y);
quad->fallspeed = DoQuadDynamics(height, quad->fallspeed, (int*)&quad->pos.yPos); quad->fallspeed = DoQuadDynamics(probe.Position.Floor, quad->fallspeed, (int*)&quad->pos.yPos);
height = (frontLeft.y + frontRight.y) / 2; probe.Position.Floor = (frontLeft.y + frontRight.y) / 2;
xRot = phd_atan(QUAD_FRONT, quad->pos.yPos - height); xRot = phd_atan(QUAD_FRONT, quad->pos.yPos - probe.Position.Floor);
zRot = phd_atan(QUAD_SIDE, height - frontLeft.y); zRot = phd_atan(QUAD_SIDE, probe.Position.Floor - frontLeft.y);
quad->pos.xRot += ((xRot - quad->pos.xRot) / 2); quad->pos.xRot += ((xRot - quad->pos.xRot) / 2);
quad->pos.zRot += ((zRot - quad->pos.zRot) / 2); quad->pos.zRot += ((zRot - quad->pos.zRot) / 2);
if (!(quadInfo->flags & QUAD_FLAG_DEAD)) if (!(quadInfo->flags & QUAD_FLAG_DEAD))
{ {
if (roomNumber != quad->roomNumber) if (probe.RoomNumber != quad->roomNumber)
{ {
ItemNewRoom(laraInfo->Vehicle, roomNumber); ItemNewRoom(laraInfo->Vehicle, probe.RoomNumber);
ItemNewRoom(laraInfo->itemNumber, roomNumber); ItemNewRoom(laraInfo->itemNumber, probe.RoomNumber);
} }
lara->pos.xPos = quad->pos.xPos; lara->pos = quad->pos;
lara->pos.yPos = quad->pos.yPos;
lara->pos.zPos = quad->pos.zPos;
lara->pos.xRot = quad->pos.xRot;
lara->pos.yRot = quad->pos.yRot;
lara->pos.zRot = quad->pos.zRot;
AnimateQuadBike(lara, quad, collide, dead); AnimateQuadBike(lara, quad, collide, dead);
AnimateItem(lara); AnimateItem(lara);

View file

@ -710,8 +710,8 @@ static void UserInput(ITEM_INFO* laraItem, ITEM_INFO* UPVItem)
int waterDepth, waterHeight, heightFromWater; int waterDepth, waterHeight, heightFromWater;
PHD_VECTOR vec = { 0, 0, 0 }; PHD_VECTOR vec = { 0, 0, 0 };
waterDepth = GetWaterSurface(laraItem->pos.xPos, laraItem->pos.yPos, laraItem->pos.zPos, laraItem->roomNumber); waterDepth = GetWaterSurface(laraItem);
waterHeight = GetWaterHeight(laraItem->pos.xPos, laraItem->pos.yPos, laraItem->pos.zPos, laraItem->roomNumber); waterHeight = GetWaterHeight(laraItem);
if (waterHeight != NO_HEIGHT) if (waterHeight != NO_HEIGHT)
heightFromWater = laraItem->pos.yPos - waterHeight; heightFromWater = laraItem->pos.yPos - waterHeight;
@ -936,7 +936,7 @@ bool SubControl(ITEM_INFO* laraItem, COLL_INFO* coll)
} }
int newHeight = GetCollisionResult(UPVItem).Position.Floor; int newHeight = GetCollisionResult(UPVItem).Position.Floor;
int waterHeight = GetWaterHeight(UPVItem->pos.xPos, UPVItem->pos.yPos, UPVItem->pos.zPos, UPVItem->roomNumber); int waterHeight = GetWaterHeight(UPVItem);
if ((newHeight - waterHeight) < SUB_HEIGHT || (newHeight < UPVItem->pos.yPos - SUB_HEIGHT / 2)) if ((newHeight - waterHeight) < SUB_HEIGHT || (newHeight < UPVItem->pos.yPos - SUB_HEIGHT / 2))
{ {