From 18103f2b898a30c459d30edf73048af651bbe6f3 Mon Sep 17 00:00:00 2001 From: Jon Ring Date: Thu, 18 Jul 2019 14:16:28 -0400 Subject: Add per-wheel throttle, brake, and steering for vehicles --- scene/3d/vehicle_body.cpp | 68 +++++++++++++++++++++++++++++++++++++++++------ scene/3d/vehicle_body.h | 11 +++++++- 2 files changed, 70 insertions(+), 9 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index 89e96e0227..98e68cfbda 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -272,6 +272,20 @@ void VehicleWheel::_bind_methods() { ClassDB::bind_method(D_METHOD("get_rpm"), &VehicleWheel::get_rpm); + ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleWheel::set_engine_force); + ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleWheel::get_engine_force); + + ClassDB::bind_method(D_METHOD("set_brake", "brake"), &VehicleWheel::set_brake); + ClassDB::bind_method(D_METHOD("get_brake"), &VehicleWheel::get_brake); + + ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleWheel::set_steering); + ClassDB::bind_method(D_METHOD("get_steering"), &VehicleWheel::get_steering); + + ADD_GROUP("Per-Wheel Motion", ""); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "engine_force", PROPERTY_HINT_RANGE, "0.00,1024.0,0.01,or_greater"), "set_engine_force", "get_engine_force"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "brake", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_brake", "get_brake"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "steering", PROPERTY_HINT_RANGE, "-180,180.0,0.01"), "set_steering", "get_steering"); + ADD_GROUP("VehicleBody Motion", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_as_traction"), "set_use_as_traction", "is_used_as_traction"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_as_steering"), "set_use_as_steering", "is_used_as_steering"); ADD_GROUP("Wheel", "wheel_"); @@ -288,6 +302,34 @@ void VehicleWheel::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "damping_relaxation"), "set_damping_relaxation", "get_damping_relaxation"); } +void VehicleWheel::set_engine_force(float p_engine_force) { + + m_engineForce = p_engine_force; +} + +float VehicleWheel::get_engine_force() const { + + return m_engineForce; +} + +void VehicleWheel::set_brake(float p_brake) { + + m_brake = p_brake; +} +float VehicleWheel::get_brake() const { + + return m_brake; +} + +void VehicleWheel::set_steering(float p_steering) { + + m_steering = p_steering; +} +float VehicleWheel::get_steering() const { + + return m_steering; +} + void VehicleWheel::set_use_as_traction(bool p_enable) { engine_traction = p_enable; @@ -374,10 +416,7 @@ void VehicleBody::_update_wheel(int p_idx, PhysicsDirectBodyState *s) { Vector3 fwd = up.cross(right); fwd = fwd.normalized(); - //rotate around steering over de wheelAxleWS - real_t steering = wheel.steers ? m_steeringValue : 0.0; - - Basis steeringMat(up, steering); + Basis steeringMat(up, wheel.m_steering); Basis rotatingMat(right, wheel.m_rotation); @@ -723,12 +762,11 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) { real_t rollingFriction = 0.f; if (wheelInfo.m_raycastInfo.m_isInContact) { - if (engine_force != 0.f && wheelInfo.engine_traction) { - rollingFriction = -engine_force * s->get_step(); + if (wheelInfo.m_engineForce != 0.f) { + rollingFriction = -wheelInfo.m_engineForce * s->get_step(); } else { real_t defaultRollingFrictionImpulse = 0.f; - float cbrake = MAX(wheelInfo.m_brake, brake); - real_t maxImpulse = cbrake ? cbrake : defaultRollingFrictionImpulse; + real_t maxImpulse = wheelInfo.m_brake ? wheelInfo.m_brake : defaultRollingFrictionImpulse; btVehicleWheelContactPoint contactPt(s, wheelInfo.m_raycastInfo.m_groundObject, wheelInfo.m_raycastInfo.m_contactPointWS, m_forwardWS[wheel], maxImpulse); rollingFriction = _calc_rolling_friction(contactPt); } @@ -886,6 +924,11 @@ void VehicleBody::_direct_state_changed(Object *p_state) { void VehicleBody::set_engine_force(float p_engine_force) { engine_force = p_engine_force; + for (int i = 0; i < wheels.size(); i++) { + VehicleWheel &wheelInfo = *wheels[i]; + if (wheelInfo.engine_traction) + wheelInfo.m_engineForce = p_engine_force; + } } float VehicleBody::get_engine_force() const { @@ -896,6 +939,10 @@ float VehicleBody::get_engine_force() const { void VehicleBody::set_brake(float p_brake) { brake = p_brake; + for (int i = 0; i < wheels.size(); i++) { + VehicleWheel &wheelInfo = *wheels[i]; + wheelInfo.m_brake = p_brake; + } } float VehicleBody::get_brake() const { @@ -905,6 +952,11 @@ float VehicleBody::get_brake() const { void VehicleBody::set_steering(float p_steering) { m_steeringValue = p_steering; + for (int i = 0; i < wheels.size(); i++) { + VehicleWheel &wheelInfo = *wheels[i]; + if (wheelInfo.steers) + wheelInfo.m_steering = p_steering; + } } float VehicleBody::get_steering() const { diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h index 9e3fe72282..914bfd54bd 100644 --- a/scene/3d/vehicle_body.h +++ b/scene/3d/vehicle_body.h @@ -70,7 +70,7 @@ class VehicleWheel : public Spatial { real_t m_deltaRotation; real_t m_rpm; real_t m_rollInfluence; - //real_t m_engineForce; + real_t m_engineForce; real_t m_brake; real_t m_clippedInvContactDotSuspension; @@ -137,6 +137,15 @@ public: float get_rpm() const; + void set_engine_force(float p_engine_force); + float get_engine_force() const; + + void set_brake(float p_brake); + float get_brake() const; + + void set_steering(float p_steering); + float get_steering() const; + String get_configuration_warning() const; VehicleWheel(); -- cgit v1.2.3 From 66d09a6b4cae73fbb48fe01082af5397c4a75d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 22 Jul 2019 13:57:39 +0200 Subject: SCons: Fix uses of [].append instead of env.add_source_files() Also added support for SCons project-absolute paths (starting with #) and warning about duplicates in add_source_files(), and fixed default_controller_mappings.gen.cpp being included twice after first build due to *.cpp globbing. Part of #30270. --- scene/3d/SCsub | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/SCsub b/scene/3d/SCsub index 200cf4316f..31a443bad1 100644 --- a/scene/3d/SCsub +++ b/scene/3d/SCsub @@ -3,10 +3,10 @@ Import('env') if env['disable_3d']: - env.scene_sources.append("3d/spatial.cpp") - env.scene_sources.append("3d/skeleton.cpp") - env.scene_sources.append("3d/particles.cpp") - env.scene_sources.append("3d/visual_instance.cpp") - env.scene_sources.append("3d/world_environment.cpp") + env.add_source_files(env.scene_sources, "spatial.cpp") + env.add_source_files(env.scene_sources, "skeleton.cpp") + env.add_source_files(env.scene_sources, "particles.cpp") + env.add_source_files(env.scene_sources, "visual_instance.cpp") + env.add_source_files(env.scene_sources, "world_environment.cpp") else: env.add_source_files(env.scene_sources, "*.cpp") -- cgit v1.2.3 From 336846e547c1daeb8855b091d21df3b91c2a80a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 25 Jul 2019 09:11:41 +0200 Subject: Inspector: Fix PROPERTY_HINT_SPRITE_FRAME not behaving as RANGE This was a regression in 3.1 and later from the new inspector, where PROPERTY_HINT_SPRITE_FRAME was not fully re-implemented. It's meant to be a normal PROPERTY_HINT_RANGE which also automatically increments its value when keyed in the animation player. To avoid code duplication, I made the frames properties use the actual PROPERTY_HINT_RANGE and introduced a PROPERTY_USAGE_KEYING_INCREMENTS usage flag instead. --- scene/3d/sprite_3d.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 2c315790ac..b39762fde8 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -628,10 +628,9 @@ Rect2 Sprite3D::get_item_rect() const { void Sprite3D::_validate_property(PropertyInfo &property) const { if (property.name == "frame") { - - property.hint = PROPERTY_HINT_SPRITE_FRAME; - + property.hint = PROPERTY_HINT_RANGE; property.hint_string = "0," + itos(vframes * hframes - 1) + ",1"; + property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS; } } @@ -659,7 +658,7 @@ void Sprite3D::_bind_methods() { ADD_GROUP("Animation", ""); ADD_PROPERTY(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_vframes", "get_vframes"); ADD_PROPERTY(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_hframes", "get_hframes"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), "set_frame", "get_frame"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame"); ADD_GROUP("Region", "region_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region_enabled"), "set_region", "is_region"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect"); @@ -851,14 +850,11 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &property) const { } if (property.name == "frame") { - property.hint = PROPERTY_HINT_RANGE; - - if (frames->has_animation(animation)) { + if (frames->has_animation(animation) && frames->get_frame_count(animation) > 1) { property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1"; - } else { - property.hint_string = "0,0,0"; } + property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS; } } @@ -1091,7 +1087,7 @@ void AnimatedSprite3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), "set_sprite_frames", "get_sprite_frames"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), "set_frame", "get_frame"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "_set_playing", "_is_playing"); } -- cgit v1.2.3 From 4ff360b73b0b0241292c51b2358817244d277734 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Silva Dias Date: Thu, 25 Jul 2019 11:53:54 -0300 Subject: Fix wrong placement of new line in 'PhysicsBody' warning --- scene/3d/collision_object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scene/3d') diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index 9d3e2983c4..63301fc226 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -370,7 +370,7 @@ String CollisionObject::get_configuration_warning() const { String warning = Spatial::get_configuration_warning(); if (shapes.empty()) { - if (warning == String()) { + if (!warning.empty()) { warning += "\n\n"; } warning += TTR("This node has no shape, so it can't collide or interact with other objects.\nConsider adding a CollisionShape or CollisionPolygon as a child to define its shape."); -- cgit v1.2.3 From 11cb4eb3638b0f97e1efde1ac54a3c7a94ea9d1b Mon Sep 17 00:00:00 2001 From: groud Date: Fri, 25 Jan 2019 19:21:23 +0100 Subject: Add frame_cords accessors to Sprite and Sprite3D --- scene/3d/sprite_3d.cpp | 18 ++++++++++++++++++ scene/3d/sprite_3d.h | 3 +++ 2 files changed, 21 insertions(+) (limited to 'scene/3d') diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index b39762fde8..fc5523633d 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -564,6 +564,9 @@ void Sprite3D::set_frame(int p_frame) { frame = p_frame; _queue_update(); + + _change_notify("frame"); + _change_notify("frame_coords"); emit_signal(SceneStringNames::get_singleton()->frame_changed); } @@ -572,6 +575,17 @@ int Sprite3D::get_frame() const { return frame; } +void Sprite3D::set_frame_coords(const Vector2 &p_coord) { + ERR_FAIL_INDEX(int(p_coord.x), vframes); + ERR_FAIL_INDEX(int(p_coord.y), hframes); + + set_frame(int(p_coord.y) * hframes + int(p_coord.x)); +} + +Vector2 Sprite3D::get_frame_coords() const { + return Vector2(frame % hframes, frame / hframes); +} + void Sprite3D::set_vframes(int p_amount) { ERR_FAIL_COND(p_amount < 1); @@ -648,6 +662,9 @@ void Sprite3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_frame", "frame"), &Sprite3D::set_frame); ClassDB::bind_method(D_METHOD("get_frame"), &Sprite3D::get_frame); + ClassDB::bind_method(D_METHOD("set_frame_coords", "coords"), &Sprite3D::set_frame_coords); + ClassDB::bind_method(D_METHOD("get_frame_coords"), &Sprite3D::get_frame_coords); + ClassDB::bind_method(D_METHOD("set_vframes", "vframes"), &Sprite3D::set_vframes); ClassDB::bind_method(D_METHOD("get_vframes"), &Sprite3D::get_vframes); @@ -659,6 +676,7 @@ void Sprite3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_vframes", "get_vframes"); ADD_PROPERTY(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_hframes", "get_hframes"); ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "frame_coords", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_frame_coords", "get_frame_coords"); ADD_GROUP("Region", "region_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region_enabled"), "set_region", "is_region"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect"); diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 0e086ef31e..5ae9b153f9 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -173,6 +173,9 @@ public: void set_frame(int p_frame); int get_frame() const; + void set_frame_coords(const Vector2 &p_row); + Vector2 get_frame_coords() const; + void set_vframes(int p_amount); int get_vframes() const; -- cgit v1.2.3 From 0243dc53b8491d086f7e472a07c8ef081456fb12 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 31 Jul 2019 13:55:38 +0200 Subject: Tweak Area and PhysicsBody damping setting hints for consistency This partially addresses #19182. --- scene/3d/area.cpp | 4 ++-- scene/3d/physics_body.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 4247266e3d..19f43dd274 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -718,8 +718,8 @@ void Area::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_distance_scale", PROPERTY_HINT_EXP_RANGE, "0,1024,0.001,or_greater"), "set_gravity_distance_scale", "get_gravity_distance_scale"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "gravity_vec"), "set_gravity_vector", "get_gravity_vector"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity", PROPERTY_HINT_RANGE, "-1024,1024,0.01"), "set_gravity", "get_gravity"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_damp", PROPERTY_HINT_RANGE, "0,1024,0.001"), "set_linear_damp", "get_linear_damp"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_damp", PROPERTY_HINT_RANGE, "0,1024,0.001"), "set_angular_damp", "get_angular_damp"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp"); ADD_PROPERTY(PropertyInfo(Variant::INT, "priority", PROPERTY_HINT_RANGE, "0,128,1"), "set_priority", "get_priority"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitoring"), "set_monitoring", "is_monitoring"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitorable"), "set_monitorable", "is_monitorable"); diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 2f8b2ecc5c..fa2bb300fa 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -1044,10 +1044,10 @@ void RigidBody::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_z"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_ANGULAR_Z); ADD_GROUP("Linear", "linear_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity"), "set_linear_velocity", "get_linear_velocity"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_damp", PROPERTY_HINT_RANGE, "-1,128,0.01"), "set_linear_damp", "get_linear_damp"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp"); ADD_GROUP("Angular", "angular_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity"), "set_angular_velocity", "get_angular_velocity"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_damp", PROPERTY_HINT_RANGE, "-1,128,0.01"), "set_angular_damp", "get_angular_damp"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp"); ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape"))); ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape"))); -- cgit v1.2.3 From 2fae8832c5480582c9d35eefd3b5c541042cbc94 Mon Sep 17 00:00:00 2001 From: David Sichma Date: Thu, 1 Aug 2019 12:54:19 +0200 Subject: Fix floor_max_angle comparison for impossible angles --- scene/3d/physics_body.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index fa2bb300fa..2b4109574b 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -1209,7 +1209,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve //all is a wall on_wall = true; } else { - if (collision.normal.dot(p_floor_direction) >= Math::cos(p_floor_max_angle + FLOOR_ANGLE_THRESHOLD)) { //floor + if (Math::acos(collision.normal.dot(p_floor_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor on_floor = true; on_floor_body = collision.collider_rid; @@ -1226,7 +1226,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve is_on_slope = true; - } else if (collision.normal.dot(-p_floor_direction) >= Math::cos(p_floor_max_angle + FLOOR_ANGLE_THRESHOLD)) { //ceiling + } else if (Math::acos(collision.normal.dot(-p_floor_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //ceiling on_ceiling = true; } else { on_wall = true; -- cgit v1.2.3 From e0b5b218638df5b7b2998233182a7d8a1118e717 Mon Sep 17 00:00:00 2001 From: qarmin Date: Wed, 7 Aug 2019 12:54:30 +0200 Subject: Add some code changes/fixes proposed by Coverity and Clang Tidy --- scene/3d/sprite_3d.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scene/3d') diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 5ae9b153f9..97a426b5b9 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -173,7 +173,7 @@ public: void set_frame(int p_frame); int get_frame() const; - void set_frame_coords(const Vector2 &p_row); + void set_frame_coords(const Vector2 &p_coord); Vector2 get_frame_coords() const; void set_vframes(int p_amount); -- cgit v1.2.3 From af5e0fff66d55d07a7910bcd7f170da2f952f7cb Mon Sep 17 00:00:00 2001 From: Tomasz Chabora Date: Thu, 8 Aug 2019 22:11:48 +0200 Subject: Remove ERR_EXPLAIN from scene/* code --- scene/3d/area.cpp | 15 +++------------ scene/3d/arvr_nodes.cpp | 15 +++------------ scene/3d/camera.cpp | 25 +++++-------------------- scene/3d/physics_body.cpp | 39 +++++++++++---------------------------- scene/3d/soft_body.cpp | 10 ++-------- scene/3d/spatial.cpp | 11 ++--------- 6 files changed, 26 insertions(+), 89 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 19f43dd274..77682abcb3 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -218,10 +218,7 @@ void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_bo void Area::_clear_monitoring() { - if (locked) { - ERR_EXPLAIN("This function can't be used during the in/out signal."); - } - ERR_FAIL_COND(locked); + ERR_FAIL_COND_MSG(locked, "This function can't be used during the in/out signal."); { Map bmcopy = body_map; @@ -291,10 +288,7 @@ void Area::_notification(int p_what) { void Area::set_monitoring(bool p_enable) { - if (locked) { - ERR_EXPLAIN("Function blocked during in/out signal. Use set_deferred(\"monitoring\",true/false)"); - } - ERR_FAIL_COND(locked); + ERR_FAIL_COND_MSG(locked, "Function blocked during in/out signal. Use set_deferred(\"monitoring\", true/false)."); if (p_enable == monitoring) return; @@ -441,10 +435,7 @@ Array Area::get_overlapping_bodies() const { void Area::set_monitorable(bool p_enable) { - if (locked || (is_inside_tree() && PhysicsServer::get_singleton()->is_flushing_queries())) { - ERR_EXPLAIN("Function blocked during in/out signal. Use set_deferred(\"monitorable\",true/false)"); - ERR_FAIL(); - } + ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false)."); if (p_enable == monitorable) return; diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp index 263a2d8de6..4c0449b68e 100644 --- a/scene/3d/arvr_nodes.cpp +++ b/scene/3d/arvr_nodes.cpp @@ -78,10 +78,7 @@ Vector3 ARVRCamera::project_local_ray_normal(const Point2 &p_pos) const { return Camera::project_local_ray_normal(p_pos); } - if (!is_inside_tree()) { - ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_tree(), Vector3()); - }; + ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_camera_rect_size(); Vector2 cpos = get_viewport()->get_camera_coords(p_pos); @@ -106,10 +103,7 @@ Point2 ARVRCamera::unproject_position(const Vector3 &p_pos) const { return Camera::unproject_position(p_pos); } - if (!is_inside_tree()) { - ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_tree(), Vector2()); - }; + ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector2(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_visible_rect().size; @@ -138,10 +132,7 @@ Vector3 ARVRCamera::project_position(const Point2 &p_point, float p_z_depth) con return Camera::project_position(p_point, p_z_depth); } - if (!is_inside_tree()) { - ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_tree(), Vector3()); - }; + ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_visible_rect().size; diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index c7d6919a2b..9f8510248c 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -279,10 +279,7 @@ Vector3 Camera::project_ray_normal(const Point2 &p_pos) const { Vector3 Camera::project_local_ray_normal(const Point2 &p_pos) const { - if (!is_inside_tree()) { - ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_tree(), Vector3()); - } + ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_camera_rect_size(); Vector2 cpos = get_viewport()->get_camera_coords(p_pos); @@ -304,10 +301,7 @@ Vector3 Camera::project_local_ray_normal(const Point2 &p_pos) const { Vector3 Camera::project_ray_origin(const Point2 &p_pos) const { - if (!is_inside_tree()) { - ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_tree(), Vector3()); - } + ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_camera_rect_size(); Vector2 cpos = get_viewport()->get_camera_coords(p_pos); @@ -345,10 +339,7 @@ bool Camera::is_position_behind(const Vector3 &p_pos) const { } Vector Camera::get_near_plane_points() const { - if (!is_inside_tree()) { - ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_tree(), Vector()); - } + ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_visible_rect().size; @@ -372,10 +363,7 @@ Vector Camera::get_near_plane_points() const { Point2 Camera::unproject_position(const Vector3 &p_pos) const { - if (!is_inside_tree()) { - ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_tree(), Vector2()); - } + ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector2(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_visible_rect().size; @@ -400,10 +388,7 @@ Point2 Camera::unproject_position(const Vector3 &p_pos) const { Vector3 Camera::project_position(const Point2 &p_point, float p_z_depth) const { - if (!is_inside_tree()) { - ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_tree(), Vector3()); - } + ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); if (p_z_depth == 0) { return get_global_transform().origin; diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index fa2bb300fa..19d5f1dd3c 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -129,10 +129,7 @@ void PhysicsBody::add_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); CollisionObject *collision_object = Object::cast_to(p_node); - if (!collision_object) { - ERR_EXPLAIN("Collision exception only works between two CollisionObject"); - } - ERR_FAIL_COND(!collision_object); + ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject."); PhysicsServer::get_singleton()->body_add_collision_exception(get_rid(), collision_object->get_rid()); } @@ -140,10 +137,7 @@ void PhysicsBody::remove_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); CollisionObject *collision_object = Object::cast_to(p_node); - if (!collision_object) { - ERR_EXPLAIN("Collision exception only works between two CollisionObject"); - } - ERR_FAIL_COND(!collision_object); + ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject."); PhysicsServer::get_singleton()->body_remove_collision_exception(get_rid(), collision_object->get_rid()); } @@ -192,8 +186,7 @@ void StaticBody::set_friction(real_t p_friction) { return; } - ERR_EXPLAIN("The method set_friction has been deprecated and will be removed in the future, use physics material instead."); - WARN_DEPRECATED; + 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); @@ -206,8 +199,7 @@ void StaticBody::set_friction(real_t 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 physics material instead."); - WARN_DEPRECATED; + 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; @@ -222,8 +214,7 @@ void StaticBody::set_bounce(real_t p_bounce) { return; } - ERR_EXPLAIN("The method set_bounce has been deprecated and will be removed in the future, use physics material instead."); - WARN_DEPRECATED; + 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); @@ -236,8 +227,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 physics material instead."); - WARN_DEPRECATED; + 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; @@ -636,8 +626,7 @@ void RigidBody::set_friction(real_t p_friction) { return; } - ERR_EXPLAIN("The method set_friction has been deprecated and will be removed in the future, use physics material instead."); - WARN_DEPRECATED; + 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); @@ -649,8 +638,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 physics material instead."); - WARN_DEPRECATED; + 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; @@ -665,8 +653,7 @@ void RigidBody::set_bounce(real_t p_bounce) { return; } - ERR_EXPLAIN("The method set_bounce has been deprecated and will be removed in the future, use physics material instead."); - WARN_DEPRECATED; + 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); @@ -677,8 +664,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 physics material instead."); - WARN_DEPRECATED; + 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; } @@ -867,10 +853,7 @@ void RigidBody::set_contact_monitor(bool p_enabled) { if (!p_enabled) { - if (contact_monitor->locked) { - ERR_EXPLAIN("Can't disable contact monitoring during in/out callback. Use call_deferred(\"set_contact_monitor\",false) instead"); - } - ERR_FAIL_COND(contact_monitor->locked); + ERR_FAIL_COND_MSG(contact_monitor->locked, "Can't disable contact monitoring during in/out callback. Use call_deferred(\"set_contact_monitor\", false) instead."); for (Map::Element *E = contact_monitor->body_map.front(); E; E = E->next()) { diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp index 386e127f8b..6c3949a0a8 100644 --- a/scene/3d/soft_body.cpp +++ b/scene/3d/soft_body.cpp @@ -577,20 +577,14 @@ Array SoftBody::get_collision_exceptions() { void SoftBody::add_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); CollisionObject *collision_object = Object::cast_to(p_node); - if (!collision_object) { - ERR_EXPLAIN("Collision exception only works between two CollisionObject"); - } - ERR_FAIL_COND(!collision_object); + ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject."); PhysicsServer::get_singleton()->soft_body_add_collision_exception(physics_rid, collision_object->get_rid()); } void SoftBody::remove_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); CollisionObject *collision_object = Object::cast_to(p_node); - if (!collision_object) { - ERR_EXPLAIN("Collision exception only works between two CollisionObject"); - } - ERR_FAIL_COND(!collision_object); + ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject."); PhysicsServer::get_singleton()->soft_body_remove_collision_exception(physics_rid, collision_object->get_rid()); } diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 1a41a31253..df831f92ef 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -684,15 +684,8 @@ void Spatial::look_at(const Vector3 &p_target, const Vector3 &p_up) { void Spatial::look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up) { - if (p_pos == p_target) { - ERR_EXPLAIN("Node origin and target are in the same position, look_at() failed"); - ERR_FAIL(); - } - - if (p_up.cross(p_target - p_pos) == Vector3()) { - ERR_EXPLAIN("Up vector and direction between node origin and target are aligned, look_at() failed"); - ERR_FAIL(); - } + ERR_FAIL_COND_MSG(p_pos == p_target, "Node origin and target are in the same position, look_at() failed."); + ERR_FAIL_COND_MSG(p_up.cross(p_target - p_pos) == Vector3(), "Up vector and direction between node origin and target are aligned, look_at() failed."); Transform lookat; lookat.origin = p_pos; -- cgit v1.2.3 From 82b9557803f33521694587b6014645a05a814ecb Mon Sep 17 00:00:00 2001 From: IAmActuallyCthulhu Date: Sat, 10 Aug 2019 07:28:17 -0500 Subject: Remove redundant author doc comments --- scene/3d/camera.h | 4 +--- scene/3d/cpu_particles.h | 4 ---- scene/3d/light.h | 4 ---- scene/3d/mesh_instance.h | 3 --- scene/3d/multimesh_instance.h | 4 ---- scene/3d/particles.h | 4 ---- scene/3d/portal.h | 3 --- scene/3d/room_instance.h | 4 ---- scene/3d/skeleton.h | 4 ---- scene/3d/spatial.h | 4 ---- scene/3d/visual_instance.h | 4 +--- scene/3d/world_environment.h | 4 ---- 12 files changed, 2 insertions(+), 44 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/camera.h b/scene/3d/camera.h index 6460f17e85..22223880c1 100644 --- a/scene/3d/camera.h +++ b/scene/3d/camera.h @@ -35,9 +35,7 @@ #include "scene/3d/spatial_velocity_tracker.h" #include "scene/main/viewport.h" #include "scene/resources/environment.h" -/** - @author Juan Linietsky -*/ + class Camera : public Spatial { GDCLASS(Camera, Spatial); diff --git a/scene/3d/cpu_particles.h b/scene/3d/cpu_particles.h index 71de56f59e..66b37f359a 100644 --- a/scene/3d/cpu_particles.h +++ b/scene/3d/cpu_particles.h @@ -34,10 +34,6 @@ #include "core/rid.h" #include "scene/3d/visual_instance.h" -/** - @author Juan Linietsky -*/ - class CPUParticles : public GeometryInstance { private: GDCLASS(CPUParticles, GeometryInstance); diff --git a/scene/3d/light.h b/scene/3d/light.h index 5d365758b5..cc8675ead1 100644 --- a/scene/3d/light.h +++ b/scene/3d/light.h @@ -35,10 +35,6 @@ #include "scene/resources/texture.h" #include "servers/visual_server.h" -/** - @author Juan Linietsky -*/ - class Light : public VisualInstance { GDCLASS(Light, VisualInstance); diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h index 022ef15aad..8b690b0c21 100644 --- a/scene/3d/mesh_instance.h +++ b/scene/3d/mesh_instance.h @@ -34,9 +34,6 @@ #include "scene/3d/visual_instance.h" #include "scene/resources/mesh.h" -/** - @author Juan Linietsky -*/ class MeshInstance : public GeometryInstance { GDCLASS(MeshInstance, GeometryInstance); diff --git a/scene/3d/multimesh_instance.h b/scene/3d/multimesh_instance.h index 8f41aa8fd2..ca69c73251 100644 --- a/scene/3d/multimesh_instance.h +++ b/scene/3d/multimesh_instance.h @@ -34,10 +34,6 @@ #include "scene/3d/visual_instance.h" #include "scene/resources/multimesh.h" -/** - @author Juan Linietsky -*/ - class MultiMeshInstance : public GeometryInstance { GDCLASS(MultiMeshInstance, GeometryInstance); diff --git a/scene/3d/particles.h b/scene/3d/particles.h index 42c68010db..391491e8b8 100644 --- a/scene/3d/particles.h +++ b/scene/3d/particles.h @@ -35,10 +35,6 @@ #include "scene/3d/visual_instance.h" #include "scene/resources/material.h" -/** - @author Juan Linietsky -*/ - class Particles : public GeometryInstance { private: GDCLASS(Particles, GeometryInstance); diff --git a/scene/3d/portal.h b/scene/3d/portal.h index f053867917..04af3a750c 100644 --- a/scene/3d/portal.h +++ b/scene/3d/portal.h @@ -32,9 +32,6 @@ #define PORTAL_H #include "scene/3d/visual_instance.h" -/** - @author Juan Linietsky -*/ /* Portal Logic: If a portal is placed next (very close to) a similar, opposing portal, they automatically connect, diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h index 9ee140d522..01efde53c9 100644 --- a/scene/3d/room_instance.h +++ b/scene/3d/room_instance.h @@ -34,10 +34,6 @@ #include "scene/3d/visual_instance.h" #include "scene/resources/room.h" -/** - @author Juan Linietsky -*/ - /* RoomInstance Logic: a) Instances that belong to the room are drawn only if the room is visible (seen through portal, or player inside) b) Instances that don't belong to any room are considered to belong to the root room (RID empty) diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h index 5f43b3c6c3..5b55dffbc8 100644 --- a/scene/3d/skeleton.h +++ b/scene/3d/skeleton.h @@ -34,10 +34,6 @@ #include "core/rid.h" #include "scene/3d/spatial.h" -/** - @author Juan Linietsky -*/ - #ifndef _3D_DISABLED typedef int BoneId; diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index 18a4a5b54d..eea2696767 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -34,10 +34,6 @@ #include "scene/main/node.h" #include "scene/main/scene_tree.h" -/** - @author Juan Linietsky -*/ - class SpatialGizmo : public Reference { GDCLASS(SpatialGizmo, Reference); diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h index 3b924e0454..63d15680aa 100644 --- a/scene/3d/visual_instance.h +++ b/scene/3d/visual_instance.h @@ -35,9 +35,7 @@ #include "core/rid.h" #include "scene/3d/spatial.h" #include "scene/resources/material.h" -/** - @author Juan Linietsky -*/ + class VisualInstance : public Spatial { GDCLASS(VisualInstance, Spatial); diff --git a/scene/3d/world_environment.h b/scene/3d/world_environment.h index bf36a0a532..656e16371f 100644 --- a/scene/3d/world_environment.h +++ b/scene/3d/world_environment.h @@ -33,10 +33,6 @@ #include "scene/3d/spatial.h" -/** - @author Juan Linietsky -*/ - class WorldEnvironment : public Node { GDCLASS(WorldEnvironment, Node); -- cgit v1.2.3 From a350fd4a5755fdaaecef820e181ddda4ce866830 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 21 Aug 2019 15:27:02 +0200 Subject: Draw 3D collision shape/raycast gizmos in grayscale when disabled This makes them easier to distinguish from their enabled counterparts, as is already done in the 2D editor. --- scene/3d/collision_polygon.cpp | 2 ++ scene/3d/ray_cast.cpp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'scene/3d') diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp index db07059b32..37aa95fb43 100644 --- a/scene/3d/collision_polygon.cpp +++ b/scene/3d/collision_polygon.cpp @@ -151,6 +151,8 @@ float CollisionPolygon::get_depth() const { void CollisionPolygon::set_disabled(bool p_disabled) { disabled = p_disabled; + update_gizmo(); + if (parent) { parent->shape_owner_set_disabled(owner_id, p_disabled); } diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index 10f92058e0..30eed8f1a7 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -102,6 +102,8 @@ Vector3 RayCast::get_collision_normal() const { void RayCast::set_enabled(bool p_enabled) { enabled = p_enabled; + update_gizmo(); + if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) set_physics_process_internal(p_enabled); if (!p_enabled) -- cgit v1.2.3 From c12ce2b4ddaf22cb06b69a8d0c685b54485e8c05 Mon Sep 17 00:00:00 2001 From: Milan Davidovic Date: Mon, 19 Aug 2019 11:11:14 +0200 Subject: Prevent move_and_slide() to generate an error. When moving KinematicBody2D from one scene to another and not freeing the old scene, the first call to move_and_slide() in the new scene will generate an error because KinematicBody2D keeps internaly a RID on_floor_body of a body resource in the old scene which no more has a space assigned. To fix this, on_floor_body is set to empty RID in response to NOTIFICATION_ENTER_TREE notification of KinematicBody2D and KinematicBody. Also all other data related to move_and_slide() is reset: floor, ceiling, wall flags, colliders vector, floor_velocity. This fixes #31416. --- scene/3d/physics_body.cpp | 12 ++++++++++++ scene/3d/physics_body.h | 1 + 2 files changed, 13 insertions(+) (limited to 'scene/3d') diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 19d5f1dd3c..3c52547bf1 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -1387,6 +1387,18 @@ Ref KinematicBody::_get_slide_collision(int p_bounce) { return slide_colliders[p_bounce]; } +void KinematicBody::_notification(int p_what) { + if (p_what == NOTIFICATION_ENTER_TREE) { + // Reset move_and_slide() data. + on_floor = false; + on_floor_body = RID(); + on_ceiling = false; + on_wall = false; + colliders.clear(); + floor_velocity = Vector3(); + } +} + void KinematicBody::_bind_methods() { ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false)); diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index aa6030d44e..7db7da6086 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -314,6 +314,7 @@ private: Ref _get_slide_collision(int p_bounce); protected: + void _notification(int p_what); static void _bind_methods(); public: -- cgit v1.2.3 From 4817595c0eecf6c63ff338628f56acd5ddde6f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20H=C3=BCbner?= Date: Tue, 27 Aug 2019 17:13:08 +0200 Subject: fix otherwise unitialized variables, found in #31694 --- scene/3d/physics_body.h | 1 + 1 file changed, 1 insertion(+) (limited to 'scene/3d') diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index aa6030d44e..0e2e614717 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -162,6 +162,7 @@ protected: ShapePair(int p_bs, int p_ls) { body_shape = p_bs; local_shape = p_ls; + tagged = false; } }; struct RigidBody_RemoveAction { -- cgit v1.2.3 From b055ade1c3043ee5e1089c3a3eeb4953c39e55b7 Mon Sep 17 00:00:00 2001 From: Tomasz Chabora Date: Wed, 17 Jul 2019 01:04:36 +0200 Subject: Add a Billboard property for Sprite3D --- scene/3d/sprite_3d.cpp | 21 +++++++++++++++++++-- scene/3d/sprite_3d.h | 3 +++ 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 67c79d8b5a..b79038e96e 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -286,6 +286,18 @@ SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const { return alpha_cut; } +void SpriteBase3D::set_billboard_mode(SpatialMaterial::BillboardMode p_mode) { + + ERR_FAIL_INDEX(p_mode, 3); + billboard_mode = p_mode; + _queue_update(); +} + +SpatialMaterial::BillboardMode SpriteBase3D::get_billboard_mode() const { + + return billboard_mode; +} + void SpriteBase3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_centered", "centered"), &SpriteBase3D::set_centered); @@ -318,6 +330,9 @@ void SpriteBase3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_alpha_cut_mode", "mode"), &SpriteBase3D::set_alpha_cut_mode); ClassDB::bind_method(D_METHOD("get_alpha_cut_mode"), &SpriteBase3D::get_alpha_cut_mode); + ClassDB::bind_method(D_METHOD("set_billboard_mode", "mode"), &SpriteBase3D::set_billboard_mode); + ClassDB::bind_method(D_METHOD("get_billboard_mode"), &SpriteBase3D::get_billboard_mode); + ClassDB::bind_method(D_METHOD("get_item_rect"), &SpriteBase3D::get_item_rect); ClassDB::bind_method(D_METHOD("generate_triangle_mesh"), &SpriteBase3D::generate_triangle_mesh); @@ -333,6 +348,7 @@ void SpriteBase3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "pixel_size", PROPERTY_HINT_RANGE, "0.0001,128,0.0001"), "set_pixel_size", "get_pixel_size"); ADD_PROPERTY(PropertyInfo(Variant::INT, "axis", PROPERTY_HINT_ENUM, "X-Axis,Y-Axis,Z-Axis"), "set_axis", "get_axis"); ADD_GROUP("Flags", ""); + ADD_PROPERTY(PropertyInfo(Variant::INT, "billboard", PROPERTY_HINT_ENUM, "Disabled,Enabled,Y-Billboard"), "set_billboard_mode", "get_billboard_mode"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "transparent"), "set_draw_flag", "get_draw_flag", FLAG_TRANSPARENT); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "shaded"), "set_draw_flag", "get_draw_flag", FLAG_SHADED); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "double_sided"), "set_draw_flag", "get_draw_flag", FLAG_DOUBLE_SIDED); @@ -361,6 +377,7 @@ SpriteBase3D::SpriteBase3D() { flags[i] = i == FLAG_TRANSPARENT || i == FLAG_DOUBLE_SIDED; alpha_cut = ALPHA_CUT_DISABLED; + billboard_mode = SpatialMaterial::BILLBOARD_DISABLED; axis = Vector3::AXIS_Z; pixel_size = 0.01; modulate = Color(1, 1, 1, 1); @@ -463,7 +480,7 @@ void Sprite3D::_draw() { tangent = Plane(1, 0, 0, 1); } - RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS); + RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == SpatialMaterial::BILLBOARD_ENABLED, get_billboard_mode() == SpatialMaterial::BILLBOARD_FIXED_Y); VS::get_singleton()->immediate_set_material(immediate, mat); VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLE_FAN, texture->get_rid()); @@ -771,7 +788,7 @@ void AnimatedSprite3D::_draw() { tangent = Plane(1, 0, 0, -1); } - RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS); + RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == SpatialMaterial::BILLBOARD_ENABLED, get_billboard_mode() == SpatialMaterial::BILLBOARD_FIXED_Y); VS::get_singleton()->immediate_set_material(immediate, mat); diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 0e086ef31e..89ddda0635 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -80,6 +80,7 @@ private: bool flags[FLAG_MAX]; AlphaCutMode alpha_cut; + SpatialMaterial::BillboardMode billboard_mode; bool pending_update; void _im_update(); @@ -130,6 +131,8 @@ public: void set_alpha_cut_mode(AlphaCutMode p_mode); AlphaCutMode get_alpha_cut_mode() const; + void set_billboard_mode(SpatialMaterial::BillboardMode p_mode); + SpatialMaterial::BillboardMode get_billboard_mode() const; virtual Rect2 get_item_rect() const = 0; -- cgit v1.2.3 From c902066bb5276d664dbd3c61cb5a3adf28ee6491 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Silva Dias Date: Fri, 30 Aug 2019 14:20:25 -0300 Subject: Remove some unneeded checks in CollisionObject(2D) --- scene/3d/collision_object.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scene/3d') diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index 63301fc226..735b393171 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -105,7 +105,8 @@ void CollisionObject::_mouse_exit() { void CollisionObject::_update_pickable() { if (!is_inside_tree()) return; - bool pickable = ray_pickable && is_inside_tree() && is_visible_in_tree(); + + bool pickable = ray_pickable && is_visible_in_tree(); if (area) PhysicsServer::get_singleton()->area_set_ray_pickable(rid, pickable); else -- cgit v1.2.3