Remove deprecated PhysicsBody friction and bounce parameters

They were replaced in 3.1 by PhysicsMaterial properties via #12403.
This commit is contained in:
Rémi Verschelde 2020-02-12 12:17:40 +01:00
parent 49eef1180b
commit 1206bdb71b
8 changed files with 0 additions and 337 deletions

View File

@ -145,10 +145,6 @@
<member name="axis_lock_linear_z" type="bool" setter="set_axis_lock" getter="get_axis_lock" default="false"> <member name="axis_lock_linear_z" type="bool" setter="set_axis_lock" getter="get_axis_lock" default="false">
Lock the body's movement in the Z axis. Lock the body's movement in the Z axis.
</member> </member>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce">
The body's bounciness. Values range from [code]0[/code] (no bounce) to [code]1[/code] (full bounciness).
Deprecated, use [member PhysicsMaterial.bounce] instead via [member physics_material_override].
</member>
<member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true"> <member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true">
If [code]true[/code], the RigidBody will not calculate forces and will act as a static body while there is no movement. It will wake up when forces are applied through other collisions or when the [code]apply_impulse[/code] method is used. If [code]true[/code], the RigidBody will not calculate forces and will act as a static body while there is no movement. It will wake up when forces are applied through other collisions or when the [code]apply_impulse[/code] method is used.
</member> </member>
@ -165,10 +161,6 @@
<member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false"> <member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false">
If [code]true[/code], internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined. If [code]true[/code], internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined.
</member> </member>
<member name="friction" type="float" setter="set_friction" getter="get_friction">
The body's friction, from 0 (frictionless) to 1 (max friction).
Deprecated, use [member PhysicsMaterial.friction] instead via [member physics_material_override].
</member>
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0"> <member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0">
This is multiplied by the global 3D gravity setting found in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b] to produce RigidBody's gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object. This is multiplied by the global 3D gravity setting found in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b] to produce RigidBody's gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
</member> </member>

View File

@ -126,10 +126,6 @@
<member name="applied_torque" type="float" setter="set_applied_torque" getter="get_applied_torque" default="0.0"> <member name="applied_torque" type="float" setter="set_applied_torque" getter="get_applied_torque" default="0.0">
The body's total applied torque. The body's total applied torque.
</member> </member>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce">
The body's bounciness. Values range from [code]0[/code] (no bounce) to [code]1[/code] (full bounciness).
Deprecated, use [member PhysicsMaterial.bounce] instead via [member physics_material_override].
</member>
<member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true"> <member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true">
If [code]true[/code], the body will not calculate forces and will act as a static body if there is no movement. The body will wake up when other forces are applied via collisions or by using [method apply_impulse] or [method add_force]. If [code]true[/code], the body will not calculate forces and will act as a static body if there is no movement. The body will wake up when other forces are applied via collisions or by using [method apply_impulse] or [method add_force].
</member> </member>
@ -146,10 +142,6 @@
<member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false"> <member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false">
If [code]true[/code], internal force integration is disabled for this body. Aside from collision response, the body will only move as determined by the [method _integrate_forces] function. If [code]true[/code], internal force integration is disabled for this body. Aside from collision response, the body will only move as determined by the [method _integrate_forces] function.
</member> </member>
<member name="friction" type="float" setter="set_friction" getter="get_friction">
The body's friction. Values range from [code]0[/code] (frictionless) to [code]1[/code] (maximum friction).
Deprecated, use [member PhysicsMaterial.friction] instead via [member physics_material_override].
</member>
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0"> <member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0">
Multiplies the gravity applied to the body. The body's gravity is calculated from the [b]Default Gravity[/b] value in [b]Project &gt; Project Settings &gt; Physics &gt; 2d[/b] and/or any additional gravity vector applied by [Area2D]s. Multiplies the gravity applied to the body. The body's gravity is calculated from the [b]Default Gravity[/b] value in [b]Project &gt; Project Settings &gt; Physics &gt; 2d[/b] and/or any additional gravity vector applied by [Area2D]s.
</member> </member>

View File

@ -12,20 +12,12 @@
<methods> <methods>
</methods> </methods>
<members> <members>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce">
The body's bounciness. Values range from [code]0[/code] (no bounce) to [code]1[/code] (full bounciness).
Deprecated, use [member PhysicsMaterial.bounce] instead via [member physics_material_override].
</member>
<member name="constant_angular_velocity" type="Vector3" setter="set_constant_angular_velocity" getter="get_constant_angular_velocity" default="Vector3( 0, 0, 0 )"> <member name="constant_angular_velocity" type="Vector3" setter="set_constant_angular_velocity" getter="get_constant_angular_velocity" default="Vector3( 0, 0, 0 )">
The body's constant angular velocity. This does not rotate the body, but affects other bodies that touch it, as if it was in a state of rotation. The body's constant angular velocity. This does not rotate the body, but affects other bodies that touch it, as if it was in a state of rotation.
</member> </member>
<member name="constant_linear_velocity" type="Vector3" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector3( 0, 0, 0 )"> <member name="constant_linear_velocity" type="Vector3" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector3( 0, 0, 0 )">
The body's constant linear velocity. This does not move the body, but affects other bodies that touch it, as if it was in a state of movement. The body's constant linear velocity. This does not move the body, but affects other bodies that touch it, as if it was in a state of movement.
</member> </member>
<member name="friction" type="float" setter="set_friction" getter="get_friction">
The body's friction, from 0 (frictionless) to 1 (full friction).
Deprecated, use [member PhysicsMaterial.friction] instead via [member physics_material_override].
</member>
<member name="physics_material_override" type="PhysicsMaterial" setter="set_physics_material_override" getter="get_physics_material_override"> <member name="physics_material_override" type="PhysicsMaterial" setter="set_physics_material_override" getter="get_physics_material_override">
The physics material override for the body. The physics material override for the body.
If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one. If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.

View File

@ -12,20 +12,12 @@
<methods> <methods>
</methods> </methods>
<members> <members>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce">
The body's bounciness. Values range from [code]0[/code] (no bounce) to [code]1[/code] (full bounciness).
Deprecated, use [member PhysicsMaterial.bounce] instead via [member physics_material_override].
</member>
<member name="constant_angular_velocity" type="float" setter="set_constant_angular_velocity" getter="get_constant_angular_velocity" default="0.0"> <member name="constant_angular_velocity" type="float" setter="set_constant_angular_velocity" getter="get_constant_angular_velocity" default="0.0">
The body's constant angular velocity. This does not rotate the body, but affects colliding bodies, as if it were rotating. The body's constant angular velocity. This does not rotate the body, but affects colliding bodies, as if it were rotating.
</member> </member>
<member name="constant_linear_velocity" type="Vector2" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector2( 0, 0 )"> <member name="constant_linear_velocity" type="Vector2" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector2( 0, 0 )">
The body's constant linear velocity. This does not move the body, but affects colliding bodies, as if it were moving. The body's constant linear velocity. This does not move the body, but affects colliding bodies, as if it were moving.
</member> </member>
<member name="friction" type="float" setter="set_friction" getter="get_friction">
The body's friction. Values range from [code]0[/code] (no friction) to [code]1[/code] (full friction).
Deprecated, use [member PhysicsMaterial.friction] instead via [member physics_material_override].
</member>
<member name="physics_material_override" type="PhysicsMaterial" setter="set_physics_material_override" getter="get_physics_material_override"> <member name="physics_material_override" type="PhysicsMaterial" setter="set_physics_material_override" getter="get_physics_material_override">
The physics material override for the body. The physics material override for the body.
If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one. If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.

View File

@ -190,64 +190,6 @@ real_t StaticBody2D::get_constant_angular_velocity() const {
return constant_angular_velocity; return constant_angular_velocity;
} }
#ifndef DISABLE_DEPRECATED
void StaticBody2D::set_friction(real_t p_friction) {
if (p_friction == 1.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}
WARN_DEPRECATED_MSG("The method set_friction has been deprecated and will be removed in the future, use physics material instead.");
ERR_FAIL_COND_MSG(p_friction < 0 || p_friction > 1, "Friction must be between 0 and 1.");
if (physics_material_override.is_null()) {
physics_material_override.instance();
set_physics_material_override(physics_material_override);
}
physics_material_override->set_friction(p_friction);
}
real_t StaticBody2D::get_friction() const {
WARN_DEPRECATED_MSG("The method get_friction has been deprecated and will be removed in the future, use physics material instead.");
if (physics_material_override.is_null()) {
return 1;
}
return physics_material_override->get_friction();
}
void StaticBody2D::set_bounce(real_t p_bounce) {
if (p_bounce == 0.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}
WARN_DEPRECATED_MSG("The method set_bounce has been deprecated and will be removed in the future, use physics material instead.");
ERR_FAIL_COND_MSG(p_bounce < 0 || p_bounce > 1, "Bounce must be between 0 and 1.");
if (physics_material_override.is_null()) {
physics_material_override.instance();
set_physics_material_override(physics_material_override);
}
physics_material_override->set_bounce(p_bounce);
}
real_t StaticBody2D::get_bounce() const {
WARN_DEPRECATED_MSG("The method get_bounce has been deprecated and will be removed in the future, use physics material instead.");
if (physics_material_override.is_null()) {
return 0;
}
return physics_material_override->get_bounce();
}
#endif // DISABLE_DEPRECATED
void StaticBody2D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) { void StaticBody2D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
if (physics_material_override.is_valid()) { if (physics_material_override.is_valid()) {
if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, this, "_reload_physics_characteristics")) if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, this, "_reload_physics_characteristics"))
@ -273,14 +215,6 @@ void StaticBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"), &StaticBody2D::get_constant_linear_velocity); ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"), &StaticBody2D::get_constant_linear_velocity);
ClassDB::bind_method(D_METHOD("get_constant_angular_velocity"), &StaticBody2D::get_constant_angular_velocity); ClassDB::bind_method(D_METHOD("get_constant_angular_velocity"), &StaticBody2D::get_constant_angular_velocity);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_friction", "friction"), &StaticBody2D::set_friction);
ClassDB::bind_method(D_METHOD("get_friction"), &StaticBody2D::get_friction);
ClassDB::bind_method(D_METHOD("set_bounce", "bounce"), &StaticBody2D::set_bounce);
ClassDB::bind_method(D_METHOD("get_bounce"), &StaticBody2D::get_bounce);
#endif // DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &StaticBody2D::set_physics_material_override); ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &StaticBody2D::set_physics_material_override);
ClassDB::bind_method(D_METHOD("get_physics_material_override"), &StaticBody2D::get_physics_material_override); ClassDB::bind_method(D_METHOD("get_physics_material_override"), &StaticBody2D::get_physics_material_override);
@ -288,10 +222,6 @@ void StaticBody2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "constant_linear_velocity"), "set_constant_linear_velocity", "get_constant_linear_velocity"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "constant_linear_velocity"), "set_constant_linear_velocity", "get_constant_linear_velocity");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "constant_angular_velocity"), "set_constant_angular_velocity", "get_constant_angular_velocity"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "constant_angular_velocity"), "set_constant_angular_velocity", "get_constant_angular_velocity");
#ifndef DISABLE_DEPRECATED
ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_friction", "get_friction");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_bounce", "get_bounce");
#endif // DISABLE_DEPRECATED
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
} }
@ -613,62 +543,6 @@ real_t RigidBody2D::get_weight() const {
return mass * (real_t(GLOBAL_DEF("physics/2d/default_gravity", 98)) / 10); return mass * (real_t(GLOBAL_DEF("physics/2d/default_gravity", 98)) / 10);
} }
#ifndef DISABLE_DEPRECATED
void RigidBody2D::set_friction(real_t p_friction) {
if (p_friction == 1.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}
WARN_DEPRECATED_MSG("The method set_friction has been deprecated and will be removed in the future, use physics material instead.");
ERR_FAIL_COND_MSG(p_friction < 0 || p_friction > 1, "Friction must be between 0 and 1.");
if (physics_material_override.is_null()) {
physics_material_override.instance();
set_physics_material_override(physics_material_override);
}
physics_material_override->set_friction(p_friction);
}
real_t RigidBody2D::get_friction() const {
WARN_DEPRECATED_MSG("The method get_friction has been deprecated and will be removed in the future, use physics material instead.");
if (physics_material_override.is_null()) {
return 1;
}
return physics_material_override->get_friction();
}
void RigidBody2D::set_bounce(real_t p_bounce) {
if (p_bounce == 0.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}
WARN_DEPRECATED_MSG("The method set_bounce has been deprecated and will be removed in the future, use physics material instead.");
ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1);
if (physics_material_override.is_null()) {
physics_material_override.instance();
set_physics_material_override(physics_material_override);
}
physics_material_override->set_bounce(p_bounce);
}
real_t RigidBody2D::get_bounce() const {
WARN_DEPRECATED_MSG("The method get_bounce has been deprecated and will be removed in the future, use physics material instead.");
if (physics_material_override.is_null()) {
return 0;
}
return physics_material_override->get_bounce();
}
#endif // DISABLE_DEPRECATED
void RigidBody2D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) { void RigidBody2D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
if (physics_material_override.is_valid()) { if (physics_material_override.is_valid()) {
if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, this, "_reload_physics_characteristics")) if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, this, "_reload_physics_characteristics"))
@ -968,14 +842,6 @@ void RigidBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_weight", "weight"), &RigidBody2D::set_weight); ClassDB::bind_method(D_METHOD("set_weight", "weight"), &RigidBody2D::set_weight);
ClassDB::bind_method(D_METHOD("get_weight"), &RigidBody2D::get_weight); ClassDB::bind_method(D_METHOD("get_weight"), &RigidBody2D::get_weight);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_friction", "friction"), &RigidBody2D::set_friction);
ClassDB::bind_method(D_METHOD("get_friction"), &RigidBody2D::get_friction);
ClassDB::bind_method(D_METHOD("set_bounce", "bounce"), &RigidBody2D::set_bounce);
ClassDB::bind_method(D_METHOD("get_bounce"), &RigidBody2D::get_bounce);
#endif // DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &RigidBody2D::set_physics_material_override); ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &RigidBody2D::set_physics_material_override);
ClassDB::bind_method(D_METHOD("get_physics_material_override"), &RigidBody2D::get_physics_material_override); ClassDB::bind_method(D_METHOD("get_physics_material_override"), &RigidBody2D::get_physics_material_override);
@ -1043,10 +909,6 @@ void RigidBody2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), "set_mass", "get_mass"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), "set_mass", "get_mass");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "inertia", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", 0), "set_inertia", "get_inertia"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "inertia", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", 0), "set_inertia", "get_inertia");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "weight", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", PROPERTY_USAGE_EDITOR), "set_weight", "get_weight"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "weight", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", PROPERTY_USAGE_EDITOR), "set_weight", "get_weight");
#ifndef DISABLE_DEPRECATED
ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_friction", "get_friction");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_bounce", "get_bounce");
#endif // DISABLE_DEPRECATED
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_scale", PROPERTY_HINT_RANGE, "-128,128,0.01"), "set_gravity_scale", "get_gravity_scale"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_scale", PROPERTY_HINT_RANGE, "-128,128,0.01"), "set_gravity_scale", "get_gravity_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom_integrator"), "set_use_custom_integrator", "is_using_custom_integrator"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom_integrator"), "set_use_custom_integrator", "is_using_custom_integrator");

View File

@ -87,13 +87,6 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifndef DISABLE_DEPRECATED
void set_friction(real_t p_friction);
real_t get_friction() const;
void set_bounce(real_t p_bounce);
real_t get_bounce() const;
#endif
void set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override); void set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override);
Ref<PhysicsMaterial> get_physics_material_override() const; Ref<PhysicsMaterial> get_physics_material_override() const;
@ -211,14 +204,6 @@ public:
void set_weight(real_t p_weight); void set_weight(real_t p_weight);
real_t get_weight() const; real_t get_weight() const;
#ifndef DISABLE_DEPRECATED
void set_friction(real_t p_friction);
real_t get_friction() const;
void set_bounce(real_t p_bounce);
real_t get_bounce() const;
#endif
void set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override); void set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override);
Ref<PhysicsMaterial> get_physics_material_override() const; Ref<PhysicsMaterial> get_physics_material_override() const;

View File

@ -178,64 +178,6 @@ PhysicsBody::PhysicsBody(PhysicsServer::BodyMode p_mode) :
collision_mask = 1; collision_mask = 1;
} }
#ifndef DISABLE_DEPRECATED
void StaticBody::set_friction(real_t p_friction) {
if (p_friction == 1.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}
WARN_DEPRECATED_MSG("The method set_friction has been deprecated and will be removed in the future, use physics material instead.");
ERR_FAIL_COND_MSG(p_friction < 0 || p_friction > 1, "Friction must be between 0 and 1.");
if (physics_material_override.is_null()) {
physics_material_override.instance();
set_physics_material_override(physics_material_override);
}
physics_material_override->set_friction(p_friction);
}
real_t StaticBody::get_friction() const {
WARN_DEPRECATED_MSG("The method get_friction has been deprecated and will be removed in the future, use physics material instead.");
if (physics_material_override.is_null()) {
return 1;
}
return physics_material_override->get_friction();
}
void StaticBody::set_bounce(real_t p_bounce) {
if (p_bounce == 0.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}
WARN_DEPRECATED_MSG("The method set_bounce has been deprecated and will be removed in the future, use physics material instead.");
ERR_FAIL_COND_MSG(p_bounce < 0 || p_bounce > 1, "Bounce must be between 0 and 1.");
if (physics_material_override.is_null()) {
physics_material_override.instance();
set_physics_material_override(physics_material_override);
}
physics_material_override->set_bounce(p_bounce);
}
real_t StaticBody::get_bounce() const {
WARN_DEPRECATED_MSG("The method get_bounce has been deprecated and will be removed in the future, use physics material instead.");
if (physics_material_override.is_null()) {
return 0;
}
return physics_material_override->get_bounce();
}
#endif
void StaticBody::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) { void StaticBody::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
if (physics_material_override.is_valid()) { if (physics_material_override.is_valid()) {
if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, this, "_reload_physics_characteristics")) if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, this, "_reload_physics_characteristics"))
@ -282,14 +224,6 @@ void StaticBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"), &StaticBody::get_constant_linear_velocity); ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"), &StaticBody::get_constant_linear_velocity);
ClassDB::bind_method(D_METHOD("get_constant_angular_velocity"), &StaticBody::get_constant_angular_velocity); ClassDB::bind_method(D_METHOD("get_constant_angular_velocity"), &StaticBody::get_constant_angular_velocity);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_friction", "friction"), &StaticBody::set_friction);
ClassDB::bind_method(D_METHOD("get_friction"), &StaticBody::get_friction);
ClassDB::bind_method(D_METHOD("set_bounce", "bounce"), &StaticBody::set_bounce);
ClassDB::bind_method(D_METHOD("get_bounce"), &StaticBody::get_bounce);
#endif // DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &StaticBody::set_physics_material_override); ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &StaticBody::set_physics_material_override);
ClassDB::bind_method(D_METHOD("get_physics_material_override"), &StaticBody::get_physics_material_override); ClassDB::bind_method(D_METHOD("get_physics_material_override"), &StaticBody::get_physics_material_override);
@ -299,10 +233,6 @@ void StaticBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_collision_exception_with", "body"), &PhysicsBody::add_collision_exception_with); ClassDB::bind_method(D_METHOD("add_collision_exception_with", "body"), &PhysicsBody::add_collision_exception_with);
ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &PhysicsBody::remove_collision_exception_with); ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &PhysicsBody::remove_collision_exception_with);
#ifndef DISABLE_DEPRECATED
ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_friction", "get_friction");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_bounce", "get_bounce");
#endif // DISABLE_DEPRECATED
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_linear_velocity"), "set_constant_linear_velocity", "get_constant_linear_velocity"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_linear_velocity"), "set_constant_linear_velocity", "get_constant_linear_velocity");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_angular_velocity"), "set_constant_angular_velocity", "get_constant_angular_velocity"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_angular_velocity"), "set_constant_angular_velocity", "get_constant_angular_velocity");
@ -618,60 +548,6 @@ real_t RigidBody::get_weight() const {
return mass * real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8)); return mass * real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8));
} }
#ifndef DISABLE_DEPRECATED
void RigidBody::set_friction(real_t p_friction) {
if (p_friction == 1.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}
WARN_DEPRECATED_MSG("The method set_friction has been deprecated and will be removed in the future, use physics material instead.");
ERR_FAIL_COND(p_friction < 0 || p_friction > 1);
if (physics_material_override.is_null()) {
physics_material_override.instance();
set_physics_material_override(physics_material_override);
}
physics_material_override->set_friction(p_friction);
}
real_t RigidBody::get_friction() const {
WARN_DEPRECATED_MSG("The method get_friction has been deprecated and will be removed in the future, use physics material instead.");
if (physics_material_override.is_null()) {
return 1;
}
return physics_material_override->get_friction();
}
void RigidBody::set_bounce(real_t p_bounce) {
if (p_bounce == 0.0 && physics_material_override.is_null()) { // default value, don't create an override for that
return;
}
WARN_DEPRECATED_MSG("The method set_bounce has been deprecated and will be removed in the future, use physics material instead.");
ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1);
if (physics_material_override.is_null()) {
physics_material_override.instance();
set_physics_material_override(physics_material_override);
}
physics_material_override->set_bounce(p_bounce);
}
real_t RigidBody::get_bounce() const {
WARN_DEPRECATED_MSG("The method get_bounce has been deprecated and will be removed in the future, use physics material instead.");
if (physics_material_override.is_null()) {
return 0;
}
return physics_material_override->get_bounce();
}
#endif // DISABLE_DEPRECATED
void RigidBody::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) { void RigidBody::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
if (physics_material_override.is_valid()) { if (physics_material_override.is_valid()) {
if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, this, "_reload_physics_characteristics")) if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, this, "_reload_physics_characteristics"))
@ -935,14 +811,6 @@ void RigidBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_weight", "weight"), &RigidBody::set_weight); ClassDB::bind_method(D_METHOD("set_weight", "weight"), &RigidBody::set_weight);
ClassDB::bind_method(D_METHOD("get_weight"), &RigidBody::get_weight); ClassDB::bind_method(D_METHOD("get_weight"), &RigidBody::get_weight);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_friction", "friction"), &RigidBody::set_friction);
ClassDB::bind_method(D_METHOD("get_friction"), &RigidBody::get_friction);
ClassDB::bind_method(D_METHOD("set_bounce", "bounce"), &RigidBody::set_bounce);
ClassDB::bind_method(D_METHOD("get_bounce"), &RigidBody::get_bounce);
#endif // DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &RigidBody::set_physics_material_override); ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &RigidBody::set_physics_material_override);
ClassDB::bind_method(D_METHOD("get_physics_material_override"), &RigidBody::get_physics_material_override); ClassDB::bind_method(D_METHOD("get_physics_material_override"), &RigidBody::get_physics_material_override);
@ -1005,10 +873,6 @@ void RigidBody::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Rigid,Static,Character,Kinematic"), "set_mode", "get_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Rigid,Static,Character,Kinematic"), "set_mode", "get_mode");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), "set_mass", "get_mass"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), "set_mass", "get_mass");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "weight", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", PROPERTY_USAGE_EDITOR), "set_weight", "get_weight"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "weight", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", PROPERTY_USAGE_EDITOR), "set_weight", "get_weight");
#ifndef DISABLE_DEPRECATED
ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_friction", "get_friction");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_bounce", "get_bounce");
#endif // DISABLE_DEPRECATED
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_scale", PROPERTY_HINT_RANGE, "-128,128,0.01"), "set_gravity_scale", "get_gravity_scale"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_scale", PROPERTY_HINT_RANGE, "-128,128,0.01"), "set_gravity_scale", "get_gravity_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom_integrator"), "set_use_custom_integrator", "is_using_custom_integrator"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom_integrator"), "set_use_custom_integrator", "is_using_custom_integrator");

View File

@ -88,14 +88,6 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifndef DISABLE_DEPRECATED
void set_friction(real_t p_friction);
real_t get_friction() const;
void set_bounce(real_t p_bounce);
real_t get_bounce() const;
#endif
void set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override); void set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override);
Ref<PhysicsMaterial> get_physics_material_override() const; Ref<PhysicsMaterial> get_physics_material_override() const;
@ -204,14 +196,6 @@ public:
void set_weight(real_t p_weight); void set_weight(real_t p_weight);
real_t get_weight() const; real_t get_weight() const;
#ifndef DISABLE_DEPRECATED
void set_friction(real_t p_friction);
real_t get_friction() const;
void set_bounce(real_t p_bounce);
real_t get_bounce() const;
#endif
void set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override); void set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override);
Ref<PhysicsMaterial> get_physics_material_override() const; Ref<PhysicsMaterial> get_physics_material_override() const;