-
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
Create enum EmitterShape to allow for emitters other than circles #33
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This looks great. One small comment about what I think may be a bug, but otherwise very happy with it.
let rotation = Quat::from_rotation_z(angle); | ||
|
||
Transform::from_translation(rotation * vec3(0.0, distance, 0.0)) | ||
.with_rotation(rotation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this causes us to not correctly respect rotate_to_movement_direction
if it is false. So I think we don't want to set transform rotation here (or for CircleSegment
) and let the code in the spawn system do it after we return this transform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should get accounted for in the particle_spawner
system in Line 142 and the following, where I override the transform.rotation
if rotate_to_movement_direction
is false. My thinking behind doing it that way, was that we need some way of communicating the movement direction of the particle from the EmitterShape
back to the system, because the system does not really have a way of determining it. So some information about direction has to be communicated back from .sample
anyways.
So the rotation of that transform basically describes the direction of movement, and not necessarily the rotation of the particle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, ok, I see it now. Perfect!
let rotation = Quat::from_rotation_z(angle); | ||
|
||
Transform::from_translation(rotation * vec3(0.0, distance, 0.0)) | ||
.with_rotation(rotation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, ok, I see it now. Perfect!
Co-authored-by: Abnormal Brain Studios <102993888+abnormalbrain@users.noreply.github.com>
I quickly threw this together for a project of mine, and thought I could as well ask if this is something that could be integrated into the upstream library.
I ran into a situation where I needed particles to be emitted from a line (think Clouds in the background e.g) and found no easy way to do this with this library, so I bundled the three
spawn_radius
,emitter_shape
andemitter_angle
properties of theParticleSystem
together into an enumEmitterShape::CircleSegment
. Another variant of this enum isEmitterShape::Line
which has similar fields that describe a line with a given length - possibly at an angle.This enum has an impl with the
sample
function, which returns a random point on the shape of the emitter, which gets used by theparticle_spawner
system to determine the position and orientation of a newly spawned particle.I also updated all the examples to account for this (breaking) change.