-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add "drag" field to particle systems ? #42
Comments
I have previously considered moving toward a more correct velocity usage. Adding drag would be a nice touch as well. I'm not super familiar with the actual physics involved, so I think it'll take me some time to digest some of the info. I'm very open to pointers in how to correctly (or at least approximately) calculate this if you have any, assuming we already have a current velocity and acceleration. |
Maybe put a simplified equation from the wiki you mentionned. It says that: F = 1/2 * p * v^2 * C * A F being the resulting drag force it gives: F = 1/2 * v^2 * C I think this would make it work, with a little tweak of "p" to make it nice out of the box What do you think ? |
I could try to implement that, but I never made a pull/merge requests out of the studio I worked before :) |
I made a branch with modifications that changes Direction/Speed to Velocity, but I have no idea how to submit it to this repo. |
@Rayoule nice! To open the change here, you'll want to fork this repo by hitting the We'll want to get the examples and docs updated so they work before we can merge though. |
Thanks ! |
It works without any modifications of the examples ! Another thing is that the acceleration is still a f32. It should be a Vec3 since an acceleration is an external force that can have any direction. Do you agree ? In the meantime I will add the drag and make an example about it. |
Drag has been added and works fine. Now that its done, I would like to turn the acceleration into a vector so it can be more flexible, and not direction-based (for example, to simulate gravity). |
Hello again ! I've just implemented a new way to handle acceleration/velocity/drag that allows more flexibility and unlocks new possibilities ! How it works:
This way, we have only one field in the And now, we can stack these modifiers so its possible to have a drag AND a constant acceleration (see the example velocity_modifiers.rs) ! I fixed the example basic.rs (the only one that was using acceleration). Its a little more verbose but its worth it in my opinion. @abnormalbrain |
@Rayoule Interesting! Sorry for the lack of reply here, got busy with my day job but I really like this approach. It feels clean and extensible. |
No problem ! |
Closed by #44 |
I am enjoying this crate very much, and I think adding a drag field would be awesome to have some smokey/lightweight effect.
It would work as a constant (or interpolated over time?) velocity scaling.
I used a lot of particle systems, and the drag is almost always on, even with little impact, so it gives the feeling that the particles are moving in the air and not in empty space.
For now, I have to use a negative acceleration to achieve this. The problem is that if I modify my initial speed, acceleration will also need a tweak so it matches the speed, and don't make the particles go too quick, or go in the opposite direction.
Also, the acceleration is a value and not a vector, so we can't deviate particles from their original direction. This makes impossible to simulate gravity or other custom forces we would like to apply (vector fields gives awesome results with particles)
Well I hope this will help :)
The text was updated successfully, but these errors were encountered: