godotengine / godot-proposals

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

Ability to use editor particle function "Create Emission Points From Node" in code during runtime #8106

Open xand00 opened 11 months ago

xand00 commented 11 months ago

Describe the project you are working on

3D Third Person RPG

Describe the problem or limitation you are having in your project

I have fire particles, when i hit some inflammable node, i want fire particles to emit from surface of this inflammable node. But right now i can only add copies of fire particles and generate them only at editor. This is not scalable and it just feels "wrong" to have a bit altered fire particle for each inflammable thing.

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

Add ability to use "Create Emission Points From Node" during runtime so users can create emission points dynamically.

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

var particles: GPUParticles3D = get_node("FireParticles") // or CPUParticles3D 
var mesh_to_generate_emission_points_from: MeshInstance3D = get_node("Mesh")

particles.generate_emission_points(mesh_to_generate_emission_points_from)

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

If doing precise emission points then it can't be worked around as far as i understand, i checked godot source code editor\plugins\gpu_particles_3d_editor_plugin.cpp and this file has ~400 lines.

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

This already can be done in editor and it can really help if some users want to reuse particle without copying it for each node with mesh.

smix8 commented 10 months ago

I remember this was touched in dev chat around 2 months ago when discussing skinned particles.

There was agreement that the current EditorPlugin only functionality should be moved to be available for runtime.

Ideally as static function so the emission point baking can be done on thread from anywhere without problems, not requiring a node or some other SceneTree involving awkwardness like a node path.

RisingThumb commented 4 months ago

Hi, I've written a small commit that exposes the currently editor-plugin only functionality inside of GPUParticle3D instead since it is something I needed on my own project. https://github.com/RisingThumb/RisingThumb-Godot/commit/229d50bcc85317b5d6eef3ff7168ce8444049f3e

There's a handful of changes that should be made further. Firstly the equivalent editorPlugin for CPUParticle3D relies on GPUParticle3DEditorPlugin's generate function which means we have shared logic there, but it's not shared for generating emission points. Additionally this change should probably also be made for CPUParticle3D anyway, and we should be calling the node's generate emission point's function instead of using the old editorplugin functions for generating it- that is if the approach in this commit is what we want to take. It'd also need error checking since I haven't really done much error checking in that commit. idk if this is the approach we want to take since what was noted requires more work.

There was agreement that the current EditorPlugin only functionality should be moved to be available for runtime.

Ideally as static function so the emission point baking can be done on thread from anywhere without problems, not requiring a node or some other SceneTree involving awkwardness like a node path.

Has there been any other progress on this proposal since? If this approach seems like the direction we want to take, I can work on cleaning and improving things for a proper PR for these changes