1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-13 16:44:50 +02:00

#3 fix reach-hang and floor & ceiling collision

This commit is contained in:
XProger
2017-09-01 03:03:13 +03:00
parent d8b2429089
commit bb486dfa26
3 changed files with 18 additions and 8 deletions

View File

@@ -41,17 +41,26 @@ struct Collision {
getFloor(level, roomIndex, vec3(pos.x, hpos.y, pos.z));
if (checkHeight(level, roomIndex, hpos, vec2(0.0f), height, 0xFFFFFF, 0xFFFFFF, side = NONE)) {
pos -= velocity;
pos.x -= velocity.x;
pos.z -= velocity.z;
side = FRONT;
return;
}
if (info[NONE].ceiling > hpos.y - maxHeight) {
int hCell = info[NONE].ceiling - (hpos.y - maxHeight);
if (hCell > 0) {
if (hCell > 128) {
pos.x -= velocity.x;
pos.z -= velocity.z;
side = FRONT;
} else {
pos.y = info[NONE].ceiling + maxHeight - offset.y;
side = TOP;
}
}
if (info[NONE].floor < hpos.y + minHeight) {
int hFloor = info[NONE].floor - (hpos.y + minHeight);
if (hFloor < 0 && hFloor > -256) {
pos.y = info[NONE].floor - minHeight - offset.y;
side = BOTTOM;
}

View File

@@ -2127,7 +2127,7 @@ namespace TR {
info.trigger = Trigger::ACTIVATE;
info.trigCmdCount = 0;
if (s.floor == -127)
if (s.floor == NO_FLOOR)
return;
Room::Sector *sBelow = &s;

View File

@@ -437,7 +437,7 @@ struct Lara : Character {
//reset(14, vec3(40448, 3584, 60928), PI * 0.5f, STAND_ONWATER); // gym (pool)
//reset(14, vec3(20215, 6656, 52942), PI); // level 1 (bridge)
//reset(33, vec3(48229, 4608, 78420), 270 * DEG2RAD); // level 1 (end)
//reset(15, vec3(70067, -256, 29104), -0.68f); // level 2 (pool)
reset(15, vec3(70067, -256, 29104), -0.68f); // level 2 (pool)
//reset(26, vec3(71980, 1546, 19000), 270 * DEG2RAD); // level 2 (underwater switch)
//reset(61, vec3(27221, -1024, 29205), PI * 0.5f); // level 2 (blade)
//reset(43, vec3(31400, -2560, 25200), PI); // level 2 (reach)
@@ -1761,7 +1761,7 @@ struct Lara : Character {
vec3 p = vec3(pos.x, bounds.min.y, pos.z);
Collision c = Collision(level, getRoomIndex(), p, getDir() * 32.0f, vec3(0.0f), LARA_RADIUS, angleExt, 0, 0, 0, 0);
Collision c = Collision(level, getRoomIndex(), p, getDir() * 128.0f, vec3(0.0f), LARA_RADIUS, angleExt, 0, 0, 0, 0);
if (c.side != Collision::FRONT)
return state;
@@ -1777,6 +1777,7 @@ struct Lara : Character {
updateEntity();
if (state == STATE_REACH) {
velocity = vec3(0.0f);
vec3 p = pos + getDir() * 256.0f;
TR::Level::FloorInfo info;
level->getFloorInfo(getRoomIndex(), int(p.x), int(p.y), int(p.z), info);