mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 23:31:53 -05:00
Merge pull request #49672 from aaronfranke/box-extents-compat
Add extents get/set override to BoxShape3D and RectangleShape2D for compatibility
This commit is contained in:
@@ -56,6 +56,26 @@ void BoxShape3D::_update_shape() {
|
|||||||
Shape3D::_update_shape();
|
Shape3D::_update_shape();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
bool BoxShape3D::_set(const StringName &p_name, const Variant &p_value) {
|
||||||
|
if (p_name == "extents") { // Compatibility with Godot 3.x.
|
||||||
|
// Convert to `size`, twice as big.
|
||||||
|
set_size((Vector3)p_value * 2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BoxShape3D::_get(const StringName &p_name, Variant &r_property) const {
|
||||||
|
if (p_name == "extents") { // Compatibility with Godot 3.x.
|
||||||
|
// Convert to `extents`, half as big.
|
||||||
|
r_property = size / 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
void BoxShape3D::set_size(const Vector3 &p_size) {
|
void BoxShape3D::set_size(const Vector3 &p_size) {
|
||||||
size = p_size;
|
size = p_size;
|
||||||
_update_shape();
|
_update_shape();
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ class BoxShape3D : public Shape3D {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
bool _set(const StringName &p_name, const Variant &p_value);
|
||||||
|
bool _get(const StringName &p_name, Variant &r_property) const;
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
virtual void _update_shape() override;
|
virtual void _update_shape() override;
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,26 @@ void RectangleShape2D::_update_shape() {
|
|||||||
emit_changed();
|
emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
bool RectangleShape2D::_set(const StringName &p_name, const Variant &p_value) {
|
||||||
|
if (p_name == "extents") { // Compatibility with Godot 3.x.
|
||||||
|
// Convert to `size`, twice as big.
|
||||||
|
set_size((Vector2)p_value * 2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RectangleShape2D::_get(const StringName &p_name, Variant &r_property) const {
|
||||||
|
if (p_name == "extents") { // Compatibility with Godot 3.x.
|
||||||
|
// Convert to `extents`, half as big.
|
||||||
|
r_property = size / 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
void RectangleShape2D::set_size(const Vector2 &p_size) {
|
void RectangleShape2D::set_size(const Vector2 &p_size) {
|
||||||
size = p_size;
|
size = p_size;
|
||||||
_update_shape();
|
_update_shape();
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ class RectangleShape2D : public Shape2D {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
bool _set(const StringName &p_name, const Variant &p_value);
|
||||||
|
bool _get(const StringName &p_name, Variant &r_property) const;
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_size(const Vector2 &p_size);
|
void set_size(const Vector2 &p_size);
|
||||||
|
|||||||
Reference in New Issue
Block a user