mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-30 21:31:03 +00:00
- put all of Polymost in a namespace.
So that its static variables are properly separated from the rest.
This commit is contained in:
parent
c6f83fa8bd
commit
9ebd8fd4a5
10 changed files with 89 additions and 486 deletions
|
@ -4,9 +4,8 @@
|
||||||
|
|
||||||
#include "mdsprite.h"
|
#include "mdsprite.h"
|
||||||
|
|
||||||
typedef struct { uint8_t r, g, b, a; } coltype;
|
namespace Polymost
|
||||||
typedef struct { float r, g, b, a; } coltypef;
|
{
|
||||||
|
|
||||||
extern float gtang;
|
extern float gtang;
|
||||||
extern double gxyaspect;
|
extern double gxyaspect;
|
||||||
extern float grhalfxdown10x;
|
extern float grhalfxdown10x;
|
||||||
|
@ -14,7 +13,6 @@ extern float gcosang, gsinang, gcosang2, gsinang2;
|
||||||
|
|
||||||
extern void Polymost_prepare_loadboard(void);
|
extern void Polymost_prepare_loadboard(void);
|
||||||
|
|
||||||
void polymost_outputGLDebugMessage(uint8_t severity, const char* format, ...);
|
|
||||||
|
|
||||||
//void phex(char v, char *s);
|
//void phex(char v, char *s);
|
||||||
void polymost_drawsprite(int32_t snum);
|
void polymost_drawsprite(int32_t snum);
|
||||||
|
@ -24,57 +22,25 @@ void polymost_initosdfuncs(void);
|
||||||
void polymost_drawrooms(void);
|
void polymost_drawrooms(void);
|
||||||
void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, fixed_t dahoriz, int16_t mirrorWall);
|
void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, fixed_t dahoriz, int16_t mirrorWall);
|
||||||
void polymost_completeMirror();
|
void polymost_completeMirror();
|
||||||
|
void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype);
|
||||||
|
void polymost_deletesprite(int num);
|
||||||
|
|
||||||
int32_t polymost_maskWallHasTranslucency(uwalltype const * const wall);
|
int32_t polymost_maskWallHasTranslucency(uwalltype const * const wall);
|
||||||
int32_t polymost_spriteHasTranslucency(tspritetype const * const tspr);
|
int32_t polymost_spriteHasTranslucency(tspritetype const * const tspr);
|
||||||
int32_t polymost_spriteIsModelOrVoxel(tspritetype const * const tspr);
|
int32_t polymost_spriteIsModelOrVoxel(tspritetype const * const tspr);
|
||||||
|
|
||||||
void polymost_glreset(void);
|
void polymost_glreset(void);
|
||||||
|
void polymost_scansector(int32_t sectnum);
|
||||||
enum {
|
|
||||||
INVALIDATE_ALL,
|
|
||||||
INVALIDATE_ART,
|
|
||||||
INVALIDATE_ALL_NON_INDEXED,
|
|
||||||
INVALIDATE_ART_NON_INDEXED
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
extern float curpolygonoffset;
|
extern float curpolygonoffset;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// these are defined in engine.cpp.
|
||||||
extern int16_t globalpicnum;
|
extern int16_t globalpicnum;
|
||||||
|
extern float fcosglobalang, fsinglobalang;
|
||||||
#define POLYMOST_CHOOSE_FOG_PAL(fogpal, pal) \
|
extern float fydimen, fviewingrange;
|
||||||
((fogpal) ? (fogpal) : (pal))
|
extern int32_t viewingrangerecip;
|
||||||
static FORCE_INLINE int32_t get_floor_fogpal(usectorptr_t const sec)
|
|
||||||
{
|
|
||||||
return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->floorpal);
|
|
||||||
}
|
|
||||||
static FORCE_INLINE int32_t get_ceiling_fogpal(usectorptr_t const sec)
|
|
||||||
{
|
|
||||||
return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->ceilingpal);
|
|
||||||
}
|
|
||||||
static FORCE_INLINE int32_t fogshade(int32_t const shade, int32_t const pal)
|
|
||||||
{
|
|
||||||
return (globalflags & GLOBAL_NO_GL_FOGSHADE) ? 0 : shade;
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr inline int check_nonpow2(int32_t const x)
|
|
||||||
{
|
|
||||||
return (x > 1 && (x&(x-1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline float polymost_invsqrt_approximation(float x)
|
|
||||||
{
|
|
||||||
#if !B_BIG_ENDIAN
|
|
||||||
float const haf = x * .5f;
|
|
||||||
union { float f; uint32_t i; } n = { x };
|
|
||||||
n.i = 0x5f375a86 - (n.i >> 1);
|
|
||||||
return n.f * (1.5f - haf * (n.f * n.f));
|
|
||||||
#else
|
|
||||||
// this is the comment
|
|
||||||
return 1.f / sqrtf(x);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flags of the <dameth> argument of various functions
|
// Flags of the <dameth> argument of various functions
|
||||||
enum {
|
enum {
|
||||||
|
@ -95,11 +61,4 @@ enum {
|
||||||
DAMETH_BACKFACECULL = -1,
|
DAMETH_BACKFACECULL = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DAMETH_NARROW_MASKPROPS(dameth) (((dameth)&(~DAMETH_TRANS1))|(((dameth)&DAMETH_TRANS1)>>1))
|
|
||||||
static_assert(DAMETH_NARROW_MASKPROPS(DAMETH_MASKPROPS) == DAMETH_MASK);
|
|
||||||
|
|
||||||
extern float fcosglobalang, fsinglobalang;
|
|
||||||
extern float fydimen, fviewingrange;
|
|
||||||
extern int32_t viewingrangerecip;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -55,9 +55,7 @@ int16_t pskybits_override = -1;
|
||||||
static TArray<TArray<uint8_t>> voxelmemory;
|
static TArray<TArray<uint8_t>> voxelmemory;
|
||||||
|
|
||||||
int16_t tiletovox[MAXTILES];
|
int16_t tiletovox[MAXTILES];
|
||||||
#ifdef USE_OPENGL
|
|
||||||
char *voxfilenames[MAXVOXELS];
|
char *voxfilenames[MAXVOXELS];
|
||||||
#endif
|
|
||||||
char g_haveVoxels;
|
char g_haveVoxels;
|
||||||
//#define kloadvoxel loadvoxel
|
//#define kloadvoxel loadvoxel
|
||||||
|
|
||||||
|
@ -297,7 +295,7 @@ int32_t animateoffs(int const tilenum, int fakevar)
|
||||||
|
|
||||||
static void renderDrawSprite(int32_t snum)
|
static void renderDrawSprite(int32_t snum)
|
||||||
{
|
{
|
||||||
polymost_drawsprite(snum);
|
Polymost::polymost_drawsprite(snum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -306,7 +304,7 @@ static void renderDrawSprite(int32_t snum)
|
||||||
//
|
//
|
||||||
static void renderDrawMaskedWall(int16_t damaskwallcnt)
|
static void renderDrawMaskedWall(int16_t damaskwallcnt)
|
||||||
{
|
{
|
||||||
polymost_drawmaskwall(damaskwallcnt); return;
|
Polymost::polymost_drawmaskwall(damaskwallcnt); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -464,10 +462,9 @@ int32_t insertsprite(int16_t sectnum, int16_t statnum)
|
||||||
// deletesprite
|
// deletesprite
|
||||||
//
|
//
|
||||||
int32_t (*deletesprite_replace)(int16_t spritenum) = NULL;
|
int32_t (*deletesprite_replace)(int16_t spritenum) = NULL;
|
||||||
void polymost_deletesprite(int num);
|
|
||||||
int32_t deletesprite(int16_t spritenum)
|
int32_t deletesprite(int16_t spritenum)
|
||||||
{
|
{
|
||||||
polymost_deletesprite(spritenum);
|
Polymost::polymost_deletesprite(spritenum);
|
||||||
if (deletesprite_replace)
|
if (deletesprite_replace)
|
||||||
return deletesprite_replace(spritenum);
|
return deletesprite_replace(spritenum);
|
||||||
assert((sprite[spritenum].statnum == MAXSTATUS)
|
assert((sprite[spritenum].statnum == MAXSTATUS)
|
||||||
|
@ -822,7 +819,7 @@ int32_t engineInit(void)
|
||||||
|
|
||||||
void engineUnInit(void)
|
void engineUnInit(void)
|
||||||
{
|
{
|
||||||
polymost_glreset();
|
Polymost::polymost_glreset();
|
||||||
freeallmodels();
|
freeallmodels();
|
||||||
# ifdef POLYMER
|
# ifdef POLYMER
|
||||||
polymer_uninit();
|
polymer_uninit();
|
||||||
|
@ -970,7 +967,7 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
polymost_drawrooms();
|
Polymost::polymost_drawrooms();
|
||||||
|
|
||||||
return inpreparemirror;
|
return inpreparemirror;
|
||||||
}
|
}
|
||||||
|
@ -1112,7 +1109,7 @@ void renderDrawMasks(void)
|
||||||
int32_t back = i;
|
int32_t back = i;
|
||||||
for (; i >= 0; --i)
|
for (; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (polymost_spriteHasTranslucency(&tsprite[i]))
|
if (Polymost::polymost_spriteHasTranslucency(&tsprite[i]))
|
||||||
{
|
{
|
||||||
tspriteptr[spritesortcnt] = &tsprite[i];
|
tspriteptr[spritesortcnt] = &tsprite[i];
|
||||||
++spritesortcnt;
|
++spritesortcnt;
|
||||||
|
@ -1127,7 +1124,7 @@ void renderDrawMasks(void)
|
||||||
{
|
{
|
||||||
const int32_t xs = tspriteptr[i]->x-globalposx, ys = tspriteptr[i]->y-globalposy;
|
const int32_t xs = tspriteptr[i]->x-globalposx, ys = tspriteptr[i]->y-globalposy;
|
||||||
const int32_t yp = DMulScale(xs,cosviewingrangeglobalang,ys,sinviewingrangeglobalang, 6);
|
const int32_t yp = DMulScale(xs,cosviewingrangeglobalang,ys,sinviewingrangeglobalang, 6);
|
||||||
const int32_t modelp = polymost_spriteIsModelOrVoxel(tspriteptr[i]);
|
const int32_t modelp = Polymost::polymost_spriteIsModelOrVoxel(tspriteptr[i]);
|
||||||
|
|
||||||
if (yp > (4<<8))
|
if (yp > (4<<8))
|
||||||
{
|
{
|
||||||
|
@ -1191,10 +1188,10 @@ killsprite:
|
||||||
int32_t pcstat = tspriteptr[i]->cstat & 48;
|
int32_t pcstat = tspriteptr[i]->cstat & 48;
|
||||||
int32_t pangle = tspriteptr[i]->ang;
|
int32_t pangle = tspriteptr[i]->ang;
|
||||||
int j = i + 1;
|
int j = i + 1;
|
||||||
if (!polymost_spriteIsModelOrVoxel(tspriteptr[i]))
|
if (!Polymost::polymost_spriteIsModelOrVoxel(tspriteptr[i]))
|
||||||
{
|
{
|
||||||
while (j < numSprites && py == spritesxyz[j].y && pcstat == (tspriteptr[j]->cstat & 48) && (pcstat != 16 || pangle == tspriteptr[j]->ang)
|
while (j < numSprites && py == spritesxyz[j].y && pcstat == (tspriteptr[j]->cstat & 48) && (pcstat != 16 || pangle == tspriteptr[j]->ang)
|
||||||
&& !polymost_spriteIsModelOrVoxel(tspriteptr[j]))
|
&& !Polymost::polymost_spriteIsModelOrVoxel(tspriteptr[j]))
|
||||||
{
|
{
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
@ -1236,7 +1233,7 @@ killsprite:
|
||||||
maskwallcnt = 0;
|
maskwallcnt = 0;
|
||||||
for (i = 0; i < numMaskWalls; i++)
|
for (i = 0; i < numMaskWalls; i++)
|
||||||
{
|
{
|
||||||
if (polymost_maskWallHasTranslucency((uwalltype *) &wall[thewall[maskwall[i]]]))
|
if (Polymost::polymost_maskWallHasTranslucency((uwalltype *) &wall[thewall[maskwall[i]]]))
|
||||||
{
|
{
|
||||||
maskwall[maskwallcnt] = maskwall[i];
|
maskwall[maskwallcnt] = maskwall[i];
|
||||||
maskwallcnt++;
|
maskwallcnt++;
|
||||||
|
@ -2829,7 +2826,7 @@ void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, f
|
||||||
|
|
||||||
inpreparemirror = 1;
|
inpreparemirror = 1;
|
||||||
|
|
||||||
polymost_prepareMirror(dax, day, daz, daang, dahoriz, dawall);
|
Polymost::polymost_prepareMirror(dax, day, daz, daang, dahoriz, dawall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2838,7 +2835,7 @@ void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, f
|
||||||
//
|
//
|
||||||
void renderCompleteMirror(void)
|
void renderCompleteMirror(void)
|
||||||
{
|
{
|
||||||
polymost_completeMirror();
|
Polymost::polymost_completeMirror();
|
||||||
inpreparemirror = 0;
|
inpreparemirror = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2983,7 +2980,7 @@ void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z)
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
void renderSetRollAngle(float rolla)
|
void renderSetRollAngle(float rolla)
|
||||||
{
|
{
|
||||||
gtang = rolla * BAngRadian;
|
Polymost::gtang = rolla * BAngRadian;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -97,9 +97,6 @@ static FORCE_INLINE int32_t getpalookup(int32_t davis, int32_t dashade)
|
||||||
static FORCE_INLINE int32_t getpalookupsh(int32_t davis) { return getpalookup(davis, globalshade) << 8; }
|
static FORCE_INLINE int32_t getpalookupsh(int32_t davis) { return getpalookup(davis, globalshade) << 8; }
|
||||||
|
|
||||||
////// yax'y stuff //////
|
////// yax'y stuff //////
|
||||||
#ifdef USE_OPENGL
|
|
||||||
extern void polymost_scansector(int32_t sectnum);
|
|
||||||
#endif
|
|
||||||
int32_t renderAddTsprite(int16_t z, int16_t sectnum);
|
int32_t renderAddTsprite(int16_t z, int16_t sectnum);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ static int32_t curextra=MAXTILES;
|
||||||
|
|
||||||
#define MIN_CACHETIME_PRINT 10
|
#define MIN_CACHETIME_PRINT 10
|
||||||
|
|
||||||
|
using namespace Polymost;
|
||||||
|
|
||||||
static int32_t addtileP(int32_t model,int32_t tile,int32_t pallet)
|
static int32_t addtileP(int32_t model,int32_t tile,int32_t pallet)
|
||||||
{
|
{
|
||||||
|
@ -1261,9 +1262,6 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
|
||||||
const uint8_t lpal = ((unsigned)owner < MAXSPRITES) ? sprite[tspr->owner].pal : tspr->pal;
|
const uint8_t lpal = ((unsigned)owner < MAXSPRITES) ? sprite[tspr->owner].pal : tspr->pal;
|
||||||
const int32_t sizyrep = tileHeight(tspr->picnum) * tspr->yrepeat;
|
const int32_t sizyrep = tileHeight(tspr->picnum) * tspr->yrepeat;
|
||||||
|
|
||||||
polymost_outputGLDebugMessage(3, "polymost_md3draw(m:%p, tspr:%p)", m, tspr);
|
|
||||||
// if ((tspr->cstat&48) == 32) return 0;
|
|
||||||
|
|
||||||
updateanimation((md2model_t *)m, tspr, lpal);
|
updateanimation((md2model_t *)m, tspr, lpal);
|
||||||
|
|
||||||
//create current&next frame's vertex list from whole list
|
//create current&next frame's vertex list from whole list
|
||||||
|
|
|
@ -23,18 +23,15 @@ Ken Silverman's official web site: http://www.advsys.net/ken
|
||||||
#include "hw_renderstate.h"
|
#include "hw_renderstate.h"
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
|
|
||||||
|
int skiptile = -1;
|
||||||
|
FGameTexture* GetSkyTexture(int basetile, int lognumtiles, const int16_t* tilemap);
|
||||||
|
|
||||||
int checkTranslucentReplacement(FTextureID picnum, int pal);
|
int checkTranslucentReplacement(FTextureID picnum, int pal);
|
||||||
|
|
||||||
CVARD(Bool, hw_animsmoothing, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable model animation smoothing")
|
CVARD(Bool, hw_animsmoothing, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable model animation smoothing")
|
||||||
CVARD(Bool, hw_hightile, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable hightile texture rendering")
|
|
||||||
CVARD(Bool, hw_models, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable model rendering")
|
CVARD(Bool, hw_models, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable model rendering")
|
||||||
CVARD(Bool, hw_parallaxskypanning, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable parallaxed floor/ceiling panning when drawing a parallaxing sky")
|
CVARD(Bool, hw_parallaxskypanning, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable parallaxed floor/ceiling panning when drawing a parallaxing sky")
|
||||||
CVARD(Float, hw_shadescale, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "multiplier for shading")
|
CVARD(Float, hw_shadescale, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "multiplier for shading")
|
||||||
bool hw_int_useindexedcolortextures;
|
|
||||||
CUSTOM_CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable indexed color texture rendering")
|
|
||||||
{
|
|
||||||
if (screen) screen->SetTextureFilterMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//{ "r_yshearing", "enable/disable y-shearing", (void*)&r_yshearing, CVAR_BOOL, 0, 1 }, disabled because not fully functional
|
//{ "r_yshearing", "enable/disable y-shearing", (void*)&r_yshearing, CVAR_BOOL, 0, 1 }, disabled because not fully functional
|
||||||
|
@ -42,6 +39,10 @@ CUSTOM_CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBAL
|
||||||
// For testing - will be removed later.
|
// For testing - will be removed later.
|
||||||
CVAR(Int, skytile, 0, 0)
|
CVAR(Int, skytile, 0, 0)
|
||||||
|
|
||||||
|
namespace Polymost
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
typedef struct { float x, cy[2], fy[2]; int32_t tag; int16_t n, p, ctag, ftag; } vsptyp;
|
typedef struct { float x, cy[2], fy[2]; int32_t tag; int16_t n, p, ctag, ftag; } vsptyp;
|
||||||
#define VSPMAX 2048 //<- careful!
|
#define VSPMAX 2048 //<- careful!
|
||||||
static vsptyp vsp[VSPMAX];
|
static vsptyp vsp[VSPMAX];
|
||||||
|
@ -102,12 +103,17 @@ static int32_t hicprecaching = 0;
|
||||||
static hitdata_t polymost_hitdata;
|
static hitdata_t polymost_hitdata;
|
||||||
|
|
||||||
FGameTexture* globalskytex = nullptr;
|
FGameTexture* globalskytex = nullptr;
|
||||||
FGameTexture* GetSkyTexture(int basetile, int lognumtiles, const int16_t* tilemap);
|
|
||||||
|
|
||||||
void polymost_outputGLDebugMessage(uint8_t severity, const char* format, ...)
|
void polymost_outputGLDebugMessage(uint8_t severity, const char* format, ...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline float polymost_invsqrt_approximation(float x)
|
||||||
|
{
|
||||||
|
// this is the comment
|
||||||
|
return 1.f / sqrtf(x);
|
||||||
|
}
|
||||||
|
|
||||||
float sectorVisibility(int sectnum)
|
float sectorVisibility(int sectnum)
|
||||||
{
|
{
|
||||||
// Beware of wraparound madness...
|
// Beware of wraparound madness...
|
||||||
|
@ -265,7 +271,6 @@ const vec2_16_t tileSize(size_t index)
|
||||||
static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, int32_t method, const vec2_16_t& tilesize);
|
static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, int32_t method, const vec2_16_t& tilesize);
|
||||||
|
|
||||||
// Hack for Duke's camera until I can find out why this behaves erratically.
|
// Hack for Duke's camera until I can find out why this behaves erratically.
|
||||||
int skiptile = -1;
|
|
||||||
|
|
||||||
static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32_t method, const vec2_16_t &tilesize)
|
static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32_t method, const vec2_16_t &tilesize)
|
||||||
{
|
{
|
||||||
|
@ -333,8 +338,6 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
|
||||||
float usub = 0;
|
float usub = 0;
|
||||||
float vsub = 0;
|
float vsub = 0;
|
||||||
|
|
||||||
polymost_outputGLDebugMessage(3, "polymost_drawpoly(dpxy:%p, n:%d, method_:%X), method: %X", dpxy, n, method_, method);
|
|
||||||
|
|
||||||
// This only takes effect for textures with their default set to SamplerClampXY.
|
// This only takes effect for textures with their default set to SamplerClampXY.
|
||||||
int sampleroverride = CLAMP_NONE;
|
int sampleroverride = CLAMP_NONE;
|
||||||
if (method & DAMETH_CLAMPED)
|
if (method & DAMETH_CLAMPED)
|
||||||
|
@ -962,12 +965,12 @@ static void polymost_internal_nonparallaxed(vec2f_t n0, vec2f_t n1, float ryp0,
|
||||||
|
|
||||||
if (globalorientation & 2)
|
if (globalorientation & 2)
|
||||||
{
|
{
|
||||||
int i = krecipasm(nsqrtasm(uhypsq(xy.x,xy.y)));
|
int i = krecipasm(ksqrt(uhypsq(xy.x,xy.y)));
|
||||||
r = i * (1.f/1073741824.f);
|
r = i * (1.f/1073741824.f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i = nsqrtasm(uhypsq(xy.x,xy.y)); if (i == 0) i = 1024; else i = 1048576 / i;
|
int i = ksqrt(uhypsq(xy.x,xy.y)); if (i == 0) i = 1024; else i = 1048576 / i;
|
||||||
r = i * (1.f/1048576.f);
|
r = i * (1.f/1048576.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1210,7 +1213,7 @@ static float fgetceilzofslope(usectorptr_t sec, float dax, float day)
|
||||||
vec2_t const w = *(vec2_t const *)wal;
|
vec2_t const w = *(vec2_t const *)wal;
|
||||||
vec2_t const d = { wal2->x - w.x, wal2->y - w.y };
|
vec2_t const d = { wal2->x - w.x, wal2->y - w.y };
|
||||||
|
|
||||||
int const i = nsqrtasm(uhypsq(d.x,d.y))<<5;
|
int const i = ksqrt(uhypsq(d.x,d.y))<<5;
|
||||||
if (i == 0) return sec->ceilingz;
|
if (i == 0) return sec->ceilingz;
|
||||||
|
|
||||||
float const j = (d.x*(day-w.y)-d.y*(dax-w.x))*(1.f/8.f);
|
float const j = (d.x*(day-w.y)-d.y*(dax-w.x))*(1.f/8.f);
|
||||||
|
@ -1228,7 +1231,7 @@ static float fgetflorzofslope(usectorptr_t sec, float dax, float day)
|
||||||
vec2_t const w = *(vec2_t const *)wal;
|
vec2_t const w = *(vec2_t const *)wal;
|
||||||
vec2_t const d = { wal2->x - w.x, wal2->y - w.y };
|
vec2_t const d = { wal2->x - w.x, wal2->y - w.y };
|
||||||
|
|
||||||
int const i = nsqrtasm(uhypsq(d.x,d.y))<<5;
|
int const i = ksqrt(uhypsq(d.x,d.y))<<5;
|
||||||
if (i == 0) return sec->floorz;
|
if (i == 0) return sec->floorz;
|
||||||
|
|
||||||
float const j = (d.x*(day-w.y)-d.y*(dax-w.x))*(1.f/8.f);
|
float const j = (d.x*(day-w.y)-d.y*(dax-w.x))*(1.f/8.f);
|
||||||
|
@ -1247,7 +1250,7 @@ static void fgetzsofslope(usectorptr_t sec, float dax, float day, float* ceilz,
|
||||||
|
|
||||||
vec2_t const d = { wal2->x - wal->x, wal2->y - wal->y };
|
vec2_t const d = { wal2->x - wal->x, wal2->y - wal->y };
|
||||||
|
|
||||||
int const i = nsqrtasm(uhypsq(d.x,d.y))<<5;
|
int const i = ksqrt(uhypsq(d.x,d.y))<<5;
|
||||||
if (i == 0) return;
|
if (i == 0) return;
|
||||||
|
|
||||||
float const j = (d.x*(day-wal->y)-d.y*(dax-wal->x))*(1.f/8.f);
|
float const j = (d.x*(day-wal->y)-d.y*(dax-wal->x))*(1.f/8.f);
|
||||||
|
@ -1590,184 +1593,6 @@ static void polymost_drawalls(int32_t const bunch)
|
||||||
flatskyrender = 0;
|
flatskyrender = 0;
|
||||||
ghoriz = ghorizbak;
|
ghoriz = ghorizbak;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
else //NOTE: code copied from ceiling code... lots of duplicated stuff :/
|
|
||||||
{
|
|
||||||
//Skybox code for parallax floor!
|
|
||||||
float sky_t0, sky_t1; // _nx0, _ny0, _nx1, _ny1;
|
|
||||||
float sky_ryp0, sky_ryp1, sky_x0, sky_x1, sky_cy0, sky_fy0, sky_cy1, sky_fy1, sky_ox0, sky_ox1;
|
|
||||||
static vec2f_t const skywal[4] = { { -512, -512 }, { 512, -512 }, { 512, 512 }, { -512, 512 } };
|
|
||||||
|
|
||||||
pow2xsplit = 0;
|
|
||||||
|
|
||||||
for (bssize_t i=0; i<4; i++)
|
|
||||||
{
|
|
||||||
walpos = skywal[i&3];
|
|
||||||
vec2f_t skyp0 = { walpos.y * gcosang - walpos.x * gsinang,
|
|
||||||
walpos.x * gcosang2 + walpos.y * gsinang2 };
|
|
||||||
|
|
||||||
walpos = skywal[(i + 1) & 3];
|
|
||||||
vec2f_t skyp1 = { walpos.y * gcosang - walpos.x * gsinang,
|
|
||||||
walpos.x * gcosang2 + walpos.y * gsinang2 };
|
|
||||||
|
|
||||||
vec2f_t const oskyp0 = skyp0;
|
|
||||||
|
|
||||||
//Clip to close parallel-screen plane
|
|
||||||
if (skyp0.y < SCISDIST)
|
|
||||||
{
|
|
||||||
if (skyp1.y < SCISDIST) continue;
|
|
||||||
sky_t0 = (SCISDIST - skyp0.y) / (skyp1.y - skyp0.y);
|
|
||||||
skyp0 = { (skyp1.x - skyp0.x) * sky_t0 + skyp0.x, SCISDIST };
|
|
||||||
}
|
|
||||||
else { sky_t0 = 0.f; }
|
|
||||||
|
|
||||||
if (skyp1.y < SCISDIST)
|
|
||||||
{
|
|
||||||
sky_t1 = (SCISDIST - oskyp0.y) / (skyp1.y - oskyp0.y);
|
|
||||||
skyp1 = { (skyp1.x - oskyp0.x) * sky_t1 + oskyp0.x, SCISDIST };
|
|
||||||
}
|
|
||||||
else { sky_t1 = 1.f; }
|
|
||||||
|
|
||||||
sky_ryp0 = 1.f/skyp0.y; sky_ryp1 = 1.f/skyp1.y;
|
|
||||||
|
|
||||||
//Generate screen coordinates for front side of wall
|
|
||||||
sky_x0 = ghalfx*skyp0.x*sky_ryp0 + ghalfx;
|
|
||||||
sky_x1 = ghalfx*skyp1.x*sky_ryp1 + ghalfx;
|
|
||||||
if ((sky_x1 <= sky_x0) || (sky_x0 >= x1) || (x0 >= sky_x1)) continue;
|
|
||||||
|
|
||||||
sky_ryp0 *= gyxscale; sky_ryp1 *= gyxscale;
|
|
||||||
|
|
||||||
sky_cy0 = -8192.f*sky_ryp0 + ghoriz;
|
|
||||||
sky_fy0 = 8192.f*sky_ryp0 + ghoriz;
|
|
||||||
sky_cy1 = -8192.f*sky_ryp1 + ghoriz;
|
|
||||||
sky_fy1 = 8192.f*sky_ryp1 + ghoriz;
|
|
||||||
|
|
||||||
sky_ox0 = sky_x0; sky_ox1 = sky_x1;
|
|
||||||
|
|
||||||
//Make sure: x0<=_x0<_x1<=x1
|
|
||||||
float nfy[2] = { fy0, fy1 };
|
|
||||||
|
|
||||||
if (sky_x0 < x0)
|
|
||||||
{
|
|
||||||
float const t = (x0-sky_x0)/(sky_x1-sky_x0);
|
|
||||||
sky_cy0 += (sky_cy1-sky_cy0)*t;
|
|
||||||
sky_fy0 += (sky_fy1-sky_fy0)*t;
|
|
||||||
sky_x0 = x0;
|
|
||||||
}
|
|
||||||
else if (sky_x0 > x0) nfy[0] += (sky_x0-x0)*(fy1-fy0)/(x1-x0);
|
|
||||||
|
|
||||||
if (sky_x1 > x1)
|
|
||||||
{
|
|
||||||
float const t = (x1-sky_x1)/(sky_x1-sky_x0);
|
|
||||||
sky_cy1 += (sky_cy1-sky_cy0)*t;
|
|
||||||
sky_fy1 += (sky_fy1-sky_fy0)*t;
|
|
||||||
sky_x1 = x1;
|
|
||||||
}
|
|
||||||
else if (sky_x1 < x1) nfy[1] += (sky_x1-x1)*(fy1-fy0)/(x1-x0);
|
|
||||||
|
|
||||||
// (skybox floor)
|
|
||||||
//(_x0,_fy0)-(_x1,_fy1)
|
|
||||||
// (skybox wall)
|
|
||||||
//(_x0,_cy0)-(_x1,_cy1)
|
|
||||||
// (skybox ceiling)
|
|
||||||
//(_x0,nfy0)-(_x1,nfy1)
|
|
||||||
|
|
||||||
//floor of skybox
|
|
||||||
drawingskybox = 6; //floor/6th texture/index 5 of skybox
|
|
||||||
float const ft[4] = { 512 / 16, 512 / -16, fcosglobalang * (1.f / 2147483648.f),
|
|
||||||
fsinglobalang * (1.f / 2147483648.f) };
|
|
||||||
|
|
||||||
xtex.d = 0;
|
|
||||||
ytex.d = gxyaspect*(1.0/4194304.0);
|
|
||||||
otex.d = -ghoriz*ytex.d;
|
|
||||||
xtex.u = ft[3]*fviewingrange*(-1.0/65536.0);
|
|
||||||
xtex.v = ft[2]*fviewingrange*(-1.0/65536.0);
|
|
||||||
ytex.u = ft[0]*ytex.d; ytex.v = ft[1]*ytex.d;
|
|
||||||
otex.u = ft[0]*otex.d; otex.v = ft[1]*otex.d;
|
|
||||||
otex.u += (ft[2]-xtex.u)*ghalfx;
|
|
||||||
otex.v -= (ft[3]+xtex.v)*ghalfx;
|
|
||||||
xtex.v = -xtex.v; ytex.v = -ytex.v; otex.v = -otex.v; //y-flip skybox floor
|
|
||||||
|
|
||||||
if ((sky_fy0 > nfy[0]) && (sky_fy1 > nfy[1]))
|
|
||||||
polymost_domost(sky_x0,sky_fy0,sky_x1,sky_fy1);
|
|
||||||
else if ((sky_fy0 > nfy[0]) != (sky_fy1 > nfy[1]))
|
|
||||||
{
|
|
||||||
//(ox,oy) is intersection of: (_x0,_fy0)-(_x1,_fy1)
|
|
||||||
// (_x0,nfy0)-(_x1,nfy1)
|
|
||||||
float const t = (sky_fy0-nfy[0])/(nfy[1]-nfy[0]-sky_fy1+sky_fy0);
|
|
||||||
vec2f_t const o = { sky_x0 + (sky_x1-sky_x0)*t, sky_fy0 + (sky_fy1-sky_fy0)*t };
|
|
||||||
if (nfy[0] > sky_fy0)
|
|
||||||
{
|
|
||||||
polymost_domost(sky_x0,nfy[0],o.x,o.y);
|
|
||||||
polymost_domost(o.x,o.y,sky_x1,sky_fy1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
polymost_domost(sky_x0,sky_fy0,o.x,o.y);
|
|
||||||
polymost_domost(o.x,o.y,sky_x1,nfy[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polymost_domost(sky_x0,nfy[0],sky_x1,nfy[1]);
|
|
||||||
|
|
||||||
//wall of skybox
|
|
||||||
drawingskybox = i+1; //i+1th texture/index i of skybox
|
|
||||||
xtex.d = (sky_ryp0-sky_ryp1)*gxyaspect*(1.0/512.0) / (sky_ox0-sky_ox1);
|
|
||||||
ytex.d = 0;
|
|
||||||
otex.d = sky_ryp0*gxyaspect*(1.0/512.0) - xtex.d*sky_ox0;
|
|
||||||
xtex.u = (sky_t0*sky_ryp0 - sky_t1*sky_ryp1)*gxyaspect*(64.0/512.0) / (sky_ox0-sky_ox1);
|
|
||||||
otex.u = sky_t0*sky_ryp0*gxyaspect*(64.0/512.0) - xtex.u*sky_ox0;
|
|
||||||
ytex.u = 0;
|
|
||||||
sky_t0 = -8192.f*sky_ryp0 + ghoriz;
|
|
||||||
sky_t1 = -8192.f*sky_ryp1 + ghoriz;
|
|
||||||
float const t = ((xtex.d*sky_ox0 + otex.d)*8.f) / ((sky_ox1-sky_ox0) * sky_ryp0 * 2048.f);
|
|
||||||
xtex.v = (sky_t0-sky_t1)*t;
|
|
||||||
ytex.v = (sky_ox1-sky_ox0)*t;
|
|
||||||
otex.v = -xtex.v*sky_ox0 - ytex.v*sky_t0;
|
|
||||||
|
|
||||||
if ((sky_cy0 > nfy[0]) && (sky_cy1 > nfy[1]))
|
|
||||||
polymost_domost(sky_x0,sky_cy0,sky_x1,sky_cy1);
|
|
||||||
else if ((sky_cy0 > nfy[0]) != (sky_cy1 > nfy[1]))
|
|
||||||
{
|
|
||||||
//(ox,oy) is intersection of: (_x0,_fy0)-(_x1,_fy1)
|
|
||||||
// (_x0,nfy0)-(_x1,nfy1)
|
|
||||||
float const t = (sky_cy0-nfy[0])/(nfy[1]-nfy[0]-sky_cy1+sky_cy0);
|
|
||||||
vec2f_t const o = { sky_x0 + (sky_x1 - sky_x0) * t, sky_cy0 + (sky_cy1 - sky_cy0) * t };
|
|
||||||
if (nfy[0] > sky_cy0)
|
|
||||||
{
|
|
||||||
polymost_domost(sky_x0,nfy[0],o.x,o.y);
|
|
||||||
polymost_domost(o.x,o.y,sky_x1,sky_cy1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
polymost_domost(sky_x0,sky_cy0,o.x,o.y);
|
|
||||||
polymost_domost(o.x,o.y,sky_x1,nfy[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polymost_domost(sky_x0,nfy[0],sky_x1,nfy[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Ceiling of skybox
|
|
||||||
drawingskybox = 5; //ceiling/5th texture/index 4 of skybox
|
|
||||||
float const ft[4] = { 512 / 16, -512 / -16, fcosglobalang * (1.f / 2147483648.f),
|
|
||||||
fsinglobalang * (1.f / 2147483648.f) };
|
|
||||||
|
|
||||||
xtex.d = 0;
|
|
||||||
ytex.d = gxyaspect*(-1.0/4194304.0);
|
|
||||||
otex.d = -ghoriz*ytex.d;
|
|
||||||
xtex.u = ft[3]*fviewingrange*(-1.0/65536.0);
|
|
||||||
xtex.v = ft[2]*fviewingrange*(-1.0/65536.0);
|
|
||||||
ytex.u = ft[0]*ytex.d; ytex.v = ft[1]*ytex.d;
|
|
||||||
otex.u = ft[0]*otex.d; otex.v = ft[1]*otex.d;
|
|
||||||
otex.u += (ft[2]-xtex.u)*ghalfx;
|
|
||||||
otex.v -= (ft[3]+xtex.v)*ghalfx;
|
|
||||||
|
|
||||||
polymost_domost(x0,fy0,x1,fy1);
|
|
||||||
|
|
||||||
drawingskybox = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1821,184 +1646,6 @@ static void polymost_drawalls(int32_t const bunch)
|
||||||
flatskyrender = 0;
|
flatskyrender = 0;
|
||||||
ghoriz = ghorizbak;
|
ghoriz = ghorizbak;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Skybox code for parallax ceiling!
|
|
||||||
float sky_t0, sky_t1; // _nx0, _ny0, _nx1, _ny1;
|
|
||||||
float sky_ryp0, sky_ryp1, sky_x0, sky_x1, sky_cy0, sky_fy0, sky_cy1, sky_fy1, sky_ox0, sky_ox1;
|
|
||||||
static vec2f_t const skywal[4] = { { -512, -512 }, { 512, -512 }, { 512, 512 }, { -512, 512 } };
|
|
||||||
|
|
||||||
pow2xsplit = 0;
|
|
||||||
|
|
||||||
for (bssize_t i=0; i<4; i++)
|
|
||||||
{
|
|
||||||
walpos = skywal[i&3];
|
|
||||||
vec2f_t skyp0 = { walpos.y * gcosang - walpos.x * gsinang,
|
|
||||||
walpos.x * gcosang2 + walpos.y * gsinang2 };
|
|
||||||
|
|
||||||
walpos = skywal[(i + 1) & 3];
|
|
||||||
vec2f_t skyp1 = { walpos.y * gcosang - walpos.x * gsinang,
|
|
||||||
walpos.x * gcosang2 + walpos.y * gsinang2 };
|
|
||||||
|
|
||||||
vec2f_t const oskyp0 = skyp0;
|
|
||||||
|
|
||||||
//Clip to close parallel-screen plane
|
|
||||||
if (skyp0.y < SCISDIST)
|
|
||||||
{
|
|
||||||
if (skyp1.y < SCISDIST) continue;
|
|
||||||
sky_t0 = (SCISDIST - skyp0.y) / (skyp1.y - skyp0.y);
|
|
||||||
skyp0 = { (skyp1.x - skyp0.x) * sky_t0 + skyp0.x, SCISDIST };
|
|
||||||
}
|
|
||||||
else { sky_t0 = 0.f; }
|
|
||||||
|
|
||||||
if (skyp1.y < SCISDIST)
|
|
||||||
{
|
|
||||||
sky_t1 = (SCISDIST - oskyp0.y) / (skyp1.y - oskyp0.y);
|
|
||||||
skyp1 = { (skyp1.x - oskyp0.x) * sky_t1 + oskyp0.x, SCISDIST };
|
|
||||||
}
|
|
||||||
else { sky_t1 = 1.f; }
|
|
||||||
|
|
||||||
sky_ryp0 = 1.f/skyp0.y; sky_ryp1 = 1.f/skyp1.y;
|
|
||||||
|
|
||||||
//Generate screen coordinates for front side of wall
|
|
||||||
sky_x0 = ghalfx*skyp0.x*sky_ryp0 + ghalfx;
|
|
||||||
sky_x1 = ghalfx*skyp1.x*sky_ryp1 + ghalfx;
|
|
||||||
if ((sky_x1 <= sky_x0) || (sky_x0 >= x1) || (x0 >= sky_x1)) continue;
|
|
||||||
|
|
||||||
sky_ryp0 *= gyxscale; sky_ryp1 *= gyxscale;
|
|
||||||
|
|
||||||
sky_cy0 = -8192.f*sky_ryp0 + ghoriz;
|
|
||||||
sky_fy0 = 8192.f*sky_ryp0 + ghoriz;
|
|
||||||
sky_cy1 = -8192.f*sky_ryp1 + ghoriz;
|
|
||||||
sky_fy1 = 8192.f*sky_ryp1 + ghoriz;
|
|
||||||
|
|
||||||
sky_ox0 = sky_x0; sky_ox1 = sky_x1;
|
|
||||||
|
|
||||||
//Make sure: x0<=_x0<_x1<=x1
|
|
||||||
float ncy[2] = { cy0, cy1 };
|
|
||||||
|
|
||||||
if (sky_x0 < x0)
|
|
||||||
{
|
|
||||||
float const t = (x0-sky_x0)/(sky_x1-sky_x0);
|
|
||||||
sky_cy0 += (sky_cy1-sky_cy0)*t;
|
|
||||||
sky_fy0 += (sky_fy1-sky_fy0)*t;
|
|
||||||
sky_x0 = x0;
|
|
||||||
}
|
|
||||||
else if (sky_x0 > x0) ncy[0] += (sky_x0-x0)*(cy1-cy0)/(x1-x0);
|
|
||||||
|
|
||||||
if (sky_x1 > x1)
|
|
||||||
{
|
|
||||||
float const t = (x1-sky_x1)/(sky_x1-sky_x0);
|
|
||||||
sky_cy1 += (sky_cy1-sky_cy0)*t;
|
|
||||||
sky_fy1 += (sky_fy1-sky_fy0)*t;
|
|
||||||
sky_x1 = x1;
|
|
||||||
}
|
|
||||||
else if (sky_x1 < x1) ncy[1] += (sky_x1-x1)*(cy1-cy0)/(x1-x0);
|
|
||||||
|
|
||||||
// (skybox ceiling)
|
|
||||||
//(_x0,_cy0)-(_x1,_cy1)
|
|
||||||
// (skybox wall)
|
|
||||||
//(_x0,_fy0)-(_x1,_fy1)
|
|
||||||
// (skybox floor)
|
|
||||||
//(_x0,ncy0)-(_x1,ncy1)
|
|
||||||
|
|
||||||
//ceiling of skybox
|
|
||||||
drawingskybox = 5; //ceiling/5th texture/index 4 of skybox
|
|
||||||
float const ft[4] = { 512 / 16, -512 / -16, fcosglobalang * (1.f / 2147483648.f),
|
|
||||||
fsinglobalang * (1.f / 2147483648.f) };
|
|
||||||
|
|
||||||
xtex.d = 0;
|
|
||||||
ytex.d = gxyaspect*(-1.0/4194304.0);
|
|
||||||
otex.d = -ghoriz*ytex.d;
|
|
||||||
xtex.u = ft[3]*fviewingrange*(-1.0/65536.0);
|
|
||||||
xtex.v = ft[2]*fviewingrange*(-1.0/65536.0);
|
|
||||||
ytex.u = ft[0]*ytex.d; ytex.v = ft[1]*ytex.d;
|
|
||||||
otex.u = ft[0]*otex.d; otex.v = ft[1]*otex.d;
|
|
||||||
otex.u += (ft[2]-xtex.u)*ghalfx;
|
|
||||||
otex.v -= (ft[3]+xtex.v)*ghalfx;
|
|
||||||
|
|
||||||
|
|
||||||
if ((sky_cy0 < ncy[0]) && (sky_cy1 < ncy[1]))
|
|
||||||
polymost_domost(sky_x1,sky_cy1,sky_x0,sky_cy0);
|
|
||||||
else if ((sky_cy0 < ncy[0]) != (sky_cy1 < ncy[1]))
|
|
||||||
{
|
|
||||||
//(ox,oy) is intersection of: (_x0,_cy0)-(_x1,_cy1)
|
|
||||||
// (_x0,ncy0)-(_x1,ncy1)
|
|
||||||
float const t = (sky_cy0-ncy[0])/(ncy[1]-ncy[0]-sky_cy1+sky_cy0);
|
|
||||||
vec2f_t const o = { sky_x0 + (sky_x1-sky_x0)*t, sky_cy0 + (sky_cy1-sky_cy0)*t };
|
|
||||||
if (ncy[0] < sky_cy0)
|
|
||||||
{
|
|
||||||
polymost_domost(o.x,o.y,sky_x0,ncy[0]);
|
|
||||||
polymost_domost(sky_x1,sky_cy1,o.x,o.y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
polymost_domost(o.x,o.y,sky_x0,sky_cy0);
|
|
||||||
polymost_domost(sky_x1,ncy[1],o.x,o.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polymost_domost(sky_x1,ncy[1],sky_x0,ncy[0]);
|
|
||||||
|
|
||||||
//wall of skybox
|
|
||||||
drawingskybox = i+1; //i+1th texture/index i of skybox
|
|
||||||
xtex.d = (sky_ryp0-sky_ryp1)*gxyaspect*(1.0/512.0) / (sky_ox0-sky_ox1);
|
|
||||||
ytex.d = 0;
|
|
||||||
otex.d = sky_ryp0*gxyaspect*(1.0/512.0) - xtex.d*sky_ox0;
|
|
||||||
xtex.u = (sky_t0*sky_ryp0 - sky_t1*sky_ryp1)*gxyaspect*(64.0/512.0) / (sky_ox0-sky_ox1);
|
|
||||||
otex.u = sky_t0*sky_ryp0*gxyaspect*(64.0/512.0) - xtex.u*sky_ox0;
|
|
||||||
ytex.u = 0;
|
|
||||||
sky_t0 = -8192.f*sky_ryp0 + ghoriz;
|
|
||||||
sky_t1 = -8192.f*sky_ryp1 + ghoriz;
|
|
||||||
float const t = ((xtex.d*sky_ox0 + otex.d)*8.f) / ((sky_ox1-sky_ox0) * sky_ryp0 * 2048.f);
|
|
||||||
xtex.v = (sky_t0-sky_t1)*t;
|
|
||||||
ytex.v = (sky_ox1-sky_ox0)*t;
|
|
||||||
otex.v = -xtex.v*sky_ox0 - ytex.v*sky_t0;
|
|
||||||
|
|
||||||
if ((sky_fy0 < ncy[0]) && (sky_fy1 < ncy[1]))
|
|
||||||
polymost_domost(sky_x1,sky_fy1,sky_x0,sky_fy0);
|
|
||||||
else if ((sky_fy0 < ncy[0]) != (sky_fy1 < ncy[1]))
|
|
||||||
{
|
|
||||||
//(ox,oy) is intersection of: (_x0,_fy0)-(_x1,_fy1)
|
|
||||||
// (_x0,ncy0)-(_x1,ncy1)
|
|
||||||
float const t = (sky_fy0-ncy[0])/(ncy[1]-ncy[0]-sky_fy1+sky_fy0);
|
|
||||||
vec2f_t const o = { sky_x0 + (sky_x1 - sky_x0) * t, sky_fy0 + (sky_fy1 - sky_fy0) * t };
|
|
||||||
if (ncy[0] < sky_fy0)
|
|
||||||
{
|
|
||||||
polymost_domost(o.x,o.y,sky_x0,ncy[0]);
|
|
||||||
polymost_domost(sky_x1,sky_fy1,o.x,o.y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
polymost_domost(o.x,o.y,sky_x0,sky_fy0);
|
|
||||||
polymost_domost(sky_x1,ncy[1],o.x,o.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polymost_domost(sky_x1,ncy[1],sky_x0,ncy[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Floor of skybox
|
|
||||||
drawingskybox = 6; //floor/6th texture/index 5 of skybox
|
|
||||||
float const ft[4] = { 512 / 16, 512 / -16, fcosglobalang * (1.f / 2147483648.f),
|
|
||||||
fsinglobalang * (1.f / 2147483648.f) };
|
|
||||||
|
|
||||||
xtex.d = 0;
|
|
||||||
ytex.d = gxyaspect*(1.0/4194304.0);
|
|
||||||
otex.d = -ghoriz*ytex.d;
|
|
||||||
xtex.u = ft[3]*fviewingrange*(-1.0/65536.0);
|
|
||||||
xtex.v = ft[2]*fviewingrange*(-1.0/65536.0);
|
|
||||||
ytex.u = ft[0]*ytex.d; ytex.v = ft[1]*ytex.d;
|
|
||||||
otex.u = ft[0]*otex.d; otex.v = ft[1]*otex.d;
|
|
||||||
otex.u += (ft[2]-xtex.u)*ghalfx;
|
|
||||||
otex.v -= (ft[3]+xtex.v)*ghalfx;
|
|
||||||
xtex.v = -xtex.v; ytex.v = -ytex.v; otex.v = -otex.v; //y-flip skybox floor
|
|
||||||
polymost_domost(x1,cy1,x0,cy0);
|
|
||||||
|
|
||||||
drawingskybox = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
skyzbufferhack = 0;
|
skyzbufferhack = 0;
|
||||||
}
|
}
|
||||||
|
@ -2985,8 +2632,6 @@ void polymost_drawsprite(int32_t snum)
|
||||||
|
|
||||||
int32_t spritenum = tspr->owner;
|
int32_t spritenum = tspr->owner;
|
||||||
|
|
||||||
polymost_outputGLDebugMessage(3, "polymost_drawsprite(snum:%d)", snum);
|
|
||||||
|
|
||||||
if ((tspr->cstat&48) != 48)
|
if ((tspr->cstat&48) != 48)
|
||||||
tileUpdatePicnum(&tspr->picnum, spritenum + 32768);
|
tileUpdatePicnum(&tspr->picnum, spritenum + 32768);
|
||||||
|
|
||||||
|
@ -3570,39 +3215,12 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype)
|
||||||
if (tex) GLInterface.SetTexture(tex, palid, CLAMP_NONE);
|
if (tex) GLInterface.SetTexture(tex, palid, CLAMP_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PrecacheHardwareTextures(int nTile)
|
void PrecacheHardwareTextures(int nTile)
|
||||||
{
|
{
|
||||||
// PRECACHE
|
// PRECACHE
|
||||||
// This really *really* needs improvement on the game side - the entire precaching logic has no clue about the different needs of a hardware renderer.
|
// This really *really* needs improvement on the game side - the entire precaching logic has no clue about the different needs of a hardware renderer.
|
||||||
polymost_precache(nTile, 0, 1);
|
Polymost::polymost_precache(nTile, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char* voxfilenames[MAXVOXELS];
|
|
||||||
void (*PolymostProcessVoxels_Callback)(void) = NULL;
|
|
||||||
void PolymostProcessVoxels(void)
|
|
||||||
{
|
|
||||||
if (PolymostProcessVoxels_Callback)
|
|
||||||
PolymostProcessVoxels_Callback();
|
|
||||||
|
|
||||||
if (g_haveVoxels != 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_haveVoxels = 2;
|
|
||||||
|
|
||||||
Printf(PRINT_NONOTIFY, "Generating voxel models for Polymost. This may take a while...\n");
|
|
||||||
|
|
||||||
for (bssize_t i = 0; i < MAXVOXELS; i++)
|
|
||||||
{
|
|
||||||
if (voxfilenames[i])
|
|
||||||
{
|
|
||||||
int lumpnum = fileSystem.FindFile(voxfilenames[i]);
|
|
||||||
if (lumpnum >= 0)
|
|
||||||
{
|
|
||||||
voxmodels[i] = voxload(lumpnum);
|
|
||||||
voxmodels[i]->scale = voxscale[i] * (1.f / 65536.f);
|
|
||||||
}
|
|
||||||
DO_FREE_AND_NULL(voxfilenames[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -13,10 +13,13 @@
|
||||||
#include "texturemanager.h"
|
#include "texturemanager.h"
|
||||||
#include "voxels.h"
|
#include "voxels.h"
|
||||||
#include "glbackend/gl_models.h"
|
#include "glbackend/gl_models.h"
|
||||||
|
#include "printf.h"
|
||||||
|
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "../../glbackend/glbackend.h"
|
#include "../../glbackend/glbackend.h"
|
||||||
|
|
||||||
|
using namespace Polymost;
|
||||||
|
|
||||||
void voxfree(voxmodel_t *m)
|
void voxfree(voxmodel_t *m)
|
||||||
{
|
{
|
||||||
if (!m)
|
if (!m)
|
||||||
|
@ -61,10 +64,6 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspriteptr_t const tspr)
|
||||||
if ((tspr->cstat & 48) == 32)
|
if ((tspr->cstat & 48) == 32)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
polymost_outputGLDebugMessage(3, "polymost_voxdraw(m:%p, tspr:%p)", m, tspr);
|
|
||||||
|
|
||||||
//updateanimation((md2model *)m,tspr);
|
|
||||||
|
|
||||||
vec3f_t m0 = { m->scale, m->scale, m->scale };
|
vec3f_t m0 = { m->scale, m->scale, m->scale };
|
||||||
vec3f_t a0 = { 0, 0, m->zadd*m->scale };
|
vec3f_t a0 = { 0, 0, m->zadd*m->scale };
|
||||||
|
|
||||||
|
@ -194,6 +193,36 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspriteptr_t const tspr)
|
||||||
GLInterface.SetFadeDisable(false);
|
GLInterface.SetFadeDisable(false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern char* voxfilenames[MAXVOXELS];
|
||||||
|
void (*PolymostProcessVoxels_Callback)(void) = NULL;
|
||||||
|
void PolymostProcessVoxels(void)
|
||||||
|
{
|
||||||
|
if (PolymostProcessVoxels_Callback)
|
||||||
|
PolymostProcessVoxels_Callback();
|
||||||
|
|
||||||
|
if (g_haveVoxels != 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_haveVoxels = 2;
|
||||||
|
|
||||||
|
Printf(PRINT_NONOTIFY, "Generating voxel models for Polymost. This may take a while...\n");
|
||||||
|
|
||||||
|
for (bssize_t i = 0; i < MAXVOXELS; i++)
|
||||||
|
{
|
||||||
|
if (voxfilenames[i])
|
||||||
|
{
|
||||||
|
int lumpnum = fileSystem.FindFile(voxfilenames[i]);
|
||||||
|
if (lumpnum >= 0)
|
||||||
|
{
|
||||||
|
voxmodels[i] = voxload(lumpnum);
|
||||||
|
voxmodels[i]->scale = voxscale[i] * (1.f / 65536.f);
|
||||||
|
}
|
||||||
|
DO_FREE_AND_NULL(voxfilenames[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//---------------------------------------- VOX LIBRARY ENDS ----------------------------------------
|
//---------------------------------------- VOX LIBRARY ENDS ----------------------------------------
|
||||||
|
|
|
@ -385,7 +385,7 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang,
|
||||||
memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES + MAXUNIQHUDID));
|
memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES + MAXUNIQHUDID));
|
||||||
initspritelists();
|
initspritelists();
|
||||||
ClearAutomap();
|
ClearAutomap();
|
||||||
Polymost_prepare_loadboard();
|
Polymost::Polymost_prepare_loadboard();
|
||||||
|
|
||||||
pos->x = fr.ReadInt32();
|
pos->x = fr.ReadInt32();
|
||||||
pos->y = fr.ReadInt32();
|
pos->y = fr.ReadInt32();
|
||||||
|
|
|
@ -512,7 +512,7 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
Polymost_prepare_loadboard();
|
Polymost::Polymost_prepare_loadboard();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FString mapname = pPath;
|
FString mapname = pPath;
|
||||||
|
|
|
@ -724,7 +724,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
||||||
viewSetErrorMessage("");
|
viewSetErrorMessage("");
|
||||||
Net_ClearFifo();
|
Net_ClearFifo();
|
||||||
paused = 0;
|
paused = 0;
|
||||||
Polymost_prepare_loadboard();
|
Polymost::Polymost_prepare_loadboard();
|
||||||
Mus_ResumeSaved();
|
Mus_ResumeSaved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,13 @@
|
||||||
#include "gamestruct.h"
|
#include "gamestruct.h"
|
||||||
#include "gl_models.h"
|
#include "gl_models.h"
|
||||||
|
|
||||||
|
CVARD(Bool, hw_hightile, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable hightile texture rendering")
|
||||||
|
bool hw_int_useindexedcolortextures;
|
||||||
|
CUSTOM_CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable indexed color texture rendering")
|
||||||
|
{
|
||||||
|
if (screen) screen->SetTextureFilterMode();
|
||||||
|
}
|
||||||
|
|
||||||
CVAR(Bool, gl_texture, true, 0)
|
CVAR(Bool, gl_texture, true, 0)
|
||||||
|
|
||||||
F2DDrawer twodpsp;
|
F2DDrawer twodpsp;
|
||||||
|
@ -519,8 +526,6 @@ void markTileForPrecache(int tilenum, int palnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype);
|
|
||||||
|
|
||||||
void precacheMarkedTiles()
|
void precacheMarkedTiles()
|
||||||
{
|
{
|
||||||
decltype(cachemap)::Iterator it(cachemap);
|
decltype(cachemap)::Iterator it(cachemap);
|
||||||
|
@ -529,7 +534,7 @@ void precacheMarkedTiles()
|
||||||
{
|
{
|
||||||
int dapicnum = pair->Key & 0x7fffffff;
|
int dapicnum = pair->Key & 0x7fffffff;
|
||||||
int dapalnum = pair->Key >> 32;
|
int dapalnum = pair->Key >> 32;
|
||||||
polymost_precache(dapicnum, dapalnum, 0);
|
Polymost::polymost_precache(dapicnum, dapalnum, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue