Rename reflect() and bounce() to avoid confusion #12979
Dark-Horizons
started this conversation in
Engine Core
Replies: 2 comments 3 replies
-
This is not possible unless you suggest to just rename |
Beta Was this translation helpful? Give feedback.
1 reply
-
Didn't we already have such a proposal? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In mathematics, the term reflect generally means to produce a mirror image with respect to a line or plane. This definition typically implies that the given vector represents the normal to the surface, since mirroring is computed relative to that perpendicular direction.
In most game engines and physics/maths libraries (Unity, Unreal, Box2D, GLM, etc.), reflect() follows this convention: it takes a normal vector and returns the reflection of the input vector as if bouncing off that surface.
Godot’s current implementation differs:
reflect(line) expects the direction of the line (parallel to the surface), not the normal.
bounce(normal) performs the operation that most engines (and maths libraries) call reflect().
This mismatch can be confusing for developers transitioning from other engines or with a background in vector mathematics. It also makes reading code less intuitive when collaborating across different codebases.
Suggested changes:
Rename the current
reflect()
tomirror()
(or a similar name that clearly states it mirrors with respect to a given line direction).Rename the current
bounce()
toreflect()
to align with established conventions in mathematics and other engines.If backward compatibility is a concern, both names could coexist for a transitional period, with the old names marked as deprecated.
This change would:
Beta Was this translation helpful? Give feedback.
All reactions