Skip to content

Add capsule geometry#117

Open
sij411 wants to merge 1 commit into
utilForever:mainfrom
sij411:feat/capsule
Open

Add capsule geometry#117
sij411 wants to merge 1 commit into
utilForever:mainfrom
sij411:feat/capsule

Conversation

@sij411
Copy link
Copy Markdown

@sij411 sij411 commented Jun 1, 2026

What

Add a Capsule geometry type to bracket-geometry.

The capsule is represented by a center segment (start to end) and a radius. It supports point containment, bounding rectangle calculation, point iteration, and point set collection.

Why

Issue #37 requests support for capsule geometry. A capsule is useful for rounded area effects, collision regions, and line-shaped ranges with thickness.

Closes #37

Checklist

Required

  • cargo check --all passes
  • cargo fmt --all -- --check passes
  • cargo clippy --workspace --all-targets -- -D warnings -A clippy::multiple-crate-versions passes
  • cargo test --all passes
  • I linked the related issue (for example: Closes #123)

Workspace clippy currently fails on an existing unrelated lint in bracket-noise/src/fastnoise.rs:2777 (clippy::collapsible_else_if). The changed crate passes:

cargo clippy -p bracket-geometry --all-targets -- -D warnings -A clippy::multiple-crate-versions

Capsule point generation was verified with Capsule::point_set():

...###########...
.###############.
.###############.
#################
.###############.
.###############.
...###########...

Functional Validation

  • Behavior related to this change was verified locally (if applicable)
  • Rendering/backend behavior was verified when runtime code changed (if applicable)
  • Algorithm behavior (pathfinding/FOV/noise/random) was verified when affected (if applicable)
  • I added or updated tests for changed behavior (if applicable)

Configuration & Docs

  • User-facing docs were updated (README.md, ARCHITECTURE.md, or relevant manual pages, if applicable)
  • New dependencies/configuration are documented (if applicable)
  • No sensitive values or credentials were introduced

If Applicable

  • Security impact considered (run cargo audit locally if needed)
  • Breaking behavior changes are clearly described in this PR

Summary by CodeRabbit

Release Notes

  • New Features
    • Introduced Capsule primitive for 2D geometry with support for point containment testing, bounding rectangle calculations, and point iteration.
    • Added optional serialization support for Capsule objects.
    • Added optional component integration for compatible systems.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a new Capsule 2D geometric primitive to bracket-geometry. The implementation includes point-in-capsule testing with clamped segment projection, bounding rectangle computation, point iteration, and point set collection. Comprehensive unit tests validate all operations and edge cases. The type integrates into the crate via module declaration and prelude export.

Changes

Capsule Primitive Implementation

Layer / File(s) Summary
Capsule type definition
bracket-geometry/src/capsule.rs
Capsule struct with start, end, and radius fields; derives Debug, Copy, Clone, Eq, PartialEq; conditionally derives Serde traits and implements specs::Component when feature-gated.
Point-in-capsule and geometric operations
bracket-geometry/src/capsule.rs
point_in_capsule computes closest point on the center segment (clamped) and tests distance; bounding_rect expands start/end coordinates by radius; for_each filters bounding-rectangle points through point_in_capsule; point_set collects filtered points into a HashSet.
Unit tests
bracket-geometry/src/capsule.rs
Tests validate construction, point membership on center line and at distance boundaries, diagonal capsules, zero-length capsules as circles, bounding rectangle values, point set membership, and callback iteration.
Module declaration and prelude export
bracket-geometry/src/lib.rs
Declares capsule module and re-exports its contents via the crate prelude.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • utilForever

Poem

🐰 A capsule so round, with start and end dear,
Now geometry's stronger, the path crystal clear!
With radius-tested points in a set,
The finest shape-checking we've ever had yet! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Title check ✅ Passed The pull request title 'Add capsule geometry' accurately and directly summarizes the main change—the addition of a new Capsule geometry primitive to the bracket-geometry crate.

✏️ 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.

@sij411 sij411 changed the title feat: add capsule geometry Add capsule geometry Jun 1, 2026
@sij411
Copy link
Copy Markdown
Author

sij411 commented Jun 1, 2026

Let me know if docs should be added :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Capsule 만들기

1 participant