Expose body_test_motion in 3D physics server

Results are exposed through PhysicsTestMotionResult, the same way it's
done for 2D.

Also cleaned a few things in the 2D version.
This commit is contained in:
PouleyKetchoupp
2021-07-02 18:04:39 -07:00
parent cbf6d51d01
commit c89476ad41
9 changed files with 169 additions and 32 deletions

View File

@ -438,6 +438,7 @@ void Physics2DShapeQueryResult::_bind_methods() {
Vector2 Physics2DTestMotionResult::get_motion() const {
return result.motion;
}
Vector2 Physics2DTestMotionResult::get_motion_remainder() const {
return result.remainder;
}
@ -445,15 +446,19 @@ Vector2 Physics2DTestMotionResult::get_motion_remainder() const {
Vector2 Physics2DTestMotionResult::get_collision_point() const {
return result.collision_point;
}
Vector2 Physics2DTestMotionResult::get_collision_normal() const {
return result.collision_normal;
}
Vector2 Physics2DTestMotionResult::get_collider_velocity() const {
return result.collider_velocity;
}
ObjectID Physics2DTestMotionResult::get_collider_id() const {
return result.collider_id;
}
RID Physics2DTestMotionResult::get_collider_rid() const {
return result.collider;
}
@ -488,12 +493,6 @@ void Physics2DTestMotionResult::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape"), "", "get_collider_shape");
}
Physics2DTestMotionResult::Physics2DTestMotionResult() {
colliding = false;
result.collider_id = 0;
result.collider_shape = 0;
}
///////////////////////////////////////
bool Physics2DServer::_body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<Physics2DTestMotionResult> &p_result) {