Skip to content

fix(iss): fix cell change detection logic#1095

Merged
alandtse merged 2 commits into
community-shaders:devfrom
sicsix:iss_cull_fix
May 27, 2025
Merged

fix(iss): fix cell change detection logic#1095
alandtse merged 2 commits into
community-shaders:devfrom
sicsix:iss_cull_fix

Conversation

@sicsix
Copy link
Copy Markdown
Collaborator

@sicsix sicsix commented May 27, 2025

  • Fixes issue where detection of cell change was not functioning correctly and it would revert to broken vanilla culling behaviour when leaving and re-entering the same interior cell
  • Skinned meshes are now ignored when forcing double sided rendering interiors, saving performance and fixing shadowing issues on actors
  • Settings are now savable

Summary by CodeRabbit

  • New Features
    • Added options to load, save, and restore default settings for interior sun shadows.
  • Improvements
    • Clarified the tooltip for the "Force Double-Sided Rendering" option to better explain its effect.
    • Enhanced the logic for determining when to use two-sided rendering for shadows.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2025

Walkthrough

The changes introduce settings management methods to the InteriorSunShadows feature, update tooltip text for a rendering option, and refine logic for sun shadow rendering in interiors. The code now supports loading, saving, and resetting settings via JSON, and adjusts the conditions for enabling two-sided rendering and handling cell/portal graph states.

Changes

Files Change Summary
src/Features/InteriorSunShadows.cpp, src/Features/InteriorSunShadows.h Added LoadSettings, SaveSettings, and RestoreDefaultSettings methods; refactored rendering and culling logic; updated tooltip text; modified two-sided rendering condition logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant InteriorSunShadows
    participant JSON

    User->>InteriorSunShadows: LoadSettings(json)
    InteriorSunShadows->>JSON: Read settings

    User->>InteriorSunShadows: SaveSettings(json)
    InteriorSunShadows->>JSON: Write settings

    User->>InteriorSunShadows: RestoreDefaultSettings()
    InteriorSunShadows->>InteriorSunShadows: Reset settings to default
Loading

Possibly related PRs

Suggested reviewers

  • alandtse
  • doodlum

Poem

In the sunlit halls where shadows play,
Settings now can save the day.
Two-sided checks, a tooltip bright,
JSON whispers through the night.
A bunny hops, with code in tow—
Shadows rendered, settings aglow!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b7f208 and b5f4f17.

📒 Files selected for processing (2)
  • src/Features/InteriorSunShadows.cpp (2 hunks)
  • src/Features/InteriorSunShadows.h (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/Features/InteriorSunShadows.cpp (3)
src/Features/VolumetricLighting.cpp (6)
  • LoadSettings (130-133)
  • LoadSettings (130-130)
  • SaveSettings (135-138)
  • SaveSettings (135-135)
  • RestoreDefaultSettings (140-145)
  • RestoreDefaultSettings (140-140)
src/Features/LightLimitFix.cpp (6)
  • LoadSettings (252-255)
  • LoadSettings (252-252)
  • SaveSettings (257-260)
  • SaveSettings (257-257)
  • RestoreDefaultSettings (262-265)
  • RestoreDefaultSettings (262-262)
src/Features/InteriorSunShadows.h (7)
  • o_json (15-15)
  • o_json (16-16)
  • cell (58-58)
  • cell (85-85)
  • singleton (6-10)
  • portalGraph (81-81)
  • dirLight (39-39)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build plugin and addons
🔇 Additional comments (5)
src/Features/InteriorSunShadows.h (2)

15-17: LGTM! Consistent settings management interface.

The virtual method declarations follow the established pattern used by other features in the codebase and properly override the base Feature class methods for settings serialization.


46-47: LGTM! Improved logic aligns with PR objectives.

The refined condition for renderTwoSided correctly implements the PR's goal of ignoring skinned meshes when forcing double-sided rendering. The logic now enables two-sided rendering when:

  • The shader has the kTwoSided flag set, OR
  • Both kAssumeShadowmask and kSkinned flags are absent

This change should resolve shadowing problems on actors by excluding skinned meshes from forced double-sided rendering.

src/Features/InteriorSunShadows.cpp (3)

15-15: LGTM! More accurate technical description.

The updated tooltip text correctly describes the functionality as "disables backface culling" rather than "forcing double-sided vertices", which is more technically precise.


20-33: LGTM! Standard settings management implementation.

The settings methods follow the exact same pattern used by other features (LightLimitFix, VolumetricLighting) in the codebase:

  • LoadSettings: Direct assignment from JSON
  • SaveSettings: Direct assignment to JSON
  • RestoreDefaultSettings: Reset to default-constructed state

This consistency is excellent for maintainability.


92-104: LGTM! Improved robustness for cell change detection.

The refactored logic addresses the cell change detection issues mentioned in the PR objectives:

  1. Enhanced null checking: Now properly validates cell, isInteriorWithSun, loadedData, and portalGraph before proceeding
  2. Better state management: currentCell is correctly set to nullptr when conditions aren't met, preventing stale state
  3. Proper array clearing: The ClearArrays() call is appropriately gated by the arraysCleared flag

This should fix the issue where the system reverted to vanilla culling behavior when leaving and re-entering the same interior cell.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

✅ A pre-release build is available for this PR:
Download

@alandtse alandtse merged commit ad6e478 into community-shaders:dev May 27, 2025
9 checks passed
alandtse pushed a commit to alandtse/open-shaders that referenced this pull request Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants