diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index 425261aa6ce..c3506a7eeaa 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -169,7 +169,7 @@ public: EngineDebugger::get_singleton()->send_message("performance:profile_frame", arr); } - PerformanceProfiler(Object *p_performance) { + explicit PerformanceProfiler(Object *p_performance) { performance = p_performance; } }; diff --git a/core/debugger/remote_debugger.h b/core/debugger/remote_debugger.h index aada92da602..fdb312ae680 100644 --- a/core/debugger/remote_debugger.h +++ b/core/debugger/remote_debugger.h @@ -108,7 +108,7 @@ public: void send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, bool p_editor_notify, ErrorHandlerType p_type); void debug(bool p_can_continue = true, bool p_is_error_breakpoint = false); - RemoteDebugger(Ref p_peer); + explicit RemoteDebugger(Ref p_peer); ~RemoteDebugger(); }; diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index 34a11758f88..076d04a5eb8 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -49,10 +49,10 @@ class NativeExtensionMethodBind : public MethodBind { bool vararg; protected: - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { return Variant::Type(get_argument_type_func(method_userdata, p_arg)); } - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { GDNativePropertyInfo pinfo; get_argument_info_func(method_userdata, p_arg, &pinfo); PropertyInfo ret; @@ -66,11 +66,13 @@ protected: } public: - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { +#ifdef DEBUG_METHODS_ENABLED + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { return GodotTypeInfo::Metadata(get_argument_metadata_func(method_userdata, p_arg)); } +#endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { Variant ret; GDExtensionClassInstancePtr extension_instance = p_object->_get_extension_instance(); GDNativeCallError ce{ GDNATIVE_CALL_OK, 0, 0 }; @@ -80,16 +82,16 @@ public: r_error.expected = ce.expected; return ret; } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { ERR_FAIL_COND_MSG(vararg, "Vararg methods don't have ptrcall support. This is most likely an engine bug."); GDExtensionClassInstancePtr extension_instance = p_object->_get_extension_instance(); ptrcall_func(method_userdata, extension_instance, (const GDNativeTypePtr *)p_args, (GDNativeTypePtr)r_ret); } - virtual bool is_vararg() const { + virtual bool is_vararg() const override { return false; } - NativeExtensionMethodBind(const GDNativeExtensionClassMethodInfo *p_method_info) { + explicit NativeExtensionMethodBind(const GDNativeExtensionClassMethodInfo *p_method_info) { method_userdata = p_method_info->method_userdata; call_func = p_method_info->call_func; ptrcall_func = p_method_info->ptrcall_func; diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 44df2029bde..17e87c835a3 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -93,7 +93,7 @@ private: PathMD5() {} - PathMD5(const Vector &p_buf) { + explicit PathMD5(const Vector &p_buf) { a = *((uint64_t *)&p_buf[0]); b = *((uint64_t *)&p_buf[8]); } diff --git a/core/io/logger.h b/core/io/logger.h index e3ac00f11ce..8ac086e3763 100644 --- a/core/io/logger.h +++ b/core/io/logger.h @@ -67,7 +67,7 @@ public: */ class StdLogger : public Logger { public: - virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0; + virtual void logv(const char *p_format, va_list p_list, bool p_err) override _PRINTF_FORMAT_ATTRIBUTE_2_0; virtual ~StdLogger() {} }; @@ -87,19 +87,19 @@ class RotatedFileLogger : public Logger { void rotate_file(); public: - RotatedFileLogger(const String &p_base_path, int p_max_files = 10); + explicit RotatedFileLogger(const String &p_base_path, int p_max_files = 10); - virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0; + virtual void logv(const char *p_format, va_list p_list, bool p_err) override _PRINTF_FORMAT_ATTRIBUTE_2_0; }; class CompositeLogger : public Logger { Vector loggers; public: - CompositeLogger(Vector p_loggers); + explicit CompositeLogger(Vector p_loggers); - virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0; - virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type = ERR_ERROR); + virtual void logv(const char *p_format, va_list p_list, bool p_err) override _PRINTF_FORMAT_ATTRIBUTE_2_0; + virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type = ERR_ERROR) override; void add_logger(Logger *p_logger); diff --git a/core/io/resource.cpp b/core/io/resource.cpp index bf914388106..96efffd49b5 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -257,7 +257,7 @@ Ref Resource::duplicate(bool p_subresources) const { List plist; get_property_list(&plist); - Ref r = (Resource *)ClassDB::instantiate(get_class()); + Ref r = static_cast(ClassDB::instantiate(get_class())); ERR_FAIL_COND_V(r.is_null(), Ref()); for (const PropertyInfo &E : plist) { diff --git a/core/math/convex_hull.cpp b/core/math/convex_hull.cpp index bd292f4c2ad..23a0b5dd547 100644 --- a/core/math/convex_hull.cpp +++ b/core/math/convex_hull.cpp @@ -509,7 +509,7 @@ public: Face() { } - void init(Vertex *p_a, Vertex *p_b, Vertex *p_c) { + void init(Vertex *p_a, const Vertex *p_b, const Vertex *p_c) { nearby_vertex = p_a; origin = p_a->point; dir0 = *p_b - *p_a; @@ -614,7 +614,7 @@ private: static Orientation get_orientation(const Edge *p_prev, const Edge *p_next, const Point32 &p_s, const Point32 &p_t); Edge *find_max_angle(bool p_ccw, const Vertex *p_start, const Point32 &p_s, const Point64 &p_rxs, const Point64 &p_ssxrxs, Rational64 &p_min_cot); - void find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, Vertex *p_stop0, Vertex *p_stop1); + void find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, const Vertex *p_stop0, const Vertex *p_stop1); Edge *new_edge_pair(Vertex *p_from, Vertex *p_to); @@ -1189,7 +1189,7 @@ ConvexHullInternal::Edge *ConvexHullInternal::find_max_angle(bool p_ccw, const V return min_edge; } -void ConvexHullInternal::find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, Vertex *p_stop0, Vertex *p_stop1) { +void ConvexHullInternal::find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, const Vertex *p_stop0, const Vertex *p_stop1) { Edge *start0 = p_e0; Edge *start1 = p_e1; Point32 et0 = start0 ? start0->target->point : p_c0->point; diff --git a/core/math/geometry_3d.cpp b/core/math/geometry_3d.cpp index bd22bffb1f3..f76de079e48 100644 --- a/core/math/geometry_3d.cpp +++ b/core/math/geometry_3d.cpp @@ -904,8 +904,8 @@ Vector Geometry3D::compute_convex_mesh_points(const Plane *p_planes, in /* dt of 1d function using squared distance */ static void edt(float *f, int stride, int n) { float *d = (float *)alloca(sizeof(float) * n + sizeof(int) * n + sizeof(float) * (n + 1)); - int *v = (int *)&(d[n]); - float *z = (float *)&v[n]; + int *v = reinterpret_cast(&(d[n])); + float *z = reinterpret_cast(&v[n]); int k = 0; v[0] = 0; diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index b7412778725..068bc0397e1 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -103,6 +103,9 @@ public: static _ALWAYS_INLINE_ double log(double p_x) { return ::log(p_x); } static _ALWAYS_INLINE_ float log(float p_x) { return ::logf(p_x); } + static _ALWAYS_INLINE_ double log1p(double p_x) { return ::log1p(p_x); } + static _ALWAYS_INLINE_ float log1p(float p_x) { return ::log1pf(p_x); } + static _ALWAYS_INLINE_ double log2(double p_x) { return ::log2(p_x); } static _ALWAYS_INLINE_ float log2(float p_x) { return ::log2f(p_x); } diff --git a/core/object/method_bind.h b/core/object/method_bind.h index bde6cba1993..28701959118 100644 --- a/core/object/method_bind.h +++ b/core/object/method_bind.h @@ -152,7 +152,7 @@ protected: MethodInfo method_info; public: - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { if (p_arg < 0) { return _gen_return_type_info(); } else if (p_arg < method_info.arguments.size()) { @@ -162,23 +162,23 @@ public: } } - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { return _gen_argument_type_info(p_arg).type; } #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int) const override { return GodotTypeInfo::METADATA_NONE; } #endif - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { ERR_FAIL(); // Can't call. } virtual bool is_const() const { return false; } - virtual bool is_vararg() const { return true; } + virtual bool is_vararg() const override { return true; } MethodBindVarArgBase( R (T::*p_method)(const Variant **, int, Callable::CallError &), @@ -224,7 +224,7 @@ class MethodBindVarArgT : public MethodBindVarArgBase, T, v friend class MethodBindVarArgBase, T, void, false>; public: - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { (static_cast(p_object)->*MethodBindVarArgBase, T, void, false>::method)(p_args, p_arg_count, r_error); return {}; } @@ -255,7 +255,7 @@ class MethodBindVarArgTR : public MethodBindVarArgBase, friend class MethodBindVarArgBase, T, R, true>; public: - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { return (static_cast(p_object)->*MethodBindVarArgBase, T, R, true>::method)(p_args, p_arg_count, r_error); } @@ -303,7 +303,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { @@ -314,7 +314,7 @@ protected: #pragma GCC diagnostic pop #endif - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { PropertyInfo pi; call_get_argument_type_info(p_arg, pi); return pi; @@ -322,25 +322,25 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { return call_get_argument_metadata(p_arg); } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { #ifdef TYPED_METHOD_BIND call_with_variant_args_dv(static_cast(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); #else - call_with_variant_args_dv((MB_T *)(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); + call_with_variant_args_dv(reinterpret_cast(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); #endif return Variant(); } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { #ifdef TYPED_METHOD_BIND call_with_ptr_args(static_cast(p_object), method, p_args); #else - call_with_ptr_args((MB_T *)(p_object), method, p_args); + call_with_ptr_args(reinterpret_cast(p_object), method, p_args); #endif } @@ -378,7 +378,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { @@ -389,7 +389,7 @@ protected: #pragma GCC diagnostic pop #endif - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { PropertyInfo pi; call_get_argument_type_info(p_arg, pi); return pi; @@ -397,25 +397,25 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { return call_get_argument_metadata(p_arg); } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { #ifdef TYPED_METHOD_BIND call_with_variant_argsc_dv(static_cast(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); #else - call_with_variant_argsc_dv((MB_T *)(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); + call_with_variant_argsc_dv(reinterpret_cast(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); #endif return Variant(); } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { #ifdef TYPED_METHOD_BIND call_with_ptr_argsc(static_cast(p_object), method, p_args); #else - call_with_ptr_argsc((MB_T *)(p_object), method, p_args); + call_with_ptr_argsc(reinterpret_cast(p_object), method, p_args); #endif } @@ -455,7 +455,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { @@ -463,7 +463,7 @@ protected: } } - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { PropertyInfo pi; call_get_argument_type_info(p_arg, pi); @@ -478,7 +478,7 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { if (p_arg >= 0) { return call_get_argument_metadata(p_arg); } else { @@ -487,21 +487,21 @@ public: } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { Variant ret; #ifdef TYPED_METHOD_BIND call_with_variant_args_ret_dv(static_cast(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); #else - call_with_variant_args_ret_dv((MB_T *)p_object, method, p_args, p_arg_count, ret, r_error, get_default_arguments()); + call_with_variant_args_ret_dv(reinterpret_cast(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); #endif return ret; } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { #ifdef TYPED_METHOD_BIND call_with_ptr_args_ret(static_cast(p_object), method, p_args, r_ret); #else - call_with_ptr_args_ret((MB_T *)(p_object), method, p_args, r_ret); + call_with_ptr_args_ret(reinterpret_cast(p_object), method, p_args, r_ret); #endif } @@ -542,7 +542,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { @@ -550,7 +550,7 @@ protected: } } - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { PropertyInfo pi; call_get_argument_type_info(p_arg, pi); @@ -565,7 +565,7 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { if (p_arg >= 0) { return call_get_argument_metadata(p_arg); } else { @@ -574,21 +574,21 @@ public: } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { Variant ret; #ifdef TYPED_METHOD_BIND call_with_variant_args_retc_dv(static_cast(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); #else - call_with_variant_args_retc_dv((MB_T *)(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); + call_with_variant_args_retc_dv(reinterpret_cast(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); #endif return ret; } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { #ifdef TYPED_METHOD_BIND call_with_ptr_args_retc(static_cast(p_object), method, p_args, r_ret); #else - call_with_ptr_args_retc((MB_T *)(p_object), method, p_args, r_ret); + call_with_ptr_args_retc(reinterpret_cast(p_object), method, p_args, r_ret); #endif } @@ -626,7 +626,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { @@ -637,7 +637,7 @@ protected: #pragma GCC diagnostic pop #endif - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { PropertyInfo pi; call_get_argument_type_info(p_arg, pi); return pi; @@ -645,18 +645,18 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { return call_get_argument_metadata(p_arg); } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { (void)p_object; // unused call_with_variant_args_static_dv(function, p_args, p_arg_count, r_error, get_default_arguments()); return Variant(); } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { (void)p_object; (void)r_ret; call_with_ptr_args_static_method(function, p_args); @@ -689,7 +689,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type(p_arg); } else { @@ -700,7 +700,7 @@ protected: #pragma GCC diagnostic pop #endif - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { PropertyInfo pi; call_get_argument_type_info(p_arg, pi); @@ -712,7 +712,7 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { if (p_arg >= 0) { return call_get_argument_metadata(p_arg); } else { @@ -721,13 +721,13 @@ public: } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { Variant ret; call_with_variant_args_static_ret_dv(function, p_args, p_arg_count, ret, r_error, get_default_arguments()); return ret; } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { (void)p_object; call_with_ptr_args_static_method_ret(function, p_args, r_ret); } diff --git a/core/os/keyboard.h b/core/os/keyboard.h index a21d81b2e7d..3176a8a210c 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -294,7 +294,7 @@ enum class Key { enum class KeyModifierMask { CODE_MASK = ((1 << 25) - 1), ///< Apply this mask to any keycode to remove modifiers. - MODIFIER_MASK = (0xFF << 24), ///< Apply this mask to isolate modifiers. + MODIFIER_MASK = (0x7F << 24), ///< Apply this mask to isolate modifiers. SHIFT = (1 << 25), ALT = (1 << 26), META = (1 << 27), diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 7199121932a..a2b1e4c4289 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -4124,15 +4124,11 @@ String String::path_to(const String &p_path) const { dst += "/"; } - String base; - if (src.begins_with("res://") && dst.begins_with("res://")) { - base = "res:/"; src = src.replace("res://", "/"); dst = dst.replace("res://", "/"); } else if (src.begins_with("user://") && dst.begins_with("user://")) { - base = "user:/"; src = src.replace("user://", "/"); dst = dst.replace("user://", "/"); @@ -4147,7 +4143,6 @@ String String::path_to(const String &p_path) const { return p_path; //impossible to do this } - base = src_begin; src = src.substr(src_begin.length(), src.length()); dst = dst.substr(dst_begin.length(), dst.length()); } diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index b3e909b4892..da5d73d5194 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -184,7 +184,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { if (p_type_from == p_type_to) { return true; } - if (p_type_to == NIL && p_type_from != NIL) { //nil can convert to anything + if (p_type_to == NIL) { //nil can convert to anything return true; } @@ -490,7 +490,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type if (p_type_from == p_type_to) { return true; } - if (p_type_to == NIL && p_type_from != NIL) { //nil can convert to anything + if (p_type_to == NIL) { //nil can convert to anything return true; } diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index f1daf1de13f..9dae0720d9d 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1239,10 +1239,10 @@ void Variant::get_method_list(List *p_list) const { void Variant::get_constants_for_type(Variant::Type p_type, List *p_constants) { ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); - _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type]; + const _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type]; #ifdef DEBUG_ENABLED - for (List::Element *E = cd.value_ordered.front(); E; E = E->next()) { + for (const List::Element *E = cd.value_ordered.front(); E; E = E->next()) { p_constants->push_back(E->get()); #else for (const KeyValue &E : cd.value) { @@ -1251,7 +1251,7 @@ void Variant::get_constants_for_type(Variant::Type p_type, List *p_c } #ifdef DEBUG_ENABLED - for (List::Element *E = cd.variant_value_ordered.front(); E; E = E->next()) { + for (const List::Element *E = cd.variant_value_ordered.front(); E; E = E->next()) { p_constants->push_back(E->get()); #else for (const KeyValue &E : cd.variant_value) { diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index e889a1bb40a..5fc6df8f39b 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -344,7 +344,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri if (string_name) { r_token.type = TK_STRING_NAME; r_token.value = StringName(str); - string_name = false; //reset } else { r_token.type = TK_STRING; r_token.value = str; diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index da6513a08bd..0a25e368996 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -2013,7 +2013,7 @@ Key Code mask. - + Modifier key mask. diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 441b049b50e..ebf538351eb 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -823,24 +823,24 @@ void RasterizerCanvasGLES3::_render_batch(uint32_t &r_index) { } // TODO maybe dont use -void RasterizerCanvasGLES3::_end_batch(uint32_t &r_index) { +void RasterizerCanvasGLES3::_end_batch(uint32_t p_index) { for (int i = 0; i < 4; i++) { - state.instance_data_array[r_index].modulation[i] = 0.0; - state.instance_data_array[r_index].ninepatch_margins[i] = 0.0; - state.instance_data_array[r_index].src_rect[i] = 0.0; - state.instance_data_array[r_index].dst_rect[i] = 0.0; + state.instance_data_array[p_index].modulation[i] = 0.0; + state.instance_data_array[p_index].ninepatch_margins[i] = 0.0; + state.instance_data_array[p_index].src_rect[i] = 0.0; + state.instance_data_array[p_index].dst_rect[i] = 0.0; } - state.instance_data_array[r_index].flags = uint32_t(0); - state.instance_data_array[r_index].color_texture_pixel_size[0] = 0.0; - state.instance_data_array[r_index].color_texture_pixel_size[1] = 0.0; + state.instance_data_array[p_index].flags = uint32_t(0); + state.instance_data_array[p_index].color_texture_pixel_size[0] = 0.0; + state.instance_data_array[p_index].color_texture_pixel_size[1] = 0.0; - state.instance_data_array[r_index].pad[0] = 0.0; - state.instance_data_array[r_index].pad[1] = 0.0; + state.instance_data_array[p_index].pad[0] = 0.0; + state.instance_data_array[p_index].pad[1] = 0.0; - state.instance_data_array[r_index].lights[0] = uint32_t(0); - state.instance_data_array[r_index].lights[1] = uint32_t(0); - state.instance_data_array[r_index].lights[2] = uint32_t(0); - state.instance_data_array[r_index].lights[3] = uint32_t(0); + state.instance_data_array[p_index].lights[0] = uint32_t(0); + state.instance_data_array[p_index].lights[1] = uint32_t(0); + state.instance_data_array[p_index].lights[2] = uint32_t(0); + state.instance_data_array[p_index].lights[3] = uint32_t(0); } RID RasterizerCanvasGLES3::light_create() { @@ -1102,8 +1102,8 @@ RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vec { glBindBuffer(GL_ARRAY_BUFFER, pb.vertex_buffer); glBufferData(GL_ARRAY_BUFFER, stride * vertex_count * sizeof(float), nullptr, GL_STATIC_DRAW); // TODO may not be necessary - const uint8_t *r = polygon_buffer.ptr(); - float *fptr = (float *)r; + uint8_t *r = polygon_buffer.ptrw(); + float *fptr = reinterpret_cast(r); uint32_t *uptr = (uint32_t *)r; uint32_t base_offset = 0; { diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h index a962796b2fa..99b079b8bbe 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.h +++ b/drivers/gles3/rasterizer_canvas_gles3.h @@ -270,7 +270,7 @@ public: void _render_items(RID p_to_render_target, int p_item_count, const Transform2D &p_canvas_transform_inverse, Light *p_lights, bool p_to_backbuffer = false); void _render_item(RID p_render_target, const Item *p_item, const Transform2D &p_canvas_transform_inverse, Item *¤t_clip, Light *p_lights, uint32_t &r_index); void _render_batch(uint32_t &p_max_index); - void _end_batch(uint32_t &p_max_index); + void _end_batch(uint32_t p_index); void _allocate_instance_data_buffer(); void initialize(); diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index 0c27b76ed8e..a6c35b6837f 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -379,7 +379,7 @@ float AudioDriverPulseAudio::get_latency() { } void AudioDriverPulseAudio::thread_func(void *p_udata) { - AudioDriverPulseAudio *ad = (AudioDriverPulseAudio *)p_udata; + AudioDriverPulseAudio *ad = static_cast(p_udata); unsigned int write_ofs = 0; size_t avail_bytes = 0; uint64_t default_device_msec = OS::get_singleton()->get_ticks_msec(); diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 400802686e2..59b4c34c3f1 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -6255,7 +6255,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma //validate with inputs for (uint32_t i = 0; i < 32; i++) { - if (!(shader->vertex_input_mask & (1 << i))) { + if (!(shader->vertex_input_mask & (1UL << i))) { continue; } bool found = false; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index a084a105288..80e251f6c8c 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -586,20 +586,20 @@ public: pi.name = "value"; p_list->push_back(pi); } else { - PropertyHint hint = PROPERTY_HINT_NONE; - String hint_string; + PropertyHint val_hint = PROPERTY_HINT_NONE; + String val_hint_string; if (v.get_type() == Variant::OBJECT) { // Could actually check the object property if exists..? Yes I will! Ref res = v; if (res.is_valid()) { - hint = PROPERTY_HINT_RESOURCE_TYPE; - hint_string = res->get_class(); + val_hint = PROPERTY_HINT_RESOURCE_TYPE; + val_hint_string = res->get_class(); } } if (v.get_type() != Variant::NIL) { - p_list->push_back(PropertyInfo(v.get_type(), "value", hint, hint_string)); + p_list->push_back(PropertyInfo(v.get_type(), "value", val_hint, val_hint_string)); } } @@ -1264,20 +1264,20 @@ public: pi.name = "value"; p_list->push_back(pi); } else { - PropertyHint hint = PROPERTY_HINT_NONE; - String hint_string; + PropertyHint val_hint = PROPERTY_HINT_NONE; + String val_hint_string; if (v.get_type() == Variant::OBJECT) { // Could actually check the object property if exists..? Yes I will! Ref res = v; if (res.is_valid()) { - hint = PROPERTY_HINT_RESOURCE_TYPE; - hint_string = res->get_class(); + val_hint = PROPERTY_HINT_RESOURCE_TYPE; + val_hint_string = res->get_class(); } } if (v.get_type() != Variant::NIL) { - p_list->push_back(PropertyInfo(v.get_type(), "value", hint, hint_string)); + p_list->push_back(PropertyInfo(v.get_type(), "value", val_hint, val_hint_string)); } } } @@ -1572,7 +1572,6 @@ void AnimationTimelineEdit::_notification(int p_what) { Color color_time_dec = color; color_time_dec.a *= 0.5; #define SC_ADJ 100 - int min = 30; int dec = 1; int step = 1; int decimals = 2; @@ -1588,7 +1587,7 @@ void AnimationTimelineEdit::_notification(int p_what) { const int max_sc_width = String::num(max_sc).length() * max_digit_width; while (!step_found) { - min = max_sc_width; + int min = max_sc_width; if (decimals > 0) { min += period_width + max_digit_width * decimals; } @@ -2552,7 +2551,7 @@ bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant } Ref AnimationTrackEdit::_get_key_type_icon() const { - Ref type_icons[9] = { + const Ref type_icons[9] = { get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), get_theme_icon(SNAME("KeyTrackPosition"), SNAME("EditorIcons")), get_theme_icon(SNAME("KeyTrackRotation"), SNAME("EditorIcons")), diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index f8bf12227a1..bea95d873ec 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -101,7 +101,7 @@ void AudioStreamPreviewGenerator::_update_emit(ObjectID p_id) { } void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) { - Preview *preview = (Preview *)p_preview; + Preview *preview = static_cast(p_preview); float muxbuff_chunk_s = 0.25; diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index b34b08b5dea..3526b4ce4c8 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -128,7 +128,7 @@ void ExportTemplateManager::_download_current() { } _download_template(mirror_url, true); - } else if (!mirrors_available && !is_refreshing_mirrors) { + } else if (!is_refreshing_mirrors) { _set_current_progress_status(TTR("Retrieving the mirror list...")); _refresh_mirrors(); } diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index fe32399fc64..f8c99ff7d4d 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -58,7 +58,7 @@ Transform3D Collada::get_root_transform() const { return unit_scale_transform; } -void Collada::Vertex::fix_unit_scale(Collada &state) { +void Collada::Vertex::fix_unit_scale(const Collada &state) { #ifdef COLLADA_IMPORT_SCALE_SCENE vertex *= state.state.unit_scale; #endif diff --git a/editor/import/collada.h b/editor/import/collada.h index b5e4cd99839..85735e93acc 100644 --- a/editor/import/collada.h +++ b/editor/import/collada.h @@ -266,7 +266,7 @@ public: } } - void fix_unit_scale(Collada &state); + void fix_unit_scale(const Collada &state); bool operator<(const Vertex &p_vert) const { if (uid == p_vert.uid) { diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 2415615a45f..8397772bf80 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -530,25 +530,25 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co state_machine_draw->draw_set_transform_matrix(Transform2D()); } -void AnimationNodeStateMachineEditor::_clip_src_line_to_rect(Vector2 &r_from, Vector2 &r_to, const Rect2 &p_rect) { - if (r_to == r_from) { +void AnimationNodeStateMachineEditor::_clip_src_line_to_rect(Vector2 &r_from, const Vector2 &p_to, const Rect2 &p_rect) { + if (p_to == r_from) { return; } //this could be optimized... - Vector2 n = (r_to - r_from).normalized(); + Vector2 n = (p_to - r_from).normalized(); while (p_rect.has_point(r_from)) { r_from += n; } } -void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(Vector2 &r_from, Vector2 &r_to, const Rect2 &p_rect) { - if (r_to == r_from) { +void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(const Vector2 &p_from, Vector2 &r_to, const Rect2 &p_rect) { + if (r_to == p_from) { return; } //this could be optimized... - Vector2 n = (r_to - r_from).normalized(); + Vector2 n = (r_to - p_from).normalized(); while (p_rect.has_point(r_to)) { r_to -= n; } diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h index bf3f7e93cf5..fe3f6f370ca 100644 --- a/editor/plugins/animation_state_machine_editor.h +++ b/editor/plugins/animation_state_machine_editor.h @@ -147,8 +147,8 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { void _open_editor(const String &p_name); void _scroll_changed(double); - void _clip_src_line_to_rect(Vector2 &r_from, Vector2 &r_to, const Rect2 &p_rect); - void _clip_dst_line_to_rect(Vector2 &r_from, Vector2 &r_to, const Rect2 &p_rect); + void _clip_src_line_to_rect(Vector2 &r_from, const Vector2 &p_to, const Rect2 &p_rect); + void _clip_dst_line_to_rect(const Vector2 &p_from, Vector2 &r_to, const Rect2 &p_rect); void _erase_selected(); void _update_mode(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 8d0db697e27..c840ce22ce7 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3372,7 +3372,7 @@ void CanvasItemEditor::_draw_selection() { // Draw the resize handles if (tool == TOOL_SELECT && canvas_item->_edit_use_rect() && _is_node_movable(canvas_item)) { Rect2 rect = canvas_item->_edit_get_rect(); - Vector2 endpoints[4] = { + const Vector2 endpoints[4] = { xform.xform(rect.position), xform.xform(rect.position + Vector2(rect.size.x, 0)), xform.xform(rect.position + rect.size), @@ -4575,7 +4575,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { Rect2 rect; int count = 0; - Map &selection = editor_selection->get_selection(); + const Map &selection = editor_selection->get_selection(); for (const KeyValue &E : selection) { CanvasItem *canvas_item = Object::cast_to(E.key); if (!canvas_item) { diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index b15aec87d9b..72caa15e9cf 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -290,7 +290,7 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { { uint8_t *tw = texdata.ptrw(); - float *twf = (float *)tw; + float *twf = reinterpret_cast(tw); for (int i = 0; i < vpc; i++) { twf[i * 2 + 0] = valid_positions[i].x; twf[i * 2 + 1] = valid_positions[i].y; @@ -334,7 +334,7 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { { uint8_t *tw = normdata.ptrw(); - float *twf = (float *)tw; + float *twf = reinterpret_cast(tw); for (int i = 0; i < vpc; i++) { twf[i * 2 + 0] = valid_normals[i].x; twf[i * 2 + 1] = valid_normals[i].y; diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index 35cbff53f43..4b1081ed92a 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -354,7 +354,7 @@ void GPUParticles3DEditor::_generate_emission_points() { uint8_t *iw = point_img.ptrw(); memset(iw, 0, w * h * 3 * sizeof(float)); const Vector3 *r = points.ptr(); - float *wf = (float *)iw; + float *wf = reinterpret_cast(iw); for (int i = 0; i < point_count; i++) { wf[i * 3 + 0] = r[i].x; wf[i * 3 + 1] = r[i].y; @@ -383,7 +383,7 @@ void GPUParticles3DEditor::_generate_emission_points() { uint8_t *iw = point_img2.ptrw(); memset(iw, 0, w * h * 3 * sizeof(float)); const Vector3 *r = normals.ptr(); - float *wf = (float *)iw; + float *wf = reinterpret_cast(iw); for (int i = 0; i < point_count; i++) { wf[i * 3 + 0] = r[i].x; wf[i * 3 + 1] = r[i].y; diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.h b/editor/plugins/gpu_particles_3d_editor_plugin.h index 190fb9954bf..6ba6d102ef2 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.h +++ b/editor/plugins/gpu_particles_3d_editor_plugin.h @@ -55,7 +55,7 @@ protected: Vector geometry; bool _generate(Vector &points, Vector &normals); - virtual void _generate_emission_points() = 0; + virtual void _generate_emission_points(){}; void _node_selected(const NodePath &p_path); static void _bind_methods(); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 6eed85e370c..7e01593bdaf 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2087,9 +2087,8 @@ void Node3DEditorViewport::_nav_pan(Ref p_event, const const NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); real_t pan_speed = 1 / 150.0; - int pan_speed_modifier = 10; if (nav_scheme == NAVIGATION_MAYA && p_event->is_shift_pressed()) { - pan_speed *= pan_speed_modifier; + pan_speed *= 10; } Transform3D camera_transform; @@ -2112,9 +2111,8 @@ void Node3DEditorViewport::_nav_zoom(Ref p_event, const const NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); real_t zoom_speed = 1 / 80.0; - int zoom_speed_modifier = 10; if (nav_scheme == NAVIGATION_MAYA && p_event->is_shift_pressed()) { - zoom_speed *= zoom_speed_modifier; + zoom_speed *= 10; } NavigationZoomStyle zoom_style = (NavigationZoomStyle)EditorSettings::get_singleton()->get("editors/3d/navigation/zoom_style").operator int(); @@ -2818,7 +2816,7 @@ void Node3DEditorViewport::_draw() { real_t scale_length = (max_speed - min_speed); if (!Math::is_zero_approx(scale_length)) { - real_t logscale_t = 1.0 - Math::log(1 + freelook_speed - min_speed) / Math::log(1 + scale_length); + real_t logscale_t = 1.0 - Math::log1p(freelook_speed - min_speed) / Math::log1p(scale_length); // Display the freelook speed to help the user get a better sense of scale. const int precision = freelook_speed < 1.0 ? 2 : 1; @@ -2841,7 +2839,7 @@ void Node3DEditorViewport::_draw() { real_t scale_length = (max_distance - min_distance); if (!Math::is_zero_approx(scale_length)) { - real_t logscale_t = 1.0 - Math::log(1 + cursor.distance - min_distance) / Math::log(1 + scale_length); + real_t logscale_t = 1.0 - Math::log1p(cursor.distance - min_distance) / Math::log1p(scale_length); // Display the zoom center distance to help the user get a better sense of scale. const int precision = cursor.distance < 1.0 ? 2 : 1; @@ -3644,7 +3642,7 @@ void Node3DEditorViewport::focus_selection() { Vector3 center; int count = 0; - List &selection = editor_selection->get_selected_node_list(); + const List &selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { Node3D *sp = Object::cast_to(E); @@ -5515,7 +5513,7 @@ void Node3DEditor::_xform_dialog_action() { undo_redo->create_action(TTR("XForm Dialog")); - List &selection = editor_selection->get_selected_node_list(); + const List &selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { Node3D *sp = Object::cast_to(E); @@ -6720,7 +6718,7 @@ Set _get_physics_bodies_rid(Node *node) { } void Node3DEditor::snap_selected_nodes_to_floor() { - List &selection = editor_selection->get_selected_node_list(); + const List &selection = editor_selection->get_selected_node_list(); Dictionary snap_data; for (Node *E : selection) { diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index e52b2749087..3284af7bb5a 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -320,14 +320,14 @@ EditorPlugin::AfterGUIInput Path3DEditorPlugin::forward_spatial_gui_input(Camera if (mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT && (curve_create->is_pressed() || (curve_edit->is_pressed() && mb->is_ctrl_pressed()))) { //click into curve, break it down Vector v3a = c->tessellate(); - int idx = 0; int rc = v3a.size(); int closest_seg = -1; Vector3 closest_seg_point; - float closest_d = 1e20; if (rc >= 2) { + int idx = 0; const Vector3 *r = v3a.ptr(); + float closest_d = 1e20; if (p_camera->unproject_position(gt.xform(c->get_point_position(0))).distance_to(mbpos) < click_dist) { return EditorPlugin::AFTER_GUI_INPUT_PASS; //nope, existing diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 065683d6327..0a67cfb54c9 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -1209,8 +1209,7 @@ void Skeleton3DGizmoPlugin::set_subgizmo_transform(const EditorNode3DGizmo *p_gi t.basis = to_local * p_transform.get_basis(); // Origin. - Vector3 orig = Vector3(); - orig = skeleton->get_bone_pose(p_id).origin; + Vector3 orig = skeleton->get_bone_pose(p_id).origin; Vector3 sub = p_transform.origin - skeleton->get_bone_global_pose(p_id).origin; t.origin = orig + to_local.xform(sub); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index adb85902466..3fa12233a8e 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -145,7 +145,7 @@ void TextureRegionEditor::_region_draw() { } } else if (snap_mode == SNAP_AUTOSLICE) { for (const Rect2 &r : autoslice_cache) { - Vector2 endpoints[4] = { + const Vector2 endpoints[4] = { mtx.basis_xform(r.position), mtx.basis_xform(r.position + Vector2(r.size.x, 0)), mtx.basis_xform(r.position + r.size), diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index 71947ae185a..4de2f42fe0a 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -350,7 +350,7 @@ void TileAtlasView::_draw_alternatives() { bool transposed = tile_data->get_transpose(); // Update the y to max value. - Vector2i offset_pos = current_pos; + Vector2i offset_pos; if (transposed) { offset_pos = (current_pos + Vector2(texture_region_size.y, texture_region_size.x) / 2 + tile_set_atlas_source->get_tile_effective_texture_offset(atlas_coords, alternative_id)); y_increment = MAX(y_increment, texture_region_size.x); diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index 6c12573cc4e..70bcd7e39a9 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -2057,7 +2057,7 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t } drag_last_pos = mb->get_position(); } - } else if (tile_data && tile_data->get_terrain_set() == terrain_set) { + } else if (tile_data->get_terrain_set() == terrain_set) { if (mb->is_ctrl_pressed()) { // Paint terrain set with rect. drag_type = DRAG_TYPE_PAINT_TERRAIN_BITS_RECT; @@ -2387,7 +2387,7 @@ void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(TileAtlasVi tile_data->set_terrain_set(drag_painted_value); } drag_last_pos = mb->get_position(); - } else if (tile_data && tile_data->get_terrain_set() == terrain_set) { + } else if (tile_data->get_terrain_set() == terrain_set) { // Paint terrain bits. drag_type = DRAG_TYPE_PAINT_TERRAIN_BITS; drag_modified.clear(); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 144697698c5..44b18f48fca 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -1695,8 +1695,8 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { Size2 zoomed_size = resize_handle->get_size() / tile_atlas_view->get_zoom(); Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile); Rect2 rect = region.grow_individual(zoomed_size.x, zoomed_size.y, 0, 0); - Vector2i coords[] = { Vector2i(0, 0), Vector2i(1, 0), Vector2i(1, 1), Vector2i(0, 1) }; - Vector2i directions[] = { Vector2i(0, -1), Vector2i(1, 0), Vector2i(0, 1), Vector2i(-1, 0) }; + const Vector2i coords[] = { Vector2i(0, 0), Vector2i(1, 0), Vector2i(1, 1), Vector2i(0, 1) }; + const Vector2i directions[] = { Vector2i(0, -1), Vector2i(1, 0), Vector2i(0, 1), Vector2i(-1, 0) }; bool can_grow[4]; for (int i = 0; i < 4; i++) { can_grow[i] = tile_set_atlas_source->has_room_for_tile(selected.tile + directions[i], tile_set_atlas_source->get_tile_size_in_atlas(selected.tile), tile_set_atlas_source->get_tile_animation_columns(selected.tile), tile_set_atlas_source->get_tile_animation_separation(selected.tile), tile_set_atlas_source->get_tile_animation_frames_count(selected.tile), selected.tile); diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp index 21ebcbd6553..9a4b14616f8 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp @@ -394,13 +394,12 @@ void TileSetScenesCollectionSourceEditor::_drop_data_fw(const Point2 &p_point, c if (p_from == scene_tiles_list) { // Handle dropping a texture in the list of atlas resources. - int scene_id = -1; Dictionary d = p_data; Vector files = d["files"]; for (int i = 0; i < files.size(); i++) { Ref resource = ResourceLoader::load(files[i]); if (resource.is_valid()) { - scene_id = tile_set_scenes_collection_source->get_next_scene_tile_id(); + int scene_id = tile_set_scenes_collection_source->get_next_scene_tile_id(); undo_redo->create_action(TTR("Add a Scene Tile")); undo_redo->add_do_method(tile_set_scenes_collection_source, "create_scene_tile", resource, scene_id); undo_redo->add_undo_method(tile_set_scenes_collection_source, "remove_scene_tile", scene_id); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index c4a5ec7a879..dc07ac7c395 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -119,7 +119,7 @@ void VisualShaderGraphPlugin::register_shader(VisualShader *p_shader) { visual_shader = Ref(p_shader); } -void VisualShaderGraphPlugin::set_connections(List &p_connections) { +void VisualShaderGraphPlugin::set_connections(const List &p_connections) { connections = p_connections; } @@ -2765,9 +2765,9 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector &p_ops, Stri } if (vsnode->get_output_port_count() > 0 || created_expression_port) { int _from_node = id_to_use; - int _from_slot = 0; if (created_expression_port) { + int _from_slot = 0; undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, _from_node, _from_slot, to_node, to_slot); undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, _from_node, _from_slot, to_node, to_slot); undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, _from_node, _from_slot, to_node, to_slot); @@ -2805,9 +2805,9 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector &p_ops, Stri if (vsnode->get_input_port_count() > 0 || created_expression_port) { int _to_node = id_to_use; - int _to_slot = 0; if (created_expression_port) { + int _to_slot = 0; undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, _to_slot); undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, _to_slot); undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, _to_slot); diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index 9f82b2ed7f6..8db2cf07f93 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -92,7 +92,7 @@ protected: public: void register_shader(VisualShader *p_visual_shader); - void set_connections(List &p_connections); + void set_connections(const List &p_connections); void register_link(VisualShader::Type p_type, int p_id, VisualShaderNode *p_visual_node, GraphNode *p_graph_node); void register_output_port(int p_id, int p_port, TextureButton *p_button); void register_uniform_name(int p_id, LineEdit *p_uniform_name); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 82aa4ead6f5..9c745e6a411 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -575,16 +575,16 @@ private: unzClose(pkg); if (failed_files.size()) { - String msg = TTR("The following files failed extraction from package:") + "\n\n"; + String err_msg = TTR("The following files failed extraction from package:") + "\n\n"; for (int i = 0; i < failed_files.size(); i++) { if (i > 15) { - msg += "\nAnd " + itos(failed_files.size() - i) + " more files."; + err_msg += "\nAnd " + itos(failed_files.size() - i) + " more files."; break; } - msg += failed_files[i] + "\n"; + err_msg += failed_files[i] + "\n"; } - dialog_error->set_text(msg); + dialog_error->set_text(err_msg); dialog_error->popup_centered(); } else if (!project_path->get_text().ends_with(".zip")) { diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index c63471720b7..3e8eb6b4eee 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2999,7 +2999,7 @@ void SceneTreeDock::attach_shader_to_selected(int p_preferred_mode) { shader_create_dialog->popup_centered(); } -void SceneTreeDock::open_shader_dialog(Ref &p_for_material, int p_preferred_mode) { +void SceneTreeDock::open_shader_dialog(const Ref &p_for_material, int p_preferred_mode) { selected_shader_material = p_for_material; attach_shader_to_selected(p_preferred_mode); } diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 842995dfe35..77e727b2c8f 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -309,7 +309,7 @@ public: void open_script_dialog(Node *p_for_node, bool p_extend); void attach_shader_to_selected(int p_preferred_mode = -1); - void open_shader_dialog(Ref &p_for_material, int p_preferred_mode = -1); + void open_shader_dialog(const Ref &p_for_material, int p_preferred_mode = -1); void open_add_child_dialog(); void open_instance_child_dialog(); diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp index ca4fc4f6282..d16d41b4380 100644 --- a/modules/navigation/godot_navigation_server.cpp +++ b/modules/navigation/godot_navigation_server.cpp @@ -40,43 +40,43 @@ /// an instance of that struct with the submitted parameters. /// Then, that struct is stored in an array; the `sync` function consume that array. -#define COMMAND_1(F_NAME, T_0, D_0) \ - struct MERGE(F_NAME, _command) : public SetCommand { \ - T_0 d_0; \ - MERGE(F_NAME, _command) \ - (T_0 p_d_0) : \ - d_0(p_d_0) {} \ - virtual void exec(GodotNavigationServer *server) { \ - server->MERGE(_cmd_, F_NAME)(d_0); \ - } \ - }; \ - void GodotNavigationServer::F_NAME(T_0 D_0) const { \ - auto cmd = memnew(MERGE(F_NAME, _command)( \ - D_0)); \ - add_command(cmd); \ - } \ +#define COMMAND_1(F_NAME, T_0, D_0) \ + struct MERGE(F_NAME, _command) : public SetCommand { \ + T_0 d_0; \ + MERGE(F_NAME, _command) \ + (T_0 p_d_0) : \ + d_0(p_d_0) {} \ + virtual void exec(GodotNavigationServer *server) override { \ + server->MERGE(_cmd_, F_NAME)(d_0); \ + } \ + }; \ + void GodotNavigationServer::F_NAME(T_0 D_0) const { \ + auto cmd = memnew(MERGE(F_NAME, _command)( \ + D_0)); \ + add_command(cmd); \ + } \ void GodotNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0) -#define COMMAND_2(F_NAME, T_0, D_0, T_1, D_1) \ - struct MERGE(F_NAME, _command) : public SetCommand { \ - T_0 d_0; \ - T_1 d_1; \ - MERGE(F_NAME, _command) \ - ( \ - T_0 p_d_0, \ - T_1 p_d_1) : \ - d_0(p_d_0), \ - d_1(p_d_1) {} \ - virtual void exec(GodotNavigationServer *server) { \ - server->MERGE(_cmd_, F_NAME)(d_0, d_1); \ - } \ - }; \ - void GodotNavigationServer::F_NAME(T_0 D_0, T_1 D_1) const { \ - auto cmd = memnew(MERGE(F_NAME, _command)( \ - D_0, \ - D_1)); \ - add_command(cmd); \ - } \ +#define COMMAND_2(F_NAME, T_0, D_0, T_1, D_1) \ + struct MERGE(F_NAME, _command) : public SetCommand { \ + T_0 d_0; \ + T_1 d_1; \ + MERGE(F_NAME, _command) \ + ( \ + T_0 p_d_0, \ + T_1 p_d_1) : \ + d_0(p_d_0), \ + d_1(p_d_1) {} \ + virtual void exec(GodotNavigationServer *server) override { \ + server->MERGE(_cmd_, F_NAME)(d_0, d_1); \ + } \ + }; \ + void GodotNavigationServer::F_NAME(T_0 D_0, T_1 D_1) const { \ + auto cmd = memnew(MERGE(F_NAME, _command)( \ + D_0, \ + D_1)); \ + add_command(cmd); \ + } \ void GodotNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1) #define COMMAND_4(F_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3) \ @@ -95,7 +95,7 @@ d_1(p_d_1), \ d_2(p_d_2), \ d_3(p_d_3) {} \ - virtual void exec(GodotNavigationServer *server) { \ + virtual void exec(GodotNavigationServer *server) override { \ server->MERGE(_cmd_, F_NAME)(d_0, d_1, d_2, d_3); \ } \ }; \ diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp index 06b0e318015..debfe8e9507 100644 --- a/modules/webxr/webxr_interface_js.cpp +++ b/modules/webxr/webxr_interface_js.cpp @@ -59,7 +59,7 @@ void _emwebxr_on_session_started(char *p_reference_space_type) { ERR_FAIL_COND(interface.is_null()); String reference_space_type = String(p_reference_space_type); - ((WebXRInterfaceJS *)interface.ptr())->_set_reference_space_type(reference_space_type); + static_cast(interface.ptr())->_set_reference_space_type(reference_space_type); interface->emit_signal(SNAME("session_started")); } @@ -94,7 +94,7 @@ void _emwebxr_on_controller_changed() { Ref interface = xr_server->find_interface("WebXR"); ERR_FAIL_COND(interface.is_null()); - ((WebXRInterfaceJS *)interface.ptr())->_on_controller_changed(); + static_cast(interface.ptr())->_on_controller_changed(); } extern "C" EMSCRIPTEN_KEEPALIVE void _emwebxr_on_input_event(char *p_signal_name, int p_input_source) { diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 54124c22d09..fc46005b413 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -139,7 +139,7 @@ void OS_Android::finalize() { } OS_Android *OS_Android::get_singleton() { - return (OS_Android *)OS::get_singleton(); + return static_cast(OS::get_singleton()); } GodotJavaWrapper *OS_Android::get_godot_java() { diff --git a/platform/javascript/javascript_singleton.cpp b/platform/javascript/javascript_singleton.cpp index c9c4d6e1b9f..8dc7aba5f88 100644 --- a/platform/javascript/javascript_singleton.cpp +++ b/platform/javascript/javascript_singleton.cpp @@ -207,7 +207,7 @@ int JavaScriptObjectImpl::_variant2js(const void **p_args, int p_pos, godot_js_w break; case Variant::INT: { const int64_t tmp = v->operator int64_t(); - if (tmp >= 1 << 31) { + if (tmp >= 1LL << 31) { r_val->r = (double)tmp; return Variant::FLOAT; } diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index acc7d1bc302..a36fcabd917 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -2143,7 +2143,7 @@ bool DisplayServerX11::window_get_flag(WindowFlags p_flag, WindowID p_window) co unsigned char *data = nullptr; if (XGetWindowProperty(x11_display, wd.x11_window, prop, 0, sizeof(Hints), False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) { if (data && (format == 32) && (len >= 5)) { - borderless = !((Hints *)data)->decorations; + borderless = !(reinterpret_cast(data)->decorations); } if (data) { XFree(data); @@ -2175,7 +2175,7 @@ void DisplayServerX11::window_request_attention(WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); - WindowData &wd = windows[p_window]; + const WindowData &wd = windows[p_window]; // Using EWMH -- Extended Window Manager Hints // // Sets the _NET_WM_STATE_DEMANDS_ATTENTION atom for WM_STATE @@ -2201,7 +2201,7 @@ void DisplayServerX11::window_move_to_foreground(WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); - WindowData &wd = windows[p_window]; + const WindowData &wd = windows[p_window]; XEvent xev; Atom net_active_window = XInternAtom(x11_display, "_NET_ACTIVE_WINDOW", False); @@ -2547,10 +2547,9 @@ DisplayServerX11::Property DisplayServerX11::_read_property(Display *p_display, unsigned long bytes_after = 0; unsigned char *ret = nullptr; - int read_bytes = 1024; - // Keep trying to read the property until there are no bytes unread. if (p_property != None) { + int read_bytes = 1024; do { if (ret != nullptr) { XFree(ret); @@ -2570,7 +2569,7 @@ DisplayServerX11::Property DisplayServerX11::_read_property(Display *p_display, return p; } -static Atom pick_target_from_list(Display *p_display, Atom *p_list, int p_count) { +static Atom pick_target_from_list(Display *p_display, const Atom *p_list, int p_count) { static const char *target_type = "text/uri-list"; for (int i = 0; i < p_count; i++) { diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 85cea0d9151..cab57146b19 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -2512,10 +2512,10 @@ void TileMap::_set_tile_data(int p_layer, const Vector &p_data) { uint32_t v = decode_uint32(&local[4]); // Extract the transform flags that used to be in the tilemap. - bool flip_h = v & (1 << 29); - bool flip_v = v & (1 << 30); - bool transpose = v & (1 << 31); - v &= (1 << 29) - 1; + bool flip_h = v & (1UL << 29); + bool flip_v = v & (1UL << 30); + bool transpose = v & (1UL << 31); + v &= (1UL << 29) - 1; // Extract autotile/atlas coords. int16_t coord_x = 0; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index d541dd5f373..6a8fa9327cb 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -563,7 +563,7 @@ void Sprite3D::_draw() { value |= CLAMP(int((t.normal.y * 0.5 + 0.5) * 1023.0), 0, 1023) << 10; value |= CLAMP(int((t.normal.z * 0.5 + 0.5) * 1023.0), 0, 1023) << 20; if (t.d > 0) { - value |= 3 << 30; + value |= 3UL << 30; } v_tangent = value; } @@ -926,7 +926,7 @@ void AnimatedSprite3D::_draw() { value |= CLAMP(int((t.normal.y * 0.5 + 0.5) * 1023.0), 0, 1023) << 10; value |= CLAMP(int((t.normal.z * 0.5 + 0.5) * 1023.0), 0, 1023) << 20; if (t.d > 0) { - value |= 3 << 30; + value |= 3UL << 30; } v_tangent = value; } diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp index bda3868fbb7..d6ac5ccf30d 100644 --- a/scene/3d/voxelizer.cpp +++ b/scene/3d/voxelizer.cpp @@ -777,8 +777,8 @@ Vector Voxelizer::get_voxel_gi_level_cell_count() const { /* dt of 1d function using squared distance */ static void edt(float *f, int stride, int n) { float *d = (float *)alloca(sizeof(float) * n + sizeof(int) * n + sizeof(float) * (n + 1)); - int *v = (int *)&(d[n]); - float *z = (float *)&v[n]; + int *v = reinterpret_cast(&(d[n])); + float *z = reinterpret_cast(&v[n]); int k = 0; v[0] = 0; diff --git a/scene/resources/immediate_mesh.cpp b/scene/resources/immediate_mesh.cpp index 28afef86383..044477e7447 100644 --- a/scene/resources/immediate_mesh.cpp +++ b/scene/resources/immediate_mesh.cpp @@ -211,7 +211,7 @@ void ImmediateMesh::surface_end() { value |= CLAMP(int((t.normal.y * 0.5 + 0.5) * 1023.0), 0, 1023) << 10; value |= CLAMP(int((t.normal.z * 0.5 + 0.5) * 1023.0), 0, 1023) << 20; if (t.d > 0) { - value |= 3 << 30; + value |= 3UL << 30; } *tangent = value; diff --git a/servers/physics_2d/godot_space_2d.cpp b/servers/physics_2d/godot_space_2d.cpp index 63e3af13951..a2459501c81 100644 --- a/servers/physics_2d/godot_space_2d.cpp +++ b/servers/physics_2d/godot_space_2d.cpp @@ -1033,9 +1033,9 @@ void GodotSpace2D::_broadphase_unpair(GodotCollisionObject2D *A, int p_subindex_ return; } - GodotSpace2D *self = (GodotSpace2D *)p_self; + GodotSpace2D *self = static_cast(p_self); self->collision_pairs--; - GodotConstraint2D *c = (GodotConstraint2D *)p_data; + GodotConstraint2D *c = static_cast(p_data); memdelete(c); } diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index 3be15db9e83..ace948d1497 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -210,7 +210,7 @@ void RenderForwardClustered::RenderBufferDataForwardClustered::configure(RID p_c tf.array_layers = view_count; // create a layer for every view tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT; - RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = { + const RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = { RD::TEXTURE_SAMPLES_1, RD::TEXTURE_SAMPLES_2, RD::TEXTURE_SAMPLES_4, diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h index c30499da299..0e588aecb49 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h @@ -218,7 +218,7 @@ class RenderForwardClustered : public RendererSceneRenderRD { INSTANCE_DATA_FLAGS_PARTICLE_TRAIL_SHIFT = 16, INSTANCE_DATA_FLAGS_PARTICLE_TRAIL_MASK = 0xFF, INSTANCE_DATA_FLAGS_FADE_SHIFT = 24, - INSTANCE_DATA_FLAGS_FADE_MASK = 0xFF << INSTANCE_DATA_FLAGS_FADE_SHIFT + INSTANCE_DATA_FLAGS_FADE_MASK = 0xFFUL << INSTANCE_DATA_FLAGS_FADE_SHIFT }; struct SceneState { diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp index d9c339097a4..b9f49cf008d 100644 --- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp @@ -158,7 +158,7 @@ void RenderForwardMobile::RenderBufferDataForwardMobile::configure(RID p_color_b tf.array_layers = view_count; // create a layer for every view tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT; - RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = { + const RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = { RD::TEXTURE_SAMPLES_1, RD::TEXTURE_SAMPLES_2, RD::TEXTURE_SAMPLES_4, diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 29bc767c860..8c727b25126 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -132,9 +132,9 @@ RendererCanvasRender::PolygonID RendererCanvasRenderRD::request_polygon(const Ve buffers.resize(5); { - const uint8_t *r = polygon_buffer.ptr(); - float *fptr = (float *)r; - uint32_t *uptr = (uint32_t *)r; + uint8_t *r = polygon_buffer.ptrw(); + float *fptr = reinterpret_cast(r); + uint32_t *uptr = reinterpret_cast(r); uint32_t base_offset = 0; { //vertices RD::VertexAttribute vd; @@ -1843,7 +1843,7 @@ void RendererCanvasRenderRD::occluder_polygon_set_shape(RID p_occluder, const Ve { uint8_t *vw = geometry.ptrw(); - float *vwptr = (float *)vw; + float *vwptr = reinterpret_cast(vw); uint8_t *iw = indices.ptrw(); uint16_t *iwptr = (uint16_t *)iw; diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp index d8b7d5384e3..0a16bf4bd19 100644 --- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp @@ -879,7 +879,7 @@ void RendererSceneGIRD::SDFGI::update_light() { push_constant.process_offset = 0; push_constant.process_increment = 1; } else { - static uint32_t frames_to_update_table[RS::ENV_SDFGI_UPDATE_LIGHT_MAX] = { + static const uint32_t frames_to_update_table[RS::ENV_SDFGI_UPDATE_LIGHT_MAX] = { 1, 2, 4, 8, 16 }; diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp index 75c502c6661..d939a0d641f 100644 --- a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp @@ -339,7 +339,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_FLOAT: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); if (p_array_size > 0) { const PackedFloat32Array &a = value; @@ -361,7 +361,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_VEC2: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); if (p_array_size > 0) { const PackedVector2Array &a = value; @@ -385,7 +385,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_VEC3: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); if (p_array_size > 0) { const PackedVector3Array &a = value; @@ -411,7 +411,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_VEC4: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); if (p_array_size > 0) { if (value.get_type() == Variant::PACKED_COLOR_ARRAY) { @@ -491,7 +491,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_MAT2: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); if (p_array_size > 0) { const PackedFloat32Array &a = value; @@ -532,7 +532,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_MAT3: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); if (p_array_size > 0) { const PackedFloat32Array &a = value; @@ -587,7 +587,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_MAT4: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); if (p_array_size > 0) { const PackedFloat32Array &a = value; @@ -748,12 +748,12 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, } } break; case ShaderLanguage::TYPE_FLOAT: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); gui[0] = value[0].real; } break; case ShaderLanguage::TYPE_VEC2: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); for (int i = 0; i < 2; i++) { gui[i] = value[i].real; @@ -761,7 +761,7 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, } break; case ShaderLanguage::TYPE_VEC3: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); for (int i = 0; i < 3; i++) { gui[i] = value[i].real; @@ -769,14 +769,14 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, } break; case ShaderLanguage::TYPE_VEC4: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); for (int i = 0; i < 4; i++) { gui[i] = value[i].real; } } break; case ShaderLanguage::TYPE_MAT2: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); //in std140 members of mat2 are treated as vec4s gui[0] = value[0].real; @@ -789,7 +789,7 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, gui[7] = 0; } break; case ShaderLanguage::TYPE_MAT3: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); gui[0] = value[0].real; gui[1] = value[1].real; @@ -805,7 +805,7 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, gui[11] = 0; } break; case ShaderLanguage::TYPE_MAT4: { - float *gui = (float *)data; + float *gui = reinterpret_cast(data); for (int i = 0; i < 16; i++) { gui[i] = value[i].real; @@ -1885,7 +1885,7 @@ void MaterialStorage::global_variable_remove(const StringName &p_name) { if (!global_variables.variables.has(p_name)) { return; } - GlobalVariables::Variable &gv = global_variables.variables[p_name]; + const GlobalVariables::Variable &gv = global_variables.variables[p_name]; if (gv.buffer_index >= 0) { global_variables.buffer_usage[gv.buffer_index].elements = 0; @@ -2110,7 +2110,7 @@ void MaterialStorage::global_variables_instance_update(RID p_instance, int p_ind ERR_FAIL_INDEX(p_index, ShaderLanguage::MAX_INSTANCE_UNIFORM_INDICES); ERR_FAIL_COND_MSG(p_value.get_type() > Variant::COLOR, "Unsupported variant type for instance parameter: " + Variant::get_type_name(p_value.get_type())); //anything greater not supported - ShaderLanguage::DataType datatype_from_value[Variant::COLOR + 1] = { + const ShaderLanguage::DataType datatype_from_value[Variant::COLOR + 1] = { ShaderLanguage::TYPE_MAX, //nil ShaderLanguage::TYPE_BOOL, //bool ShaderLanguage::TYPE_INT, //int diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp index 8c60264ce34..0f74c591c66 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp @@ -50,7 +50,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 3); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast(w); fptr[0] = 0.0; fptr[1] = 0.0; fptr[2] = 0.0; @@ -62,7 +62,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 3); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast(w); fptr[0] = 1.0; fptr[1] = 0.0; fptr[2] = 0.0; @@ -74,7 +74,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 4); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast(w); fptr[0] = 1.0; fptr[1] = 0.0; fptr[2] = 0.0; @@ -87,7 +87,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 4); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast(w); fptr[0] = 1.0; fptr[1] = 1.0; fptr[2] = 1.0; @@ -100,7 +100,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 2); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast(w); fptr[0] = 0.0; fptr[1] = 0.0; } @@ -110,7 +110,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 2); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast(w); fptr[0] = 0.0; fptr[1] = 0.0; } @@ -121,7 +121,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 4); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast(w); fptr[0] = 0.0; fptr[1] = 0.0; fptr[2] = 0.0; @@ -134,7 +134,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(uint32_t) * 4); { uint8_t *w = buffer.ptrw(); - uint32_t *fptr = (uint32_t *)w; + uint32_t *fptr = reinterpret_cast(w); fptr[0] = 0; fptr[1] = 0; fptr[2] = 0; @@ -147,7 +147,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 4); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast(w); fptr[0] = 0.0; fptr[1] = 0.0; fptr[2] = 0.0; @@ -284,9 +284,9 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) case RS::ARRAY_CUSTOM2: case RS::ARRAY_CUSTOM3: { int idx = i - RS::ARRAY_CUSTOM0; - uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT }; + const uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT }; uint32_t fmt = (p_surface.format >> fmt_shift[idx]) & RS::ARRAY_FORMAT_CUSTOM_MASK; - uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 }; + const uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 }; attrib_stride += fmtsize[fmt]; } break; @@ -1098,10 +1098,10 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V vd.offset = attribute_stride; int idx = i - RS::ARRAY_CUSTOM0; - uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT }; + const uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT }; uint32_t fmt = (s->format >> fmt_shift[idx]) & RS::ARRAY_FORMAT_CUSTOM_MASK; - uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 }; - RD::DataFormat fmtrd[RS::ARRAY_CUSTOM_MAX] = { RD::DATA_FORMAT_R8G8B8A8_UNORM, RD::DATA_FORMAT_R8G8B8A8_SNORM, RD::DATA_FORMAT_R16G16_SFLOAT, RD::DATA_FORMAT_R16G16B16A16_SFLOAT, RD::DATA_FORMAT_R32_SFLOAT, RD::DATA_FORMAT_R32G32_SFLOAT, RD::DATA_FORMAT_R32G32B32_SFLOAT, RD::DATA_FORMAT_R32G32B32A32_SFLOAT }; + const uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 }; + const RD::DataFormat fmtrd[RS::ARRAY_CUSTOM_MAX] = { RD::DATA_FORMAT_R8G8B8A8_UNORM, RD::DATA_FORMAT_R8G8B8A8_SNORM, RD::DATA_FORMAT_R16G16_SFLOAT, RD::DATA_FORMAT_R16G16B16A16_SFLOAT, RD::DATA_FORMAT_R32_SFLOAT, RD::DATA_FORMAT_R32G32_SFLOAT, RD::DATA_FORMAT_R32G32B32_SFLOAT, RD::DATA_FORMAT_R32G32B32A32_SFLOAT }; vd.format = fmtrd[fmt]; attribute_stride += fmtsize[fmt]; buffer = s->attribute_buffer; @@ -1238,7 +1238,7 @@ void MeshStorage::multimesh_set_mesh(RID p_multimesh, RID p_mesh) { if (multimesh->buffer_set) { Vector buffer = RD::get_singleton()->buffer_get_data(multimesh->buffer); const uint8_t *r = buffer.ptr(); - const float *data = (const float *)r; + const float *data = reinterpret_cast(r); _multimesh_re_create_aabb(multimesh, data, multimesh->instances); } } diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp index 75dd20bdbdd..402536de88a 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp @@ -1722,7 +1722,7 @@ RID ParticlesStorage::particles_collision_get_heightfield_framebuffer(RID p_part if (particles_collision->heightfield_texture == RID()) { //create - int resolutions[RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX] = { 256, 512, 1024, 2048, 4096, 8192 }; + const int resolutions[RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX] = { 256, 512, 1024, 2048, 4096, 8192 }; Size2i size; if (particles_collision->extents.x > particles_collision->extents.z) { size.x = resolutions[particles_collision->heightfield_resolution]; diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index b58e6138eb9..c2a6b83485e 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -424,7 +424,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint value |= CLAMP(int((src[i * 4 + 1] * 0.5 + 0.5) * 1023.0), 0, 1023) << 10; value |= CLAMP(int((src[i * 4 + 2] * 0.5 + 0.5) * 1023.0), 0, 1023) << 20; if (src[i * 4 + 3] > 0) { - value |= 3 << 30; + value |= 3UL << 30; } memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], &value, 4); @@ -440,7 +440,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint value |= CLAMP(int((src[i * 4 + 1] * 0.5 + 0.5) * 1023.0), 0, 1023) << 10; value |= CLAMP(int((src[i * 4 + 2] * 0.5 + 0.5) * 1023.0), 0, 1023) << 20; if (src[i * 4 + 3] > 0) { - value |= 3 << 30; + value |= 3UL << 30; } memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], &value, 4); } @@ -1093,7 +1093,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector(&r[j * vertex_elem_size + offsets[i]]); w[j] = Vector2(v[0], v[1]); } } @@ -1107,7 +1107,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector(&r[j * vertex_elem_size + offsets[i]]); w[j] = Vector3(v[0], v[1], v[2]); } } @@ -1156,7 +1156,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector(&ar[j * attrib_elem_size + offsets[i]]); w[j] = Color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, v[3] / 255.0); } @@ -1170,7 +1170,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector(&ar[j * attrib_elem_size + offsets[i]]); w[j] = Vector2(v[0], v[1]); } @@ -1184,7 +1184,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector(&ar[j * attrib_elem_size + offsets[i]]); w[j] = Vector2(v[0], v[1]); } @@ -1209,7 +1209,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector(&ar[j * attrib_elem_size + offsets[i]]); memcpy(&w[j * s], v, s); } @@ -1228,7 +1228,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector(&ar[j * attrib_elem_size + offsets[i]]); memcpy(&w[j * s], v, s * sizeof(float)); } ret[i] = arr;