-
-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Pos
and Rot
in favor of bevy's Transform
#16
Comments
I agree here, it would be nicer/simpler for quick usecases, but I think it ends up falling apart more because things that directly change Transform probably aren't compatible with the physics engine aside from scenes. I think something that might make sense is to have the Pos/Rot take the Transform when it is initially created, which would give us the benefits of being able to set Transforms for initialization.
We could just move
Tbh I don't expect users to ever really use PrevPos/Rot so I'm not sure we need to worry much about those. One benefit I can see with splitting Pos/Rot is if we want to add more traditional particle physics in the original PBD sense for things like cloth/ropes
However, I do think adding a
This is also partially why I'm more partial to our own positioning, at least with the mentioned part of the paper in this PR: (#7). One big thing is there is no way to opt out of the transform hierarchy and having a parent-child relationship with physics entities doesn't make a whole lot of sense as they would be better explained with a fixed joint constraint (which we could do automatically to be fair, but I think that adds some implicitness and I'd rather error/warn here if we were to go this route). Overall I think I'm more on the side of keep them separated for the sake of being more explicit when you are interacting with physics entities. |
dimforge/bevy_rapier#219 (comment) |
Physics uses isometries (no scale or shear), and these must be global (from the physics engine's point of view), so it's not a good match for |
Putting the rotation and translation together in a struct can make the math a lot cleaner, though. I use two types of isometries: one with a Maybe the second one should be called something else. |
in my opinion, this alone is reason enough not to use From my previous attempts with
Yeah, I think this could work quite nicely with the builder methods on I also think it's nice to be able to run a simulation that doesn't sync back to the bevy transforms. Could easily integrate with crates like seldom_pixel for instance, or physics simulations that don't really need to render every frame (or at all) On the topic of granularity of components: In the version of bevy_xpbd I use in cargo space (derived from the same source as this repo), I use the presence of components to communicate what a physics entity can and cannot do. e.g.:
|
I agree with everyone's points here, I think we should stick with I think this was still a worthwile discussion to have, at least for future reference. I'll close this now :) Edit: The components are now called |
Currently,
bevy_xpbd
uses the componentsPos
andRot
for describing the position and orientation of bodies. At the end of each iteration of the main physics loop, these are synchronized with bevy'sTransform
s.I'd like to discuss if we should remove the separate components and move to just using bevy's own
Transform
s.Advantages
Rot
implementations for 2D and 3D, all rotations useQuat
s)Transform
andPrevTransform
instead ofPos
,PrevPos
,Rot
, andPrevRot
)Transform
s directlybevy_rapier
)Disadvantages
Transform
hierarchies, scaling and shearing can cause serious problems (see comments below)Transform
at once. Separate systems withPos
andRot
can run simultaneously.f64
version ofTransform
unless we make a custom one (addingf64
as a crate feature: Addbevy_xpbd_2d_f64
andbevy_xpbd_3d_f64
crates #7)Pos
usesVec2
andRot
uses a scalar value.Transform
s just have aVec3
and aQuat
, which can be considered less ergonomic for 2D. However, bevy users are used to working with them, and they might provide more freedom, so this may not be an issue.Conclusion
Personally, at least from an API standpoint, I think it makes sense to move to using just
Transform
s, as it would generally be much more convenient and familiar for bevy users, and it would also probably reduce the engine's code and complexity. UsingTransform
s for physics can cause many problems as well though, which is why I'd like to hear what others think.The text was updated successfully, but these errors were encountered: