Skip to content
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

Physics #81

Merged
merged 20 commits into from
Feb 12, 2024
Merged

Physics #81

merged 20 commits into from
Feb 12, 2024

Conversation

Speykious
Copy link
Member

BEHOLD, IT'S PHYSIC-ING

waifu-physiiiiiiiiiiiiiiics.mp4

Speykious and others added 20 commits July 16, 2023 20:16
The fruits of my procrastination...
...just not physics :p
Rationale:
- `PhysicsState` and `PhysicsSystem` trait can be viewed as the requirements for the provided Runge-Kutta method impl to work. So they are all contained in file `runge_kutta.rs`. Simple Physics systems can choose to utilize the impl, thus using the structs and implementing the traits, or not, completely forgetting about that file, during implementation of `tick()`.
- `tick()` of `SimplePhysicsSystems` enum-dispatches to `tick()`s of variants, instead of dynamic dispatches, as for inox2d users are not supposed to bring their own physics systems (as of now).
- Decoupling is done realizing that one step of physics simulation is a closure yielding a `Vec2` and changing some contained states, per step. Thus letting one step do the calc, return the `Vec2` and letting external code setting params based on the return value will solve the previous ownership problem.
- TODO: The call to step the physics system is put naively inside `end_set_params()`, and without actual time elapsed passed in. Takeaway is, the physics step should be after param setting and before full puppet transform re-calc. But future refactor should provide the user with a better interface (physics still run if `end_set_params()` not called, and actual time elapsed passed in).
Rationale:
- `PhysicsState` and `PhysicsSystem` trait can be viewed as the
requirements for the provided Runge-Kutta method impl to work. So they
are all contained in file `runge_kutta.rs`. Simple Physics systems can
choose to utilize the impl, thus using the structs and implementing the
traits, or not, completely forgetting about that file, during
implementation of `tick()`.
- `tick()` of `SimplePhysicsSystems` enum-dispatches to `tick()`s of
variants, instead of dynamic dispatches, as for inox2d users are not
supposed to bring their own physics systems (as of now).
- Decoupling is done realizing that one step of physics simulation is a
closure yielding a `Vec2` and changing some contained states, per step.
Thus letting one step do the calc, return the `Vec2` and letting
external code setting params based on the return value will solve the
previous ownership problem.
- TODO: The call to step the physics system is put naively inside
`end_set_params()`, and without actual time elapsed passed in. Takeaway
is, the physics step should be after param setting and before full
puppet transform re-calc. But future refactor should provide the user
with a better interface (physics still run if `end_set_params()` not
called, and actual time elapsed passed in).
Unicode variables! :D
This basically fixes all weird physics behavior
@Speykious
Copy link
Member Author

This code is very ugly but we can now finally focus on refactoring

@Speykious Speykious merged commit ea6425f into main Feb 12, 2024
11 checks passed
@Speykious Speykious deleted the physics branch February 12, 2024 03:15
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.

2 participants