X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=model_shared.h;h=cb8a15015a494bb5a87a7a3fd9cdf8d78dfc8bba;hb=569035fb5d987a2ebcac65c5c2657d86556c24b3;hp=a911946dc86fe5ca93552e950f83484105964a1e;hpb=ec3f709602d4eb7697a130fbcc483700ad571c1a;p=xonotic%2Fdarkplaces.git diff --git a/model_shared.h b/model_shared.h index a911946d..cb8a1501 100644 --- a/model_shared.h +++ b/model_shared.h @@ -144,33 +144,43 @@ struct trace_s; typedef struct model_brush_s { + // true if this model is a HalfLife .bsp file + qboolean ishlbsp; + // string of entity definitions (.map format) char *entities; + // number of submodels in this map (just used by server to know how many + // submodels to load) + int numsubmodels; + // common functions + int (*SuperContentsFromNativeContents)(struct model_s *model, int nativecontents); + int (*NativeContentsFromSuperContents)(struct model_s *model, int supercontents); + qbyte *(*GetPVS)(struct model_s *model, const vec3_t p); int (*FatPVS)(struct model_s *model, const vec3_t org, vec_t radius, qbyte *pvsbuffer, int pvsbufferlength); int (*BoxTouchingPVS)(struct model_s *model, const qbyte *pvs, const vec3_t mins, const vec3_t maxs); void (*LightPoint)(struct model_s *model, const vec3_t p, vec3_t ambientcolor, vec3_t diffusecolor, vec3_t diffusenormal); void (*FindNonSolidLocation)(struct model_s *model, const vec3_t in, vec3_t out, vec_t radius); - void (*TraceBox)(struct model_s *model, struct trace_s *trace, const vec3_t boxstartmins, const vec3_t boxstartmaxs, const vec3_t boxendmins, const vec3_t boxendmaxs); + // these are actually only found on brushq1, but NULL is handled gracefully + void (*AmbientSoundLevelsForPoint)(struct model_s *model, const vec3_t p, qbyte *out, int outsize); + void (*RoundUpToHullSize)(struct model_s *cmodel, const vec3_t inmins, const vec3_t inmaxs, vec3_t outmins, vec3_t outmaxs); } model_brush_t; typedef struct model_brushq1_s { - // true if this model is a HalfLife .bsp file - qboolean ishlbsp; - int firstmodelsurface, nummodelsurfaces; // lightmap format, set to r_lightmaprgba when model is loaded int lightmaprgba; - int numsubmodels; dmodel_t *submodels; int numplanes; mplane_t *planes; - // number of visible leafs, not counting 0 (solid) + // number of actual leafs (including 0 which is solid) int numleafs; + // visible leafs, not counting 0 (solid) + int visleafs; mleaf_t *leafs; int numvertexes; @@ -191,7 +201,6 @@ typedef struct model_brushq1_s int *surfacepvsframes; msurface_t *surfacepvsnext; surfmesh_t *entiremesh; - surfmesh_t *surfmeshes; int numsurfedges; int *surfedges; @@ -207,7 +216,11 @@ typedef struct model_brushq1_s int numtextures; texture_t *textures; - qbyte *visdata; + int num_compressedpvs; + qbyte *data_compressedpvs; + qbyte *data_decompressedpvs; + + int num_lightdata; qbyte *lightdata; int numportals; @@ -242,7 +255,6 @@ typedef struct model_brushq1_s float light_ambient; mleaf_t *(*PointInLeaf)(struct model_s *model, const float *p); - qbyte *(*LeafPVS)(struct model_s *model, mleaf_t *leaf); void (*BuildPVSTextureChains)(struct model_s *model); } model_brushq1_t; @@ -254,11 +266,16 @@ typedef struct model_brushq2_s model_brushq2_t; */ +#define Q3MTEXTURERENDERFLAGS_NODRAW 1 +#define Q3MTEXTURERENDERFLAGS_SKY 2 + typedef struct q3mtexture_s { char name[Q3PATHLENGTH]; int surfaceflags; - int contents; + int nativecontents; + int supercontents; + int renderflags; int number; skinframe_t skin; @@ -267,8 +284,12 @@ q3mtexture_t; typedef struct q3mnode_s { + //this part shared between node and leaf int isnode; // true struct q3mnode_s *parent; + vec3_t mins; + vec3_t maxs; + // this part unique to nodes struct mplane_s *plane; struct q3mnode_s *children[2]; } @@ -276,16 +297,18 @@ q3mnode_t; typedef struct q3mleaf_s { + //this part shared between node and leaf int isnode; // false struct q3mnode_s *parent; + vec3_t mins; + vec3_t maxs; + // this part unique to leafs int clusterindex; int areaindex; int numleaffaces; struct q3mface_s **firstleafface; int numleafbrushes; struct q3mbrush_s **firstleafbrush; - vec3_t mins; - vec3_t maxs; } q3mleaf_t; @@ -329,21 +352,29 @@ typedef struct q3mface_s struct q3mtexture_s *texture; struct q3meffect_s *effect; rtexture_t *lightmaptexture; + int collisions; // performs per triangle collisions on this surface + int collisionmarkframe; // don't collide twice in one trace int type; int firstvertex; - int numvertices; int firstelement; - int numelements; int patchsize[2]; + // used for processing + int markframe; + // (world only) visframe == r_framecount means it is visible this frame + int visframe; + // bounding box for culling + float mins[3]; + float maxs[3]; + int num_vertices; + int num_triangles; float *data_vertex3f; - float *data_texturetexcoord2f; - float *data_lightmaptexcoord2f; + float *data_texcoordtexture2f; + float *data_texcoordlightmap2f; float *data_svector3f; float *data_tvector3f; float *data_normal3f; float *data_color4f; - int numtriangles; int *data_element3i; int *data_neighbor3i; } @@ -351,6 +382,10 @@ q3mface_t; typedef struct model_brushq3_s { + // if non-zero this is a submodel + // (this is the number of the submodel, an index into data_models) + int submodel; + int num_textures; q3mtexture_t *data_textures; @@ -372,7 +407,7 @@ typedef struct model_brushq3_s int num_models; q3mmodel_t *data_models; // each submodel gets its own model struct so this is different for each. - q3mmodel_t data_thismodel; + q3mmodel_t *data_thismodel; int num_brushes; q3mbrush_t *data_brushes; @@ -382,8 +417,8 @@ typedef struct model_brushq3_s int num_vertices; float *data_vertex3f; - float *data_texturetexcoord2f; - float *data_lightmaptexcoord2f; + float *data_texcoordtexture2f; + float *data_texcoordlightmap2f; float *data_svector3f; float *data_tvector3f; float *data_normal3f; @@ -477,12 +512,12 @@ typedef struct model_s void(*DrawSky)(struct entity_render_s *ent); // draw the model using lightmap/dlight shading void(*Draw)(struct entity_render_s *ent); - // draw a fake shadow for the model - void(*DrawFakeShadow)(struct entity_render_s *ent); // draw a shadow volume for the model based on light source void(*DrawShadowVolume)(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius); // draw the lighting on a model (through stencil) void(*DrawLight)(struct entity_render_s *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltofilter, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz); + // trace a box against this model + void (*TraceBox)(struct model_s *model, int frame, struct trace_s *trace, const vec3_t boxstartmins, const vec3_t boxstartmaxs, const vec3_t boxendmins, const vec3_t boxendmaxs, int hitsupercontentsmask); // fields belonging to each type of model model_alias_t alias; model_sprite_t sprite; @@ -494,6 +529,8 @@ typedef struct model_s model_brushq3_t brushq3; // skin files can have different tags for each skin overridetagnameset_t *data_overridetagnamesforskin; + // flags this model for offseting sounds to the model center (used by brush models) + int soundfromcenter; } model_t; @@ -506,6 +543,8 @@ extern rtexture_t *mod_shared_detailtextures[NUM_DETAILTEXTURES]; // every texture must be in a pool... extern rtexturepool_t *mod_shared_texturepool; +extern rtexture_t *mod_shared_distorttexture[64]; + // model loading extern model_t *loadmodel; extern qbyte *mod_base; @@ -548,6 +587,10 @@ void Mod_ShadowMesh_Free(shadowmesh_t *mesh); int Mod_LoadSkinFrame(skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture); int Mod_LoadSkinFrame_Internal(skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture, qbyte *skindata, int width, int height); +// used for talking to the QuakeC mainly +int Mod_Q1BSP_NativeContentsFromSuperContents(struct model_s *model, int supercontents); +int Mod_Q1BSP_SuperContentsFromNativeContents(struct model_s *model, int nativecontents); + extern cvar_t r_mipskins; typedef struct skinfileitem_s @@ -569,5 +612,7 @@ skinfile_t *Mod_LoadSkinFiles(void); void Mod_FreeSkinFiles(skinfile_t *skinfile); int Mod_CountSkinFiles(skinfile_t *skinfile); +int Mod_RemoveDegenerateTriangles(int numtriangles, const int *inelement3i, int *outelement3i, const float *vertex3f); + #endif // __MODEL__