godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.14k stars 96 forks source link

Setting to Swap Y/Z axes to Increase rather than decrease per convention #2048

Closed CitrusWire closed 3 years ago

CitrusWire commented 3 years ago

Describe the project you are working on

n/a

Describe the problem or limitation you are having in your project

Godot increases the Y and the Z axis in the "negative" direction. Or put another way, for 2D projects, the origin (0,0) is the top left, rather than the usually-expected bottom-left.

This is counterintuitive to most people, runs counter to the game industry norm, and increases the likelihood of mistakes by most users.

For example, these are how Godot declares these things:

    Vector2.UP == (0,-1)
    Vector3.FORWARD == (0,0,-1)

As an image (from http://kidscancode.org/godot_recipes/math/transforms/) image

It's unintuitive for "UP" to be a negative value, if I give you the number 5, and say "go up 3", you'll tell me 8, not 2 because people equate "up" (and "forward") with "add". The current approach is akin to defining: Compass.East == Left Compass.West == Right

While I appreciate some domains of computing do have this odd "increase by decreasing" behaviour (i.e. raster handling software), this is not the game industry standard. Below are the random selection I looked up of OS and proprietary engines:

Wikipedia also concurs that this is the "standard" orientation for cartesian coordinate systems - https://en.wikipedia.org/wiki/Cartesian_coordinate_system#In_two_dimensions

This is also how it's taught in basic maths (the level most folks have).

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

The ability for the user to specify what how the Y/Z coordinates work in the engine. These could be either a Project setting or an Engine Setting.

Two options should probably be sufficient, at least for 2D:

Godot: Default; what it is now (although longer term I'd suggest it shouldn't be the default; i.e. change at a major point release)

Vector2.UP == (0,-1)
Vector3.FORWARD == (0,0,-1)

Industry Standard: Y goes up from bottom left, Z increases.

Vector2.UP == (0,1)
Vector2.FORWARD == (0,0,1)

image

(from https://en.wikipedia.org/wiki/File:Cartesian-coordinate-system-with-circle.svg )

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

As above

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

Doesn't seem to be any consistent way to switch it around at the script level.

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

It's an engine thing

Jummit commented 3 years ago
Resolved For reference, here is a coordinate systems cheat sheet: ![coordinate_systems](https://user-images.githubusercontent.com/28286961/103294995-5234ba80-49f3-11eb-9457-49436fee7f39.jpeg) Source: https://twitter.com/FreyaHolmer/status/1325556229410861056 EDIT: I realized that this graphic is not applicable here. > This is counterintuitive to most people How do you know that most people find this counterintuitive? > Industry Standard There is no industry standard. Every application uses the coordinate system that fits their needs.

I'm against such a setting, as it breaks addons and tutorials if you use the wrong system, and it isn't present in any other game engine I know of.

CitrusWire commented 3 years ago

I'm against such a setting, as it breaks addons and tutorials if you use the wrong system

Hence the suggestion for the default. I'd expect it'd be transparent to most addons and all tutorials.

, and it isn't present in any other game engine I know of.

Probably because no other game engine does it in such a squiffy way. ;-)

MaaaxiKing commented 3 years ago

If it were an Option, I would agree but if it were set by the Editor and did not allow the user to change, nearly every existing project will be being destroyed.

Zireael07 commented 3 years ago

Been asked several times (in various variants - there is really no "standard" convention here) and core devs have said multiple times that this won't happen.

omicron321 commented 3 years ago

use v_flip property of a viewport when needed or set -1 y scale of a containing parent

also, your explanations with 3D/2D are mixed without specifying what in which is inverted relatively to what.

basic maths as you say can acommodate with y down for 2D

this is theory crafting about best coordinate systems ideally, all sprites would have y up, screen native coordinate too, and we would read text from bottom to up too

CitrusWire commented 3 years ago

A prime example of where the current situation becomes a gotcha: AnimationTreeBlendSpaces2D. You have to put the "Up" animation at the bottom of the space, and the "Down" animation at the top, completely counter intuitive. The youtube vid I just saw had to point this out explicitly and explained it: "these blend spaces are often used for 3D games and I'm guessing that's why it's not, it doesn't line up, but that's okay, we can work with this".

also, your explanations with 3D/2D are mixed without specifying what in which is inverted relatively to what.

Yep, it's a hard thing to convey, why I tried to explain it 3 different ways.

basic maths as you say can acommodate with y down for 2D

Sure it can, but once you start reversing axis values it's not really "basic maths" any more. Just like I can use innumerable archaic brobdingnagian lexicographic oddities in place of their lilliputian synonyms (translation: It's possible to use fancy/long words to say the exact same thing as simple/short words). You don't do it as a matter of course because most people (even native speakers) don't understand it intuitively despite it being accommodated by basic English.

omicron321 commented 3 years ago

i myself am using 2d transforms/operations at the moment, then project to 3d, i know how this is annoying by default at least 3d is right handed

adding an option to change core axis, is too much trouble and inefficient for computation chain, that's why all tools need to choose one at best, there will be options like ways you display things you can eventually do everything like if everything was in your wanted coordinate orientation and apply transform to your root node

aaronfranke commented 3 years ago

I will copy-paste my explanation from here. The TL;DR is that this won't happen.

I am assuming you are coming at this from a Unity perspective, since it has +Z as forward. You are welcome to rotate your own objects by 180 degrees, but also note that Godot uses a right-handed coordinate system, which is mirrored/flipped compared to Unity's left-handed system - so if you just rotate by 180 degrees, you won't get the same coordinate system as Unity (now the X axis will point the opposite direction).

The standard rotation for Y-is-up right-handed coordinate systems is that +X is right and +Z is back. If you rotate by 180 degrees, then +X is left and +Z is forward. If what you want is equivalence with Unity's +X is right and +Z is forward, this can't be done with a rotation - you'd need to change the handedness of the coordinate system, which would be a hugely complex change and will never happen, especially because right-handed coordinate systems are the standard in math and physics and in pretty much all software that isn't Unity, Unreal, or DirectX.

Godot's Y-is-up right-handed coordinate system is shared by many programs including Minecraft, Maya, and GLTF. Using the same coordinate system as GLTF is an advantage by itself, IMO.

While this won't happen either, it would be more realistic to switch to a Z-is-up, +Y is forward system like in Blender/Source/CryEngine/Max, since that uses the same handedness (and just involves a rotation of 90 degrees).

I'm closing this, because this will never happen, and also because even if the Godot developers would be willing to make this change, this isn't a desirable change because Godot's current coordinate system is already a very good one (same handedness as in math/physics and most software, and same coordinate system as the GLTF standard).