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>
This commit is contained in:
Bogdan Devichev 2015-02-05 15:06:10 +01:00 committed by Cedric BAIL
parent d503dbeed1
commit 36515241b9
1 changed files with 15 additions and 14 deletions

View File

@ -1881,9 +1881,7 @@ evas_is_sphere_in_frustum(Evas_Sphere *bsphere, Evas_Vec4 *planes)
int intersected_planes_count = 0; int intersected_planes_count = 0;
for (i = 0; i < 6; i++) 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++) 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)) switch (intersected_planes_count)
return EINA_TRUE;
else if (intersected_planes_count == 2)
{ {
evas_intersection_line_of_two_planes(&line, &planes[intersected_planes[0]], &planes[intersected_planes[1]]); case 2:
return (evas_point_line_distance(&bsphere->center, &line) < bsphere->radius) ? EINA_TRUE : EINA_FALSE; evas_intersection_line_of_two_planes(&line,
} &planes[intersected_planes[0]],
else if (intersected_planes_count == 3) &planes[intersected_planes[1]]);
{ return (evas_point_line_distance(&bsphere->center, &line) <
evas_intersection_point_of_three_planes(&point, &planes[intersected_planes[0]], &planes[intersected_planes[1]], &planes[intersected_planes[2]]); 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); evas_vec3_subtract(&sub, &point, &bsphere->center);
return (evas_vec3_length_get(&sub) < bsphere->radius) ? EINA_TRUE : EINA_FALSE; return (evas_vec3_length_get(&sub) < bsphere->radius) ? EINA_TRUE : EINA_FALSE;
default:
return EINA_TRUE;
} }
return EINA_FALSE;
} }
static inline Eina_Bool static inline Eina_Bool