Skip to content

fix(weather-editor): write VR precipitation settings through VR runtime#2208

Merged
alandtse merged 6 commits into
community-shaders:devfrom
ParticleTroned:pr/weather-editor-vr-fix
Apr 27, 2026
Merged

fix(weather-editor): write VR precipitation settings through VR runtime#2208
alandtse merged 6 commits into
community-shaders:devfrom
ParticleTroned:pr/weather-editor-vr-fix

Conversation

@ParticleTroned
Copy link
Copy Markdown
Contributor

@ParticleTroned ParticleTroned commented Apr 26, 2026

  • Issue:
    Fixes giant snow flakes/ice crystals appearing in VR when Weather Editor is active in VR.

  • Reason:
    BGSShaderParticleGeometryData uses different particle setting layouts in flat and VR. In flat, each entry is 4 bytes while in VR each entry is 8 bytes. The editor reads these values with GetSettingValue(), which already handles both layouts correctly. But PrecipitationWidget.cpp wrote changes back through GetRuntimeData().data[...], which is the flat 4-byte path. In VR this can corrupt precipitation values like particle size or density.

  • Fix:
    Precipitation settings now write through VR-aware helper. In VR it writes GetVRRuntimeData().data[i].value; in flat it keeps using GetRuntimeData().data[i]. Particle texture access is also VR-aware now.

Pics (winterhold in front of frozen heath) - weather as indicated in pics

RC3:

rc3

this PR:
pr

Summary by CodeRabbit

  • Refactor
    • Refactored precipitation widget to use setting accessors for data access and configuration updates.
    • Replaced VR detection mechanism with a shared boolean flag system for centralized VR state management.
    • Updated shader particle geometry data access patterns.
    • Modified particle texture handling and live updates in precipitation settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR refactors PrecipitationWidget to use setting accessors instead of directly mutating runtime data, and introduces a global VR detection flag in Game.h with a new GET_SHADER_PARTICLE_SETTING macro for VR-aware shader particle configuration access.

Changes

Cohort / File(s) Summary
PrecipitationWidget Refactoring
src/WeatherEditor/Weather/PrecipitationWidget.cpp
Replaces direct runtime.data[...] mutations/reads with setting accessors via GetSettingRef() and GET_SHADER_PARTICLE_SETTING(). Updated LoadFromGameSettings to obtain particleTexture via GET_INSTANCE_MEMBER() and updated ApplyChanges to write settings through accessors, then reinitialize weather.
VR Detection & Shader Particle Macro
src/Utils/Game.h
Adds extern bool isVR flag to globals::game namespace and introduces GET_SHADER_PARTICLE_SETTING macro that conditionally accesses shader particle geometry data with separate logic paths for flat vs VR storage conventions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • davo0411

Poem

🐰 A rabbit hops through settings clean,
No more mutations in the scene!
VR flags now guide the way,
Shaders dance in grand array!
Refactored paths, precision bright,

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(weather-editor): write VR precipitation settings through VR runtime' accurately and specifically describes the main change - making precipitation setting writes VR-aware by routing them through the correct VR runtime path.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

No actionable suggestions for changed features.

Comment thread src/WeatherEditor/Weather/PrecipitationWidget.cpp Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 26, 2026

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

Copy link
Copy Markdown
Collaborator

@SkrubbySkrubInAShrub SkrubbySkrubInAShrub left a comment

Choose a reason for hiding this comment

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

lgtm apart from alandtses comment

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.

🧹 Nitpick comments (1)
src/Utils/Game.h (1)

36-49: Optional: harmonize VR-detection between sibling macros.

The new GET_SHADER_PARTICLE_SETTING uses globals::game::isVR (a cached bool init'd in Globals.cpp::OnPostLoad), while the adjacent GET_INSTANCE_MEMBER / GET_INSTANCE_MEMBER_PTR still call REL::Module::IsVR(). They are semantically equivalent but the call-style differs across three closely-grouped macros in the same header, which is mildly confusing and means a single ApplyChanges (in PrecipitationWidget.cpp) ends up using both styles in the same function body.

Consider switching all three macros to globals::game::isVR for consistency (and a marginally cheaper check) in a follow-up, or keep this as-is if you'd rather leave the existing macros untouched in this PR.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Utils/Game.h` around lines 36 - 49, The macros in this header mix
VR-detection styles: GET_SHADER_PARTICLE_SETTING uses the cached
globals::game::isVR while the sibling macros GET_INSTANCE_MEMBER and
GET_INSTANCE_MEMBER_PTR call REL::Module::IsVR(), which is inconsistent; to
harmonize, change GET_INSTANCE_MEMBER and GET_INSTANCE_MEMBER_PTR to use
globals::game::isVR (or alternatively switch GET_SHADER_PARTICLE_SETTING to
REL::Module::IsVR() if you prefer keeping existing macros unchanged) so all
three macros use the same VR check; update the conditional expressions in
GET_INSTANCE_MEMBER and GET_INSTANCE_MEMBER_PTR to reference globals::game::isVR
and ensure the semantics (flat vs VR storage selection) remain identical after
the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/Utils/Game.h`:
- Around line 36-49: The macros in this header mix VR-detection styles:
GET_SHADER_PARTICLE_SETTING uses the cached globals::game::isVR while the
sibling macros GET_INSTANCE_MEMBER and GET_INSTANCE_MEMBER_PTR call
REL::Module::IsVR(), which is inconsistent; to harmonize, change
GET_INSTANCE_MEMBER and GET_INSTANCE_MEMBER_PTR to use globals::game::isVR (or
alternatively switch GET_SHADER_PARTICLE_SETTING to REL::Module::IsVR() if you
prefer keeping existing macros unchanged) so all three macros use the same VR
check; update the conditional expressions in GET_INSTANCE_MEMBER and
GET_INSTANCE_MEMBER_PTR to reference globals::game::isVR and ensure the
semantics (flat vs VR storage selection) remain identical after the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e3391d2c-e2c3-4730-ae86-0caf44a036d7

📥 Commits

Reviewing files that changed from the base of the PR and between f33823f and df6944a.

📒 Files selected for processing (2)
  • src/Utils/Game.h
  • src/WeatherEditor/Weather/PrecipitationWidget.cpp

@ParticleTroned
Copy link
Copy Markdown
Contributor Author

addressed rabbits nitpick in [0cdfde6].

@ParticleTroned ParticleTroned requested a review from alandtse April 26, 2026 19:11
Copy link
Copy Markdown
Collaborator

@alandtse alandtse left a comment

Choose a reason for hiding this comment

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

I meant we can use GET_INSTANCE_MEMBER to expose the value and then access it's index. No need for a PARTICLE only version.

alandtse

This comment was marked as low quality.

alandtse and others added 2 commits April 26, 2026 16:40
Add GetSettingRef(DataID) to BGSShaderParticleGeometryData as a
writable companion to GetSettingValue(DataID), mirroring its VR-aware
dispatch. This removes the need for the particle-only
GET_SHADER_PARTICLE_SETTING macro.

Revert GET_INSTANCE_MEMBER/GET_INSTANCE_MEMBER_PTR to REL::Module::IsVR()
and drop the globals::game::isVR forward declaration from Game.h.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

🧹 Nitpick comments (1)
src/Utils/Game.h (1)

48-49: Optional: deduplicate the cast and parenthesize for defensive macro hygiene.

Minor nit — static_cast<uint32_t>(a_id) is repeated in both branches. You can lift it into a single subexpression and parenthesize the macro args/result for safety against unusual call sites. Non-blocking.

♻️ Optional tweak
 `#define` GET_SHADER_PARTICLE_SETTING(a_value, a_source, a_id) \
-	auto& a_value = !globals::game::isVR ? (a_source)->GetRuntimeData().data[static_cast<uint32_t>(a_id)] : (a_source)->GetVRRuntimeData().data[static_cast<uint32_t>(a_id)].value;
+	const auto a_value##_idx = static_cast<uint32_t>(a_id);                                                                          \
+	auto& a_value = !globals::game::isVR ? (a_source)->GetRuntimeData().data[a_value##_idx] : (a_source)->GetVRRuntimeData().data[a_value##_idx].value;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Utils/Game.h` around lines 48 - 49, The macro GET_SHADER_PARTICLE_SETTING
should lift the duplicated cast into a single parenthesized subexpression and
add defensive parentheses to macro args/usage: introduce a private local
identifier (e.g., const uint32_t __cast_id = static_cast<uint32_t>((a_id)))
inside the macro, and then use ((a_source)->GetRuntimeData().data[__cast_id])
and ((a_source)->GetVRRuntimeData().data[__cast_id]). Also parenthesize the
macro parameters and the declared variable name (e.g., auto& (a_value) = ...) to
avoid surprises from complex call sites; keep the globals::game::isVR check
as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/Utils/Game.h`:
- Around line 48-49: The macro GET_SHADER_PARTICLE_SETTING should lift the
duplicated cast into a single parenthesized subexpression and add defensive
parentheses to macro args/usage: introduce a private local identifier (e.g.,
const uint32_t __cast_id = static_cast<uint32_t>((a_id))) inside the macro, and
then use ((a_source)->GetRuntimeData().data[__cast_id]) and
((a_source)->GetVRRuntimeData().data[__cast_id]). Also parenthesize the macro
parameters and the declared variable name (e.g., auto& (a_value) = ...) to avoid
surprises from complex call sites; keep the globals::game::isVR check as-is.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fcf22e04-69f1-4023-a63f-77188bda9d7a

📥 Commits

Reviewing files that changed from the base of the PR and between 6cf2719 and 9b1d292.

📒 Files selected for processing (2)
  • src/Utils/Game.h
  • src/WeatherEditor/Weather/PrecipitationWidget.cpp

@ParticleTroned
Copy link
Copy Markdown
Contributor Author

thx for clarification and implemention -should be then concluded now.

Replace GET_SHADER_PARTICLE_SETTING macro with GetSettingRef() from
CommonLib, which handles the flat/VR layout difference internally.
Remove the particle-specific macro and the globals::game::isVR forward
declaration. Revert GET_INSTANCE_MEMBER/GET_INSTANCE_MEMBER_PTR to
REL::Module::IsVR(). Bump CommonLib to 4.15.0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@alandtse alandtse merged commit 367375f into community-shaders:dev Apr 27, 2026
12 checks passed
ParticleTroned added a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 2, 2026
IgorAlanAlbuquerque pushed a commit to IgorAlanAlbuquerque/skyrim-community-shaders that referenced this pull request May 29, 2026
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