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**. 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 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 ### Bug fixes
* Significantly improved renderer performance. * 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 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 not switching off correctly after flyby.
* Fixed binocular or lasersight camera transitions. * 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 Lara's Home entry not working.
* Fixed exploding TR3 bosses. * Fixed exploding TR3 bosses.
* Fixed original issue with deactivation of Dart Emitter. * 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 not_luadoc = true
local version = "1.6" local version = "1.7"
project = " TombEngine" project = " TombEngine"
title = "TombEngine " .. version .. " Lua API" title = "TombEngine " .. version .. " Lua API"
description = "TombEngine " .. version .. " scripting interface" description = "TombEngine " .. version .. " scripting interface"

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

View file

@ -1,12 +1,10 @@
#pragma once #pragma once
#include "Specific/clock.h" #include "Specific/clock.h"
struct ItemInfo; struct ItemInfo;
constexpr auto OPTICS_FADE_SPEED = 6.0f / FPS; constexpr auto OPTICS_FADE_SPEED = 6.0f / FPS;
constexpr auto OPTICS_RANGE_DEFAULT = ANGLE(0.7f); 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); bool HandlePlayerOptics(ItemInfo& item);

View file

@ -20,6 +20,7 @@
#include "Math/Math.h" #include "Math/Math.h"
#include "Scripting/Include/ScriptInterfaceGame.h" #include "Scripting/Include/ScriptInterfaceGame.h"
#include "Sound/sound.h" #include "Sound/sound.h"
#include "Specific/winmain.h"
using namespace TEN::Collision::Floordata; using namespace TEN::Collision::Floordata;
using namespace TEN::Collision::Point; using namespace TEN::Collision::Point;
@ -330,6 +331,11 @@ void TestForObjectOnLedge(ItemInfo* item, CollisionInfo* coll)
bool TestLaraPosition(const ObjectCollisionBounds& bounds, ItemInfo* item, ItemInfo* laraItem) 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; auto deltaOrient = laraItem->Pose.Orientation - item->Pose.Orientation;
if (deltaOrient.x < bounds.OrientConstraint.first.x || deltaOrient.x > bounds.OrientConstraint.second.x || 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 || 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 pos = (laraItem->Pose.Position - item->Pose.Position).ToVector3();
auto rotMatrix = item->Pose.Orientation.ToRotationMatrix(); auto rotMatrix = item->Pose.Orientation.ToRotationMatrix();
// This solves once for all the minus sign hack of CreateFromYawPitchRoll. // NOTE: Transpose = faster inverse.
// 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.
rotMatrix = rotMatrix.Transpose(); rotMatrix = rotMatrix.Transpose();
pos = Vector3::Transform(pos, rotMatrix); pos = Vector3::Transform(pos, rotMatrix);

View file

@ -300,8 +300,11 @@ void ControlWaterfallMist(short itemNumber);
void TriggerWaterfallMist(const ItemInfo& item); void TriggerWaterfallMist(const ItemInfo& item);
void KillAllCurrentItems(short itemNumber); void KillAllCurrentItems(short itemNumber);
void TriggerDynamicLight(int x, int y, int z, short falloff, byte r, byte g, byte b); 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 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 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 TriggerRocketFlame(int x, int y, int z, int xv, int yv, int zv, int itemNumber);
void TriggerRocketSmoke(int x, int y, int z); void TriggerRocketSmoke(int x, int y, int z);
void TriggerFlashSmoke(int x, int y, int z, short roomNumber); void TriggerFlashSmoke(int x, int y, int z, short roomNumber);

View file

@ -520,11 +520,11 @@ namespace TEN::Renderer
void CreateSSAONoiseTexture(); void CreateSSAONoiseTexture();
void InitializeSMAA(); 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) inline void ReflectVectorOptionally(Vector3& vector)

View file

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

View file

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

View file

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

View file

@ -600,10 +600,11 @@ namespace TEN::Renderer
return rendererItem->BoneOrientations[boneID]; 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)) if (roomNumber == mirror.RoomNumber && (Camera.pos.RoomNumber == mirror.RoomNumber || LaraItem->RoomNumber == mirror.RoomNumber))
return true; return true;
} }

View file

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

View file

@ -286,8 +286,9 @@ void Renderer::UpdateLaraAnimations(bool force)
rItem.DoneAnimations = true; 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). // Don't draw player if using optics (but still draw reflections).
if (Lara.Control.Look.OpticRange != 0 && _currentMirror == nullptr) if (Lara.Control.Look.OpticRange != 0 && _currentMirror == nullptr)
return; return;

View file

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

View file

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

View file

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

View file

@ -31,9 +31,9 @@ namespace TEN::Scripting
"ammoUsed", &Statistics::AmmoUsed, "ammoUsed", &Statistics::AmmoUsed,
/*** Distance traveled. /*** 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. /*** Health packs used.
@tfield int healthPacksUsed amount of used medipacks. @tfield int healthPacksUsed amount of used medipacks.

View file

@ -1522,7 +1522,6 @@ void LoadBoxes()
void LoadMirrors() void LoadMirrors()
{ {
int mirrorCount = ReadCount(); int mirrorCount = ReadCount();
TENLog("Mirror count: " + std::to_string(mirrorCount), LogLevel::Info); TENLog("Mirror count: " + std::to_string(mirrorCount), LogLevel::Info);
g_Level.Mirrors.reserve(mirrorCount); g_Level.Mirrors.reserve(mirrorCount);
@ -1530,27 +1529,20 @@ void LoadMirrors()
{ {
auto& mirror = g_Level.Mirrors.emplace_back(); 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.x = ReadFloat();
mirror.Plane.y = ReadFloat(); mirror.Plane.y = ReadFloat();
mirror.Plane.z = ReadFloat(); mirror.Plane.z = ReadFloat();
mirror.Plane.w = ReadFloat(); mirror.Plane.w = ReadFloat();
mirror.ReflectLara = ReadBool(); mirror.ReflectPlayer = ReadBool();
mirror.ReflectMoveables = ReadBool(); mirror.ReflectMoveables = ReadBool();
mirror.ReflectStatics = ReadBool(); mirror.ReflectStatics = ReadBool();
mirror.ReflectSprites = ReadBool(); mirror.ReflectSprites = ReadBool();
mirror.ReflectLights = ReadBool(); mirror.ReflectLights = ReadBool();
mirror.Enabled = true; mirror.Enabled = true;
Plane plane = Plane( mirror.ReflectionMatrix = Matrix::CreateReflection(mirror.Plane);
Vector3(mirror.Plane.x,
mirror.Plane.y,
mirror.Plane.z),
mirror.Plane.w);
mirror.ReflectionMatrix = Matrix::CreateReflection(plane);
} }
} }

View file

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

View file

@ -6,11 +6,11 @@
#define TE_REVISION_NUMBER 0 #define TE_REVISION_NUMBER 0
#define TEN_MAJOR_VERSION 1 #define TEN_MAJOR_VERSION 1
#define TEN_MINOR_VERSION 6 #define TEN_MINOR_VERSION 7
#define TEN_BUILD_NUMBER 0 #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 TOSTR(x) #x
#define MAKE_VERSION_STRING(major, minor, build, revision) TOSTR(major) "." TOSTR(minor) "." TOSTR(build) "." TOSTR(revision) #define MAKE_VERSION_STRING(major, minor, build, revision) TOSTR(major) "." TOSTR(minor) "." TOSTR(build) "." TOSTR(revision)