home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / VOXRAY.ZIP / BSPTREE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-10  |  1.1 KB  |  54 lines

  1. #include "ray.h"
  2. #include "globals.h"
  3.  
  4. typedef long bsp_stack_node;
  5.  
  6. #define BSP_STACK_LENGTH 64
  7. #define NODE_MASK 0x8000
  8.  
  9.  
  10. // There will be a stack used in the BSP drawing routine to simulate recursion,
  11. // because as we all know, real recursion is too slow to use in games
  12.  
  13. short bsp_stack_size;
  14. bsp_stack_node bsp_stack[BSP_STACK_LENGTH];
  15.  
  16. // Two routines to automate push and poping on BSP stack
  17.  
  18. inline BOOL PushBSPStack(bsp_stack_node push_value) {
  19.  
  20.    if (bsp_stack_size>=bsp_stack_length) {
  21.       return TRUE;
  22.    } else {
  23.       bsp_stack[bsp_stack_size]=push_value;
  24.       bsp_stack_size++;
  25.       return FALSE;
  26.    }
  27.  
  28. }
  29.  
  30. invoid BOOL PopBSPStack(bsp_stack_nod & pop_value) {
  31.  
  32.    if (bsp_stack_size<=0) {
  33.       return TRUE;
  34.    } else {
  35.       bsp_stack_size--;
  36.       pop_value=bsp_stack[bsp_stack_size];
  37.    } /* endif */
  38.  
  39. }
  40.  
  41.  
  42. // This routine examines the fifth bit of the child node to determine whether they
  43. // are another recursive division, or a drawable subsector
  44.  
  45. inline BOOL GetChildType(USHORT child_num) {
  46.    return (BOOL)(child_num & NODE_MASK);
  47. }
  48.  
  49. void BSP_Recursion_Draw()
  50. {
  51.  
  52. long current_bsp_section;
  53.  
  54.