Fix #46282 Executing RigidBody3D.get_inverse_inertia_tensor() crashes Godot
This commit is contained in:
parent
57927bd56b
commit
b19544e91d
4 changed files with 15 additions and 8 deletions
|
@ -43,18 +43,21 @@ public:
|
||||||
v->type = p_type;
|
v->type = p_type;
|
||||||
|
|
||||||
switch (p_type) {
|
switch (p_type) {
|
||||||
case Variant::AABB:
|
case Variant::STRING:
|
||||||
init_aabb(v);
|
init_string(v);
|
||||||
break;
|
break;
|
||||||
case Variant::TRANSFORM2D:
|
case Variant::TRANSFORM2D:
|
||||||
init_transform2d(v);
|
init_transform2d(v);
|
||||||
break;
|
break;
|
||||||
|
case Variant::AABB:
|
||||||
|
init_aabb(v);
|
||||||
|
break;
|
||||||
|
case Variant::BASIS:
|
||||||
|
init_basis(v);
|
||||||
|
break;
|
||||||
case Variant::TRANSFORM:
|
case Variant::TRANSFORM:
|
||||||
init_transform(v);
|
init_transform(v);
|
||||||
break;
|
break;
|
||||||
case Variant::STRING:
|
|
||||||
init_string(v);
|
|
||||||
break;
|
|
||||||
case Variant::STRING_NAME:
|
case Variant::STRING_NAME:
|
||||||
init_string_name(v);
|
init_string_name(v);
|
||||||
break;
|
break;
|
||||||
|
@ -192,6 +195,10 @@ public:
|
||||||
v->type = GetTypeInfo<T>::VARIANT_TYPE;
|
v->type = GetTypeInfo<T>::VARIANT_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Should be in the same order as Variant::Type for consistency.
|
||||||
|
// Those primitive and vector types don't need an `init_` method:
|
||||||
|
// Nil, bool, float, Vector2/i, Rect2/i, Vector3/i, Plane, Quat, Color, RID.
|
||||||
|
// Object is a special case, handled via `object_assign_null`.
|
||||||
_FORCE_INLINE_ static void init_string(Variant *v) {
|
_FORCE_INLINE_ static void init_string(Variant *v) {
|
||||||
memnew_placement(v->_data._mem, String);
|
memnew_placement(v->_data._mem, String);
|
||||||
v->type = Variant::STRING;
|
v->type = Variant::STRING;
|
||||||
|
|
|
@ -103,7 +103,7 @@
|
||||||
[b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead.
|
[b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_inverse_inertia_tensor">
|
<method name="get_inverse_inertia_tensor" qualifiers="const">
|
||||||
<return type="Basis">
|
<return type="Basis">
|
||||||
</return>
|
</return>
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -511,7 +511,7 @@ Vector3 RigidBody3D::get_angular_velocity() const {
|
||||||
return angular_velocity;
|
return angular_velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
Basis RigidBody3D::get_inverse_inertia_tensor() {
|
Basis RigidBody3D::get_inverse_inertia_tensor() const {
|
||||||
return inverse_inertia_tensor;
|
return inverse_inertia_tensor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ public:
|
||||||
void set_angular_velocity(const Vector3 &p_velocity);
|
void set_angular_velocity(const Vector3 &p_velocity);
|
||||||
Vector3 get_angular_velocity() const override;
|
Vector3 get_angular_velocity() const override;
|
||||||
|
|
||||||
Basis get_inverse_inertia_tensor();
|
Basis get_inverse_inertia_tensor() const;
|
||||||
|
|
||||||
void set_gravity_scale(real_t p_gravity_scale);
|
void set_gravity_scale(real_t p_gravity_scale);
|
||||||
real_t get_gravity_scale() const;
|
real_t get_gravity_scale() const;
|
||||||
|
|
Loading…
Reference in a new issue