mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Physics Interpolation - Add editor warning for non-interpolated physics body
(cherry picked from commit 9ad73062e8
)
This commit is contained in:
parent
82158b3f7d
commit
fec8e695b6
5 changed files with 34 additions and 2 deletions
|
@ -60,6 +60,19 @@ void PhysicsBody2D::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::INT, "layers", PROPERTY_HINT_LAYERS_2D_PHYSICS, "", 0), "_set_layers", "_get_layers"); //for backwards compat
|
||||
}
|
||||
|
||||
String PhysicsBody2D::get_configuration_warning() const {
|
||||
String warning = CollisionObject2D::get_configuration_warning();
|
||||
|
||||
if (!is_physics_interpolated()) {
|
||||
if (!warning.empty()) {
|
||||
warning += "\n\n";
|
||||
}
|
||||
warning += TTR("PhysicsBody2D will not work correctly on a non-interpolated branch of the SceneTree.\nCheck the node's inherited physics_interpolation_mode.");
|
||||
}
|
||||
|
||||
return warning;
|
||||
}
|
||||
|
||||
PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) :
|
||||
CollisionObject2D(RID_PRIME(Physics2DServer::get_singleton()->body_create()), false) {
|
||||
Physics2DServer::get_singleton()->body_set_mode(get_rid(), p_mode);
|
||||
|
@ -808,7 +821,7 @@ void RigidBody2D::_notification(int p_what) {
|
|||
String RigidBody2D::get_configuration_warning() const {
|
||||
Transform2D t = get_transform();
|
||||
|
||||
String warning = CollisionObject2D::get_configuration_warning();
|
||||
String warning = PhysicsBody2D::get_configuration_warning();
|
||||
|
||||
if ((get_mode() == MODE_RIGID || get_mode() == MODE_CHARACTER) && (ABS(t.elements[0].length() - 1.0) > 0.05 || ABS(t.elements[1].length() - 1.0) > 0.05)) {
|
||||
if (warning != String()) {
|
||||
|
|
|
@ -51,6 +51,8 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual String get_configuration_warning() const;
|
||||
|
||||
Array get_collision_exceptions();
|
||||
void add_collision_exception_with(Node *p_node); //must be physicsbody
|
||||
void remove_collision_exception_with(Node *p_node);
|
||||
|
|
|
@ -98,6 +98,19 @@ void PhysicsBody::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("_get_layers"), &PhysicsBody::_get_layers);
|
||||
}
|
||||
|
||||
String PhysicsBody::get_configuration_warning() const {
|
||||
String warning = CollisionObject::get_configuration_warning();
|
||||
|
||||
if (!is_physics_interpolated()) {
|
||||
if (!warning.empty()) {
|
||||
warning += "\n\n";
|
||||
}
|
||||
warning += TTR("PhysicsBody will not work correctly on a non-interpolated branch of the SceneTree.\nCheck the node's inherited physics_interpolation_mode.");
|
||||
}
|
||||
|
||||
return warning;
|
||||
}
|
||||
|
||||
PhysicsBody::PhysicsBody(PhysicsServer::BodyMode p_mode) :
|
||||
CollisionObject(RID_PRIME(PhysicsServer::get_singleton()->body_create(p_mode)), false) {
|
||||
}
|
||||
|
@ -783,7 +796,7 @@ Array RigidBody::get_colliding_bodies() const {
|
|||
String RigidBody::get_configuration_warning() const {
|
||||
Transform t = get_transform();
|
||||
|
||||
String warning = CollisionObject::get_configuration_warning();
|
||||
String warning = PhysicsBody::get_configuration_warning();
|
||||
|
||||
if ((get_mode() == MODE_RIGID || get_mode() == MODE_CHARACTER) && (ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(2).length() - 1.0) > 0.05)) {
|
||||
if (warning != String()) {
|
||||
|
|
|
@ -49,6 +49,8 @@ protected:
|
|||
PhysicsBody(PhysicsServer::BodyMode p_mode);
|
||||
|
||||
public:
|
||||
virtual String get_configuration_warning() const;
|
||||
|
||||
virtual Vector3 get_linear_velocity() const;
|
||||
virtual Vector3 get_angular_velocity() const;
|
||||
virtual float get_inverse_mass() const;
|
||||
|
|
|
@ -225,6 +225,8 @@ void Node::_propagate_physics_interpolated(bool p_interpolated) {
|
|||
// allow a call to the VisualServer etc in derived classes
|
||||
_physics_interpolated_changed();
|
||||
|
||||
update_configuration_warning();
|
||||
|
||||
data.blocked++;
|
||||
for (int i = 0; i < data.children.size(); i++) {
|
||||
data.children[i]->_propagate_physics_interpolated(p_interpolated);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue