summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2015-02-05 15:06:10 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-02-05 15:37:15 +0100
commit36515241b9a45436dc2202728904fe00925cd0ae (patch)
treea60e376e838dfd7276f9257d29dfedf2b315961a
parentd503dbeed1b2e26272893f86c37df3eaeb270e30 (diff)
downloadefl-36515241b9a45436dc2202728904fe00925cd0ae.tar.gz
evas: Evas_3D - fix when bounding sphere is large, situation with incorrect frustum calculation was possible.
Summary: When center of bounding sphere was out of frustum and number of intersections between bs and planes of frustum was more then 3, objects disappeared. @fix Reviewers: Hermet, raster, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1938 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/evas/include/evas_3d_utils.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/lib/evas/include/evas_3d_utils.h b/src/lib/evas/include/evas_3d_utils.h
index b6d52e9b17..0cf9f34928 100644
--- a/src/lib/evas/include/evas_3d_utils.h
+++ b/src/lib/evas/include/evas_3d_utils.h
@@ -1881,9 +1881,7 @@ evas_is_sphere_in_frustum(Evas_Sphere *bsphere, Evas_Vec4 *planes)
int intersected_planes_count = 0;
for (i = 0; i < 6; i++)
- {
- distances[i] = evas_point_plane_distance(&bsphere->center, &planes[i]);
- }
+ distances[i] = evas_point_plane_distance(&bsphere->center, &planes[i]);
for (i = 0; i < 6; i++)
{
@@ -1898,21 +1896,24 @@ evas_is_sphere_in_frustum(Evas_Sphere *bsphere, Evas_Vec4 *planes)
}
}
- if ((intersected_planes_count == 0) || (intersected_planes_count == 1))
- return EINA_TRUE;
- else if (intersected_planes_count == 2)
- {
- evas_intersection_line_of_two_planes(&line, &planes[intersected_planes[0]], &planes[intersected_planes[1]]);
- return (evas_point_line_distance(&bsphere->center, &line) < bsphere->radius) ? EINA_TRUE : EINA_FALSE;
- }
- else if (intersected_planes_count == 3)
+ switch (intersected_planes_count)
{
- evas_intersection_point_of_three_planes(&point, &planes[intersected_planes[0]], &planes[intersected_planes[1]], &planes[intersected_planes[2]]);
+ case 2:
+ evas_intersection_line_of_two_planes(&line,
+ &planes[intersected_planes[0]],
+ &planes[intersected_planes[1]]);
+ return (evas_point_line_distance(&bsphere->center, &line) <
+ bsphere->radius) ? EINA_TRUE : EINA_FALSE;
+ case 3:
+ evas_intersection_point_of_three_planes(&point,
+ &planes[intersected_planes[0]],
+ &planes[intersected_planes[1]],
+ &planes[intersected_planes[2]]);
evas_vec3_subtract(&sub, &point, &bsphere->center);
return (evas_vec3_length_get(&sub) < bsphere->radius) ? EINA_TRUE : EINA_FALSE;
+ default:
+ return EINA_TRUE;
}
-
- return EINA_FALSE;
}
static inline Eina_Bool