2018-04-13 18:23:45 +02:00
|
|
|
/*
|
|
|
|
mod_local.h - model loader
|
|
|
|
Copyright (C) 2007 Uncle Mike
|
|
|
|
|
|
|
|
This program 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOD_LOCAL_H
|
|
|
|
#define MOD_LOCAL_H
|
|
|
|
|
2019-03-16 05:15:06 +01:00
|
|
|
//#include "common.h"
|
2018-04-13 18:23:45 +02:00
|
|
|
#include "edict.h"
|
|
|
|
#include "eiface.h"
|
2019-02-24 16:45:27 +01:00
|
|
|
#include "ref_api.h"
|
2019-10-26 14:42:00 +02:00
|
|
|
#include "studio.h"
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
#define LM_SAMPLE_SIZE 16
|
|
|
|
#define LM_SAMPLE_EXTRASIZE 8
|
|
|
|
|
|
|
|
#define MAX_MAP_WADS 256 // max wads that can be referenced per one map
|
|
|
|
|
|
|
|
#define CHECKVISBIT( vis, b ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] & (1 << ((b) & 7))) : (byte)false )
|
|
|
|
#define SETVISBIT( vis, b )( void ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] |= (1 << ((b) & 7))) : (byte)false )
|
|
|
|
#define CLEARVISBIT( vis, b )( void ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] &= ~(1 << ((b) & 7))) : (byte)false )
|
|
|
|
|
|
|
|
#define REFPVS_RADIUS 2.0f // radius for rendering
|
|
|
|
#define FATPVS_RADIUS 8.0f // FatPVS use radius smaller than the FatPHS
|
|
|
|
#define FATPHS_RADIUS 16.0f
|
|
|
|
|
|
|
|
#define WORLD_INDEX (1) // world index is always 1
|
|
|
|
|
|
|
|
typedef struct consistency_s
|
|
|
|
{
|
|
|
|
const char *filename;
|
|
|
|
int orig_index;
|
|
|
|
int check_type;
|
|
|
|
qboolean issound;
|
|
|
|
int value;
|
|
|
|
vec3_t mins;
|
|
|
|
vec3_t maxs;
|
|
|
|
} consistency_t;
|
|
|
|
|
|
|
|
#define FCRC_SHOULD_CHECKSUM BIT( 0 )
|
|
|
|
#define FCRC_CHECKSUM_DONE BIT( 1 )
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int flags;
|
|
|
|
CRC32_t initialCRC;
|
|
|
|
} model_info_t;
|
|
|
|
|
|
|
|
// values for model_t's needload
|
|
|
|
#define NL_UNREFERENCED 0 // this model can be freed after sequence precaching is done
|
|
|
|
#define NL_NEEDS_LOADED 1
|
|
|
|
#define NL_PRESENT 2
|
|
|
|
|
2018-06-09 00:28:35 +02:00
|
|
|
typedef struct hullnode_s
|
|
|
|
{
|
|
|
|
struct hullnode_s *next;
|
|
|
|
struct hullnode_s *prev;
|
|
|
|
} hullnode_t;
|
|
|
|
|
|
|
|
typedef struct winding_s
|
|
|
|
{
|
|
|
|
const mplane_t *plane;
|
|
|
|
struct winding_s *pair;
|
|
|
|
hullnode_t chain;
|
|
|
|
int numpoints;
|
|
|
|
vec3_t p[4]; // variable sized
|
|
|
|
} winding_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
hullnode_t polys;
|
|
|
|
uint num_polys;
|
|
|
|
} hull_model_t;
|
|
|
|
|
2018-04-13 18:23:45 +02:00
|
|
|
|
2019-02-24 16:45:27 +01:00
|
|
|
typedef struct world_static_s
|
2018-04-13 18:23:45 +02:00
|
|
|
{
|
|
|
|
qboolean loading; // true if worldmodel is loading
|
|
|
|
int flags; // misc flags
|
|
|
|
|
|
|
|
// mapstats info
|
|
|
|
char message[2048]; // just for debug
|
|
|
|
char compiler[256]; // map compiler
|
|
|
|
char generator[256]; // map editor
|
|
|
|
|
2018-06-09 00:28:35 +02:00
|
|
|
hull_model_t *hull_models;
|
|
|
|
int num_hull_models;
|
|
|
|
|
2019-06-17 06:05:36 +02:00
|
|
|
// out pointers to light data
|
|
|
|
color24 *deluxedata; // deluxemap data pointer
|
|
|
|
byte *shadowdata; // occlusion data pointer
|
|
|
|
|
2018-04-13 18:23:45 +02:00
|
|
|
// visibility info
|
|
|
|
size_t visbytes; // cluster size
|
|
|
|
size_t fatbytes; // fatpvs size
|
|
|
|
|
|
|
|
// world bounds
|
|
|
|
vec3_t mins; // real accuracy world bounds
|
|
|
|
vec3_t maxs;
|
|
|
|
vec3_t size;
|
2019-07-27 12:27:40 +02:00
|
|
|
|
|
|
|
// tree visualization stuff
|
|
|
|
int recursion_level;
|
|
|
|
int max_recursion;
|
2018-04-13 18:23:45 +02:00
|
|
|
} world_static_t;
|
|
|
|
|
2019-03-16 12:15:05 +01:00
|
|
|
#ifndef REF_DLL
|
2018-04-13 18:23:45 +02:00
|
|
|
extern world_static_t world;
|
2021-06-01 18:28:52 +02:00
|
|
|
extern poolhandle_t com_studiocache;
|
2018-04-13 18:23:45 +02:00
|
|
|
extern model_t *loadmodel;
|
|
|
|
extern convar_t *mod_studiocache;
|
|
|
|
extern convar_t *r_wadtextures;
|
2018-06-09 00:28:35 +02:00
|
|
|
extern convar_t *r_showhull;
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// model.c
|
|
|
|
//
|
|
|
|
void Mod_Init( void );
|
2019-03-17 12:26:57 +01:00
|
|
|
void Mod_FreeModel( model_t *mod );
|
2018-04-13 18:23:45 +02:00
|
|
|
void Mod_FreeAll( void );
|
|
|
|
void Mod_Shutdown( void );
|
|
|
|
void Mod_ClearUserData( void );
|
|
|
|
model_t *Mod_LoadWorld( const char *name, qboolean preload );
|
|
|
|
void *Mod_Calloc( int number, size_t size );
|
|
|
|
void *Mod_CacheCheck( struct cache_user_s *c );
|
|
|
|
void Mod_LoadCacheFile( const char *path, struct cache_user_s *cu );
|
|
|
|
void *Mod_AliasExtradata( model_t *mod );
|
|
|
|
void *Mod_StudioExtradata( model_t *mod );
|
|
|
|
model_t *Mod_FindName( const char *name, qboolean trackCRC );
|
|
|
|
model_t *Mod_LoadModel( model_t *mod, qboolean crash );
|
|
|
|
model_t *Mod_ForName( const char *name, qboolean crash, qboolean trackCRC );
|
|
|
|
qboolean Mod_ValidateCRC( const char *name, CRC32_t crc );
|
|
|
|
void Mod_NeedCRC( const char *name, qboolean needCRC );
|
|
|
|
void Mod_FreeUnused( void );
|
2018-04-19 23:51:17 +02:00
|
|
|
model_t *Mod_Handle( int handle );
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// mod_bmodel.c
|
|
|
|
//
|
|
|
|
void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *loaded );
|
|
|
|
qboolean Mod_TestBmodelLumps( const char *name, const byte *mod_base, qboolean silent );
|
|
|
|
qboolean Mod_HeadnodeVisible( mnode_t *node, const byte *visbits, int *lastleaf );
|
|
|
|
int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, qboolean merge, qboolean fullvis );
|
|
|
|
qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbits );
|
|
|
|
int Mod_CheckLump( const char *filename, const int lump, int *lumpsize );
|
|
|
|
int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize );
|
|
|
|
int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize );
|
|
|
|
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node );
|
|
|
|
void Mod_AmbientLevels( const vec3_t p, byte *pvolumes );
|
|
|
|
int Mod_SampleSizeForFace( msurface_t *surf );
|
|
|
|
byte *Mod_GetPVSForPoint( const vec3_t p );
|
|
|
|
void Mod_UnloadBrushModel( model_t *mod );
|
|
|
|
void Mod_PrintWorldStats_f( void );
|
|
|
|
|
2018-06-09 00:28:35 +02:00
|
|
|
//
|
|
|
|
// mod_dbghulls.c
|
|
|
|
//
|
|
|
|
void Mod_InitDebugHulls( void );
|
|
|
|
void Mod_CreatePolygonsForHull( int hullnum );
|
|
|
|
void Mod_ReleaseHullPolygons( void );
|
|
|
|
|
2018-04-13 18:23:45 +02:00
|
|
|
//
|
|
|
|
// mod_studio.c
|
|
|
|
//
|
2019-03-15 19:23:59 +01:00
|
|
|
void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded );
|
|
|
|
void Mod_UnloadStudioModel( model_t *mod );
|
2018-04-13 18:23:45 +02:00
|
|
|
void Mod_InitStudioAPI( void );
|
|
|
|
void Mod_InitStudioHull( void );
|
|
|
|
void Mod_ResetStudioAPI( void );
|
|
|
|
const char *Mod_StudioTexName( const char *modname );
|
|
|
|
qboolean Mod_GetStudioBounds( const char *name, vec3_t mins, vec3_t maxs );
|
|
|
|
void Mod_StudioGetAttachment( const edict_t *e, int iAttachment, float *org, float *ang );
|
|
|
|
void Mod_GetBonePosition( const edict_t *e, int iBone, float *org, float *ang );
|
|
|
|
hull_t *Mod_HullForStudio( model_t *m, float frame, int seq, vec3_t ang, vec3_t org, vec3_t size, byte *pcnt, byte *pbl, int *hitboxes, edict_t *ed );
|
|
|
|
void R_StudioSlerpBones( int numbones, vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s );
|
2018-04-17 02:53:01 +02:00
|
|
|
void R_StudioCalcBoneQuaternion( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, vec4_t q );
|
|
|
|
void R_StudioCalcBonePosition( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, vec3_t adj, vec3_t pos );
|
|
|
|
void *R_StudioGetAnim( studiohdr_t *m_pStudioHeader, model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc );
|
2018-04-13 18:23:45 +02:00
|
|
|
void Mod_StudioComputeBounds( void *buffer, vec3_t mins, vec3_t maxs, qboolean ignore_sequences );
|
|
|
|
int Mod_HitgroupForStudioHull( int index );
|
|
|
|
void Mod_ClearStudioCache( void );
|
|
|
|
|
2019-03-06 14:23:33 +01:00
|
|
|
//
|
|
|
|
// mod_sprite.c
|
|
|
|
//
|
|
|
|
void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, uint texFlags );
|
2019-03-16 12:15:05 +01:00
|
|
|
#endif
|
2019-03-06 14:23:33 +01:00
|
|
|
|
2018-04-17 02:53:01 +02:00
|
|
|
#endif//MOD_LOCAL_H
|