From 77d96ccb0529bd7171074e0481a7a007a04deae5 Mon Sep 17 00:00:00 2001 From: XProger Date: Wed, 4 Oct 2017 01:07:55 +0300 Subject: [PATCH] #8 fix cutscenes bug; #22 add spot shadows for darts --- src/camera.h | 9 +++++++++ src/format.h | 12 ++++++------ src/lara.h | 5 +---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/camera.h b/src/camera.h index 00a6200..6ab658b 100644 --- a/src/camera.h +++ b/src/camera.h @@ -47,6 +47,7 @@ struct Camera : ICamera { if (owner->getEntity().type != TR::Entity::LARA && level->cameraFrames) { state = STATE_CUTSCENE; room = level->entities[level->cutEntity].room; + timer = 0.0f; } else state = STATE_FOLLOW; destPos = owner->pos - owner->getDir() * 1024.0f; @@ -144,6 +145,14 @@ struct Camera : ICamera { target = viewPoint; } + virtual void doCutscene(const vec3 &pos, float rotation) { + state = Camera::STATE_CUTSCENE; + level->cutMatrix.identity(); + level->cutMatrix.rotateY(angle.y); + level->cutMatrix.setPos(pos); + timer = 0.0f; + } + virtual void update() { if (shake > 0.0f) shake = max(0.0f, shake - Core::deltaTime); diff --git a/src/format.h b/src/format.h index bdfc253..473893d 100644 --- a/src/format.h +++ b/src/format.h @@ -681,7 +681,7 @@ namespace TR { } bool isBlock() const { - return type >= TR::Entity::BLOCK_1 && type <= TR::Entity::BLOCK_4; + return type >= BLOCK_1 && type <= BLOCK_4; } bool isLara() const { @@ -689,7 +689,7 @@ namespace TR { } bool castShadow() const { - return isLara() || isEnemy() || isActor(); + return isLara() || isEnemy() || isActor() || type == TRAP_DART; } void getAxis(int &dx, int &dz) { @@ -1505,7 +1505,7 @@ namespace TR { } for (int i = 0; i < spriteSequencesCount; i++) - if (spriteSequences[i].type == TR::Entity::GLYPH) { + if (spriteSequences[i].type == Entity::GLYPH) { extra.glyphSeq = i; break; } @@ -2041,8 +2041,8 @@ namespace TR { } int16 getModelIndex(Entity::Type type) const { - if (type == TR::Entity::ENEMY_MUTANT_2 || type == TR::Entity::ENEMY_MUTANT_3) - type = TR::Entity::ENEMY_MUTANT_1; // hardcoded mutant models remapping + if (type == Entity::ENEMY_MUTANT_2 || type == Entity::ENEMY_MUTANT_3) + type = Entity::ENEMY_MUTANT_1; // hardcoded mutant models remapping for (int i = 0; i < modelsCount; i++) if (type == models[i].type) @@ -2056,7 +2056,7 @@ namespace TR { return 0; } - int entityAdd(TR::Entity::Type type, int16 room, int32 x, int32 y, int32 z, angle rotation, int16 intensity) { + int entityAdd(Entity::Type type, int16 room, int32 x, int32 y, int32 z, angle rotation, int16 intensity) { for (int i = entitiesBaseCount; i < entitiesCount; i++) if (entities[i].type == Entity::NONE) { Entity &e = entities[i]; diff --git a/src/lara.h b/src/lara.h index a1b30f3..a4fbc19 100644 --- a/src/lara.h +++ b/src/lara.h @@ -1506,10 +1506,7 @@ struct Lara : Character { if (item.type == TR::Entity::SCION_QUALOPEC) { animation.setAnim(level->models[TR::MODEL_LARA_SPEC].animation); - ((Camera*)level->cameraController)->state = Camera::STATE_CUTSCENE; - level->cutMatrix.identity(); - level->cutMatrix.rotateY(angle.y); - level->cutMatrix.setPos(pos); + ((Camera*)level->cameraController)->doCutscene(pos, angle.y); } else state = STATE_PICK_UP;