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

Particle emitter - part2 #113

Merged
merged 13 commits into from
Jul 13, 2020
Merged

Particle emitter - part2 #113

merged 13 commits into from
Jul 13, 2020

Conversation

caguero
Copy link
Contributor

@caguero caguero commented Jul 9, 2020

This pull request focuses on the API of the particle emitter. Here are a few points for potential discussion:

1. How does the ParticleEmitter class API set its type?

Typically, there's a way to specify the geometry of the emitter, that dictates the origin from where the particles are created (point, box, cylinder, ellipsoid, hollow ellipsoid, ring, ...). Each shape can be specified with its own parameters. E.g.: {width, height, depth} for a box and {width, height, depth, internal_width, internal_height, internal_depth} for a hollow ellipsoid.

1.1: Ogre decides to have a particle emitter for each type subclassing from the ParticleEmitter base class. Additionally, they provide a few instances of emitters for the regular types mentioned before. This design allows to create custom shapes for the emitters.

1.2: Another idea could be to create a Geometry class that can be subclassed with all the different geometries to support. The SetType() function should accept a Geometry parameter. Probably, each derived Geometry should have its own initialization parameters and all of them should have a way to sample a particle from that geometry.

1.3: The simplest approach that I can imagine is to offer a SetType() function where we specify the geometry as an enum, and then, to offer a SetEmitterSize() that accepts a Vector3d. The interpretation of the vector varies depending on the type, but we can at least represent a point, box, cylinder and ellipsoid.

I decided to go for (1.3) for its simplicity and for avoiding extra inheritance. Let me know if you think we should go for a more general approach even at the cost of adding some extra inheritance. I do think that (1.2) is a more elegant and could be a good balanced approach between complexity and flexibility.

2. When does the emitter start emitting particles?

2.1 One idea could be to start as soon as it can. This probably means when the emitter is instantiated. It will have default parameters, so it should be possible. As soon as the emitter instance is modified via the API, the behavior should change on the fly.

2.2 The alternative approach is to use a function (e.g.: SetEmitting()) to start/stop emitting particles. Then, you could instantiate your object, set all the parameters, and then, call SetEmitting(true) when you're ready to emit particles. Even in this approach we could consider if modifying attributes while the emitter is enabled makes sense.

This pull request uses (2.2) because the behavior looks a bit more controlled to me. I'm guessing that the expected behavior should be to support changes in the attributes even if we're emitting particles but I can convinced otherwise.

3. What's the behavior of SetColorRange()?

As far as I know Ogre samples a color from the [start_color, end_color]. In our API discussion, we mentioned interpolation between the two colors. Not sure if this means that the particle should have start_color when is spawn, should finish with end_color at the end of its lifetime, and in between we should interpolate the color smoothly. In this PR, I went for the Ogre approach based on simplicity but again, totally open to discussion.

4. Getters?

This is almost trivial but we didn't include it in our initial API. I didn't add them to this patch but I'm almost convinced that we should do it.

Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
@caguero caguero requested a review from iche033 as a code owner July 9, 2020 21:08
@github-actions github-actions bot added the 🔮 dome Ignition Dome label Jul 9, 2020
@osrf-triage osrf-triage added this to Inbox in Core development Jul 9, 2020
Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
@codecov
Copy link

codecov bot commented Jul 9, 2020

Codecov Report

Merging #113 into master will decrease coverage by 0.34%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #113      +/-   ##
=========================================
- Coverage    7.56%   7.22%   -0.35%     
=========================================
  Files          26      27       +1     
  Lines        1744    2229     +485     
=========================================
+ Hits          132     161      +29     
- Misses       1612    2068     +456     
Impacted Files Coverage Δ
include/ignition/rendering/base/BaseScene.hh 0.00% <0.00%> (ø)
src/base/BaseScene.cc 0.00% <0.00%> (ø)
src/LidarVisual.cc 0.00% <0.00%> (ø)
src/RenderEngineManager.cc 26.50% <0.00%> (+1.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bdf0886...1843624. Read the comment docs.

caguero and others added 3 commits July 9, 2020 23:58
Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me! I made some minor style changes in 8a7b2ee, mainly removing const from primitive types as we've been doing that recently.

1.3: sounds good. I agree we should start with something simple. Using enum's is also consistent with how we are handling different types of markers.

2.2: yep also agree with this. I think ogre equivalent is the setEnabled function.

3: I made an inline comment about doxygen comment of the color range function as it currently says the colors are randomly chosen. I think doing interpolation is better.

4: +1 yeah we should have getters. The accessor functions will also help with unit testing.

include/ignition/rendering/ParticleEmitter.hh Outdated Show resolved Hide resolved
Core development automation moved this from Inbox to In review Jul 10, 2020
Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
@caguero
Copy link
Contributor Author

caguero commented Jul 10, 2020

looks good to me! I made some minor style changes in 8a7b2ee, mainly removing const from primitive types as we've been doing that recently.

Thanks!

1.3: sounds good. I agree we should start with something simple. Using enum's is also consistent with how we are handling different types of markers.

2.2: yep also agree with this. I think ogre equivalent is the setEnabled function.

3: I made an inline comment about doxygen comment of the color range function as it currently says the colors are randomly chosen. I think doing interpolation is better.

Changed in 0323230.

4: +1 yeah we should have getters. The accessor functions will also help with unit testing.

Accessors added in 0323230.

src/ParticleEmitter_TEST.cc Outdated Show resolved Hide resolved
include/ignition/rendering/ParticleEmitter.hh Outdated Show resolved Hide resolved
Signed-off-by: Carlos Aguero <caguero@openrobotics.org>
@caguero caguero merged commit f2e838b into master Jul 13, 2020
Core development automation moved this from In review to Done Jul 13, 2020
@caguero caguero deleted the particles_part2 branch July 13, 2020 18:44
@chapulina chapulina mentioned this pull request Jul 20, 2020
@j-rivero j-rivero removed this from Done in Core development May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔮 dome Ignition Dome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants