Skip to content

Commit

Permalink
CMake: added 'SOFT' flag to compile with compatible structures for so…
Browse files Browse the repository at this point in the history
…ftware engine
  • Loading branch information
SmileyAG authored and YaLTeR committed Mar 5, 2023
1 parent 66232d9 commit bc6425f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required (VERSION 3.12)

option(COF "Set COF_BUILD preprocessor flag if enabled" OFF)
option(SOFT "Set SOFTWARE_BUILD preprocessor flag if enabled" OFF)

set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")

Expand Down Expand Up @@ -59,6 +60,10 @@ if (MSVC)
if (COF)
add_definitions(-DCOF_BUILD)
endif()

if (SOFT)
add_definitions(-DSOFTWARE_BUILD)
endif()
else ()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=pentium-m -mfpmath=387 -mno-sse -g -Wall -Wextra -Wno-unused-parameter")

Expand Down
59 changes: 59 additions & 0 deletions HLSDK/common/com_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,23 @@ typedef struct texture_s
{
char name[16];
unsigned width, height;

#ifndef SOFTWARE_BUILD
int gl_texturenum;
struct msurface_s *texturechain; // for gl_texsort drawing
#endif

int anim_total; // total tenths in sequence ( 0 = no)
int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s *anim_next; // in the animation sequence
struct texture_s *alternate_anims; // bmodels in frame 1 use these
unsigned offsets[MIPLEVELS]; // four mip maps stored

#ifdef SOFTWARE_BUILD
unsigned paloffset;
#else
byte *pPal;
#endif
} texture_t;

typedef struct
Expand All @@ -120,7 +129,11 @@ typedef struct mnode_s
int contents; // 0, to differentiate from leafs
int visframe; // node needs to be traversed if current

#ifdef SOFTWARE_BUILD
short minmaxs[6]; // for bounding box culling
#else
float minmaxs[6]; // for bounding box culling
#endif

struct mnode_s *parent;

Expand All @@ -140,11 +153,20 @@ struct decal_s
{
decal_t *pnext; // linked list for each surface
msurface_t *psurface; // Surface id for persistence / unlinking

#ifdef SOFTWARE_BUILD
short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats)
short dy;
short texture; // Decal texture
byte scale; // Pixel scale
byte flags; // Decal flags
#else
float dx; // local texture coordinates
float dy;
float scale; // Pixel scale
short texture; // Decal texture
short flags; // Decal flags
#endif
short entityIndex; // Entity this is attached to
};

Expand All @@ -154,7 +176,11 @@ typedef struct mleaf_s
int contents; // wil be a negative contents number
int visframe; // node needs to be traversed if current

#ifdef SOFTWARE_BUILD
short minmaxs[6]; // for bounding box culling
#else
float minmaxs[6]; // for bounding box culling
#endif

struct mnode_s *parent;

Expand All @@ -179,6 +205,38 @@ typedef struct glpoly_s
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
} glpoly_t;

#ifdef SOFTWARE_BUILD
struct msurface_s
{
int visframe; // should be drawn when node is crossed

int dlightframe; // last frame the surface was checked by an animated light
int dlightbits; // dynamically generated. Indicates if the surface illumination
// is modified by an animated light.

mplane_t *plane; // pointer to shared plane
int flags; // see SURF_ #defines

int firstedge; // look up in model->surfedges[], negative numbers
int numedges; // are backwards edges

// surface generation data
struct surfcache_s *cachespots[MIPLEVELS];

short texturemins[2]; // smallest s/t position on the surface.
short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces

mtexinfo_t *texinfo;

// lighting info
byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights
// no one surface can be effected by more than 4
// animated lights.
color24 *samples;

decal_t *pdecals;
};
#else
struct msurface_s
{
int visframe; // should be drawn when node is crossed
Expand Down Expand Up @@ -212,6 +270,7 @@ struct msurface_s
color24 *samples; // note: this is the actual lightmap data for this surface
decal_t *pdecals;
};
#endif

typedef struct
{
Expand Down

0 comments on commit bc6425f

Please sign in to comment.