Skip to content

Commit

Permalink
Merge branch 'godotengine:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
NohbdyAhtall authored Feb 4, 2025
2 parents dcc3f15 + 0b6a717 commit 9ad1abf
Show file tree
Hide file tree
Showing 195 changed files with 4,534 additions and 1,638 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
stages: [manual] # Not automatically triggered, invoked via `pre-commit run --hook-stage manual clang-tidy`

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
rev: v0.9.4
hooks:
- id: ruff
args: [--fix]
Expand All @@ -48,7 +48,7 @@ repos:
types_or: [text]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.14.1
hooks:
- id: mypy
files: \.py$
Expand Down
5 changes: 2 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ if not env["platform"]:
env["platform"] = "windows"

if env["platform"]:
print(f'Automatically detected platform: {env["platform"]}')
print(f"Automatically detected platform: {env['platform']}")

# Deprecated aliases kept for compatibility.
if env["platform"] in compatibility_platform_aliases:
Expand Down Expand Up @@ -998,8 +998,7 @@ if env["disable_3d"]:
if env["disable_advanced_gui"]:
if env.editor_build:
print_error(
"Build option `disable_advanced_gui=yes` cannot be used for editor builds, "
"only for export template builds."
"Build option `disable_advanced_gui=yes` cannot be used for editor builds, only for export template builds."
)
Exit(255)
else:
Expand Down
4 changes: 2 additions & 2 deletions core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,10 +1263,10 @@ void ProjectSettings::refresh_global_class_list() {
Array script_classes = get_global_class_list();
for (int i = 0; i < script_classes.size(); i++) {
Dictionary c = script_classes[i];
if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base")) {
if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base") || !c.has("is_abstract") || !c.has("is_tool")) {
continue;
}
ScriptServer::add_global_class(c["class"], c["base"], c["language"], c["path"]);
ScriptServer::add_global_class(c["class"], c["base"], c["language"], c["path"], c["is_abstract"], c["is_tool"]);
}
}

Expand Down
53 changes: 18 additions & 35 deletions core/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ Input *Input::singleton = nullptr;

void (*Input::set_mouse_mode_func)(Input::MouseMode) = nullptr;
Input::MouseMode (*Input::get_mouse_mode_func)() = nullptr;
void (*Input::set_mouse_mode_override_func)(Input::MouseMode) = nullptr;
Input::MouseMode (*Input::get_mouse_mode_override_func)() = nullptr;
void (*Input::set_mouse_mode_override_enabled_func)(bool) = nullptr;
bool (*Input::is_mouse_mode_override_enabled_func)() = nullptr;
void (*Input::warp_mouse_func)(const Vector2 &p_position) = nullptr;
Input::CursorShape (*Input::get_current_cursor_shape_func)() = nullptr;
void (*Input::set_custom_mouse_cursor_func)(const Ref<Resource> &, Input::CursorShape, const Vector2 &) = nullptr;
Expand All @@ -86,51 +90,29 @@ Input *Input::get_singleton() {
}

void Input::set_mouse_mode(MouseMode p_mode) {
ERR_FAIL_INDEX((int)p_mode, 5);

if (p_mode == mouse_mode) {
return;
}

// Allow to be set even if overridden, to see if the platform allows the mode.
ERR_FAIL_INDEX(p_mode, MouseMode::MOUSE_MODE_MAX);
set_mouse_mode_func(p_mode);
mouse_mode = get_mouse_mode_func();

if (mouse_mode_override_enabled) {
set_mouse_mode_func(mouse_mode_override);
}
}

Input::MouseMode Input::get_mouse_mode() const {
return mouse_mode;
return get_mouse_mode_func();
}

void Input::set_mouse_mode_override_enabled(bool p_enabled) {
if (p_enabled == mouse_mode_override_enabled) {
return;
}

mouse_mode_override_enabled = p_enabled;

if (p_enabled) {
set_mouse_mode_func(mouse_mode_override);
mouse_mode_override = get_mouse_mode_func();
} else {
set_mouse_mode_func(mouse_mode);
}
void Input::set_mouse_mode_override(MouseMode p_mode) {
ERR_FAIL_INDEX(p_mode, MouseMode::MOUSE_MODE_MAX);
set_mouse_mode_override_func(p_mode);
}

void Input::set_mouse_mode_override(MouseMode p_mode) {
ERR_FAIL_INDEX((int)p_mode, 5);
Input::MouseMode Input::get_mouse_mode_override() const {
return get_mouse_mode_override_func();
}

if (p_mode == mouse_mode_override) {
return;
}
void Input::set_mouse_mode_override_enabled(bool p_override_enabled) {
set_mouse_mode_override_enabled_func(p_override_enabled);
}

if (mouse_mode_override_enabled) {
set_mouse_mode_func(p_mode);
mouse_mode_override = get_mouse_mode_func();
}
bool Input::is_mouse_mode_override_enabled() {
return is_mouse_mode_override_enabled_func();
}

void Input::_bind_methods() {
Expand Down Expand Up @@ -199,6 +181,7 @@ void Input::_bind_methods() {
BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED_HIDDEN);
BIND_ENUM_CONSTANT(MOUSE_MODE_MAX);

BIND_ENUM_CONSTANT(CURSOR_ARROW);
BIND_ENUM_CONSTANT(CURSOR_IBEAM);
Expand Down
14 changes: 9 additions & 5 deletions core/input/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ class Input : public Object {
static constexpr uint64_t MAX_EVENT = 32;

public:
// Keep synced with "DisplayServer::MouseMode" enum.
enum MouseMode {
MOUSE_MODE_VISIBLE,
MOUSE_MODE_HIDDEN,
MOUSE_MODE_CAPTURED,
MOUSE_MODE_CONFINED,
MOUSE_MODE_CONFINED_HIDDEN,
MOUSE_MODE_MAX,
};

#undef CursorShape
Expand Down Expand Up @@ -105,10 +107,6 @@ class Input : public Object {
bool legacy_just_pressed_behavior = false;
bool disable_input = false;

MouseMode mouse_mode = MOUSE_MODE_VISIBLE;
bool mouse_mode_override_enabled = false;
MouseMode mouse_mode_override = MOUSE_MODE_VISIBLE;

struct ActionState {
uint64_t pressed_physics_frame = UINT64_MAX;
uint64_t pressed_process_frame = UINT64_MAX;
Expand Down Expand Up @@ -268,6 +266,10 @@ class Input : public Object {

static void (*set_mouse_mode_func)(MouseMode);
static MouseMode (*get_mouse_mode_func)();
static void (*set_mouse_mode_override_func)(MouseMode);
static MouseMode (*get_mouse_mode_override_func)();
static void (*set_mouse_mode_override_enabled_func)(bool);
static bool (*is_mouse_mode_override_enabled_func)();
static void (*warp_mouse_func)(const Vector2 &p_position);

static CursorShape (*get_current_cursor_shape_func)();
Expand All @@ -286,8 +288,10 @@ class Input : public Object {
public:
void set_mouse_mode(MouseMode p_mode);
MouseMode get_mouse_mode() const;
void set_mouse_mode_override_enabled(bool p_enabled);
void set_mouse_mode_override(MouseMode p_mode);
MouseMode get_mouse_mode_override() const;
void set_mouse_mode_override_enabled(bool p_override_enabled);
bool is_mouse_mode_override_enabled();

#ifdef TOOLS_ENABLED
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
Expand Down
2 changes: 1 addition & 1 deletion core/io/file_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ String FileAccess::get_line() const {
uint8_t c = get_8();

while (!eof_reached()) {
if (c == '\n' || c == '\0') {
if (c == '\n' || c == '\0' || get_error() != OK) {
line.push_back(0);
return String::utf8(line.get_data());
} else if (c != '\r') {
Expand Down
29 changes: 17 additions & 12 deletions core/math/basis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,11 @@ void Basis::get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) cons
}

Vector3 Basis::get_euler(EulerOrder p_order) const {
// This epsilon value results in angles within a +/- 0.04 degree range being simplified/truncated.
// Based on testing, this is the largest the epsilon can be without the angle truncation becoming
// visually noticeable.
const real_t epsilon = 0.00000025;

switch (p_order) {
case EulerOrder::XYZ: {
// Euler angles in XYZ convention.
Expand All @@ -466,8 +471,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {

Vector3 euler;
real_t sy = rows[0][2];
if (sy < (1.0f - (real_t)CMP_EPSILON)) {
if (sy > -(1.0f - (real_t)CMP_EPSILON)) {
if (sy < (1.0f - epsilon)) {
if (sy > -(1.0f - epsilon)) {
// is this a pure Y rotation?
if (rows[1][0] == 0 && rows[0][1] == 0 && rows[1][2] == 0 && rows[2][1] == 0 && rows[1][1] == 1) {
// return the simplest form (human friendlier in editor and scripts)
Expand Down Expand Up @@ -501,8 +506,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {

Vector3 euler;
real_t sz = rows[0][1];
if (sz < (1.0f - (real_t)CMP_EPSILON)) {
if (sz > -(1.0f - (real_t)CMP_EPSILON)) {
if (sz < (1.0f - epsilon)) {
if (sz > -(1.0f - epsilon)) {
euler.x = Math::atan2(rows[2][1], rows[1][1]);
euler.y = Math::atan2(rows[0][2], rows[0][0]);
euler.z = Math::asin(-sz);
Expand Down Expand Up @@ -532,8 +537,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {

real_t m12 = rows[1][2];

if (m12 < (1 - (real_t)CMP_EPSILON)) {
if (m12 > -(1 - (real_t)CMP_EPSILON)) {
if (m12 < (1 - epsilon)) {
if (m12 > -(1 - epsilon)) {
// is this a pure X rotation?
if (rows[1][0] == 0 && rows[0][1] == 0 && rows[0][2] == 0 && rows[2][0] == 0 && rows[0][0] == 1) {
// return the simplest form (human friendlier in editor and scripts)
Expand Down Expand Up @@ -568,8 +573,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {

Vector3 euler;
real_t sz = rows[1][0];
if (sz < (1.0f - (real_t)CMP_EPSILON)) {
if (sz > -(1.0f - (real_t)CMP_EPSILON)) {
if (sz < (1.0f - epsilon)) {
if (sz > -(1.0f - epsilon)) {
euler.x = Math::atan2(-rows[1][2], rows[1][1]);
euler.y = Math::atan2(-rows[2][0], rows[0][0]);
euler.z = Math::asin(sz);
Expand All @@ -596,8 +601,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
// -cx*sy sx cx*cy
Vector3 euler;
real_t sx = rows[2][1];
if (sx < (1.0f - (real_t)CMP_EPSILON)) {
if (sx > -(1.0f - (real_t)CMP_EPSILON)) {
if (sx < (1.0f - epsilon)) {
if (sx > -(1.0f - epsilon)) {
euler.x = Math::asin(sx);
euler.y = Math::atan2(-rows[2][0], rows[2][2]);
euler.z = Math::atan2(-rows[0][1], rows[1][1]);
Expand All @@ -624,8 +629,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
// -sy cy*sx cy*cx
Vector3 euler;
real_t sy = rows[2][0];
if (sy < (1.0f - (real_t)CMP_EPSILON)) {
if (sy > -(1.0f - (real_t)CMP_EPSILON)) {
if (sy < (1.0f - epsilon)) {
if (sy > -(1.0f - epsilon)) {
euler.x = Math::atan2(rows[2][1], rows[2][2]);
euler.y = Math::asin(-sy);
euler.z = Math::atan2(rows[1][0], rows[0][0]);
Expand Down
14 changes: 9 additions & 5 deletions core/object/class_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1866,26 +1866,30 @@ void ClassDB::_bind_compatibility(ClassInfo *type, MethodBind *p_method) {
void ClassDB::_bind_method_custom(const StringName &p_class, MethodBind *p_method, bool p_compatibility) {
OBJTYPE_WLOCK;

StringName method_name = p_method->get_name();

ClassInfo *type = classes.getptr(p_class);
if (!type) {
ERR_FAIL_MSG(vformat("Couldn't bind custom method '%s' for instance '%s'.", p_method->get_name(), p_class));
memdelete(p_method);
ERR_FAIL_MSG(vformat("Couldn't bind custom method '%s' for instance '%s'.", method_name, p_class));
}

if (p_compatibility) {
_bind_compatibility(type, p_method);
return;
}

if (type->method_map.has(p_method->get_name())) {
if (type->method_map.has(method_name)) {
// overloading not supported
ERR_FAIL_MSG(vformat("Method already bound '%s::%s'.", p_class, p_method->get_name()));
memdelete(p_method);
ERR_FAIL_MSG(vformat("Method already bound '%s::%s'.", p_class, method_name));
}

#ifdef DEBUG_METHODS_ENABLED
type->method_order.push_back(p_method->get_name());
type->method_order.push_back(method_name);
#endif

type->method_map[p_method->get_name()] = p_method;
type->method_map[method_name] = p_method;
}

MethodBind *ClassDB::_bind_vararg_method(MethodBind *p_bind, const StringName &p_name, const Vector<Variant> &p_default_args, bool p_compatibility) {
Expand Down
33 changes: 1 addition & 32 deletions core/object/make_virtuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def generate_version(argcount, const=False, returns=False, required=False, compa
callptrargsptr += ", "
argtext += f"m_type{i + 1}"
callargtext += f"m_type{i + 1} arg{i + 1}"
callsiargs += f"_to_variant(arg{i + 1})"
callsiargs += f"arg{i + 1}"
callsiargptrs += f"&vargs[{i}]"
callptrargs += (
f"PtrToArg<m_type{i + 1}>::EncodeT argval{i + 1} = (PtrToArg<m_type{i + 1}>::EncodeT)arg{i + 1};\\\n"
Expand Down Expand Up @@ -240,37 +240,6 @@ def run(target, source, env):
#define _GDVIRTUAL_GET_DEPRECATED(m_name, m_name_sn, m_compat)
#endif
// MSVC WORKAROUND START
// FIXME The below helper functions are needed to work around an MSVC bug.
// They should be removed (by modifying core/object/make_virtuals.py) once the bug ceases to be triggered.
// The bug is triggered by the following code:
// `Variant(arg)`
// Through the introduction of the move constructor, MSVC forgets that `operator Variant()`
// is also a valid way to resolve this call. So for some argument types, it fails the call because
// it cannot convert to `Variant`.
// The function `_to_variant` helps the compiler select `.operator Variant()` for appropriate arguments using SFINAE.
template <typename T, typename = void>
struct has_variant_operator : std::false_type {};
template <typename T>
struct has_variant_operator<T, std::void_t<decltype(std::declval<T>().operator Variant())>> : std::true_type {};
// Function that is enabled if T has `.operator Variant()`.
template <typename T>
_ALWAYS_INLINE_ typename std::enable_if<has_variant_operator<T>::value, Variant>::type
_to_variant(T&& t) {
return std::forward<T>(t).operator Variant();
}
// Function that is enabled if T does not have `.operator Variant()`.
template <typename T>
_ALWAYS_INLINE_ typename std::enable_if<!has_variant_operator<T>::value, Variant>::type
_to_variant(T&& t) {
return Variant(std::forward<T>(t));
}
// MSVC WORKAROUND END
"""

for i in range(max_versions + 1):
Expand Down
Loading

0 comments on commit 9ad1abf

Please sign in to comment.