[Reviewed] [3D particle emitter] Fix the emission zone radius and relative particles with the 3D renderer world scale - #2290
Merged
Conversation
…ative particles with the 3D renderer world scale The emitter transformation (which includes the scale of the layer, i.e. the 3D renderer world scale) already converts the emitter shape, and the velocities of relative particles, to the Three.js world units: - The emission zone radius was converted twice: zones were 100 times too small. - The start speed and the gravity are now converted only for particles in world space: relative particles were 100 times too slow. - The trail length is a number of positions, not a distance: it is no longer converted (trails were almost invisible). - The emitter world matrix is updated with its parents when created, so that the first particles are emitted with the layer scale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HdyuCYDD8w7U2Q3p1aHY5M
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up of #2277 (emission zone radius) and #2193, for the Three.js upgrade: 4ian/GDevelop#8853
The emitter is in the layer, whose Three.js scene is scaled by
1 / worldScale. So the emitter's world matrix already converts the emitter shape, and the velocities of relative particles, from pixels to Three.js world units. Converting them in the extension too divided them by the world scale twice.Changes (3.2.0 → 3.2.1)
inverseWorldScale. Zones were 100× too small with the upgrade.updateWorldMatrix(true, true)instead ofupdateMatrixWorld(true), so the parents (with the layer scale) are up to date and the very first particles get the right scale too.Nothing changes on GDevelop versions without the world scale (
inverseWorldScaleis 1 there).Testing
verifyExtension('ParticleEmitter3D')returnssuccess.I created an emitter in the 3D tank example (zone radius 500, spray angle 0, speed 100), rendered every frame, and measured the spawned particles in pixels on a GDevelop build with the runtime of #8853 and on the current release:
(The expected mean distance in a disc of radius 500 is ~333 px; differences come from the random spawn positions.)
🤖 Generated with Claude Code
https://claude.ai/code/session_01HdyuCYDD8w7U2Q3p1aHY5M
Generated by Claude Code