2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 // $Header: r:/t2repos/thief2/libsrc/portold/wrfunc.h,v 1.9 1998/02/11 11:38:53 MAT Exp $
8 // World Representation Functions
13 #include <lg.h> // bool
22 // the way cell references work is like this:
23 // the first time you reference a cell in a given
24 // frame, use WR_CELL(n) to get a pointer to it
25 // after that, you can use wr_cell[n] to refer to
26 // it, until the end of the frame.
28 // Every time you call ResetWorldRep(), you can no
29 // longer count on data which you have dangled off
30 // of the world rep, and you need to call WR_CELL
33 // In reality, for this round, we're not going to
34 // swap the db to disk.
36 extern PortalCell
*wr_cell
[];
37 extern int wr_num_cells
;
38 extern wrBspNode
*wrBspTree
;
39 void ResetWorldRep(void);
42 #define WR_CELL(n) (wr_cell[n])
44 #define WR_CELL(n) (wr_cell[n] ? wr_cell[n] : LoadWorldRepCell(n))
45 PortalCell
*LoadWorldRepCell(int n
);
48 // A macro which if true means that we definitely have a valid
49 // cell, and we can quickly compute it
50 #define IS_CELLFROMLOC_FAST(loc) ((loc)->cell != CELL_INVALID)
52 #define CellFromLoc(loc) (IS_CELLFROMLOC_FAST(loc) ? (loc)->cell : ComputeCellForLocation(loc))
53 #define CellFromPos(p) CellFromLoc(&((p)->loc))
55 // Macros for the worldrep bsp tree
56 #define wrIS_LEAF(b) (b->leaf)
57 #define wrIS_NODE(b) (!b->leaf)
58 #define wrIS_ROOT(b) (b->parent == NULL)
59 #define wrIS_MARKED(b) (b->mark)
60 #define wrMARK(b) (b->mark = TRUE)
61 #define wrUNMARK(b) (b->mark = FALSE)
63 int ComputeCellForLocation(Location
*loc
);
64 int PortalComputeCellFromPoint(mxs_vector
*seed_pos
);
65 bool PortalTestInCell(int r
, Location
*loc
);
67 void PortalComputeBoundingSphere(PortalCell
*cell
);
69 // for opening and closing doors
70 int PortalBlockVision(PortalCell
*starting_cell
);
71 int PortalBlockVisionFromLocation(Location
*seed_loc
);
72 int PortalUnblockVision(PortalCell
*starting_cell
);
73 int PortalUnblockVisionFromLocation(Location
*seed_loc
);