Skip to content

Add Packed Math Types & AABB#57

Open
Shakai-Dev wants to merge 2 commits into
Redot-Engine:masterfrom
Shakai-Dev:packed-math-types
Open

Add Packed Math Types & AABB#57
Shakai-Dev wants to merge 2 commits into
Redot-Engine:masterfrom
Shakai-Dev:packed-math-types

Conversation

@Shakai-Dev

@Shakai-Dev Shakai-Dev commented Jul 17, 2026

Copy link
Copy Markdown
Member
  • Adds Packed Math Types such as Float2, Float3, Float4 & Float4x4
  • Adds benchmarks for Packed Math Types
  • Adds AABB with tests

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added packed Float2, Float3, Float4, and Float4x4 math types with swizzling, vector operations, and utilities like dot/length/normalize (including Float3 cross product).
    • Added AABB with an empty-box constructor plus expand(), center(), and size() accessors.
    • Exposed the packed types through the core math module.
  • Performance

    • Added microbenchmarks for vector dot-product throughput/latency and matrix–vector multiplication.
  • Tests

    • Added doctests validating AABB behavior and vector layout/utility correctness.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Shakai-Dev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c35f591-24d0-48c2-b41f-37cef035d792

📥 Commits

Reviewing files that changed from the base of the PR and between 76f12de and 029f4a3.

📒 Files selected for processing (3)
  • Engine/cpp/Runtime/Core/Math/AABB.cppm
  • Engine/cpp/Runtime/Core/Math/AABB.test.cpp
  • Engine/cpp/Runtime/Core/Math/PackedTypes.cppm
📝 Walkthrough

Walkthrough

Adds a packed math module with aligned vector and matrix types, arithmetic, utilities, formatting, module re-exporting, and benchmarks. It also adds an exported AABB type with tests for bounds, expansion, center, size, and vector behavior.

Changes

Packed math module

Layer / File(s) Summary
Packed vector types
Engine/cpp/Runtime/Core/Math/PackedTypes.cppm
Adds selection helpers and aligned Float2, Float3, and Float4 types with constructors, indexing, swizzles, and compound arithmetic.
Matrix and vector math API
Engine/cpp/Runtime/Core/Math/PackedTypes.cppm
Adds column-major Float4x4, component-wise operators, dot/length/normalize/cross utilities, and vector formatter specializations.
Module exposure and benchmarks
Engine/cpp/Runtime/Core/Math/Types.cppm, Engine/cpp/Runtime/Core/Math/PackedTypes.bench.cpp
Re-exports the packed module and adds metadata reporting plus benchmarks for vector dot products and matrix–vector multiplication.

AABB module

Layer / File(s) Summary
AABB type and validation
Engine/cpp/Runtime/Core/Math/AABB.cppm, Engine/cpp/Runtime/Core/Math/AABB.test.cpp
Adds an exported AABB type with empty-box initialization, expansion, center, and size operations, plus tests for bounds and vector layouts and behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: joltedjon, mcdubhghlas

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main additions: packed math types and AABB.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Engine/cpp/Runtime/Core/Math/PackedTypes.cppm`:
- Around line 502-508: Update Float4::operator*=(f32) to multiply the w
component by other, alongside x, y, and z, so its result matches
operator*(Float4, f32).
- Around line 140-173: Replace the runtime (&x)[…] accesses in the Float2 index
and swizzle operators with select()-based member selection, preserving
compile-time and runtime results; apply the same fix to the corresponding Float3
and Float4 overloads. Also update Float4::operator*=(f32) to scale w along with
x, y, and z.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7e6728c9-c6f0-4268-94db-0a55728e02c0

📥 Commits

Reviewing files that changed from the base of the PR and between 53097f5 and 8c7c1c4.

📒 Files selected for processing (3)
  • Engine/cpp/Runtime/Core/Math/PackedTypes.bench.cpp
  • Engine/cpp/Runtime/Core/Math/PackedTypes.cppm
  • Engine/cpp/Runtime/Core/Math/Types.cppm

Comment thread Engine/cpp/Runtime/Core/Math/PackedTypes.cppm
Comment thread Engine/cpp/Runtime/Core/Math/PackedTypes.cppm
* Adds Packed Math Types such as Float2, Float3, Float4 & Float4x4
* Adds benchmarks & tests for Packed Math Types
@Shakai-Dev Shakai-Dev changed the title Add Packed Math Types with benchmarks & tests Add Packed Math Types with benchmarks Jul 18, 2026
@Shakai-Dev Shakai-Dev changed the title Add Packed Math Types with benchmarks Add Packed Math Types & AABB Jul 18, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
Engine/cpp/Runtime/Core/Math/PackedTypes.cppm (1)

345-345: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Make the Float4 constructor explicit to prevent implicit conversions.

Since this constructor has a default argument for w, it can be invoked with a single Float3 argument. It should be marked explicit to prevent unintended implicit conversions from Float3 to Float4. This ensures consistency with the Float3(const Float2 &, f32) constructor, which is appropriately marked explicit.

♻️ Proposed refactor
-        [[nodiscard]] constexpr Float4(const Float3 &xyz, f32 w = 0.0f) noexcept : x{xyz.x}, y{xyz.y}, z{xyz.z}, w{w} {}
+        [[nodiscard]] constexpr explicit Float4(const Float3 &xyz, f32 w = 0.0f) noexcept : x{xyz.x}, y{xyz.y}, z{xyz.z}, w{w} {}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Engine/cpp/Runtime/Core/Math/PackedTypes.cppm` at line 345, Mark the Float4
constructor taking const Float3& xyz and optional f32 w as explicit. Keep its
initialization and default w value unchanged, matching the conversion-prevention
behavior of the Float3 constructor.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Engine/cpp/Runtime/Core/Math/PackedTypes.cppm`:
- Around line 500-507: Correct the third (`z`) component calculation in
Float4::operator* by using columns[1].z for the vector.y term instead of
columns[1].y. Leave the other matrix-vector multiplication components unchanged.

---

Nitpick comments:
In `@Engine/cpp/Runtime/Core/Math/PackedTypes.cppm`:
- Line 345: Mark the Float4 constructor taking const Float3& xyz and optional
f32 w as explicit. Keep its initialization and default w value unchanged,
matching the conversion-prevention behavior of the Float3 constructor.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9c15a71d-b7c8-4818-ad88-4c5d274ff8c7

📥 Commits

Reviewing files that changed from the base of the PR and between 8c7c1c4 and 05fc5fc.

📒 Files selected for processing (5)
  • Engine/cpp/Runtime/Core/Math/AABB.cppm
  • Engine/cpp/Runtime/Core/Math/AABB.test.cpp
  • Engine/cpp/Runtime/Core/Math/PackedTypes.bench.cpp
  • Engine/cpp/Runtime/Core/Math/PackedTypes.cppm
  • Engine/cpp/Runtime/Core/Math/Types.cppm
🚧 Files skipped from review as they are similar to previous changes (2)
  • Engine/cpp/Runtime/Core/Math/Types.cppm
  • Engine/cpp/Runtime/Core/Math/PackedTypes.bench.cpp

Comment thread Engine/cpp/Runtime/Core/Math/PackedTypes.cppm
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.

1 participant