Merge branch 'develop_mirrors' into realtime_shader_reloading

This commit is contained in:
Lwmte 2024-12-25 13:40:38 +01:00
commit 329bb52ec7
80 changed files with 294 additions and 303 deletions

View file

@ -3,7 +3,7 @@
The dates are in European standard format where date is presented as **YYYY-MM-DD**.
TombEngine releases are located in this repository (alongside with Tomb Editor): https://github.com/TombEngine/TombEditorReleases
## Version 1.6 - xxxx-xx-xx
## Version 1.7 - xxxx-xx-xx
### Bug fixes
* Significantly improved renderer performance.
@ -32,6 +32,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
* Fixed incorrect camera movement near walls after leaving look mode.
* Fixed binocular or lasersight camera not switching off correctly after flyby.
* Fixed binocular or lasersight camera transitions.
* Fixed target highlighter still being active in binocular or lasersight mode.
* Fixed Lara's Home entry not working.
* Fixed exploding TR3 bosses.
* Fixed original issue with deactivation of Dart Emitter.

View file

@ -12,7 +12,7 @@ new_type("luautil", "5 Lua utility modules", true)
not_luadoc = true
local version = "1.6"
local version = "1.7"
project = " TombEngine"
title = "TombEngine " .. version .. " Lua API"
description = "TombEngine " .. version .. " scripting interface"

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -122,7 +122,7 @@
<td class="summary">Ammo used.</td>
</tr>
<tr>
<td class="name" ><a href="#traveledDistance">traveledDistance</a></td>
<td class="name" ><a href="#distanceTraveled">distanceTraveled</a></td>
<td class="summary">Distance traveled.</td>
</tr>
<tr>
@ -197,8 +197,8 @@
</dd>
<dt>
<a name = "traveledDistance"></a>
<strong>traveledDistance</strong>
<a name = "distanceTraveled"></a>
<strong>distanceTraveled</strong>
</dt>
<dd>
Distance traveled.
@ -206,7 +206,7 @@
<ul>
<li><span class="parameter">traveledDistance</span>
<li><span class="parameter">distanceTraveled</span>
<span class="types"><span class="type">int</span></span>
amount of traveled distance in world units. One meter is 420 world units.
</li>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine 1.6 Lua API</title>
<title>TombEngine 1.7 Lua API</title>
<link rel="stylesheet" href="ldoc.css" type="text/css" />
</head>
<body>
@ -107,7 +107,7 @@
<div id="content">
<h2>TombEngine 1.6 scripting interface</h2>
<h2>TombEngine 1.7 scripting interface</h2>
<p>Welcome to the TombEngine scripting API. This is a work in progress and some information might be wrong or outdated. Please also note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse.</p>
<p>At the time of writing, there is a tutorial describing the basics of Lua, as well as a number of example scripts, on <a href="https://www.tombengine.com">the TombEngine website</a>.</p>

View file

@ -461,8 +461,8 @@ static short NormalizeLookAroundTurnRate(short turnRate, short opticRange)
void HandlePlayerLookAround(ItemInfo& item, bool invertXAxis)
{
constexpr auto TURN_RATE_MAX = ANGLE(4.0f);
constexpr auto TURN_RATE_ACCEL = ANGLE(0.75f);
constexpr auto TURN_RATE_MAX = ANGLE(4.0f);
constexpr auto TURN_RATE_ACCEL = ANGLE(0.75f);
auto& player = GetLaraInfo(item);

View file

@ -4,20 +4,25 @@
#include "Game/camera.h"
#include "Game/control/los.h"
#include "Game/effects/effects.h"
#include "Game/items.h"
#include "Game/Lara/lara.h"
#include "Game/Lara/lara_flare.h"
#include "Game/Lara/lara_helpers.h"
#include "Game/Lara/lara_struct.h"
#include "Game/Lara/lara_one_gun.h"
#include "Game/Lara/lara_struct.h"
#include "Game/Lara/lara_two_guns.h"
#include "Specific/Input/Input.h"
#include "Game/Setup.h"
#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/Input/Input.h"
using namespace TEN::Input;
static void HandlePlayerOpticZoom(ItemInfo& item)
{
constexpr auto OPTICS_RANGE_MAX = ANGLE(8.5f);
constexpr auto OPTICS_RANGE_MIN = ANGLE(0.7f);
constexpr auto OPTICS_RANGE_RATE = ANGLE(0.35f);
auto& player = GetLaraInfo(item);
bool isSlow = IsHeld(In::Walk);
@ -64,7 +69,6 @@ static void HandlePlayerOpticAnimations(ItemInfo& item)
return;
int animNumber = Objects[ID_LARA_BINOCULARS_MESH].loaded ? LA_BINOCULARS_IDLE : LA_STAND_IDLE;
if (player.Control.Look.IsUsingLasersight)
{
switch (player.Control.Weapon.GunType)
@ -95,7 +99,8 @@ static void HandlePlayerOpticAnimations(ItemInfo& item)
player.Torch.IsLit = false;
player.Flare.ControlLeft = false;
player.Flare.Life = 0;
player.Control.Weapon.GunType = player.Control.Weapon.RequestGunType = player.Control.Weapon.LastGunType;
player.Control.Weapon.GunType =
player.Control.Weapon.RequestGunType = player.Control.Weapon.LastGunType;
}
else if (player.Control.Weapon.GunType != LaraWeaponType::None &&
player.Control.HandStatus != HandStatus::Free)
@ -124,10 +129,14 @@ static void HandlePlayerOpticAnimations(ItemInfo& item)
player.Control.HandStatus = HandStatus::Free;
}
player.LeftArm.Locked = player.RightArm.Locked = false;
player.LeftArm.FrameNumber = player.RightArm.FrameNumber = 0;
player.LeftArm.AnimNumber = player.RightArm.AnimNumber = animNumber;
player.LeftArm.FrameBase = player.RightArm.FrameBase = GetAnimData(animNumber).FramePtr;
player.LeftArm.Locked =
player.RightArm.Locked = false;
player.LeftArm.FrameNumber =
player.RightArm.FrameNumber = 0;
player.LeftArm.AnimNumber =
player.RightArm.AnimNumber = animNumber;
player.LeftArm.FrameBase =
player.RightArm.FrameBase = GetAnimData(animNumber).FramePtr;
}
static void ResetPlayerOpticAnimations(ItemInfo& item)
@ -136,10 +145,14 @@ static void ResetPlayerOpticAnimations(ItemInfo& item)
ResetPlayerFlex(&item);
player.LeftArm.Locked = player.RightArm.Locked = false;
player.LeftArm.AnimNumber = player.RightArm.AnimNumber = 0;
player.LeftArm.FrameNumber = player.RightArm.FrameNumber = 0;
player.RightArm.FrameBase = player.LeftArm.FrameBase = GetAnimData(item).FramePtr;
player.LeftArm.Locked =
player.RightArm.Locked = false;
player.LeftArm.AnimNumber =
player.RightArm.AnimNumber = 0;
player.LeftArm.FrameNumber =
player.RightArm.FrameNumber = 0;
player.RightArm.FrameBase =
player.LeftArm.FrameBase = GetAnimData(item).FramePtr;
player.Control.HandStatus = player.Control.Look.IsUsingLasersight ? HandStatus::WeaponReady : HandStatus::Free;
if (!player.Control.Look.IsUsingLasersight)
@ -156,32 +169,31 @@ static void ResetPlayerOpticAnimations(ItemInfo& item)
SetScreenFadeIn(OPTICS_FADE_SPEED);
}
static void DoOpticsHighlight(const ItemInfo& item, Vector3i* origin, Vector3i* target)
static void DoOpticsHighlight(const ItemInfo& item, const Vector3i& origin, const Vector3i& target)
{
auto pos1 = GameVector(*origin, item.RoomNumber);
auto pos2 = GameVector(*target);
auto origin2 = GameVector(origin, item.RoomNumber);
auto target2 = GameVector(target);
const auto& binocularColor = g_GameFlow->GetSettings()->Camera.BinocularLightColor;
const auto& binocularsColor = g_GameFlow->GetSettings()->Camera.BinocularLightColor;
const auto& lasersightColor = g_GameFlow->GetSettings()->Camera.LasersightLightColor;
const auto& color = GetLaraInfo(item).Control.Look.IsUsingLasersight ? lasersightColor : binocularColor;
const auto& color = GetLaraInfo(item).Control.Look.IsUsingLasersight ? lasersightColor : binocularsColor;
TriggerDynamicLight(pos1.x, pos1.y, pos1.z, 12, color.GetR(), color.GetG(), color.GetB());
TriggerDynamicLight(origin2.x, origin2.y, origin2.z, 12, color.GetR(), color.GetG(), color.GetB());
if (!LOS(&pos1, &pos2))
if (!LOS(&origin2, &target2))
{
int l = sqrt(pow(pos1.x - pos2.x, 2) + pow(pos1.y - pos2.y, 2) + pow(pos1.z - pos2.z, 2)) * CLICK(1);
int luma = sqrt(SQUARE(origin2.x - target2.x) + SQUARE(origin2.y - target2.y) + SQUARE(origin2.z - target2.z)) * CLICK(1);
if ((luma + 8) > 31)
luma = 31;
if (l + 8 > 31)
l = 31;
auto dir = pos1.ToVector3() - pos2.ToVector3();
auto dir = origin2.ToVector3() - target2.ToVector3();
dir.Normalize();
dir *= BLOCK(1);
byte r = std::max(0, color.GetR() - l);
byte g = std::max(0, color.GetG() - l);
byte b = std::max(0, color.GetB() - l);
TriggerDynamicLight(pos2.x + dir.x, pos2.y + dir.y, pos2.z + dir.z, l + 12, r, g, b);
byte r = std::max(0, color.GetR() - luma);
byte g = std::max(0, color.GetG() - luma);
byte b = std::max(0, color.GetB() - luma);
TriggerDynamicLight(target2.x + dir.x, target2.y + dir.y, target2.z + dir.z, luma + 12, r, g, b);
}
}
@ -257,7 +269,7 @@ bool HandlePlayerOptics(ItemInfo& item)
auto origin = Camera.pos.ToVector3i();
auto target = Camera.target.ToVector3i();
DoOpticsHighlight(item, &origin, &target);
DoOpticsHighlight(item, origin, target);
}
if (!breakOptics)

View file

@ -1,12 +1,10 @@
#pragma once
#include "Specific/clock.h"
struct ItemInfo;
constexpr auto OPTICS_FADE_SPEED = 6.0f / FPS;
constexpr auto OPTICS_RANGE_DEFAULT = ANGLE(0.7f);
constexpr auto OPTICS_RANGE_MIN = ANGLE(0.7f);
constexpr auto OPTICS_RANGE_MAX = ANGLE(8.5f);
constexpr auto OPTICS_RANGE_RATE = ANGLE(0.35f);
bool HandlePlayerOptics(ItemInfo& item);

View file

@ -20,6 +20,7 @@
#include "Math/Math.h"
#include "Scripting/Include/ScriptInterfaceGame.h"
#include "Sound/sound.h"
#include "Specific/winmain.h"
using namespace TEN::Collision::Floordata;
using namespace TEN::Collision::Point;
@ -330,6 +331,11 @@ void TestForObjectOnLedge(ItemInfo* item, CollisionInfo* coll)
bool TestLaraPosition(const ObjectCollisionBounds& bounds, ItemInfo* item, ItemInfo* laraItem)
{
if (DebugMode)
{
DrawDebugBox(bounds.BoundingBox.ToBoundingOrientedBox(item->Pose), Color(1.0f, 0.0f, 0.0f), RendererDebugPage::CollisionStats);
}
auto deltaOrient = laraItem->Pose.Orientation - item->Pose.Orientation;
if (deltaOrient.x < bounds.OrientConstraint.first.x || deltaOrient.x > bounds.OrientConstraint.second.x ||
deltaOrient.y < bounds.OrientConstraint.first.y || deltaOrient.y > bounds.OrientConstraint.second.y ||
@ -341,11 +347,7 @@ bool TestLaraPosition(const ObjectCollisionBounds& bounds, ItemInfo* item, ItemI
auto pos = (laraItem->Pose.Position - item->Pose.Position).ToVector3();
auto rotMatrix = item->Pose.Orientation.ToRotationMatrix();
// This solves once for all the minus sign hack of CreateFromYawPitchRoll.
// In reality it should be the inverse, but the inverse of a rotation matrix is equal to the transpose
// and transposing a matrix is faster.
// It's the only piece of code that does it, because we want Lara's location relative to the identity frame
// of the object we are test against.
// NOTE: Transpose = faster inverse.
rotMatrix = rotMatrix.Transpose();
pos = Vector3::Transform(pos, rotMatrix);

View file

@ -300,8 +300,11 @@ void ControlWaterfallMist(short itemNumber);
void TriggerWaterfallMist(const ItemInfo& item);
void KillAllCurrentItems(short itemNumber);
void TriggerDynamicLight(int x, int y, int z, short falloff, byte r, byte g, byte b);
// TODO: use Spawn prefix instead.
void TriggerDynamicPointLight(const Vector3& pos, const Color& color, float falloff, bool castShadows = false, int hash = 0);
void TriggerDynamicSpotLight(const Vector3& pos, const Vector3& dir, const Color& color, float radius, float falloff, float distance, bool castShadows = false, int hash = 0);
void TriggerRocketFlame(int x, int y, int z, int xv, int yv, int zv, int itemNumber);
void TriggerRocketSmoke(int x, int y, int z);
void TriggerFlashSmoke(int x, int y, int z, short roomNumber);

View file

@ -46,15 +46,15 @@ namespace TEN::Renderer
RenderViewCamera Camera;
D3D11_VIEWPORT Viewport;
std::vector<RendererRoom*> RoomsToDraw = {};
std::vector<RendererLight*> LightsToDraw = {};
std::vector<RendererFogBulb> FogBulbsToDraw = {};
std::vector<RendererSpriteToDraw> SpritesToDraw = {};
std::vector<RendererDisplaySpriteToDraw> DisplaySpritesToDraw = {};
std::map<int, std::vector<RendererStatic*>> SortedStaticsToDraw = {};
std::vector<RendererRoom*> RoomsToDraw = {};
std::vector<RendererLight*> LightsToDraw = {};
std::vector<RendererFogBulb> FogBulbsToDraw = {};
std::vector<RendererSpriteToDraw> SpritesToDraw = {};
std::vector<RendererDisplaySpriteToDraw> DisplaySpritesToDraw = {};
std::map<int, std::vector<RendererStatic*>> SortedStaticsToDraw = {};
std::vector<RendererSortableObject> TransparentObjectsToDraw = {};
std::vector<RendererLensFlare> LensFlaresToDraw = {};
std::vector<RendererMirror> Mirrors = {};
std::vector<RendererLensFlare> LensFlaresToDraw = {};
std::vector<RendererMirror> Mirrors = {};
RenderView(CAMERA_INFO* cam, float roll, float fov, float nearPlane, float farPlane, int w, int h);
RenderView(const Vector3& pos, const Vector3& dir, const Vector3& up, int w, int h, int room, float nearPlane, float farPlane, float fov);

View file

@ -520,11 +520,11 @@ namespace TEN::Renderer
void CreateSSAONoiseTexture();
void InitializeSMAA();
bool RoomIsReflected(RenderView& renderView, int roomNumber);
bool IsRoomReflected(RenderView& renderView, int roomNumber);
inline bool IgnoreReflectionPassForRoom(int room)
inline bool IgnoreReflectionPassForRoom(int roomNumber)
{
return (_currentMirror != nullptr && room != _currentMirror->RoomNumber);
return (_currentMirror != nullptr && roomNumber != _currentMirror->RoomNumber);
}
inline void ReflectVectorOptionally(Vector3& vector)

View file

@ -561,9 +561,9 @@ namespace TEN::Renderer
if (rat->On)
{
RendererMesh* mesh = GetMesh(Objects[ID_RATS_EMITTER].meshIndex + (rand() % 8));
const auto& mesh = *GetMesh(Objects[ID_RATS_EMITTER].meshIndex + (rand() % 8));
Matrix world = rat->Transform;
auto world = rat->Transform;
ReflectMatrixOptionally(world);
_stStatic.World = world;
@ -571,27 +571,21 @@ namespace TEN::Renderer
_stStatic.AmbientLight = _rooms[rat->RoomNumber].AmbientLight;
if (rendererPass != RendererPass::GBuffer)
{
BindStaticLights(_rooms[rat->RoomNumber].LightsToDraw);
}
_cbStatic.UpdateData(_stStatic, _context.Get());
for (auto& bucket : mesh->Buckets)
for (const auto& bucket : mesh.Buckets)
{
if (bucket.NumVertices == 0)
{
continue;
}
int passes = rendererPass == RendererPass::Opaque && bucket.BlendMode == BlendMode::AlphaTest ? 2 : 1;
for (int p = 0; p < passes; p++)
{
if (!SetupBlendModeAndAlphaTest(bucket.BlendMode, rendererPass, p))
{
continue;
}
BindTexture(TextureRegister::ColorMap, &std::get<0>(_moveablesTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp);
BindTexture(TextureRegister::NormalMap, &std::get<1>(_moveablesTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp);
@ -779,7 +773,7 @@ namespace TEN::Renderer
auto transformMatrix = Matrix::Lerp(bat.PrevTransform, bat.Transform, GetInterpolationFactor());
Matrix world = transformMatrix;
auto world = transformMatrix;
ReflectMatrixOptionally(world);
_stInstancedStaticMeshBuffer.StaticMeshes[batCount].World = world;
@ -901,7 +895,7 @@ namespace TEN::Renderer
auto transformMatrix = Matrix::Lerp(beetle.PrevTransform, beetle.Transform, GetInterpolationFactor());
Matrix world = transformMatrix;
auto world = transformMatrix;
ReflectMatrixOptionally(world);
_stInstancedStaticMeshBuffer.StaticMeshes[beetleCount].World = world;
@ -1058,7 +1052,7 @@ namespace TEN::Renderer
auto& mesh = *GetMesh(Objects[ID_LOCUSTS].meshIndex + (-locust.counter & 3));
Matrix world = Matrix::Lerp(locust.PrevTransform, locust.Transform, GetInterpolationFactor());
auto world = Matrix::Lerp(locust.PrevTransform, locust.Transform, GetInterpolationFactor());
ReflectMatrixOptionally(world);
_stStatic.World = world;
@ -1598,7 +1592,7 @@ namespace TEN::Renderer
if (_isLocked || g_GameFlow->LastFreezeMode != FreezeMode::None)
return;
RendererLight dynamicLight = {};
auto dynamicLight = RendererLight{};
dynamicLight.Color = Vector3(color.x, color.y, color.z);
if (radius < BLOCK(2))
@ -1620,22 +1614,23 @@ namespace TEN::Renderer
void Renderer::PrepareDynamicLight(RendererLight& light)
{
// If hash is provided, search for same light in old buffer.
// If hash is provided, search for same light in previous buffer.
if (light.Hash != 0)
{
// Determine the previous buffer index.
const auto& previousList = _dynamicLights[1 - _dynamicLightList];
// Determine previous buffer index.
const auto& prevList = _dynamicLights[1 - _dynamicLightList];
// Find a light in the previous buffer with the same Hash.
auto it = std::find_if(previousList.begin(), previousList.end(),
// Find light in previous buffer with same hash.
auto it = std::find_if(
prevList.begin(), prevList.end(),
[&light](const auto& prevLight)
{
return prevLight.Hash == light.Hash;
return (prevLight.Hash == light.Hash);
});
if (it != previousList.end())
if (it != prevList.end())
{
// If a matching light is found, copy its data.
// If matching light is found, copy it.
const auto& prevLight = *it;
light.PrevPosition = prevLight.Position;
light.PrevDirection = prevLight.Direction;
@ -1645,16 +1640,17 @@ namespace TEN::Renderer
// Queue dynamic light.
_dynamicLights[_dynamicLightList].push_back(light);
// Check if light is spawned in a mirrored room, and create reflection.
for (auto& mirror : g_Level.Mirrors)
// Check if light is spawned in mirrored room and create reflection.
for (const auto& mirror : g_Level.Mirrors)
{
if (!mirror.ReflectLights)
continue;
// TODO: Avoid LaraItem global.
if ((Camera.pos.RoomNumber == mirror.RoomNumber || LaraItem->RoomNumber == mirror.RoomNumber) &&
IsPointInRoom(light.Position, mirror.RoomNumber))
{
RendererLight reflectedLight = light;
auto reflectedLight = light;
reflectedLight.Position = Vector3::Transform(light.Position, mirror.ReflectionMatrix);
reflectedLight.Direction = Vector3::Transform(light.Direction, mirror.ReflectionMatrix);
reflectedLight.Hash = 0;
@ -1886,7 +1882,7 @@ namespace TEN::Renderer
SortTransparentFaces(view);
DoRenderPass(RendererPass::Transparent, view, true);
DoRenderPass(RendererPass::GunFlashes, view, true); // HACK: Gunflashes are drawn after everything because they are near the camera.
DoRenderPass(RendererPass::GunFlashes, view, true); // HACK: Gunflashes are drawn after everything because they are near camera.
// Draw 3D debug lines and triangles.
DrawLines3D(view);
@ -2192,7 +2188,7 @@ namespace TEN::Renderer
SetCullMode(CullMode::CounterClockwise);
SetDepthState(DepthState::Write);
// Draw room geometry first, if applicable for a given pass.
// Draw room geometry first if applicable for a given pass.
if (pass != RendererPass::Transparent && pass != RendererPass::GunFlashes)
DrawRooms(view, pass);
@ -2206,9 +2202,10 @@ namespace TEN::Renderer
for (auto& mirror : view.Mirrors)
{
_currentMirror = &mirror;
DrawObjects(pass, view, mirror.ReflectLara, mirror.ReflectMoveables, mirror.ReflectStatics, mirror.ReflectSprites);
DrawObjects(pass, view, mirror.ReflectPlayer, mirror.ReflectMoveables, mirror.ReflectStatics, mirror.ReflectSprites);
_currentMirror = nullptr;
}
SetCullMode(CullMode::CounterClockwise);
}
}
@ -2251,7 +2248,7 @@ namespace TEN::Renderer
DrawDebris(view, pass); // Debris mostly originate from shatter statics.
}
// Sorted sprites are already collected at the beginning of frame.
// Sorted sprites already collected at beginning of frame.
if (sprites && pass != RendererPass::CollectTransparentFaces)
DrawSprites(view, pass);
@ -2512,14 +2509,14 @@ namespace TEN::Renderer
for (auto it = view.SortedStaticsToDraw.begin(); it != view.SortedStaticsToDraw.end(); it++)
{
std::vector<RendererStatic*> statics = it->second;
auto statics = it->second;
RendererStatic* refStatic = statics[0];
RendererObject& refStaticObj = GetStaticRendererObject(refStatic->ObjectNumber);
auto* refStatic = statics[0];
auto& refStaticObj = GetStaticRendererObject(refStatic->ObjectNumber);
if (refStaticObj.ObjectMeshes.size() == 0)
continue;
RendererMesh* refMesh = refStaticObj.ObjectMeshes[0];
auto* refMesh = refStaticObj.ObjectMeshes[0];
int staticsCount = (int)statics.size();
int bucketSize = INSTANCED_STATIC_MESH_BUCKET_SIZE;
@ -2532,13 +2529,13 @@ namespace TEN::Renderer
for (int s = baseStaticIndex; s < max; s++)
{
RendererStatic* current = statics[s];
RendererRoom* room = &_rooms[current->RoomNumber];
auto* current = statics[s];
auto* room = &_rooms[current->RoomNumber];
if (IgnoreReflectionPassForRoom(current->RoomNumber))
continue;
Matrix world = current->World;
auto world = current->World;
ReflectMatrixOptionally(world);
_stInstancedStaticMeshBuffer.StaticMeshes[instancesCount].World = world;
@ -2547,9 +2544,7 @@ namespace TEN::Renderer
_stInstancedStaticMeshBuffer.StaticMeshes[instancesCount].LightMode = (int)refMesh->LightMode;
if (rendererPass != RendererPass::GBuffer)
{
BindInstancedStaticLights(current->LightsToDraw, instancesCount);
}
instancesCount++;
}
@ -2560,21 +2555,16 @@ namespace TEN::Renderer
{
_cbInstancedStaticMeshBuffer.UpdateData(_stInstancedStaticMeshBuffer, _context.Get());
for (auto& bucket : refMesh->Buckets)
for (const auto& bucket : refMesh->Buckets)
{
if (bucket.NumVertices == 0)
{
continue;
}
int passes = rendererPass == RendererPass::Opaque && bucket.BlendMode == BlendMode::AlphaTest ? 2 : 1;
for (int p = 0; p < passes; p++)
{
if (!SetupBlendModeAndAlphaTest(bucket.BlendMode, rendererPass, p))
{
continue;
}
BindTexture(TextureRegister::ColorMap,
&std::get<0>(_staticTextures[bucket.Texture]),
@ -2594,18 +2584,17 @@ namespace TEN::Renderer
}
else
{
// Collect sorted blend modes faces ordered by room, if transparent pass
// Collect sorted blend modes faces ordered by room if doing transparent pass.
for (auto it = view.SortedStaticsToDraw.begin(); it != view.SortedStaticsToDraw.end(); it++)
{
std::vector<RendererStatic*> statics = it->second;
auto statics = it->second;
RendererStatic* refStatic = statics[0];
RendererObject& refStaticObj = GetStaticRendererObject(refStatic->ObjectNumber);
auto* refStatic = statics[0];
auto& refStaticObj = GetStaticRendererObject(refStatic->ObjectNumber);
if (refStaticObj.ObjectMeshes.size() == 0)
continue;
RendererMesh* refMesh = refStaticObj.ObjectMeshes[0];
auto* refMesh = refStaticObj.ObjectMeshes[0];
for (int i = 0; i < statics.size(); i++)
{
@ -2614,15 +2603,13 @@ namespace TEN::Renderer
auto& bucket = refMesh->Buckets[j];
if (bucket.NumVertices == 0)
{
continue;
}
if (IsSortedBlendMode(bucket.BlendMode))
{
for (int p = 0; p < bucket.Polygons.size(); p++)
{
RendererSortableObject object;
auto object = RendererSortableObject{};
object.ObjectType = RendererObjectType::Static;
object.Bucket = &bucket;
@ -3301,8 +3288,8 @@ namespace TEN::Renderer
{
for (int i = 0; i < view.TransparentObjectsToDraw.size(); i++)
{
RendererSortableObject* object = &view.TransparentObjectsToDraw[i];
RendererObjectType lastObjectType = (i > 0 ? view.TransparentObjectsToDraw[i - 1].ObjectType : RendererObjectType::Unknown);
auto* object = &view.TransparentObjectsToDraw[i];
auto lastObjectType = (i > 0 ? view.TransparentObjectsToDraw[i - 1].ObjectType : RendererObjectType::Unknown);
_sortedPolygonsVertices.clear();
_sortedPolygonsIndices.clear();
@ -3319,7 +3306,7 @@ namespace TEN::Renderer
view.TransparentObjectsToDraw[i].Bucket->BlendMode == object->Bucket->BlendMode &&
_sortedPolygonsIndices.size() + (view.TransparentObjectsToDraw[i].Polygon->Shape == 0 ? 6 : 3) < MAX_TRANSPARENT_VERTICES)
{
RendererSortableObject* currentObject = &view.TransparentObjectsToDraw[i];
auto* currentObject = &view.TransparentObjectsToDraw[i];
_sortedPolygonsIndices.bulk_push_back(
_roomsIndices.data(),
currentObject->Polygon->BaseIndex,
@ -3330,9 +3317,7 @@ namespace TEN::Renderer
DrawRoomSorted(object, lastObjectType, view);
if (i == view.TransparentObjectsToDraw.size())
{
return;
}
i--;
}
@ -3345,7 +3330,7 @@ namespace TEN::Renderer
view.TransparentObjectsToDraw[i].Bucket->BlendMode == object->Bucket->BlendMode &&
_sortedPolygonsIndices.size() + (view.TransparentObjectsToDraw[i].Polygon->Shape == 0 ? 6 : 3) < MAX_TRANSPARENT_VERTICES)
{
RendererSortableObject* currentObject = &view.TransparentObjectsToDraw[i];
auto* currentObject = &view.TransparentObjectsToDraw[i];
_sortedPolygonsIndices.bulk_push_back(
_moveablesIndices.data(),
currentObject->Polygon->BaseIndex,
@ -3356,9 +3341,7 @@ namespace TEN::Renderer
DrawItemSorted(object, lastObjectType, view);
if (i == view.TransparentObjectsToDraw.size())
{
return;
}
i--;
}
@ -3372,7 +3355,7 @@ namespace TEN::Renderer
view.TransparentObjectsToDraw[i].Bucket->BlendMode == object->Bucket->BlendMode &&
_sortedPolygonsIndices.size() + (view.TransparentObjectsToDraw[i].Polygon->Shape == 0 ? 6 : 3) < MAX_TRANSPARENT_VERTICES)
{
RendererSortableObject* currentObject = &view.TransparentObjectsToDraw[i];
auto* currentObject = &view.TransparentObjectsToDraw[i];
_sortedPolygonsIndices.bulk_push_back(
_staticsIndices.data(),
currentObject->Polygon->BaseIndex,
@ -3383,9 +3366,7 @@ namespace TEN::Renderer
DrawStaticSorted(object, lastObjectType, view);
if (i == view.TransparentObjectsToDraw.size())
{
return;
}
i--;
}
@ -3398,7 +3379,7 @@ namespace TEN::Renderer
view.TransparentObjectsToDraw[i].Bucket->BlendMode == object->Bucket->BlendMode &&
_sortedPolygonsIndices.size() + (view.TransparentObjectsToDraw[i].Polygon->Shape == 0 ? 6 : 3) < MAX_TRANSPARENT_VERTICES)
{
RendererSortableObject* currentObject = &view.TransparentObjectsToDraw[i];
auto* currentObject = &view.TransparentObjectsToDraw[i];
_sortedPolygonsIndices.bulk_push_back(
_staticsIndices.data(),
currentObject->Polygon->BaseIndex,
@ -3409,9 +3390,7 @@ namespace TEN::Renderer
DrawMoveableAsStaticSorted(object, lastObjectType, view);
if (i == view.TransparentObjectsToDraw.size())
{
return;
}
i--;
}
@ -3460,7 +3439,7 @@ namespace TEN::Renderer
uv2 = spr->Sprite->UV[2];
uv3 = spr->Sprite->UV[3];
Matrix world = GetWorldMatrixForSprite(currentObject->Sprite, view);
auto world = GetWorldMatrixForSprite(currentObject->Sprite, view);
Vertex v0;
v0.Position = Vector3::Transform(p0t, world);
@ -3637,7 +3616,7 @@ namespace TEN::Renderer
_shaderManager.Bind(Shader::Statics);
Matrix world = objectInfo->Static->World;
auto world = objectInfo->Static->World;
_stStatic.World = world;
_stStatic.Color = objectInfo->Static->Color;
@ -3675,7 +3654,7 @@ namespace TEN::Renderer
_shaderManager.Bind(Shader::Statics);
Matrix world = objectInfo->World;
auto world = objectInfo->World;
_stStatic.World = world;
_stStatic.Color = Vector4::One;

View file

@ -1285,19 +1285,23 @@ namespace TEN::Renderer
auto spriteMatrix = Matrix::Identity;
auto scaleMatrix = Matrix::CreateScale(sprite->Width * sprite->Scale, sprite->Height * sprite->Scale, sprite->Scale);
Vector3 spritePosition = sprite->pos;
auto spritePos = sprite->pos;
if (sprite->Type == SpriteType::ThreeD)
{
ReflectMatrixOptionally(spriteMatrix);
}
else
ReflectVectorOptionally(spritePosition);
{
ReflectVectorOptionally(spritePos);
}
switch (sprite->Type)
{
case SpriteType::Billboard:
{
auto cameraUp = Vector3(view.Camera.View._12, view.Camera.View._22, view.Camera.View._32);
spriteMatrix = scaleMatrix * Matrix::CreateRotationZ(sprite->Rotation) * Matrix::CreateBillboard(spritePosition, Camera.pos.ToVector3(), cameraUp);
spriteMatrix = scaleMatrix * Matrix::CreateRotationZ(sprite->Rotation) * Matrix::CreateBillboard(spritePos, Camera.pos.ToVector3(), cameraUp);
}
break;
@ -1306,7 +1310,7 @@ namespace TEN::Renderer
auto rotMatrix = Matrix::CreateRotationY(sprite->Rotation);
auto quadForward = Vector3(0.0f, 0.0f, 1.0f);
spriteMatrix = scaleMatrix * Matrix::CreateConstrainedBillboard(
spritePosition,
spritePos,
Camera.pos.ToVector3(),
sprite->ConstrainAxis,
nullptr,
@ -1316,9 +1320,9 @@ namespace TEN::Renderer
case SpriteType::LookAtBillboard:
{
auto tMatrix = Matrix::CreateTranslation(spritePosition);
auto translationMatrix = Matrix::CreateTranslation(spritePos);
auto rotMatrix = Matrix::CreateRotationZ(sprite->Rotation) * Matrix::CreateLookAt(Vector3::Zero, sprite->LookAtAxis, Vector3::UnitZ);
spriteMatrix = scaleMatrix * rotMatrix * tMatrix;
spriteMatrix = scaleMatrix * rotMatrix * translationMatrix;
}
break;
@ -1334,7 +1338,7 @@ namespace TEN::Renderer
{
const auto& room = _rooms[effect->RoomNumber];
Matrix world = effect->InterpolatedWorld;
auto world = effect->InterpolatedWorld;
ReflectMatrixOptionally(world);
_stStatic.World = world;

View file

@ -34,6 +34,7 @@ namespace TEN::Renderer
constexpr auto MenuLoadNumberLeftSide = 80;
constexpr auto MenuLoadNameLeftSide = 150;
constexpr auto MenuLoadTimestampRightSide = 600;
// Vertical spacing templates
constexpr auto MenuVerticalLineSpacing = 30;
@ -657,7 +658,7 @@ namespace TEN::Renderer
// Timestamp
sprintf(stringBuffer, g_GameFlow->GetString(STRING_SAVEGAME_TIMESTAMP), save.Hours, save.Minutes, save.Seconds);
AddString(MenuRightSideEntry, y, stringBuffer, PRINTSTRING_COLOR_WHITE, SF(selection == n));
AddString(MenuLoadTimestampRightSide, y, stringBuffer, PRINTSTRING_COLOR_WHITE, SF(selection == n));
}
GetNextLinePosition(&y);
@ -1225,7 +1226,7 @@ namespace TEN::Renderer
void Renderer::DrawDebugInfo(RenderView& view)
{
#ifdef TEST_BUILD
#if TEST_BUILD
if (CurrentLevel == 0)
{
AddString("TombEngine " + std::string(TEN_VERSION_STRING) + " test build - not for distribution",

View file

@ -359,9 +359,10 @@ namespace TEN::Renderer
void Renderer::CollectMirrors(RenderView& renderView)
{
// Collect mirrors first, because they are needed while collecting items
for (auto& mirror : g_Level.Mirrors)
// Collect mirrors first because they are needed while collecting moveables.
for (const auto& mirror : g_Level.Mirrors)
{
// TODO: Avoid LaraItem global.
if (mirror.RoomNumber != Camera.pos.RoomNumber && mirror.RoomNumber != LaraItem->RoomNumber)
continue;
@ -369,10 +370,9 @@ namespace TEN::Renderer
continue;
auto& rendererMirror = renderView.Mirrors.emplace_back();
rendererMirror.RoomNumber = mirror.RoomNumber;
rendererMirror.ReflectionMatrix = mirror.ReflectionMatrix;
rendererMirror.ReflectLara = mirror.ReflectLara;
rendererMirror.ReflectPlayer = mirror.ReflectPlayer;
rendererMirror.ReflectMoveables = mirror.ReflectMoveables;
rendererMirror.ReflectStatics = mirror.ReflectStatics;
rendererMirror.ReflectSprites = mirror.ReflectSprites;
@ -385,98 +385,100 @@ namespace TEN::Renderer
if (_rooms.size() < roomNumber)
return;
auto& room = _rooms[roomNumber];
auto* r = &g_Level.Rooms[room.RoomNumber];
auto& rendererRoom = _rooms[roomNumber];
const auto& room = g_Level.Rooms[rendererRoom.RoomNumber];
bool roomIsReflected = RoomIsReflected(renderView, roomNumber);
bool isRoomReflected = IsRoomReflected(renderView, roomNumber);
short itemNum = NO_VALUE;
for (itemNum = r->itemNumber; itemNum != NO_VALUE; itemNum = g_Level.Items[itemNum].NextItem)
short itemNumber = NO_VALUE;
for (itemNumber = room.itemNumber; itemNumber != NO_VALUE; itemNumber = g_Level.Items[itemNumber].NextItem)
{
auto* item = &g_Level.Items[itemNum];
const auto& item = g_Level.Items[itemNumber];
if (item->ObjectNumber == ID_LARA && itemNum == g_Level.Items[itemNum].NextItem)
if (item.ObjectNumber == ID_LARA && itemNumber == g_Level.Items[itemNumber].NextItem)
break;
if (item->Status == ITEM_INVISIBLE)
if (item.Status == ITEM_INVISIBLE)
continue;
if (item->ObjectNumber == ID_LARA && (SpotcamOverlay || SpotcamDontDrawLara))
if (item.ObjectNumber == ID_LARA && (SpotcamOverlay || SpotcamDontDrawLara))
continue;
if (item->ObjectNumber == ID_LARA && CurrentLevel == 0 && !g_GameFlow->IsLaraInTitleEnabled())
if (item.ObjectNumber == ID_LARA && CurrentLevel == 0 && !g_GameFlow->IsLaraInTitleEnabled())
continue;
if (!_moveableObjects[item->ObjectNumber].has_value())
if (!_moveableObjects[item.ObjectNumber].has_value())
continue;
auto& obj = _moveableObjects[item->ObjectNumber].value();
auto& obj = _moveableObjects[item.ObjectNumber].value();
if (obj.DoNotDraw)
continue;
// Clip object by frustum only if it doesn't cast shadows and is not in the mirror room.
// Otherwise we may see disappearing shadows or reflections if object gets out of frustum.
if (!roomIsReflected && obj.ShadowType == ShadowMode::None)
// Clip object by frustum only if it doesn't cast shadows and is not in mirror room,
// otherwise disappearing shadows or reflections may be seen if object gets out of frustum.
if (!isRoomReflected && obj.ShadowType == ShadowMode::None)
{
// Get all spheres and check if frustum intersects any of them.
auto spheres = GetSpheres(itemNum);
auto spheres = GetSpheres(itemNumber);
bool inFrustum = false;
for (int i = 0; !inFrustum, i < spheres.size(); i++)
{
// Blow up sphere radius by half for cases of too small calculated spheres.
if (renderView.Camera.Frustum.SphereInFrustum(spheres[i].Center, spheres[i].Radius * 1.5f))
inFrustum = true;
}
if (!inFrustum)
continue;
}
auto newItem = &_items[itemNum];
auto& newItem = _items[itemNumber];
newItem->ItemNumber = itemNum;
newItem->ObjectID = item->ObjectNumber;
newItem->Color = item->Model.Color;
newItem->Position = item->Pose.Position.ToVector3();
newItem->Translation = Matrix::CreateTranslation(newItem->Position.x, newItem->Position.y, newItem->Position.z);
newItem->Rotation = item->Pose.Orientation.ToRotationMatrix();
newItem->Scale = Matrix::CreateScale(1.0f);
newItem->World = newItem->Rotation * newItem->Translation;
newItem.ItemNumber = itemNumber;
newItem.ObjectID = item.ObjectNumber;
newItem.Color = item.Model.Color;
newItem.Position = item.Pose.Position.ToVector3();
newItem.Translation = Matrix::CreateTranslation(newItem.Position.x, newItem.Position.y, newItem.Position.z);
newItem.Rotation = item.Pose.Orientation.ToRotationMatrix();
newItem.Scale = Matrix::CreateScale(1.0f);
newItem.World = newItem.Rotation * newItem.Translation;
// Disable interpolation either when renderer slot or item slot has flag.
// Renderer slot has no interpolation flag set in case it is fetched for the first time (e.g. item first time in frustum).
newItem->DisableInterpolation = item->DisableInterpolation || newItem->DisableInterpolation;
// Renderer slot has no interpolation flag set in case it is fetched for first time (e.g. item first time in frustum).
newItem.DisableInterpolation = item.DisableInterpolation || newItem.DisableInterpolation;
if (newItem->DisableInterpolation)
if (newItem.DisableInterpolation)
{
// NOTE: Interpolation alwasy returns same result.
newItem->PrevPosition = newItem->Position;
newItem->PrevTranslation = newItem->Translation;
newItem->PrevRotation = newItem->Rotation;
newItem->PrevWorld = newItem->World;
// NOTE: Interpolation always returns same result.
newItem.PrevPosition = newItem.Position;
newItem.PrevTranslation = newItem.Translation;
newItem.PrevRotation = newItem.Rotation;
newItem.PrevWorld = newItem.World;
// Otherwise all frames until the next ControlPhase will not be interpolated.
newItem->DisableInterpolation = false;
// Otherwise all frames until next ControlPhase will not be interpolated.
newItem.DisableInterpolation = false;
for (int j = 0; j < MAX_BONES; j++)
newItem->PrevAnimTransforms[j] = newItem->AnimTransforms[j];
newItem.PrevAnimTransforms[j] = newItem.AnimTransforms[j];
}
// Force interpolation only for Lara in player freeze mode.
bool forceValue = g_GameFlow->CurrentFreezeMode == FreezeMode::Player && item->ObjectNumber == ID_LARA;
// Force interpolation only for player in player freeze mode.
bool forceValue = g_GameFlow->CurrentFreezeMode == FreezeMode::Player && item.ObjectNumber == ID_LARA;
newItem->InterpolatedPosition = Vector3::Lerp(newItem->PrevPosition, newItem->Position, GetInterpolationFactor(forceValue));
newItem->InterpolatedTranslation = Matrix::Lerp(newItem->PrevTranslation, newItem->Translation, GetInterpolationFactor(forceValue));
newItem->InterpolatedRotation = Matrix::Lerp(newItem->InterpolatedRotation, newItem->Rotation, GetInterpolationFactor(forceValue));
newItem->InterpolatedWorld = Matrix::Lerp(newItem->PrevWorld, newItem->World, GetInterpolationFactor(forceValue));
newItem.InterpolatedPosition = Vector3::Lerp(newItem.PrevPosition, newItem.Position, GetInterpolationFactor(forceValue));
newItem.InterpolatedTranslation = Matrix::Lerp(newItem.PrevTranslation, newItem.Translation, GetInterpolationFactor(forceValue));
newItem.InterpolatedRotation = Matrix::Lerp(newItem.InterpolatedRotation, newItem.Rotation, GetInterpolationFactor(forceValue));
newItem.InterpolatedWorld = Matrix::Lerp(newItem.PrevWorld, newItem.World, GetInterpolationFactor(forceValue));
for (int j = 0; j < MAX_BONES; j++)
newItem->InterpolatedAnimTransforms[j] = Matrix::Lerp(newItem->PrevAnimTransforms[j], newItem->AnimTransforms[j], GetInterpolationFactor(forceValue));
newItem.InterpolatedAnimTransforms[j] = Matrix::Lerp(newItem.PrevAnimTransforms[j], newItem.AnimTransforms[j], GetInterpolationFactor(forceValue));
CalculateLightFades(newItem);
CollectLightsForItem(newItem);
CalculateLightFades(&newItem);
CollectLightsForItem(&newItem);
room.ItemsToDraw.push_back(newItem);
rendererRoom.ItemsToDraw.push_back(&newItem);
}
}
@ -491,7 +493,7 @@ namespace TEN::Renderer
if (r->mesh.empty())
return;
bool roomIsReflected = RoomIsReflected(renderView, roomNumber);
bool isRoomReflected = IsRoomReflected(renderView, roomNumber);
for (int i = 0; i < room.Statics.size(); i++)
{
@ -521,7 +523,7 @@ namespace TEN::Renderer
if (obj.ObjectMeshes.empty())
continue;
if (!roomIsReflected && !renderView.Camera.Frustum.SphereInFrustum(mesh->Sphere.Center, mesh->Sphere.Radius))
if (!isRoomReflected && !renderView.Camera.Frustum.SphereInFrustum(mesh->Sphere.Center, mesh->Sphere.Radius))
continue;
// Collect the lights

View file

@ -600,10 +600,11 @@ namespace TEN::Renderer
return rendererItem->BoneOrientations[boneID];
}
bool Renderer::RoomIsReflected(RenderView& renderView, int roomNumber)
bool Renderer::IsRoomReflected(RenderView& renderView, int roomNumber)
{
for (auto& mirror : renderView.Mirrors)
for (const auto& mirror : renderView.Mirrors)
{
// TODO: Avoid LaraItem global.
if (roomNumber == mirror.RoomNumber && (Camera.pos.RoomNumber == mirror.RoomNumber || LaraItem->RoomNumber == mirror.RoomNumber))
return true;
}

View file

@ -1,7 +1,6 @@
#include "framework.h"
#include <string>
#include <memory>
#include <filesystem>
// TODO: To framework.
#include <random>
#include <d3dcompiler.h>

View file

@ -111,7 +111,7 @@ void Renderer::UpdateLaraAnimations(bool force)
auto frameData = GetFrameInterpData(*LaraItem);
UpdateAnimation(&rItem, playerObject, frameData, mask);
auto gunType = Lara.Control.Weapon.GunType;
auto gunType = Lara.Control.Weapon.GunType;
auto handStatus = Lara.Control.HandStatus;
// HACK: Treat binoculars as two-handed weapon.
@ -286,8 +286,9 @@ void Renderer::UpdateLaraAnimations(bool force)
rItem.DoneAnimations = true;
}
void TEN::Renderer::Renderer::DrawLara(RenderView& view, RendererPass rendererPass)
void Renderer::DrawLara(RenderView& view, RendererPass rendererPass)
{
// TODO: Avoid Lara global.
// Don't draw player if using optics (but still draw reflections).
if (Lara.Control.Look.OpticRange != 0 && _currentMirror == nullptr)
return;

View file

@ -129,7 +129,6 @@ namespace TEN::Renderer
DrawTriangles(3, 0);
_doingFullscreenPass = false;
}

View file

@ -1,20 +1,17 @@
#pragma once
#include <SimpleMath.h>
namespace TEN::Renderer::Structures
{
using namespace DirectX;
using namespace DirectX::SimpleMath;
struct RendererMirror
{
short RoomNumber;
Plane Plane;
Matrix ReflectionMatrix;
bool ReflectLara;
bool ReflectMoveables;
bool ReflectStatics;
bool ReflectSprites;
bool ReflectLights;
int RoomNumber = 0;
Plane Plane = SimpleMath::Plane();
Matrix ReflectionMatrix = Matrix::Identity;
bool ReflectPlayer = false;
bool ReflectMoveables = false;
bool ReflectStatics = false;
bool ReflectSprites = false;
bool ReflectLights = false;
};
}

View file

@ -1,6 +1,5 @@
#pragma once
#include <wrl/client.h>
#include <d3d11.h>
#include <utility>
using Microsoft::WRL::ComPtr;
@ -18,25 +17,25 @@ namespace TEN::Renderer::Structures
struct RendererPixelShaderAndBlob
{
ComPtr<ID3D11PixelShader> Shader = nullptr;
ComPtr<ID3D10Blob> Blob;
ComPtr<ID3D10Blob> Blob = nullptr;
};
struct RendererVertexShaderAndBlob
{
ComPtr<ID3D11VertexShader> Shader = nullptr;
ComPtr<ID3D10Blob> Blob;
ComPtr<ID3D10Blob> Blob = nullptr;
};
struct RendererComputeShaderAndBlob
{
ComPtr<ID3D11ComputeShader> Shader = nullptr;
ComPtr<ID3D10Blob> Blob;
ComPtr<ID3D10Blob> Blob = nullptr;
};
struct RendererShader
{
RendererPixelShaderAndBlob Pixel;
RendererVertexShaderAndBlob Vertex;
RendererComputeShaderAndBlob Compute;
RendererPixelShaderAndBlob Pixel = {};
RendererVertexShaderAndBlob Vertex = {};
RendererComputeShaderAndBlob Compute = {};
};
}

View file

@ -31,9 +31,9 @@ namespace TEN::Scripting
"ammoUsed", &Statistics::AmmoUsed,
/*** Distance traveled.
@tfield int traveledDistance amount of traveled distance in world units. One meter is 420 world units.
@tfield int distanceTraveled amount of traveled distance in world units. One meter is 420 world units.
*/
"traveledDistance", &Statistics::Distance,
"distanceTraveled", &Statistics::Distance,
/*** Health packs used.
@tfield int healthPacksUsed amount of used medipacks.

View file

@ -1522,7 +1522,6 @@ void LoadBoxes()
void LoadMirrors()
{
int mirrorCount = ReadCount();
TENLog("Mirror count: " + std::to_string(mirrorCount), LogLevel::Info);
g_Level.Mirrors.reserve(mirrorCount);
@ -1530,27 +1529,20 @@ void LoadMirrors()
{
auto& mirror = g_Level.Mirrors.emplace_back();
mirror.RoomNumber = ReadInt16();
mirror.RoomNumber = ReadInt16(); // TODO: Write Int32 to level instead. Short isn't used for room numbers anymore.
mirror.Plane.x = ReadFloat();
mirror.Plane.y = ReadFloat();
mirror.Plane.z = ReadFloat();
mirror.Plane.w = ReadFloat();
mirror.ReflectLara = ReadBool();
mirror.ReflectPlayer = ReadBool();
mirror.ReflectMoveables = ReadBool();
mirror.ReflectStatics = ReadBool();
mirror.ReflectSprites = ReadBool();
mirror.ReflectLights = ReadBool();
mirror.Enabled = true;
Plane plane = Plane(
Vector3(mirror.Plane.x,
mirror.Plane.y,
mirror.Plane.z),
mirror.Plane.w);
mirror.ReflectionMatrix = Matrix::CreateReflection(plane);
mirror.ReflectionMatrix = Matrix::CreateReflection(mirror.Plane);
}
}

View file

@ -85,17 +85,18 @@ struct MESH
std::vector<BUCKET> buckets;
};
struct MirrorInfo
struct MirrorData
{
short RoomNumber;
Vector4 Plane;
Matrix ReflectionMatrix;
bool ReflectLara;
bool ReflectMoveables;
bool ReflectStatics;
bool ReflectLights;
bool ReflectSprites;
bool Enabled;
int RoomNumber = 0;
Plane Plane = SimpleMath::Plane();
Matrix ReflectionMatrix = Matrix::Identity;
bool Enabled = false;
bool ReflectPlayer = false;
bool ReflectMoveables = false;
bool ReflectStatics = false;
bool ReflectLights = false;
bool ReflectSprites = false;
};
// LevelData
@ -136,7 +137,7 @@ struct LEVEL
std::vector<int> LoopedEventSetIndices = {};
std::vector<AI_OBJECT> AIObjects = {};
std::vector<SPRITE> Sprites = {};
std::vector<MirrorInfo> Mirrors = {};
std::vector<MirrorData> Mirrors = {};
// Texture data
TEXTURE SkyTexture = {};

View file

@ -6,11 +6,11 @@
#define TE_REVISION_NUMBER 0
#define TEN_MAJOR_VERSION 1
#define TEN_MINOR_VERSION 6
#define TEN_MINOR_VERSION 7
#define TEN_BUILD_NUMBER 0
#define TEN_REVISION_NUMBER 7
#define TEN_REVISION_NUMBER 0
#define TEST_BUILD 1
#define TEST_BUILD 0
#define TOSTR(x) #x
#define MAKE_VERSION_STRING(major, minor, build, revision) TOSTR(major) "." TOSTR(minor) "." TOSTR(build) "." TOSTR(revision)