mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
- eliminated the sine table and moved tilehasmodelorvoxel to a different file to delete engine.cpp.
This commit is contained in:
parent
ef2f781e09
commit
6dd7fac902
13 changed files with 55 additions and 137 deletions
|
@ -883,7 +883,7 @@ set( VM_JIT_SOURCES
|
|||
common/scripting/jit/jit_store.cpp
|
||||
)
|
||||
|
||||
# Enable fast math for some sources where performance matters (or where the PCH must not be used.) (This would be good for rendering code, but unfortunately that is hopelessly intermingled with the playsim code in engine.cpp.)
|
||||
# Enable fast math for some sources where performance matters (or where the PCH must not be used.)
|
||||
set( FASTMATH_SOURCES
|
||||
|
||||
common/rendering/gl_load/gl_load.c
|
||||
|
@ -958,7 +958,6 @@ set (PCH_SOURCES
|
|||
|
||||
# Todo: Split out the license-safe code from this.
|
||||
build/src/clip.cpp
|
||||
build/src/engine.cpp
|
||||
build/src/mdsprite.cpp
|
||||
|
||||
core/actorinfo.cpp
|
||||
|
|
|
@ -17,17 +17,6 @@ static_assert('\xff' == 255, "Char must be unsigned!");
|
|||
|
||||
#include "printf.h"
|
||||
#include "palette.h"
|
||||
|
||||
//Make all variables in BUILD.H defined in the ENGINE,
|
||||
//and externed in GAME
|
||||
#ifdef engine_c_
|
||||
# define EXTERN
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN int sintable[2048];
|
||||
|
||||
#include "buildtiles.h"
|
||||
#include "c_cvars.h"
|
||||
#include "cmdlib.h"
|
||||
|
@ -86,8 +75,6 @@ enum {
|
|||
|
||||
int32_t getwalldist(vec2_t const in, int const wallnum, vec2_t * const out);
|
||||
|
||||
EXTERN int32_t guniqhudid;
|
||||
|
||||
struct usermaphack_t
|
||||
{
|
||||
FString mhkfile;
|
||||
|
@ -95,25 +82,12 @@ struct usermaphack_t
|
|||
uint8_t md4[16]{};
|
||||
};
|
||||
|
||||
EXTERN int leveltimer;
|
||||
|
||||
EXTERN int32_t Numsprites;
|
||||
EXTERN int32_t display_mirror;
|
||||
|
||||
EXTERN int32_t randomseed;
|
||||
|
||||
EXTERN uint8_t paletteloaded;
|
||||
|
||||
enum {
|
||||
PALETTE_MAIN = 1<<0,
|
||||
PALETTE_SHADE = 1<<1,
|
||||
PALETTE_TRANSLUC = 1<<2,
|
||||
};
|
||||
|
||||
inline int32_t g_visibility = 512, g_relvisibility = 0;
|
||||
|
||||
extern uint8_t globalr, globalg, globalb;
|
||||
|
||||
enum {
|
||||
ENGINECOMPATIBILITY_NONE = 0,
|
||||
ENGINECOMPATIBILITY_19950829, // Powerslave/Exhumed
|
||||
|
@ -121,11 +95,17 @@ enum {
|
|||
ENGINECOMPATIBILITY_19961112, // Duke 3d v1.5, Redneck Rampage
|
||||
};
|
||||
|
||||
EXTERN int32_t enginecompatibility_mode;
|
||||
inline int leveltimer;
|
||||
inline int32_t Numsprites;
|
||||
inline int32_t display_mirror;
|
||||
inline int32_t randomseed;
|
||||
inline uint8_t paletteloaded;
|
||||
inline int32_t g_visibility = 512, g_relvisibility = 0;
|
||||
inline int32_t enginecompatibility_mode;
|
||||
inline int32_t nextvoxid;
|
||||
inline FixedBitArray<MAXVOXELS>voxreserve;
|
||||
|
||||
|
||||
void engineInit(void);
|
||||
|
||||
void setVideoMode();
|
||||
|
||||
class F2DDrawer;
|
||||
|
@ -173,9 +153,6 @@ inline int hitscan(const DVector3& start, const sectortype* startsect, const vec
|
|||
return hitscan(istart, startsect, direction, hitinfo, cliptype);
|
||||
}
|
||||
|
||||
|
||||
extern const int16_t *chsecptr_onextwall;
|
||||
|
||||
inline int32_t krand(void)
|
||||
{
|
||||
randomseed = (randomseed * 27584621) + 1;
|
||||
|
@ -206,7 +183,6 @@ EXTERN_CVAR(Bool, hw_useindexedcolortextures)
|
|||
EXTERN_CVAR(Bool, r_voxels)
|
||||
|
||||
extern int32_t mdtims, omdtims;
|
||||
|
||||
extern int32_t r_rorphase;
|
||||
|
||||
// flags bitset: 1 = don't compress
|
||||
|
@ -215,8 +191,6 @@ int32_t md_loadmodel(const char *fn);
|
|||
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags);
|
||||
// int32_t md_tilehasmodel(int32_t tilenume, int32_t pal);
|
||||
|
||||
EXTERN int32_t nextvoxid;
|
||||
EXTERN FixedBitArray<MAXVOXELS>voxreserve;
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
// TODO: dynamically allocate this
|
||||
|
@ -237,8 +211,8 @@ typedef struct
|
|||
|
||||
# define EXTRATILES (MAXTILES/8)
|
||||
|
||||
EXTERN int32_t mdinited;
|
||||
EXTERN tile2model_t tile2model[MAXTILES+EXTRATILES];
|
||||
inline int32_t mdinited;
|
||||
inline tile2model_t tile2model[MAXTILES+EXTRATILES];
|
||||
|
||||
inline int32_t md_tilehasmodel(int32_t const tilenume, int32_t const pal)
|
||||
{
|
||||
|
|
|
@ -177,16 +177,16 @@ struct md3model_t : public idmodel_t
|
|||
*/
|
||||
};
|
||||
|
||||
EXTERN mdmodel_t **models;
|
||||
inline mdmodel_t **models;
|
||||
|
||||
FGameTexture* mdloadskin(idmodel_t* m, int32_t number, int32_t pal, int32_t surf, bool* exact);
|
||||
void mdinit(void);
|
||||
void freeallmodels(void);
|
||||
int32_t polymost_mddraw(tspritetype* tspr);
|
||||
EXTERN void md3_vox_calcmat_common(tspritetype* tspr, const FVector3 *a0, float f, float mat[16]);
|
||||
void md3_vox_calcmat_common(tspritetype* tspr, const FVector3 *a0, float f, float mat[16]);
|
||||
|
||||
EXTERN int32_t mdpause;
|
||||
EXTERN int32_t nextmodelid;
|
||||
inline int32_t mdpause;
|
||||
inline int32_t nextmodelid;
|
||||
|
||||
#endif // defined USE_OPENGL
|
||||
|
||||
|
|
|
@ -1327,8 +1327,8 @@ int hitscan(const vec3_t& start, const sectortype* startsect, const vec3_t& dire
|
|||
{
|
||||
int32_t x3, y3, x4, y4;
|
||||
int32_t const heinum = spriteGetSlope(actor);
|
||||
int32_t const dax = (heinum * sintable[(actor->int_ang() + 1024) & 2047]) << 1;
|
||||
int32_t const day = (heinum * sintable[(actor->int_ang() + 512) & 2047]) << 1;
|
||||
int32_t const dax = (heinum * -bsin(actor->int_ang())) << 1;
|
||||
int32_t const day = (heinum * bcos(actor->int_ang())) << 1;
|
||||
int32_t const j = (vz << 8) - DMulScale(dax, vy, -day, vx, 15);
|
||||
if (j == 0) continue;
|
||||
if ((cstat & 64) != 0)
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
||||
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
||||
// Ken Silverman's official web site: "http://www.advsys.net/ken"
|
||||
// See the included license file "BUILDLIC.TXT" for license info.
|
||||
//
|
||||
// This file has been modified from Ken Silverman's original release
|
||||
// by Jonathon Fowler (jf@jonof.id.au)
|
||||
// by the EDuke32 team (development@voidpoint.com)
|
||||
|
||||
#define engine_c_
|
||||
|
||||
#include "gl_load.h"
|
||||
#include "build.h"
|
||||
#include "automap.h"
|
||||
|
||||
#include "imagehelpers.h"
|
||||
#include "palette.h"
|
||||
#include "gamecvars.h"
|
||||
#include "c_console.h"
|
||||
#include "v_2ddrawer.h"
|
||||
#include "v_draw.h"
|
||||
#include "stats.h"
|
||||
#include "razemenu.h"
|
||||
#include "version.h"
|
||||
#include "earcut.hpp"
|
||||
#include "gamestate.h"
|
||||
#include "inputstate.h"
|
||||
#include "printf.h"
|
||||
#include "gamecontrol.h"
|
||||
#include "render.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "hw_voxels.h"
|
||||
#include "coreactor.h"
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
# include "mdsprite.h"
|
||||
#include "v_video.h"
|
||||
#include "gl_renderer.h"
|
||||
#endif
|
||||
|
||||
int32_t mdtims, omdtims;
|
||||
|
||||
uint8_t globalr = 255, globalg = 255, globalb = 255;
|
||||
|
||||
//
|
||||
// Internal Engine Functions
|
||||
//
|
||||
|
||||
void engineInit(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
for (i=0; i<=512; i++)
|
||||
sintable[i] = int(sin(i * BAngRadian) * +SINTABLEUNIT);
|
||||
for (i=513; i<1024; i++)
|
||||
sintable[i] = sintable[1024-i];
|
||||
for (i=1024; i<2048; i++)
|
||||
sintable[i] = -sintable[i-1024];
|
||||
|
||||
}
|
||||
|
||||
|
||||
int tilehasmodelorvoxel(int const tilenume, int pal)
|
||||
{
|
||||
return
|
||||
(mdinited && hw_models && tile2model[Ptile2tile(tilenume, pal)].modelid != -1) ||
|
||||
(r_voxels && tiletovox[tilenume] != -1);
|
||||
}
|
|
@ -16,6 +16,8 @@
|
|||
#include "printf.h"
|
||||
#include "hw_voxels.h"
|
||||
|
||||
int32_t mdtims, omdtims;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// just make it shut up. Most of this file will go down the drain anyway soon.
|
||||
#pragma warning(disable:4244)
|
||||
|
|
|
@ -1111,7 +1111,6 @@ int RunGame()
|
|||
gameinfo.mBackButton = "engine/graphics/m_back.png";
|
||||
StartWindow->Progress();
|
||||
|
||||
engineInit();
|
||||
GC::AddMarkerFunc(MarkMap);
|
||||
gi->app_init();
|
||||
StartWindow->Progress();
|
||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "intvec.h"
|
||||
#include "coreactor.h"
|
||||
#include "interpolate.h"
|
||||
#include "hw_voxels.h"
|
||||
|
||||
IntRect viewport3d;
|
||||
|
||||
|
@ -785,6 +786,18 @@ tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor)
|
|||
return tspr;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int tilehasmodelorvoxel(int const tilenume, int pal)
|
||||
{
|
||||
return
|
||||
(mdinited && hw_models && tile2model[Ptile2tile(tilenume, pal)].modelid != -1) ||
|
||||
(r_voxels && tiletovox[tilenume] != -1);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
@ -174,8 +174,6 @@ constexpr double BAngRadian = pi::pi() * (1. / 1024.);
|
|||
constexpr double BAngToDegree = 360. / 2048.;
|
||||
constexpr DAngle DAngleBuildToDeg = DAngle::fromDeg(BAngToDegree);
|
||||
|
||||
extern int sintable[2048];
|
||||
|
||||
inline constexpr double sinscale(const int shift)
|
||||
{
|
||||
return shift >= -BUILDSINBITS ? uint64_t(1) << (BUILDSINBITS + shift) : 1. / (uint64_t(1) << abs(BUILDSINBITS + shift));
|
||||
|
@ -188,15 +186,20 @@ inline constexpr double sinscale(const int shift)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
inline int bsin(const int ang, int shift = 0)
|
||||
{
|
||||
return (shift -= BUILDSINSHIFT) < 0 ? sintable[ang & 2047] >> abs(shift) : sintable[ang & 2047] << shift;
|
||||
}
|
||||
inline double bsinf(const double ang, const int shift = 0)
|
||||
{
|
||||
return g_sinbam(ang * BAMUNIT) * sinscale(shift);
|
||||
}
|
||||
|
||||
inline int bsin(const int ang, int shift = 0)
|
||||
{
|
||||
return (int)bsinf(ang, shift);
|
||||
}
|
||||
|
||||
inline int Sin(int ang)
|
||||
{
|
||||
return (int)bsinf(ang, 16);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -211,15 +214,20 @@ inline double bsinf(const double ang, const int shift = 0)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
inline int bcos(const int ang, int shift = 0)
|
||||
{
|
||||
return (shift -= BUILDSINSHIFT) < 0 ? sintable[(ang + 512) & 2047] >> abs(shift) : sintable[(ang + 512) & 2047] << shift;
|
||||
}
|
||||
inline double bcosf(const double ang, const int shift = 0)
|
||||
{
|
||||
return g_cosbam(ang * BAMUNIT) * sinscale(shift);
|
||||
}
|
||||
|
||||
inline int bcos(const int ang, int shift = 0)
|
||||
{
|
||||
return (int)bcosf(ang, shift);
|
||||
}
|
||||
|
||||
inline int Cos(int ang)
|
||||
{
|
||||
return (int)bcosf(ang, 16);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -536,7 +536,6 @@ void loadMap(const char* filename, int flags, DVector3* pos, int16_t* ang, secto
|
|||
fixSectors();
|
||||
*cursect = validSectorIndex(cursectnum) ? §or[cursectnum] : nullptr;
|
||||
updatesector(*pos, cursect);
|
||||
guniqhudid = 0;
|
||||
fr.Seek(0, FileReader::SeekSet);
|
||||
auto buffer = fr.Read();
|
||||
uint8_t md4[16];
|
||||
|
|
|
@ -193,6 +193,7 @@ void SetLightAndFog(HWDrawInfo* di, FRenderState& state, PalEntry fade, int pale
|
|||
}
|
||||
|
||||
// The shade rgb from the tint is ignored here.
|
||||
state.SetColor(globalr * (1 / 255.f), globalg * (1 / 255.f), globalb * (1 / 255.f), alpha);
|
||||
//state.SetColor(globalr * (1 / 255.f), globalg * (1 / 255.f), globalb * (1 / 255.f), alpha);
|
||||
state.SetColor(1., 1., 1., alpha);
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,8 @@ void HWWall::RenderMirrorSurface(HWDrawInfo *di, FRenderState &state)
|
|||
// Use sphere mapping for this
|
||||
state.SetEffect(EFF_SPHEREMAP);
|
||||
SetLightAndFog(di, state, fade, palette, min<int>(shade, numshades), visibility, alpha);
|
||||
state.SetColor(PalEntry(25, globalr >> 1, globalg >> 1, globalb >> 1));
|
||||
//state.SetColor(PalEntry(25, globalr >> 1, globalg >> 1, globalb >> 1));
|
||||
state.SetColor(PalEntry(25, 128, 128, 128));
|
||||
|
||||
state.SetRenderStyle(STYLE_Add);
|
||||
state.AlphaFunc(Alpha_Greater, 0);
|
||||
|
|
|
@ -72,16 +72,6 @@ void RotateVector(int* dx, int* dy, int nAngle);
|
|||
|
||||
#include "m_fixed.h"
|
||||
|
||||
inline int Sin(int ang)
|
||||
{
|
||||
return sintable[ang & 2047];
|
||||
}
|
||||
|
||||
inline int Cos(int ang)
|
||||
{
|
||||
return sintable[(ang + 512) & 2047];
|
||||
}
|
||||
|
||||
enum SurfaceType {
|
||||
kSurfNone = 0,
|
||||
kSurfStone,
|
||||
|
|
Loading…
Reference in a new issue