-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix use of non-existent Vector3.Axis
enum type in built-in methods and members
#99341
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
50 changes: 50 additions & 0 deletions
50
modules/godot_physics_3d/godot_physics_server_3d.compat.inc
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/**************************************************************************/ | ||
/* godot_physics_server_3d.compat.inc */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | ||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
#ifndef DISABLE_DEPRECATED | ||
#include "godot_physics_server_3d.h" | ||
|
||
void GodotPhysicsServer3D::_generic_6dof_joint_set_param_bind_compat_99341(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) { | ||
GodotPhysicsServer3D::generic_6dof_joint_set_param(p_joint, (int)p_axis, p_param, p_value); | ||
} | ||
|
||
real_t GodotPhysicsServer3D::_generic_6dof_joint_get_param_bind_compat_99341(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) const { | ||
return GodotPhysicsServer3D::generic_6dof_joint_get_param(p_joint, (int)p_axis, p_param); | ||
} | ||
|
||
void GodotPhysicsServer3D::_generic_6dof_joint_set_flag_bind_compat_99341(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) { | ||
GodotPhysicsServer3D::generic_6dof_joint_set_flag(p_joint, (int)p_axis, p_flag, p_enable); | ||
} | ||
|
||
bool GodotPhysicsServer3D::_generic_6dof_joint_get_flag_bind_compat_99341(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) const { | ||
return GodotPhysicsServer3D::generic_6dof_joint_get_flag(p_joint, (int)p_axis, p_flag); | ||
} | ||
|
||
#endif //DISABLE_DEPRECATED |
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the right approach. Even if binary compatibility is retained, this changes the public API exposed towards extensions.
Bindings such as godot-rust and Swift-Godot have been built around a type Vector3Axis (Rust) or Vector3.Axis (Swift). You can't just remove it because of an issue in
set_axis()
, while it works everywhere else.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I may (as someone who noticed the issue but isn't proficient in C++), the issue seems to be deeper than just set_axis(), since this PR finds and eliminates references to the same enum in multiple classes. I've just checked & found that the enum Vector3.Axis does exist in the code after all, but trying to access it in GDScript results in errors. If eliminating it breaks compat, then perhaps the right approach would be finding a way to expose it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the same but no class has exposed enums, so I thought that wasn't the intended approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Precisely my thoughts. These enums from Variants should be exposed appropriately and used across the codebase like
Vector3.Axis
is. However, doing so is not straightforward because, unlike enums from classes inheriting Object, there's currently no way to do it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some low-level classes have them; off the top of my head - HTTPClient has enums for Method, Status and ResponseCode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bromeon
I looked at other implementations for other classes like
Vector4
andVector2
. None of them had that issue, instead they treatedVector2.Axis
params and return types as anint
. At least for binded methods. So I thought I'd change any binded method that usesVector3.Axis
as param/return type toint
.I basically matched
Vector3
's implementation withVector2
,Vector2I
,Vector3I
,Vector4
,Vector4I
, andPlane
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are global enums though. They already contain enums such as
EulerOrder
specific to geometric builtin types, soVector3Axis
and futureVector2Axis/Vector4Axis
wouldn't be that out of place.DitIt would still technically be a compatibility breakage, but we don't just plain remove a valid feature.
Vector3.Axis
andVector3Axis
in the JSON.Edit: what's not so nice with that is that the constants are effectively duplicated. But retrofitting builtin enums seems like a huge endeavour for these few (others like
EulerAngle
,VariantType
,VariantOperator
already exist in global scope and can't just be moved...)Maybe status quo is still the lesser evil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we just deprecated VectorX.Axis enums and replaced them with
@GlobalScope.VectorAxis
that would looks something like thisthat way its only one enum for all vector types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about a single enum type; you could then pass
VECTOR_AXIS_W
to an API that expectsVector2.Axis
. If all APIs refer toVectorAxis
, the documentation aspect (which dimension) also gets lost.