1 //**************************************************************************
3 //** ## ## ## ## ## #### #### ### ###
4 //** ## ## ## ## ## ## ## ## ## ## #### ####
5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ##
6 //** ## ## ######## ## ## ## ## ## ## ## ### ##
7 //** ### ## ## ### ## ## ## ## ## ##
8 //** # ## ## # #### #### ## ##
10 //** Copyright (C) 1999-2006 Jānis Legzdiņš
11 //** Copyright (C) 2018-2023 Ketmar Dark
13 //** This program is free software: you can redistribute it and/or modify
14 //** it under the terms of the GNU General Public License as published by
15 //** the Free Software Foundation, version 3 of the License ONLY.
17 //** This program is distributed in the hope that it will be useful,
18 //** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 //** GNU General Public License for more details.
22 //** You should have received a copy of the GNU General Public License
23 //** along with this program. If not, see <http://www.gnu.org/licenses/>.
25 //**************************************************************************
27 // BLOCK MAP ITERATORS
29 // For each line/thing in the given mapblock, call the passed PIT_*
30 // function. If the function returns false, exit with false without checking
33 //**************************************************************************
34 #ifndef VAVOOM_PSIM_WORLD_HEADER
35 #define VAVOOM_PSIM_WORLD_HEADER
38 //==========================================================================
42 // The validcount flags are used to avoid checking pobjs that are marked in
43 // multiple mapblocks, so increment validcount before creating this object.
45 //==========================================================================
46 class VBlockPObjIterator
{
50 polyblock_t
*PolyLink
;
54 // if `all` is false, return only 3d pobjs
55 VBlockPObjIterator (VLevel
*Level
, int x
, int y
, polyobj_t
**APolyPtr
, bool all
=false);
60 //==========================================================================
62 // VRadiusThingsIterator
64 //==========================================================================
65 class VRadiusThingsIterator
: public VScriptIterator
{
75 VRadiusThingsIterator (VThinker
*ASelf
, VEntity
**AEntPtr
, TVec Org
, float Radius
);
76 virtual bool GetNext () override
;
80 //==========================================================================
84 // Traces a line from x1,y1 to x2,y2, calling the traverser function for
85 // each. Returns true if the traverser function returns true for all lines.
87 //==========================================================================
88 class VPathTraverse
: public VScriptIterator
{
97 TVec trace_dir3d
; // normalised
101 unsigned scanflags
; // PT_xxx
103 int poolStart
, poolEnd
;
110 VPathTraverse (VThinker
*Self
, intercept_t
*AInPtr
, const TVec
&p0
, const TVec
&p1
, int flags
,
111 vuint32 planeflags
=SPF_NOBLOCKING
|SPF_NOBLOCKSHOOT
, vuint32 lineflags
=ML_BLOCKEVERYTHING
|ML_BLOCKHITSCAN
);
113 virtual ~VPathTraverse ();
115 virtual bool GetNext () override
;
118 void Init (VThinker
*Self
, const TVec
&p0
, const TVec
&p1
, int flags
, vuint32 planeflags
, vuint32 lineflags
);
119 void AddLineIntercepts (int mapx
, int mapy
, vuint32 planeflags
, vuint32 lineflags
);
120 void AddThingIntercepts (int mapx
, int mapy
);
121 intercept_t
&NewIntercept (const float frac
);
123 inline int InterceptCount () const noexcept
{ return Level
->CurrentPathInterceptionIndex()-poolStart
; }
124 inline intercept_t
*GetIntercept (int idx
) noexcept
{ return Level
->GetPathIntercept(poolStart
+idx
); }
126 inline bool NeedCheckBMCell (const int bmx
, const int bmy
) const noexcept
{
127 if (bmx
>= 0 && bmy
>= 0 && bmx
< Level
->BlockMapWidth
&& bmy
< Level
->BlockMapHeight
) {
128 vint32
*pp
= Level
->processedBMCells
+(bmy
*Level
->BlockMapWidth
+bmx
);
129 if (*pp
== validcount
) return false;