mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-27 05:30:56 +00:00
- made the MapSectionGenerator a class to remove a global array.
This commit is contained in:
parent
4357f0dc40
commit
202d209eb8
1 changed files with 133 additions and 119 deletions
|
@ -49,14 +49,36 @@
|
||||||
#include "gl/dynlights/gl_glow.h"
|
#include "gl/dynlights/gl_glow.h"
|
||||||
#include "gl/utility/gl_clock.h"
|
#include "gl/utility/gl_clock.h"
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Map section generation
|
||||||
|
// Map sections are physically separated parts of the map.
|
||||||
|
// If the player is in section A, any map part in other sections can
|
||||||
|
// often be quickly discarded to improve performance.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
struct MapSectionGenerator
|
||||||
|
{
|
||||||
|
struct cvertex_t
|
||||||
|
{
|
||||||
|
double X, Y;
|
||||||
|
|
||||||
|
operator int() const { return xs_FloorToInt(X) + 65536 * xs_FloorToInt(Y); }
|
||||||
|
bool operator!= (const cvertex_t &other) const { return fabs(X - other.X) >= EQUAL_EPSILON || fabs(Y - other.Y) >= EQUAL_EPSILON; }
|
||||||
|
cvertex_t& operator =(const vertex_t *v) { X = v->fX(); Y = v->fY(); return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef TMap<cvertex_t, int> FSectionVertexMap;
|
||||||
|
TArray<subsector_t *> MapSectionCollector;
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
static TArray<subsector_t *> MapSectionCollector;
|
|
||||||
|
|
||||||
static void DoSetMapSection(subsector_t *sub, int num)
|
void DoSetMapSection(subsector_t *sub, int num)
|
||||||
{
|
{
|
||||||
MapSectionCollector.Resize(1);
|
MapSectionCollector.Resize(1);
|
||||||
MapSectionCollector[0] = sub;
|
MapSectionCollector[0] = sub;
|
||||||
|
@ -93,18 +115,8 @@ static void DoSetMapSection(subsector_t *sub, int num)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
struct cvertex_t
|
|
||||||
{
|
|
||||||
double X, Y;
|
|
||||||
|
|
||||||
operator int() const { return xs_FloorToInt(X) + 65536 * xs_FloorToInt(Y); }
|
int MergeMapSections(int num)
|
||||||
bool operator!= (const cvertex_t &other) const { return fabs(X - other.X) >= EQUAL_EPSILON || fabs(Y - other.Y) >= EQUAL_EPSILON; }
|
|
||||||
cvertex_t& operator =(const vertex_t *v) { X = v->fX(); Y = v->fY(); return *this; }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef TMap<cvertex_t, int> FSectionVertexMap;
|
|
||||||
|
|
||||||
static int MergeMapSections(int num)
|
|
||||||
{
|
{
|
||||||
FSectionVertexMap vmap;
|
FSectionVertexMap vmap;
|
||||||
FSectionVertexMap::Pair *pair;
|
FSectionVertexMap::Pair *pair;
|
||||||
|
@ -176,7 +188,7 @@ static int MergeMapSections(int num)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void SetMapSections()
|
void SetMapSections()
|
||||||
{
|
{
|
||||||
bool set;
|
bool set;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
@ -201,6 +213,7 @@ static void SetMapSections()
|
||||||
Printf("%d map sections found\n", num);
|
Printf("%d map sections found\n", num);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
@ -283,7 +296,8 @@ static void PrepareSectorData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetMapSections();
|
MapSectionGenerator msg;
|
||||||
|
msg.SetMapSections();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
Loading…
Reference in a new issue