`bevy_math`: Organize `HalfSpace`, create 2d and 3d `HalfSpace` primitives
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
> 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](https://gist.github.com/Jondolf/6aa7b87637034f8f09c59ad0c37f40c8).
> - 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.
_Originally posted by @Jondolf in https://github.com/bevyengine/bevy/pull/22684#pullrequestreview-3702647975_
Just making sure this uncontroversial comment on the future of `HalfSpace` is not lost in the ether.
Currently `HalfSpace` is in its own module. I assume the 2d and 3d versions can just be placed in the respective `dim2` and `dim3` modules.
Contributor guide
Assessment
This issue has not been assessed yet.