00001
00002
00010
00011
00012
#ifndef GAME_BSP_H
00013
#define GAME_BSP_H
00014
00015
00016
class cGame_World;
00017
class cSquare_Area;
00018
00019
00020
#include <vector>
00021
00022
#include "HV_bsp.h"
00023
#include "game_graph.h"
00024
#include "level.h"
00025
00026
00028
00035 class cSquare_Area :
public cHV_Node
00036 {
00037
friend class cSquare_Area_Debug_Displayer;
00038
public:
00041 cSquare_Area(
cPositive_Rectangle& area):
cHV_Node()
00042 {
00043
Bounds = area;
00044 };
00045
00047
~cSquare_Area();
00048
00050
void Print();
00051
00052
00054
00059
void split(
cHV_Wall & wall,
cSquare_Area ** A1,
cSquare_Area ** A2);
00060
00062
00063
void Add_Wall(
cHV_Seg & w);
00064
00066
00067
void Add_Portal(
cPortal * portal);
00068
00070
00073
void Add_Paralells_Portals(
cPortal * portal1 ,
cPortal * portal2);
00074
00076
00077 void Get_Centre(
cPoint2D & p)
00078 {
00079
Bounds.
Get_Centre(p);
00080 assert(
Bounds.
In(p) );
00081 };
00082
00084
00088
void Manage_Paralell_Portals();
00089
00090 cPositive_Rectangle Bounds;
00091 std::vector<cHV_Seg*>
List_Walls;
00092 std::vector<cPortal*>
List_Portals;
00093 };
00094
00095
00096
00097
00098
00100
00101 class cGame_World
00102 {
00103
friend class cGame_World_Debug_Displayer;
00104
public:
00106
cGame_World();
00108
~cGame_World();
00110
void Print_Leaves();
00111
00113
00114
bool Find_Path(
cPoint2D& pA ,
cPoint2D& pB , std::vector<cPoint2D> & Path);
00115
00117
00118
00119
00121
bool Do_Ball_Intersect_Walls(
int x,
int y,
int r);
00122
00124
00126
bool Do_Segment_Intersect_Walls(
cSeg& seg ,
cPoint2D& p_inter ,
int square_test_range);
00127
00129
bool Do_Segment_Intersect_Walls(
cSeg& seg ,
cPoint2D& p_inter );
00130
00132
void Decorate();
00133
00134 cHV_BSP_Tree My_BSP;
00135 static cPositive_Rectangle Ecran;
00136
00137
private :
00138 std::vector<cSquare_Area*>
List_Areas;
00139 std::vector<cPortal*>
List_Portals;
00140 int N_Leaves;
00141 int N_Portals;
00142 bool bDecorated_With_Areas;
00143 cA_Star_Search Path_Finder;
00144
00146
00147
void Decorate_With_Areas();
00148
00150
00152
void Decorate_With_Areas(
cHV_Node * node ,
cSquare_Area * area );
00153
00155
00158
void Decorate_With_Walls_And_Portals();
00159
00161
00164
cPortal *
Declare_Portal(
cSquare_Area *area ,
cHV_Seg& seg);
00165
00167
00170
void Add_Wall_And_Portals(
cSquare_Area * area ,
cHV_Seg& seg);
00171
00173
00177
void Creates_And_Add_Portals(
cSquare_Area * area ,
cHV_Seg& seg ,
cHV_Seg& wall);
00178
00180
00185
void Split_Portal(
cPortal * p ,
cHV_Seg& seg);
00186
00188
00192
void Manage_Paralell_Portals(
void);
00193 };
00194
00195
00196
00197
#endif