1
/****************************************************************************
3
** Copyright (C) 2005-2005 Trolltech AS. All rights reserved.
4
** Copyright (C) 2002-2005 Bjļæ½rn Bergstrļæ½m
6
** This file is part of the designer application of the Qt Toolkit.
8
** This file may be distributed under the terms of the Q Public License
9
** as defined by Trolltech AS of Norway and appearing in the file
10
** LICENSE.QPL included in the packaging of this file.
12
** This file may be distributed and/or modified under the terms of the
13
** GNU General Public License version 2 as published by the Free Software
14
** Foundation and appearing in the file LICENSE.GPL included in the
15
** packaging of this file.
17
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
18
** information about Qt Commercial License Agreements.
19
** See http://www.trolltech.com/qpl/ for QPL licensing information.
20
** See http://www.trolltech.com/gpl/ for GPL licensing information.
22
** Contact info@trolltech.com if any conditions of this licensing are
25
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
28
****************************************************************************/
32
* implementation of recursive shadowcasting
34
* 020125: Bjļæ½rn Bergstrļæ½m - changed from float to double to remove compiler
36
* 020125: Bjļæ½rn Bergstrļæ½m - included a check to avoid orthogonal edges to be
37
* scanned more than once
38
* 020125: Greg McIntyre - declared the nwL, neL etc in FOV::start outside the
44
#include "oublietteplan.h"
47
double FOV::slope(double x1, double y1, double x2, double y2)
62
double FOV::invSlope(double x1, double y1, double x2, double y2)
64
double slope=this->slope(x1,y1,x2,y2);
78
scans the octant covering the area from north west to north from left to
80
the method ignores the octants starting and ending cells since they have
81
been applied in FOV::start
83
void FOV::scanNW2N(OublietteLevel *map, int xCenter, int yCenter, int distance, int maxRadius, double startSlope, double endSlope)
85
if(distance > maxRadius)
90
// calculate start and end cell of the scan
91
int xStart=(int)((double)xCenter + 0.5 - (startSlope * distance));
92
int xEnd=(int)((double)xCenter + 0.5 - (endSlope * distance));
93
int yCheck=yCenter - distance;
95
// is the starting cell the leftmost cell in the octant?
96
// NO: call applyCell() to starting cell
97
// YES: it has already been applied in FOV::start()
98
if(xStart != xCenter-(1*distance))
100
this->applyCell(map,xStart,yCheck);
103
// find out if starting cell blocks LOS
104
bool prevBlocked=this->scanCell(map,xStart,yCheck);
106
// scan from the cell after the starting cell (xStart+1) to end cell of
107
// scan (xCheck<=xEnd)
108
for(int xCheck=xStart+1; xCheck<=xEnd; xCheck++)
110
// is the current cell the rightmost cell in the octant?
111
// NO: call applyCell() to current cell
112
// YES: it has already been applied in FOV::start()
113
if(xCheck != xCenter)
116
this->applyCell(map,xCheck,yCheck);
120
// if previous cell didn't block LOS (prevBlocked==false) we have
121
// hit a 'new' section of walls. a new scan will be started with an
122
// endSlope that 'brushes' by to the left of the blocking cell
124
// +---+a####+---+ @ = [xCenter+0.5,yCenter+0.5]
125
// | |#####| | a = old [xCheck,yCheck]
126
// | |#####| | b = new [xCheck-0.00001,yCheck+0.99999]
135
if(this->scanCell(map,xCheck,yCheck))
139
this->scanNW2N(map,xCenter,yCenter,distance+1,maxRadius,startSlope,this->slope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck-0.000001,(double)yCheck+0.999999));
144
// cell doesn't block LOS
145
// if the cell is the first non-blocking cell after a section of walls
146
// we need to calculate a new startSlope that 'brushes' by to the right
147
// of the blocking cells
149
// #####a---++---+ @ = [xCenter+0.5,yCenter+0.5]
150
// #####| || | a = new and old [xCheck,yCheck]
164
startSlope=this->slope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck,(double)yCheck);
170
// if the last cell of the scan didn't block LOS a new scan should be
174
this->scanNW2N(map,xCenter,yCenter,distance+1,maxRadius,startSlope,endSlope);
180
scans the octant covering the area from north east to north from right to
182
the method ignores the octants starting and ending cells since they have
183
been applied in FOV::start
185
void FOV::scanNE2N(OublietteLevel *map, int xCenter, int yCenter, int distance, int maxRadius, double startSlope, double endSlope)
187
if(distance > maxRadius)
192
// calculate start and end cell of the scan
193
int xStart=(int)((double)xCenter + 0.5 - (startSlope * distance));
194
int xEnd=(int)((double)xCenter + 0.5 - (endSlope * distance));
195
int yCheck=yCenter - distance;
197
// is starting cell the rightmost cell in the octant?
198
// NO: call applyCell() to starting cell
199
// YES: it has already been applied in FOV::start()
200
if(xStart != xCenter-(-1*distance))
202
this->applyCell(map,xStart,yCheck);
205
// find out if starting cell blocks LOS
206
bool prevBlocked=this->scanCell(map,xStart,yCheck);
208
// scan from the cell after the starting cell (xStart-1) to end cell of
209
// scan (xCheck>=xEnd)
210
for(int xCheck=xStart-1; xCheck>=xEnd; xCheck--)
212
// is the current cell the leftmost cell in the octant?
213
// NO: call applyCell() to current cell
214
// YES: it has already been applied in FOV::start()
215
if(xCheck != xCenter)
218
this->applyCell(map,xCheck,yCheck);
222
// if previous cell didn't block LOS (prevBlocked==false) we have
223
// hit a 'new' section of walls. a new scan will be started with an
224
// endSlope that 'brushes' by to the right of the blocking cell
226
// +---+a####+---+ @ = [xCenter+0.5,yCenter+0.5]
227
// | |#####| | a = old [xCheck,yCheck]
228
// | |#####| | b = new [xCheck+0.9999,yCheck-0.00001]
237
if(this->scanCell(map,xCheck,yCheck))
241
this->scanNE2N(map,xCenter,yCenter,distance+1,maxRadius,startSlope,this->slope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck+1,(double)yCheck+0.99999));
246
// cell doesn't block LOS
247
// if the cell is the first non-blocking cell after a section of walls
248
// we need to calculate a new startSlope that 'brushes' by to the left
249
// of the blocking cells
251
// +---+a---b##### @ = [xCenter+0.5,yCenter+0.5]
252
// | || |##### a = old [xCheck,yCheck]
253
// | || |##### b = new [xCheck+0.99999,yCheck]
266
startSlope=this->slope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck+0.9999999,(double)yCheck);
272
// if the last cell of the scan didn't block LOS a new scan should be
276
this->scanNE2N(map,xCenter,yCenter,distance+1,maxRadius,startSlope,endSlope);
282
scans the octant covering the area from north west to west from top to
284
the method ignores the octants starting and ending cells since they have
285
been applied in FOV::start
287
void FOV::scanNW2W(OublietteLevel *map, int xCenter, int yCenter, int distance, int maxRadius, double startSlope, double endSlope)
289
if(distance > maxRadius)
294
// calculate start and end cell of the scan
295
int yStart=(int)((double)yCenter + 0.5 - (startSlope * distance));
296
int yEnd=(int)((double)yCenter + 0.5 - (endSlope * distance));
297
int xCheck=xCenter - distance;
299
// is starting cell the topmost cell in the octant?
300
// NO: call applyCell() to starting cell
301
// YES: it has already been applied in FOV::start()
302
if(yStart != yCenter-(1*distance))
304
this->applyCell(map,xCheck,yStart);
307
// find out if starting cell blocks LOS
308
bool prevBlocked=this->scanCell(map,xCheck,yStart);
310
// scan from the cell after the starting cell (yStart+1) to end cell of
311
// scan (yCheck<=yEnd)
312
for(int yCheck=yStart+1; yCheck<=yEnd; yCheck++)
314
// is the current cell the bottommost cell in the octant?
315
// NO: call applyCell() to current cell
316
// YES: it has already been applied in FOV::start()
317
if(yCheck != yCenter)
320
this->applyCell(map,xCheck,yCheck);
324
// if previous cell didn't block LOS (prevBlocked==false) we have
325
// hit a 'new' section of walls. a new scan will be started with an
326
// endSlope that 'brushes' by the top of the blocking cell (see fig.)
328
// +---++---++---+ @ = [xCenter+0.5,yCenter+0.5]
329
// | || || | a = old [xCheck,yCheck]
330
// | || || | b = new [xCheck+0.99999,yCheck-0.00001]
344
if(this->scanCell(map,xCheck,yCheck))
348
this->scanNW2W(map,xCenter,yCenter,distance+1,maxRadius,startSlope,this->invSlope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck+0.99999,(double)yCheck-0.00001));
353
// cell doesn't block LOS
354
// if the cell is the first non-blocking cell after a section of walls
355
// we need to calculate a new startSlope that 'brushes' by the bottom
356
// of the blocking cells
358
// #####+---++---+ @ = [xCenter+0.5,yCenter+0.5]
359
// #####| || | a = old and new [xCheck,yCheck]
378
startSlope=this->invSlope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck,(double)yCheck);
384
// if the last cell of the scan didn't block LOS a new scan should be
388
this->scanNW2W(map,xCenter,yCenter,distance+1,maxRadius,startSlope,endSlope);
393
scans the octant covering the area from southe west to west from bottom to
395
the method ignores the octants starting and ending cells since they have
396
been applied in FOV::start
398
void FOV::scanSW2W(OublietteLevel *map, int xCenter, int yCenter, int distance, int maxRadius, double startSlope, double endSlope)
400
if(distance > maxRadius)
405
// calculate start and end cell of the scan
406
int yStart=(int)((double)yCenter + 0.5 - (startSlope * distance));
407
int yEnd=(int)((double)yCenter + 0.5 - (endSlope * distance));
408
int xCheck=xCenter - distance;
410
// is starting cell the bottommost cell in the octant?
411
// NO: call applyCell() to starting cell
412
// YES: it has already been applied in FOV::start()
413
if(yStart != yCenter-(-1*distance))
415
this->applyCell(map,xCheck,yStart);
418
// find out if starting cell blocks LOS
419
bool prevBlocked=this->scanCell(map,xCheck,yStart);
421
// scan from the cell after the starting cell (yStart-1) to end cell of
422
// scan (yCheck>=yEnd)
423
for(int yCheck=yStart-1; yCheck>=yEnd; yCheck--)
425
// is the current cell the topmost cell in the octant?
426
// NO: call applyCell() to current cell
427
// YES: it has already been applied in FOV::start()
428
if(yCheck != yCenter)
431
this->applyCell(map,xCheck,yCheck);
435
// if previous cell didn't block LOS (prevBlocked==false) we have
436
// hit a 'new' section of walls. a new scan will be started with an
437
// endSlope that 'brushes' by the bottom of the blocking cell
439
// +---++---++---+ @ = [xCenter+0.5,yCenter+0.5]
440
// | || || | a = old [xCheck,yCheck]
441
// | || || @ | b = new [xCheck+0.99999,yCheck+1]
455
if(this->scanCell(map,xCheck,yCheck))
459
this->scanSW2W(map,xCenter,yCenter,distance+1,maxRadius,startSlope,this->invSlope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck+0.99999,(double)yCheck+1));
464
// cell doesn't block LOS
465
// if the cell is the first non-blocking cell after a section of walls
466
// we need to calculate a new startSlope that 'brushes' by the top of
467
// the blocking cells
469
// +---++---++---+ @ = [xCenter+0.5,yCenter+0.5]
470
// | || || | a = old [xCheck,yCheck]
471
// | || || @ | b = new [xCheck,yCheck+0.99999]
489
startSlope=this->invSlope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck,(double)yCheck+0.99999);
495
// if the last cell of the scan didn't block LOS a new scan should be
499
this->scanSW2W(map,xCenter,yCenter,distance+1,maxRadius,startSlope,endSlope);
505
scans the octant covering the area from south west to south from left to
507
the method ignores the octants starting and ending cells since they have
508
been applied in FOV::start
510
void FOV::scanSW2S(OublietteLevel *map, int xCenter, int yCenter, int distance, int maxRadius, double startSlope, double endSlope)
512
if(distance > maxRadius)
517
// calculate start and end cell of the scan
518
int xStart=(int)((double)xCenter + 0.5 + (startSlope * distance));
519
int xEnd=(int)((double)xCenter + 0.5 + (endSlope * distance));
520
int yCheck=yCenter + distance;
522
// is the starting cell the leftmost cell in the octant?
523
// NO: call applyCell() to starting cell
524
// YES: it has already been applied in FOV::start()
525
if(xStart != xCenter+(-1*distance))
527
this->applyCell(map,xStart,yCheck);
530
// find out if starting cell blocks LOS
531
bool prevBlocked=this->scanCell(map,xStart,yCheck);
533
// scan from the cell after the starting cell (xStart+1) to end cell of
534
// scan (xCheck<=xEnd)
535
for(int xCheck=xStart+1; xCheck<=xEnd; xCheck++)
537
// is the current cell the rightmost cell in the octant?
538
// NO: call applyCell() to current cell
539
// YES: it has already been applied in FOV::start()
540
if(xCheck != xCenter)
543
this->applyCell(map,xCheck,yCheck);
547
// if previous cell didn't block LOS (prevBlocked==false) we have
548
// hit a 'new' section of walls. a new scan will be started with an
549
// endSlope that 'brushes' by to the left of the blocking cell
556
// +---ba####+---+ @ = [xCenter+0.5,yCenter+0.5]
557
// | |#####| | a = old [xCheck,yCheck]
558
// | |#####| | b = new [xCheck-0.00001,yCheck]
562
if(this->scanCell(map,xCheck,yCheck))
566
this->scanSW2S(map,xCenter,yCenter,distance+1,maxRadius,startSlope,this->slope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck-0.00001,(double)yCheck));
571
// cell doesn't block LOS
572
// if the cell is the first non-blocking cell after a section of walls
573
// we need to calculate a new startSlope that 'brushes' by to the right
574
// of the blocking cells
581
// #####a---++---+ @ = [xCenter+0.5,yCenter+0.5]
582
// #####| || | a = old [xCheck,yCheck]
583
// #####| || | b = new [xCheck,yCheck+0.99999]
591
startSlope=this->slope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck,(double)yCheck+0.99999);
597
// if the last cell of the scan didn't block LOS a new scan should be
601
this->scanSW2S(map,xCenter,yCenter,distance+1,maxRadius,startSlope,endSlope);
607
scans the octant covering the area from south east to south from right to
609
the method ignores the octants starting and ending cells since they have
610
been applied in FOV::start
612
void FOV::scanSE2S(OublietteLevel *map, int xCenter, int yCenter, int distance, int maxRadius, double startSlope, double endSlope)
614
if(distance > maxRadius)
619
// calculate start and end cell of the scan
620
int xStart=(int)((double)xCenter + 0.5 + (startSlope * distance));
621
int xEnd=(int)((double)xCenter + 0.5 + (endSlope * distance));
622
int yCheck=yCenter + distance;
624
// is starting cell the rightmost cell in the octant?
625
// NO: call applyCell() to starting cell
626
// YES: it has already been applied in FOV::start()
627
if(xStart != xCenter+(1*distance))
629
this->applyCell(map,xStart,yCheck);
632
// find out if starting cell blocks LOS
633
bool prevBlocked=this->scanCell(map,xStart,yCheck);
635
// scan from the cell after the starting cell (xStart-1) to end cell of
636
// scan (xCheck>=xEnd)
637
for(int xCheck=xStart-1; xCheck>=xEnd; xCheck--)
639
// is the current cell the leftmost cell in the octant?
640
// NO: call applyCell() to current cell
641
// YES: it has already been applied in FOV::start()
642
if(xCheck != xCenter)
645
this->applyCell(map,xCheck,yCheck);
649
// if previous cell didn't block LOS (prevBlocked==false) we have
650
// hit a 'new' section of walls. a new scan will be started with an
651
// endSlope that 'brushes' by to the right of the blocking cell
658
// +---+a####b---+ @ = [xCenter+0.5,yCenter+0.5]
659
// | |#####| | a = old [xCheck,yCheck]
660
// | |#####| | b = new [xCheck+1,yCheck]
664
if(this->scanCell(map,xCheck,yCheck))
668
this->scanSE2S(map,xCenter,yCenter,distance+1,maxRadius,startSlope,this->slope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck+1,(double)yCheck));
673
// cell doesn't block LOS
674
// if the cell is the first non-blocking cell after a section of walls
675
// we need to calculate a new startSlope that 'brushes' by to the left
676
// of the blocking cells
683
// +---+a---+##### @ = [xCenter+0.5,yCenter+0.5]
684
// | || |##### a = old [xCheck,yCheck]
685
// | || |##### b = new [xCheck+0.99999,yCheck+0.99999]
693
startSlope=this->slope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck+0.99999,(double)yCheck+0.99999);
699
// if the last cell of the scan didn't block LOS a new scan should be
703
this->scanSE2S(map,xCenter,yCenter,distance+1,maxRadius,startSlope,endSlope);
709
scans the octant covering the area from north east to east from top to
711
the method ignores the octants starting and ending cells since they have
712
been applied in FOV::start
714
void FOV::scanNE2E(OublietteLevel *map, int xCenter, int yCenter, int distance, int maxRadius, double startSlope, double endSlope)
716
if(distance > maxRadius)
721
// calculate start and end cell of the scan
722
int yStart=(int)((double)yCenter + 0.5 + (startSlope * distance));
723
int yEnd=(int)((double)yCenter + 0.5 + (endSlope * distance));
724
int xCheck=xCenter + distance;
726
// is starting cell the topmost cell in the octant?
727
// NO: call applyCell() to starting cell
728
// YES: it has already been applied in FOV::start()
729
if(yStart != yCenter+(-1*distance))
731
this->applyCell(map,xCheck,yStart);
734
// find out if starting cell blocks LOS
735
bool prevBlocked=this->scanCell(map,xCheck,yStart);
737
// scan from the cell after the starting cell (yStart+1) to end cell of
738
// scan (yCheck<=yEnd)
739
for(int yCheck=yStart+1; yCheck<=yEnd; yCheck++)
741
// is the current cell the bottommost cell in the octant?
742
// NO: call applyCell() to current cell
743
// YES: it has already been applied in FOV::start()
744
if(yCheck != yCenter)
747
this->applyCell(map,xCheck,yCheck);
751
// if previous cell didn't block LOS (prevBlocked==false) we have
752
// hit a 'new' section of walls. a new scan will be started with an
753
// endSlope that 'brushes' by the top of the blocking cell (see fig.)
755
// +---++---++---+ @ = [xCenter+0.5,yCenter+0.5]
756
// | || || | a = old [xCheck,yCheck]
757
// | || || | b = new [xCheck,yCheck-0.00001]
771
if(this->scanCell(map,xCheck,yCheck))
775
this->scanNE2E(map,xCenter,yCenter,distance+1,maxRadius,startSlope,this->invSlope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck,(double)yCheck-0.00001));
780
// cell doesn't block LOS
781
// if the cell is the first non-blocking cell after a section of walls
782
// we need to calculate a new startSlope that 'brushes' by the bottom
783
// of the blocking cells
785
// +---++---+##### @ = [xCenter+0.5,yCenter+0.5]
786
// | || |##### a = old [xCheck,yCheck]
787
// | || |##### b = new [xCheck+0.99999,yCheck]
805
startSlope=this->invSlope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck+0.99999,(double)yCheck);
811
// if the last cell of the scan didn't block LOS a new scan should be
815
this->scanNE2E(map,xCenter,yCenter,distance+1,maxRadius,startSlope,endSlope);
820
scans the octant covering the area from south east to east from bottom to
822
the method ignores the octants starting and ending cells since they have
823
been applied in FOV::start
825
void FOV::scanSE2E(OublietteLevel *map, int xCenter, int yCenter, int distance, int maxRadius, double startSlope, double endSlope)
827
if(distance > maxRadius)
832
// calculate start and end cell of the scan
833
int yStart=(int)((double)yCenter + 0.5 + (startSlope * distance));
834
int yEnd=(int)((double)yCenter + 0.5 + (endSlope * distance));
835
int xCheck=xCenter + distance;
837
// is starting cell the bottommost cell in the octant?
838
// NO: call applyCell() to starting cell
839
// YES: it has already been applied in FOV::start()
840
if(yStart != yCenter+(1*distance))
842
this->applyCell(map,xCheck,yStart);
845
// find out if starting cell blocks LOS
846
bool prevBlocked=this->scanCell(map,xCheck,yStart);
848
// scan from the cell after the starting cell (yStart-1) to end cell of
849
// scan (yCheck>=yEnd)
850
for(int yCheck=yStart-1; yCheck>=yEnd; yCheck--)
852
// is the current cell the topmost cell in the octant?
853
// NO: call applyCell() to current cell
854
// YES: it has already been applied in FOV::start()
855
if(yCheck != yCenter)
858
this->applyCell(map,xCheck,yCheck);
862
// if previous cell didn't block LOS (prevBlocked==false) we have
863
// hit a 'new' section of walls. a new scan will be started with an
864
// endSlope that 'brushes' by the bottom of the blocking cell
866
// +---++---++---+ @ = [xCenter+0.5,yCenter+0.5]
867
// | || || | a = old [xCheck,yCheck]
868
// | @ || || | b = new [xCheck,yCheck+1]
882
if(this->scanCell(map,xCheck,yCheck))
886
this->scanSE2E(map,xCenter,yCenter,distance+1,maxRadius,startSlope,this->invSlope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck,(double)yCheck+1));
891
// cell doesn't block LOS
892
// if the cell is the first non-blocking cell after a section of walls
893
// we need to calculate a new startSlope that 'brushes' by the top of
894
// the blocking cells
896
// +---++---++---+ @ = [xCenter+0.5,yCenter+0.5]
897
// | || || | a = old [xCheck,yCheck]
898
// | @ || || | b = new [xCheck+0.99999,yCheck+0.99999]
916
startSlope=this->invSlope((double)xCenter+0.5,(double)yCenter+0.5,(double)xCheck+0.99999,(double)yCheck+0.99999);
922
// if the last cell of the scan didn't block LOS a new scan should be
926
this->scanSE2E(map,xCenter,yCenter,distance+1,maxRadius,startSlope,endSlope);
931
void FOV::start(OublietteLevel *map, unsigned int x, unsigned int y, int maxRadius)
938
// apply starting cell
939
this->applyCell(map,x,y);
943
// scan and apply north
944
// until a blocking cell is hit or
945
// until maxRadius is reached
947
for(nL=1; nL<=maxRadius; nL++)
949
this->applyCell(map,x,y-nL);
950
if(this->scanCell(map,x,y-nL))
956
// scan and apply north east
957
// until a blocking cell is hit or
958
// until maxRadius is reached
960
for(neL=1; neL<=maxRadius; neL++)
962
this->applyCell(map,x+neL,y-neL);
963
if(this->scanCell(map,x+neL,y-neL))
969
// scan and apply east
970
// until a blocking cell is hit or
971
// until maxRadius is reached
973
for(eL=1; eL<=maxRadius; eL++)
975
this->applyCell(map,x+eL,y);
976
if(this->scanCell(map,x+eL,y))
982
// scan and apply south east
983
// until a blocking cell is hit or
984
// until maxRadius is reached
986
for(seL=1; seL<=maxRadius; seL++)
988
this->applyCell(map,x+seL,y+seL);
989
if(this->scanCell(map,x+seL,y+seL))
995
// scan and apply south
996
// until a blocking cell is hit or
997
// until maxRadius is reached
999
for(sL=1; sL<=maxRadius; sL++)
1001
this->applyCell(map,x,y+sL);
1002
if(this->scanCell(map,x,y+sL))
1008
// scan and apply south west
1009
// until a blocking cell is hit or
1010
// until maxRadius is reached
1012
for(swL=1; swL<=maxRadius; swL++)
1014
this->applyCell(map,x-swL,y+swL);
1015
if(this->scanCell(map,x-swL,y+swL))
1021
// scan and apply west
1022
// until a blocking cell is hit or
1023
// until maxRadius is reached
1025
for(wL=1; wL<=maxRadius; wL++)
1027
this->applyCell(map,x-wL,y);
1028
if(this->scanCell(map,x-wL,y))
1034
// scan and apply north west
1035
// until a blocking cell is hit or
1036
// until maxRadius is reached
1038
for(nwL=1; nwL<=maxRadius; nwL++)
1040
this->applyCell(map,x-nwL,y-nwL);
1041
if(this->scanCell(map,x-nwL,y-nwL))
1048
// scan the octant covering the area from north west to north
1049
// if it isn't blocked
1052
this->scanNW2N(map,x,y,1,maxRadius,1,0);
1055
// scan the octant covering the area from north east to north
1056
// if it isn't blocked
1059
this->scanNE2N(map,x,y,1,maxRadius,-1,0);
1062
// scan the octant covering the area from north west to west
1063
// if it isn't blocked
1066
this->scanNW2W(map,x,y,1,maxRadius,1,0);
1069
// scan the octant covering the area from south west to west
1070
// if it isn't blocked
1073
this->scanSW2W(map,x,y,1,maxRadius,-1,0);
1076
// scan the octant covering the area from south west to south
1077
// if it isn't blocked
1080
this->scanSW2S(map,x,y,1,maxRadius,-1,0);
1083
// scan the octant covering the area from south east to south
1084
// if it isn't blocked
1087
this->scanSE2S(map,x,y,1,maxRadius,1,0);
1090
// scan the octant covering the area from north east to east
1091
// if it isn't blocked
1094
this->scanNE2E(map,x,y,1,maxRadius,-1,0);
1097
// scan the octant covering the area from south east to east
1098
// if it isn't blocked
1101
this->scanSE2E(map,x,y,1,maxRadius,1,0);
1107
bool SIMPLEFOV::scanCell(OublietteLevel *map, int x, int y)
1109
return map->blockLOS(x,y);
1112
void SIMPLEFOV::applyCell(OublietteLevel *map, int x, int y)
1114
map->updateTileFlags(QPoint(x, y), Tile::Explored);