1. pragma Warnings (Off); 
  2. pragma Style_Checks (Off); 
  3.  
  4. with Ada.Unchecked_Deallocation; 
  5.  
  6. with GLOBE_3D.Math; 
  7.  
  8. package body GLOBE_3D.BSP is 
  9.  
  10.   use Ada.Strings.Unbounded; 
  11.  
  12.   procedure Locate (P : Point_3D; tree : p_BSP_node; area : out p_Object_3D) is 
  13.  
  14.     procedure Locate_point (tree_point : p_BSP_node) is 
  15.       -- ^ internal, for skipping useless parameter passing 
  16.       use Math, GL; 
  17.     begin 
  18.       info_b_str1 := info_b_str1 & " - > " & Integer'Image (tree_point.node_id); 
  19.       info_b_ntl1 := info_b_ntl1 + 1; 
  20.       if P * tree_point.normal + tree_point.distance > 0.0 then -- in front 
  21.         if tree_point.front_child = null then 
  22.           area := tree_point.front_leaf; 
  23.         else 
  24.           Locate_point (tree_point.front_child); 
  25.         end if; 
  26.       else -- in back 
  27.         if tree_point.back_child = null then 
  28.           area := tree_point.back_leaf; 
  29.         else 
  30.           Locate_point (tree_point.back_child); 
  31.         end if; 
  32.       end if; 
  33.     end Locate_point; 
  34.  
  35.   begin 
  36.     info_b_str1 := Null_Unbounded_String; 
  37.     info_b_ntl1 := 0; -- depth counter 
  38.     area := null; 
  39.     if tree /= null then 
  40.       Locate_point (tree); 
  41.     end if; 
  42.     info_b_bool1 := area /= null; 
  43.   end Locate; 
  44.  
  45.   procedure Delete (tree : in out p_BSP_node) is 
  46.     procedure Dispose is new Ada.Unchecked_Deallocation (BSP_node, p_BSP_node); 
  47.   begin 
  48.     if tree/=null then 
  49.       Delete (tree.front_child); 
  50.       Delete (tree.back_child); 
  51.       Dispose (tree); 
  52.       tree := null; 
  53.     end if; 
  54.   end Delete; 
  55.  
  56. end GLOBE_3D.BSP;