mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Integrate GetWaterSurface(), GetWaterDepth() and GetWaterHeight() into PointCollisionData
This commit is contained in:
parent
2439e7cd46
commit
e3c1ccf5c2
24 changed files with 287 additions and 346 deletions
|
@ -141,7 +141,7 @@ scripts too.</p>
|
|||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" ><a href="#EnableFlyCheat">EnableFlyCheat(enabled)</a></td>
|
||||
<td class="summary">Enable or disable DOZY mode (fly cheat).</td>
|
||||
<td class="summary">Enable or disable the fly cheat.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" ><a href="#EnablePointFilter">EnablePointFilter(enabled)</a></td>
|
||||
|
@ -371,7 +371,7 @@ Must be true or false
|
|||
<strong>EnableHomeLevel(enabled)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Enable or disable Home Level entry in the main menu.
|
||||
Enable or disable Home Level entry in the main menu. ()
|
||||
|
||||
|
||||
|
||||
|
@ -379,7 +379,7 @@ Must be true or false
|
|||
<ul>
|
||||
<li><span class="parameter">enabled</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
true or false.
|
||||
True or false.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
@ -393,7 +393,7 @@ Must be true or false
|
|||
<strong>EnableLoadSave(enabled)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Enable or disable saving and loading of savegames.
|
||||
Enable or disable saving and loading of savegames. ()
|
||||
|
||||
|
||||
|
||||
|
@ -401,7 +401,7 @@ Must be true or false
|
|||
<ul>
|
||||
<li><span class="parameter">enabled</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
true or false.
|
||||
True or false.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
@ -419,8 +419,7 @@ Must be true or false
|
|||
<strong>EnableFlyCheat(enabled)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Enable or disable DOZY mode (fly cheat).
|
||||
Must be true or false
|
||||
Enable or disable the fly cheat. ()
|
||||
|
||||
|
||||
|
||||
|
@ -428,7 +427,7 @@ Must be true or false
|
|||
<ul>
|
||||
<li><span class="parameter">enabled</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
true or false
|
||||
True or false.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -497,13 +497,11 @@ void LaraSurfaceCollision(ItemInfo* item, CollisionInfo* coll)
|
|||
}
|
||||
|
||||
auto pointColl = GetPointCollision(*item);
|
||||
int waterHeight = GetWaterHeight(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, item->RoomNumber);
|
||||
|
||||
if ((pointColl.GetFloorHeight() - item->Pose.Position.y) < SWIM_WATER_DEPTH)
|
||||
{
|
||||
TestPlayerWaterStepOut(item, coll);
|
||||
}
|
||||
else if ((waterHeight - item->Pose.Position.y) <= -LARA_HEADROOM)
|
||||
else if ((pointColl.GetWaterTopHeight() - item->Pose.Position.y) <= -LARA_HEADROOM)
|
||||
{
|
||||
SetLaraSwimDiveAnimation(item);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "Game/animation.h"
|
||||
#include "Game/camera.h"
|
||||
#include "Game/collision/Point.h"
|
||||
#include "Game/control/control.h"
|
||||
#include "Game/items.h"
|
||||
#include "Game/Lara/lara_collide.h"
|
||||
|
@ -14,6 +15,7 @@
|
|||
#include "Specific/level.h"
|
||||
#include "Specific/Input/Input.h"
|
||||
|
||||
using namespace TEN::Collision::Point;
|
||||
using namespace TEN::Input;
|
||||
|
||||
// -----------------------------
|
||||
|
@ -187,7 +189,7 @@ void lara_col_underwater_death(ItemInfo* item, CollisionInfo* coll)
|
|||
item->HitPoints = -1;
|
||||
lara->Control.HandStatus = HandStatus::Busy;
|
||||
|
||||
int waterHeight = GetWaterHeight(item);
|
||||
int waterHeight = GetPointCollision(*item).GetWaterTopHeight();
|
||||
if (waterHeight < (item->Pose.Position.y - (CLICK(0.4f) - 2)) &&
|
||||
waterHeight != NO_HEIGHT)
|
||||
{
|
||||
|
|
|
@ -1087,15 +1087,13 @@ void TestLaraWaterDepth(ItemInfo* item, CollisionInfo* coll)
|
|||
auto& player = GetLaraInfo(*item);
|
||||
|
||||
auto pointColl = GetPointCollision(*item);
|
||||
int waterDepth = GetWaterDepth(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, pointColl.GetRoomNumber());
|
||||
|
||||
if (waterDepth == NO_HEIGHT)
|
||||
if (pointColl.GetWaterBottomHeight() == NO_HEIGHT)
|
||||
{
|
||||
item->Animation.Velocity.y = 0.0f;
|
||||
item->Pose.Position = coll->Setup.PrevPosition;
|
||||
}
|
||||
|
||||
else if (waterDepth <= (LARA_HEIGHT - (LARA_HEADROOM / 2)))
|
||||
else if (pointColl.GetWaterBottomHeight() <= (LARA_HEIGHT - (LARA_HEADROOM / 2)))
|
||||
{
|
||||
SetAnimation(item, LA_UNDERWATER_TO_STAND);
|
||||
ResetPlayerLean(item);
|
||||
|
|
|
@ -177,9 +177,24 @@ namespace TEN::Collision::Point
|
|||
if (_waterSurfaceHeight.has_value())
|
||||
return *_waterSurfaceHeight;
|
||||
|
||||
// Set water surface height. TODO: Calculate here.
|
||||
_waterSurfaceHeight = GetWaterSurface(_position.x, _position.y, _position.z, _roomNumber);
|
||||
auto* room = &g_Level.Rooms[_roomNumber];
|
||||
const auto* sector = Room::GetSector(room, _position.x - room->Position.x, _position.z - room->Position.z);
|
||||
|
||||
// Set water surface height.
|
||||
bool isBelow = !TestEnvironment(ENV_FLAG_WATER, room);
|
||||
while (sector->GetNextRoomNumber(_position, isBelow).has_value())
|
||||
{
|
||||
room = &g_Level.Rooms[sector->GetNextRoomNumber(_position, isBelow).value_or(sector->RoomNumber)];
|
||||
if (isBelow == TestEnvironment(ENV_FLAG_WATER, room))
|
||||
{
|
||||
_waterSurfaceHeight = sector->GetSurfaceHeight(_position.x, _position.z, isBelow);
|
||||
return *_waterSurfaceHeight;
|
||||
}
|
||||
|
||||
sector = Room::GetSector(room, _position.x - room->Position.x, _position.z - room->Position.z);
|
||||
}
|
||||
|
||||
_waterSurfaceHeight = NO_HEIGHT;
|
||||
return *_waterSurfaceHeight;
|
||||
}
|
||||
|
||||
|
@ -188,10 +203,100 @@ namespace TEN::Collision::Point
|
|||
if (_waterBottomHeight.has_value())
|
||||
return *_waterBottomHeight;
|
||||
|
||||
// Set water bottom height. TODO: Calculate here.
|
||||
_waterBottomHeight = GetWaterDepth(_position.x, _position.y, _position.z, _roomNumber);
|
||||
FloorInfo* sector = nullptr;
|
||||
auto* room = &g_Level.Rooms[_roomNumber];
|
||||
short roomNumber = _roomNumber;
|
||||
|
||||
return *_waterBottomHeight;
|
||||
int adjoiningRoomNumber = NO_VALUE;
|
||||
do
|
||||
{
|
||||
int x = (_position.x - room->Position.x) / BLOCK(1);
|
||||
int z = (_position.z - room->Position.z) / BLOCK(1);
|
||||
|
||||
if (z <= 0)
|
||||
{
|
||||
z = 0;
|
||||
if (x < 1)
|
||||
{
|
||||
x = 1;
|
||||
}
|
||||
else if (x > (room->XSize - 2))
|
||||
{
|
||||
x = room->XSize - 2;
|
||||
}
|
||||
}
|
||||
else if (z >= (room->ZSize - 1))
|
||||
{
|
||||
z = room->ZSize - 1;
|
||||
if (x < 1)
|
||||
{
|
||||
x = 1;
|
||||
}
|
||||
else if (x > (room->XSize - 2))
|
||||
{
|
||||
x = room->XSize - 2;
|
||||
}
|
||||
}
|
||||
else if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
else if (x >= room->XSize)
|
||||
{
|
||||
x = room->XSize - 1;
|
||||
}
|
||||
|
||||
sector = &room->Sectors[z + (x * room->ZSize)];
|
||||
adjoiningRoomNumber = sector->SidePortalRoomNumber;
|
||||
if (adjoiningRoomNumber != NO_VALUE)
|
||||
{
|
||||
roomNumber = adjoiningRoomNumber;
|
||||
room = &g_Level.Rooms[adjoiningRoomNumber];
|
||||
}
|
||||
}
|
||||
while (adjoiningRoomNumber != NO_VALUE);
|
||||
|
||||
// Set water bottom height.
|
||||
if (TestEnvironment(ENV_FLAG_WATER, room) || TestEnvironment(ENV_FLAG_SWAMP, room))
|
||||
{
|
||||
while (sector->GetNextRoomNumber(_position, false).value_or(NO_VALUE) != NO_VALUE)
|
||||
{
|
||||
room = &g_Level.Rooms[sector->GetNextRoomNumber(_position, false).value_or(sector->RoomNumber)];
|
||||
if (!TestEnvironment(ENV_FLAG_WATER, room) && !TestEnvironment(ENV_FLAG_SWAMP, room))
|
||||
{
|
||||
int waterHeight = sector->GetSurfaceHeight(_position.x, _position.z, false);
|
||||
int floorHeight = GetPointCollision(_position, sector->RoomNumber).GetBottomSector().GetSurfaceHeight(_position.x, _position.z, true);
|
||||
|
||||
_waterBottomHeight = floorHeight - waterHeight;
|
||||
return *_waterBottomHeight;
|
||||
}
|
||||
|
||||
sector = Room::GetSector(room, _position.x - room->Position.x, _position.z - room->Position.z);
|
||||
}
|
||||
|
||||
_waterBottomHeight = DEEP_WATER;
|
||||
return *_waterBottomHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (sector->GetNextRoomNumber(_position, true).value_or(NO_VALUE) != NO_VALUE)
|
||||
{
|
||||
room = &g_Level.Rooms[sector->GetNextRoomNumber(_position, true).value_or(sector->RoomNumber)];
|
||||
if (TestEnvironment(ENV_FLAG_WATER, room) || TestEnvironment(ENV_FLAG_SWAMP, room))
|
||||
{
|
||||
int waterHeight = sector->GetSurfaceHeight(_position.x, _position.z, true);
|
||||
sector = GetFloor(_position.x, _position.y, _position.z, &roomNumber);
|
||||
|
||||
_waterBottomHeight = GetPointCollision(_position, sector->RoomNumber).GetFloorHeight() - waterHeight;
|
||||
return *_waterBottomHeight;
|
||||
}
|
||||
|
||||
sector = Room::GetSector(room, _position.x - room->Position.x, _position.z - room->Position.z);
|
||||
}
|
||||
|
||||
_waterBottomHeight = NO_HEIGHT;
|
||||
return *_waterBottomHeight;
|
||||
}
|
||||
}
|
||||
|
||||
int PointCollisionData::GetWaterTopHeight()
|
||||
|
@ -199,9 +304,96 @@ namespace TEN::Collision::Point
|
|||
if (_waterTopHeight.has_value())
|
||||
return *_waterTopHeight;
|
||||
|
||||
// Set water top height. TODO: Calculate here.
|
||||
_waterTopHeight = GetWaterHeight(_position.x, _position.y, _position.z, _roomNumber);
|
||||
FloorInfo* sector = nullptr;
|
||||
auto* room = &g_Level.Rooms[_roomNumber];
|
||||
int roomNumber = _roomNumber;
|
||||
|
||||
int adjoiningRoomNumber = NO_VALUE;
|
||||
do
|
||||
{
|
||||
int x = (_position.x - room->Position.x) / BLOCK(1);
|
||||
int z = (_position.z - room->Position.z) / BLOCK(1);
|
||||
|
||||
if (z <= 0)
|
||||
{
|
||||
z = 0;
|
||||
if (x < 1)
|
||||
{
|
||||
x = 1;
|
||||
}
|
||||
else if (x > (room->XSize - 2))
|
||||
{
|
||||
x = room->XSize - 2;
|
||||
}
|
||||
}
|
||||
else if (z >= (room->ZSize - 1))
|
||||
{
|
||||
z = room->ZSize - 1;
|
||||
if (x < 1)
|
||||
{
|
||||
x = 1;
|
||||
}
|
||||
else if (x > (room->XSize - 2))
|
||||
{
|
||||
x = room->XSize - 2;
|
||||
}
|
||||
}
|
||||
else if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
else if (x >= room->XSize)
|
||||
{
|
||||
x = room->XSize - 1;
|
||||
}
|
||||
|
||||
sector = &room->Sectors[z + (x * room->ZSize)];
|
||||
adjoiningRoomNumber = sector->SidePortalRoomNumber;
|
||||
|
||||
if (adjoiningRoomNumber != NO_VALUE)
|
||||
{
|
||||
roomNumber = adjoiningRoomNumber;
|
||||
room = &g_Level.Rooms[adjoiningRoomNumber];
|
||||
}
|
||||
}
|
||||
while (adjoiningRoomNumber != NO_VALUE);
|
||||
|
||||
if (sector->IsWall(_position.x, _position.z))
|
||||
{
|
||||
_waterTopHeight = NO_HEIGHT;
|
||||
return *_waterTopHeight;
|
||||
}
|
||||
|
||||
if (TestEnvironment(ENV_FLAG_WATER, room) || TestEnvironment(ENV_FLAG_SWAMP, room))
|
||||
{
|
||||
while (sector->GetNextRoomNumber(_position, false).has_value())
|
||||
{
|
||||
room = &g_Level.Rooms[sector->GetNextRoomNumber(_position, false).value_or(sector->RoomNumber)];
|
||||
if (!TestEnvironment(ENV_FLAG_WATER, room) && !TestEnvironment(ENV_FLAG_SWAMP, room))
|
||||
break;
|
||||
|
||||
sector = Room::GetSector(room, _position.x - room->Position.x, _position.z - room->Position.z);
|
||||
}
|
||||
|
||||
_waterTopHeight = sector->GetSurfaceHeight(_position, false);
|
||||
return *_waterTopHeight;
|
||||
}
|
||||
else if (sector->GetNextRoomNumber(_position, true).has_value())
|
||||
{
|
||||
while (sector->GetNextRoomNumber(_position, true).has_value())
|
||||
{
|
||||
room = &g_Level.Rooms[sector->GetNextRoomNumber(_position, true).value_or(sector->RoomNumber)];
|
||||
if (TestEnvironment(ENV_FLAG_WATER, room) || TestEnvironment(ENV_FLAG_SWAMP, room))
|
||||
break;
|
||||
|
||||
sector = Room::GetSector(room, _position.x - room->Position.x, _position.z - room->Position.z);
|
||||
}
|
||||
|
||||
_waterTopHeight = sector->GetSurfaceHeight(_position, true);
|
||||
return *_waterTopHeight;
|
||||
}
|
||||
|
||||
_waterTopHeight = NO_HEIGHT;
|
||||
return *_waterTopHeight;
|
||||
}
|
||||
|
||||
|
|
|
@ -1081,246 +1081,6 @@ int GetDistanceToFloor(int itemNumber, bool precise)
|
|||
return (minHeight + item.Pose.Position.y - height);
|
||||
}
|
||||
|
||||
int GetWaterSurface(int x, int y, int z, short roomNumber)
|
||||
{
|
||||
auto* room = &g_Level.Rooms[roomNumber];
|
||||
auto* sector = GetSector(room, x - room->Position.x, z - room->Position.z);
|
||||
|
||||
if (TestEnvironment(ENV_FLAG_WATER, room))
|
||||
{
|
||||
while (sector->GetNextRoomNumber(Vector3i(x, y, z), false).has_value())
|
||||
{
|
||||
room = &g_Level.Rooms[sector->GetNextRoomNumber(Vector3i(x, y, z), false).value_or(sector->RoomNumber)];
|
||||
if (!TestEnvironment(ENV_FLAG_WATER, room))
|
||||
return (sector->GetSurfaceHeight(x, z, false));
|
||||
|
||||
sector = GetSector(room, x - room->Position.x, z - room->Position.z);
|
||||
}
|
||||
|
||||
return NO_HEIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (sector->GetNextRoomNumber(Vector3i(x, y, z), true).has_value())
|
||||
{
|
||||
room = &g_Level.Rooms[sector->GetNextRoomNumber(Vector3i(x, y, z), true).value_or(sector->RoomNumber)];
|
||||
if (TestEnvironment(ENV_FLAG_WATER, room))
|
||||
return (sector->GetSurfaceHeight(x, z, true));
|
||||
|
||||
sector = GetSector(room, x - room->Position.x, z - room->Position.z);
|
||||
}
|
||||
}
|
||||
|
||||
return NO_HEIGHT;
|
||||
}
|
||||
|
||||
int GetWaterSurface(ItemInfo* item)
|
||||
{
|
||||
return GetWaterSurface(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, item->RoomNumber);
|
||||
}
|
||||
|
||||
int GetWaterDepth(int x, int y, int z, short roomNumber)
|
||||
{
|
||||
FloorInfo* sector = nullptr;
|
||||
auto* room = &g_Level.Rooms[roomNumber];
|
||||
|
||||
int adjoiningRoomNumber = NO_VALUE;
|
||||
do
|
||||
{
|
||||
int xFloor = (x - room->Position.x) / BLOCK(1);
|
||||
int zFloor = (z - room->Position.z) / BLOCK(1);
|
||||
|
||||
if (zFloor <= 0)
|
||||
{
|
||||
zFloor = 0;
|
||||
if (xFloor < 1)
|
||||
{
|
||||
xFloor = 1;
|
||||
}
|
||||
else if (xFloor > (room->XSize - 2))
|
||||
{
|
||||
xFloor = room->XSize - 2;
|
||||
}
|
||||
}
|
||||
else if (zFloor >= (room->ZSize - 1))
|
||||
{
|
||||
zFloor = room->ZSize - 1;
|
||||
if (xFloor < 1)
|
||||
{
|
||||
xFloor = 1;
|
||||
}
|
||||
else if (xFloor > (room->XSize - 2))
|
||||
{
|
||||
xFloor = room->XSize - 2;
|
||||
}
|
||||
}
|
||||
else if (xFloor < 0)
|
||||
{
|
||||
xFloor = 0;
|
||||
}
|
||||
else if (xFloor >= room->XSize)
|
||||
{
|
||||
xFloor = room->XSize - 1;
|
||||
}
|
||||
|
||||
sector = &room->Sectors[zFloor + (xFloor * room->ZSize)];
|
||||
adjoiningRoomNumber = sector->SidePortalRoomNumber;
|
||||
if (adjoiningRoomNumber != NO_VALUE)
|
||||
{
|
||||
roomNumber = adjoiningRoomNumber;
|
||||
room = &g_Level.Rooms[adjoiningRoomNumber];
|
||||
}
|
||||
}
|
||||
while (adjoiningRoomNumber != NO_VALUE);
|
||||
|
||||
if (TestEnvironment(ENV_FLAG_WATER, room) ||
|
||||
TestEnvironment(ENV_FLAG_SWAMP, room))
|
||||
{
|
||||
while (sector->GetNextRoomNumber(Vector3i(x, y, z), false).value_or(NO_VALUE) != NO_VALUE)
|
||||
{
|
||||
room = &g_Level.Rooms[sector->GetNextRoomNumber(Vector3i(x, y, z), false).value_or(sector->RoomNumber)];
|
||||
|
||||
if (!TestEnvironment(ENV_FLAG_WATER, room) &&
|
||||
!TestEnvironment(ENV_FLAG_SWAMP, room))
|
||||
{
|
||||
int waterHeight = sector->GetSurfaceHeight(x, z, false);
|
||||
int floorHeight = GetPointCollision(Vector3i(x, y, z), sector->RoomNumber).GetBottomSector().GetSurfaceHeight(x, z, true);
|
||||
return (floorHeight - waterHeight);
|
||||
}
|
||||
|
||||
sector = GetSector(room, x - room->Position.x, z - room->Position.z);
|
||||
}
|
||||
|
||||
return DEEP_WATER;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (sector->GetNextRoomNumber(Vector3i(x, y, z), true).value_or(NO_VALUE) != NO_VALUE)
|
||||
{
|
||||
room = &g_Level.Rooms[sector->GetNextRoomNumber(Vector3i(x, y, z), true).value_or(sector->RoomNumber)];
|
||||
|
||||
if (TestEnvironment(ENV_FLAG_WATER, room) ||
|
||||
TestEnvironment(ENV_FLAG_SWAMP, room))
|
||||
{
|
||||
int waterHeight = sector->GetSurfaceHeight(x, z, true);
|
||||
sector = GetFloor(x, y, z, &roomNumber);
|
||||
return (GetFloorHeight(sector, x, y, z) - waterHeight);
|
||||
}
|
||||
|
||||
sector = GetSector(room, x - room->Position.x, z - room->Position.z);
|
||||
}
|
||||
|
||||
return NO_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
int GetWaterDepth(ItemInfo* item)
|
||||
{
|
||||
return GetWaterDepth(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, item->RoomNumber);
|
||||
}
|
||||
|
||||
int GetWaterHeight(int x, int y, int z, short roomNumber)
|
||||
{
|
||||
FloorInfo* sector = nullptr;
|
||||
auto* room = &g_Level.Rooms[roomNumber];
|
||||
|
||||
int adjoiningRoomNumber = NO_VALUE;
|
||||
do
|
||||
{
|
||||
int xBlock = (x - room->Position.x) / BLOCK(1);
|
||||
int zBlock = (z - room->Position.z) / BLOCK(1);
|
||||
|
||||
if (zBlock <= 0)
|
||||
{
|
||||
zBlock = 0;
|
||||
if (xBlock < 1)
|
||||
{
|
||||
xBlock = 1;
|
||||
}
|
||||
else if (xBlock > (room->XSize - 2))
|
||||
{
|
||||
xBlock = room->XSize - 2;
|
||||
}
|
||||
}
|
||||
else if (zBlock >= (room->ZSize - 1))
|
||||
{
|
||||
zBlock = room->ZSize - 1;
|
||||
if (xBlock < 1)
|
||||
{
|
||||
xBlock = 1;
|
||||
}
|
||||
else if (xBlock > (room->XSize - 2))
|
||||
{
|
||||
xBlock = room->XSize - 2;
|
||||
}
|
||||
}
|
||||
else if (xBlock < 0)
|
||||
{
|
||||
xBlock = 0;
|
||||
}
|
||||
else if (xBlock >= room->XSize)
|
||||
{
|
||||
xBlock = room->XSize - 1;
|
||||
}
|
||||
|
||||
sector = &room->Sectors[zBlock + (xBlock * room->ZSize)];
|
||||
adjoiningRoomNumber = sector->SidePortalRoomNumber;
|
||||
|
||||
if (adjoiningRoomNumber != NO_VALUE)
|
||||
{
|
||||
roomNumber = adjoiningRoomNumber;
|
||||
room = &g_Level.Rooms[adjoiningRoomNumber];
|
||||
}
|
||||
}
|
||||
while (adjoiningRoomNumber != NO_VALUE);
|
||||
|
||||
if (sector->IsWall(x, z))
|
||||
return NO_HEIGHT;
|
||||
|
||||
if (TestEnvironment(ENV_FLAG_WATER, room) ||
|
||||
TestEnvironment(ENV_FLAG_SWAMP, room))
|
||||
{
|
||||
while (sector->GetNextRoomNumber(Vector3i(x, y, z), false).has_value())
|
||||
{
|
||||
auto* room = &g_Level.Rooms[sector->GetNextRoomNumber(Vector3i(x, y, z), false).value_or(sector->RoomNumber)];
|
||||
|
||||
if (!TestEnvironment(ENV_FLAG_WATER, room) &&
|
||||
!TestEnvironment(ENV_FLAG_SWAMP, room))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
sector = GetSector(room, x - room->Position.x, z - room->Position.z);
|
||||
}
|
||||
|
||||
return sector->GetSurfaceHeight(Vector3i(x, y, z), false);
|
||||
}
|
||||
else if (sector->GetNextRoomNumber(Vector3i(x, y, z), true).has_value())
|
||||
{
|
||||
while (sector->GetNextRoomNumber(Vector3i(x, y, z), true).has_value())
|
||||
{
|
||||
auto* room2 = &g_Level.Rooms[sector->GetNextRoomNumber(Vector3i(x, y, z), true).value_or(sector->RoomNumber)];
|
||||
|
||||
if (TestEnvironment(ENV_FLAG_WATER, room2) ||
|
||||
TestEnvironment(ENV_FLAG_SWAMP, room2))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
sector = GetSector(room2, x - room2->Position.x, z - room2->Position.z);
|
||||
}
|
||||
|
||||
return sector->GetSurfaceHeight(Vector3i(x, y, z), true);
|
||||
}
|
||||
|
||||
return NO_HEIGHT;
|
||||
}
|
||||
|
||||
int GetWaterHeight(ItemInfo* item)
|
||||
{
|
||||
return GetWaterHeight(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, item->RoomNumber);
|
||||
}
|
||||
|
||||
bool TestEnvironment(RoomEnvFlags environmentType, int x, int y, int z, int roomNumber)
|
||||
{
|
||||
return TestEnvironment(environmentType, GetPointCollision(Vector3i(x, y, z), roomNumber).GetRoomNumber());
|
||||
|
@ -1341,7 +1101,7 @@ bool TestEnvironment(RoomEnvFlags environmentType, int roomNumber)
|
|||
return TestEnvironment(environmentType, &g_Level.Rooms[roomNumber]);
|
||||
}
|
||||
|
||||
bool TestEnvironment(RoomEnvFlags environmentType, ROOM_INFO* room)
|
||||
bool TestEnvironment(RoomEnvFlags environmentType, const ROOM_INFO* room)
|
||||
{
|
||||
return TestEnvironmentFlags(environmentType, room->flags);
|
||||
}
|
||||
|
|
|
@ -137,13 +137,6 @@ int GetFloorHeight(FloorInfo* floor, int x, int y, int z);
|
|||
int GetCeiling(FloorInfo* floor, int x, int y, int z);
|
||||
int GetDistanceToFloor(int itemNumber, bool precise = true);
|
||||
|
||||
int GetWaterSurface(int x, int y, int z, short roomNumber);
|
||||
int GetWaterSurface(ItemInfo* item);
|
||||
int GetWaterDepth(int x, int y, int z, short roomNumber);
|
||||
int GetWaterDepth(ItemInfo* item);
|
||||
int GetWaterHeight(int x, int y, int z, short roomNumber);
|
||||
int GetWaterHeight(ItemInfo* item);
|
||||
|
||||
int FindGridShift(int x, int z);
|
||||
void ShiftItem(ItemInfo* item, CollisionInfo* coll);
|
||||
void SnapItemToLedge(ItemInfo* item, CollisionInfo* coll, float offsetMultiplier = 0.0f, bool snapToAngle = true);
|
||||
|
@ -157,5 +150,5 @@ bool TestEnvironment(RoomEnvFlags environmentType, int x, int y, int z, int room
|
|||
bool TestEnvironment(RoomEnvFlags environmentType, const Vector3i& pos, int roomNumber);
|
||||
bool TestEnvironment(RoomEnvFlags environmentType, const ItemInfo* item);
|
||||
bool TestEnvironment(RoomEnvFlags environmentType, int roomNumber);
|
||||
bool TestEnvironment(RoomEnvFlags environmentType, ROOM_INFO* room);
|
||||
bool TestEnvironment(RoomEnvFlags environmentType, const ROOM_INFO* room);
|
||||
bool TestEnvironmentFlags(RoomEnvFlags environmentType, int flags);
|
||||
|
|
|
@ -613,7 +613,7 @@ void CreatureUnderwater(ItemInfo* item, int depth)
|
|||
}
|
||||
else
|
||||
{
|
||||
waterHeight = GetWaterHeight(item);
|
||||
waterHeight = GetPointCollision(*item).GetWaterTopHeight();
|
||||
}
|
||||
|
||||
int y = waterHeight + waterLevel;
|
||||
|
@ -647,7 +647,7 @@ void CreatureFloat(short itemNumber)
|
|||
item->Pose.Orientation.x = 0;
|
||||
|
||||
int y = item->Pose.Position.y;
|
||||
int waterLevel = GetWaterHeight(item);
|
||||
int waterLevel = GetPointCollision(*item).GetWaterTopHeight();
|
||||
if (waterLevel == NO_HEIGHT)
|
||||
return;
|
||||
|
||||
|
@ -794,7 +794,7 @@ void CreatureHealth(ItemInfo* item)
|
|||
TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, &g_Level.Rooms[item->RoomNumber]))
|
||||
{
|
||||
auto bounds = GameBoundingBox(item);
|
||||
auto height = item->Pose.Position.y - GetWaterHeight(item);
|
||||
auto height = item->Pose.Position.y - GetPointCollision(*item).GetWaterTopHeight();
|
||||
|
||||
if (abs(bounds.Y1 + bounds.Y2) < height)
|
||||
DoDamage(item, INT_MAX);
|
||||
|
|
|
@ -130,9 +130,8 @@ namespace TEN::Effects::Drip
|
|||
// Spawn ripple on surface only.
|
||||
if (!TestEnvironment(ENV_FLAG_WATER, prevRoomNumber))
|
||||
{
|
||||
float waterHeight = GetWaterHeight(drip.Position.x, drip.Position.y, drip.Position.z, drip.RoomNumber);
|
||||
SpawnRipple(
|
||||
Vector3(drip.Position.x, waterHeight - RIPPLE_HEIGHT_OFFSET, drip.Position.z),
|
||||
Vector3(drip.Position.x, pointColl.GetWaterTopHeight() - RIPPLE_HEIGHT_OFFSET, drip.Position.z),
|
||||
pointColl.GetRoomNumber(),
|
||||
Random::GenerateFloat(RIPPLE_SIZE_WATER_MIN, RIPPLE_SIZE_WATER_MAX),
|
||||
(int)RippleFlags::SlowFade | (int)RippleFlags::LowOpacity);
|
||||
|
|
|
@ -1308,7 +1308,7 @@ void Splash(ItemInfo* item)
|
|||
if (!TestEnvironment(ENV_FLAG_WATER, probedRoomNumber))
|
||||
return;
|
||||
|
||||
int waterHeight = GetWaterHeight(item);
|
||||
int waterHeight = GetPointCollision(*item).GetWaterTopHeight();
|
||||
|
||||
SplashSetup.x = item->Pose.Position.x;
|
||||
SplashSetup.y = waterHeight - 1;
|
||||
|
@ -1940,7 +1940,7 @@ void ProcessEffects(ItemInfo* item)
|
|||
if (item->Effect.Type != EffectType::Sparks && item->Effect.Type != EffectType::Smoke)
|
||||
{
|
||||
const auto& bounds = GameBoundingBox(item);
|
||||
int waterHeight = GetWaterHeight(item);
|
||||
int waterHeight = GetPointCollision(*item).GetWaterTopHeight();
|
||||
int itemLevel = item->Pose.Position.y + bounds.Y2 - (bounds.GetHeight() / 3);
|
||||
|
||||
if (waterHeight != NO_HEIGHT && itemLevel > waterHeight)
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace TEN::Effects::Hair
|
|||
// Get water height.
|
||||
auto pos = item.Pose.Position + Vector3i(GetWaterProbeOffset(item));
|
||||
int roomNumber = item.RoomNumber;
|
||||
int waterHeight = GetWaterHeight(pos.x, pos.y, pos.z, roomNumber);
|
||||
int waterHeight = GetPointCollision(pos, roomNumber).GetWaterTopHeight();
|
||||
|
||||
// Get collision spheres.
|
||||
auto spheres = GetSpheres(item, isYoung);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "Game/animation.h"
|
||||
#include "Game/collision/collide_room.h"
|
||||
#include "Game/collision/floordata.h"
|
||||
#include "Game/collision/Point.h"
|
||||
#include "Game/effects/effects.h"
|
||||
#include "Game/effects/Bubble.h"
|
||||
#include "Game/effects/debris.h"
|
||||
|
@ -27,6 +28,7 @@ using namespace TEN::Effects::Environment;
|
|||
using namespace TEN::Effects::Ripple;
|
||||
using namespace TEN::Effects::Smoke;
|
||||
using namespace TEN::Collision::Floordata;
|
||||
using namespace TEN::Collision::Point;
|
||||
using namespace TEN::Math;
|
||||
using TEN::Renderer::g_Renderer;
|
||||
|
||||
|
@ -1117,7 +1119,7 @@ void TriggerUnderwaterExplosion(ItemInfo* item, int flag)
|
|||
TriggerExplosionBubbles(x, y, z, item->RoomNumber);
|
||||
TriggerExplosionSparks(x, y, z, 2, -1, 1, item->RoomNumber);
|
||||
|
||||
int waterHeight = GetWaterHeight(x, y, z, item->RoomNumber);
|
||||
int waterHeight = GetPointCollision(Vector3i(x, y, z), item->RoomNumber).GetWaterTopHeight();
|
||||
if (waterHeight != NO_HEIGHT)
|
||||
SomeSparkEffect(x, waterHeight, z, 8);
|
||||
}
|
||||
|
@ -1129,7 +1131,7 @@ void TriggerUnderwaterExplosion(ItemInfo* item, int flag)
|
|||
for (int i = 0; i < 3; i++)
|
||||
TriggerExplosionSparks(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, 2, -1, 1, item->RoomNumber);
|
||||
|
||||
int waterHeight = GetWaterHeight(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, item->RoomNumber);
|
||||
int waterHeight = GetPointCollision(*item).GetWaterTopHeight();
|
||||
if (waterHeight != NO_HEIGHT)
|
||||
{
|
||||
int dy = item->Pose.Position.y - waterHeight;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "Objects/TR1/Entity/tr1_big_rat.h"
|
||||
|
||||
#include "Game/collision/collide_room.h"
|
||||
#include "Game/collision/Point.h"
|
||||
#include "Game/control/box.h"
|
||||
#include "Game/control/control.h"
|
||||
#include "Game/effects/effects.h"
|
||||
|
@ -13,6 +14,7 @@
|
|||
#include "Math/Math.h"
|
||||
#include "Specific/level.h"
|
||||
|
||||
using namespace TEN::Collision::Point;
|
||||
using namespace TEN::Math;
|
||||
|
||||
namespace TEN::Entities::Creatures::TR1
|
||||
|
@ -83,8 +85,7 @@ namespace TEN::Entities::Creatures::TR1
|
|||
|
||||
bool RatOnWater(ItemInfo* item)
|
||||
{
|
||||
int waterDepth = GetWaterSurface(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, item->RoomNumber);
|
||||
|
||||
int waterDepth = GetPointCollision(*item).GetWaterSurfaceHeight();
|
||||
if (item->IsCreature())
|
||||
{
|
||||
auto& creature = *GetCreatureInfo(item);
|
||||
|
@ -240,7 +241,7 @@ namespace TEN::Entities::Creatures::TR1
|
|||
if (RatOnWater(item))
|
||||
{
|
||||
CreatureUnderwater(item, 0);
|
||||
item->Pose.Position.y = GetWaterHeight(item) - BIG_RAT_WATER_SURFACE_OFFSET;
|
||||
item->Pose.Position.y = GetPointCollision(*item).GetWaterTopHeight() - BIG_RAT_WATER_SURFACE_OFFSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -549,11 +549,11 @@ namespace TEN::Entities::Vehicles
|
|||
SpeedboatDoShift(speedboatItem, &f, &frontOld);
|
||||
}
|
||||
|
||||
auto probe = GetPointCollision(*speedboatItem);
|
||||
auto height = GetWaterHeight(speedboatItem->Pose.Position.x, speedboatItem->Pose.Position.y - 5, speedboatItem->Pose.Position.z, probe.GetRoomNumber());
|
||||
auto pointColl = GetPointCollision(*speedboatItem);
|
||||
auto height = GetPointCollision(Vector3i(speedboatItem->Pose.Position.x, speedboatItem->Pose.Position.y - 5, speedboatItem->Pose.Position.z), pointColl.GetRoomNumber()).GetWaterTopHeight();
|
||||
|
||||
if (height == NO_HEIGHT)
|
||||
height = GetFloorHeight(&probe.GetSector(), speedboatItem->Pose.Position.x, speedboatItem->Pose.Position.y - 5, speedboatItem->Pose.Position.z);
|
||||
height = GetFloorHeight(&pointColl.GetSector(), speedboatItem->Pose.Position.x, speedboatItem->Pose.Position.y - 5, speedboatItem->Pose.Position.z);
|
||||
|
||||
if (height < (speedboatItem->Pose.Position.y - CLICK(0.5f)))
|
||||
SpeedboatDoShift(speedboatItem, (Vector3i*)&speedboatItem->Pose, &old);
|
||||
|
@ -825,7 +825,7 @@ namespace TEN::Entities::Vehicles
|
|||
TestTriggers(speedboatItem, false);
|
||||
}
|
||||
|
||||
auto water = GetWaterHeight(speedboatItem->Pose.Position.x, speedboatItem->Pose.Position.y, speedboatItem->Pose.Position.z, probe.GetRoomNumber());
|
||||
auto water = GetPointCollision(Vector3i(speedboatItem->Pose.Position.x, speedboatItem->Pose.Position.y, speedboatItem->Pose.Position.z), probe.GetRoomNumber()).GetWaterTopHeight();
|
||||
speedboat->Water = water;
|
||||
|
||||
bool noTurn = true;
|
||||
|
@ -968,7 +968,7 @@ namespace TEN::Entities::Vehicles
|
|||
TEN::Effects::TriggerSpeedboatFoam(speedboatItem, Vector3(0.0f, 0.0f, SPEEDBOAT_BACK));
|
||||
}
|
||||
|
||||
int waterHeight = GetWaterHeight(speedboatItem);
|
||||
int waterHeight = GetPointCollision(*speedboatItem).GetWaterTopHeight();
|
||||
SpawnVehicleWake(*speedboatItem, SPEEDBOAT_WAKE_OFFSET, waterHeight);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,6 @@ namespace TEN::Entities::Creatures::TR3
|
|||
|
||||
// Get point collision.
|
||||
auto pointColl = GetPointCollision(pos, item.RoomNumber);
|
||||
int waterHeight = GetWaterHeight(pointColl.GetPosition().x, pointColl.GetPosition().y, pointColl.GetPosition().z, pointColl.GetRoomNumber());
|
||||
|
||||
// 1) Test for water room.
|
||||
if (!TestEnvironment(ENV_FLAG_WATER, pointColl.GetRoomNumber()))
|
||||
|
@ -229,7 +228,7 @@ namespace TEN::Entities::Creatures::TR3
|
|||
|
||||
// 2) Assess point collision.
|
||||
if (pos.y >= (pointColl.GetFloorHeight() - BUFFER) ||
|
||||
pos.y <= (waterHeight + BUFFER) ||
|
||||
pos.y <= (pointColl.GetWaterTopHeight() + BUFFER) ||
|
||||
pointColl.GetSector().IsWall(item.Pose.Position.x + BUFFER, item.Pose.Position.z + BUFFER) ||
|
||||
pointColl.GetSector().IsWall(item.Pose.Position.x - BUFFER, item.Pose.Position.z - BUFFER))
|
||||
{
|
||||
|
@ -380,7 +379,7 @@ namespace TEN::Entities::Creatures::TR3
|
|||
}
|
||||
|
||||
// Clamp position to slightly below water surface.
|
||||
int waterHeight = GetWaterHeight(fish.Position.x, fish.Position.y, fish.Position.z, fish.RoomNumber);
|
||||
int waterHeight = pointColl.GetWaterTopHeight();
|
||||
if (fish.Position.y < (waterHeight + WATER_SURFACE_OFFSET))
|
||||
fish.Position.y = waterHeight + WATER_SURFACE_OFFSET;
|
||||
|
||||
|
|
|
@ -130,11 +130,11 @@ namespace TEN::Entities::Creatures::TR3
|
|||
}
|
||||
else
|
||||
{
|
||||
AI_INFO AI;
|
||||
CreatureAIInfo(item, &AI);
|
||||
AI_INFO ai;
|
||||
CreatureAIInfo(item, &ai);
|
||||
|
||||
GetCreatureMood(item, &AI, false);
|
||||
CreatureMood(item, &AI, false);
|
||||
GetCreatureMood(item, &ai, false);
|
||||
CreatureMood(item, &ai, false);
|
||||
|
||||
bool shoot = false;
|
||||
if (Lara.Control.WaterStatus == WaterStatus::Dry)
|
||||
|
@ -143,23 +143,21 @@ namespace TEN::Entities::Creatures::TR3
|
|||
item->Pose.Position.x,
|
||||
item->Pose.Position.y - CLICK(1),
|
||||
item->Pose.Position.z,
|
||||
item->RoomNumber
|
||||
);
|
||||
item->RoomNumber);
|
||||
auto target = GameVector(
|
||||
LaraItem->Pose.Position.x,
|
||||
LaraItem->Pose.Position.y - (LARA_HEIGHT - 150),
|
||||
LaraItem->Pose.Position.z
|
||||
);
|
||||
LaraItem->Pose.Position.z);
|
||||
|
||||
shoot = LOS(&origin, &target);
|
||||
|
||||
if (shoot)
|
||||
creature->Target = LaraItem->Pose.Position;
|
||||
|
||||
if (AI.angle < -ANGLE(45.0f) || AI.angle > ANGLE(45.0f))
|
||||
if (ai.angle < -ANGLE(45.0f) || ai.angle > ANGLE(45.0f))
|
||||
shoot = false;
|
||||
}
|
||||
else if (AI.angle > -ANGLE(45.0f) && AI.angle < ANGLE(45.0f))
|
||||
else if (ai.angle > -ANGLE(45.0f) && ai.angle < ANGLE(45.0f))
|
||||
{
|
||||
auto origin = GameVector(item->Pose.Position, item->RoomNumber);
|
||||
auto target = GameVector(LaraItem->Pose.Position);
|
||||
|
@ -168,7 +166,7 @@ namespace TEN::Entities::Creatures::TR3
|
|||
}
|
||||
|
||||
angle = CreatureTurn(item, creature->MaxTurn);
|
||||
waterHeight = GetWaterSurface(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, item->RoomNumber) + BLOCK(0.5f);
|
||||
waterHeight = GetPointCollision(*item).GetWaterSurfaceHeight() + BLOCK(0.5f);
|
||||
|
||||
switch (item->Animation.ActiveState)
|
||||
{
|
||||
|
@ -176,7 +174,7 @@ namespace TEN::Entities::Creatures::TR3
|
|||
creature->MaxTurn = SCUBA_DIVER_SWIM_TURN_RATE_MAX;
|
||||
|
||||
if (shoot)
|
||||
neck = -AI.angle;
|
||||
neck = -ai.angle;
|
||||
|
||||
if (creature->Target.y < waterHeight &&
|
||||
item->Pose.Position.y < (waterHeight + creature->LOT.Fly))
|
||||
|
@ -194,7 +192,7 @@ namespace TEN::Entities::Creatures::TR3
|
|||
creature->Flags = 0;
|
||||
|
||||
if (shoot)
|
||||
neck = -AI.angle;
|
||||
neck = -ai.angle;
|
||||
|
||||
if (!shoot || creature->Mood == MoodType::Escape ||
|
||||
(creature->Target.y < waterHeight &&
|
||||
|
@ -209,7 +207,7 @@ namespace TEN::Entities::Creatures::TR3
|
|||
|
||||
case SDIVER_STATE_SWIM_SHOOT:
|
||||
if (shoot)
|
||||
neck = -AI.angle;
|
||||
neck = -ai.angle;
|
||||
|
||||
if (!creature->Flags)
|
||||
{
|
||||
|
@ -224,7 +222,7 @@ namespace TEN::Entities::Creatures::TR3
|
|||
creature->MaxTurn = SCUBA_DIVER_SWIM_TURN_RATE_MAX;
|
||||
|
||||
if (shoot)
|
||||
head = AI.angle;
|
||||
head = ai.angle;
|
||||
|
||||
if (creature->Target.y > waterHeight)
|
||||
item->Animation.TargetState = SDIVER_STATE_SWIM;
|
||||
|
@ -239,7 +237,7 @@ namespace TEN::Entities::Creatures::TR3
|
|||
creature->Flags = 0;
|
||||
|
||||
if (shoot)
|
||||
head = AI.angle;
|
||||
head = ai.angle;
|
||||
|
||||
if (!shoot || creature->Mood == MoodType::Escape || creature->Target.y > waterHeight)
|
||||
item->Animation.TargetState = SDIVER_STATE_TREAD_WATER_IDLE;
|
||||
|
@ -250,7 +248,7 @@ namespace TEN::Entities::Creatures::TR3
|
|||
|
||||
case SDIVER_STATE_TREAD_WATER_SHOOT:
|
||||
if (shoot)
|
||||
head = AI.angle;
|
||||
head = ai.angle;
|
||||
|
||||
if (!creature->Flags)
|
||||
{
|
||||
|
|
|
@ -74,24 +74,24 @@ namespace TEN::Entities::TR3
|
|||
bool isWater = TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, item.RoomNumber);
|
||||
float verticalVelCoeff = isWater ? 81.0f : 1.0f;
|
||||
|
||||
int roomNumber = GetPointCollision(item).GetRoomNumber();
|
||||
if (item.RoomNumber != roomNumber)
|
||||
auto pointColl = GetPointCollision(item);
|
||||
if (item.RoomNumber != pointColl.GetRoomNumber())
|
||||
{
|
||||
if (TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, roomNumber) &&
|
||||
if (TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, pointColl.GetRoomNumber()) &&
|
||||
!TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, item.RoomNumber))
|
||||
{
|
||||
int waterHeight = GetWaterHeight(item.Pose.Position.x, item.Pose.Position.y, item.Pose.Position.z, roomNumber);
|
||||
int waterHeight = pointColl.GetWaterTopHeight();
|
||||
SplashSetup.y = waterHeight - 1;
|
||||
SplashSetup.x = item.Pose.Position.x;
|
||||
SplashSetup.z = item.Pose.Position.z;
|
||||
SplashSetup.splashPower = item.Animation.Velocity.y * 4;
|
||||
SplashSetup.innerRadius = 160.0f;
|
||||
|
||||
SetupSplash(&SplashSetup, roomNumber);
|
||||
SetupSplash(&SplashSetup, pointColl.GetRoomNumber());
|
||||
item.Animation.Velocity.y = 0.0f;
|
||||
}
|
||||
|
||||
ItemNewRoom(itemNumber, roomNumber);
|
||||
ItemNewRoom(itemNumber, pointColl.GetRoomNumber());
|
||||
}
|
||||
|
||||
auto pointColl = GetPointCollision(item);
|
||||
|
|
|
@ -215,7 +215,7 @@ namespace TEN::Entities::Vehicles
|
|||
int z = kayakItem->Pose.Position.z + (zOffset * cosY) - (xOffset * sinY);
|
||||
|
||||
int probedRoomNumber = GetPointCollision(Vector3i(x, kayakItem->Pose.Position.y, z), kayakItem->RoomNumber).GetRoomNumber();
|
||||
int waterHeight = GetWaterHeight(x, kayakItem->Pose.Position.y, z, probedRoomNumber);
|
||||
int waterHeight = GetPointCollision(Vector3i(x, kayakItem->Pose.Position.y, z), probedRoomNumber).GetWaterTopHeight();
|
||||
|
||||
//if (waterHeight != NO_HEIGHT)
|
||||
// SetupRipple(x, kayakItem->Pose.Position.y, z, -2 - (GetRandomControl() & 1), 0, Objects[ID_KAYAK_PADDLE_TRAIL_SPRITE].meshIndex,TO_RAD(kayakItem->Pose.Orientation.y));
|
||||
|
@ -538,7 +538,7 @@ namespace TEN::Entities::Vehicles
|
|||
auto probe = GetPointCollision(*kayakItem);
|
||||
int probedRoomNum = probe.GetRoomNumber();
|
||||
|
||||
height2 = GetWaterHeight(kayakItem->Pose.Position.x, kayakItem->Pose.Position.y, kayakItem->Pose.Position.z, probedRoomNum);
|
||||
height2 = GetPointCollision(kayakItem->Pose.Position, probedRoomNum).GetWaterTopHeight();
|
||||
if (height2 == NO_HEIGHT)
|
||||
height2 = probe.GetFloorHeight();
|
||||
|
||||
|
@ -548,7 +548,7 @@ namespace TEN::Entities::Vehicles
|
|||
probe = GetPointCollision(*kayakItem);
|
||||
probedRoomNum = probe.GetRoomNumber();
|
||||
|
||||
height2 = GetWaterHeight(kayakItem->Pose.Position.x, kayakItem->Pose.Position.y, kayakItem->Pose.Position.z, probedRoomNum);
|
||||
height2 = GetPointCollision(kayakItem->Pose.Position, probedRoomNum).GetWaterTopHeight();
|
||||
if (height2 == NO_HEIGHT)
|
||||
height2 = probe.GetFloorHeight();
|
||||
|
||||
|
@ -1084,7 +1084,7 @@ namespace TEN::Entities::Vehicles
|
|||
TestTriggers(kayakItem, false);
|
||||
|
||||
auto probe = GetPointCollision(*kayakItem);
|
||||
int water = GetWaterHeight(kayakItem->Pose.Position.x, kayakItem->Pose.Position.y, kayakItem->Pose.Position.z, probe.GetRoomNumber());
|
||||
int water = GetPointCollision(kayakItem->Pose.Position, probe.GetRoomNumber()).GetWaterTopHeight();
|
||||
kayak->WaterHeight = water;
|
||||
|
||||
if (kayak->WaterHeight == NO_HEIGHT)
|
||||
|
@ -1131,7 +1131,7 @@ namespace TEN::Entities::Vehicles
|
|||
if (kayak->TrueWater &&
|
||||
(kayakItem->Animation.Velocity.z != 0.0f || lara->Context.WaterCurrentPull != Vector3i::Zero))
|
||||
{
|
||||
int waterHeight = GetWaterHeight(kayakItem);
|
||||
int waterHeight = GetPointCollision(*kayakItem).GetWaterTopHeight();
|
||||
SpawnVehicleWake(*kayakItem, KAYAK_WAKE_OFFSET, waterHeight);
|
||||
}
|
||||
|
||||
|
|
|
@ -423,7 +423,7 @@ namespace TEN::Entities::Vehicles
|
|||
|
||||
short roomNumber = rBoatItem->RoomNumber;
|
||||
auto floor = GetFloor(rBoatItem->Pose.Position.x, rBoatItem->Pose.Position.y, rBoatItem->Pose.Position.z, &roomNumber);
|
||||
int height = GetWaterHeight(rBoatItem->Pose.Position.x, rBoatItem->Pose.Position.y, rBoatItem->Pose.Position.z, roomNumber);
|
||||
int height = GetPointCollision(rBoatItem->Pose.Position, roomNumber).GetWaterTopHeight();
|
||||
|
||||
if (height == NO_HEIGHT)
|
||||
height = GetFloorHeight(floor, rBoatItem->Pose.Position.x, rBoatItem->Pose.Position.y, rBoatItem->Pose.Position.z);
|
||||
|
@ -827,7 +827,7 @@ namespace TEN::Entities::Vehicles
|
|||
}
|
||||
|
||||
auto probe = GetPointCollision(*rBoatItem);
|
||||
int water = GetWaterHeight(rBoatItem->Pose.Position.x, rBoatItem->Pose.Position.y, rBoatItem->Pose.Position.z, probe.GetRoomNumber());
|
||||
int water = GetPointCollision(rBoatItem->Pose.Position, probe.GetRoomNumber()).GetWaterTopHeight();
|
||||
rBoat->Water = water;
|
||||
|
||||
if (lara->Context.Vehicle == itemNumber && laraItem->HitPoints > 0)
|
||||
|
@ -936,7 +936,7 @@ namespace TEN::Entities::Vehicles
|
|||
DoRubberBoatDismount(rBoatItem, laraItem);
|
||||
|
||||
short probedRoomNumber = GetPointCollision(Vector3i(rBoatItem->Pose.Position.x, rBoatItem->Pose.Position.y + 128, rBoatItem->Pose.Position.z), rBoatItem->RoomNumber).GetRoomNumber();
|
||||
height = GetWaterHeight(rBoatItem->Pose.Position.x, rBoatItem->Pose.Position.y + 128, rBoatItem->Pose.Position.z, probedRoomNumber);
|
||||
height = GetPointCollision(Vector3i(rBoatItem->Pose.Position.x, rBoatItem->Pose.Position.y + 128, rBoatItem->Pose.Position.z), probedRoomNumber).GetWaterTopHeight();
|
||||
if (height > rBoatItem->Pose.Position.y + 32 || height == NO_HEIGHT)
|
||||
height = 0;
|
||||
else
|
||||
|
@ -951,7 +951,7 @@ namespace TEN::Entities::Vehicles
|
|||
{
|
||||
TriggerRubberBoatMist(prop.x, prop.y, prop.z, abs(rBoatItem->Animation.Velocity.z), rBoatItem->Pose.Orientation.y + ANGLE(180.0f), 0);
|
||||
|
||||
int waterHeight = GetWaterHeight(rBoatItem);
|
||||
int waterHeight = GetPointCollision(*rBoatItem).GetWaterTopHeight();
|
||||
SpawnVehicleWake(*rBoatItem, RBOAT_WAKE_OFFSET, waterHeight);
|
||||
|
||||
if ((GetRandomControl() & 1) == 0)
|
||||
|
|
|
@ -731,8 +731,9 @@ namespace TEN::Entities::Vehicles
|
|||
UPV->Flags &= ~UPV_FLAG_CONTROL;
|
||||
int waterDepth, waterHeight, heightFromWater;
|
||||
|
||||
waterDepth = GetWaterSurface(laraItem);
|
||||
waterHeight = GetWaterHeight(laraItem);
|
||||
auto pointColl = GetPointCollision(*laraItem);
|
||||
waterDepth = pointColl.GetWaterSurfaceHeight();
|
||||
waterHeight = pointColl.GetWaterTopHeight();
|
||||
|
||||
if (waterHeight != NO_HEIGHT)
|
||||
heightFromWater = laraItem->Pose.Position.y - waterHeight;
|
||||
|
@ -871,8 +872,9 @@ namespace TEN::Entities::Vehicles
|
|||
TranslateItem(UPVItem, UPVItem->Pose.Orientation, UPVItem->Animation.Velocity.z);
|
||||
}
|
||||
|
||||
int newHeight = GetPointCollision(*UPVItem).GetFloorHeight();
|
||||
int waterHeight = GetWaterHeight(UPVItem);
|
||||
auto pointColl = GetPointCollision(*UPVItem);
|
||||
int newHeight = pointColl.GetFloorHeight();
|
||||
int waterHeight = pointColl.GetWaterTopHeight();
|
||||
|
||||
if ((newHeight - waterHeight) < UPV_HEIGHT || (newHeight < UPVItem->Pose.Position.y - UPV_HEIGHT / 2) ||
|
||||
(newHeight == NO_HEIGHT) || (waterHeight == NO_HEIGHT))
|
||||
|
@ -943,7 +945,7 @@ namespace TEN::Entities::Vehicles
|
|||
|
||||
if (UPV->Velocity || IsDirectionalActionHeld())
|
||||
{
|
||||
waterHeight = GetWaterHeight(UPVItem);
|
||||
waterHeight = GetPointCollision(*UPVItem).GetWaterTopHeight();
|
||||
SpawnVehicleWake(*UPVItem, UPV_WAKE_OFFSET, waterHeight, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "Game/animation.h"
|
||||
#include "Game/collision/collide_room.h"
|
||||
#include "Game/collision/Point.h"
|
||||
#include "Game/control/box.h"
|
||||
#include "Game/control/control.h"
|
||||
#include "Game/effects/effects.h"
|
||||
|
@ -15,6 +16,7 @@
|
|||
#include "Math/Math.h"
|
||||
#include "Specific/level.h"
|
||||
|
||||
using namespace TEN::Collision::Point;
|
||||
using namespace TEN::Math;
|
||||
|
||||
namespace TEN::Entities::TR4
|
||||
|
@ -90,7 +92,7 @@ namespace TEN::Entities::TR4
|
|||
{
|
||||
auto* creature = GetCreatureInfo(item);
|
||||
|
||||
int waterDepth = GetWaterSurface(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, item->RoomNumber);
|
||||
int waterDepth = GetPointCollision(*item).GetWaterSurfaceHeight();
|
||||
if (waterDepth != NO_HEIGHT)
|
||||
{
|
||||
creature->LOT.Step = BLOCK(20);
|
||||
|
|
|
@ -209,7 +209,7 @@ void ControlBodyPart(short fxNumber)
|
|||
if (TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, pointColl.GetRoomNumber()) &&
|
||||
!TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, fx->roomNumber))
|
||||
{
|
||||
int waterHeight = GetWaterHeight(fx->pos.Position.x, fx->pos.Position.y, fx->pos.Position.z, pointColl.GetRoomNumber());
|
||||
int waterHeight = GetPointCollision(fx->pos.Position, pointColl.GetRoomNumber()).GetWaterTopHeight();
|
||||
|
||||
SplashSetup.y = waterHeight - 1;
|
||||
SplashSetup.x = fx->pos.Position.x;
|
||||
|
|
|
@ -259,23 +259,22 @@ void RollingBallControl(short itemNumber)
|
|||
}
|
||||
}
|
||||
|
||||
auto roomNumber = GetPointCollision(*item).GetRoomNumber();
|
||||
|
||||
if (item->RoomNumber != roomNumber)
|
||||
auto pointColl = GetPointCollision(*item);
|
||||
if (item->RoomNumber != pointColl.GetRoomNumber())
|
||||
{
|
||||
if (TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, roomNumber) &&
|
||||
if (TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, pointColl.GetRoomNumber()) &&
|
||||
!TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, item->RoomNumber))
|
||||
{
|
||||
int waterHeight = GetWaterHeight(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, roomNumber);
|
||||
int waterHeight = pointColl.GetWaterTopHeight();
|
||||
SplashSetup.y = waterHeight - 1;
|
||||
SplashSetup.x = item->Pose.Position.x;
|
||||
SplashSetup.z = item->Pose.Position.z;
|
||||
SplashSetup.splashPower = item->Animation.Velocity.y * 4;
|
||||
SplashSetup.innerRadius = 160;
|
||||
SetupSplash(&SplashSetup, roomNumber);
|
||||
SetupSplash(&SplashSetup, pointColl.GetRoomNumber());
|
||||
}
|
||||
|
||||
ItemNewRoom(itemNumber, roomNumber);
|
||||
ItemNewRoom(itemNumber, pointColl.GetRoomNumber());
|
||||
}
|
||||
|
||||
if (item->ItemFlags[0] > ROLLING_BALL_MAX_VELOCITY)
|
||||
|
|
|
@ -178,7 +178,7 @@ namespace TEN::Entities::Vehicles
|
|||
*pos = Vector3i(point);
|
||||
|
||||
auto pointColl = GetPointCollision(*pos, vehicleItem->RoomNumber);
|
||||
int height = GetWaterHeight(pos->x, pos->y, pos->z, pointColl.GetRoomNumber());
|
||||
int height = GetPointCollision(Vector3i(pos->x, pos->y, pos->z), pointColl.GetRoomNumber()).GetWaterTopHeight();
|
||||
|
||||
if (height == NO_HEIGHT)
|
||||
{
|
||||
|
@ -218,7 +218,7 @@ namespace TEN::Entities::Vehicles
|
|||
if (TestEnvironment(ENV_FLAG_WATER, vehicleItem) ||
|
||||
TestEnvironment(ENV_FLAG_SWAMP, vehicleItem))
|
||||
{
|
||||
auto waterDepth = (float)GetWaterDepth(vehicleItem);
|
||||
int waterDepth = GetPointCollision(*vehicleItem).GetWaterBottomHeight();
|
||||
|
||||
// HACK: Sometimes quadbike test position may end up under non-portal ceiling block.
|
||||
// GetWaterDepth returns DEEP_WATER constant in that case, which is too large for our needs.
|
||||
|
@ -239,11 +239,8 @@ namespace TEN::Entities::Vehicles
|
|||
|
||||
if (isWater)
|
||||
{
|
||||
int waterHeight = GetWaterHeight(vehicleItem);
|
||||
int waterHeight = GetPointCollision(*vehicleItem).GetWaterTopHeight();
|
||||
SpawnVehicleWake(*vehicleItem, wakeOffset, waterHeight);
|
||||
|
||||
//SpawnStreamer(vehicleItem, -wakeOffset.x, waterHeight / 2, wakeOffset.z, 1, true, 5.0f, 50, 9.0f);
|
||||
//SpawnStreamer(vehicleItem, wakeOffset.x, waterHeight / 2, wakeOffset.z, 2, true, 5.0f, 50, 9.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,7 +252,7 @@ namespace TEN::Entities::Vehicles
|
|||
}
|
||||
else
|
||||
{
|
||||
int waterHeight = vehicleItem->Pose.Position.y - GetWaterHeight(vehicleItem);
|
||||
int waterHeight = vehicleItem->Pose.Position.y - GetPointCollision(*vehicleItem).GetWaterTopHeight();
|
||||
|
||||
if (waterDepth > VEHICLE_WATER_HEIGHT_MAX && waterHeight > VEHICLE_WATER_HEIGHT_MAX)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue