mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-01 09:18:00 +03:00
Add GetDiagonalIntersect()
GetDiagonalIntersect() returns Vector2 with x and z coordinates aligned to diagonal, offset by LARA_RAD
This commit is contained in:
parent
e2ebbe0f66
commit
475effbe25
4 changed files with 47 additions and 47 deletions
|
@ -1627,3 +1627,42 @@ void CalcItemToFloorRotation(ITEM_INFO* item, short rotY, int radiusZ, int radiu
|
||||||
item->pos.xRot = ANGLE(atan2(frontHDif, 2 * radiusZ) / RADIAN);
|
item->pos.xRot = ANGLE(atan2(frontHDif, 2 * radiusZ) / RADIAN);
|
||||||
item->pos.zRot = ANGLE(atan2(sideHDif, 2 * radiusX) / RADIAN);
|
item->pos.zRot = ANGLE(atan2(sideHDif, 2 * radiusX) / RADIAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 GetDiagonalIntersect(int xPos, int zPos, int splitType, int radius, short yRot)
|
||||||
|
{
|
||||||
|
Vector2 vect;
|
||||||
|
|
||||||
|
int dx = (xPos % WALL_SIZE) - WALL_SIZE/2;
|
||||||
|
int dz = (zPos % WALL_SIZE) - WALL_SIZE/2;
|
||||||
|
int xGrid = xPos - dx;
|
||||||
|
int zGrid = zPos - dz;
|
||||||
|
|
||||||
|
switch (splitType)
|
||||||
|
{
|
||||||
|
case SPLIT1:
|
||||||
|
case NOCOLF1T:
|
||||||
|
case NOCOLF1B:
|
||||||
|
xPos = xGrid + (dx - dz) / 2;
|
||||||
|
zPos = zGrid - (dx - dz) / 2;
|
||||||
|
break;
|
||||||
|
case SPLIT2:
|
||||||
|
case NOCOLF2T:
|
||||||
|
case NOCOLF2B:
|
||||||
|
xPos = xGrid + (dx + dz) / 2;
|
||||||
|
zPos = zGrid + (dx + dz) / 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (splitType)
|
||||||
|
{
|
||||||
|
xPos -= int(radius * sin(TO_RAD(yRot)));
|
||||||
|
zPos -= int(radius * cos(TO_RAD(yRot)));
|
||||||
|
}
|
||||||
|
|
||||||
|
vect.x = xPos;
|
||||||
|
vect.y = zPos;
|
||||||
|
|
||||||
|
return vect;
|
||||||
|
}
|
||||||
|
|
|
@ -116,3 +116,4 @@ void CreatureCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll);
|
||||||
void GetCollisionInfo(COLL_INFO* coll, int xPos, int yPos, int zPos, int roomNumber, int objectHeight);
|
void GetCollisionInfo(COLL_INFO* coll, int xPos, int yPos, int zPos, int roomNumber, int objectHeight);
|
||||||
void LaraBaddieCollision(ITEM_INFO* item, COLL_INFO* coll);
|
void LaraBaddieCollision(ITEM_INFO* item, COLL_INFO* coll);
|
||||||
void CalcItemToFloorRotation(ITEM_INFO* item, short rotY, int radiusZ, int radiusX); // new function for rotating item along XZ slopes
|
void CalcItemToFloorRotation(ITEM_INFO* item, short rotY, int radiusZ, int radiusX); // new function for rotating item along XZ slopes
|
||||||
|
Vector2 GetDiagonalIntersect(int xPos, int zPos, int splitType, int radius, short yRot); // finds xPos, zPos that intersects with diagonal on sector
|
|
@ -6614,29 +6614,9 @@ int TestLaraVault(ITEM_INFO* item, COLL_INFO* coll) // (F) (D)
|
||||||
|
|
||||||
if (coll->midSplitFloor) // diagonal alignment
|
if (coll->midSplitFloor) // diagonal alignment
|
||||||
{
|
{
|
||||||
int dx = item->pos.xPos & 0x3FF;
|
Vector2 v = GetDiagonalIntersect(item->pos.xPos, item->pos.zPos, coll->midSplitFloor, LARA_RAD, item->pos.yRot);
|
||||||
int dz = item->pos.zPos & 0x3FF;
|
item->pos.xPos = v.x;
|
||||||
item->pos.xPos -= dx;
|
item->pos.zPos = v.y;
|
||||||
item->pos.zPos -= dz;
|
|
||||||
|
|
||||||
switch (coll->midSplitFloor)
|
|
||||||
{
|
|
||||||
case SPLIT1:
|
|
||||||
case NOCOLF1T:
|
|
||||||
case NOCOLF1B:
|
|
||||||
item->pos.xPos += 512 + (dx - dz) / 2;
|
|
||||||
item->pos.zPos += 512 - (dx - dz) / 2;
|
|
||||||
break;
|
|
||||||
case SPLIT2:
|
|
||||||
case NOCOLF2T:
|
|
||||||
case NOCOLF2B:
|
|
||||||
item->pos.xPos += (dx + dz) / 2;
|
|
||||||
item->pos.zPos += (dx + dz) / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
item->pos.xPos -= (phd_sin(angle) * 100) >> W2V_SHIFT;
|
|
||||||
item->pos.zPos -= (phd_cos(angle) * 100) >> W2V_SHIFT;
|
|
||||||
}
|
}
|
||||||
else // regular aligment
|
else // regular aligment
|
||||||
{
|
{
|
||||||
|
|
|
@ -386,29 +386,9 @@ int LaraTestWaterClimbOut(ITEM_INFO* item, COLL_INFO* coll)//4D22C, 4D690
|
||||||
|
|
||||||
if (coll->midSplitFloor)
|
if (coll->midSplitFloor)
|
||||||
{
|
{
|
||||||
int dx = item->pos.xPos & 0x3FF;
|
Vector2 v = GetDiagonalIntersect(item->pos.xPos, item->pos.zPos, coll->midSplitFloor, -LARA_RAD, item->pos.yRot);
|
||||||
int dz = item->pos.zPos & 0x3FF;
|
item->pos.xPos = v.x;
|
||||||
item->pos.xPos -= dx;
|
item->pos.zPos = v.y;
|
||||||
item->pos.zPos -= dz;
|
|
||||||
|
|
||||||
switch (coll->midSplitFloor)
|
|
||||||
{
|
|
||||||
case SPLIT1:
|
|
||||||
case NOCOLF1T:
|
|
||||||
case NOCOLF1B:
|
|
||||||
item->pos.xPos += 512 + (dx - dz) / 2;
|
|
||||||
item->pos.zPos += 512 - (dx - dz) / 2;
|
|
||||||
break;
|
|
||||||
case SPLIT2:
|
|
||||||
case NOCOLF2T:
|
|
||||||
case NOCOLF2B:
|
|
||||||
item->pos.xPos += (dx + dz) / 2;
|
|
||||||
item->pos.zPos += (dx + dz) / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
item->pos.xPos += (phd_sin(rot) * 100) >> W2V_SHIFT;
|
|
||||||
item->pos.zPos += (phd_cos(rot) * 100) >> W2V_SHIFT;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue