fix: camera has some collision buffer behind it
This commit is contained in:
parent
a1cbc6d853
commit
b648d48b64
1 changed files with 4 additions and 2 deletions
|
|
@ -46,13 +46,15 @@ void PlayerCamera::update_rotation() {
|
|||
void PlayerCamera::update_position() {
|
||||
Vector3 origin{ get_origin() };
|
||||
Vector3 direction{ get_global_basis().get_column(2) };
|
||||
float distance{ this->target_distance };
|
||||
float distance{ this->target_distance + 1.0f };
|
||||
Vector3 target{ origin + direction * distance };
|
||||
this->ray.from = origin;
|
||||
this->ray.to = target;
|
||||
PhysicsDirectSpaceState3D::RayResult result{};
|
||||
if (get_world_3d()->get_direct_space_state()->intersect_ray(this->ray, result)) {
|
||||
distance = origin.distance_to(result.position) - (1.0 - Math::abs(direction.dot(result.normal)));
|
||||
distance = origin.distance_to(result.position) - (2.0 - Math::abs(direction.dot(result.normal)));
|
||||
} else {
|
||||
distance -= 1;
|
||||
}
|
||||
look_at_from_position(origin + direction * MAX(distance, 0.4f), origin);
|
||||
this->previous_origin = origin;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue