Skip to content

Conversation

@kfc35
Copy link
Contributor

@kfc35 kfc35 commented Jan 24, 2026

Objective

Solution

  • Moves bevy_camera::primitives::HalfSpace to bevy_math::primitives::HalfSpace (first commit)
  • Moves some of bevy_camera::primitives::Frustum to bevy_math::primitives::ViewFrustum (second commit)
  • I basically followed Jondolf’s directions on the two refactorings. aabb, obb, and sphere stuff stays in bevy_camera (for now? If sphere is refactored, it has been stressed to be done as a follow up )

Testing

I ran the lighting, 2d_gizmos, and 3d_gizmos example just to make sure the lights… and camera… (and action!) were still working. Everything seems to be fine there compared to main. If there are any other examples I should run to make sure things look good, let me know.

@kfc35 kfc35 force-pushed the frustum_halfspace_13945 branch from cb93bc3 to ff89364 Compare January 24, 2026 19:05
@kfc35 kfc35 added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Math Fundamental domain-agnostic mathematical operations D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-Camera User-facing camera APIs and controllers. A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide and removed C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Camera User-facing camera APIs and controllers. labels Jan 24, 2026
@kfc35 kfc35 force-pushed the frustum_halfspace_13945 branch from ff89364 to b34bb28 Compare January 24, 2026 19:13
#[reflect(ignore, clone)]
pub half_spaces: [HalfSpace; 6],
}
pub struct Frustum(pub ViewFrustum);

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

why is that even a thing at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don’t actually know, but I’m not curious/courageous enough to try removing it
Trying to be as minimally invasive for this PR as possible

Copy link
Contributor

Choose a reason for hiding this comment

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

dunno #22693

@atlv24 atlv24 self-requested a review January 24, 2026 19:24
@Jondolf Jondolf self-requested a review January 24, 2026 19:42
@alice-i-cecile
Copy link
Member

Looks like one of your doc links is broken :)

Copy link
Contributor

@Jondolf Jondolf left a comment

Choose a reason for hiding this comment

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

I'm generally in favor of something like this! I think starting with a direct port like this is fine, though long-term, I'd like to handle things a bit differently. I didn't look at the code too deeply yet, just some general initial thoughts in this area:

  • I would personally prefer if we replaced our existing plane types with a representation like this one (normal and signed distance). The existing ones are kinda useless. Edit: specifically infinite planes, I don't really care what we do with finite planes, I'd make them meshing-only or remove them
    • Planes are more general-purpose, and a half-space is also defined by a plane, just with the additional semantics that it represents one of the two regions created by the plane, not the plane itself. IMO these semantics can generally be derived from surrounding context (ex: you could have a half_space property that is still defined by a Plane3d).
    • Alternatively, we could also keep HalfSpace2d and HalfSpace3d for their special semantics, but as newtypes over Plane2d and Plane3d.
    • Note that I have my own Plane2d and Plane3d types implemented locally. IMO they have a better and more complete API than the half-space type here. I made a gist for them here.
  • I would like to have both HalfSpace2d and HalfSpace3d. HalfSpace shouldn't be a 3D-specific type.
  • This has been discussed a million times, but we really need to figure out what shapes we include in bevy_math and if/how to categorize them. Unlike most other shapes, these probably won't have meshing or some other features.

@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-22684

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

Copy link
Contributor

@atlv24 atlv24 left a comment

Choose a reason for hiding this comment

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

Generally onboard with this direction. I avoid touch bevy_math because people have a lot of conflicting opinions about it which makes PRs stagnate and die, so while I would have chosen different names for things I dont want to feel strongly enough about it that i contribute to the problem.

Im fine with merging as is, provided CI passes. I have some feelings about the NEAR/FAR constants living in bevy_math, and the more render-y specific stuff being here, but eh. I like seeing any movement at all on this. Agree with Jondolf about 2d/3d variants in the future, maybe good to make space for them now by going to HalfSpace3d immediately.

@alice-i-cecile alice-i-cecile added the X-Contentious There are nontrivial implications that should be thought through label Jan 25, 2026
@kfc35 kfc35 force-pushed the frustum_halfspace_13945 branch from f79ab7e to 510723b Compare January 25, 2026 22:43
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

I'm happy with this as an incremental improvement, but unsurprisingly Jondolf has good takes on the longterm plans :)

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Math Fundamental domain-agnostic mathematical operations A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Contentious There are nontrivial implications that should be thought through

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants