Skip to content

fix(SkySync): fix CPU side moon luminance calcs#1348

Merged
alandtse merged 2 commits into
community-shaders:devfrom
sicsix:ss-fixmoonluminancecalcs
Aug 1, 2025
Merged

fix(SkySync): fix CPU side moon luminance calcs#1348
alandtse merged 2 commits into
community-shaders:devfrom
sicsix:ss-fixmoonluminancecalcs

Conversation

@sicsix
Copy link
Copy Markdown
Collaborator

@sicsix sicsix commented Aug 1, 2025

  • added call to update after setting local rotation to update world rotation, fixes incorrect light level calcs on CPU
  • added extra null check to OnNewClimate

Summary by CodeRabbit

  • Bug Fixes
    • Improved lighting updates for smoother transitions after changes to the sun's rotation.
    • Enhanced climate synchronization reliability by ensuring features are only updated when enabled and all necessary data is present.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 1, 2025

Walkthrough

The changes introduce an explicit update call to the sun's light node after modifying its rotation in the SetLighting method. Additionally, the conditional logic in the Sky_OnNewClimate::thunk method is reordered and extended to require the feature to be enabled and both sky and sky->currentClimate to be non-null before updating timings.

Changes

Cohort / File(s) Change Summary
Lighting Update Logic
src/Features/SkySync.cpp
Adds a call to update the sun's light node after changing its rotation; refines and reorders conditional checks in the climate change handler to ensure feature enablement and pointer validity before proceeding.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

  • fix(skysync): ctd with null sky #1270: Extends null checks in SkySync::Sky_OnNewClimate::thunk, overlapping with the conditional logic changes in this PR but not the lighting update addition.

Suggested reviewers

  • doodlum

Poem

In the sky where the sun does gleam,
A rabbit tweaks the lighting beam.
With careful checks and updates bright,
The climate shifts, the code feels right.
Hop, hop, the changes shine—
All is synced, and all aligns! 🌞🐇

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 generate unit tests to generate unit tests for 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.

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.

Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 1, 2025

Using provided base ref: 3c80909
Using base ref: 3c80909
Base commit date: 2025-07-30T23:25:49-07:00 (Wednesday, July 30, 2025 11:25 PM)
No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/Features/SkySync.cpp (1)

400-400: LGTM! Improved robustness with better conditional ordering.

The reordered logic correctly checks the feature enablement first before pointer dereferencing, and adds the missing null check for sky->currentClimate. This prevents unnecessary work when the feature is disabled and enhances code robustness.

For consistency, consider applying the same conditional pattern used in the Update() method (lines 84-85), where all pointer checks are grouped together after the enablement check.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c80909 and 924e453.

📒 Files selected for processing (1)
  • src/Features/SkySync.cpp (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-05T05:20:45.823Z
Learning: In the skyrim-community-shaders repository, file deletion error handling improvements that replace existence checks and try-catch blocks with std::filesystem::remove error-code-based approaches are considered bug fixes rather than refactoring, as they address inadequate error handling and misleading log messages.
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-06-24T07:17:36.604Z
Learning: When reviewing PRs, always clarify the scope if there are multiple related features or dependencies. WeatherPicker was a separate PR that was already merged, while this PR focuses specifically on WetnessEffects climate preset system enhancements.
Learnt from: jiayev
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-18T15:21:03.641Z
Learning: In the skyrim-community-shaders rendering pipeline, materials with alpha < 1 or alpha blending enabled are rendered in non-deferred mode rather than deferred mode. This means issues with dynamic cubemaps on transparent materials are actually non-deferred rendering issues.
📚 Learning: when reviewing prs, always clarify the scope if there are multiple related features or dependencies....
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-06-24T07:17:36.604Z
Learning: When reviewing PRs, always clarify the scope if there are multiple related features or dependencies. WeatherPicker was a separate PR that was already merged, while this PR focuses specifically on WetnessEffects climate preset system enhancements.

Applied to files:

  • src/Features/SkySync.cpp
📚 Learning: in the skyrim-community-shaders repository, file deletion error handling improvements that replace e...
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-05T05:20:45.823Z
Learning: In the skyrim-community-shaders repository, file deletion error handling improvements that replace existence checks and try-catch blocks with std::filesystem::remove error-code-based approaches are considered bug fixes rather than refactoring, as they address inadequate error handling and misleading log messages.

Applied to files:

  • src/Features/SkySync.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build plugin and addons
🔇 Additional comments (1)
src/Features/SkySync.cpp (1)

351-352: LGTM! Critical fix for light rotation synchronization.

Adding the explicit Update() call after modifying the sun light's rotation matrix ensures that changes propagate through the scene graph. This pattern is consistent with similar operations elsewhere in the codebase (e.g., line 120) and directly addresses the CPU-side moon luminance calculation issues mentioned in the PR objectives.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 1, 2025

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

@alandtse alandtse merged commit ae0f523 into community-shaders:dev Aug 1, 2025
15 checks passed
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.

3 participants