Skip to content

Commit

Permalink
Merge branch 'master' into mod_support
Browse files Browse the repository at this point in the history
  • Loading branch information
apanteleev committed Jul 22, 2021
2 parents 4b9cf3b + fab557b commit ae6cd7d
Show file tree
Hide file tree
Showing 57 changed files with 2,752 additions and 553 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
.baseq2/
rogue/
xatrix/
q2pro
q2proded
q2rtx
q2rtxded
game*.so
*.swp
build/
build*/
shader_vkpt
./vkpt
./vkptded
Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ OPTION(CONFIG_VKPT_ENABLE_DEVICE_GROUPS "Enable device groups (multi-gpu) suppor
OPTION(CONFIG_VKPT_ENABLE_IMAGE_DUMPS "Enable image dumping functionality" OFF)
OPTION(CONFIG_USE_CURL "Use CURL for HTTP support" ON)
OPTION(CONFIG_LINUX_PACKAGING_SUPPORT "Enable Linux Packaging support" OFF)
OPTION(CONFIG_LINUX_PACKAGING_SKIP_PKZ "Skip zipping the game contents into .pkz when packaging (for quicker iteration)" OFF)
OPTION(CONFIG_LINUX_STEAM_RUNTIME_SUPPORT "Enable Linux Steam Runtime support" OFF)
IF(WIN32)
SET(DEFAULT_BUILD_GLSLANG OFF)
Expand Down Expand Up @@ -95,9 +96,15 @@ IF(CONFIG_LINUX_PACKAGING_SUPPORT)
set(CPACK_PACKAGE_VERSION_MAJOR ${Q2RTX_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${Q2RTX_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${Q2RTX_VERSION_POINT})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_SECTION "games")

IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm64")
ELSE()
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
ENDIF()

set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")

set(CPACK_PACKAGE_CONTACT "http://nvidia.com/object/support.html")

Expand Down
2 changes: 2 additions & 0 deletions cmake/compileShaders.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ set(SHADER_SOURCE_DEPENDENCIES
${CMAKE_SOURCE_DIR}/src/refresh/vkpt/shader/light_lists.h
${CMAKE_SOURCE_DIR}/src/refresh/vkpt/shader/path_tracer_rgen.h
${CMAKE_SOURCE_DIR}/src/refresh/vkpt/shader/path_tracer.h
${CMAKE_SOURCE_DIR}/src/refresh/vkpt/shader/path_tracer_hit_shaders.h
${CMAKE_SOURCE_DIR}/src/refresh/vkpt/shader/path_tracer_transparency.glsl
${CMAKE_SOURCE_DIR}/src/refresh/vkpt/shader/precomputed_sky.glsl
${CMAKE_SOURCE_DIR}/src/refresh/vkpt/shader/precomputed_sky_params.h
${CMAKE_SOURCE_DIR}/src/refresh/vkpt/shader/projection.glsl
Expand Down
3 changes: 0 additions & 3 deletions inc/client/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ void VID_UpdateGamma(const byte *table);
void *VID_GetCoreAddr(const char *sym);
void *VID_GetProcAddr(const char *sym);

qboolean VID_VideoSync(void);
void VID_VideoWait(void);

void VID_BeginFrame(void);
void VID_EndFrame(void);

Expand Down
8 changes: 4 additions & 4 deletions inc/common/bsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ typedef struct bsp_s {
msurfedge_t *surfedges;
#endif

char *pvs_matrix;
char *pvs2_matrix;
byte *pvs_matrix;
byte *pvs2_matrix;
qboolean pvs_patched;

// WARNING: the 'name' string is actually longer than this, and the bsp_t structure is allocated larger than sizeof(bsp_t) in BSP_Load
Expand Down Expand Up @@ -312,8 +312,8 @@ byte *BSP_ClusterVis(bsp_t *bsp, byte *mask, int cluster, int vis);
mleaf_t *BSP_PointLeaf(mnode_t *node, vec3_t p);
mmodel_t *BSP_InlineModel(bsp_t *bsp, const char *name);

char* BSP_GetPvs(bsp_t *bsp, int cluster);
char* BSP_GetPvs2(bsp_t *bsp, int cluster);
byte* BSP_GetPvs(bsp_t *bsp, int cluster);
byte* BSP_GetPvs2(bsp_t *bsp, int cluster);

qboolean BSP_SavePatchedPVS(bsp_t *bsp);

Expand Down
131 changes: 131 additions & 0 deletions inc/format/iqm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
===========================================================================
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/

#ifndef __IQM_H__
#define __IQM_H__

#define IQM_MAGIC "INTERQUAKEMODEL"
#define IQM_VERSION 2

#define IQM_IDENT (('E'<<24)+('T'<<16)+('N'<<8)+'I')

#define IQM_MAX_JOINTS 256

typedef struct iqmheader
{
char magic[16];
unsigned int version;
unsigned int filesize;
unsigned int flags;
unsigned int num_text, ofs_text;
unsigned int num_meshes, ofs_meshes;
unsigned int num_vertexarrays, num_vertexes, ofs_vertexarrays;
unsigned int num_triangles, ofs_triangles, ofs_adjacency;
unsigned int num_joints, ofs_joints;
unsigned int num_poses, ofs_poses;
unsigned int num_anims, ofs_anims;
unsigned int num_frames, num_framechannels, ofs_frames, ofs_bounds;
unsigned int num_comment, ofs_comment;
unsigned int num_extensions, ofs_extensions;
} iqmHeader_t;

typedef struct iqmmesh
{
unsigned int name;
unsigned int material;
unsigned int first_vertex, num_vertexes;
unsigned int first_triangle, num_triangles;
} iqmMesh_t;

enum
{
IQM_POSITION = 0,
IQM_TEXCOORD = 1,
IQM_NORMAL = 2,
IQM_TANGENT = 3,
IQM_BLENDINDEXES = 4,
IQM_BLENDWEIGHTS = 5,
IQM_COLOR = 6,
IQM_CUSTOM = 0x10
};

enum
{
IQM_BYTE = 0,
IQM_UBYTE = 1,
IQM_SHORT = 2,
IQM_USHORT = 3,
IQM_INT = 4,
IQM_UINT = 5,
IQM_HALF = 6,
IQM_FLOAT = 7,
IQM_DOUBLE = 8,
};

typedef struct iqmtriangle
{
unsigned int vertex[3];
} iqmTriangle_t;

typedef struct iqmjoint
{
unsigned int name;
int parent;
float translate[3], rotate[4], scale[3];
} iqmJoint_t;

typedef struct iqmpose
{
int parent;
unsigned int mask;
float channeloffset[10];
float channelscale[10];
} iqmPose_t;

typedef struct iqmanim
{
unsigned int name;
unsigned int first_frame, num_frames;
float framerate;
unsigned int flags;
} iqmAnim_t;

enum
{
IQM_LOOP = 1<<0
};

typedef struct iqmvertexarray
{
unsigned int type;
unsigned int flags;
unsigned int format;
unsigned int size;
unsigned int offset;
} iqmVertexArray_t;

typedef struct iqmbounds
{
float bbmin[3], bbmax[3];
float xyradius, radius;
} iqmBounds_t;

#endif

73 changes: 70 additions & 3 deletions inc/refresh/models.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,65 @@ typedef enum
MCLASS_FLARE
} model_class_t;

typedef struct
{
vec3_t translate;
quat_t rotate;
vec3_t scale;
} iqm_transform_t;

typedef struct
{
char name[MAX_QPATH];
uint32_t first_frame;
uint32_t num_frames;
qboolean loop;
} iqm_anim_t;

// inter-quake-model
typedef struct
{
uint32_t num_vertexes;
uint32_t num_triangles;
uint32_t num_frames;
uint32_t num_meshes;
uint32_t num_joints;
uint32_t num_poses;
uint32_t num_animations;
struct iqm_mesh_s* meshes;

uint32_t* indices;

// vertex arrays
float* positions;
float* texcoords;
float* normals;
float* tangents;
byte* colors;
byte* blend_indices; // byte4 per vertex
float* blend_weights; // float4 per vertex

char* jointNames;
int* jointParents;
float* bindJoints; // [num_joints * 12]
float* invBindJoints; // [num_joints * 12]
iqm_transform_t* poses; // [num_frames * num_poses]
float* bounds;

iqm_anim_t* animations;
} iqm_model_t;

// inter-quake-model mesh
typedef struct iqm_mesh_s
{
char name[MAX_QPATH];
char material[MAX_QPATH];
iqm_model_t* data;
uint32_t first_vertex, num_vertexes;
uint32_t first_triangle, num_triangles;
uint32_t first_influence, num_influences;
} iqm_mesh_t;

typedef struct model_s {
enum {
MOD_FREE,
Expand Down Expand Up @@ -81,13 +140,17 @@ typedef struct model_s {
// sprite models
struct mspriteframe_s *spriteframes;
qboolean sprite_vertical;

iqm_model_t* iqmData;
} model_t;

extern model_t r_models[];
extern int r_numModels;

extern int registration_sequence;

typedef struct entity_s entity_t;

// these are implemented in r_models.c
void MOD_FreeUnused(void);
void MOD_FreeAll(void);
Expand All @@ -100,12 +163,16 @@ qhandle_t R_RegisterModel(const char *name);
struct dmd2header_s;
qerror_t MOD_ValidateMD2(struct dmd2header_s *header, size_t length);

qerror_t MOD_LoadIQM_Base(model_t* mod, const void* rawdata, size_t length, const char* mod_name);
qboolean R_ComputeIQMTransforms(const iqm_model_t* model, const entity_t* entity, float* pose_matrices);

// these are implemented in [gl,sw]_models.c
typedef qerror_t (*mod_load_t)(model_t *, const void *, size_t);
extern qerror_t (*MOD_LoadMD2)(model_t *model, const void *rawdata, size_t length);
typedef qerror_t (*mod_load_t)(model_t *, const void *, size_t, const char*);
extern qerror_t (*MOD_LoadMD2)(model_t *model, const void *rawdata, size_t length, const char* mod_name);
#if USE_MD3
extern qerror_t (*MOD_LoadMD3)(model_t *model, const void *rawdata, size_t length);
extern qerror_t (*MOD_LoadMD3)(model_t *model, const void *rawdata, size_t length, const char* mod_name);
#endif
extern qerror_t(*MOD_LoadIQM)(model_t* model, const void* rawdata, size_t length, const char* mod_name);
extern void (*MOD_Reference)(model_t *model);

#endif // MODELS_H
3 changes: 1 addition & 2 deletions inc/refresh/refresh.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ typedef struct refdef_s {
typedef enum {
QVF_ACCELERATED = (1 << 0),
QVF_GAMMARAMP = (1 << 1),
QVF_FULLSCREEN = (1 << 2),
QVF_VIDEOSYNC = (1 << 3)
QVF_FULLSCREEN = (1 << 2)
} vidFlags_t;

typedef struct {
Expand Down
3 changes: 3 additions & 0 deletions inc/shared/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#elif _WIN32
#define CPUSTRING "x86"
#define BUILDSTRING "Win32"
#elif __aarch64__
#define CPUSTRING "aarch64"
#define BUILDSTRING "Linux"
#elif __x86_64__
#define CPUSTRING "x86_64"
#define BUILDSTRING "Linux"
Expand Down
4 changes: 4 additions & 0 deletions inc/shared/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ typedef vec_t vec3_t[3];
typedef vec_t vec4_t[4];
typedef vec_t vec5_t[5];

typedef vec_t quat_t[4];

typedef float mat4_t[16];

typedef union {
Expand Down Expand Up @@ -261,6 +263,8 @@ static inline float Q_fabs(float f)
#define Vector4Negate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2],(b)[3]=-(a)[3])
#define Vector4Set(v, a, b, c, d) ((v)[0]=(a),(v)[1]=(b),(v)[2]=(c),(v)[3]=(d))

#define QuatCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])

void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
vec_t VectorNormalize(vec3_t v); // returns vector length
vec_t VectorNormalize2(vec3_t v, vec3_t out);
Expand Down
Loading

0 comments on commit ae6cd7d

Please sign in to comment.