mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Merge commit godotengine/godot@0c51ede243
This commit is contained in:
@@ -32,6 +32,10 @@
|
||||
|
||||
#include "character_body_2d.h"
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
#include "servers/extensions/physics_server_2d_extension.h"
|
||||
#endif
|
||||
|
||||
// So, if you pass 45 as limit, avoid numerical precision errors when angle is 45.
|
||||
#define FLOOR_ANGLE_THRESHOLD 0.01
|
||||
|
||||
@@ -418,10 +422,25 @@ void CharacterBody2D::_set_collision_direction(const PhysicsServer2D::MotionResu
|
||||
}
|
||||
|
||||
void CharacterBody2D::_set_platform_data(const PhysicsServer2D::MotionResult &p_result) {
|
||||
PhysicsDirectBodyState2D *bs = PhysicsServer2D::get_singleton()->body_get_direct_state(p_result.collider);
|
||||
if (bs == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
platform_rid = p_result.collider;
|
||||
platform_object_id = p_result.collider_id;
|
||||
platform_velocity = p_result.collider_velocity;
|
||||
platform_layer = PhysicsServer2D::get_singleton()->body_get_collision_layer(platform_rid);
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
// Try to accommodate for any physics extensions that have yet to implement `PhysicsDirectBodyState2D::get_collision_layer`.
|
||||
PhysicsDirectBodyState2DExtension *bs_ext = Object::cast_to<PhysicsDirectBodyState2DExtension>(bs);
|
||||
if (bs_ext != nullptr && !GDVIRTUAL_IS_OVERRIDDEN_PTR(bs_ext, _get_collision_layer)) {
|
||||
platform_layer = PhysicsServer2D::get_singleton()->body_get_collision_layer(p_result.collider);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
platform_layer = bs->get_collision_layer();
|
||||
}
|
||||
}
|
||||
|
||||
const Vector2 &CharacterBody2D::get_velocity() const {
|
||||
|
||||
Reference in New Issue
Block a user