Skip to content

WIP: Conditional Relight#1063

Draft
Nickelony wants to merge 2 commits intodevelopfrom
Nickelony/Conditional-Relight
Draft

WIP: Conditional Relight#1063
Nickelony wants to merge 2 commits intodevelopfrom
Nickelony/Conditional-Relight

Conversation

@Nickelony
Copy link
Collaborator

No description provided.

@Nickelony Nickelony requested a review from Copilot September 20, 2025 11:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements conditional relighting functionality to optimize room geometry operations by only performing lighting calculations when necessary.

  • Adds a PendingRelight property to track rooms that need lighting updates
  • Introduces a Rebuild method that conditionally performs relighting based on current editor mode
  • Replaces direct BuildGeometry calls with Rebuild calls throughout the codebase to respect the conditional lighting behavior

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
TombLib/TombLib/LevelData/RoomGeometry.cs Removes highQualityLighting parameter from Build method and removes automatic relighting call
TombLib/TombLib/LevelData/Room.cs Adds PendingRelight property and Rebuild method with conditional relighting logic
TombLib/TombLib/LevelData/Level.cs Updates texture removal to use Rebuild method
TombLib/TombLib/LevelData/IO/PrjLoader.cs Updates project loading to use Rebuild method
TombLib/TombLib/LevelData/IO/Prj2Loader.cs Updates project loading to use Rebuild method
TombEditor/Undo.cs Updates undo operations to use appropriate lighting methods
TombEditor/Forms/FormTextureRemap.cs Updates texture remapping to use Rebuild method
TombEditor/EditorActions.cs Updates all geometry operations to use Rebuild with conditional relighting
TombEditor/Editor.cs Adds ShouldRelight property and automatic relighting when switching to lighting mode

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1326 to +1327
if (_editor.ShouldRelight)
room.RebuildLighting(_editor.Configuration.Rendering3D_HighQualityLightPreview);
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a LightInstance is deleted while not in Lighting mode, the room lighting becomes stale but the PendingRelight flag is not set to true. This means the lighting won't be refreshed when switching to Lighting mode. Since PendingRelight has a private setter, the proper fix would be to either call room.Rebuild(relight: false, highQualityLighting: false) when ShouldRelight is false, or add a public method to Room that sets PendingRelight to true. The same issue likely affects light movement and rotation operations in RebuildLightsForObject.

Suggested change
if (_editor.ShouldRelight)
room.RebuildLighting(_editor.Configuration.Rendering3D_HighQualityLightPreview);
if (_editor.ShouldRelight)
{
room.RebuildLighting(_editor.Configuration.Rendering3D_HighQualityLightPreview);
}
else
{
// Ensure lighting will be refreshed later even when not currently in Lighting mode.
// This avoids stale lighting by marking the room for a future relight.
room.Rebuild(relight: false, highQualityLighting: false);
}

Copilot uses AI. Check for mistakes.
// Rebuild lighting!
if (UndoObject is LightInstance)
Room.BuildGeometry();
Room.RebuildLighting(parent.Editor.Configuration.Rendering3D_HighQualityLightPreview);
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The undo operation for LightInstance transformations unconditionally rebuilds lighting without checking ShouldRelight. For consistency with the conditional relighting optimization, this should check parent.Editor.ShouldRelight and only rebuild lighting when in Lighting mode, otherwise marking the room as PendingRelight.

Suggested change
Room.RebuildLighting(parent.Editor.Configuration.Rendering3D_HighQualityLightPreview);
{
if (Parent.Editor.ShouldRelight)
Room.RebuildLighting(Parent.Editor.Configuration.Rendering3D_HighQualityLightPreview);
else
Room.PendingRelight = true;
}

Copilot uses AI. Check for mistakes.
@Nickelony Nickelony changed the title Conditional Relight WIP: Conditional Relight Feb 23, 2026
@Nickelony Nickelony added work in progress The Pull Request is not finished yet or needs some extra work done to it. labels Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

work in progress The Pull Request is not finished yet or needs some extra work done to it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants