mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Added logic for hiding selectively reflecting moveables and statics;
Added enabled flag for disabling mirrros in the future with LUA;
This commit is contained in:
parent
c5f10777e7
commit
3e6e9cb61e
5 changed files with 50 additions and 6 deletions
|
@ -475,9 +475,10 @@ namespace TEN::Renderer
|
|||
void Renderer::DrawRats(RenderView& view, RendererPass rendererPass)
|
||||
{
|
||||
if (!Objects[ID_RATS_EMITTER].loaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_currentMirror != nullptr && !_currentMirror->ReflectMoveables)
|
||||
return;
|
||||
|
||||
if (rendererPass == RendererPass::CollectTransparentFaces)
|
||||
{
|
||||
|
@ -734,6 +735,9 @@ namespace TEN::Renderer
|
|||
if (!Objects[ID_BATS_EMITTER].loaded)
|
||||
return;
|
||||
|
||||
if (_currentMirror != nullptr && !_currentMirror->ReflectMoveables)
|
||||
return;
|
||||
|
||||
auto& mesh = *GetMesh(Objects[ID_BATS_EMITTER].meshIndex + (GlobalCounter & 3));
|
||||
|
||||
if (rendererPass == RendererPass::CollectTransparentFaces)
|
||||
|
@ -858,6 +862,9 @@ namespace TEN::Renderer
|
|||
if (!Objects[ID_LITTLE_BEETLE].loaded)
|
||||
return;
|
||||
|
||||
if (_currentMirror != nullptr && !_currentMirror->ReflectMoveables)
|
||||
return;
|
||||
|
||||
auto& mesh = *GetMesh(Objects[ID_LITTLE_BEETLE].meshIndex + ((Wibble >> 2) % 2));
|
||||
|
||||
if (rendererPass == RendererPass::CollectTransparentFaces)
|
||||
|
@ -986,6 +993,9 @@ namespace TEN::Renderer
|
|||
if (!Objects[ID_LOCUSTS].loaded)
|
||||
return;
|
||||
|
||||
if (_currentMirror != nullptr && !_currentMirror->ReflectMoveables)
|
||||
return;
|
||||
|
||||
if (rendererPass == RendererPass::CollectTransparentFaces)
|
||||
{
|
||||
auto* obj = &Objects[ID_LOCUSTS];
|
||||
|
@ -2423,8 +2433,15 @@ namespace TEN::Renderer
|
|||
|
||||
for (auto room : view.RoomsToDraw)
|
||||
{
|
||||
if (_currentMirror != nullptr && _currentMirror->RealRoom != room->RoomNumber)
|
||||
continue;
|
||||
|
||||
for (auto itemToDraw : room->ItemsToDraw)
|
||||
{
|
||||
if (_currentMirror != nullptr &&
|
||||
(g_Level.Items[itemToDraw->ItemNumber].Flags & IFLAG_CLEAR_BODY))
|
||||
continue;
|
||||
|
||||
switch (itemToDraw->ObjectID)
|
||||
{
|
||||
case ID_LARA:
|
||||
|
@ -2439,10 +2456,14 @@ namespace TEN::Renderer
|
|||
case ID_WATERFALL6:
|
||||
case ID_WATERFALLSS1:
|
||||
case ID_WATERFALLSS2:
|
||||
if (_currentMirror != nullptr && !_currentMirror->ReflectMoveables)
|
||||
continue;
|
||||
DrawWaterfalls(itemToDraw, view, 10, rendererPass);
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (_currentMirror != nullptr && !_currentMirror->ReflectMoveables)
|
||||
continue;
|
||||
DrawAnimatingItem(itemToDraw, view, rendererPass);
|
||||
break;
|
||||
}
|
||||
|
@ -2545,9 +2566,10 @@ namespace TEN::Renderer
|
|||
void Renderer::DrawStatics(RenderView& view, RendererPass rendererPass)
|
||||
{
|
||||
if (_staticTextures.size() == 0 || view.SortedStaticsToDraw.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_currentMirror != nullptr && !_currentMirror->ReflectStatics)
|
||||
return;
|
||||
|
||||
if (rendererPass != RendererPass::CollectTransparentFaces)
|
||||
{
|
||||
|
@ -2676,9 +2698,7 @@ namespace TEN::Renderer
|
|||
RendererRoom* room = &_rooms[current->RoomNumber];
|
||||
|
||||
if (_currentMirror != nullptr && current->RoomNumber != _currentMirror->RealRoom)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Matrix world = current->World;
|
||||
if (_currentMirror != nullptr)
|
||||
|
|
|
@ -27,16 +27,24 @@ namespace TEN::Renderer
|
|||
|
||||
void Renderer::CollectRooms(RenderView& renderView, bool onlyRooms)
|
||||
{
|
||||
// Collect mirrors first, because they are needed while collecting items
|
||||
for (auto& mirror : g_Level.Mirrors)
|
||||
{
|
||||
if (mirror.RealRoom != Camera.pos.RoomNumber)
|
||||
continue;
|
||||
|
||||
if (!mirror.Enabled)
|
||||
continue;
|
||||
|
||||
auto& rendererMirror = renderView.Mirrors.emplace_back();
|
||||
|
||||
rendererMirror.RealRoom = mirror.RealRoom;
|
||||
rendererMirror.VirtualRoom = mirror.VirtualRoom;
|
||||
rendererMirror.ReflectionMatrix = mirror.ReflectionMatrix;
|
||||
rendererMirror.ReflectLara = mirror.ReflectLara;
|
||||
rendererMirror.ReflectMoveables = mirror.ReflectMoveables;
|
||||
rendererMirror.ReflectStatics = mirror.ReflectStatics;
|
||||
rendererMirror.ReflectLights = mirror.ReflectLights;
|
||||
}
|
||||
|
||||
constexpr auto VIEW_PORT = Vector4(-1.0f, -1.0f, 1.0f, 1.0f);
|
||||
|
|
|
@ -12,5 +12,9 @@ namespace TEN::Renderer::Structures
|
|||
short VirtualRoom;
|
||||
Plane Plane;
|
||||
Matrix ReflectionMatrix;
|
||||
bool ReflectLara;
|
||||
bool ReflectMoveables;
|
||||
bool ReflectStatics;
|
||||
bool ReflectLights;
|
||||
};
|
||||
}
|
|
@ -1536,6 +1536,13 @@ void LoadMirrors()
|
|||
mirror.MirrorPlane.z = ReadFloat();
|
||||
mirror.MirrorPlane.w = ReadFloat();
|
||||
|
||||
mirror.ReflectLara = ReadBool();
|
||||
mirror.ReflectMoveables = ReadBool();
|
||||
mirror.ReflectStatics = ReadBool();
|
||||
mirror.ReflectLights = ReadBool();
|
||||
|
||||
mirror.Enabled = true;
|
||||
|
||||
Plane plane = Plane(
|
||||
Vector3(mirror.MirrorPlane.x,
|
||||
mirror.MirrorPlane.y,
|
||||
|
|
|
@ -91,6 +91,11 @@ struct MirrorInfo
|
|||
short VirtualRoom;
|
||||
Vector4 MirrorPlane;
|
||||
Matrix ReflectionMatrix;
|
||||
bool ReflectLara;
|
||||
bool ReflectMoveables;
|
||||
bool ReflectStatics;
|
||||
bool ReflectLights;
|
||||
bool Enabled;
|
||||
};
|
||||
|
||||
// LevelData
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue