godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Add Ring emission shape to CPUParticles2D #10303

Open StamesJames opened 1 month ago

StamesJames commented 1 month ago

Describe the project you are working on

A 2D Shoot'em up game

Describe the problem or limitation you are having in your project

I am trying to visualize a laser loading by pulling in particles in some radius.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

With the emission shape ring, particles would be generated in a ring.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Add a enum Variant EMISSION_SHAPE_RING to the EmissionShape Enum. Give this emission shape the properties emission_ring_inner_radius and emission_ring_outer_radius and uniformly sample in the ring between those circles the following way:

case EMISSION_SHAPE_RING: {
real_t t = MATH_TAU * Math::randf();
real_t radius = emission_ring_inner_radius + Math:sqrt(Math::randf()) * (emission_ring_outer_radius - emission_ring_inner_radius);
p.transform[2] = Vector2(Math::cos(t), Math::in(t)) * radius;
}

I think I should be able to write a PR for this.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I don't think it can be worked around with a few lines of code but maybe with emission masks by loading in a texture of a ring. But this would not be very flexible because you wouldn't be able to change the sizes of the rings easily.

Is there a reason why this should be core and not an add-on in the asset library?

Because there already exists a similar feature in 3D and also I think there was such an emission shape in the 3.x versions of the particle systems (I have seen it in a tutorial once)

Calinou commented 1 month ago

Feel free to open a pull request for this :slightly_smiling_face:

Because there already exists a similar feature in 3D and also I think there was such an emission shape in the 3.x versions of the particle systems (I have seen it in a tutorial once)

This emission shape was never implemented in 2D in the first place, only in 3D:

image

StamesJames commented 1 month ago

Ok nice I will look into this 😀 this will be my first Godot PR 😁