Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
7b7f4b20
Unverified
Commit
7b7f4b20
authored
Aug 29, 2018
by
Rémi Verschelde
Committed by
GitHub
Aug 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #21572 from akien-mga/physicsbody-friction-bounce
Physics: Properly obsolete friction and bounce properties
parents
5eb32cc1
06098840
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
47 deletions
+25
-47
physics_body_2d.cpp
scene/2d/physics_body_2d.cpp
+13
-23
physics_body.cpp
scene/3d/physics_body.cpp
+12
-24
No files found.
scene/2d/physics_body_2d.cpp
View file @
7b7f4b20
...
...
@@ -35,18 +35,8 @@
#include "engine.h"
#include "math_funcs.h"
#include "scene/scene_string_names.h"
void
PhysicsBody2D
::
_notification
(
int
p_what
)
{
/*
switch(p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_TRANSFORM,get_global_transform());
} break;
}
*/
void
PhysicsBody2D
::
_notification
(
int
p_what
)
{
}
void
PhysicsBody2D
::
_set_layers
(
uint32_t
p_mask
)
{
...
...
@@ -190,7 +180,7 @@ real_t StaticBody2D::get_constant_angular_velocity() const {
#ifndef DISABLE_DEPRECATED
void
StaticBody2D
::
set_friction
(
real_t
p_friction
)
{
ERR_EXPLAIN
(
"The method set_friction has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method set_friction has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
ERR_FAIL_COND
(
p_friction
<
0
||
p_friction
>
1
);
...
...
@@ -204,7 +194,7 @@ void StaticBody2D::set_friction(real_t p_friction) {
real_t
StaticBody2D
::
get_friction
()
const
{
ERR_EXPLAIN
(
"The method get_friction has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method get_friction has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
if
(
physics_material_override
.
is_null
())
{
...
...
@@ -216,7 +206,7 @@ real_t StaticBody2D::get_friction() const {
void
StaticBody2D
::
set_bounce
(
real_t
p_bounce
)
{
ERR_EXPLAIN
(
"The method set_bounce has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method set_bounce has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
ERR_FAIL_COND
(
p_bounce
<
0
||
p_bounce
>
1
);
...
...
@@ -230,7 +220,7 @@ void StaticBody2D::set_bounce(real_t p_bounce) {
real_t
StaticBody2D
::
get_bounce
()
const
{
ERR_EXPLAIN
(
"The method get_bounce has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method get_bounce has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
if
(
physics_material_override
.
is_null
())
{
...
...
@@ -282,8 +272,8 @@ void StaticBody2D::_bind_methods() {
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"
);
#ifndef DISABLE_DEPRECATED
ADD_PROPERTY
(
PropertyInfo
(
Variant
::
REAL
,
"friction"
,
PROPERTY_HINT_RANGE
,
"0,1,0.01"
),
"set_friction"
,
"get_friction"
);
ADD_PROPERTY
(
PropertyInfo
(
Variant
::
REAL
,
"bounce"
,
PROPERTY_HINT_RANGE
,
"0,1,0.01"
),
"set_bounce"
,
"get_bounce"
);
ADD_PROPERTY
NO
(
PropertyInfo
(
Variant
::
REAL
,
"friction"
,
PROPERTY_HINT_RANGE
,
"0,1,0.01"
,
0
),
"set_friction"
,
"get_friction"
);
ADD_PROPERTY
NZ
(
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"
);
}
...
...
@@ -609,7 +599,7 @@ real_t RigidBody2D::get_weight() const {
#ifndef DISABLE_DEPRECATED
void
RigidBody2D
::
set_friction
(
real_t
p_friction
)
{
ERR_EXPLAIN
(
"The method set_friction has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method set_friction has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
ERR_FAIL_COND
(
p_friction
<
0
||
p_friction
>
1
);
...
...
@@ -621,7 +611,7 @@ void RigidBody2D::set_friction(real_t p_friction) {
}
real_t
RigidBody2D
::
get_friction
()
const
{
ERR_EXPLAIN
(
"The method get_friction has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method get_friction has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
if
(
physics_material_override
.
is_null
())
{
...
...
@@ -633,7 +623,7 @@ real_t RigidBody2D::get_friction() const {
void
RigidBody2D
::
set_bounce
(
real_t
p_bounce
)
{
ERR_EXPLAIN
(
"The method set_bounce has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method set_bounce has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
ERR_FAIL_COND
(
p_bounce
<
0
||
p_bounce
>
1
);
...
...
@@ -646,7 +636,7 @@ void RigidBody2D::set_bounce(real_t p_bounce) {
}
real_t
RigidBody2D
::
get_bounce
()
const
{
ERR_EXPLAIN
(
"The method get_bounce has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method get_bounce has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
if
(
physics_material_override
.
is_null
())
{
...
...
@@ -1035,8 +1025,8 @@ void RigidBody2D::_bind_methods() {
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"
);
#ifndef DISABLE_DEPRECATED
ADD_PROPERTY
(
PropertyInfo
(
Variant
::
REAL
,
"friction"
,
PROPERTY_HINT_RANGE
,
"0,1,0.01"
),
"set_friction"
,
"get_friction"
);
ADD_PROPERTY
(
PropertyInfo
(
Variant
::
REAL
,
"bounce"
,
PROPERTY_HINT_RANGE
,
"0,1,0.01"
),
"set_bounce"
,
"get_bounce"
);
ADD_PROPERTY
NO
(
PropertyInfo
(
Variant
::
REAL
,
"friction"
,
PROPERTY_HINT_RANGE
,
"0,1,0.01"
,
0
),
"set_friction"
,
"get_friction"
);
ADD_PROPERTY
NZ
(
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
::
REAL
,
"gravity_scale"
,
PROPERTY_HINT_RANGE
,
"-128,128,0.01"
),
"set_gravity_scale"
,
"get_gravity_scale"
);
...
...
scene/3d/physics_body.cpp
View file @
7b7f4b20
...
...
@@ -40,17 +40,6 @@
#endif
void
PhysicsBody
::
_notification
(
int
p_what
)
{
/*
switch(p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
PhysicsServer::get_singleton()->body_set_state(get_rid(),PhysicsServer::BODY_STATE_TRANSFORM,get_global_transform());
} break;
}
*/
}
Vector3
PhysicsBody
::
get_linear_velocity
()
const
{
...
...
@@ -182,7 +171,7 @@ PhysicsBody::PhysicsBody(PhysicsServer::BodyMode p_mode) :
#ifndef DISABLE_DEPRECATED
void
StaticBody
::
set_friction
(
real_t
p_friction
)
{
ERR_EXPLAIN
(
"The method set_friction has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method set_friction has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
ERR_FAIL_COND
(
p_friction
<
0
||
p_friction
>
1
);
...
...
@@ -191,13 +180,12 @@ void StaticBody::set_friction(real_t p_friction) {
physics_material_override
.
instance
();
set_physics_material_override
(
physics_material_override
);
}
physics_material_override
->
set_friction
(
p_friction
);
}
real_t
StaticBody
::
get_friction
()
const
{
ERR_EXPLAIN
(
"The method get_friction has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method get_friction has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
if
(
physics_material_override
.
is_null
())
{
...
...
@@ -209,7 +197,7 @@ real_t StaticBody::get_friction() const {
void
StaticBody
::
set_bounce
(
real_t
p_bounce
)
{
ERR_EXPLAIN
(
"The method set_bounce has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method set_bounce has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
ERR_FAIL_COND
(
p_bounce
<
0
||
p_bounce
>
1
);
...
...
@@ -223,7 +211,7 @@ void StaticBody::set_bounce(real_t p_bounce) {
real_t
StaticBody
::
get_bounce
()
const
{
ERR_EXPLAIN
(
"The method get_bounce has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method get_bounce has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
if
(
physics_material_override
.
is_null
())
{
...
...
@@ -297,8 +285,8 @@ void StaticBody::_bind_methods() {
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"
),
"set_friction"
,
"get_friction"
);
ADD_PROPERTY
(
PropertyInfo
(
Variant
::
REAL
,
"bounce"
,
PROPERTY_HINT_RANGE
,
"0,1,0.01"
),
"set_bounce"
,
"get_bounce"
);
ADD_PROPERTY
NO
(
PropertyInfo
(
Variant
::
REAL
,
"friction"
,
PROPERTY_HINT_RANGE
,
"0,1,0.01"
,
0
),
"set_friction"
,
"get_friction"
);
ADD_PROPERTY
NZ
(
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
::
VECTOR3
,
"constant_linear_velocity"
),
"set_constant_linear_velocity"
,
"get_constant_linear_velocity"
);
...
...
@@ -618,7 +606,7 @@ real_t RigidBody::get_weight() const {
#ifndef DISABLE_DEPRECATED
void
RigidBody
::
set_friction
(
real_t
p_friction
)
{
ERR_EXPLAIN
(
"The method set_friction has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method set_friction has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
ERR_FAIL_COND
(
p_friction
<
0
||
p_friction
>
1
);
...
...
@@ -630,7 +618,7 @@ void RigidBody::set_friction(real_t p_friction) {
}
real_t
RigidBody
::
get_friction
()
const
{
ERR_EXPLAIN
(
"The method get_friction has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method get_friction has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
if
(
physics_material_override
.
is_null
())
{
return
1
;
...
...
@@ -640,7 +628,7 @@ real_t RigidBody::get_friction() const {
}
void
RigidBody
::
set_bounce
(
real_t
p_bounce
)
{
ERR_EXPLAIN
(
"The method set_bounce has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method set_bounce has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
ERR_FAIL_COND
(
p_bounce
<
0
||
p_bounce
>
1
);
...
...
@@ -651,7 +639,7 @@ void RigidBody::set_bounce(real_t p_bounce) {
physics_material_override
->
set_bounce
(
p_bounce
);
}
real_t
RigidBody
::
get_bounce
()
const
{
ERR_EXPLAIN
(
"The method get_bounce has been deprecated and will be removed in the future, use physic
al material
"
)
ERR_EXPLAIN
(
"The method get_bounce has been deprecated and will be removed in the future, use physic
s material instead.
"
)
WARN_DEPRECATED
if
(
physics_material_override
.
is_null
())
{
return
0
;
...
...
@@ -998,8 +986,8 @@ void RigidBody::_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
,
"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"
),
"set_friction"
,
"get_friction"
);
ADD_PROPERTY
(
PropertyInfo
(
Variant
::
REAL
,
"bounce"
,
PROPERTY_HINT_RANGE
,
"0,1,0.01"
),
"set_bounce"
,
"get_bounce"
);
ADD_PROPERTY
NO
(
PropertyInfo
(
Variant
::
REAL
,
"friction"
,
PROPERTY_HINT_RANGE
,
"0,1,0.01"
,
0
),
"set_friction"
,
"get_friction"
);
ADD_PROPERTY
NZ
(
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
::
REAL
,
"gravity_scale"
,
PROPERTY_HINT_RANGE
,
"-128,128,0.01"
),
"set_gravity_scale"
,
"get_gravity_scale"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment