summaryrefslogtreecommitdiff
path: root/scene/3d/camera.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-04-28 22:05:01 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-04-28 22:05:01 -0300
commit98c086edafbbb81635fed46b17268af2df9ae47d (patch)
tree9d7b40208796c7c0f4e4572ca57a61adf318f431 /scene/3d/camera.cpp
parentc6dce44dd85c4ebae791756a76f6afbfbb0a5c28 (diff)
-fix forced texture repeat in Polygon2D, now depends on texture.
-added a new function, Camera::is_position_behind to aid to unproject(), fixes #1725
Diffstat (limited to 'scene/3d/camera.cpp')
-rw-r--r--scene/3d/camera.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index d8512172c8..dce5060a44 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -552,6 +552,13 @@ Vector3 Camera::project_ray_origin(const Point2& p_pos) const {
};
};
+bool Camera::is_position_behind(const Vector3& p_pos) const {
+
+ Transform t = get_global_transform();
+ Vector3 eyedir = -get_global_transform().basis.get_axis(2).normalized();
+ return eyedir.dot(p_pos) < (eyedir.dot(t.origin)+near);
+}
+
Point2 Camera::unproject_position(const Vector3& p_pos) const {
if (!is_inside_tree()) {
@@ -666,6 +673,7 @@ void Camera::_bind_methods() {
ObjectTypeDB::bind_method( _MD("project_local_ray_normal","screen_point"), &Camera::project_local_ray_normal);
ObjectTypeDB::bind_method( _MD("project_ray_origin","screen_point"), &Camera::project_ray_origin);
ObjectTypeDB::bind_method( _MD("unproject_position","world_point"), &Camera::unproject_position);
+ ObjectTypeDB::bind_method( _MD("is_position_behind","world_point"), &Camera::is_position_behind);
ObjectTypeDB::bind_method( _MD("project_position","screen_point"), &Camera::project_position);
ObjectTypeDB::bind_method( _MD("set_perspective","fov","z_near","z_far"),&Camera::set_perspective );
ObjectTypeDB::bind_method( _MD("set_orthogonal","size","z_near","z_far"),&Camera::set_orthogonal );