mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-02 17:57:59 +03:00
Work
This commit is contained in:
parent
dacd55fdd4
commit
4368c616ee
3 changed files with 69 additions and 10 deletions
|
@ -2811,4 +2811,63 @@ Vector2 GetOrthogonalIntersect(int xPos, int zPos, int radius, short yRot)
|
|||
}
|
||||
|
||||
return vect;
|
||||
}
|
||||
|
||||
short GetNearestLedgeAngle(FLOOR_INFO* f, int x, int y, int z, short ang, int rad)
|
||||
{
|
||||
auto height = f->FloorHeight(x, z, y);
|
||||
auto bridge = f->InsideBridge(x, z, y, false, y == height);
|
||||
|
||||
auto fY = y - 1;
|
||||
auto cY = y + 1;
|
||||
|
||||
if (bridge >= 0)
|
||||
{
|
||||
// bridge code
|
||||
auto bounds = GetBoundsAccurate(&g_Level.Items[bridge]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// block code
|
||||
|
||||
// Block corners
|
||||
auto fX = floor(x / WALL_SIZE) * WALL_SIZE - 1;
|
||||
auto fZ = floor(z / WALL_SIZE) * WALL_SIZE - 1;
|
||||
auto cX = fX + WALL_SIZE + 1;
|
||||
auto cZ = fZ + WALL_SIZE + 1;
|
||||
|
||||
// Block edge planes
|
||||
Plane plane[4] =
|
||||
{
|
||||
Plane(Vector3(fX, cY, fZ), Vector3(cX, cY, fZ), Vector3(cX, fY, fZ)), // south
|
||||
Plane(Vector3(fX, cY, cZ), Vector3(cX, cY, cZ), Vector3(cX, fY, fZ)), // north
|
||||
Plane(Vector3(fX, cY, fZ), Vector3(fX, cY, cZ), Vector3(fX, fY, cZ)), // west
|
||||
Plane(Vector3(cX, cY, fZ), Vector3(cX, cY, cZ), Vector3(cX, fY, cZ)) // east
|
||||
};
|
||||
|
||||
//f->FloorCollision.SplitAngle
|
||||
|
||||
// Ray end coords
|
||||
int eX = x + rad * phd_sin(ang);
|
||||
int eZ = z + rad * phd_cos(ang);
|
||||
|
||||
auto ray = Ray(Vector3(x, cY, z), Vector3(eX, cY, eZ));
|
||||
|
||||
float closestDistance = FLT_MAX;
|
||||
int closestPlane = -1;
|
||||
|
||||
// Find closest block edge plane
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
float dist;
|
||||
if (ray.Intersects(plane[i], dist))
|
||||
{
|
||||
if (dist < closestDistance)
|
||||
{
|
||||
closestDistance = dist;
|
||||
closestPlane = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -238,7 +238,7 @@ bool FLOOR_INFO::IsWall(int x, int z) const
|
|||
return IsWall(SectorPlane(x, z));
|
||||
}
|
||||
|
||||
bool FLOOR_INFO::InsideBridge(int x, int z, int y, bool floorBorder, bool ceilingBorder) const
|
||||
short FLOOR_INFO::InsideBridge(int x, int z, int y, bool floorBorder, bool ceilingBorder) const
|
||||
{
|
||||
for (const auto itemNumber : BridgeItem)
|
||||
{
|
||||
|
@ -246,10 +246,10 @@ bool FLOOR_INFO::InsideBridge(int x, int z, int y, bool floorBorder, bool ceilin
|
|||
const auto floorHeight = Objects[item.objectNumber].floor(itemNumber, x, y, z);
|
||||
const auto ceilingHeight = Objects[item.objectNumber].ceiling(itemNumber, x, y, z);
|
||||
if (floorHeight && ceilingHeight && (y > *floorHeight && y < *ceilingHeight || floorBorder && y == *floorHeight || ceilingBorder && y == *ceilingHeight))
|
||||
return true;
|
||||
return itemNumber;
|
||||
}
|
||||
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void FLOOR_INFO::AddItem(short itemNumber)
|
||||
|
@ -382,7 +382,7 @@ namespace TEN::Floordata
|
|||
floor = &GetFloorSide(*roomAbove, x, z, &roomNumber);
|
||||
}
|
||||
}
|
||||
while (floor->InsideBridge(x, z, y, false, true));
|
||||
while (floor->InsideBridge(x, z, y, false, true) >= 0);
|
||||
|
||||
if (topRoomNumber)
|
||||
*topRoomNumber = roomNumber;
|
||||
|
@ -410,7 +410,7 @@ namespace TEN::Floordata
|
|||
floor = &GetFloorSide(*roomBelow, x, z, &roomNumber);
|
||||
}
|
||||
}
|
||||
while (floor->InsideBridge(x, z, y, true, false));
|
||||
while (floor->InsideBridge(x, z, y, true, false) >= 0);
|
||||
|
||||
if (bottomRoomNumber)
|
||||
*bottomRoomNumber = roomNumber;
|
||||
|
@ -452,7 +452,7 @@ namespace TEN::Floordata
|
|||
|
||||
y = std::clamp(y, std::min(ceilingHeight, floorHeight), std::max(ceilingHeight, floorHeight));
|
||||
|
||||
if (floor->InsideBridge(x, z, y, y == ceilingHeight, y == floorHeight))
|
||||
if (floor->InsideBridge(x, z, y, y == ceilingHeight, y == floorHeight) >= 0)
|
||||
{
|
||||
auto height = GetTopHeight(*floor, x, z, y);
|
||||
if (height)
|
||||
|
@ -508,7 +508,7 @@ namespace TEN::Floordata
|
|||
|
||||
y = std::clamp(y, std::min(ceilingHeight, floorHeight), std::max(ceilingHeight, floorHeight));
|
||||
|
||||
if (floor->InsideBridge(x, z, y, y == ceilingHeight, y == floorHeight))
|
||||
if (floor->InsideBridge(x, z, y, y == ceilingHeight, y == floorHeight) >= 0)
|
||||
{
|
||||
auto height = GetBottomHeight(*floor, x, z, y);
|
||||
if (height)
|
||||
|
@ -550,7 +550,7 @@ namespace TEN::Floordata
|
|||
|
||||
location.yNumber = std::clamp(location.yNumber, std::min(ceilingHeight, floorHeight), std::max(ceilingHeight, floorHeight));
|
||||
|
||||
if (floor->InsideBridge(x, z, location.yNumber, location.yNumber == ceilingHeight, location.yNumber == floorHeight))
|
||||
if (floor->InsideBridge(x, z, location.yNumber, location.yNumber == ceilingHeight, location.yNumber == floorHeight) >= 0)
|
||||
{
|
||||
const auto height = GetBottomHeight(*floor, x, z, location.yNumber, &location.roomNumber, &floor);
|
||||
if (!height)
|
||||
|
@ -612,7 +612,7 @@ namespace TEN::Floordata
|
|||
|
||||
location.yNumber = std::clamp(location.yNumber, std::min(ceilingHeight, floorHeight), std::max(ceilingHeight, floorHeight));
|
||||
|
||||
if (floor->InsideBridge(x, z, location.yNumber, location.yNumber == ceilingHeight, location.yNumber == floorHeight))
|
||||
if (floor->InsideBridge(x, z, location.yNumber, location.yNumber == ceilingHeight, location.yNumber == floorHeight) >= 0)
|
||||
{
|
||||
const auto height = GetTopHeight(*floor, x, z, location.yNumber, &location.roomNumber, &floor);
|
||||
if (!height)
|
||||
|
|
|
@ -68,7 +68,7 @@ class FLOOR_INFO
|
|||
Vector2 CeilingSlope(int x, int z) const;
|
||||
bool IsWall(int plane) const;
|
||||
bool IsWall(int x, int z) const;
|
||||
bool InsideBridge(int x, int z, int y, bool floorBorder, bool ceilingBorder) const;
|
||||
short InsideBridge(int x, int z, int y, bool floorBorder, bool ceilingBorder) const;
|
||||
void AddItem(short itemNumber);
|
||||
void RemoveItem(short itemNumber);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue