Skip to content

feat(weather): std::array & std::vector support#1702

Merged
davo0411 merged 3 commits into
community-shaders:devfrom
davo0411:weather-array-support
Jan 13, 2026
Merged

feat(weather): std::array & std::vector support#1702
davo0411 merged 3 commits into
community-shaders:devfrom
davo0411:weather-array-support

Conversation

@davo0411
Copy link
Copy Markdown
Collaborator

@davo0411 davo0411 commented Jan 13, 2026

Summary by CodeRabbit

  • New Features

    • Added support for fixed-size and dynamic array weather variables with customizable element interpolation.
    • Enhanced weather system to handle complex composite types including arrays and vectors.
  • Documentation

    • Added comprehensive guides for registering and using array and vector weather variables.
    • Included JSON serialization examples and detailed interpolation behavior documentation for array and vector types.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

The changes introduce support for weather variables with composite array and vector types through two new specialized template classes (ArrayVariable and VectorVariable), along with comprehensive documentation covering usage, interpolation behavior, and JSON serialization.

Changes

Cohort / File(s) Summary
Documentation
docs/weather-system-docs/WeatherVariableRegistration.md
Added sections describing ArrayVariable and VectorVariable with code examples, interpolation behavior notes including handling of differing sizes and default initialization, and JSON serialization guidance with example JSON demonstrating array/vector usage in weather settings.
Header Implementation
src/WeatherVariableRegistry.h
Introduced ArrayVariable<T, N> template class for fixed-size std::array and VectorVariable<T> template class for dynamic std::vector. Both extend WeatherVariable, support custom element lerp functions or default std::lerp for floating-point types, and implement per-element interpolation with size mismatch handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • jiayev

Poem

🐰 Arrays and vectors hop along,
With lerp and defaults, smooth and strong,
ArrayVariable keeps sizes tight,
While VectorVariable grows just right,
The weather system now takes flight! 🌤️

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding support for std::array and std::vector types in the weather system, which is the primary focus of both the documentation updates and the new API additions.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

pre-commit-ci Bot and others added 2 commits January 13, 2026 06:07
Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
@github-actions
Copy link
Copy Markdown

Using provided base ref: 0bb5c37
Using base ref: 0bb5c37
Base commit date: 2026-01-13T01:53:04Z (Tuesday, January 13, 2026 01:53 AM)
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/weather-system-docs/WeatherVariableRegistration.md (1)

105-106: Fix corrupted text on this line.

The text appears to have been incorrectly merged. It should be split into two separate parts.

📝 Suggested fix
--   Handles default values and missing dataanced Usage
+-   Handles default values and missing data
+
+## Advanced Usage
🧹 Nitpick comments (2)
docs/weather-system-docs/WeatherVariableRegistration.md (1)

374-376: Remove empty code block.

This empty code block at the end of the file serves no purpose.

🧹 Suggested fix
-```
-
-```
src/WeatherVariableRegistry.h (1)

229-240: Consider using defaultValue elements for missing vector entries.

Currently, when vectors have different sizes during interpolation, missing elements use T{} (value-initialization). This differs from how the base class handles missing JSON data (uses defaultValue).

While the current behavior is documented, using elements from defaultValue might be more intuitive for users expecting consistent fallback behavior.

♻️ Optional: Use defaultValue for missing elements

This would require capturing defaultValue in the lambda:

-			[elementLerpFunc](const std::vector<T>& from, const std::vector<T>& to, float factor) {
+			[elementLerpFunc, defaultValue](const std::vector<T>& from, const std::vector<T>& to, float factor) {
 				size_t maxSize = std::max(from.size(), to.size());
 				std::vector<T> result;
 				result.reserve(maxSize);
 
 				for (size_t i = 0; i < maxSize; ++i) {
-					T fromVal = (i < from.size()) ? from[i] : T{};
-					T toVal = (i < to.size()) ? to[i] : T{};
+					T defaultElement = (i < defaultValue.size()) ? defaultValue[i] : T{};
+					T fromVal = (i < from.size()) ? from[i] : defaultElement;
+					T toVal = (i < to.size()) ? to[i] : defaultElement;
 					result.push_back(elementLerpFunc(fromVal, toVal, factor));
 				}
 				return result;
 			})

If the current behavior is intentional for your use cases, this is fine as-is since it's properly documented.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0bb5c37 and 1a4792e.

📒 Files selected for processing (2)
  • docs/weather-system-docs/WeatherVariableRegistration.md
  • src/WeatherVariableRegistry.h
🧰 Additional context used
📓 Path-based instructions (3)
**/*

⚙️ CodeRabbit configuration file

**/*: When reviewing PRs, please provide suggestions for:

  1. Conventional Commit Titles (if not following https://www.conventionalcommits.org/ or
    if the existing title does not describe the code changes):
    Format: type(scope): description
    Length: 50 characters limit for title, 72 for body
    Style: lowercase description, no ending period
    Examples:

    • feat(vr): add cross-eye sampling
    • fix(water): resolve flowmap bug
    • docs: update shader documentation
  2. Issue References (if PR fixes bugs or implements features):
    Suggest adding appropriate GitHub keywords:

    • "Fixes #123" or "Closes #123" for bug fixes
    • "Implements #123" or "Addresses #123" for features
    • "Related to #123" for partial implementations

Otherwise, use your standard review approach focusing on code quality.

Files:

  • docs/weather-system-docs/WeatherVariableRegistration.md
  • src/WeatherVariableRegistry.h
**/*.{cpp,cxx,cc,c,h,hpp,hxx,hlsl,hlsli,fx,fxh,py}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Do not include TODO/FIXME placeholders; provide complete, working solutions

Files:

  • src/WeatherVariableRegistry.h
src/**/*.{cpp,cxx,cc,h,hpp,hxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.{cpp,cxx,cc,h,hpp,hxx}: Ensure SE/AE/VR runtime compatibility; use runtime detection patterns (e.g., REL::RelocateMember())
Include robust error handling and resource management with graceful degradation in the plugin code

Files:

  • src/WeatherVariableRegistry.h
🧠 Learnings (2)
📓 Common learnings
Learnt from: alandtse
Repo: doodlum/skyrim-community-shaders PR: 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: ThePagi
Repo: doodlum/skyrim-community-shaders PR: 1369
File: src/Features/SnowCover.cpp:277-293
Timestamp: 2025-08-05T18:22:40.578Z
Learning: In the skyrim-community-shaders SnowCover feature, the wstrtostr and strtowstr utility functions defined in src/Features/SnowCover.cpp are unused and should be removed rather than fixed, as confirmed by the original author ThePagi.
Learnt from: alandtse
Repo: doodlum/skyrim-community-shaders PR: 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.
📚 Learning: 2025-08-17T18:37:35.839Z
Learnt from: CR
Repo: doodlum/skyrim-community-shaders PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-17T18:37:35.839Z
Learning: Applies to features/**/*.{cpp,cxx,cc,h,hpp,hxx} : Register new features in the globals::features namespace

Applied to files:

  • src/WeatherVariableRegistry.h
⏰ 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 (4)
docs/weather-system-docs/WeatherVariableRegistration.md (1)

129-213: Documentation for array and vector types looks comprehensive.

The examples clearly demonstrate:

  • Fixed-size arrays with ArrayVariable<T, N> for primitive and complex types
  • Dynamic vectors with VectorVariable<T>
  • Custom interpolation functions for complex element types
  • Important notes on vector interpolation behavior with mismatched sizes
src/WeatherVariableRegistry.h (3)

13-29: LGTM!

The header documentation clearly explains the available variable types and provides a concise example for custom element types requiring interpolation functions.


189-218: LGTM!

The ArrayVariable implementation correctly:

  • Uses SFINAE to provide a convenient constructor for floating-point element types
  • Captures elementLerpFunc by value in the lambda (necessary since it outlives the constructor)
  • Performs per-element interpolation with proper bounds

244-254: LGTM!

The helper constructor correctly mirrors the ArrayVariable pattern with proper SFINAE constraints for floating-point types.

@github-actions
Copy link
Copy Markdown

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

@davo0411 davo0411 merged commit 9419062 into community-shaders:dev Jan 13, 2026
16 checks passed
@davo0411 davo0411 deleted the weather-array-support branch January 13, 2026 09:48
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