text
stringlengths
0
234
Display_face_optimized.Display_face (f = o.face'First, o.face (f), o.face_invariant (f));
end loop;
when Is_List => GL.CallList (GL.uint (o.List_Id));
end case;
-- Close list
case o.List_Status is
when No_list | Is_List => null;
when Generate_List =>
GL.EndList;
if GL.GetError = OUT_OF_MEMORY then
o.List_Status := No_List;
else
o.List_Status := Is_List;
end if;
end case;
if show_normals then
GL.Disable (GL.LIGHTING);
GL.Disable (GL.TEXTURE_2D);
Display_normals;
GL.Enable (GL.LIGHTING); -- mmmh .. .
end if;
GL.PopMatrix; -- 26 - May - 2006 : instead of rotating/translating back
-- GL.Rotate (o.auto_rotation (2), 0.0, 0.0, - 1.0);
-- GL.Rotate (o.auto_rotation (1), 0.0, - 1.0, 0.0);
-- GL.Rotate (o.auto_rotation (0), - 1.0, 0.0, 0.0);
-- GL.Translate ( - o.centre);
end Display_one;
procedure Display (
o : in out Object_3D;
clip : in Clipping_data
)
is
use GLOBE_3D.Portals;
procedure Display_clipped (
o : in out Object_3D'Class;
clip_area : in Clipping_area;
portal_depth : in Natural
)
is
procedure Try_portal (f : Positive) is
use G3DM, GL;
dp : Real;
plane_to_eye : Vector_3D; -- vector from any point in plane to the eye
bounding_of_face, intersection_clip_and_face : Clipping_area;
success, non_empty_intersection : Boolean;
begin
-- Culling #1 : check if portal is in vield of view's "dead angle"
dp := o.face_invariant (f).normal * clip.view_direction;
if dp < clip.max_dot_product then
-- Culling #2 : check if we are on the right side of the portal
-- NB : ignores o.auto_rotation !
plane_to_eye :=
clip.eye_position -
(o.point (o.face_invariant (f).P_compact (1)) + o.centre)
;
dp := plane_to_eye * o.face_invariant (f).normal;
-- dp = signed distance to the plane
if dp > 0.0 then
-- Culling #3 : clipping rectangle
Find_bounding_box (o, f, bounding_of_face, success);
if success then
Intersect (clip_area, bounding_of_face,
intersection_clip_and_face, non_empty_intersection);
else
-- in doubt, draw with the present clipping
intersection_clip_and_face := clip_area;
non_empty_intersection := True;
end if;
if non_empty_intersection then
-- Recursion here:
Display_clipped (
o => o.face (f).connecting.all,
clip_area => intersection_clip_and_face,
portal_depth => portal_depth + 1
);
end if;
end if;
end if;
end Try_portal;
begin -- Display_clipped
if not o.pre_calculated then
Pre_calculate (o);
end if;
--
-- a/ Display connected objects which are visible through o's faces
-- This is where recursion happens
if (not filter_portal_depth) or else -- filter_portal_depth : test/debug
portal_depth <= 6
then
for f in o.face'Range loop
if o.face (f).connecting /= null and then
not o.face_invariant (f).portal_seen
-- ^ prevents infinite recursion on rare cases where
-- object A or B is not convex, and A and B see each other
-- and the culling by clipping cannot stop the recursion
-- (e.g. origin2.proc, tomb.proc)
--
-- NB : drawing [different parts of] the same object several times
-- is right, since portions can be seen through different portals,
-- but going more than once through the same portal is wrong