1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-03-13 23:59:41 +01:00
This commit is contained in:
Timur Gagiev 2020-09-25 05:33:20 +03:00
commit 7a3c15d29c
7 changed files with 38 additions and 15 deletions

View File

@ -22,7 +22,7 @@ struct Collision {
angle = normalizeAngle(PI2 + vec2(velocity.z, velocity.x).angle());
pos += velocity;
int q = angleQuadrant(angle);
int q = angleQuadrant(angle, 0.25f);
const vec2 v[] = {
vec2( -radius, radius ),

View File

@ -790,7 +790,7 @@ struct Controller {
}
bool alignToWall(float offset = 0.0f, int quadrant = -1, int maxDist = 0, int maxWidth = 0) {
int q = angleQuadrant(angle.y);
int q = angleQuadrant(angle.y, 0.25f);
int ix = int(pos.x);
int iz = int(pos.z);
int x = ix & ~1023;

View File

@ -472,7 +472,14 @@ struct Enemy : Character {
int z = (b.minZ + b.maxZ) / 2 - int(target->pos.z);
if (abs(z) > STALK_BOX) return false;
// TODO: check for some quadrant shit
int target_quadrant = angleQuadrant(target->angle.y, 0.0);
int box_quadrant = z > 0 ? (x > 0 ? 2 : 1) : (x > 0 ? 3 : 0);
if (target_quadrant == box_quadrant) return false;
int controller_quadrant = pos.z > target->pos.z ? (pos.x > target->pos.x ? 2 : 1) : (pos.x > target->pos.x ? 3 : 0);
if (target_quadrant == controller_quadrant && abs(target_quadrant - box_quadrant) == 2) return false;
return true;
}
@ -2550,7 +2557,7 @@ struct Human : Enemy {
int jointGun;
int animDeath;
Human(IGame *game, int entity, float health) : Enemy(game, entity, health, 100, 375.0f, 1.0f), animDeath(-1) {
Human(IGame *game, int entity, float health) : Enemy(game, entity, health, 100, 0.0f, 1.0f), animDeath(-1) {
jointGun = 0;
jointChest = 7;
jointHead = 8;

View File

@ -6219,19 +6219,28 @@ namespace TR {
}
void readAnimTex(Stream &stream) {
uint32 size;
stream.read(size);
if (size) {
stream.read(animTexturesCount);
uint32 animTexBlockSize;
stream.read(animTexBlockSize);
if (animTexBlockSize) {
uint16 *animTexBlock = new uint16[animTexBlockSize];
for (int i = 0; i < animTexBlockSize; i++) {
animTexBlock[i] = stream.readLE16();
}
uint16 *ptr = animTexBlock;
animTexturesCount = *(ptr++);
animTextures = animTexturesCount ? new AnimTexture[animTexturesCount] : NULL;
for (int i = 0; i < animTexturesCount; i++) {
AnimTexture &animTex = animTextures[i];
animTex.count = stream.readLE16() + 1;
animTex.count = *(ptr++) + 1;
animTex.textures = new uint16[animTex.count];
for (int j = 0; j < animTex.count; j++)
animTex.textures[j] = stream.readLE16();
animTex.textures[j] = *(ptr++);
}
delete animTexBlock;
}
if (version & (VER_TR4 | VER_TR5)) {

View File

@ -2510,7 +2510,7 @@ struct Lara : Character {
Block *block = (Block*)e.controller;
float oldAngle = block->angle.y;
block->angle.y = angleQuadrant(angle.y) * (PI * 0.5f);
block->angle.y = angleQuadrant(angle.y, 0.25f) * (PI * 0.5f);
if (!checkInteraction(block, &TR::Limits::BLOCK, (input & ACTION) != 0)) {
block->angle.y = oldAngle;
@ -3609,7 +3609,7 @@ struct Lara : Character {
}
if (level->version & TR::VER_TR1) // TODO: check hit animation indices for TR2 and TR3
hitDir = angleQuadrant(dir.rotateY(angle.y + PI * 0.5f).angleY());
hitDir = angleQuadrant(dir.rotateY(angle.y + PI * 0.5f).angleY(), 0.25f);
return true;
}
};
@ -3692,7 +3692,7 @@ struct Lara : Character {
if (collision.side == Collision::FRONT) {
float floor = collision.info[Collision::FRONT].floor;
/*
switch (angleQuadrant(angleExt - angle.y)) {
switch (angleQuadrant(angleExt - angle.y), 0.25f) {
case 0 : collision.side = Collision::FRONT; LOG("FRONT\n"); break;
case 1 : collision.side = Collision::RIGHT; LOG("RIGHT\n"); break;
case 2 : collision.side = Collision::BACK; LOG("BACK\n"); break;

View File

@ -1928,6 +1928,13 @@ struct Level : IGame {
s.z -= s.x;
s.w -= s.y;
// Use the viewport rect if one of the dimensions is the same size
// as the viewport. This may fix clipping bugs while still allowing
// impossible geometry tricks.
if (s.z - s.x >= vp.z - vp.x || s.w - s.y >= vp.w - vp.y) {
return vp;
}
return s;
}

View File

@ -165,8 +165,8 @@ float normalizeAngle(float angle) {
return angle;
}
int angleQuadrant(float angle) {
return int(normalizeAngle(angle + PI * 0.25f) / (PI * 0.5f));
int angleQuadrant(float angle, float offset) {
return int(normalizeAngle(angle + PI * offset) / (PI * 0.5f));
}
float decrease(float delta, float &value, float &speed) {