mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 19:42:43 +00:00
Merge pull request #63650 from fabriceci/apply-moving-platform-angular-velocity
Allow to apply the angular velocity of a moving platform
This commit is contained in:
commit
151e1355e8
@ -41,10 +41,16 @@
|
||||
Returns a [KinematicCollision3D], which contains information about the latest collision that occurred during the last call to [method move_and_slide].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_platform_angular_velocity" qualifiers="const">
|
||||
<return type="Vector3" />
|
||||
<description>
|
||||
Returns the angular velocity of the platform at the last collision point. Only valid after calling [method move_and_slide].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_platform_velocity" qualifiers="const">
|
||||
<return type="Vector3" />
|
||||
<description>
|
||||
Returns the linear velocity of the floor at the last collision point. Only valid after calling [method move_and_slide] and when [method is_on_floor] returns [code]true[/code].
|
||||
Returns the linear velocity of the platform at the last collision point. Only valid after calling [method move_and_slide].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_position_delta" qualifiers="const">
|
||||
|
@ -1246,6 +1246,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
|
||||
platform_rid = RID();
|
||||
platform_object_id = ObjectID();
|
||||
platform_velocity = Vector3();
|
||||
platform_angular_velocity = Vector3();
|
||||
platform_ceiling_velocity = Vector3();
|
||||
floor_normal = Vector3();
|
||||
wall_normal = Vector3();
|
||||
@ -1506,6 +1507,7 @@ void CharacterBody3D::_move_and_slide_floating(double p_delta) {
|
||||
platform_object_id = ObjectID();
|
||||
floor_normal = Vector3();
|
||||
platform_velocity = Vector3();
|
||||
platform_angular_velocity = Vector3();
|
||||
|
||||
bool first_slide = true;
|
||||
for (int iteration = 0; iteration < max_slides; ++iteration) {
|
||||
@ -1708,6 +1710,7 @@ void CharacterBody3D::_set_platform_data(const PhysicsServer3D::MotionCollision
|
||||
platform_rid = p_collision.collider;
|
||||
platform_object_id = p_collision.collider_id;
|
||||
platform_velocity = p_collision.collider_velocity;
|
||||
platform_angular_velocity = p_collision.collider_angular_velocity;
|
||||
platform_layer = PhysicsServer3D::get_singleton()->body_get_collision_layer(platform_rid);
|
||||
}
|
||||
|
||||
@ -1780,6 +1783,10 @@ const Vector3 &CharacterBody3D::get_platform_velocity() const {
|
||||
return platform_velocity;
|
||||
}
|
||||
|
||||
const Vector3 &CharacterBody3D::get_platform_angular_velocity() const {
|
||||
return platform_angular_velocity;
|
||||
}
|
||||
|
||||
Vector3 CharacterBody3D::get_linear_velocity() const {
|
||||
return get_real_velocity();
|
||||
}
|
||||
@ -1932,6 +1939,7 @@ void CharacterBody3D::_notification(int p_what) {
|
||||
platform_object_id = ObjectID();
|
||||
motion_results.clear();
|
||||
platform_velocity = Vector3();
|
||||
platform_angular_velocity = Vector3();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@ -1986,6 +1994,7 @@ void CharacterBody3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_real_velocity"), &CharacterBody3D::get_real_velocity);
|
||||
ClassDB::bind_method(D_METHOD("get_floor_angle", "up_direction"), &CharacterBody3D::get_floor_angle, DEFVAL(Vector3(0.0, 1.0, 0.0)));
|
||||
ClassDB::bind_method(D_METHOD("get_platform_velocity"), &CharacterBody3D::get_platform_velocity);
|
||||
ClassDB::bind_method(D_METHOD("get_platform_angular_velocity"), &CharacterBody3D::get_platform_angular_velocity);
|
||||
ClassDB::bind_method(D_METHOD("get_slide_collision_count"), &CharacterBody3D::get_slide_collision_count);
|
||||
ClassDB::bind_method(D_METHOD("get_slide_collision", "slide_idx"), &CharacterBody3D::_get_slide_collision);
|
||||
ClassDB::bind_method(D_METHOD("get_last_slide_collision"), &CharacterBody3D::_get_last_slide_collision);
|
||||
|
@ -371,6 +371,7 @@ public:
|
||||
const Vector3 &get_real_velocity() const;
|
||||
real_t get_floor_angle(const Vector3 &p_up_direction = Vector3(0.0, 1.0, 0.0)) const;
|
||||
const Vector3 &get_platform_velocity() const;
|
||||
const Vector3 &get_platform_angular_velocity() const;
|
||||
|
||||
virtual Vector3 get_linear_velocity() const override;
|
||||
|
||||
@ -423,6 +424,7 @@ private:
|
||||
Vector3 ceiling_normal;
|
||||
Vector3 last_motion;
|
||||
Vector3 platform_velocity;
|
||||
Vector3 platform_angular_velocity;
|
||||
Vector3 platform_ceiling_velocity;
|
||||
Vector3 previous_position;
|
||||
Vector3 real_velocity;
|
||||
|
@ -992,6 +992,7 @@ bool GodotSpace3D::test_body_motion(GodotBody3D *p_body, const PhysicsServer3D::
|
||||
|
||||
Vector3 rel_vec = result.contact - (body->get_transform().origin + body->get_center_of_mass());
|
||||
collision.collider_velocity = body->get_linear_velocity() + (body->get_angular_velocity()).cross(rel_vec);
|
||||
collision.collider_angular_velocity = body->get_angular_velocity();
|
||||
}
|
||||
|
||||
r_result->travel = safe * p_parameters.motion;
|
||||
|
@ -541,6 +541,7 @@ public:
|
||||
Vector3 position;
|
||||
Vector3 normal;
|
||||
Vector3 collider_velocity;
|
||||
Vector3 collider_angular_velocity;
|
||||
real_t depth = 0.0;
|
||||
int local_shape = 0;
|
||||
ObjectID collider_id;
|
||||
|
Loading…
Reference in New Issue
Block a user