Call Spatial::get_global_transform and Vector3::dot only once within Camera::is_position_behind to avoid redundant work.
(cherry picked from commit b2a204799a
)
This commit is contained in:
parent
636b1e4518
commit
f06fc1fdf4
|
@ -333,8 +333,8 @@ Vector3 Camera::project_ray_origin(const Point2 &p_pos) const {
|
||||||
bool Camera::is_position_behind(const Vector3 &p_pos) const {
|
bool Camera::is_position_behind(const Vector3 &p_pos) const {
|
||||||
|
|
||||||
Transform t = get_global_transform();
|
Transform t = get_global_transform();
|
||||||
Vector3 eyedir = -get_global_transform().basis.get_axis(2).normalized();
|
Vector3 eyedir = -t.basis.get_axis(2).normalized();
|
||||||
return eyedir.dot(p_pos) < (eyedir.dot(t.origin) + near);
|
return eyedir.dot(p_pos - t.origin) < near;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<Vector3> Camera::get_near_plane_points() const {
|
Vector<Vector3> Camera::get_near_plane_points() const {
|
||||||
|
|
Loading…
Reference in New Issue