bilowik / bevy_despawn_particles

The Unlicense
2 stars 0 forks source link

What to do if the number of triangles in the triangle mesh exceed the target num particles? #17

Open bilowik opened 1 year ago

bilowik commented 1 year ago

For the default of 64, this should be a very rare occurrence so it should not be too much a worry, but there SHOULD be some, configurable functionality. We can do, none, one, or multiple of the proposed solutions.

Nothing

Don't do anything, just live with the number of particles that will be spawned

Pros

Maintainable, simple, consistency in particles

Cons

Less fine-tuned control, potentially for a large number of particles to be spawned.

Merge together triangles

Pros

Every part of the original mesh is utilized

Cons

Can lead to misshapen particles, inconsistently sized particles, or, depending on how the mesh is constructed and vertices ordered, very awkward, disjoint particles

Skip a certain number of triangles

Calculation for how many to skip on an interval could be (num_triangles / target_num_particles).ceiling() (or maybe .floor()?) For example, if our target is 32 and we have 64, we only use every other triangle. If we have 96 and our target is 32, we only use every 3rd triangle. For an uneven example, 48 triangles with target 32, would become 24 triangles skipping every other. Or, to avoid going below target, we could even do .floor() instead, so in the previous example we would retain the 48.

Pros

Consistency in particles, simple, efficient

Cons

Could create awkward spacing between particles depending on the even and the way the mesh was built.