From 2fa6c1c686a631ca835285d9f01eddf0dd58de85 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 17 Jul 2003 14:57:05 +0000 Subject: [PATCH] moved all type-specific model fields to respective structures (alias, sprite, brush) renamed model_t brush to brushq1, and created brush, brushq2, brushq3, currently brush only has entities, all else is type specific wrote the beginnings of a q3 bsp loader (and of course the headers) added functions CL_PointContents and CL_FindNonSolidLocation to simplify queries of world model (and make it more maintainable when q3bsp support is finished) added r_shadow_glossintensity cvar (default 1) for glossmap textures added r_shadow_gloss2intensity cvar (default 0.25) for forced gloss git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3284 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_collision.c | 15 + cl_collision.h | 4 +- cl_main.c | 3 +- cl_parse.c | 235 +++++++------- cl_particles.c | 18 +- cl_screen.c | 3 +- collision.c | 38 +-- gl_models.c | 32 +- gl_rmain.c | 22 +- gl_rsurf.c | 138 ++++---- model_alias.c | 202 ++++++------ model_brush.c | 852 ++++++++++++++++++++++++++++++++++++------------- model_brush.h | 170 ++++++++++ model_shared.h | 327 ++++++++++++++----- model_sprite.c | 28 +- portals.c | 10 +- pr_cmds.c | 18 +- protocol.h | 28 ++ r_light.c | 48 +-- r_shadow.c | 49 +-- r_sprites.c | 6 +- snd_dma.c | 6 +- sv_light.c | 12 +- sv_main.c | 16 +- sv_move.c | 4 +- sv_phys.c | 8 +- view.c | 3 +- 27 files changed, 1541 insertions(+), 754 deletions(-) diff --git a/cl_collision.c b/cl_collision.c index 8269bebb..dfbc0b80 100644 --- a/cl_collision.c +++ b/cl_collision.c @@ -90,3 +90,18 @@ float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t return maxfrac; } +void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius) +{ + // FIXME: check multiple brush models + if (cl.worldmodel && cl.worldmodel->brushq1.FindNonSolidLocation) + cl.worldmodel->brushq1.FindNonSolidLocation(cl.worldmodel, in, out, radius); +} + +int CL_PointContents(const vec3_t p) +{ + // FIXME: check multiple brush models + if (cl.worldmodel && cl.worldmodel->brushq1.PointContents) + return cl.worldmodel->brushq1.PointContents(cl.worldmodel, p); + return CONTENTS_EMPTY; +} + diff --git a/cl_collision.h b/cl_collision.h index 9e4cda56..c7ba4022 100644 --- a/cl_collision.h +++ b/cl_collision.h @@ -6,6 +6,8 @@ // (leafs matching contents are considered empty, others are solid) extern int cl_traceline_endcontents; // set by TraceLine -float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels, entity_render_t **hitent); +float CL_TraceLine(const vec3_t start, const vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels, entity_render_t **hitent); +void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius); +int CL_PointContents(const vec3_t p); #endif diff --git a/cl_main.c b/cl_main.c index c9a2b18b..8522d7c2 100644 --- a/cl_main.c +++ b/cl_main.c @@ -436,8 +436,7 @@ dlightsetup: //Con_Printf("dlight %i : %f %f %f : %f %f %f\n", i, org[0], org[1], org[2], red * radius, green * radius, blue * radius); memset (dl, 0, sizeof(*dl)); dl->ent = ent; - if (cl.worldmodel) - cl.worldmodel->FindNonSolidLocation(cl.worldmodel, org, dl->origin, 6); + CL_FindNonSolidLocation(org, dl->origin, 6); //VectorCopy(org, dl->origin); dl->radius = radius; dl->color[0] = red; diff --git a/cl_parse.c b/cl_parse.c index 6375d290..57b98790 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // cl_parse.c -- parse a message received from the server #include "quakedef.h" +#include "cl_collision.h" char *svc_strings[128] = { @@ -989,7 +990,7 @@ void CL_ParseBeam (model_t *m, int lightning) Con_Printf ("beam list overflow!\n"); } -void CL_ParseTempEntity (void) +void CL_ParseTempEntity(void) { int type; vec3_t pos; @@ -1001,136 +1002,136 @@ void CL_ParseTempEntity (void) float velspeed, radius; qbyte *tempcolor; - type = MSG_ReadByte (); + type = MSG_ReadByte(); switch (type) { case TE_WIZSPIKE: // spike hitting wall MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); - CL_AllocDlight (NULL, pos, 50, 0.25f, 1.00f, 0.25f, 250, 0.2); - CL_RunParticleEffect (pos, vec3_origin, 20, 30); - S_StartSound (-1, 0, cl_sfx_wizhit, pos, 1, 1); + CL_FindNonSolidLocation(pos, pos, 4); + CL_AllocDlight(NULL, pos, 50, 0.25f, 1.00f, 0.25f, 250, 0.2); + CL_RunParticleEffect(pos, vec3_origin, 20, 30); + S_StartSound(-1, 0, cl_sfx_wizhit, pos, 1, 1); break; case TE_KNIGHTSPIKE: // spike hitting wall MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); - CL_AllocDlight (NULL, pos, 50, 1.0f, 0.60f, 0.20f, 250, 0.2); - CL_RunParticleEffect (pos, vec3_origin, 226, 20); - S_StartSound (-1, 0, cl_sfx_knighthit, pos, 1, 1); + CL_FindNonSolidLocation(pos, pos, 4); + CL_AllocDlight(NULL, pos, 50, 1.0f, 0.60f, 0.20f, 250, 0.2); + CL_RunParticleEffect(pos, vec3_origin, 226, 20); + S_StartSound(-1, 0, cl_sfx_knighthit, pos, 1, 1); break; case TE_SPIKE: // spike hitting wall MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); + CL_FindNonSolidLocation(pos, pos, 4); // LordHavoc: changed to spark shower CL_SparkShower(pos, vec3_origin, 15); - if ( rand() % 5 ) - S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1); + if (rand() % 5) + S_StartSound(-1, 0, cl_sfx_tink1, pos, 1, 1); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric1, pos, 1, 1); else if (rnd == 2) - S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric2, pos, 1, 1); else - S_StartSound (-1, 0, cl_sfx_ric3, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric3, pos, 1, 1); } break; case TE_SPIKEQUAD: // quad spike hitting wall MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); + CL_FindNonSolidLocation(pos, pos, 4); // LordHavoc: changed to spark shower CL_SparkShower(pos, vec3_origin, 15); - CL_AllocDlight (NULL, pos, 200, 0.1f, 0.1f, 1.0f, 1000, 0.2); - S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); - if ( rand() % 5 ) - S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1); + CL_AllocDlight(NULL, pos, 200, 0.1f, 0.1f, 1.0f, 1000, 0.2); + S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1); + if (rand() % 5) + S_StartSound(-1, 0, cl_sfx_tink1, pos, 1, 1); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric1, pos, 1, 1); else if (rnd == 2) - S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric2, pos, 1, 1); else - S_StartSound (-1, 0, cl_sfx_ric3, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric3, pos, 1, 1); } break; case TE_SUPERSPIKE: // super spike hitting wall MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); + CL_FindNonSolidLocation(pos, pos, 4); // LordHavoc: changed to dust shower CL_SparkShower(pos, vec3_origin, 30); - if ( rand() % 5 ) - S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1); + if (rand() % 5) + S_StartSound(-1, 0, cl_sfx_tink1, pos, 1, 1); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric1, pos, 1, 1); else if (rnd == 2) - S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric2, pos, 1, 1); else - S_StartSound (-1, 0, cl_sfx_ric3, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric3, pos, 1, 1); } break; case TE_SUPERSPIKEQUAD: // quad super spike hitting wall MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); + CL_FindNonSolidLocation(pos, pos, 4); // LordHavoc: changed to dust shower CL_SparkShower(pos, vec3_origin, 30); - CL_AllocDlight (NULL, pos, 200, 0.1f, 0.1f, 1.0f, 1000, 0.2); - if ( rand() % 5 ) - S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1); + CL_AllocDlight(NULL, pos, 200, 0.1f, 0.1f, 1.0f, 1000, 0.2); + if (rand() % 5) + S_StartSound(-1, 0, cl_sfx_tink1, pos, 1, 1); else { rnd = rand() & 3; if (rnd == 1) - S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric1, pos, 1, 1); else if (rnd == 2) - S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric2, pos, 1, 1); else - S_StartSound (-1, 0, cl_sfx_ric3, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_ric3, pos, 1, 1); } break; // LordHavoc: added for improved blood splatters case TE_BLOOD: // blood puff MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); - dir[0] = MSG_ReadChar (); - dir[1] = MSG_ReadChar (); - dir[2] = MSG_ReadChar (); - count = MSG_ReadByte (); + CL_FindNonSolidLocation(pos, pos, 4); + dir[0] = MSG_ReadChar(); + dir[1] = MSG_ReadChar(); + dir[2] = MSG_ReadChar(); + count = MSG_ReadByte(); CL_BloodPuff(pos, dir, count); break; case TE_BLOOD2: // blood puff MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); + CL_FindNonSolidLocation(pos, pos, 4); CL_BloodPuff(pos, vec3_origin, 10); break; case TE_SPARK: // spark shower MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); - dir[0] = MSG_ReadChar (); - dir[1] = MSG_ReadChar (); - dir[2] = MSG_ReadChar (); - count = MSG_ReadByte (); + CL_FindNonSolidLocation(pos, pos, 4); + dir[0] = MSG_ReadChar(); + dir[1] = MSG_ReadChar(); + dir[2] = MSG_ReadChar(); + count = MSG_ReadByte(); CL_SparkShower(pos, dir, count); break; case TE_PLASMABURN: MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); + CL_FindNonSolidLocation(pos, pos, 4); CL_AllocDlight(NULL, pos, 200, 1, 1, 1, 1000, 0.2); CL_PlasmaBurn(pos); break; @@ -1139,8 +1140,8 @@ void CL_ParseTempEntity (void) // vaporized body MSG_ReadVector(pos); // mins MSG_ReadVector(pos2); // maxs - velspeed = MSG_ReadCoord (); // speed - count = MSG_ReadShort (); // number of particles + velspeed = MSG_ReadCoord(); // speed + count = MSG_ReadShort(); // number of particles CL_BloodShower(pos, pos2, velspeed, count); break; case TE_PARTICLECUBE: @@ -1148,10 +1149,10 @@ void CL_ParseTempEntity (void) MSG_ReadVector(pos); // mins MSG_ReadVector(pos2); // maxs MSG_ReadVector(dir); // dir - count = MSG_ReadShort (); // number of particles - colorStart = MSG_ReadByte (); // color - colorLength = MSG_ReadByte (); // gravity (1 or 0) - velspeed = MSG_ReadCoord (); // randomvel + count = MSG_ReadShort(); // number of particles + colorStart = MSG_ReadByte(); // color + colorLength = MSG_ReadByte(); // gravity (1 or 0) + velspeed = MSG_ReadCoord(); // randomvel CL_ParticleCube(pos, pos2, dir, count, colorStart, colorLength, velspeed); break; @@ -1160,8 +1161,8 @@ void CL_ParseTempEntity (void) MSG_ReadVector(pos); // mins MSG_ReadVector(pos2); // maxs MSG_ReadVector(dir); // dir - count = MSG_ReadShort (); // number of particles - colorStart = MSG_ReadByte (); // color + count = MSG_ReadShort(); // number of particles + colorStart = MSG_ReadByte(); // color CL_ParticleRain(pos, pos2, dir, count, colorStart, 0); break; @@ -1170,15 +1171,15 @@ void CL_ParseTempEntity (void) MSG_ReadVector(pos); // mins MSG_ReadVector(pos2); // maxs MSG_ReadVector(dir); // dir - count = MSG_ReadShort (); // number of particles - colorStart = MSG_ReadByte (); // color + count = MSG_ReadShort(); // number of particles + colorStart = MSG_ReadByte(); // color CL_ParticleRain(pos, pos2, dir, count, colorStart, 1); break; case TE_GUNSHOT: // bullet hitting wall MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); + CL_FindNonSolidLocation(pos, pos, 4); // LordHavoc: changed to dust shower CL_SparkShower(pos, vec3_origin, 15); break; @@ -1186,77 +1187,77 @@ void CL_ParseTempEntity (void) case TE_GUNSHOTQUAD: // quad bullet hitting wall MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); + CL_FindNonSolidLocation(pos, pos, 4); CL_SparkShower(pos, vec3_origin, 15); - CL_AllocDlight (NULL, pos, 200, 0.1f, 0.1f, 1.0f, 1000, 0.2); + CL_AllocDlight(NULL, pos, 200, 0.1f, 0.1f, 1.0f, 1000, 0.2); break; case TE_EXPLOSION: // rocket explosion MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 10); - CL_ParticleExplosion (pos); + CL_FindNonSolidLocation(pos, pos, 10); + CL_ParticleExplosion(pos); // LordHavoc: boosted color from 1.0, 0.8, 0.4 to 1.25, 1.0, 0.5 - CL_AllocDlight (NULL, pos, 350, 1.25f, 1.0f, 0.5f, 700, 0.5); - S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); + CL_AllocDlight(NULL, pos, 350, 1.25f, 1.0f, 0.5f, 700, 0.5); + S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1); break; case TE_EXPLOSIONQUAD: // quad rocket explosion MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 10); - CL_ParticleExplosion (pos); - CL_AllocDlight (NULL, pos, 600, 0.5f, 0.4f, 1.0f, 1200, 0.5); - S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); + CL_FindNonSolidLocation(pos, pos, 10); + CL_ParticleExplosion(pos); + CL_AllocDlight(NULL, pos, 600, 0.5f, 0.4f, 1.0f, 1200, 0.5); + S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1); break; case TE_EXPLOSION3: // Nehahra movie colored lighting explosion MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 10); - CL_ParticleExplosion (pos); - CL_AllocDlight (NULL, pos, 350, MSG_ReadCoord(), MSG_ReadCoord(), MSG_ReadCoord(), 700, 0.5); - S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); + CL_FindNonSolidLocation(pos, pos, 10); + CL_ParticleExplosion(pos); + CL_AllocDlight(NULL, pos, 350, MSG_ReadCoord(), MSG_ReadCoord(), MSG_ReadCoord(), 700, 0.5); + S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1); break; case TE_EXPLOSIONRGB: // colored lighting explosion MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 10); - CL_ParticleExplosion (pos); + CL_FindNonSolidLocation(pos, pos, 10); + CL_ParticleExplosion(pos); color[0] = MSG_ReadByte() * (1.0 / 255.0); color[1] = MSG_ReadByte() * (1.0 / 255.0); color[2] = MSG_ReadByte() * (1.0 / 255.0); - CL_AllocDlight (NULL, pos, 350, color[0], color[1], color[2], 700, 0.5); - S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); + CL_AllocDlight(NULL, pos, 350, color[0], color[1], color[2], 700, 0.5); + S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1); break; case TE_TAREXPLOSION: // tarbaby explosion MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 10); - CL_BlobExplosion (pos); + CL_FindNonSolidLocation(pos, pos, 10); + CL_BlobExplosion(pos); - S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); - CL_AllocDlight (NULL, pos, 600, 0.8f, 0.4f, 1.0f, 1200, 0.5); - S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1); + S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1); + CL_AllocDlight(NULL, pos, 600, 0.8f, 0.4f, 1.0f, 1200, 0.5); break; case TE_SMALLFLASH: MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 10); - CL_AllocDlight (NULL, pos, 200, 1, 1, 1, 1000, 0.2); + CL_FindNonSolidLocation(pos, pos, 10); + CL_AllocDlight(NULL, pos, 200, 1, 1, 1, 1000, 0.2); break; case TE_CUSTOMFLASH: MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); + CL_FindNonSolidLocation(pos, pos, 4); radius = MSG_ReadByte() * 8; velspeed = (MSG_ReadByte() + 1) * (1.0 / 256.0); color[0] = MSG_ReadByte() * (1.0 / 255.0); color[1] = MSG_ReadByte() * (1.0 / 255.0); color[2] = MSG_ReadByte() * (1.0 / 255.0); - CL_AllocDlight (NULL, pos, radius, color[0], color[1], color[2], radius / velspeed, velspeed); + CL_AllocDlight(NULL, pos, radius, color[0], color[1], color[2], radius / velspeed, velspeed); break; case TE_FLAMEJET: @@ -1270,21 +1271,21 @@ void CL_ParseTempEntity (void) // lightning bolts if (!cl_model_bolt) cl_model_bolt = Mod_ForName("progs/bolt.mdl", true, false, false); - CL_ParseBeam (cl_model_bolt, true); + CL_ParseBeam(cl_model_bolt, true); break; case TE_LIGHTNING2: // lightning bolts if (!cl_model_bolt2) cl_model_bolt2 = Mod_ForName("progs/bolt2.mdl", true, false, false); - CL_ParseBeam (cl_model_bolt2, true); + CL_ParseBeam(cl_model_bolt2, true); break; case TE_LIGHTNING3: // lightning bolts if (!cl_model_bolt3) cl_model_bolt3 = Mod_ForName("progs/bolt3.mdl", true, false, false); - CL_ParseBeam (cl_model_bolt3, false); + CL_ParseBeam(cl_model_bolt3, false); break; // PGM 01/21/97 @@ -1292,40 +1293,40 @@ void CL_ParseTempEntity (void) // grappling hook beam if (!cl_model_beam) cl_model_beam = Mod_ForName("progs/beam.mdl", true, false, false); - CL_ParseBeam (cl_model_beam, false); + CL_ParseBeam(cl_model_beam, false); break; // PGM 01/21/97 // LordHavoc: for compatibility with the Nehahra movie... case TE_LIGHTNING4NEH: - CL_ParseBeam (Mod_ForName(MSG_ReadString(), true, false, false), false); + CL_ParseBeam(Mod_ForName(MSG_ReadString(), true, false, false), false); break; case TE_LAVASPLASH: - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); - CL_LavaSplash (pos); + pos[0] = MSG_ReadCoord(); + pos[1] = MSG_ReadCoord(); + pos[2] = MSG_ReadCoord(); + CL_LavaSplash(pos); break; case TE_TELEPORT: - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); - CL_AllocDlight (NULL, pos, 500, 1.0f, 1.0f, 1.0f, 1500, 99.0f); -// CL_TeleportSplash (pos); + pos[0] = MSG_ReadCoord(); + pos[1] = MSG_ReadCoord(); + pos[2] = MSG_ReadCoord(); + CL_AllocDlight(NULL, pos, 500, 1.0f, 1.0f, 1.0f, 1500, 99.0f); +// CL_TeleportSplash(pos); break; case TE_EXPLOSION2: // color mapped explosion MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 10); - colorStart = MSG_ReadByte (); - colorLength = MSG_ReadByte (); - CL_ParticleExplosion2 (pos, colorStart, colorLength); + CL_FindNonSolidLocation(pos, pos, 10); + colorStart = MSG_ReadByte(); + colorLength = MSG_ReadByte(); + CL_ParticleExplosion2(pos, colorStart, colorLength); tempcolor = (qbyte *)&palette_complete[(rand()%colorLength) + colorStart]; - CL_AllocDlight (NULL, pos, 350, tempcolor[0] * (1.0f / 255.0f), tempcolor[1] * (1.0f / 255.0f), tempcolor[2] * (1.0f / 255.0f), 700, 0.5); - S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); + CL_AllocDlight(NULL, pos, 350, tempcolor[0] * (1.0f / 255.0f), tempcolor[1] * (1.0f / 255.0f), tempcolor[2] * (1.0f / 255.0f), 700, 0.5); + S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1); break; case TE_TEI_G3: @@ -1339,30 +1340,30 @@ void CL_ParseTempEntity (void) case TE_TEI_SMOKE: MSG_ReadVector(pos); MSG_ReadVector(dir); - count = MSG_ReadByte (); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 4); + count = MSG_ReadByte(); + CL_FindNonSolidLocation(pos, pos, 4); CL_Tei_Smoke(pos, dir, count); break; case TE_TEI_BIGEXPLOSION: MSG_ReadVector(pos); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 10); - CL_ParticleExplosion (pos); - CL_AllocDlight (NULL, pos, 500, 1.25f, 1.0f, 0.5f, 500, 9999); - S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); + CL_FindNonSolidLocation(pos, pos, 10); + CL_ParticleExplosion(pos); + CL_AllocDlight(NULL, pos, 500, 1.25f, 1.0f, 0.5f, 500, 9999); + S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1); break; case TE_TEI_PLASMAHIT: MSG_ReadVector(pos); MSG_ReadVector(dir); - count = MSG_ReadByte (); - if (cl.worldmodel) cl.worldmodel->FindNonSolidLocation(cl.worldmodel, pos, pos, 5); + count = MSG_ReadByte(); + CL_FindNonSolidLocation(pos, pos, 5); CL_Tei_PlasmaHit(pos, dir, count); - CL_AllocDlight (NULL, pos, 500, 0.3, 0.6, 1.0f, 2000, 9999); + CL_AllocDlight(NULL, pos, 500, 0.3, 0.6, 1.0f, 2000, 9999); break; default: - Host_Error ("CL_ParseTempEntity: bad type %d (hex %02X)", type, type); + Host_Error("CL_ParseTempEntity: bad type %d (hex %02X)", type, type); } } diff --git a/cl_particles.c b/cl_particles.c index da6be2fa..ae4f2e79 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. siextern float r_avertexnormals[NUMVERTEXNORMALS][3]; #define m_bytenormals r_avertexnormals #define VectorNormalizeFast VectorNormalize -#define Mod_PointContents(v,m) (Mod_PointInLeaf(v,m)->contents) +#define CL_PointContents(v) (Mod_PointInLeaf(v,cl.worldmodel)->contents) typedef unsigned char qbyte; #define cl_stainmaps.integer 0 void R_Stain (vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, int cr2, int cg2, int cb2, int ca2) @@ -163,9 +163,9 @@ float CL_TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int trace.fraction = 1; VectorCopy (end, trace.endpos); #if QW - PM_RecursiveHullCheck (cl.model_precache[1]->hulls, 0, 0, 1, start, end, &trace); + PM_RecursiveHullCheck (cl.model_precache[1]->brushq1.hulls, 0, 0, 1, start, end, &trace); #else - RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace); + RecursiveHullCheck (cl.worldmodel->brushq1.hulls, 0, 0, 1, start, end, &trace); #endif VectorCopy(trace.endpos, impact); VectorCopy(trace.plane.normal, normal); @@ -556,7 +556,7 @@ void CL_ParticleExplosion (vec3_t org) if (cl_stainmaps.integer) R_Stain(org, 96, 80, 80, 80, 64, 176, 176, 176, 64); - i = cl.worldmodel ? cl.worldmodel->PointContents(cl.worldmodel, org) : CONTENTS_EMPTY; + i = CL_PointContents(org); if ((i == CONTENTS_SLIME || i == CONTENTS_WATER) && cl_particles.integer && cl_particles_bubbles.integer) { for (i = 0;i < 128;i++) @@ -1026,7 +1026,7 @@ void CL_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent) VectorMA(start, dec, vec, pos); len -= dec; - contents = cl.worldmodel ? cl.worldmodel->PointContents(cl.worldmodel, pos) : CONTENTS_EMPTY; + contents = CL_PointContents(pos); if (contents == CONTENTS_SKY || contents == CONTENTS_LAVA) return; @@ -1307,7 +1307,7 @@ void CL_MoveParticles (void) { f = p->friction * frametime; if (!content) - content = cl.worldmodel ? cl.worldmodel->PointContents(cl.worldmodel, p->org) : CONTENTS_EMPTY; + content = CL_PointContents(p->org); if (content != CONTENTS_EMPTY) f *= 4; f = 1.0f - f; @@ -1320,7 +1320,7 @@ void CL_MoveParticles (void) { case pt_blood: if (!content) - content = cl.worldmodel ? cl.worldmodel->PointContents(cl.worldmodel, p->org) : CONTENTS_EMPTY; + content = CL_PointContents(p->org); a = content; if (a != CONTENTS_EMPTY) { @@ -1338,7 +1338,7 @@ void CL_MoveParticles (void) break; case pt_bubble: if (!content) - content = cl.worldmodel ? cl.worldmodel->PointContents(cl.worldmodel, p->org) : CONTENTS_EMPTY; + content = CL_PointContents(p->org); if (content != CONTENTS_WATER && content != CONTENTS_SLIME) { p->die = -1; @@ -1355,7 +1355,7 @@ void CL_MoveParticles (void) p->vel[2] = /*lhrandom(-32, 32) +*/ p->vel2[2]; } if (!content) - content = cl.worldmodel ? cl.worldmodel->PointContents(cl.worldmodel, p->org) : CONTENTS_EMPTY; + content = CL_PointContents(p->org); a = content; if (a != CONTENTS_EMPTY && a != CONTENTS_SKY) p->die = -1; diff --git a/cl_screen.c b/cl_screen.c index b9a10ed9..17e8e70c 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -2,6 +2,7 @@ #include "quakedef.h" #include "cl_video.h" #include "jpeg.h" +#include "cl_collision.h" cvar_t scr_viewsize = {CVAR_SAVE, "viewsize","100"}; cvar_t scr_fov = {CVAR_SAVE, "fov","90"}; // 10 - 170 @@ -697,7 +698,7 @@ static void SCR_CalcRefdef (void) if (cl.worldmodel) { Mod_CheckLoaded(cl.worldmodel); - contents = cl.worldmodel ? cl.worldmodel->PointContents(cl.worldmodel, r_refdef.vieworg) : CONTENTS_EMPTY; + contents = CL_PointContents(r_refdef.vieworg); if (contents != CONTENTS_EMPTY && contents != CONTENTS_SOLID) { r_refdef.fov_x *= (sin(cl.time * 4.7) * 0.015 + 0.985); diff --git a/collision.c b/collision.c index bcc3c0f4..168ca70a 100644 --- a/collision.c +++ b/collision.c @@ -210,28 +210,28 @@ void Collision_RoundUpToHullSize(const model_t *cmodel, const vec3_t inmins, con const hull_t *hull; VectorSubtract(inmaxs, inmins, size); - if (cmodel->ishlbsp) + if (cmodel->brushq1.ishlbsp) { if (size[0] < 3) - hull = &cmodel->hulls[0]; // 0x0x0 + hull = &cmodel->brushq1.hulls[0]; // 0x0x0 else if (size[0] <= 32) { if (size[2] < 54) // pick the nearest of 36 or 72 - hull = &cmodel->hulls[3]; // 32x32x36 + hull = &cmodel->brushq1.hulls[3]; // 32x32x36 else - hull = &cmodel->hulls[1]; // 32x32x72 + hull = &cmodel->brushq1.hulls[1]; // 32x32x72 } else - hull = &cmodel->hulls[2]; // 64x64x64 + hull = &cmodel->brushq1.hulls[2]; // 64x64x64 } else { if (size[0] < 3) - hull = &cmodel->hulls[0]; // 0x0x0 + hull = &cmodel->brushq1.hulls[0]; // 0x0x0 else if (size[0] <= 32) - hull = &cmodel->hulls[1]; // 32x32x56 + hull = &cmodel->brushq1.hulls[1]; // 32x32x56 else - hull = &cmodel->hulls[2]; // 64x64x88 + hull = &cmodel->brushq1.hulls[2]; // 64x64x88 } VectorCopy(inmins, outmins); VectorAdd(inmins, hull->clip_size, outmaxs); @@ -301,28 +301,28 @@ static const hull_t *HullForBrushModel (const model_t *cmodel, const vec3_t cori // explicit hulls in the BSP model VectorSubtract (maxs, mins, size); // LordHavoc: FIXME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - if (cmodel->ishlbsp) + if (cmodel->brushq1.ishlbsp) { if (size[0] < 3) - hull = &cmodel->hulls[0]; // 0x0x0 + hull = &cmodel->brushq1.hulls[0]; // 0x0x0 else if (size[0] <= 32) { if (size[2] < 54) // pick the nearest of 36 or 72 - hull = &cmodel->hulls[3]; // 32x32x36 + hull = &cmodel->brushq1.hulls[3]; // 32x32x36 else - hull = &cmodel->hulls[1]; // 32x32x72 + hull = &cmodel->brushq1.hulls[1]; // 32x32x72 } else - hull = &cmodel->hulls[2]; // 64x64x64 + hull = &cmodel->brushq1.hulls[2]; // 64x64x64 } else { if (size[0] < 3) - hull = &cmodel->hulls[0]; // 0x0x0 + hull = &cmodel->brushq1.hulls[0]; // 0x0x0 else if (size[0] <= 32) - hull = &cmodel->hulls[1]; // 32x32x56 + hull = &cmodel->brushq1.hulls[1]; // 32x32x56 else - hull = &cmodel->hulls[2]; // 64x64x88 + hull = &cmodel->brushq1.hulls[2]; // 64x64x88 } // calculate an offset value to center the origin @@ -953,7 +953,7 @@ void Collision_RecursiveTraceBrushNode(colbrushbmodelinfo_t *info, mnode_t *node msurface_t *surf; for (i = 0, mark = leaf->firstmarksurface;i < leaf->nummarksurfaces;i++, mark++) { - surf = info->model->surfaces + *mark; + surf = info->model->brushq1.surfaces + *mark; // don't check a surface twice if (surf->colframe != colframecount) { @@ -1015,7 +1015,7 @@ float Collision_TraceBrushBModel(const colbrushf_t *thisbrush_start, const colbr info.fraction = 1; info.startsolid = false; info.allsolid = false; - Collision_RecursiveTraceBrushNode(&info, model->nodes + model->hulls[0].firstclipnode); + Collision_RecursiveTraceBrushNode(&info, model->brushq1.nodes + model->brushq1.hulls[0].firstclipnode); if (info.fraction < 1) VectorCopy(info.impactnormal, impactnormal); if (startsolid) @@ -1037,7 +1037,7 @@ float Collision_TraceBrushBModelTransform(const colbrushf_t *thisbrush_start, co info.fraction = 1; info.startsolid = false; info.allsolid = false; - Collision_RecursiveTraceBrushNode(&info, model->nodes); + Collision_RecursiveTraceBrushNode(&info, model->brushq1.nodes); if (info.fraction < 1) VectorCopy(info.impactnormal, impactnormal); if (startsolid) diff --git a/gl_models.c b/gl_models.c index ec9ed00e..c71dcf34 100644 --- a/gl_models.c +++ b/gl_models.c @@ -166,7 +166,7 @@ void R_DrawAliasModelCallback (const void *calldata1, int calldata2) qbyte *bcolor; rmeshstate_t m; const entity_render_t *ent = calldata1; - aliasmesh_t *mesh = ent->model->aliasdata_meshes + calldata2; + aliasmesh_t *mesh = ent->model->alias.aliasdata_meshes + calldata2; aliaslayer_t *layer; aliasskin_t *skin; @@ -294,7 +294,7 @@ void R_Model_Alias_Draw(entity_render_t *ent) c_models++; - for (meshnum = 0, mesh = ent->model->aliasdata_meshes;meshnum < ent->model->aliasnum_meshes;meshnum++, mesh++) + for (meshnum = 0, mesh = ent->model->alias.aliasdata_meshes;meshnum < ent->model->alias.aliasnum_meshes;meshnum++, mesh++) { if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_FetchAliasSkin(ent, mesh)->flags & ALIASSKIN_TRANSPARENT) R_MeshQueue_AddTransparent(ent->origin, R_DrawAliasModelCallback, ent, meshnum); @@ -348,7 +348,7 @@ void R_Model_Alias_DrawFakeShadow (entity_render_t *ent) dist = -1.0f / DotProduct(projection, plane); VectorScale(projection, dist, projection); - for (meshnum = 0, mesh = ent->model->aliasdata_meshes;meshnum < ent->model->aliasnum_meshes;meshnum++) + for (meshnum = 0, mesh = ent->model->alias.aliasdata_meshes;meshnum < ent->model->alias.aliasnum_meshes;meshnum++) { skin = R_FetchAliasSkin(ent, mesh); if (skin->flags & ALIASSKIN_TRANSPARENT) @@ -377,7 +377,7 @@ void R_Model_Alias_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightor if (projectdistance > 0.1) { R_Mesh_Matrix(&ent->matrix); - for (meshnum = 0, mesh = ent->model->aliasdata_meshes;meshnum < ent->model->aliasnum_meshes;meshnum++, mesh++) + for (meshnum = 0, mesh = ent->model->alias.aliasdata_meshes;meshnum < ent->model->alias.aliasnum_meshes;meshnum++, mesh++) { skin = R_FetchAliasSkin(ent, mesh); if (skin->flags & ALIASSKIN_TRANSPARENT) @@ -421,7 +421,7 @@ void R_Model_Alias_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, v } ifog = 1 - fog; - for (meshnum = 0, mesh = ent->model->aliasdata_meshes;meshnum < ent->model->aliasnum_meshes;meshnum++, mesh++) + for (meshnum = 0, mesh = ent->model->alias.aliasdata_meshes;meshnum < ent->model->alias.aliasnum_meshes;meshnum++, mesh++) { skin = R_FetchAliasSkin(ent, mesh); if (skin->flags & ALIASSKIN_TRANSPARENT) @@ -752,12 +752,12 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2) R_Mesh_Matrix(&ent->matrix); // find the vertex index list and texture - renderlist = ent->model->zymdata_renderlist; + renderlist = ent->model->alias.zymdata_renderlist; for (i = 0;i < shadernum;i++) renderlist += renderlist[0] * 3 + 1; - texture = ent->model->zymdata_textures[shadernum]; + texture = ent->model->alias.zymdata_textures[shadernum]; - numverts = ent->model->zymnum_verts; + numverts = ent->model->alias.zymnum_verts; numtriangles = *renderlist++; elements = renderlist; @@ -807,13 +807,13 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2) colorscale *= 0.25f; } mstate.tex[0] = R_GetTexture(texture); - mstate.pointer_texcoord[0] = ent->model->zymdata_texcoords; + mstate.pointer_texcoord[0] = ent->model->alias.zymdata_texcoords; R_Mesh_State_Texture(&mstate); - ZymoticLerpBones(ent->model->zymnum_bones, (zymbonematrix *) ent->model->zymdata_poses, ent->frameblend, ent->model->zymdata_bones); + ZymoticLerpBones(ent->model->alias.zymnum_bones, (zymbonematrix *) ent->model->alias.zymdata_poses, ent->frameblend, ent->model->alias.zymdata_bones); - ZymoticTransformVerts(numverts, varray_vertex3f, ent->model->zymdata_vertbonecounts, ent->model->zymdata_verts); - ZymoticCalcNormal3f(numverts, varray_vertex3f, aliasvert_normal3f, ent->model->zymnum_shaders, ent->model->zymdata_renderlist); + ZymoticTransformVerts(numverts, varray_vertex3f, ent->model->alias.zymdata_vertbonecounts, ent->model->alias.zymdata_verts); + ZymoticCalcNormal3f(numverts, varray_vertex3f, aliasvert_normal3f, ent->model->alias.zymnum_shaders, ent->model->alias.zymdata_renderlist); if (R_LightModel(ambientcolor4f, ent, ifog * colorscale, ifog * colorscale, ifog * colorscale, ent->alpha, false)) { GL_ColorPointer(varray_color4f); @@ -834,11 +834,11 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2) memset(&mstate, 0, sizeof(mstate)); // FIXME: need alpha mask for fogging... //mstate.tex[0] = R_GetTexture(texture); - //mstate.pointer_texcoord = ent->model->zymdata_texcoords; + //mstate.pointer_texcoord = ent->model->alias.zymdata_texcoords; R_Mesh_State_Texture(&mstate); GL_Color(fogcolor[0] * r_colorscale, fogcolor[1] * r_colorscale, fogcolor[2] * r_colorscale, ent->alpha * fog); - ZymoticTransformVerts(numverts, varray_vertex3f, ent->model->zymdata_vertbonecounts, ent->model->zymdata_verts); + ZymoticTransformVerts(numverts, varray_vertex3f, ent->model->alias.zymdata_vertbonecounts, ent->model->alias.zymdata_verts); R_Mesh_Draw(numverts, numtriangles, elements); c_alias_polys += numtriangles; } @@ -853,9 +853,9 @@ void R_Model_Zymotic_Draw(entity_render_t *ent) c_models++; - for (i = 0;i < ent->model->zymnum_shaders;i++) + for (i = 0;i < ent->model->alias.zymnum_shaders;i++) { - if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_TextureHasAlpha(ent->model->zymdata_textures[i])) + if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_TextureHasAlpha(ent->model->alias.zymdata_textures[i])) R_MeshQueue_AddTransparent(ent->origin, R_DrawZymoticModelMeshCallback, ent, i); else R_DrawZymoticModelMeshCallback(ent, i); diff --git a/gl_rmain.c b/gl_rmain.c index 2b57c0f7..91f2316e 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -231,8 +231,8 @@ void gl_main_newmap(void) return; } } - if (cl.worldmodel->entities) - CL_ParseEntityLump(cl.worldmodel->entities); + if (cl.worldmodel->brush.entities) + CL_ParseEntityLump(cl.worldmodel->brush.entities); } } @@ -404,13 +404,13 @@ int PVS_CullBox(const vec3_t mins, const vec3_t maxs) if (cl.worldmodel == NULL) return false; stackpos = 0; - stack[stackpos++] = cl.worldmodel->nodes; + stack[stackpos++] = cl.worldmodel->brushq1.nodes; while (stackpos) { node = stack[--stackpos]; if (node->contents < 0) { - if (((mleaf_t *)node)->pvsframe == cl.worldmodel->pvsframecount) + if (((mleaf_t *)node)->pvsframe == cl.worldmodel->brushq1.pvsframecount) return false; } else @@ -434,7 +434,7 @@ int VIS_CullBox(const vec3_t mins, const vec3_t maxs) if (cl.worldmodel == NULL) return false; stackpos = 0; - stack[stackpos++] = cl.worldmodel->nodes; + stack[stackpos++] = cl.worldmodel->brushq1.nodes; while (stackpos) { node = stack[--stackpos]; @@ -471,13 +471,13 @@ int PVS_CullSphere(const vec3_t origin, vec_t radius) if (cl.worldmodel == NULL) return false; stackpos = 0; - stack[stackpos++] = cl.worldmodel->nodes; + stack[stackpos++] = cl.worldmodel->brushq1.nodes; while (stackpos) { node = stack[--stackpos]; if (node->contents < 0) { - if (((mleaf_t *)node)->pvsframe == cl.worldmodel->pvsframecount) + if (((mleaf_t *)node)->pvsframe == cl.worldmodel->brushq1.pvsframecount) return false; } else @@ -502,7 +502,7 @@ int VIS_CullSphere(const vec3_t origin, vec_t radius) if (cl.worldmodel == NULL) return false; stackpos = 0; - stack[stackpos++] = cl.worldmodel->nodes; + stack[stackpos++] = cl.worldmodel->brushq1.nodes; while (stackpos) { node = stack[--stackpos]; @@ -659,7 +659,7 @@ int Light_CullBox(const vec3_t mins, const vec3_t maxs) if (cl.worldmodel == NULL) return false; stackpos = 0; - stack[stackpos++] = cl.worldmodel->nodes; + stack[stackpos++] = cl.worldmodel->brushq1.nodes; while (stackpos) { node = stack[--stackpos]; @@ -689,7 +689,7 @@ int LightAndVis_CullBox(const vec3_t mins, const vec3_t maxs) if (cl.worldmodel == NULL) return false; stackpos = 0; - stack[stackpos++] = cl.worldmodel->nodes; + stack[stackpos++] = cl.worldmodel->brushq1.nodes; while (stackpos) { node = stack[--stackpos]; @@ -721,7 +721,7 @@ int LightAndVis_CullPointCloud(int numpoints, const float *points) if (cl.worldmodel == NULL) return false; stackpos = 0; - stack[stackpos++] = cl.worldmodel->nodes; + stack[stackpos++] = cl.worldmodel->brushq1.nodes; while (stackpos) { node = stack[--stackpos]; diff --git a/gl_rsurf.c b/gl_rsurf.c index 35b582a5..4727958b 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -250,7 +250,7 @@ static void R_BuildLightMap (const entity_render_t *ent, msurface_t *surf) // set to full bright if no light data bl = intblocklights; - if ((ent->effects & EF_FULLBRIGHT) || !ent->model->lightdata) + if ((ent->effects & EF_FULLBRIGHT) || !ent->model->brushq1.lightdata) { for (i = 0;i < size3;i++) bl[i] = 255*256; @@ -289,7 +289,7 @@ static void R_BuildLightMap (const entity_render_t *ent, msurface_t *surf) out = templight; // deal with lightmap brightness scale shift = 7 + r_lightmapscalebit + 8; - if (ent->model->lightmaprgba) + if (ent->model->brushq1.lightmaprgba) { stride = (surf->lightmaptexturestride - smax) * 4; for (i = 0;i < tmax;i++, out += stride) @@ -336,7 +336,7 @@ static void R_BuildLightMap (const entity_render_t *ent, msurface_t *surf) // set to full bright if no light data bl = floatblocklights; - if ((ent->effects & EF_FULLBRIGHT) || !ent->model->lightdata) + if ((ent->effects & EF_FULLBRIGHT) || !ent->model->brushq1.lightdata) j = 255*256; else j = r_ambient.value * 512.0f; // would be 128.0f logically, but using 512.0f to match winquake style @@ -371,7 +371,7 @@ static void R_BuildLightMap (const entity_render_t *ent, msurface_t *surf) out = templight; // deal with lightmap brightness scale scale = 1.0f / (1 << (7 + r_lightmapscalebit + 8)); - if (ent->model->lightmaprgba) + if (ent->model->brushq1.lightmaprgba) { stride = (surf->lightmaptexturestride - smax) * 4; for (i = 0;i < tmax;i++, out += stride) @@ -444,7 +444,7 @@ loc0: impact[2] = origin[2] - node->plane->normal[2] * ndist; } - for (surf = model->surfaces + node->firstsurface, endsurf = surf + node->numsurfaces;surf < endsurf;surf++) + for (surf = model->brushq1.surfaces + node->firstsurface, endsurf = surf + node->numsurfaces;surf < endsurf;surf++) { if (surf->stainsamples) { @@ -543,7 +543,7 @@ void R_Stain (const vec3_t origin, float radius, int cr1, int cg1, int cb1, int fcolor[6] = cb2 - cb1; fcolor[7] = (ca2 - ca1) * (1.0f / 64.0f); - R_StainNode(cl.worldmodel->nodes + cl.worldmodel->hulls[0].firstclipnode, cl.worldmodel, origin, radius, fcolor); + R_StainNode(cl.worldmodel->brushq1.nodes + cl.worldmodel->brushq1.hulls[0].firstclipnode, cl.worldmodel, origin, radius, fcolor); // look for embedded bmodels for (n = 0;n < cl_num_brushmodel_entities;n++) @@ -556,7 +556,7 @@ void R_Stain (const vec3_t origin, float radius, int cr1, int cg1, int cb1, int if (model->type == mod_brush) { Matrix4x4_Transform(&ent->inversematrix, origin, org); - R_StainNode(model->nodes + model->hulls[0].firstclipnode, model, org, radius, fcolor); + R_StainNode(model->brushq1.nodes + model->brushq1.hulls[0].firstclipnode, model, org, radius, fcolor); } } } @@ -729,7 +729,7 @@ static void RSurfShader_Sky(const entity_render_t *ent, const texture_t *texture rmeshstate_t m; // LordHavoc: HalfLife maps have freaky skypolys... - if (ent->model->ishlbsp) + if (ent->model->brushq1.ishlbsp) return; if (skyrendernow) @@ -778,7 +778,7 @@ static void RSurfShader_Sky(const entity_render_t *ent, const texture_t *texture static void RSurfShader_Water_Callback(const void *calldata1, int calldata2) { const entity_render_t *ent = calldata1; - const msurface_t *surf = ent->model->surfaces + calldata2; + const msurface_t *surf = ent->model->brushq1.surfaces + calldata2; float f, colorscale; const surfmesh_t *mesh; rmeshstate_t m; @@ -879,14 +879,14 @@ static void RSurfShader_Water(const entity_render_t *ent, const texture_t *textu if (surf->visframe == r_framecount) { Matrix4x4_Transform(&ent->matrix, surf->poly_center, center); - R_MeshQueue_AddTransparent(center, RSurfShader_Water_Callback, ent, surf - ent->model->surfaces); + R_MeshQueue_AddTransparent(center, RSurfShader_Water_Callback, ent, surf - ent->model->brushq1.surfaces); } } } else for (chain = surfchain;(surf = *chain) != NULL;chain++) if (surf->visframe == r_framecount) - RSurfShader_Water_Callback(ent, surf - ent->model->surfaces); + RSurfShader_Water_Callback(ent, surf - ent->model->brushq1.surfaces); } static void RSurfShader_Wall_Pass_BaseVertex(const entity_render_t *ent, const msurface_t *surf, const texture_t *texture, int rendertype, float currentalpha) @@ -1278,7 +1278,7 @@ static void RSurfShader_OpaqueWall_Pass_OpaqueGlow(const entity_render_t *ent, c static void RSurfShader_Wall_Vertex_Callback(const void *calldata1, int calldata2) { const entity_render_t *ent = calldata1; - const msurface_t *surf = ent->model->surfaces + calldata2; + const msurface_t *surf = ent->model->brushq1.surfaces + calldata2; int rendertype; float currentalpha; texture_t *texture; @@ -1318,7 +1318,7 @@ static void RSurfShader_Wall_Lightmap(const entity_render_t *ent, const texture_ if (surf->visframe == r_framecount) { Matrix4x4_Transform(&ent->matrix, surf->poly_center, center); - R_MeshQueue_AddTransparent(center, RSurfShader_Wall_Vertex_Callback, ent, surf - ent->model->surfaces); + R_MeshQueue_AddTransparent(center, RSurfShader_Wall_Vertex_Callback, ent, surf - ent->model->brushq1.surfaces); } } } @@ -1396,9 +1396,9 @@ void R_UpdateTextureInfo(entity_render_t *ent) alttextures = ent->frame != 0; texframe = (int)(cl.time * 5.0f); - for (i = 0;i < ent->model->numtextures;i++) + for (i = 0;i < ent->model->brushq1.numtextures;i++) { - t = ent->model->textures + i; + t = ent->model->brushq1.textures + i; t->currentalpha = ent->alpha; if (t->flags & SURF_WATERALPHA) t->currentalpha *= r_wateralpha.value; @@ -1427,30 +1427,30 @@ void R_PrepareSurfaces(entity_render_t *ent) model = ent->model; Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg); - numsurfaces = model->nummodelsurfaces; - surfaces = model->surfaces + model->firstmodelsurface; - surfacevisframes = model->surfacevisframes + model->firstmodelsurface; + numsurfaces = model->brushq1.nummodelsurfaces; + surfaces = model->brushq1.surfaces + model->brushq1.firstmodelsurface; + surfacevisframes = model->brushq1.surfacevisframes + model->brushq1.firstmodelsurface; R_UpdateTextureInfo(ent); if (r_dynamic.integer && !r_shadow_realtime_dlight.integer) R_MarkLights(ent); - if (model->light_ambient != r_ambient.value || model->light_scalebit != r_lightmapscalebit) + if (model->brushq1.light_ambient != r_ambient.value || model->brushq1.light_scalebit != r_lightmapscalebit) { - model->light_ambient = r_ambient.value; - model->light_scalebit = r_lightmapscalebit; - for (i = 0;i < model->nummodelsurfaces;i++) - model->surfaces[i + model->firstmodelsurface].cached_dlight = true; + model->brushq1.light_ambient = r_ambient.value; + model->brushq1.light_scalebit = r_lightmapscalebit; + for (i = 0;i < model->brushq1.nummodelsurfaces;i++) + model->brushq1.surfaces[i + model->brushq1.firstmodelsurface].cached_dlight = true; } else { - for (i = 0;i < model->light_styles;i++) + for (i = 0;i < model->brushq1.light_styles;i++) { - if (model->light_stylevalue[i] != d_lightstylevalue[model->light_style[i]]) + if (model->brushq1.light_stylevalue[i] != d_lightstylevalue[model->brushq1.light_style[i]]) { - model->light_stylevalue[i] = d_lightstylevalue[model->light_style[i]]; - for (surfchain = model->light_styleupdatechains[i];*surfchain;surfchain++) + model->brushq1.light_stylevalue[i] = d_lightstylevalue[model->brushq1.light_style[i]]; + for (surfchain = model->brushq1.light_styleupdatechains[i];*surfchain;surfchain++) (**surfchain).cached_dlight = true; } } @@ -1491,7 +1491,7 @@ void R_DrawSurfaces(entity_render_t *ent, int type, msurface_t ***chains) if (ent->model == NULL) return; R_Mesh_Matrix(&ent->matrix); - for (i = 0, t = ent->model->textures;i < ent->model->numtextures;i++, t++) + for (i = 0, t = ent->model->brushq1.textures;i < ent->model->brushq1.numtextures;i++, t++) if (t->shader->shaderfunc[type] && t->currentframe && chains[i] != NULL) t->shader->shaderfunc[type](ent, t->currentframe, chains[i]); } @@ -1502,7 +1502,7 @@ static void R_DrawPortal_Callback(const void *calldata1, int calldata2) float *v; rmeshstate_t m; const entity_render_t *ent = calldata1; - const mportal_t *portal = ent->model->portals + calldata2; + const mportal_t *portal = ent->model->brushq1.portals + calldata2; GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_DepthMask(false); GL_DepthTest(true); @@ -1512,7 +1512,7 @@ static void R_DrawPortal_Callback(const void *calldata1, int calldata2) memset(&m, 0, sizeof(m)); R_Mesh_State_Texture(&m); - i = portal - ent->model->portals; + i = portal - ent->model->brushq1.portals; GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_colorscale, ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_colorscale, ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_colorscale, @@ -1535,9 +1535,9 @@ static void R_DrawPortals(entity_render_t *ent) float temp[3], center[3], f; if (ent->model == NULL) return; - for (portal = ent->model->portals, endportal = portal + ent->model->numportals;portal < endportal;portal++) + for (portal = ent->model->brushq1.portals, endportal = portal + ent->model->brushq1.numportals;portal < endportal;portal++) { - if ((portal->here->pvsframe == ent->model->pvsframecount || portal->past->pvsframe == ent->model->pvsframecount) && portal->numpoints <= POLYGONELEMENTS_MAXPOINTS) + if ((portal->here->pvsframe == ent->model->brushq1.pvsframecount || portal->past->pvsframe == ent->model->brushq1.pvsframecount) && portal->numpoints <= POLYGONELEMENTS_MAXPOINTS) { VectorClear(temp); for (i = 0;i < portal->numpoints;i++) @@ -1545,7 +1545,7 @@ static void R_DrawPortals(entity_render_t *ent) f = ixtable[portal->numpoints]; VectorScale(temp, f, temp); Matrix4x4_Transform(&ent->matrix, temp, center); - R_MeshQueue_AddTransparent(center, R_DrawPortal_Callback, ent, portal - ent->model->portals); + R_MeshQueue_AddTransparent(center, R_DrawPortal_Callback, ent, portal - ent->model->brushq1.portals); } } } @@ -1567,10 +1567,10 @@ void R_PrepareBrushModel(entity_render_t *ent) #if WORLDNODECULLBACKFACES Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg); #endif - numsurfaces = model->nummodelsurfaces; - surf = model->surfaces + model->firstmodelsurface; - surfacevisframes = model->surfacevisframes + model->firstmodelsurface; - surfacepvsframes = model->surfacepvsframes + model->firstmodelsurface; + numsurfaces = model->brushq1.nummodelsurfaces; + surf = model->brushq1.surfaces + model->brushq1.firstmodelsurface; + surfacevisframes = model->brushq1.surfacevisframes + model->brushq1.firstmodelsurface; + surfacepvsframes = model->brushq1.surfacepvsframes + model->brushq1.firstmodelsurface; for (i = 0;i < numsurfaces;i++, surf++) { #if WORLDNODECULLBACKFACES @@ -1602,11 +1602,11 @@ void R_SurfaceWorldNode (entity_render_t *ent) model = ent->model; if (model == NULL) return; - surfacevisframes = model->surfacevisframes + model->firstmodelsurface; - surfacepvsframes = model->surfacepvsframes + model->firstmodelsurface; + surfacevisframes = model->brushq1.surfacevisframes + model->brushq1.firstmodelsurface; + surfacepvsframes = model->brushq1.surfacepvsframes + model->brushq1.firstmodelsurface; Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg); - for (leaf = model->pvsleafchain;leaf;leaf = leaf->pvschain) + for (leaf = model->brushq1.pvsleafchain;leaf;leaf = leaf->pvschain) { if (!R_CullBox (leaf->mins, leaf->maxs)) { @@ -1615,10 +1615,10 @@ void R_SurfaceWorldNode (entity_render_t *ent) } } - for (i = 0;i < model->pvssurflistlength;i++) + for (i = 0;i < model->brushq1.pvssurflistlength;i++) { - surfnum = model->pvssurflist[i]; - surf = model->surfaces + surfnum; + surfnum = model->brushq1.pvssurflist[i]; + surf = model->brushq1.surfaces + surfnum; #if WORLDNODECULLBACKFACES if (PlaneDist(modelorg, surf->plane) < surf->plane->dist) { @@ -1654,8 +1654,8 @@ static void R_PortalWorldNode(entity_render_t *ent, mleaf_t *viewleaf) // follows portals leading outward from viewleaf, does not venture // offscreen or into leafs that are not visible, faster than Quake's // RecursiveWorldNode - surfaces = ent->model->surfaces; - surfacevisframes = ent->model->surfacevisframes; + surfaces = ent->model->brushq1.surfaces; + surfacevisframes = ent->model->brushq1.surfacevisframes; Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg); viewleaf->worldnodeframe = r_framecount; leafstack[0] = viewleaf; @@ -1703,7 +1703,7 @@ static void R_PortalWorldNode(entity_render_t *ent, mleaf_t *viewleaf) { leaf->worldnodeframe = r_framecount; // FIXME: R_CullBox is absolute, should be done relative - if (leaf->pvsframe == ent->model->pvsframecount && !R_CullBox(leaf->mins, leaf->maxs)) + if (leaf->pvsframe == ent->model->brushq1.pvsframecount && !R_CullBox(leaf->mins, leaf->maxs)) leafstack[leafstackpos++] = leaf; } } @@ -1719,41 +1719,41 @@ void R_PVSUpdate (entity_render_t *ent, mleaf_t *viewleaf) model_t *model; model = ent->model; - if (model && (model->pvsviewleaf != viewleaf || model->pvsviewleafnovis != r_novis.integer)) + if (model && (model->brushq1.pvsviewleaf != viewleaf || model->brushq1.pvsviewleafnovis != r_novis.integer)) { - model->pvsframecount++; - model->pvsviewleaf = viewleaf; - model->pvsviewleafnovis = r_novis.integer; - model->pvsleafchain = NULL; - model->pvssurflistlength = 0; + model->brushq1.pvsframecount++; + model->brushq1.pvsviewleaf = viewleaf; + model->brushq1.pvsviewleafnovis = r_novis.integer; + model->brushq1.pvsleafchain = NULL; + model->brushq1.pvssurflistlength = 0; if (viewleaf) { - surfacepvsframes = model->surfacepvsframes; - vis = model->LeafPVS(model, viewleaf); - for (j = 0;j < model->numleafs;j += 8) + surfacepvsframes = model->brushq1.surfacepvsframes; + vis = model->brushq1.LeafPVS(model, viewleaf); + for (j = 0;j < model->brushq1.numleafs;j += 8) { bits = *vis++; if (bits) { - l = model->numleafs - j; + l = model->brushq1.numleafs - j; if (l > 8) l = 8; for (i = 0;i < l;i++) { if (bits & (1 << i)) { - leaf = &model->leafs[j + i + 1]; - leaf->pvschain = model->pvsleafchain; - model->pvsleafchain = leaf; - leaf->pvsframe = model->pvsframecount; + leaf = &model->brushq1.leafs[j + i + 1]; + leaf->pvschain = model->brushq1.pvsleafchain; + model->brushq1.pvsleafchain = leaf; + leaf->pvsframe = model->brushq1.pvsframecount; // mark surfaces bounding this leaf as visible for (c = leaf->nummarksurfaces, mark = leaf->firstmarksurface;c;c--, mark++) - surfacepvsframes[*mark] = model->pvsframecount; + surfacepvsframes[*mark] = model->brushq1.pvsframecount; } } } } - model->BuildPVSTextureChains(model); + model->brushq1.BuildPVSTextureChains(model); } } } @@ -1764,7 +1764,7 @@ void R_WorldVisibility (entity_render_t *ent) mleaf_t *viewleaf; Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg); - viewleaf = ent->model ? ent->model->PointInLeaf(ent->model, modelorg) : NULL; + viewleaf = ent->model ? ent->model->brushq1.PointInLeaf(ent->model, modelorg) : NULL; R_PVSUpdate(ent, viewleaf); if (!viewleaf) @@ -1781,8 +1781,8 @@ void R_DrawWorld (entity_render_t *ent) if (ent->model == NULL) return; R_PrepareSurfaces(ent); - R_DrawSurfaces(ent, SHADERSTAGE_SKY, ent->model->pvstexturechains); - R_DrawSurfaces(ent, SHADERSTAGE_NORMAL, ent->model->pvstexturechains); + R_DrawSurfaces(ent, SHADERSTAGE_SKY, ent->model->brushq1.pvstexturechains); + R_DrawSurfaces(ent, SHADERSTAGE_NORMAL, ent->model->brushq1.pvstexturechains); if (r_drawportals.integer) R_DrawPortals(ent); } @@ -1793,7 +1793,7 @@ void R_Model_Brush_DrawSky (entity_render_t *ent) return; if (ent != &cl_entities[0].render) R_PrepareBrushModel(ent); - R_DrawSurfaces(ent, SHADERSTAGE_SKY, ent->model->pvstexturechains); + R_DrawSurfaces(ent, SHADERSTAGE_SKY, ent->model->brushq1.pvstexturechains); } void R_Model_Brush_Draw (entity_render_t *ent) @@ -1803,7 +1803,7 @@ void R_Model_Brush_Draw (entity_render_t *ent) c_bmodels++; if (ent != &cl_entities[0].render) R_PrepareBrushModel(ent); - R_DrawSurfaces(ent, SHADERSTAGE_NORMAL, ent->model->pvstexturechains); + R_DrawSurfaces(ent, SHADERSTAGE_NORMAL, ent->model->brushq1.pvstexturechains); } void R_Model_Brush_DrawShadowVolume (entity_render_t *ent, vec3_t relativelightorigin, float lightradius) @@ -1818,7 +1818,7 @@ void R_Model_Brush_DrawShadowVolume (entity_render_t *ent, vec3_t relativelighto lightradius2 = lightradius * lightradius; R_UpdateTextureInfo(ent); projectdistance = 1000000000.0f;//lightradius + ent->model->radius; - for (i = 0, surf = ent->model->surfaces + ent->model->firstmodelsurface;i < ent->model->nummodelsurfaces;i++, surf++) + for (i = 0, surf = ent->model->brushq1.surfaces + ent->model->brushq1.firstmodelsurface;i < ent->model->brushq1.nummodelsurfaces;i++, surf++) { if (surf->texinfo->texture->rendertype == SURFRENDER_OPAQUE && surf->flags & SURF_SHADOWCAST) { @@ -1884,7 +1884,7 @@ void R_Model_Brush_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, v lightmaxs[1] = relativelightorigin[1] + lightradius; lightmaxs[2] = relativelightorigin[2] + lightradius; R_UpdateTextureInfo(ent); - for (surfnum = 0, surf = ent->model->surfaces + ent->model->firstmodelsurface;surfnum < ent->model->nummodelsurfaces;surfnum++, surf++) + for (surfnum = 0, surf = ent->model->brushq1.surfaces + ent->model->brushq1.firstmodelsurface;surfnum < ent->model->brushq1.nummodelsurfaces;surfnum++, surf++) { if ((ent != &cl_entities[0].render || surf->visframe == r_framecount) && BoxesOverlap(surf->poly_mins, surf->poly_maxs, lightmins, lightmaxs)) { diff --git a/model_alias.c b/model_alias.c index a3ca3fbf..61ee6507 100644 --- a/model_alias.c +++ b/model_alias.c @@ -39,7 +39,7 @@ static void Mod_CalcAliasModelBBoxes (void) VectorClear(loadmodel->normalmaxs); yawradius = 0; radius = 0; - for (meshnum = 0, mesh = loadmodel->aliasdata_meshes;meshnum < loadmodel->aliasnum_meshes;meshnum++, mesh++) + for (meshnum = 0, mesh = loadmodel->alias.aliasdata_meshes;meshnum < loadmodel->alias.aliasnum_meshes;meshnum++, mesh++) { for (vnum = 0, v = mesh->data_aliasvertex3f;vnum < mesh->num_vertices * mesh->num_frames;vnum++, v += 3) { @@ -141,8 +141,8 @@ static void Mod_MDL_LoadFrames (qbyte* datapointer, int inverts, vec3_t scale, v { pinframe = (daliasframe_t *)datapointer; datapointer += sizeof(daliasframe_t); - Mod_ConvertAliasVerts(inverts, scale, translate, (trivertx_t *)datapointer, loadmodel->aliasdata_meshes->data_aliasvertex3f + pose * loadmodel->aliasdata_meshes->num_vertices * 3, vertremap); - Mod_BuildTextureVectorsAndNormals(loadmodel->aliasdata_meshes->num_vertices, loadmodel->aliasdata_meshes->num_triangles, loadmodel->aliasdata_meshes->data_aliasvertex3f + pose * loadmodel->aliasdata_meshes->num_vertices * 3, loadmodel->aliasdata_meshes->data_texcoord2f, loadmodel->aliasdata_meshes->data_element3i, loadmodel->aliasdata_meshes->data_aliassvector3f + pose * loadmodel->aliasdata_meshes->num_vertices * 3, loadmodel->aliasdata_meshes->data_aliastvector3f + pose * loadmodel->aliasdata_meshes->num_vertices * 3, loadmodel->aliasdata_meshes->data_aliasnormal3f + pose * loadmodel->aliasdata_meshes->num_vertices * 3); + Mod_ConvertAliasVerts(inverts, scale, translate, (trivertx_t *)datapointer, loadmodel->alias.aliasdata_meshes->data_aliasvertex3f + pose * loadmodel->alias.aliasdata_meshes->num_vertices * 3, vertremap); + Mod_BuildTextureVectorsAndNormals(loadmodel->alias.aliasdata_meshes->num_vertices, loadmodel->alias.aliasdata_meshes->num_triangles, loadmodel->alias.aliasdata_meshes->data_aliasvertex3f + pose * loadmodel->alias.aliasdata_meshes->num_vertices * 3, loadmodel->alias.aliasdata_meshes->data_texcoord2f, loadmodel->alias.aliasdata_meshes->data_element3i, loadmodel->alias.aliasdata_meshes->data_aliassvector3f + pose * loadmodel->alias.aliasdata_meshes->num_vertices * 3, loadmodel->alias.aliasdata_meshes->data_aliastvector3f + pose * loadmodel->alias.aliasdata_meshes->num_vertices * 3, loadmodel->alias.aliasdata_meshes->data_aliasnormal3f + pose * loadmodel->alias.aliasdata_meshes->num_vertices * 3); datapointer += sizeof(trivertx_t) * inverts; pose++; } @@ -248,15 +248,15 @@ void Mod_IDP0_Load(model_t *mod, void *buffer) loadmodel->name, version, ALIAS_VERSION); loadmodel->type = mod_alias; - loadmodel->aliastype = ALIASTYPE_ALIAS; + loadmodel->alias.aliastype = ALIASTYPE_ALIAS; loadmodel->DrawSky = NULL; loadmodel->Draw = R_Model_Alias_Draw; loadmodel->DrawFakeShadow = R_Model_Alias_DrawFakeShadow; loadmodel->DrawShadowVolume = R_Model_Alias_DrawShadowVolume; loadmodel->DrawLight = R_Model_Alias_DrawLight; - loadmodel->aliasnum_meshes = 1; - loadmodel->aliasdata_meshes = Mem_Alloc(loadmodel->mempool, sizeof(aliasmesh_t)); + loadmodel->alias.aliasnum_meshes = 1; + loadmodel->alias.aliasdata_meshes = Mem_Alloc(loadmodel->mempool, sizeof(aliasmesh_t)); loadmodel->numskins = LittleLong(pinmodel->numskins); BOUNDI(loadmodel->numskins,0,256); @@ -266,8 +266,8 @@ void Mod_IDP0_Load(model_t *mod, void *buffer) BOUNDI(skinheight,0,4096); numverts = LittleLong(pinmodel->numverts); BOUNDI(numverts,0,65536); - loadmodel->aliasdata_meshes->num_triangles = LittleLong(pinmodel->numtris); - BOUNDI(loadmodel->aliasdata_meshes->num_triangles,0,65536 / 3); // max elements limit, rather than max triangles limit + loadmodel->alias.aliasdata_meshes->num_triangles = LittleLong(pinmodel->numtris); + BOUNDI(loadmodel->alias.aliasdata_meshes->num_triangles,0,65536 / 3); // max elements limit, rather than max triangles limit loadmodel->numframes = LittleLong(pinmodel->numframes); BOUNDI(loadmodel->numframes,0,65536); loadmodel->synctype = LittleLong (pinmodel->synctype); @@ -307,10 +307,10 @@ void Mod_IDP0_Load(model_t *mod, void *buffer) datapointer += sizeof(stvert_t) * numverts; pintriangles = (dtriangle_t *)datapointer; - datapointer += sizeof(dtriangle_t) * loadmodel->aliasdata_meshes->num_triangles; + datapointer += sizeof(dtriangle_t) * loadmodel->alias.aliasdata_meshes->num_triangles; startframes = datapointer; - loadmodel->aliasdata_meshes->num_frames = 0; + loadmodel->alias.aliasdata_meshes->num_frames = 0; for (i = 0;i < loadmodel->numframes;i++) { pinframetype = (daliasframetype_t *)datapointer; @@ -329,7 +329,7 @@ void Mod_IDP0_Load(model_t *mod, void *buffer) { datapointer += sizeof(daliasframe_t); datapointer += sizeof(trivertx_t) * numverts; - loadmodel->aliasdata_meshes->num_frames++; + loadmodel->alias.aliasdata_meshes->num_frames++; } } @@ -411,10 +411,10 @@ void Mod_IDP0_Load(model_t *mod, void *buffer) break; } - loadmodel->aliasdata_meshes->num_skins = 0; + loadmodel->alias.aliasdata_meshes->num_skins = 0; for (i = 0;i < loadmodel->numskins;i++) - loadmodel->aliasdata_meshes->num_skins += loadmodel->skinscenes[i].framecount; - loadmodel->aliasdata_meshes->data_skins = Mem_Alloc(loadmodel->mempool, loadmodel->aliasdata_meshes->num_skins * sizeof(aliasskin_t)); + loadmodel->alias.aliasdata_meshes->num_skins += loadmodel->skinscenes[i].framecount; + loadmodel->alias.aliasdata_meshes->data_skins = Mem_Alloc(loadmodel->mempool, loadmodel->alias.aliasdata_meshes->num_skins * sizeof(aliasskin_t)); // store texture coordinates into temporary array, they will be stored // after usage is determined (triangle data) @@ -434,63 +434,63 @@ void Mod_IDP0_Load(model_t *mod, void *buffer) } // load triangle data - loadmodel->aliasdata_meshes->data_element3i = Mem_Alloc(loadmodel->mempool, sizeof(int[3]) * loadmodel->aliasdata_meshes->num_triangles); + loadmodel->alias.aliasdata_meshes->data_element3i = Mem_Alloc(loadmodel->mempool, sizeof(int[3]) * loadmodel->alias.aliasdata_meshes->num_triangles); // read the triangle elements - for (i = 0;i < loadmodel->aliasdata_meshes->num_triangles;i++) + for (i = 0;i < loadmodel->alias.aliasdata_meshes->num_triangles;i++) for (j = 0;j < 3;j++) - loadmodel->aliasdata_meshes->data_element3i[i*3+j] = LittleLong(pintriangles[i].vertindex[j]); + loadmodel->alias.aliasdata_meshes->data_element3i[i*3+j] = LittleLong(pintriangles[i].vertindex[j]); // validate (note numverts is used because this is the original data) - Mod_ValidateElements(loadmodel->aliasdata_meshes->data_element3i, loadmodel->aliasdata_meshes->num_triangles, numverts, __FILE__, __LINE__); + Mod_ValidateElements(loadmodel->alias.aliasdata_meshes->data_element3i, loadmodel->alias.aliasdata_meshes->num_triangles, numverts, __FILE__, __LINE__); // now butcher the elements according to vertonseam and tri->facesfront // and then compact the vertex set to remove duplicates - for (i = 0;i < loadmodel->aliasdata_meshes->num_triangles;i++) + for (i = 0;i < loadmodel->alias.aliasdata_meshes->num_triangles;i++) if (!LittleLong(pintriangles[i].facesfront)) // backface for (j = 0;j < 3;j++) - if (vertonseam[loadmodel->aliasdata_meshes->data_element3i[i*3+j]]) - loadmodel->aliasdata_meshes->data_element3i[i*3+j] += numverts; + if (vertonseam[loadmodel->alias.aliasdata_meshes->data_element3i[i*3+j]]) + loadmodel->alias.aliasdata_meshes->data_element3i[i*3+j] += numverts; // count the usage // (this uses vertremap to count usage to save some memory) for (i = 0;i < numverts*2;i++) vertremap[i] = 0; - for (i = 0;i < loadmodel->aliasdata_meshes->num_triangles*3;i++) - vertremap[loadmodel->aliasdata_meshes->data_element3i[i]]++; + for (i = 0;i < loadmodel->alias.aliasdata_meshes->num_triangles*3;i++) + vertremap[loadmodel->alias.aliasdata_meshes->data_element3i[i]]++; // build remapping table and compact array - loadmodel->aliasdata_meshes->num_vertices = 0; + loadmodel->alias.aliasdata_meshes->num_vertices = 0; for (i = 0;i < numverts*2;i++) { if (vertremap[i]) { - vertremap[i] = loadmodel->aliasdata_meshes->num_vertices; - vertst[loadmodel->aliasdata_meshes->num_vertices*2+0] = vertst[i*2+0]; - vertst[loadmodel->aliasdata_meshes->num_vertices*2+1] = vertst[i*2+1]; - loadmodel->aliasdata_meshes->num_vertices++; + vertremap[i] = loadmodel->alias.aliasdata_meshes->num_vertices; + vertst[loadmodel->alias.aliasdata_meshes->num_vertices*2+0] = vertst[i*2+0]; + vertst[loadmodel->alias.aliasdata_meshes->num_vertices*2+1] = vertst[i*2+1]; + loadmodel->alias.aliasdata_meshes->num_vertices++; } else vertremap[i] = -1; // not used at all } // remap the elements to the new vertex set - for (i = 0;i < loadmodel->aliasdata_meshes->num_triangles * 3;i++) - loadmodel->aliasdata_meshes->data_element3i[i] = vertremap[loadmodel->aliasdata_meshes->data_element3i[i]]; + for (i = 0;i < loadmodel->alias.aliasdata_meshes->num_triangles * 3;i++) + loadmodel->alias.aliasdata_meshes->data_element3i[i] = vertremap[loadmodel->alias.aliasdata_meshes->data_element3i[i]]; // store the texture coordinates - loadmodel->aliasdata_meshes->data_texcoord2f = Mem_Alloc(loadmodel->mempool, sizeof(float[2]) * loadmodel->aliasdata_meshes->num_vertices); - for (i = 0;i < loadmodel->aliasdata_meshes->num_vertices;i++) + loadmodel->alias.aliasdata_meshes->data_texcoord2f = Mem_Alloc(loadmodel->mempool, sizeof(float[2]) * loadmodel->alias.aliasdata_meshes->num_vertices); + for (i = 0;i < loadmodel->alias.aliasdata_meshes->num_vertices;i++) { - loadmodel->aliasdata_meshes->data_texcoord2f[i*2+0] = vertst[i*2+0]; - loadmodel->aliasdata_meshes->data_texcoord2f[i*2+1] = vertst[i*2+1]; + loadmodel->alias.aliasdata_meshes->data_texcoord2f[i*2+0] = vertst[i*2+0]; + loadmodel->alias.aliasdata_meshes->data_texcoord2f[i*2+1] = vertst[i*2+1]; } // load the frames loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); - loadmodel->aliasdata_meshes->data_aliasvertex3f = Mem_Alloc(loadmodel->mempool, sizeof(float[4][3]) * loadmodel->aliasdata_meshes->num_frames * loadmodel->aliasdata_meshes->num_vertices); - loadmodel->aliasdata_meshes->data_aliassvector3f = loadmodel->aliasdata_meshes->data_aliasvertex3f + loadmodel->aliasdata_meshes->num_frames * loadmodel->aliasdata_meshes->num_vertices * 3 * 1; - loadmodel->aliasdata_meshes->data_aliastvector3f = loadmodel->aliasdata_meshes->data_aliasvertex3f + loadmodel->aliasdata_meshes->num_frames * loadmodel->aliasdata_meshes->num_vertices * 3 * 2; - loadmodel->aliasdata_meshes->data_aliasnormal3f = loadmodel->aliasdata_meshes->data_aliasvertex3f + loadmodel->aliasdata_meshes->num_frames * loadmodel->aliasdata_meshes->num_vertices * 3 * 3; + loadmodel->alias.aliasdata_meshes->data_aliasvertex3f = Mem_Alloc(loadmodel->mempool, sizeof(float[4][3]) * loadmodel->alias.aliasdata_meshes->num_frames * loadmodel->alias.aliasdata_meshes->num_vertices); + loadmodel->alias.aliasdata_meshes->data_aliassvector3f = loadmodel->alias.aliasdata_meshes->data_aliasvertex3f + loadmodel->alias.aliasdata_meshes->num_frames * loadmodel->alias.aliasdata_meshes->num_vertices * 3 * 1; + loadmodel->alias.aliasdata_meshes->data_aliastvector3f = loadmodel->alias.aliasdata_meshes->data_aliasvertex3f + loadmodel->alias.aliasdata_meshes->num_frames * loadmodel->alias.aliasdata_meshes->num_vertices * 3 * 2; + loadmodel->alias.aliasdata_meshes->data_aliasnormal3f = loadmodel->alias.aliasdata_meshes->data_aliasvertex3f + loadmodel->alias.aliasdata_meshes->num_frames * loadmodel->alias.aliasdata_meshes->num_vertices * 3 * 3; Mod_MDL_LoadFrames (startframes, numverts, scale, translate, vertremap); - loadmodel->aliasdata_meshes->data_neighbor3i = Mem_Alloc(loadmodel->mempool, loadmodel->aliasdata_meshes->num_triangles * sizeof(int[3])); - Mod_BuildTriangleNeighbors(loadmodel->aliasdata_meshes->data_neighbor3i, loadmodel->aliasdata_meshes->data_element3i, loadmodel->aliasdata_meshes->num_triangles); - for (i = 0;i < loadmodel->aliasdata_meshes->num_skins;i++) - Mod_BuildAliasSkinFromSkinFrame(loadmodel->aliasdata_meshes->data_skins + i, loadmodel->skinframes + i); + loadmodel->alias.aliasdata_meshes->data_neighbor3i = Mem_Alloc(loadmodel->mempool, loadmodel->alias.aliasdata_meshes->num_triangles * sizeof(int[3])); + Mod_BuildTriangleNeighbors(loadmodel->alias.aliasdata_meshes->data_neighbor3i, loadmodel->alias.aliasdata_meshes->data_element3i, loadmodel->alias.aliasdata_meshes->num_triangles); + for (i = 0;i < loadmodel->alias.aliasdata_meshes->num_skins;i++) + Mod_BuildAliasSkinFromSkinFrame(loadmodel->alias.aliasdata_meshes->data_skins + i, loadmodel->skinframes + i); Mod_CalcAliasModelBBoxes(); Mem_Free(vertst); @@ -537,7 +537,7 @@ void Mod_IDP2_Load(model_t *mod, void *buffer) loadmodel->name, version, MD2ALIAS_VERSION); loadmodel->type = mod_alias; - loadmodel->aliastype = ALIASTYPE_ALIAS; + loadmodel->alias.aliastype = ALIASTYPE_ALIAS; loadmodel->DrawSky = NULL; loadmodel->Draw = R_Model_Alias_Draw; loadmodel->DrawFakeShadow = R_Model_Alias_DrawFakeShadow; @@ -565,15 +565,15 @@ void Mod_IDP2_Load(model_t *mod, void *buffer) if (LittleLong(pinmodel->ofs_glcmds <= 0) || LittleLong(pinmodel->ofs_glcmds) >= end) Host_Error ("%s is not a valid model", loadmodel->name); - loadmodel->aliasnum_meshes = 1; - loadmodel->aliasdata_meshes = Mem_Alloc(loadmodel->mempool, sizeof(aliasmesh_t)); + loadmodel->alias.aliasnum_meshes = 1; + loadmodel->alias.aliasdata_meshes = Mem_Alloc(loadmodel->mempool, sizeof(aliasmesh_t)); loadmodel->numskins = LittleLong(pinmodel->num_skins); numxyz = LittleLong(pinmodel->num_xyz); numst = LittleLong(pinmodel->num_st); - loadmodel->aliasdata_meshes->num_triangles = LittleLong(pinmodel->num_tris); + loadmodel->alias.aliasdata_meshes->num_triangles = LittleLong(pinmodel->num_tris); loadmodel->numframes = LittleLong(pinmodel->num_frames); - loadmodel->aliasdata_meshes->num_frames = loadmodel->numframes; + loadmodel->alias.aliasdata_meshes->num_frames = loadmodel->numframes; loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, loadmodel->numframes * sizeof(animscene_t)); loadmodel->flags = 0; // there are no MD2 flags @@ -594,8 +594,8 @@ void Mod_IDP2_Load(model_t *mod, void *buffer) loadmodel->numskins = 1; loadmodel->skinframes = Mem_Alloc(loadmodel->mempool, sizeof(skinframe_t) * loadmodel->numskins); } - loadmodel->aliasdata_meshes->num_skins = loadmodel->numskins; - loadmodel->aliasdata_meshes->data_skins = Mem_Alloc(loadmodel->mempool, loadmodel->aliasdata_meshes->num_skins * sizeof(aliasskin_t)); + loadmodel->alias.aliasdata_meshes->num_skins = loadmodel->numskins; + loadmodel->alias.aliasdata_meshes->data_skins = Mem_Alloc(loadmodel->mempool, loadmodel->alias.aliasdata_meshes->num_skins * sizeof(aliasskin_t)); loadmodel->skinscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numskins); for (i = 0;i < loadmodel->numskins;i++) @@ -630,11 +630,11 @@ void Mod_IDP2_Load(model_t *mod, void *buffer) } md2verthash = Mem_Alloc(tempmempool, 256 * sizeof(hash)); - md2verthashdata = Mem_Alloc(tempmempool, loadmodel->aliasdata_meshes->num_triangles * 3 * sizeof(*hash)); + md2verthashdata = Mem_Alloc(tempmempool, loadmodel->alias.aliasdata_meshes->num_triangles * 3 * sizeof(*hash)); // swap the triangle list num = 0; - loadmodel->aliasdata_meshes->data_element3i = Mem_Alloc(loadmodel->mempool, loadmodel->aliasdata_meshes->num_triangles * sizeof(int[3])); - for (i = 0;i < loadmodel->aliasdata_meshes->num_triangles;i++) + loadmodel->alias.aliasdata_meshes->data_element3i = Mem_Alloc(loadmodel->mempool, loadmodel->alias.aliasdata_meshes->num_triangles * sizeof(int[3])); + for (i = 0;i < loadmodel->alias.aliasdata_meshes->num_triangles;i++) { for (j = 0;j < 3;j++) { @@ -665,22 +665,22 @@ void Mod_IDP2_Load(model_t *mod, void *buffer) hash->next = md2verthash[hashindex]; md2verthash[hashindex] = hash; } - loadmodel->aliasdata_meshes->data_element3i[i*3+j] = (hash - md2verthashdata); + loadmodel->alias.aliasdata_meshes->data_element3i[i*3+j] = (hash - md2verthashdata); } } Mem_Free(stverts); numverts = num; - loadmodel->aliasdata_meshes->num_vertices = numverts; + loadmodel->alias.aliasdata_meshes->num_vertices = numverts; vertremap = Mem_Alloc(loadmodel->mempool, num * sizeof(int)); - loadmodel->aliasdata_meshes->data_texcoord2f = Mem_Alloc(loadmodel->mempool, num * sizeof(float[2])); + loadmodel->alias.aliasdata_meshes->data_texcoord2f = Mem_Alloc(loadmodel->mempool, num * sizeof(float[2])); for (i = 0;i < num;i++) { hash = md2verthashdata + i; vertremap[i] = hash->xyz; - loadmodel->aliasdata_meshes->data_texcoord2f[i*2+0] = hash->st[0]; - loadmodel->aliasdata_meshes->data_texcoord2f[i*2+1] = hash->st[1]; + loadmodel->alias.aliasdata_meshes->data_texcoord2f[i*2+0] = hash->st[0]; + loadmodel->alias.aliasdata_meshes->data_texcoord2f[i*2+1] = hash->st[1]; } Mem_Free(md2verthash); @@ -688,11 +688,11 @@ void Mod_IDP2_Load(model_t *mod, void *buffer) // load the frames datapointer = (base + LittleLong(pinmodel->ofs_frames)); - loadmodel->aliasdata_meshes->data_aliasvertex3f = Mem_Alloc(loadmodel->mempool, numverts * loadmodel->aliasdata_meshes->num_frames * sizeof(float[4][3])); - loadmodel->aliasdata_meshes->data_aliassvector3f = loadmodel->aliasdata_meshes->data_aliasvertex3f + numverts * loadmodel->aliasdata_meshes->num_frames * 3 * 1; - loadmodel->aliasdata_meshes->data_aliastvector3f = loadmodel->aliasdata_meshes->data_aliasvertex3f + numverts * loadmodel->aliasdata_meshes->num_frames * 3 * 2; - loadmodel->aliasdata_meshes->data_aliasnormal3f = loadmodel->aliasdata_meshes->data_aliasvertex3f + numverts * loadmodel->aliasdata_meshes->num_frames * 3 * 3; - for (i = 0;i < loadmodel->aliasdata_meshes->num_frames;i++) + loadmodel->alias.aliasdata_meshes->data_aliasvertex3f = Mem_Alloc(loadmodel->mempool, numverts * loadmodel->alias.aliasdata_meshes->num_frames * sizeof(float[4][3])); + loadmodel->alias.aliasdata_meshes->data_aliassvector3f = loadmodel->alias.aliasdata_meshes->data_aliasvertex3f + numverts * loadmodel->alias.aliasdata_meshes->num_frames * 3 * 1; + loadmodel->alias.aliasdata_meshes->data_aliastvector3f = loadmodel->alias.aliasdata_meshes->data_aliasvertex3f + numverts * loadmodel->alias.aliasdata_meshes->num_frames * 3 * 2; + loadmodel->alias.aliasdata_meshes->data_aliasnormal3f = loadmodel->alias.aliasdata_meshes->data_aliasvertex3f + numverts * loadmodel->alias.aliasdata_meshes->num_frames * 3 * 3; + for (i = 0;i < loadmodel->alias.aliasdata_meshes->num_frames;i++) { pinframe = (md2frame_t *)datapointer; datapointer += sizeof(md2frame_t); @@ -701,8 +701,8 @@ void Mod_IDP2_Load(model_t *mod, void *buffer) scale[j] = LittleFloat(pinframe->scale[j]); translate[j] = LittleFloat(pinframe->translate[j]); } - Mod_MD2_ConvertVerts(scale, translate, (void *)datapointer, loadmodel->aliasdata_meshes->data_aliasvertex3f + i * numverts * 3, numverts, vertremap); - Mod_BuildTextureVectorsAndNormals(loadmodel->aliasdata_meshes->num_vertices, loadmodel->aliasdata_meshes->num_triangles, loadmodel->aliasdata_meshes->data_aliasvertex3f + i * loadmodel->aliasdata_meshes->num_vertices * 3, loadmodel->aliasdata_meshes->data_texcoord2f, loadmodel->aliasdata_meshes->data_element3i, loadmodel->aliasdata_meshes->data_aliassvector3f + i * loadmodel->aliasdata_meshes->num_vertices * 3, loadmodel->aliasdata_meshes->data_aliastvector3f + i * loadmodel->aliasdata_meshes->num_vertices * 3, loadmodel->aliasdata_meshes->data_aliasnormal3f + i * loadmodel->aliasdata_meshes->num_vertices * 3); + Mod_MD2_ConvertVerts(scale, translate, (void *)datapointer, loadmodel->alias.aliasdata_meshes->data_aliasvertex3f + i * numverts * 3, numverts, vertremap); + Mod_BuildTextureVectorsAndNormals(loadmodel->alias.aliasdata_meshes->num_vertices, loadmodel->alias.aliasdata_meshes->num_triangles, loadmodel->alias.aliasdata_meshes->data_aliasvertex3f + i * loadmodel->alias.aliasdata_meshes->num_vertices * 3, loadmodel->alias.aliasdata_meshes->data_texcoord2f, loadmodel->alias.aliasdata_meshes->data_element3i, loadmodel->alias.aliasdata_meshes->data_aliassvector3f + i * loadmodel->alias.aliasdata_meshes->num_vertices * 3, loadmodel->alias.aliasdata_meshes->data_aliastvector3f + i * loadmodel->alias.aliasdata_meshes->num_vertices * 3, loadmodel->alias.aliasdata_meshes->data_aliasnormal3f + i * loadmodel->alias.aliasdata_meshes->num_vertices * 3); datapointer += numxyz * sizeof(trivertx_t); strcpy(loadmodel->animscenes[i].name, pinframe->name); @@ -714,10 +714,10 @@ void Mod_IDP2_Load(model_t *mod, void *buffer) Mem_Free(vertremap); - loadmodel->aliasdata_meshes->data_neighbor3i = Mem_Alloc(loadmodel->mempool, loadmodel->aliasdata_meshes->num_triangles * sizeof(int[3])); - Mod_BuildTriangleNeighbors(loadmodel->aliasdata_meshes->data_neighbor3i, loadmodel->aliasdata_meshes->data_element3i, loadmodel->aliasdata_meshes->num_triangles); - for (i = 0;i < loadmodel->aliasdata_meshes->num_skins;i++) - Mod_BuildAliasSkinFromSkinFrame(loadmodel->aliasdata_meshes->data_skins + i, loadmodel->skinframes + i); + loadmodel->alias.aliasdata_meshes->data_neighbor3i = Mem_Alloc(loadmodel->mempool, loadmodel->alias.aliasdata_meshes->num_triangles * sizeof(int[3])); + Mod_BuildTriangleNeighbors(loadmodel->alias.aliasdata_meshes->data_neighbor3i, loadmodel->alias.aliasdata_meshes->data_element3i, loadmodel->alias.aliasdata_meshes->num_triangles); + for (i = 0;i < loadmodel->alias.aliasdata_meshes->num_skins;i++) + Mod_BuildAliasSkinFromSkinFrame(loadmodel->alias.aliasdata_meshes->data_skins + i, loadmodel->skinframes + i); Mod_CalcAliasModelBBoxes(); } @@ -740,7 +740,7 @@ void Mod_IDP3_Load(model_t *mod, void *buffer) loadmodel->name, version, MD3VERSION); loadmodel->type = mod_alias; - loadmodel->aliastype = ALIASTYPE_ALIAS; + loadmodel->alias.aliastype = ALIASTYPE_ALIAS; loadmodel->DrawSky = NULL; loadmodel->Draw = R_Model_Alias_Draw; loadmodel->DrawFakeShadow = R_Model_Alias_DrawFakeShadow; @@ -752,7 +752,7 @@ void Mod_IDP3_Load(model_t *mod, void *buffer) // set up some global info about the model loadmodel->numframes = LittleLong(pinmodel->num_frames); loadmodel->numskins = 1; - loadmodel->aliasnum_meshes = LittleLong(pinmodel->num_meshes); + loadmodel->alias.aliasnum_meshes = LittleLong(pinmodel->num_meshes); loadmodel->skinscenes = Mem_Alloc(loadmodel->mempool, loadmodel->numskins * sizeof(animscene_t)); loadmodel->skinscenes[0].firstframe = 0; loadmodel->skinscenes[0].framecount = 1; @@ -773,12 +773,12 @@ void Mod_IDP3_Load(model_t *mod, void *buffer) // tags are not loaded yet // load meshes - loadmodel->aliasdata_meshes = Mem_Alloc(loadmodel->mempool, loadmodel->aliasnum_meshes * sizeof(aliasmesh_t)); - for (i = 0, pinmesh = (md3mesh_t *)((qbyte *)pinmodel + LittleLong(pinmodel->lump_meshes));i < loadmodel->aliasnum_meshes;i++, pinmesh = (md3mesh_t *)((qbyte *)pinmesh + LittleLong(pinmesh->lump_end))) + loadmodel->alias.aliasdata_meshes = Mem_Alloc(loadmodel->mempool, loadmodel->alias.aliasnum_meshes * sizeof(aliasmesh_t)); + for (i = 0, pinmesh = (md3mesh_t *)((qbyte *)pinmodel + LittleLong(pinmodel->lump_meshes));i < loadmodel->alias.aliasnum_meshes;i++, pinmesh = (md3mesh_t *)((qbyte *)pinmesh + LittleLong(pinmesh->lump_end))) { if (memcmp(pinmesh->identifier, "IDP3", 4)) Host_Error("Mod_IDP3_Load: invalid mesh identifier (not IDP3)\n"); - mesh = loadmodel->aliasdata_meshes + i; + mesh = loadmodel->alias.aliasdata_meshes + i; mesh->num_skins = loadmodel->numskins; mesh->num_frames = LittleLong(pinmesh->num_frames); mesh->num_vertices = LittleLong(pinmesh->num_vertices); @@ -835,7 +835,7 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer) Host_Error ("Mod_ZYMOTICMODEL_Load: only type 1 (skeletal pose) models are currently supported (name = %s)\n", loadmodel->name); loadmodel->type = mod_alias; - loadmodel->aliastype = ALIASTYPE_ZYM; + loadmodel->alias.aliastype = ALIASTYPE_ZYM; loadmodel->DrawSky = NULL; loadmodel->Draw = R_Model_Zymotic_Draw; loadmodel->DrawFakeShadow = NULL;//R_Model_Zymotic_DrawFakeShadow; @@ -853,11 +853,11 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer) pheader->maxs[1] = BigFloat(pinmodel->maxs[1]); pheader->maxs[2] = BigFloat(pinmodel->maxs[2]); pheader->radius = BigFloat(pinmodel->radius); - pheader->numverts = loadmodel->zymnum_verts = BigLong(pinmodel->numverts); - pheader->numtris = loadmodel->zymnum_tris = BigLong(pinmodel->numtris); - pheader->numshaders = loadmodel->zymnum_shaders = BigLong(pinmodel->numshaders); - pheader->numbones = loadmodel->zymnum_bones = BigLong(pinmodel->numbones); - pheader->numscenes = loadmodel->zymnum_scenes = BigLong(pinmodel->numscenes); + pheader->numverts = loadmodel->alias.zymnum_verts = BigLong(pinmodel->numverts); + pheader->numtris = loadmodel->alias.zymnum_tris = BigLong(pinmodel->numtris); + pheader->numshaders = loadmodel->alias.zymnum_shaders = BigLong(pinmodel->numshaders); + pheader->numbones = loadmodel->alias.zymnum_bones = BigLong(pinmodel->numbones); + pheader->numscenes = loadmodel->alias.zymnum_scenes = BigLong(pinmodel->numscenes); pheader->lump_scenes.start = BigLong(pinmodel->lump_scenes.start); pheader->lump_scenes.length = BigLong(pinmodel->lump_scenes.length); pheader->lump_poses.start = BigLong(pinmodel->lump_poses.start); @@ -948,24 +948,24 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer) int i; float *poses; // zymlump_t lump_poses; // float pose[numposes][numbones][3][4]; // animation data - loadmodel->zymdata_poses = Mem_Alloc(loadmodel->mempool, pheader->lump_poses.length); + loadmodel->alias.zymdata_poses = Mem_Alloc(loadmodel->mempool, pheader->lump_poses.length); poses = (void *) (pheader->lump_poses.start + pbase); for (i = 0;i < pheader->lump_poses.length / 4;i++) - loadmodel->zymdata_poses[i] = BigFloat(poses[i]); + loadmodel->alias.zymdata_poses[i] = BigFloat(poses[i]); } { int i; zymbone_t *bone; // zymlump_t lump_bones; // zymbone_t bone[numbones]; - loadmodel->zymdata_bones = Mem_Alloc(loadmodel->mempool, pheader->numbones * sizeof(zymbone_t)); + loadmodel->alias.zymdata_bones = Mem_Alloc(loadmodel->mempool, pheader->numbones * sizeof(zymbone_t)); bone = (void *) (pheader->lump_bones.start + pbase); for (i = 0;i < pheader->numbones;i++) { - memcpy(loadmodel->zymdata_bones[i].name, bone[i].name, sizeof(bone[i].name)); - loadmodel->zymdata_bones[i].flags = BigLong(bone[i].flags); - loadmodel->zymdata_bones[i].parent = BigLong(bone[i].parent); - if (loadmodel->zymdata_bones[i].parent >= i) + memcpy(loadmodel->alias.zymdata_bones[i].name, bone[i].name, sizeof(bone[i].name)); + loadmodel->alias.zymdata_bones[i].flags = BigLong(bone[i].flags); + loadmodel->alias.zymdata_bones[i].parent = BigLong(bone[i].parent); + if (loadmodel->alias.zymdata_bones[i].parent >= i) Host_Error("Mod_ZYMOTICMODEL_Load: bone[%i].parent >= %i in %s\n", i, i, loadmodel->name); } } @@ -973,12 +973,12 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer) { int i, *bonecount; // zymlump_t lump_vertbonecounts; // int vertbonecounts[numvertices]; // how many bones influence each vertex (separate mainly to make this compress better) - loadmodel->zymdata_vertbonecounts = Mem_Alloc(loadmodel->mempool, pheader->numverts * sizeof(int)); + loadmodel->alias.zymdata_vertbonecounts = Mem_Alloc(loadmodel->mempool, pheader->numverts * sizeof(int)); bonecount = (void *) (pheader->lump_vertbonecounts.start + pbase); for (i = 0;i < pheader->numverts;i++) { - loadmodel->zymdata_vertbonecounts[i] = BigLong(bonecount[i]); - if (loadmodel->zymdata_vertbonecounts[i] < 1) + loadmodel->alias.zymdata_vertbonecounts[i] = BigLong(bonecount[i]); + if (loadmodel->alias.zymdata_vertbonecounts[i] < 1) Host_Error("Mod_ZYMOTICMODEL_Load: bone vertex count < 1 in %s\n", loadmodel->name); } } @@ -987,14 +987,14 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer) int i; zymvertex_t *vertdata; // zymlump_t lump_verts; // zymvertex_t vert[numvertices]; // see vertex struct - loadmodel->zymdata_verts = Mem_Alloc(loadmodel->mempool, pheader->lump_verts.length); + loadmodel->alias.zymdata_verts = Mem_Alloc(loadmodel->mempool, pheader->lump_verts.length); vertdata = (void *) (pheader->lump_verts.start + pbase); for (i = 0;i < pheader->lump_verts.length / (int) sizeof(zymvertex_t);i++) { - loadmodel->zymdata_verts[i].bonenum = BigLong(vertdata[i].bonenum); - loadmodel->zymdata_verts[i].origin[0] = BigFloat(vertdata[i].origin[0]); - loadmodel->zymdata_verts[i].origin[1] = BigFloat(vertdata[i].origin[1]); - loadmodel->zymdata_verts[i].origin[2] = BigFloat(vertdata[i].origin[2]); + loadmodel->alias.zymdata_verts[i].bonenum = BigLong(vertdata[i].bonenum); + loadmodel->alias.zymdata_verts[i].origin[0] = BigFloat(vertdata[i].origin[0]); + loadmodel->alias.zymdata_verts[i].origin[1] = BigFloat(vertdata[i].origin[1]); + loadmodel->alias.zymdata_verts[i].origin[2] = BigFloat(vertdata[i].origin[2]); } } @@ -1002,7 +1002,7 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer) int i; float *intexcoord2f, *outtexcoord2f; // zymlump_t lump_texcoords; // float texcoords[numvertices][2]; - loadmodel->zymdata_texcoords = outtexcoord2f = Mem_Alloc(loadmodel->mempool, pheader->numverts * sizeof(float[2])); + loadmodel->alias.zymdata_texcoords = outtexcoord2f = Mem_Alloc(loadmodel->mempool, pheader->numverts * sizeof(float[2])); intexcoord2f = (void *) (pheader->lump_texcoords.start + pbase); for (i = 0;i < pheader->numverts;i++) { @@ -1015,12 +1015,12 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer) { int i, count, *renderlist, *renderlistend, *outrenderlist; // zymlump_t lump_render; // int renderlist[rendersize]; // sorted by shader with run lengths (int count), shaders are sequentially used, each run can be used with glDrawElements (each triangle is 3 int indices) - loadmodel->zymdata_renderlist = Mem_Alloc(loadmodel->mempool, pheader->lump_render.length); + loadmodel->alias.zymdata_renderlist = Mem_Alloc(loadmodel->mempool, pheader->lump_render.length); // byteswap, validate, and swap winding order of tris count = pheader->numshaders * sizeof(int) + pheader->numtris * sizeof(int[3]); if (pheader->lump_render.length != count) Host_Error("Mod_ZYMOTICMODEL_Load: renderlist is wrong size in %s (is %i bytes, should be %i bytes)\n", loadmodel->name, pheader->lump_render.length, count); - outrenderlist = loadmodel->zymdata_renderlist = Mem_Alloc(loadmodel->mempool, count); + outrenderlist = loadmodel->alias.zymdata_renderlist = Mem_Alloc(loadmodel->mempool, count); renderlist = (void *) (pheader->lump_render.start + pbase); renderlistend = (void *) ((qbyte *) renderlist + pheader->lump_render.length); for (i = 0;i < pheader->numshaders;i++) @@ -1050,15 +1050,15 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer) int i; char *shadername; // zymlump_t lump_shaders; // char shadername[numshaders][32]; // shaders used on this model - loadmodel->zymdata_textures = Mem_Alloc(loadmodel->mempool, pheader->numshaders * sizeof(rtexture_t *)); + loadmodel->alias.zymdata_textures = Mem_Alloc(loadmodel->mempool, pheader->numshaders * sizeof(rtexture_t *)); shadername = (void *) (pheader->lump_shaders.start + pbase); for (i = 0;i < pheader->numshaders;i++) - loadmodel->zymdata_textures[i] = loadtextureimage(loadmodel->texturepool, shadername + i * 32, 0, 0, true, TEXF_ALPHA | TEXF_PRECACHE | (r_mipskins.integer ? TEXF_MIPMAP : 0)); + loadmodel->alias.zymdata_textures[i] = loadtextureimage(loadmodel->texturepool, shadername + i * 32, 0, 0, true, TEXF_ALPHA | TEXF_PRECACHE | (r_mipskins.integer ? TEXF_MIPMAP : 0)); } { // zymlump_t lump_trizone; // byte trizone[numtris]; // see trizone explanation - loadmodel->zymdata_trizone = Mem_Alloc(loadmodel->mempool, pheader->numtris); - memcpy(loadmodel->zymdata_trizone, (void *) (pheader->lump_trizone.start + pbase), pheader->numtris); + loadmodel->alias.zymdata_trizone = Mem_Alloc(loadmodel->mempool, pheader->numtris); + memcpy(loadmodel->alias.zymdata_trizone, (void *) (pheader->lump_trizone.start + pbase), pheader->numtris); } } diff --git a/model_brush.c b/model_brush.c index f196dd28..bfe485fd 100644 --- a/model_brush.c +++ b/model_brush.c @@ -57,7 +57,7 @@ static mleaf_t *Mod_Q1BSP_PointInLeaf(model_t *model, const vec3_t p) // LordHavoc: modified to start at first clip node, // in other words: first node of the (sub)model - node = model->nodes + model->hulls[0].firstclipnode; + node = model->brushq1.nodes + model->brushq1.hulls[0].firstclipnode; while (node->contents == 0) node = node->children[(node->plane->type < 3 ? p[node->plane->type] : DotProduct(p,node->plane->normal)) < node->plane->dist]; @@ -75,7 +75,7 @@ static int Mod_Q1BSP_PointContents(model_t *model, const vec3_t p) // LordHavoc: modified to start at first clip node, // in other words: first node of the (sub)model - node = model->nodes + model->hulls[0].firstclipnode; + node = model->brushq1.nodes + model->brushq1.hulls[0].firstclipnode; while (node->contents == 0) node = node->children[(node->plane->type < 3 ? p[node->plane->type] : DotProduct(p,node->plane->normal)) < node->plane->dist]; @@ -106,7 +106,7 @@ static void Mod_Q1BSP_FindNonSolidLocation_r_Leaf(findnonsolidlocationinfo_t *in surfmesh_t *mesh; for (surfnum = 0, mark = leaf->firstmarksurface;surfnum < leaf->nummarksurfaces;surfnum++, mark++) { - surf = info->model->surfaces + *mark; + surf = info->model->brushq1.surfaces + *mark; if (surf->flags & SURF_SOLIDCLIP) { #if 0 @@ -239,7 +239,7 @@ static void Mod_Q1BSP_FindNonSolidLocation_r(findnonsolidlocationinfo_t *info, m } } -static void Mod_Q1BSP_FindNonSolidLocation(model_t *model, vec3_t in, vec3_t out, float radius) +static void Mod_Q1BSP_FindNonSolidLocation(model_t *model, const vec3_t in, vec3_t out, float radius) { int i; findnonsolidlocationinfo_t info; @@ -256,7 +256,7 @@ static void Mod_Q1BSP_FindNonSolidLocation(model_t *model, vec3_t in, vec3_t out { VectorClear(info.nudge); info.bestdist = radius; - Mod_Q1BSP_FindNonSolidLocation_r(&info, model->nodes + model->hulls[0].firstclipnode); + Mod_Q1BSP_FindNonSolidLocation_r(&info, model->brushq1.nodes + model->brushq1.hulls[0].firstclipnode); VectorAdd(info.center, info.nudge, info.center); } while (info.bestdist < radius && ++i < 10); @@ -270,7 +270,7 @@ static qbyte *Mod_Q1BSP_DecompressVis(model_t *model, qbyte *in) qbyte *out; int row; - row = (model->numleafs+7)>>3; + row = (model->brushq1.numleafs+7)>>3; out = decompressed; do @@ -295,7 +295,7 @@ static qbyte *Mod_Q1BSP_DecompressVis(model_t *model, qbyte *in) static qbyte *Mod_Q1BSP_LeafPVS(model_t *model, mleaf_t *leaf) { - if (r_novis.integer || leaf == model->leafs || leaf->compressed_vis == NULL) + if (r_novis.integer || leaf == model->brushq1.leafs || leaf->compressed_vis == NULL) return mod_q1bsp_novis; return Mod_Q1BSP_DecompressVis(model, leaf->compressed_vis); } @@ -309,7 +309,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) qbyte *data, *mtdata; char name[256]; - loadmodel->textures = NULL; + loadmodel->brushq1.textures = NULL; if (!l->filelen) return; @@ -319,11 +319,11 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) m->nummiptex = LittleLong (m->nummiptex); // add two slots for notexture walls and notexture liquids - loadmodel->numtextures = m->nummiptex + 2; - loadmodel->textures = Mem_Alloc(loadmodel->mempool, loadmodel->numtextures * sizeof(texture_t)); + loadmodel->brushq1.numtextures = m->nummiptex + 2; + loadmodel->brushq1.textures = Mem_Alloc(loadmodel->mempool, loadmodel->brushq1.numtextures * sizeof(texture_t)); // fill out all slots with notexture - for (i = 0, tx = loadmodel->textures;i < loadmodel->numtextures;i++, tx++) + for (i = 0, tx = loadmodel->brushq1.textures;i < loadmodel->brushq1.numtextures;i++, tx++) { tx->number = i; strcpy(tx->name, "NO TEXTURE FOUND"); @@ -332,7 +332,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) tx->skin.base = r_notexture; tx->shader = &Cshader_wall_lightmap; tx->flags = SURF_SOLIDCLIP; - if (i == loadmodel->numtextures - 1) + if (i == loadmodel->brushq1.numtextures - 1) { tx->flags |= SURF_DRAWTURB | SURF_LIGHTBOTHSIDES; tx->shader = &Cshader_water; @@ -378,7 +378,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) if (name[j] >= 'A' && name[j] <= 'Z') name[j] += 'a' - 'A'; - tx = loadmodel->textures + i; + tx = loadmodel->brushq1.textures + i; strcpy(tx->name, name); tx->width = mtwidth; tx->height = mtheight; @@ -390,7 +390,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) } // LordHavoc: HL sky textures are entirely different than quake - if (!loadmodel->ishlbsp && !strncmp(tx->name, "sky", 3) && mtwidth == 256 && mtheight == 128) + if (!loadmodel->brushq1.ishlbsp && !strncmp(tx->name, "sky", 3) && mtwidth == 256 && mtheight == 128) { if (loadmodel->isworldmodel) { @@ -419,7 +419,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) if (!Mod_LoadSkinFrame(&tx->skin, tx->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE, false, true, true)) { // did not find external texture, load it from the bsp or wad3 - if (loadmodel->ishlbsp) + if (loadmodel->brushq1.ishlbsp) { // internal texture overrides wad qbyte *pixels, *freepixels, *fogpixels; @@ -496,7 +496,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) // sequence the animations for (i = 0;i < m->nummiptex;i++) { - tx = loadmodel->textures + i; + tx = loadmodel->brushq1.textures + i; if (!tx || tx->name[0] != '+' || tx->name[1] == 0 || tx->name[2] == 0) continue; if (tx->anim_total[0] || tx->anim_total[1]) @@ -508,7 +508,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) for (j = i;j < m->nummiptex;j++) { - tx2 = loadmodel->textures + j; + tx2 = loadmodel->brushq1.textures + j; if (!tx2 || tx2->name[0] != '+' || strcmp(tx2->name+2, tx->name+2)) continue; @@ -600,11 +600,11 @@ static void Mod_Q1BSP_LoadLighting(lump_t *l) int i; qbyte *in, *out, *data, d; char litfilename[1024]; - loadmodel->lightdata = NULL; - if (loadmodel->ishlbsp) // LordHavoc: load the colored lighting data straight + loadmodel->brushq1.lightdata = NULL; + if (loadmodel->brushq1.ishlbsp) // LordHavoc: load the colored lighting data straight { - loadmodel->lightdata = Mem_Alloc(loadmodel->mempool, l->filelen); - memcpy(loadmodel->lightdata, mod_base + l->fileofs, l->filelen); + loadmodel->brushq1.lightdata = Mem_Alloc(loadmodel->mempool, l->filelen); + memcpy(loadmodel->brushq1.lightdata, mod_base + l->fileofs, l->filelen); } else // LordHavoc: bsp version 29 (normal white lighting) { @@ -621,8 +621,8 @@ static void Mod_Q1BSP_LoadLighting(lump_t *l) if (i == 1) { Con_DPrintf("loaded %s\n", litfilename); - loadmodel->lightdata = Mem_Alloc(loadmodel->mempool, fs_filesize - 8); - memcpy(loadmodel->lightdata, data + 8, fs_filesize - 8); + loadmodel->brushq1.lightdata = Mem_Alloc(loadmodel->mempool, fs_filesize - 8); + memcpy(loadmodel->brushq1.lightdata, data + 8, fs_filesize - 8); Mem_Free(data); return; } @@ -644,9 +644,9 @@ static void Mod_Q1BSP_LoadLighting(lump_t *l) // LordHavoc: oh well, expand the white lighting data if (!l->filelen) return; - loadmodel->lightdata = Mem_Alloc(loadmodel->mempool, l->filelen*3); - in = loadmodel->lightdata + l->filelen*2; // place the file at the end, so it will not be overwritten until the very last write - out = loadmodel->lightdata; + loadmodel->brushq1.lightdata = Mem_Alloc(loadmodel->mempool, l->filelen*3); + in = loadmodel->brushq1.lightdata + l->filelen*2; // place the file at the end, so it will not be overwritten until the very last write + out = loadmodel->brushq1.lightdata; memcpy(in, mod_base + l->fileofs, l->filelen); for (i = 0;i < l->filelen;i++) { @@ -683,7 +683,7 @@ static void Mod_Q1BSP_LoadLightList(void) s++; numlights++; } - loadmodel->lights = Mem_Alloc(loadmodel->mempool, numlights * sizeof(mlight_t)); + loadmodel->brushq1.lights = Mem_Alloc(loadmodel->mempool, numlights * sizeof(mlight_t)); s = lightsstring; n = 0; while (*s && n < numlights) @@ -696,7 +696,7 @@ static void Mod_Q1BSP_LoadLightList(void) Mem_Free(lightsstring); Host_Error("misparsed lights file!\n"); } - e = loadmodel->lights + n; + e = loadmodel->brushq1.lights + n; *s = 0; a = sscanf(t, "%f %f %f %f %f %f %f %f %f %f %f %f %f %d", &e->origin[0], &e->origin[1], &e->origin[2], &e->falloff, &e->light[0], &e->light[1], &e->light[2], &e->subtract, &e->spotdir[0], &e->spotdir[1], &e->spotdir[2], &e->spotcone, &e->distbias, &e->style); *s = '\n'; @@ -713,7 +713,7 @@ static void Mod_Q1BSP_LoadLightList(void) Mem_Free(lightsstring); Host_Error("misparsed lights file!\n"); } - loadmodel->numlights = numlights; + loadmodel->brushq1.numlights = numlights; Mem_Free(lightsstring); } } @@ -730,7 +730,7 @@ static void Mod_Q1BSP_ProcessLightList(void) qbyte *pvs; vec3_t temp; float *v, radius2; - for (lnum = 0, e = loadmodel->lights;lnum < loadmodel->numlights;lnum++, e++) + for (lnum = 0, e = loadmodel->brushq1.lights;lnum < loadmodel->brushq1.numlights;lnum++, e++) { e->cullradius2 = DotProduct(e->light, e->light) / (e->falloff * e->falloff * 8192.0f * 8192.0f * 2.0f * 2.0f);// + 4096.0f; if (e->cullradius2 > 4096.0f * 4096.0f) @@ -741,15 +741,15 @@ static void Mod_Q1BSP_ProcessLightList(void) pvs = Mod_Q1BSP_DecompressVis(leaf->compressed_vis, loadmodel); else pvs = mod_q1bsp_novis; - for (j = 0;j < loadmodel->numsurfaces;j++) - loadmodel->surfacevisframes[j] = -1; - for (j = 0, leaf = loadmodel->leafs + 1;j < loadmodel->numleafs - 1;j++, leaf++) + for (j = 0;j < loadmodel->brushq1.numsurfaces;j++) + loadmodel->brushq1.surfacevisframes[j] = -1; + for (j = 0, leaf = loadmodel->brushq1.leafs + 1;j < loadmodel->brushq1.numleafs - 1;j++, leaf++) { if (pvs[j >> 3] & (1 << (j & 7))) { for (k = 0, mark = leaf->firstmarksurface;k < leaf->nummarksurfaces;k++, mark++) { - surf = loadmodel->surfaces + *mark; + surf = loadmodel->brushq1.surfaces + *mark; if (surf->number != *mark) Con_Printf("%d != %d\n", surf->number, *mark); dist = DotProduct(e->origin, surf->plane->normal) - surf->plane->dist; @@ -761,24 +761,24 @@ static void Mod_Q1BSP_ProcessLightList(void) temp[1] = bound(surf->poly_mins[1], e->origin[1], surf->poly_maxs[1]) - e->origin[1]; temp[2] = bound(surf->poly_mins[2], e->origin[2], surf->poly_maxs[2]) - e->origin[2]; if (DotProduct(temp, temp) < lightradius2) - loadmodel->surfacevisframes[*mark] = -2; + loadmodel->brushq1.surfacevisframes[*mark] = -2; } } } } // build list of light receiving surfaces e->numsurfaces = 0; - for (j = 0;j < loadmodel->numsurfaces;j++) - if (loadmodel->surfacevisframes[j] == -2) + for (j = 0;j < loadmodel->brushq1.numsurfaces;j++) + if (loadmodel->brushq1.surfacevisframes[j] == -2) e->numsurfaces++; e->surfaces = NULL; if (e->numsurfaces > 0) { e->surfaces = Mem_Alloc(loadmodel->mempool, sizeof(msurface_t *) * e->numsurfaces); e->numsurfaces = 0; - for (j = 0;j < loadmodel->numsurfaces;j++) - if (loadmodel->surfacevisframes[j] == -2) - e->surfaces[e->numsurfaces++] = loadmodel->surfaces + j; + for (j = 0;j < loadmodel->brushq1.numsurfaces;j++) + if (loadmodel->brushq1.surfacevisframes[j] == -2) + e->surfaces[e->numsurfaces++] = loadmodel->brushq1.surfaces + j; } // find bounding box and sphere of lit surfaces // (these will be used for creating a shape to clip the light) @@ -979,11 +979,11 @@ static void Mod_Q1BSP_ProcessLightList(void) static void Mod_Q1BSP_LoadVisibility(lump_t *l) { - loadmodel->visdata = NULL; + loadmodel->brushq1.visdata = NULL; if (!l->filelen) return; - loadmodel->visdata = Mem_Alloc(loadmodel->mempool, l->filelen); - memcpy(loadmodel->visdata, mod_base + l->fileofs, l->filelen); + loadmodel->brushq1.visdata = Mem_Alloc(loadmodel->mempool, l->filelen); + memcpy(loadmodel->brushq1.visdata, mod_base + l->fileofs, l->filelen); } // used only for HalfLife maps @@ -1015,7 +1015,7 @@ static void Mod_Q1BSP_ParseWadsFromEntityLump(const char *data) strcpy(value, com_token); if (!strcmp("wad", key)) // for HalfLife maps { - if (loadmodel->ishlbsp) + if (loadmodel->brushq1.ishlbsp) { j = 0; for (i = 0;i < 4096;i++) @@ -1048,13 +1048,13 @@ static void Mod_Q1BSP_ParseWadsFromEntityLump(const char *data) static void Mod_Q1BSP_LoadEntities(lump_t *l) { - loadmodel->entities = NULL; + loadmodel->brush.entities = NULL; if (!l->filelen) return; - loadmodel->entities = Mem_Alloc(loadmodel->mempool, l->filelen); - memcpy(loadmodel->entities, mod_base + l->fileofs, l->filelen); - if (loadmodel->ishlbsp) - Mod_Q1BSP_ParseWadsFromEntityLump(loadmodel->entities); + loadmodel->brush.entities = Mem_Alloc(loadmodel->mempool, l->filelen); + memcpy(loadmodel->brush.entities, mod_base + l->fileofs, l->filelen); + if (loadmodel->brushq1.ishlbsp) + Mod_Q1BSP_ParseWadsFromEntityLump(loadmodel->brush.entities); } @@ -1070,8 +1070,8 @@ static void Mod_Q1BSP_LoadVertexes(lump_t *l) count = l->filelen / sizeof(*in); out = Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); - loadmodel->vertexes = out; - loadmodel->numvertexes = count; + loadmodel->brushq1.vertexes = out; + loadmodel->brushq1.numvertexes = count; for ( i=0 ; ifilelen / sizeof(*in); out = Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); - loadmodel->submodels = out; - loadmodel->numsubmodels = count; + loadmodel->brushq1.submodels = out; + loadmodel->brushq1.numsubmodels = count; for ( i=0 ; ifilelen / sizeof(*in); out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); - loadmodel->edges = out; - loadmodel->numedges = count; + loadmodel->brushq1.edges = out; + loadmodel->brushq1.numedges = count; for ( i=0 ; ifilelen / sizeof(*in); out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); - loadmodel->texinfo = out; - loadmodel->numtexinfo = count; + loadmodel->brushq1.texinfo = out; + loadmodel->brushq1.numtexinfo = count; for (i = 0;i < count;i++, in++, out++) { @@ -1160,25 +1160,25 @@ static void Mod_Q1BSP_LoadTexinfo(lump_t *l) out->flags = LittleLong(in->flags); out->texture = NULL; - if (loadmodel->textures) + if (loadmodel->brushq1.textures) { - if ((unsigned int) miptex >= (unsigned int) loadmodel->numtextures) - Con_Printf("error in model \"%s\": invalid miptex index %i(of %i)\n", loadmodel->name, miptex, loadmodel->numtextures); + if ((unsigned int) miptex >= (unsigned int) loadmodel->brushq1.numtextures) + Con_Printf("error in model \"%s\": invalid miptex index %i(of %i)\n", loadmodel->name, miptex, loadmodel->brushq1.numtextures); else - out->texture = loadmodel->textures + miptex; + out->texture = loadmodel->brushq1.textures + miptex; } if (out->flags & TEX_SPECIAL) { // if texture chosen is NULL or the shader needs a lightmap, // force to notexture water shader if (out->texture == NULL || out->texture->shader->flags & SHADERFLAGS_NEEDLIGHTMAP) - out->texture = loadmodel->textures + (loadmodel->numtextures - 1); + out->texture = loadmodel->brushq1.textures + (loadmodel->brushq1.numtextures - 1); } else { // if texture chosen is NULL, force to notexture if (out->texture == NULL) - out->texture = loadmodel->textures + (loadmodel->numtextures - 2); + out->texture = loadmodel->brushq1.textures + (loadmodel->brushq1.numtextures - 2); } } } @@ -1365,11 +1365,11 @@ static void Mod_Q1BSP_GenerateSurfacePolygon(msurface_t *surf, int firstedge, in vert = surf->poly_verts = Mem_Alloc(loadmodel->mempool, sizeof(float[3]) * numedges); for (i = 0;i < numedges;i++) { - lindex = loadmodel->surfedges[firstedge + i]; + lindex = loadmodel->brushq1.surfedges[firstedge + i]; if (lindex > 0) - vec = loadmodel->vertexes[loadmodel->edges[lindex].v[0]].position; + vec = loadmodel->brushq1.vertexes[loadmodel->brushq1.edges[lindex].v[0]].position; else - vec = loadmodel->vertexes[loadmodel->edges[-lindex].v[1]].position; + vec = loadmodel->brushq1.vertexes[loadmodel->brushq1.edges[-lindex].v[1]].position; VectorCopy(vec, vert); vert += 3; } @@ -1425,35 +1425,35 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l) if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadFaces: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - loadmodel->surfaces = Mem_Alloc(loadmodel->mempool, count*sizeof(msurface_t)); + loadmodel->brushq1.surfaces = Mem_Alloc(loadmodel->mempool, count*sizeof(msurface_t)); - loadmodel->numsurfaces = count; - loadmodel->surfacevisframes = Mem_Alloc(loadmodel->mempool, count * sizeof(int)); - loadmodel->surfacepvsframes = Mem_Alloc(loadmodel->mempool, count * sizeof(int)); - loadmodel->pvssurflist = Mem_Alloc(loadmodel->mempool, count * sizeof(int)); + loadmodel->brushq1.numsurfaces = count; + loadmodel->brushq1.surfacevisframes = Mem_Alloc(loadmodel->mempool, count * sizeof(int)); + loadmodel->brushq1.surfacepvsframes = Mem_Alloc(loadmodel->mempool, count * sizeof(int)); + loadmodel->brushq1.pvssurflist = Mem_Alloc(loadmodel->mempool, count * sizeof(int)); - for (surfnum = 0, surf = loadmodel->surfaces, totalverts = 0, totaltris = 0, totalmeshes = 0;surfnum < count;surfnum++, totalverts += surf->poly_numverts, totaltris += surf->poly_numverts - 2, totalmeshes++, in++, surf++) + for (surfnum = 0, surf = loadmodel->brushq1.surfaces, totalverts = 0, totaltris = 0, totalmeshes = 0;surfnum < count;surfnum++, totalverts += surf->poly_numverts, totaltris += surf->poly_numverts - 2, totalmeshes++, in++, surf++) { surf->number = surfnum; // FIXME: validate edges, texinfo, etc? firstedge = LittleLong(in->firstedge); numedges = LittleShort(in->numedges); - if ((unsigned int) firstedge > (unsigned int) loadmodel->numsurfedges || (unsigned int) numedges > (unsigned int) loadmodel->numsurfedges || (unsigned int) firstedge + (unsigned int) numedges > (unsigned int) loadmodel->numsurfedges) - Host_Error("Mod_Q1BSP_LoadFaces: invalid edge range (firstedge %i, numedges %i, model edges %i)\n", firstedge, numedges, loadmodel->numsurfedges); + if ((unsigned int) firstedge > (unsigned int) loadmodel->brushq1.numsurfedges || (unsigned int) numedges > (unsigned int) loadmodel->brushq1.numsurfedges || (unsigned int) firstedge + (unsigned int) numedges > (unsigned int) loadmodel->brushq1.numsurfedges) + Host_Error("Mod_Q1BSP_LoadFaces: invalid edge range (firstedge %i, numedges %i, model edges %i)\n", firstedge, numedges, loadmodel->brushq1.numsurfedges); i = LittleShort(in->texinfo); - if ((unsigned int) i >= (unsigned int) loadmodel->numtexinfo) - Host_Error("Mod_Q1BSP_LoadFaces: invalid texinfo index %i(model has %i texinfos)\n", i, loadmodel->numtexinfo); - surf->texinfo = loadmodel->texinfo + i; + if ((unsigned int) i >= (unsigned int) loadmodel->brushq1.numtexinfo) + Host_Error("Mod_Q1BSP_LoadFaces: invalid texinfo index %i(model has %i texinfos)\n", i, loadmodel->brushq1.numtexinfo); + surf->texinfo = loadmodel->brushq1.texinfo + i; surf->flags = surf->texinfo->texture->flags; planenum = LittleShort(in->planenum); - if ((unsigned int) planenum >= (unsigned int) loadmodel->numplanes) - Host_Error("Mod_Q1BSP_LoadFaces: invalid plane index %i (model has %i planes)\n", planenum, loadmodel->numplanes); + if ((unsigned int) planenum >= (unsigned int) loadmodel->brushq1.numplanes) + Host_Error("Mod_Q1BSP_LoadFaces: invalid plane index %i (model has %i planes)\n", planenum, loadmodel->brushq1.numplanes); if (LittleShort(in->side)) surf->flags |= SURF_PLANEBACK; - surf->plane = loadmodel->planes + planenum; + surf->plane = loadmodel->brushq1.planes + planenum; // clear lightmap (filled in later) surf->lightmaptexture = NULL; @@ -1472,10 +1472,10 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l) i = LittleLong(in->lightofs); if (i == -1) surf->samples = NULL; - else if (loadmodel->ishlbsp) // LordHavoc: HalfLife map (bsp version 30) - surf->samples = loadmodel->lightdata + i; + else if (loadmodel->brushq1.ishlbsp) // LordHavoc: HalfLife map (bsp version 30) + surf->samples = loadmodel->brushq1.lightdata + i; else // LordHavoc: white lighting (bsp version 29) - surf->samples = loadmodel->lightdata + (i * 3); + surf->samples = loadmodel->brushq1.lightdata + (i * 3); if (surf->texinfo->texture->shader == &Cshader_wall_lightmap) { @@ -1488,24 +1488,24 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l) } } - loadmodel->entiremesh = Mod_Q1BSP_AllocSurfMesh(totalverts, totaltris); - loadmodel->surfmeshes = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t) * totalmeshes); + loadmodel->brushq1.entiremesh = Mod_Q1BSP_AllocSurfMesh(totalverts, totaltris); + loadmodel->brushq1.surfmeshes = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t) * totalmeshes); - for (surfnum = 0, surf = loadmodel->surfaces, totalverts = 0, totaltris = 0, totalmeshes = 0;surfnum < count;surfnum++, totalverts += surf->poly_numverts, totaltris += surf->poly_numverts - 2, totalmeshes++, surf++) + for (surfnum = 0, surf = loadmodel->brushq1.surfaces, totalverts = 0, totaltris = 0, totalmeshes = 0;surfnum < count;surfnum++, totalverts += surf->poly_numverts, totaltris += surf->poly_numverts - 2, totalmeshes++, surf++) { - mesh = surf->mesh = loadmodel->surfmeshes + totalmeshes; + mesh = surf->mesh = loadmodel->brushq1.surfmeshes + totalmeshes; mesh->numverts = surf->poly_numverts; mesh->numtriangles = surf->poly_numverts - 2; - mesh->vertex3f = loadmodel->entiremesh->vertex3f + totalverts * 3; - mesh->texcoordtexture2f = loadmodel->entiremesh->texcoordtexture2f + totalverts * 2; - mesh->texcoordlightmap2f = loadmodel->entiremesh->texcoordlightmap2f + totalverts * 2; - mesh->texcoorddetail2f = loadmodel->entiremesh->texcoorddetail2f + totalverts * 2; - mesh->svector3f = loadmodel->entiremesh->svector3f + totalverts * 3; - mesh->tvector3f = loadmodel->entiremesh->tvector3f + totalverts * 3; - mesh->normal3f = loadmodel->entiremesh->normal3f + totalverts * 3; - mesh->lightmapoffsets = loadmodel->entiremesh->lightmapoffsets + totalverts; - mesh->element3i = loadmodel->entiremesh->element3i + totaltris * 3; - mesh->neighbor3i = loadmodel->entiremesh->neighbor3i + totaltris * 3; + mesh->vertex3f = loadmodel->brushq1.entiremesh->vertex3f + totalverts * 3; + mesh->texcoordtexture2f = loadmodel->brushq1.entiremesh->texcoordtexture2f + totalverts * 2; + mesh->texcoordlightmap2f = loadmodel->brushq1.entiremesh->texcoordlightmap2f + totalverts * 2; + mesh->texcoorddetail2f = loadmodel->brushq1.entiremesh->texcoorddetail2f + totalverts * 2; + mesh->svector3f = loadmodel->brushq1.entiremesh->svector3f + totalverts * 3; + mesh->tvector3f = loadmodel->brushq1.entiremesh->tvector3f + totalverts * 3; + mesh->normal3f = loadmodel->brushq1.entiremesh->normal3f + totalverts * 3; + mesh->lightmapoffsets = loadmodel->brushq1.entiremesh->lightmapoffsets + totalverts; + mesh->element3i = loadmodel->brushq1.entiremesh->element3i + totaltris * 3; + mesh->neighbor3i = loadmodel->brushq1.entiremesh->neighbor3i + totaltris * 3; surf->lightmaptexturestride = 0; surf->lightmaptexture = NULL; @@ -1548,12 +1548,12 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l) if (r_miplightmaps.integer) { surf->lightmaptexturestride = smax+1; - surf->lightmaptexture = R_LoadTexture2D(loadmodel->texturepool, NULL, surf->lightmaptexturestride, (surf->extents[1]>>4)+1, NULL, loadmodel->lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, TEXF_MIPMAP | TEXF_FORCELINEAR | TEXF_PRECACHE, NULL); + surf->lightmaptexture = R_LoadTexture2D(loadmodel->texturepool, NULL, surf->lightmaptexturestride, (surf->extents[1]>>4)+1, NULL, loadmodel->brushq1.lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, TEXF_MIPMAP | TEXF_FORCELINEAR | TEXF_PRECACHE, NULL); } else { - surf->lightmaptexturestride = R_CompatibleFragmentWidth(smax+1, loadmodel->lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, 0); - surf->lightmaptexture = R_LoadTexture2D(loadmodel->texturepool, NULL, surf->lightmaptexturestride, (surf->extents[1]>>4)+1, NULL, loadmodel->lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, TEXF_FRAGMENT | TEXF_FORCELINEAR | TEXF_PRECACHE, NULL); + surf->lightmaptexturestride = R_CompatibleFragmentWidth(smax+1, loadmodel->brushq1.lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, 0); + surf->lightmaptexture = R_LoadTexture2D(loadmodel->texturepool, NULL, surf->lightmaptexturestride, (surf->extents[1]>>4)+1, NULL, loadmodel->brushq1.lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, TEXF_FRAGMENT | TEXF_FORCELINEAR | TEXF_PRECACHE, NULL); } R_FragmentLocation(surf->lightmaptexture, NULL, NULL, &ubase, &vbase, &uscale, &vscale); uscale = (uscale - ubase) / (smax + 1); @@ -1595,8 +1595,8 @@ static void Mod_Q1BSP_LoadNodes(lump_t *l) count = l->filelen / sizeof(*in); out = Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); - loadmodel->nodes = out; - loadmodel->numnodes = count; + loadmodel->brushq1.nodes = out; + loadmodel->brushq1.numnodes = count; for ( i=0 ; iplanenum); - out->plane = loadmodel->planes + p; + out->plane = loadmodel->brushq1.planes + p; out->firstsurface = LittleShort(in->firstface); out->numsurfaces = LittleShort(in->numfaces); @@ -1616,13 +1616,13 @@ static void Mod_Q1BSP_LoadNodes(lump_t *l) { p = LittleShort(in->children[j]); if (p >= 0) - out->children[j] = loadmodel->nodes + p; + out->children[j] = loadmodel->brushq1.nodes + p; else - out->children[j] = (mnode_t *)(loadmodel->leafs + (-1 - p)); + out->children[j] = (mnode_t *)(loadmodel->brushq1.leafs + (-1 - p)); } } - Mod_Q1BSP_SetParent(loadmodel->nodes, NULL); // sets nodes and leafs + Mod_Q1BSP_SetParent(loadmodel->brushq1.nodes, NULL); // sets nodes and leafs } static void Mod_Q1BSP_LoadLeafs(lump_t *l) @@ -1637,8 +1637,8 @@ static void Mod_Q1BSP_LoadLeafs(lump_t *l) count = l->filelen / sizeof(*in); out = Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); - loadmodel->leafs = out; - loadmodel->numleafs = count; + loadmodel->brushq1.leafs = out; + loadmodel->brushq1.numleafs = count; for ( i=0 ; icontents); out->contents = p; - out->firstmarksurface = loadmodel->marksurfaces + + out->firstmarksurface = loadmodel->brushq1.marksurfaces + LittleShort(in->firstmarksurface); out->nummarksurfaces = LittleShort(in->nummarksurfaces); @@ -1659,7 +1659,7 @@ static void Mod_Q1BSP_LoadLeafs(lump_t *l) if (p == -1) out->compressed_vis = NULL; else - out->compressed_vis = loadmodel->visdata + p; + out->compressed_vis = loadmodel->brushq1.visdata + p; for (j=0 ; j<4 ; j++) out->ambient_sound_level[j] = in->ambient_level[j]; @@ -1680,16 +1680,16 @@ static void Mod_Q1BSP_LoadClipnodes(lump_t *l) count = l->filelen / sizeof(*in); out = Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); - loadmodel->clipnodes = out; - loadmodel->numclipnodes = count; + loadmodel->brushq1.clipnodes = out; + loadmodel->brushq1.numclipnodes = count; - if (loadmodel->ishlbsp) + if (loadmodel->brushq1.ishlbsp) { - hull = &loadmodel->hulls[1]; + hull = &loadmodel->brushq1.hulls[1]; hull->clipnodes = out; hull->firstclipnode = 0; hull->lastclipnode = count-1; - hull->planes = loadmodel->planes; + hull->planes = loadmodel->brushq1.planes; hull->clip_mins[0] = -16; hull->clip_mins[1] = -16; hull->clip_mins[2] = -36; @@ -1698,11 +1698,11 @@ static void Mod_Q1BSP_LoadClipnodes(lump_t *l) hull->clip_maxs[2] = 36; VectorSubtract(hull->clip_maxs, hull->clip_mins, hull->clip_size); - hull = &loadmodel->hulls[2]; + hull = &loadmodel->brushq1.hulls[2]; hull->clipnodes = out; hull->firstclipnode = 0; hull->lastclipnode = count-1; - hull->planes = loadmodel->planes; + hull->planes = loadmodel->brushq1.planes; hull->clip_mins[0] = -32; hull->clip_mins[1] = -32; hull->clip_mins[2] = -32; @@ -1711,11 +1711,11 @@ static void Mod_Q1BSP_LoadClipnodes(lump_t *l) hull->clip_maxs[2] = 32; VectorSubtract(hull->clip_maxs, hull->clip_mins, hull->clip_size); - hull = &loadmodel->hulls[3]; + hull = &loadmodel->brushq1.hulls[3]; hull->clipnodes = out; hull->firstclipnode = 0; hull->lastclipnode = count-1; - hull->planes = loadmodel->planes; + hull->planes = loadmodel->brushq1.planes; hull->clip_mins[0] = -16; hull->clip_mins[1] = -16; hull->clip_mins[2] = -18; @@ -1726,11 +1726,11 @@ static void Mod_Q1BSP_LoadClipnodes(lump_t *l) } else { - hull = &loadmodel->hulls[1]; + hull = &loadmodel->brushq1.hulls[1]; hull->clipnodes = out; hull->firstclipnode = 0; hull->lastclipnode = count-1; - hull->planes = loadmodel->planes; + hull->planes = loadmodel->brushq1.planes; hull->clip_mins[0] = -16; hull->clip_mins[1] = -16; hull->clip_mins[2] = -24; @@ -1739,11 +1739,11 @@ static void Mod_Q1BSP_LoadClipnodes(lump_t *l) hull->clip_maxs[2] = 32; VectorSubtract(hull->clip_maxs, hull->clip_mins, hull->clip_size); - hull = &loadmodel->hulls[2]; + hull = &loadmodel->brushq1.hulls[2]; hull->clipnodes = out; hull->firstclipnode = 0; hull->lastclipnode = count-1; - hull->planes = loadmodel->planes; + hull->planes = loadmodel->brushq1.planes; hull->clip_mins[0] = -32; hull->clip_mins[1] = -32; hull->clip_mins[2] = -24; @@ -1771,21 +1771,21 @@ static void Mod_Q1BSP_MakeHull0(void) int i; hull_t *hull; - hull = &loadmodel->hulls[0]; + hull = &loadmodel->brushq1.hulls[0]; - in = loadmodel->nodes; - out = Mem_Alloc(loadmodel->mempool, loadmodel->numnodes * sizeof(dclipnode_t)); + in = loadmodel->brushq1.nodes; + out = Mem_Alloc(loadmodel->mempool, loadmodel->brushq1.numnodes * sizeof(dclipnode_t)); hull->clipnodes = out; hull->firstclipnode = 0; - hull->lastclipnode = loadmodel->numnodes - 1; - hull->planes = loadmodel->planes; + hull->lastclipnode = loadmodel->brushq1.numnodes - 1; + hull->planes = loadmodel->brushq1.planes; - for (i = 0;i < loadmodel->numnodes;i++, out++, in++) + for (i = 0;i < loadmodel->brushq1.numnodes;i++, out++, in++) { - out->planenum = in->plane - loadmodel->planes; - out->children[0] = in->children[0]->contents < 0 ? in->children[0]->contents : in->children[0] - loadmodel->nodes; - out->children[1] = in->children[1]->contents < 0 ? in->children[1]->contents : in->children[1] - loadmodel->nodes; + out->planenum = in->plane - loadmodel->brushq1.planes; + out->children[0] = in->children[0]->contents < 0 ? in->children[0]->contents : in->children[0] - loadmodel->brushq1.nodes; + out->children[1] = in->children[1]->contents < 0 ? in->children[1]->contents : in->children[1] - loadmodel->brushq1.nodes; } } @@ -1797,15 +1797,15 @@ static void Mod_Q1BSP_LoadMarksurfaces(lump_t *l) in = (void *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadMarksurfaces: funny lump size in %s",loadmodel->name); - loadmodel->nummarksurfaces = l->filelen / sizeof(*in); - loadmodel->marksurfaces = Mem_Alloc(loadmodel->mempool, loadmodel->nummarksurfaces * sizeof(int)); + loadmodel->brushq1.nummarksurfaces = l->filelen / sizeof(*in); + loadmodel->brushq1.marksurfaces = Mem_Alloc(loadmodel->mempool, loadmodel->brushq1.nummarksurfaces * sizeof(int)); - for (i = 0;i < loadmodel->nummarksurfaces;i++) + for (i = 0;i < loadmodel->brushq1.nummarksurfaces;i++) { j = (unsigned) LittleShort(in[i]); - if (j >= loadmodel->numsurfaces) + if (j >= loadmodel->brushq1.numsurfaces) Host_Error("Mod_Q1BSP_LoadMarksurfaces: bad surface number"); - loadmodel->marksurfaces[i] = j; + loadmodel->brushq1.marksurfaces[i] = j; } } @@ -1817,11 +1817,11 @@ static void Mod_Q1BSP_LoadSurfedges(lump_t *l) in = (void *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadSurfedges: funny lump size in %s",loadmodel->name); - loadmodel->numsurfedges = l->filelen / sizeof(*in); - loadmodel->surfedges = Mem_Alloc(loadmodel->mempool, loadmodel->numsurfedges * sizeof(int)); + loadmodel->brushq1.numsurfedges = l->filelen / sizeof(*in); + loadmodel->brushq1.surfedges = Mem_Alloc(loadmodel->mempool, loadmodel->brushq1.numsurfedges * sizeof(int)); - for (i = 0;i < loadmodel->numsurfedges;i++) - loadmodel->surfedges[i] = LittleLong(in[i]); + for (i = 0;i < loadmodel->brushq1.numsurfedges;i++) + loadmodel->brushq1.surfedges[i] = LittleLong(in[i]); } @@ -1835,10 +1835,10 @@ static void Mod_Q1BSP_LoadPlanes(lump_t *l) if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadPlanes: funny lump size in %s", loadmodel->name); - loadmodel->numplanes = l->filelen / sizeof(*in); - loadmodel->planes = out = Mem_Alloc(loadmodel->mempool, loadmodel->numplanes * sizeof(*out)); + loadmodel->brushq1.numplanes = l->filelen / sizeof(*in); + loadmodel->brushq1.planes = out = Mem_Alloc(loadmodel->mempool, loadmodel->brushq1.numplanes * sizeof(*out)); - for (i = 0;i < loadmodel->numplanes;i++, in++, out++) + for (i = 0;i < loadmodel->brushq1.numplanes;i++, in++, out++) { out->normal[0] = LittleFloat(in->normal[0]); out->normal[1] = LittleFloat(in->normal[1]); @@ -2194,8 +2194,8 @@ static void Mod_Q1BSP_FinalizePortals(void) winding_t *w; // recalculate bounding boxes for all leafs(because qbsp is very sloppy) - leaf = loadmodel->leafs; - endleaf = leaf + loadmodel->numleafs; + leaf = loadmodel->brushq1.leafs; + endleaf = leaf + loadmodel->brushq1.numleafs; for (;leaf < endleaf;leaf++) { VectorSet(leaf->mins, 2000000000, 2000000000, 2000000000); @@ -2224,7 +2224,7 @@ static void Mod_Q1BSP_FinalizePortals(void) p = p->chain; } - Mod_Q1BSP_RecursiveRecalcNodeBBox(loadmodel->nodes); + Mod_Q1BSP_RecursiveRecalcNodeBBox(loadmodel->brushq1.nodes); // tally up portal and point counts p = portalchain; @@ -2243,16 +2243,16 @@ static void Mod_Q1BSP_FinalizePortals(void) } p = p->chain; } - loadmodel->portals = Mem_Alloc(loadmodel->mempool, numportals * sizeof(mportal_t) + numpoints * sizeof(mvertex_t)); - loadmodel->numportals = numportals; - loadmodel->portalpoints = (void *)((qbyte *) loadmodel->portals + numportals * sizeof(mportal_t)); - loadmodel->numportalpoints = numpoints; + loadmodel->brushq1.portals = Mem_Alloc(loadmodel->mempool, numportals * sizeof(mportal_t) + numpoints * sizeof(mvertex_t)); + loadmodel->brushq1.numportals = numportals; + loadmodel->brushq1.portalpoints = (void *)((qbyte *) loadmodel->brushq1.portals + numportals * sizeof(mportal_t)); + loadmodel->brushq1.numportalpoints = numpoints; // clear all leaf portal chains - for (i = 0;i < loadmodel->numleafs;i++) - loadmodel->leafs[i].portals = NULL; + for (i = 0;i < loadmodel->brushq1.numleafs;i++) + loadmodel->brushq1.leafs[i].portals = NULL; // process all portals in the global portal chain, while freeing them - portal = loadmodel->portals; - point = loadmodel->portalpoints; + portal = loadmodel->brushq1.portals; + point = loadmodel->brushq1.portalpoints; p = portalchain; portalchain = NULL; while (p) @@ -2514,7 +2514,7 @@ static void Mod_Q1BSP_RecursiveNodePortals(mnode_t *node) static void Mod_Q1BSP_MakePortals(void) { portalchain = NULL; - Mod_Q1BSP_RecursiveNodePortals(loadmodel->nodes); + Mod_Q1BSP_RecursiveNodePortals(loadmodel->brushq1.nodes); Mod_Q1BSP_FinalizePortals(); } @@ -2569,86 +2569,86 @@ static void Mod_Q1BSP_BuildLightmapUpdateChains(mempool_t *mempool, model_t *mod int i, j, stylecounts[256], totalcount, remapstyles[256]; msurface_t *surf; memset(stylecounts, 0, sizeof(stylecounts)); - for (i = 0;i < model->nummodelsurfaces;i++) + for (i = 0;i < model->brushq1.nummodelsurfaces;i++) { - surf = model->surfaces + model->firstmodelsurface + i; + surf = model->brushq1.surfaces + model->brushq1.firstmodelsurface + i; for (j = 0;j < MAXLIGHTMAPS;j++) stylecounts[surf->styles[j]]++; } totalcount = 0; - model->light_styles = 0; + model->brushq1.light_styles = 0; for (i = 0;i < 255;i++) { if (stylecounts[i]) { - remapstyles[i] = model->light_styles++; + remapstyles[i] = model->brushq1.light_styles++; totalcount += stylecounts[i] + 1; } } if (!totalcount) return; - model->light_style = Mem_Alloc(mempool, model->light_styles * sizeof(qbyte)); - model->light_stylevalue = Mem_Alloc(mempool, model->light_styles * sizeof(int)); - model->light_styleupdatechains = Mem_Alloc(mempool, model->light_styles * sizeof(msurface_t **)); - model->light_styleupdatechainsbuffer = Mem_Alloc(mempool, totalcount * sizeof(msurface_t *)); - model->light_styles = 0; + model->brushq1.light_style = Mem_Alloc(mempool, model->brushq1.light_styles * sizeof(qbyte)); + model->brushq1.light_stylevalue = Mem_Alloc(mempool, model->brushq1.light_styles * sizeof(int)); + model->brushq1.light_styleupdatechains = Mem_Alloc(mempool, model->brushq1.light_styles * sizeof(msurface_t **)); + model->brushq1.light_styleupdatechainsbuffer = Mem_Alloc(mempool, totalcount * sizeof(msurface_t *)); + model->brushq1.light_styles = 0; for (i = 0;i < 255;i++) if (stylecounts[i]) - model->light_style[model->light_styles++] = i; + model->brushq1.light_style[model->brushq1.light_styles++] = i; j = 0; - for (i = 0;i < model->light_styles;i++) + for (i = 0;i < model->brushq1.light_styles;i++) { - model->light_styleupdatechains[i] = model->light_styleupdatechainsbuffer + j; - j += stylecounts[model->light_style[i]] + 1; + model->brushq1.light_styleupdatechains[i] = model->brushq1.light_styleupdatechainsbuffer + j; + j += stylecounts[model->brushq1.light_style[i]] + 1; } - for (i = 0;i < model->nummodelsurfaces;i++) + for (i = 0;i < model->brushq1.nummodelsurfaces;i++) { - surf = model->surfaces + model->firstmodelsurface + i; + surf = model->brushq1.surfaces + model->brushq1.firstmodelsurface + i; for (j = 0;j < MAXLIGHTMAPS;j++) if (surf->styles[j] != 255) - *model->light_styleupdatechains[remapstyles[surf->styles[j]]]++ = surf; + *model->brushq1.light_styleupdatechains[remapstyles[surf->styles[j]]]++ = surf; } j = 0; - for (i = 0;i < model->light_styles;i++) + for (i = 0;i < model->brushq1.light_styles;i++) { - *model->light_styleupdatechains[i] = NULL; - model->light_styleupdatechains[i] = model->light_styleupdatechainsbuffer + j; - j += stylecounts[model->light_style[i]] + 1; + *model->brushq1.light_styleupdatechains[i] = NULL; + model->brushq1.light_styleupdatechains[i] = model->brushq1.light_styleupdatechainsbuffer + j; + j += stylecounts[model->brushq1.light_style[i]] + 1; } } static void Mod_Q1BSP_BuildPVSTextureChains(model_t *model) { int i, j; - for (i = 0;i < model->numtextures;i++) - model->pvstexturechainslength[i] = 0; - for (i = 0, j = model->firstmodelsurface;i < model->nummodelsurfaces;i++, j++) + for (i = 0;i < model->brushq1.numtextures;i++) + model->brushq1.pvstexturechainslength[i] = 0; + for (i = 0, j = model->brushq1.firstmodelsurface;i < model->brushq1.nummodelsurfaces;i++, j++) { - if (model->surfacepvsframes[j] == model->pvsframecount) + if (model->brushq1.surfacepvsframes[j] == model->brushq1.pvsframecount) { - model->pvssurflist[model->pvssurflistlength++] = j; - model->pvstexturechainslength[model->surfaces[j].texinfo->texture->number]++; + model->brushq1.pvssurflist[model->brushq1.pvssurflistlength++] = j; + model->brushq1.pvstexturechainslength[model->brushq1.surfaces[j].texinfo->texture->number]++; } } - for (i = 0, j = 0;i < model->numtextures;i++) + for (i = 0, j = 0;i < model->brushq1.numtextures;i++) { - if (model->pvstexturechainslength[i]) + if (model->brushq1.pvstexturechainslength[i]) { - model->pvstexturechains[i] = model->pvstexturechainsbuffer + j; - j += model->pvstexturechainslength[i] + 1; + model->brushq1.pvstexturechains[i] = model->brushq1.pvstexturechainsbuffer + j; + j += model->brushq1.pvstexturechainslength[i] + 1; } else - model->pvstexturechains[i] = NULL; + model->brushq1.pvstexturechains[i] = NULL; } - for (i = 0, j = model->firstmodelsurface;i < model->nummodelsurfaces;i++, j++) - if (model->surfacepvsframes[j] == model->pvsframecount) - *model->pvstexturechains[model->surfaces[j].texinfo->texture->number]++ = model->surfaces + j; - for (i = 0;i < model->numtextures;i++) + for (i = 0, j = model->brushq1.firstmodelsurface;i < model->brushq1.nummodelsurfaces;i++, j++) + if (model->brushq1.surfacepvsframes[j] == model->brushq1.pvsframecount) + *model->brushq1.pvstexturechains[model->brushq1.surfaces[j].texinfo->texture->number]++ = model->brushq1.surfaces + j; + for (i = 0;i < model->brushq1.numtextures;i++) { - if (model->pvstexturechainslength[i]) + if (model->brushq1.pvstexturechainslength[i]) { - *model->pvstexturechains[i] = NULL; - model->pvstexturechains[i] -= model->pvstexturechainslength[i]; + *model->brushq1.pvstexturechains[i] = NULL; + model->brushq1.pvstexturechains[i] -= model->brushq1.pvstexturechainslength[i]; } } } @@ -2676,17 +2676,17 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer) i = LittleLong(header->version); if (i != BSPVERSION && i != 30) Host_Error("Mod_Q1BSP_Load: %s has wrong version number(%i should be %i(Quake) or 30(HalfLife))", mod->name, i, BSPVERSION); - mod->ishlbsp = i == 30; + mod->brushq1.ishlbsp = i == 30; - mod->FindNonSolidLocation = Mod_Q1BSP_FindNonSolidLocation; - mod->PointInLeaf = Mod_Q1BSP_PointInLeaf; - mod->PointContents = Mod_Q1BSP_PointContents; - mod->LeafPVS = Mod_Q1BSP_LeafPVS; - mod->BuildPVSTextureChains = Mod_Q1BSP_BuildPVSTextureChains; + mod->brushq1.FindNonSolidLocation = Mod_Q1BSP_FindNonSolidLocation; + mod->brushq1.PointInLeaf = Mod_Q1BSP_PointInLeaf; + mod->brushq1.PointContents = Mod_Q1BSP_PointContents; + mod->brushq1.LeafPVS = Mod_Q1BSP_LeafPVS; + mod->brushq1.BuildPVSTextureChains = Mod_Q1BSP_BuildPVSTextureChains; if (loadmodel->isworldmodel) { - Cvar_SetValue("halflifebsp", mod->ishlbsp); + Cvar_SetValue("halflifebsp", mod->brushq1.ishlbsp); // until we get a texture for it... R_ResetQuakeSky(); } @@ -2700,7 +2700,7 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer) // load into heap // store which lightmap format to use - mod->lightmaprgba = r_lightmaprgba.integer; + mod->brushq1.lightmaprgba = r_lightmaprgba.integer; Mod_Q1BSP_LoadEntities(&header->lumps[LUMP_ENTITIES]); Mod_Q1BSP_LoadVertexes(&header->lumps[LUMP_VERTEXES]); @@ -2732,19 +2732,19 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer) // // set up the submodels(FIXME: this is confusing) // - for (i = 0;i < mod->numsubmodels;i++) + for (i = 0;i < mod->brushq1.numsubmodels;i++) { - bm = &mod->submodels[i]; + bm = &mod->brushq1.submodels[i]; - mod->hulls[0].firstclipnode = bm->headnode[0]; + mod->brushq1.hulls[0].firstclipnode = bm->headnode[0]; for (j=1 ; jhulls[j].firstclipnode = bm->headnode[j]; - mod->hulls[j].lastclipnode = mod->numclipnodes - 1; + mod->brushq1.hulls[j].firstclipnode = bm->headnode[j]; + mod->brushq1.hulls[j].lastclipnode = mod->brushq1.numclipnodes - 1; } - mod->firstmodelsurface = bm->firstface; - mod->nummodelsurfaces = bm->numfaces; + mod->brushq1.firstmodelsurface = bm->firstface; + mod->brushq1.nummodelsurfaces = bm->numfaces; // this gets altered below if sky is used mod->DrawSky = NULL; @@ -2752,25 +2752,25 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer) mod->DrawFakeShadow = NULL; mod->DrawShadowVolume = R_Model_Brush_DrawShadowVolume; mod->DrawLight = R_Model_Brush_DrawLight; - mod->pvstexturechains = Mem_Alloc(originalloadmodel->mempool, mod->numtextures * sizeof(msurface_t **)); - mod->pvstexturechainsbuffer = Mem_Alloc(originalloadmodel->mempool,(mod->nummodelsurfaces + mod->numtextures) * sizeof(msurface_t *)); - mod->pvstexturechainslength = Mem_Alloc(originalloadmodel->mempool, mod->numtextures * sizeof(int)); + mod->brushq1.pvstexturechains = Mem_Alloc(originalloadmodel->mempool, mod->brushq1.numtextures * sizeof(msurface_t **)); + mod->brushq1.pvstexturechainsbuffer = Mem_Alloc(originalloadmodel->mempool,(mod->brushq1.nummodelsurfaces + mod->brushq1.numtextures) * sizeof(msurface_t *)); + mod->brushq1.pvstexturechainslength = Mem_Alloc(originalloadmodel->mempool, mod->brushq1.numtextures * sizeof(int)); Mod_Q1BSP_BuildPVSTextureChains(mod); Mod_Q1BSP_BuildLightmapUpdateChains(originalloadmodel->mempool, mod); - if (mod->nummodelsurfaces) + if (mod->brushq1.nummodelsurfaces) { // LordHavoc: calculate bmodel bounding box rather than trusting what it says mod->normalmins[0] = mod->normalmins[1] = mod->normalmins[2] = 1000000000.0f; mod->normalmaxs[0] = mod->normalmaxs[1] = mod->normalmaxs[2] = -1000000000.0f; modelyawradius = 0; modelradius = 0; - for (j = 0, surf = &mod->surfaces[mod->firstmodelsurface];j < mod->nummodelsurfaces;j++, surf++) + for (j = 0, surf = &mod->brushq1.surfaces[mod->brushq1.firstmodelsurface];j < mod->brushq1.nummodelsurfaces;j++, surf++) { // we only need to have a drawsky function if it is used(usually only on world model) if (surf->texinfo->texture->shader == &Cshader_sky) mod->DrawSky = R_Model_Brush_DrawSky; // LordHavoc: submodels always clip, even if water - if (mod->numsubmodels - 1) + if (mod->brushq1.numsubmodels - 1) surf->flags |= SURF_SOLIDCLIP; // calculate bounding shapes for (mesh = surf->mesh;mesh;mesh = mesh->chain) @@ -2807,13 +2807,13 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer) // LordHavoc: empty submodel(lacrima.bsp has such a glitch) Con_Printf("warning: empty submodel *%i in %s\n", i+1, loadname); } - Mod_Q1BSP_BuildSurfaceNeighbors(mod->surfaces + mod->firstmodelsurface, mod->nummodelsurfaces, originalloadmodel->mempool); + Mod_Q1BSP_BuildSurfaceNeighbors(mod->brushq1.surfaces + mod->brushq1.firstmodelsurface, mod->brushq1.nummodelsurfaces, originalloadmodel->mempool); - mod->numleafs = bm->visleafs; + mod->brushq1.numleafs = bm->visleafs; // LordHavoc: only register submodels if it is the world // (prevents bsp models from replacing world submodels) - if (loadmodel->isworldmodel && i < (mod->numsubmodels - 1)) + if (loadmodel->isworldmodel && i < (mod->brushq1.numsubmodels - 1)) { char name[10]; // duplicate the basic information @@ -3215,17 +3215,19 @@ void Mod_Q2BSP_Load(model_t *mod, void *buffer) int i; q2dheader_t *header; + Host_Error("Mod_Q2BSP_Load: not yet implemented\n"); + mod->type = mod_brushq2; header = (q2dheader_t *)buffer; i = LittleLong(header->version); if (i != Q2BSPVERSION) - Host_Error("Mod_Q2BSP_Load: %s has wrong version number(%i should be %i)", mod->name, i, BSPVERSION); - mod->ishlbsp = false; + Host_Error("Mod_Q2BSP_Load: %s has wrong version number (%i, should be %i)", mod->name, i, Q2BSPVERSION); + mod->brushq1.ishlbsp = false; if (loadmodel->isworldmodel) { - Cvar_SetValue("halflifebsp", mod->ishlbsp); + Cvar_SetValue("halflifebsp", mod->brushq1.ishlbsp); // until we get a texture for it... R_ResetQuakeSky(); } @@ -3233,11 +3235,11 @@ void Mod_Q2BSP_Load(model_t *mod, void *buffer) mod_base = (qbyte *)header; // swap all the lumps - for (i = 0;i < (int) sizeof(dheader_t) / 4;i++) + for (i = 0;i < (int) sizeof(*header) / 4;i++) ((int *)header)[i] = LittleLong(((int *)header)[i]); // store which lightmap format to use - mod->lightmaprgba = r_lightmaprgba.integer; + mod->brushq1.lightmaprgba = r_lightmaprgba.integer; Mod_Q2BSP_LoadEntities(&header->lumps[Q2LUMP_ENTITIES]); Mod_Q2BSP_LoadPlanes(&header->lumps[Q2LUMP_PLANES]); @@ -3260,17 +3262,417 @@ void Mod_Q2BSP_Load(model_t *mod, void *buffer) Mod_Q2BSP_LoadModels(&header->lumps[Q2LUMP_MODELS]); } +static void Mod_Q3BSP_LoadEntities(lump_t *l) +{ + if (!l->filelen) + return; + loadmodel->brush.entities = Mem_Alloc(loadmodel->mempool, l->filelen); + memcpy(loadmodel->brush.entities, mod_base + l->fileofs, l->filelen); +} + +static void Mod_Q3BSP_LoadTextures(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadTextures: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadPlanes(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadPlanes: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadNodes(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadNodes: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadLeafs(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadLeafs: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadLeafFaces(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadLeafFaces: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadLeafBrushes(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadLeafBrushes: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadModels(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadModels: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadBrushes(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadBrushes: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadBrushSides(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadBrushSides: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadVertices(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadVertices: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadTriangles(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadTriangles: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadEffects(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadEffects: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadFaces(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadFaces: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadLightmaps(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadLightmaps: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadLightGrid(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadLightGrid: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + +static void Mod_Q3BSP_LoadPVS(lump_t *l) +{ +/* + d_t *in; + m_t *out; + int i, count; + + in = (void *)(mod_base + l->fileofs); + if (l->filelen % sizeof(*in)) + Host_Error("Mod_Q3BSP_LoadPVS: funny lump size in %s",loadmodel->name); + count = l->filelen / sizeof(*in); + out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + + loadmodel-> = out; + loadmodel->num = count; + + for (i = 0;i < count;i++, in++, out++) + { + } +*/ +} + void Mod_Q3BSP_Load(model_t *mod, void *buffer) { + int i; + q3dheader_t *header; Host_Error("Mod_Q3BSP_Load: not yet implemented\n"); + + mod->type = mod_brushq2; + + header = (q3dheader_t *)buffer; + + i = LittleLong(header->version); + if (i != Q3BSPVERSION) + Host_Error("Mod_Q3BSP_Load: %s has wrong version number (%i, should be %i)", mod->name, i, Q3BSPVERSION); + if (loadmodel->isworldmodel) + { + Cvar_SetValue("halflifebsp", false); + // until we get a texture for it... + R_ResetQuakeSky(); + } + + mod_base = (qbyte *)header; + + // swap all the lumps + for (i = 0;i < (int) sizeof(*header) / 4;i++) + ((int *)header)[i] = LittleLong(((int *)header)[i]); + + Mod_Q3BSP_LoadEntities(&header->lumps[Q3LUMP_ENTITIES]); + Mod_Q3BSP_LoadTextures(&header->lumps[Q3LUMP_TEXTURES]); + Mod_Q3BSP_LoadPlanes(&header->lumps[Q3LUMP_PLANES]); + Mod_Q3BSP_LoadNodes(&header->lumps[Q3LUMP_NODES]); + Mod_Q3BSP_LoadBrushSides(&header->lumps[Q3LUMP_BRUSHSIDES]); + Mod_Q3BSP_LoadBrushes(&header->lumps[Q3LUMP_BRUSHES]); + Mod_Q3BSP_LoadEffects(&header->lumps[Q3LUMP_EFFECTS]); + Mod_Q3BSP_LoadVertices(&header->lumps[Q3LUMP_VERTICES]); + Mod_Q3BSP_LoadTriangles(&header->lumps[Q3LUMP_TRIANGLES]); + Mod_Q3BSP_LoadLightmaps(&header->lumps[Q3LUMP_LIGHTMAPS]); + Mod_Q3BSP_LoadFaces(&header->lumps[Q3LUMP_FACES]); + Mod_Q3BSP_LoadModels(&header->lumps[Q3LUMP_MODELS]); + Mod_Q3BSP_LoadLeafBrushes(&header->lumps[Q3LUMP_LEAFBRUSHES]); + Mod_Q3BSP_LoadLeafFaces(&header->lumps[Q3LUMP_LEAFFACES]); + Mod_Q3BSP_LoadLeafs(&header->lumps[Q3LUMP_LEAFS]); + Mod_Q3BSP_LoadLightGrid(&header->lumps[Q3LUMP_LIGHTGRID]); + Mod_Q3BSP_LoadPVS(&header->lumps[Q3LUMP_PVS]); } void Mod_IBSP_Load(model_t *mod, void *buffer) { int i = LittleLong(* ((int *)buffer)); - if (i == 46) + if (i == Q3BSPVERSION) Mod_Q3BSP_Load(mod,buffer); - else if (i == 38) + else if (i == Q2BSPVERSION) Mod_Q2BSP_Load(mod,buffer); else Host_Error("Mod_IBSP_Load: unknown/unsupported version %i\n", i); diff --git a/model_brush.h b/model_brush.h index 184f7825..83f11d2d 100644 --- a/model_brush.h +++ b/model_brush.h @@ -544,5 +544,175 @@ typedef struct int firstareaportal; } q2darea_t; + +//Q3 bsp stuff + +#define Q3BSPVERSION 46 + +#define Q3LUMP_ENTITIES 0 // entities to spawn (used by server and client) +#define Q3LUMP_TEXTURES 1 // textures used (used by faces) +#define Q3LUMP_PLANES 2 // planes used (used by bsp nodes) +#define Q3LUMP_NODES 3 // bsp nodes (used by bsp nodes, bsp leafs, rendering, collisions) +#define Q3LUMP_LEAFS 4 // bsp leafs (used by bsp nodes) +#define Q3LUMP_LEAFFACES 5 // array of ints indexing faces (used by leafs) +#define Q3LUMP_LEAFBRUSHES 6 // array of ints indexing brushes (used by leafs) +#define Q3LUMP_MODELS 7 // models (used by rendering, collisions) +#define Q3LUMP_BRUSHES 8 // brushes (used by effects, collisions) +#define Q3LUMP_BRUSHSIDES 9 // brush faces (used by brushes) +#define Q3LUMP_VERTICES 10 // mesh vertices (used by faces) +#define Q3LUMP_TRIANGLES 11 // mesh triangles (used by faces) +#define Q3LUMP_EFFECTS 12 // fog (used by faces) +#define Q3LUMP_FACES 13 // surfaces (used by leafs) +#define Q3LUMP_LIGHTMAPS 14 // lightmap textures (used by faces) +#define Q3LUMP_LIGHTGRID 15 // lighting as a voxel grid (used by rendering) +#define Q3LUMP_PVS 16 // potentially visible set; bit[clusters][clusters] (used by rendering) +#define Q3HEADER_LUMPS 17 + +#define Q3PATHLENGTH 64 + +typedef struct +{ + int ident; + int version; + lump_t lumps[HEADER_LUMPS]; +} q3dheader_t; + +typedef struct +{ + char name[Q3PATHLENGTH]; + int surfaceflags; + int contents; +} +q3dtexture_t; + +// note: planes are paired, the pair of planes with i and i ^ 1 are opposites. +typedef struct +{ + float normal[3]; + float dist; +} +q3dplane_t; + +typedef struct +{ + int planeindex; + int childrenindex[2]; + int mins[3]; + int maxs[3]; +} +q3dnode_t; + +typedef struct +{ + int clusterindex; // pvs index + int areaindex; // area index + int mins[3]; + int maxs[3]; + int firstleafface; + int numleaffaces; + int firstleafbrush; + int numleafbrushes; +} +q3dleaf_t; + +typedef struct +{ + float mins[3]; + float maxs[3]; + int firstface; + int numfaces; + int firstbrush; + int numbrushes; +} +q3dmodel_t; + +typedef struct +{ + int firstbrushside; + int numbrushsides; + int textureindex; +} +q3dbrush_t; + +typedef struct +{ + int planeindex; + int textureindex; +} +q3dbrushside_t; + +typedef struct +{ + float origin3f[3]; + float texcoord2f[2]; + float lightmap2f[2]; + float normal3f[3]; + unsigned char color4ub[4]; +} +q3dvertex_t; + +typedef struct +{ + int offset; // first vertex index of mesh +} +q3dmeshvertex_t; + +typedef struct +{ + char shadername[Q3PATHLENGTH]; + int brushindex; + int unknown; // I read this is always 5 except in q3dm8 which has one effect with -1 +} +q3deffect_t; + +#define Q3FACETYPE_POLYGON 1 // common +#define Q3FACETYPE_PATCH 2 // common +#define Q3FACETYPE_MESH 3 // common +#define Q3FACETYPE_BILLBOARD 4 // rare (is this ever used?) + +typedef struct +{ + int textureindex; + int effectindex; // -1 if none + int type; // Q3FACETYPE + int firstvertex; + int numvertices; + int firstelement; + int numelements; + int lightmapindex; + int lightmap_base[2]; // only needed by lighting util + int lightmap_size[2]; // only needed by lighting util + float lightmap_origin[3]; // only needed by lighting util + float lightmap_vectors[2][3]; // only needed by lighting util + float normal[3]; // only needed by lighting util + int patchsize[2]; // size for Q3FACETYPE_PATCH +} +q3dface_t; + +typedef struct +{ + unsigned char rgb[128][128][3]; +} +q3dlightmap_t; + +typedef struct +{ + unsigned char ambientrgb[3]; + unsigned char diffusergb[3]; + unsigned char diffusepitch; + unsigned char diffuseyaw; +} +q3dlightgrid_t; + +typedef struct +{ + int numclusters; + int chainlength; + // unsigned char chains[]; + // containing bits in 0-7 order (not 7-0 order), + // pvschains[mycluster * chainlength + (thatcluster >> 3)] & (1 << (thatcluster & 7)) +} +q3dpvs_t; + #endif diff --git a/model_shared.h b/model_shared.h index 85935792..0265d892 100644 --- a/model_shared.h +++ b/model_shared.h @@ -89,55 +89,50 @@ shadowmesh_t; #include "matrixlib.h" -typedef struct model_s +typedef struct model_alias_s { - char name[MAX_QPATH]; - // model needs to be loaded if this is true - qboolean needload; - // set if the model is used in current map, models which are not, are purged - qboolean used; - // CRC of the file this model was loaded from, to reload if changed - qboolean crc; - // true if this is the world model (I.E. defines what sky to use, and may contain submodels) - qboolean isworldmodel; - // true if this model is a HalfLife .bsp file - qboolean ishlbsp; - - // mod_brush, mod_alias, mod_sprite - modtype_t type; // LordHavoc: Q2/ZYM model support int aliastype; - // LordHavoc: if true (normally only for sprites) the model/sprite/bmodel is always rendered fullbright - int fullbright; - // number of QC accessible frame(group)s in the model - int numframes; - // number of QC accessible skin(group)s in the model - int numskins; - // whether to randomize animated framegroups - synctype_t synctype; + // mdl/md2/md3 models are the same after loading + int aliasnum_meshes; + aliasmesh_t *aliasdata_meshes; - // flags from the model file - int flags; - // engine calculated flags, ones that can not be set in the file - int flags2; + // for Zymotic models + int zymnum_verts; + int zymnum_tris; + int zymnum_shaders; + int zymnum_bones; + int zymnum_scenes; + float *zymdata_texcoords; + rtexture_t **zymdata_textures; + qbyte *zymdata_trizone; + zymbone_t *zymdata_bones; + unsigned int *zymdata_vertbonecounts; + zymvertex_t *zymdata_verts; + unsigned int *zymdata_renderlist; + float *zymdata_poses; +} +model_alias_t; - // all models use textures... - rtexturepool_t *texturepool; +typedef struct model_sprite_s +{ + int sprnum_type; + mspriteframe_t *sprdata_frames; +} +model_sprite_t; - // volume occupied by the model - // bounding box at angles '0 0 0' - vec3_t normalmins, normalmaxs; - // bounding box if yaw angle is not 0, but pitch and roll are - vec3_t yawmins, yawmaxs; - // bounding box if pitch or roll are used - vec3_t rotatedmins, rotatedmaxs; - // sphere radius, usable at any angles - float radius; - // squared sphere radius for easier comparisons - float radius2; +typedef struct model_brush_s +{ + char *entities; +} +model_brush_t; + +typedef struct model_brushq1_s +{ + // true if this model is a HalfLife .bsp file + qboolean ishlbsp; - // brush model specific int firstmodelsurface, nummodelsurfaces; // lightmap format, set to r_lightmaprgba when model is loaded @@ -189,7 +184,6 @@ typedef struct model_s qbyte *visdata; qbyte *lightdata; - char *entities; int numportals; mportal_t *portals; @@ -222,60 +216,231 @@ typedef struct model_s int light_scalebit; float light_ambient; - // skin animation info - animscene_t *skinscenes; // [numskins] - // skin frame info - skinframe_t *skinframes; + void (*FindNonSolidLocation)(struct model_s *model, const vec3_t in, vec3_t out, vec_t radius); + mleaf_t *(*PointInLeaf)(struct model_s *model, const float *p); + int (*PointContents)(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; - animscene_t *animscenes; // [numframes] +typedef struct model_brushq2_s +{ +} +model_brushq2_t; - // mdl/md2/md3 models are the same after loading - int aliasnum_meshes; - aliasmesh_t *aliasdata_meshes; +typedef struct q3mtexture_s +{ + char name[Q3PATHLENGTH]; + int surfaceflags; + int contents; - // for Zymotic models - int zymnum_verts; - int zymnum_tris; - int zymnum_shaders; - int zymnum_bones; - int zymnum_scenes; - float *zymdata_texcoords; - rtexture_t **zymdata_textures; - qbyte *zymdata_trizone; - zymbone_t *zymdata_bones; - unsigned int *zymdata_vertbonecounts; - zymvertex_t *zymdata_verts; - unsigned int *zymdata_renderlist; - float *zymdata_poses; + int number; + skinframe_t skin; +} +q3mtexture_t; - int sprnum_type; - mspriteframe_t *sprdata_frames; +typedef struct q3mnode_s +{ + int isnode; // true + struct mplane_s *plane; + struct q3mnode_s *parent; + struct q3mnode_s *children[2]; +} +q3mnode_t; + +typedef struct q3mleaf_s +{ + int isnode; // false + int clusterindex; + int areaindex; + vec3_t mins[3]; + vec3_t maxs[3]; + int numleaffaces; + struct q3mface_s **leaffaces; + int numleafbrushes; + struct q3mbrush_s **leafbrushes; +} +q3mleaf_t; + +typedef struct q3mmodel_s +{ + vec3_t mins; + vec3_t maxs; + int numfaces; + struct q3mface_s *faces; + int numbrushes; + struct q3mbrush_s *brushes; +} +q3mmodel_t; + +typedef struct q3mbrush_s +{ + int numsides; + struct q3mbrushside_s *sides; + struct q3mtexture_s *texture; +} +q3mbrush_t; + +typedef struct q3mbrushside_s +{ + struct mplane_s *plane; + struct q3mtexture_s *texture; +} +q3mbrushside_t; + +typedef struct q3meffect_s +{ + char shadername[Q3PATHLENGTH]; + struct q3mbrush_s *brush; + int unknown; // 5 or -1 +} +q3meffect_t; + +typedef struct q3mface_s +{ + struct q3mtexture_s *texture; + struct q3meffect_s *effect; + int type; + int firstvertex; + int numvertices; + int firstelement; + int numelements; + int patchsize[2]; + + float *data_vertex3f; + float *data_texturetexcoord2f; + float *data_lightmaptexcoord2f; + float *data_svector3f; + float *data_tvector3f; + float *data_normal3f; + float *data_color4f; +} +q3mface_t; + +typedef struct model_brushq3_s +{ + int num_textures; + q3mtexture_t *data_textures; + + int num_planes; + mplane_t *data_planes; + + int num_nodes; + q3mnode_t *data_nodes; + + int num_leafs; + q3mleaf_t *data_leafs; + + int num_models; + q3mmodel_t *data_models; + // each submodel gets its own model struct so this is different for each. + q3mmodel_t data_thismodel; + + int num_brushes; + q3mbrush_t *data_brushes; + + int num_brushsides; + q3mbrushside_t *data_brushsides; + + int num_vertices; + float *data_vertex3f; + float *data_texturetexcoord2f; + float *data_lightmaptexcoord2f; + float *data_normal3f; + float *data_color4f; + + int num_triangles; + int *data_element3i; + int *data_neighbor3i; + int num_effects; + q3meffect_t data_effects; - // functions used in both rendering modes + int num_faces; + q3mface_t *data_faces; + + // lightmap textures + int num_lightmaps; + rtexture_t *data_lightmaps; + + // transform world coordinates to lightgrid index + matrix4x4_t num_lightgrid_indexfromworld; + q3dlightgrid_t *data_lightgrid_cells; + + // pvs + int num_pvsclusters; + int num_pvschainlength; + unsigned char *data_pvschains; + // example + //pvschain = model->brushq3.data_pvschains + mycluster * model->brushq3.num_pvschainlength; + //if (pvschain[thatcluster >> 3] & (1 << (thatcluster & 7))) +} +model_brushq3_t; + +typedef struct model_s +{ + // name and path of model, for example "progs/player.mdl" + char name[MAX_QPATH]; + // model needs to be loaded if this is true + qboolean needload; + // set if the model is used in current map, models which are not, are purged + qboolean used; + // true if this is the world model (I.E. defines what sky to use, and may contain submodels) + qboolean isworldmodel; + // CRC of the file this model was loaded from, to reload if changed + unsigned int crc; + // mod_brush, mod_alias, mod_sprite + modtype_t type; + // memory pool for allocations + mempool_t *mempool; + // all models use textures... + rtexturepool_t *texturepool; + // flags from the model file + int flags; + // engine calculated flags, ones that can not be set in the file + int flags2; + // LordHavoc: if true (normally only for sprites) the model/sprite/bmodel is always rendered fullbright + int fullbright; + // number of QC accessible frame(group)s in the model + int numframes; + // number of QC accessible skin(group)s in the model + int numskins; + // whether to randomize animated framegroups + synctype_t synctype; + // bounding box at angles '0 0 0' + vec3_t normalmins, normalmaxs; + // bounding box if yaw angle is not 0, but pitch and roll are + vec3_t yawmins, yawmaxs; + // bounding box if pitch or roll are used + vec3_t rotatedmins, rotatedmaxs; + // sphere radius, usable at any angles + float radius; + // squared sphere radius for easier comparisons + float radius2; + // skin animation info + animscene_t *skinscenes; // [numskins] + // skin frame info + skinframe_t *skinframes; + // skin animation info + animscene_t *animscenes; // [numframes] // draw the model's sky polygons (only used by brush models) void(*DrawSky)(struct entity_render_s *ent); - - // functions used only in normal rendering mode - // draw the model + // 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); - - // functions used only in shadow volume rendering mode // 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); - - void (*FindNonSolidLocation)(struct model_s *model, vec3_t in, vec3_t out, vec_t radius); - mleaf_t *(*PointInLeaf)(struct model_s *model, const float *p); - int (*PointContents)(struct model_s *model, const float *p); - qbyte *(*LeafPVS)(struct model_s *model, mleaf_t *leaf); - void (*BuildPVSTextureChains)(struct model_s *model); - - // memory pool for allocations - mempool_t *mempool; + // fields belonging to each type of model + model_alias_t alias; + model_sprite_t sprite; + model_brush_t brush; + model_brushq1_t brushq1; + model_brushq2_t brushq2; + model_brushq3_t brushq3; } model_t; diff --git a/model_sprite.c b/model_sprite.c index 7fa46ea2..043f9fd2 100644 --- a/model_sprite.c +++ b/model_sprite.c @@ -121,7 +121,7 @@ static void Mod_Sprite_SharedSetup(qbyte *datapointer, int version, int *palette } loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); - loadmodel->sprdata_frames = Mem_Alloc(loadmodel->mempool, sizeof(mspriteframe_t) * realframes); + loadmodel->sprite.sprdata_frames = Mem_Alloc(loadmodel->mempool, sizeof(mspriteframe_t) * realframes); datapointer = startframes; realframes = 0; @@ -166,13 +166,13 @@ static void Mod_Sprite_SharedSetup(qbyte *datapointer, int version, int *palette width = LittleLong (pinframe->width); height = LittleLong (pinframe->height); - loadmodel->sprdata_frames[realframes].left = origin[0]; - loadmodel->sprdata_frames[realframes].right = origin[0] + width; - loadmodel->sprdata_frames[realframes].up = origin[1]; - loadmodel->sprdata_frames[realframes].down = origin[1] - height; + loadmodel->sprite.sprdata_frames[realframes].left = origin[0]; + loadmodel->sprite.sprdata_frames[realframes].right = origin[0] + width; + loadmodel->sprite.sprdata_frames[realframes].up = origin[1]; + loadmodel->sprite.sprdata_frames[realframes].down = origin[1] - height; - x = max(loadmodel->sprdata_frames[realframes].left * loadmodel->sprdata_frames[realframes].left, loadmodel->sprdata_frames[realframes].right * loadmodel->sprdata_frames[realframes].right); - y = max(loadmodel->sprdata_frames[realframes].up * loadmodel->sprdata_frames[realframes].up, loadmodel->sprdata_frames[realframes].down * loadmodel->sprdata_frames[realframes].down); + x = max(loadmodel->sprite.sprdata_frames[realframes].left * loadmodel->sprite.sprdata_frames[realframes].left, loadmodel->sprite.sprdata_frames[realframes].right * loadmodel->sprite.sprdata_frames[realframes].right); + y = max(loadmodel->sprite.sprdata_frames[realframes].up * loadmodel->sprite.sprdata_frames[realframes].up, loadmodel->sprite.sprdata_frames[realframes].down * loadmodel->sprite.sprdata_frames[realframes].down); if (modelradius < x + y) modelradius = x + y; @@ -182,10 +182,10 @@ static void Mod_Sprite_SharedSetup(qbyte *datapointer, int version, int *palette sprintf (name, "%s_%i_%i", tempname, i, j); else sprintf (name, "%s_%i", tempname, i); - loadmodel->sprdata_frames[realframes].texture = loadtextureimagewithmask(loadmodel->texturepool, name, 0, 0, false, (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE); - loadmodel->sprdata_frames[realframes].fogtexture = image_masktex; + loadmodel->sprite.sprdata_frames[realframes].texture = loadtextureimagewithmask(loadmodel->texturepool, name, 0, 0, false, (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE); + loadmodel->sprite.sprdata_frames[realframes].fogtexture = image_masktex; - if (!loadmodel->sprdata_frames[realframes].texture) + if (!loadmodel->sprite.sprdata_frames[realframes].texture) { pixbuf = Mem_Alloc(tempmempool, width*height*4); if (version == SPRITE32_VERSION) @@ -193,7 +193,7 @@ static void Mod_Sprite_SharedSetup(qbyte *datapointer, int version, int *palette else //if (version == SPRITE_VERSION || version == SPRITEHL_VERSION) Image_Copy8bitRGBA(datapointer, pixbuf, width*height, palette); - loadmodel->sprdata_frames[realframes].texture = R_LoadTexture2D (loadmodel->texturepool, name, width, height, pixbuf, TEXTYPE_RGBA, TEXF_ALPHA | (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_CLAMP | TEXF_PRECACHE, NULL); + loadmodel->sprite.sprdata_frames[realframes].texture = R_LoadTexture2D (loadmodel->texturepool, name, width, height, pixbuf, TEXTYPE_RGBA, TEXF_ALPHA | (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_CLAMP | TEXF_PRECACHE, NULL); // make fog version (just alpha) for (k = 0;k < width*height;k++) @@ -206,7 +206,7 @@ static void Mod_Sprite_SharedSetup(qbyte *datapointer, int version, int *palette sprintf (name, "%s_%i_%ifog", tempname, i, j); else sprintf (name, "%s_%ifog", tempname, i); - loadmodel->sprdata_frames[realframes].fogtexture = R_LoadTexture2D (loadmodel->texturepool, name, width, height, pixbuf, TEXTYPE_RGBA, TEXF_ALPHA | (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_CLAMP | TEXF_PRECACHE, NULL); + loadmodel->sprite.sprdata_frames[realframes].fogtexture = R_LoadTexture2D (loadmodel->texturepool, name, width, height, pixbuf, TEXTYPE_RGBA, TEXF_ALPHA | (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_CLAMP | TEXF_PRECACHE, NULL); Mem_Free(pixbuf); } @@ -254,7 +254,7 @@ void Mod_IDSP_Load(model_t *mod, void *buffer) datapointer += sizeof(dsprite_t); loadmodel->numframes = LittleLong (pinqsprite->numframes); - loadmodel->sprnum_type = LittleLong (pinqsprite->type); + loadmodel->sprite.sprnum_type = LittleLong (pinqsprite->type); loadmodel->synctype = LittleLong (pinqsprite->synctype); Mod_Sprite_SharedSetup(datapointer, LittleLong (pinqsprite->version), palette_complete); @@ -265,7 +265,7 @@ void Mod_IDSP_Load(model_t *mod, void *buffer) datapointer += sizeof(dspritehl_t); loadmodel->numframes = LittleLong (pinhlsprite->numframes); - loadmodel->sprnum_type = LittleLong (pinhlsprite->type); + loadmodel->sprite.sprnum_type = LittleLong (pinhlsprite->type); loadmodel->synctype = LittleLong (pinhlsprite->synctype); rendermode = pinhlsprite->rendermode; diff --git a/portals.c b/portals.c index 209e025c..dff58aef 100644 --- a/portals.c +++ b/portals.c @@ -193,9 +193,9 @@ int Portal_CheckPolygon(model_t *model, vec3_t eye, float *polypoints, int numpo portal_markid++; Mod_CheckLoaded(model); - Portal_PolygonRecursiveMarkLeafs(model->nodes, polypoints, numpoints); + Portal_PolygonRecursiveMarkLeafs(model->brushq1.nodes, polypoints, numpoints); - eyeleaf = model->PointInLeaf(model, eye); + eyeleaf = model->brushq1.PointInLeaf(model, eye); // find the center by averaging VectorClear(center); @@ -340,7 +340,7 @@ void Portal_RecursiveFlow_ExactMarkSurfaces(portalrecursioninfo_t *info, int *ma { if (!info->surfacemark[*mark]) { - surf = info->model->surfaces + *mark; + surf = info->model->brushq1.surfaces + *mark; if (surf->poly_numverts) { if (surf->flags & SURF_PLANEBACK) @@ -389,7 +389,7 @@ void Portal_RecursiveFlow (portalrecursioninfo_t *info, mleaf_t *leaf, int first tinyplane_t *newplanes; if (info->leafmark) - info->leafmark[leaf - info->model->leafs] = true; + info->leafmark[leaf - info->model->brushq1.leafs] = true; // mark surfaces in leaf that can be seen through portal if (leaf->nummarksurfaces && info->surfacemark) @@ -494,7 +494,7 @@ void Portal_Visibility(model_t *model, const vec3_t eye, qbyte *leafmark, qbyte VectorCopy(eye, info.eye); info.numfrustumplanes = numfrustumplanes; - Portal_RecursiveFindLeafForFlow(&info, model->nodes); + Portal_RecursiveFindLeafForFlow(&info, model->brushq1.nodes); if (ranoutofportalplanes) Con_Printf("Portal_RecursiveFlow: ran out of %d plane stack when recursing through portals\n", MAXRECURSIVEPORTALPLANES); diff --git a/pr_cmds.c b/pr_cmds.c index ffa23aac..07159201 100644 --- a/pr_cmds.c +++ b/pr_cmds.c @@ -862,7 +862,7 @@ int PF_newcheckclient (int check) // get the PVS for the entity VectorAdd (ent->v->origin, ent->v->view_ofs, org); - memcpy (checkpvs, sv.worldmodel->LeafPVS(sv.worldmodel, sv.worldmodel->PointInLeaf(sv.worldmodel, org)), (sv.worldmodel->numleafs+7)>>3 ); + memcpy (checkpvs, sv.worldmodel->brushq1.LeafPVS(sv.worldmodel, sv.worldmodel->brushq1.PointInLeaf(sv.worldmodel, org)), (sv.worldmodel->brushq1.numleafs+7)>>3 ); return i; } @@ -908,10 +908,10 @@ void PF_checkclient (void) // if current entity can't possibly see the check entity, return 0 self = PROG_TO_EDICT(pr_global_struct->self); VectorAdd (self->v->origin, self->v->view_ofs, view); - leaf = sv.worldmodel->PointInLeaf(sv.worldmodel, view); + leaf = sv.worldmodel->brushq1.PointInLeaf(sv.worldmodel, view); if (leaf) { - l = (leaf - sv.worldmodel->leafs) - 1; + l = (leaf - sv.worldmodel->brushq1.leafs) - 1; if ( (l<0) || !(checkpvs[l>>3] & (1<<(l&7)) ) ) { c_notvis++; @@ -1311,7 +1311,7 @@ void PF_precache_model (void) Host_Error ("PF_Precache_*: Precache can only be done in spawn functions"); s = G_STRING(OFS_PARM0); - if (sv.worldmodel->ishlbsp && ((!s) || (!s[0]))) + if (sv.worldmodel->brushq1.ishlbsp && ((!s) || (!s[0]))) return; G_INT(OFS_RETURN) = G_INT(OFS_PARM0); PR_CheckEmptyString (s); @@ -1497,7 +1497,7 @@ PF_pointcontents */ void PF_pointcontents (void) { - G_FLOAT(OFS_RETURN) = sv.worldmodel->PointContents(sv.worldmodel, G_VECTOR(OFS_PARM0)); + G_FLOAT(OFS_RETURN) = sv.worldmodel->brushq1.PointContents(sv.worldmodel, G_VECTOR(OFS_PARM0)); } /* @@ -2555,9 +2555,9 @@ static msurface_t *getsurface(edict_t *ed, int surfnum) model = sv.models[modelindex]; if (model->type != mod_brush) return NULL; - if (surfnum < 0 || surfnum >= model->nummodelsurfaces) + if (surfnum < 0 || surfnum >= model->brushq1.nummodelsurfaces) return NULL; - return model->surfaces + surfnum + model->firstmodelsurface; + return model->brushq1.surfaces + surfnum + model->brushq1.firstmodelsurface; } @@ -2641,9 +2641,9 @@ void PF_getsurfacenearpoint(void) VectorSubtract(point, ed->v->origin, p); best = -1; bestdist = 1000000000; - for (surfnum = 0;surfnum < model->nummodelsurfaces;surfnum++) + for (surfnum = 0;surfnum < model->brushq1.nummodelsurfaces;surfnum++) { - surf = model->surfaces + surfnum + model->firstmodelsurface; + surf = model->brushq1.surfaces + surfnum + model->brushq1.firstmodelsurface; dist = PlaneDiff(p, surf->plane); dist = dist * dist; if (dist < bestdist) diff --git a/protocol.h b/protocol.h index 4a1e1c2b..13c68768 100644 --- a/protocol.h +++ b/protocol.h @@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // LordHavoc: I think the 96-99 range was going to run out too soon... // so here I jump to 3500 #define DPPROTOCOL_VERSION3 3500 +#define DPPROTOCOL_VERSION4 3501 // model effects #define EF_ROCKET 1 // leave a trail @@ -358,6 +359,31 @@ if server receives ack message in put packet it performs these steps: 1. remove all older frames from database. */ +/* +DPPROTOCOL_VERSION4 +a frame consists of some visible entities in a range (this is stored as start and end, note that end may be less than start if it wrapped). + +these entities are stored in a range (firstentity/endentity) of structs in the entitydata[] buffer. + +to make a commit the server performs these steps: +1. build an entity_frame_t using appropriate functions, containing (some of) the visible entities, this is passed to the Write function to send it. + +This documention is unfinished! +the Write function performs these steps: +1. check if entity frame is larger than MAX_ENTITYFRAME or is larger than available space in database, if so the baseline is defaults, otherwise it is the current baseline of the database. +2. write differences of an entity compared to selected baseline. +3. add entity to entity update in database. +4. if there are more entities to write and packet is not full, go back to step 2. +5. write terminator (0xFFFF) as entity number. +6. return. + + + + + +server updates entities in looping ranges, a frame consists of a range of visible entities (not always all visible entities), +*/ + typedef struct { double time; @@ -398,6 +424,8 @@ typedef struct double time; int framenum; int numentities; + int firstentitynum; + int lastentitynum; vec3_t eye; entity_state_t entitydata[MAX_ENTITY_DATABASE]; } diff --git a/r_light.c b/r_light.c index 2e5067da..65150fda 100644 --- a/r_light.c +++ b/r_light.c @@ -192,7 +192,7 @@ static void R_OldMarkLights (entity_render_t *ent, vec3_t lightorigin, rdlight_t // for comparisons to minimum acceptable light maxdist = rd->cullradius2; - surfacepvsframes = ent->model->surfacepvsframes; + surfacepvsframes = ent->model->brushq1.surfacepvsframes; loc0: if (node->contents < 0) return; @@ -211,10 +211,10 @@ loc0: } // mark the polygons - surf = ent->model->surfaces + node->firstsurface; + surf = ent->model->brushq1.surfaces + node->firstsurface; for (i = 0;i < node->numsurfaces;i++, surf++) { - if (surfacepvsframes[surf->number] != ent->model->pvsframecount) + if (surfacepvsframes[surf->number] != ent->model->brushq1.pvsframecount) continue; dist = ndist; if (surf->flags & SURF_PLANEBACK) @@ -304,7 +304,7 @@ static void R_VisMarkLights (entity_render_t *ent, rdlight_t *rd, int bit, int b Matrix4x4_Transform(&ent->inversematrix, rd->origin, lightorigin); model = ent->model; - pvsleaf = model->PointInLeaf(model, lightorigin); + pvsleaf = model->brushq1.PointInLeaf(model, lightorigin); if (pvsleaf == NULL) return; @@ -312,7 +312,7 @@ static void R_VisMarkLights (entity_render_t *ent, rdlight_t *rd, int bit, int b if (!r_vismarklights.integer || !in) { // told not to use pvs, or there's no pvs to use - R_OldMarkLights(ent, lightorigin, rd, bit, bitindex, model->nodes + model->hulls[0].firstclipnode); + R_OldMarkLights(ent, lightorigin, rd, bit, bitindex, model->brushq1.nodes + model->brushq1.hulls[0].firstclipnode); return; } @@ -324,8 +324,8 @@ static void R_VisMarkLights (entity_render_t *ent, rdlight_t *rd, int bit, int b // for comparisons to minimum acceptable light maxdist = rd->cullradius2; - row = (model->numleafs+7)>>3; - surfacepvsframes = model->surfacepvsframes; + row = (model->brushq1.numleafs+7)>>3; + surfacepvsframes = model->brushq1.surfacepvsframes; k = 0; while (k < row) @@ -339,9 +339,9 @@ static void R_VisMarkLights (entity_render_t *ent, rdlight_t *rd, int bit, int b { // warning to the clumsy: numleafs is one less than it should be, it only counts leafs with vis bits (skips leaf 0) leafnum = (k << 3)+i+1; - if (leafnum > model->numleafs) + if (leafnum > model->brushq1.numleafs) return; - leaf = &model->leafs[leafnum]; + leaf = &model->brushq1.leafs[leafnum]; if (leaf->mins[0] > high[0] || leaf->maxs[0] < low[0] || leaf->mins[1] > high[1] || leaf->maxs[1] < low[1] || leaf->mins[2] > high[2] || leaf->maxs[2] < low[2]) @@ -351,12 +351,12 @@ static void R_VisMarkLights (entity_render_t *ent, rdlight_t *rd, int bit, int b mark = leaf->firstmarksurface; do { - surf = model->surfaces + *mark++; + surf = model->brushq1.surfaces + *mark++; // if not visible in current frame, or already marked because it was in another leaf we passed, skip if (surf->lightframe == lightframe) continue; surf->lightframe = lightframe; - if (surfacepvsframes[surf->number] != model->pvsframecount) + if (surfacepvsframes[surf->number] != model->brushq1.pvsframecount) continue; dist = PlaneDiff(lightorigin, surf->plane); if (surf->flags & SURF_PLANEBACK) @@ -486,7 +486,7 @@ loc0: int i, ds, dt; msurface_t *surf; - surf = cl.worldmodel->surfaces + node->firstsurface; + surf = cl.worldmodel->brushq1.surfaces + node->firstsurface; for (i = 0;i < node->numsurfaces;i++, surf++) { if (!(surf->flags & SURF_LIGHTMAP)) @@ -580,19 +580,19 @@ void R_CompleteLightPoint (vec3_t color, const vec3_t p, int dynamic, const mlea rdlight_t *rd; mlight_t *sl; if (leaf == NULL && cl.worldmodel != NULL) - leaf = cl.worldmodel->PointInLeaf(cl.worldmodel, p); - if (!leaf || leaf->contents == CONTENTS_SOLID || r_fullbright.integer || !cl.worldmodel->lightdata) + leaf = cl.worldmodel->brushq1.PointInLeaf(cl.worldmodel, p); + if (!leaf || leaf->contents == CONTENTS_SOLID || r_fullbright.integer || !cl.worldmodel->brushq1.lightdata) { color[0] = color[1] = color[2] = 1; return; } color[0] = color[1] = color[2] = r_ambient.value * (2.0f / 128.0f); - if (cl.worldmodel->numlights) + if (cl.worldmodel->brushq1.numlights) { - for (i = 0;i < cl.worldmodel->numlights;i++) + for (i = 0;i < cl.worldmodel->brushq1.numlights;i++) { - sl = cl.worldmodel->lights + i; + sl = cl.worldmodel->brushq1.lights + i; if (d_lightstylevalue[sl->style] > 0) { VectorSubtract (p, sl->origin, v); @@ -606,7 +606,7 @@ void R_CompleteLightPoint (vec3_t color, const vec3_t p, int dynamic, const mlea } } else - RecursiveLightPoint (color, cl.worldmodel->nodes, p[0], p[1], p[2], p[2] - 65536); + RecursiveLightPoint (color, cl.worldmodel->brushq1.nodes, p[0], p[1], p[2], p[2] - 65536); if (dynamic) { @@ -681,14 +681,14 @@ int R_LightModel(float *ambient4f, const entity_render_t *ent, float colorr, flo ambient4f[3] = colora; return false; } - leaf = cl.worldmodel ? cl.worldmodel->PointInLeaf(cl.worldmodel, ent->origin) : NULL; - if (!leaf || leaf->contents == CONTENTS_SOLID || !cl.worldmodel->lightdata) + leaf = cl.worldmodel ? cl.worldmodel->brushq1.PointInLeaf(cl.worldmodel, ent->origin) : NULL; + if (!leaf || leaf->contents == CONTENTS_SOLID || !cl.worldmodel->brushq1.lightdata) ambient4f[0] = ambient4f[1] = ambient4f[2] = 1; else { ambient4f[0] = ambient4f[1] = ambient4f[2] = r_ambient.value * (2.0f / 128.0f); - if (!cl.worldmodel->numlights) - RecursiveLightPoint (ambient4f, cl.worldmodel->nodes, ent->origin[0], ent->origin[1], ent->origin[2], ent->origin[2] - 65536); + if (!cl.worldmodel->brushq1.numlights) + RecursiveLightPoint (ambient4f, cl.worldmodel->brushq1.nodes, ent->origin[0], ent->origin[1], ent->origin[2], ent->origin[2] - 65536); } // scale of the model's coordinate space, to alter light attenuation to match // make the mscale squared so it can scale the squared distance results @@ -696,7 +696,7 @@ int R_LightModel(float *ambient4f, const entity_render_t *ent, float colorr, flo nl = &nearlight[0]; for (i = 0;i < ent->numentlights;i++) { - sl = cl.worldmodel->lights + ent->entlights[i]; + sl = cl.worldmodel->brushq1.lights + ent->entlights[i]; stylescale = d_lightstylevalue[sl->style] * (1.0f / 65536.0f); VectorSubtract (ent->origin, sl->origin, v); f = ((1.0f / (DotProduct(v, v) * sl->falloff + sl->distbias)) - sl->subtract) * stylescale; @@ -875,7 +875,7 @@ void R_UpdateEntLights(entity_render_t *ent) VectorCopy(ent->origin, ent->entlightsorigin); ent->numentlights = 0; if (cl.worldmodel) - for (i = 0, sl = cl.worldmodel->lights;i < cl.worldmodel->numlights && ent->numentlights < MAXENTLIGHTS;i++, sl++) + for (i = 0, sl = cl.worldmodel->brushq1.lights;i < cl.worldmodel->brushq1.numlights && ent->numentlights < MAXENTLIGHTS;i++, sl++) if (CL_TraceLine(ent->origin, sl->origin, NULL, NULL, 0, false, NULL) == 1) ent->entlights[ent->numentlights++] = i; } diff --git a/r_shadow.c b/r_shadow.c index daaa1a42..6362eb05 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -145,6 +145,8 @@ cvar_t r_shadow_realtime_world = {0, "r_shadow_realtime_world", "0"}; cvar_t r_shadow_realtime_dlight = {0, "r_shadow_realtime_dlight", "0"}; cvar_t r_shadow_visiblevolumes = {0, "r_shadow_visiblevolumes", "0"}; cvar_t r_shadow_gloss = {0, "r_shadow_gloss", "1"}; +cvar_t r_shadow_glossintensity = {0, "r_shadow_glossintensity", "1"}; +cvar_t r_shadow_gloss2intensity = {0, "r_shadow_gloss2intensity", "0.25"}; cvar_t r_shadow_debuglight = {0, "r_shadow_debuglight", "-1"}; cvar_t r_shadow_scissor = {0, "r_shadow_scissor", "1"}; cvar_t r_shadow_bumpscale_bumpmap = {0, "r_shadow_bumpscale_bumpmap", "4"}; @@ -227,6 +229,8 @@ void R_Shadow_Init(void) Cvar_RegisterVariable(&r_shadow_realtime_dlight); Cvar_RegisterVariable(&r_shadow_visiblevolumes); Cvar_RegisterVariable(&r_shadow_gloss); + Cvar_RegisterVariable(&r_shadow_glossintensity); + Cvar_RegisterVariable(&r_shadow_gloss2intensity); Cvar_RegisterVariable(&r_shadow_debuglight); Cvar_RegisterVariable(&r_shadow_scissor); Cvar_RegisterVariable(&r_shadow_bumpscale_bumpmap); @@ -749,7 +753,7 @@ void R_Shadow_Stage_Begin(void) if (r_shadow_texture3d.integer && !gl_texture3d) Cvar_SetValueQuick(&r_shadow_texture3d, 0); - //cl.worldmodel->numlights = min(cl.worldmodel->numlights, 1); + //cl.worldmodel->brushq1.numlights = min(cl.worldmodel->brushq1.numlights, 1); if (!r_shadow_attenuation2dtexture || (!r_shadow_attenuation3dtexture && r_shadow_texture3d.integer) || r_shadow_lightattenuationpower.value != r_shadow_attenpower @@ -1595,16 +1599,19 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elements, const float *vertex3f, const float *svector3f, const float *tvector3f, const float *normal3f, const float *texcoord2f, const float *relativelightorigin, const float *relativeeyeorigin, float lightradius, const float *lightcolor, const matrix4x4_t *matrix_modeltofilter, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz, rtexture_t *glosstexture, rtexture_t *bumptexture, rtexture_t *lightcubemap) { int renders; - float color[3], color2[3]; + float color[3], color2[3], colorscale; rmeshstate_t m; if (!gl_dot3arb || !gl_texturecubemap || !gl_combine.integer || !gl_stencil) return; - if (!bumptexture) - bumptexture = r_shadow_blankbumptexture; if (!glosstexture) glosstexture = r_shadow_blankglosstexture; if (r_shadow_gloss.integer >= 2 || (r_shadow_gloss.integer >= 1 && glosstexture != r_shadow_blankglosstexture)) { + colorscale = r_colorscale * r_shadow_glossintensity.value; + if (!bumptexture) + bumptexture = r_shadow_blankbumptexture; + if (glosstexture == r_shadow_blankglosstexture) + colorscale *= r_shadow_gloss2intensity.value; GL_VertexPointer(vertex3f); GL_Color(1,1,1,1); if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && lightcubemap /*&& gl_support_blendsquare*/) // FIXME: detect blendsquare! @@ -1660,7 +1667,7 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen GL_BlendFunc(GL_DST_ALPHA, GL_ONE); if (lightcubemap) R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltofilter); - VectorScale(lightcolor, r_colorscale * r_shadow_lightintensityscale.value * 0.25f, color2); + VectorScale(lightcolor, colorscale, color2); for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--) { color[0] = bound(0, color2[0], 1); @@ -1714,7 +1721,7 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen qglColorMask(1,1,1,0); GL_BlendFunc(GL_DST_ALPHA, GL_ONE); R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltoattenuationxyz); - VectorScale(lightcolor, r_colorscale * r_shadow_lightintensityscale.value * 0.25f, color2); + VectorScale(lightcolor, colorscale, color2); for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--) { color[0] = bound(0, color2[0], 1); @@ -1782,7 +1789,7 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen GL_BlendFunc(GL_DST_ALPHA, GL_ONE); if (lightcubemap) R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltofilter); - VectorScale(lightcolor, r_colorscale * r_shadow_lightintensityscale.value * 0.25f, color2); + VectorScale(lightcolor, colorscale, color2); for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--) { color[0] = bound(0, color2[0], 1); @@ -1863,22 +1870,22 @@ void R_Shadow_NewWorldLight(vec3_t origin, float radius, vec3_t color, int style if (cl.worldmodel) { castshadowcount++; - i = cl.worldmodel->PointContents(cl.worldmodel, e->origin); + i = CL_PointContents(e->origin); if (r_shadow_portallight.integer && i != CONTENTS_SOLID && i != CONTENTS_SKY) { qbyte *byteleafpvs; qbyte *bytesurfacepvs; - byteleafpvs = Mem_Alloc(tempmempool, cl.worldmodel->numleafs + 1); - bytesurfacepvs = Mem_Alloc(tempmempool, cl.worldmodel->numsurfaces); + byteleafpvs = Mem_Alloc(tempmempool, cl.worldmodel->brushq1.numleafs + 1); + bytesurfacepvs = Mem_Alloc(tempmempool, cl.worldmodel->brushq1.numsurfaces); Portal_Visibility(cl.worldmodel, e->origin, byteleafpvs, bytesurfacepvs, NULL, 0, true, RadiusFromBoundsAndOrigin(e->mins, e->maxs, e->origin)); - for (i = 0, leaf = cl.worldmodel->leafs + 1;i < cl.worldmodel->numleafs;i++, leaf++) + for (i = 0, leaf = cl.worldmodel->brushq1.leafs + 1;i < cl.worldmodel->brushq1.numleafs;i++, leaf++) if (byteleafpvs[i+1] && BoxesOverlap(leaf->mins, leaf->maxs, e->mins, e->maxs)) leaf->worldnodeframe = castshadowcount; - for (i = 0, surf = cl.worldmodel->surfaces;i < cl.worldmodel->numsurfaces;i++, surf++) + for (i = 0, surf = cl.worldmodel->brushq1.surfaces;i < cl.worldmodel->brushq1.numsurfaces;i++, surf++) if (bytesurfacepvs[i] && BoxesOverlap(surf->poly_mins, surf->poly_maxs, e->mins, e->maxs)) surf->castshadow = castshadowcount; @@ -1887,16 +1894,16 @@ void R_Shadow_NewWorldLight(vec3_t origin, float radius, vec3_t color, int style } else { - leaf = cl.worldmodel->PointInLeaf(cl.worldmodel, origin); - pvs = cl.worldmodel->LeafPVS(cl.worldmodel, leaf); - for (i = 0, leaf = cl.worldmodel->leafs + 1;i < cl.worldmodel->numleafs;i++, leaf++) + leaf = cl.worldmodel->brushq1.PointInLeaf(cl.worldmodel, origin); + pvs = cl.worldmodel->brushq1.LeafPVS(cl.worldmodel, leaf); + for (i = 0, leaf = cl.worldmodel->brushq1.leafs + 1;i < cl.worldmodel->brushq1.numleafs;i++, leaf++) { if (pvs[i >> 3] & (1 << (i & 7)) && BoxesOverlap(leaf->mins, leaf->maxs, e->mins, e->maxs)) { leaf->worldnodeframe = castshadowcount; for (j = 0, mark = leaf->firstmarksurface;j < leaf->nummarksurfaces;j++, mark++) { - surf = cl.worldmodel->surfaces + *mark; + surf = cl.worldmodel->brushq1.surfaces + *mark; if (surf->castshadow != castshadowcount && BoxesOverlap(surf->poly_mins, surf->poly_maxs, e->mins, e->maxs)) surf->castshadow = castshadowcount; } @@ -1905,11 +1912,11 @@ void R_Shadow_NewWorldLight(vec3_t origin, float radius, vec3_t color, int style } e->numleafs = 0; - for (i = 0, leaf = cl.worldmodel->leafs + 1;i < cl.worldmodel->numleafs;i++, leaf++) + for (i = 0, leaf = cl.worldmodel->brushq1.leafs + 1;i < cl.worldmodel->brushq1.numleafs;i++, leaf++) if (leaf->worldnodeframe == castshadowcount) e->numleafs++; e->numsurfaces = 0; - for (i = 0, surf = cl.worldmodel->surfaces + cl.worldmodel->firstmodelsurface;i < cl.worldmodel->nummodelsurfaces;i++, surf++) + for (i = 0, surf = cl.worldmodel->brushq1.surfaces + cl.worldmodel->brushq1.firstmodelsurface;i < cl.worldmodel->brushq1.nummodelsurfaces;i++, surf++) if (surf->castshadow == castshadowcount) e->numsurfaces++; @@ -1918,11 +1925,11 @@ void R_Shadow_NewWorldLight(vec3_t origin, float radius, vec3_t color, int style if (e->numsurfaces) e->surfaces = Mem_Alloc(r_shadow_mempool, e->numsurfaces * sizeof(msurface_t *)); e->numleafs = 0; - for (i = 0, leaf = cl.worldmodel->leafs + 1;i < cl.worldmodel->numleafs;i++, leaf++) + for (i = 0, leaf = cl.worldmodel->brushq1.leafs + 1;i < cl.worldmodel->brushq1.numleafs;i++, leaf++) if (leaf->worldnodeframe == castshadowcount) e->leafs[e->numleafs++] = leaf; e->numsurfaces = 0; - for (i = 0, surf = cl.worldmodel->surfaces + cl.worldmodel->firstmodelsurface;i < cl.worldmodel->nummodelsurfaces;i++, surf++) + for (i = 0, surf = cl.worldmodel->brushq1.surfaces + cl.worldmodel->brushq1.firstmodelsurface;i < cl.worldmodel->brushq1.nummodelsurfaces;i++, surf++) if (surf->castshadow == castshadowcount) e->surfaces[e->numsurfaces++] = surf; @@ -2253,7 +2260,7 @@ void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void) Con_Printf("No map loaded.\n"); return; } - data = cl.worldmodel->entities; + data = cl.worldmodel->brush.entities; if (!data) return; for (entnum = 0;COM_ParseToken(&data) && com_token[0] == '{';entnum++) diff --git a/r_sprites.c b/r_sprites.c index 7b5b8e55..8adee274 100644 --- a/r_sprites.c +++ b/r_sprites.c @@ -91,7 +91,7 @@ void R_DrawSpriteModelCallback(const void *calldata1, int calldata2) vec3_t diff; float fog, ifog; - if (R_SpriteSetup(ent, ent->model->sprnum_type, org, left, up)) + if (R_SpriteSetup(ent, ent->model->sprite.sprnum_type, org, left, up)) return; R_Mesh_Matrix(&r_identitymatrix); @@ -119,7 +119,7 @@ void R_DrawSpriteModelCallback(const void *calldata1, int calldata2) { if (ent->frameblend[i].lerp >= 0.01f) { - frame = ent->model->sprdata_frames + ent->frameblend[i].frame; + frame = ent->model->sprite.sprdata_frames + ent->frameblend[i].frame; R_DrawSpriteImage((ent->effects & EF_ADDITIVE) || (ent->model->flags & EF_ADDITIVE), frame, frame->texture, org, up, left, color[0] * ifog, color[1] * ifog, color[2] * ifog, ent->alpha * ent->frameblend[i].lerp); if (fog * ent->frameblend[i].lerp >= 0.01f) R_DrawSpriteImage(true, frame, frame->fogtexture, org, up, left, fogcolor[0],fogcolor[1],fogcolor[2], fog * ent->alpha * ent->frameblend[i].lerp); @@ -131,7 +131,7 @@ void R_DrawSpriteModelCallback(const void *calldata1, int calldata2) // LordHavoc: no interpolation frame = NULL; for (i = 0;i < 4 && ent->frameblend[i].lerp;i++) - frame = ent->model->sprdata_frames + ent->frameblend[i].frame; + frame = ent->model->sprite.sprdata_frames + ent->frameblend[i].frame; R_DrawSpriteImage((ent->effects & EF_ADDITIVE) || (ent->model->flags & EF_ADDITIVE), frame, frame->texture, org, up, left, color[0] * ifog, color[1] * ifog, color[2] * ifog, ent->alpha); if (fog * ent->frameblend[i].lerp >= 0.01f) diff --git a/snd_dma.c b/snd_dma.c index 7adfa7ae..6de33897 100644 --- a/snd_dma.c +++ b/snd_dma.c @@ -689,11 +689,7 @@ void S_UpdateAmbientSounds (void) for (ambient_channel = 0 ; ambient_channel < NUM_AMBIENTS;ambient_channel++) channels[ambient_channel].sfx = NULL; - if (!snd_ambient || !cl.worldmodel || ambient_level.value <= 0) - return; - - l = cl.worldmodel->PointInLeaf(cl.worldmodel, listener_origin); - if (!l) + if (!snd_ambient || ambient_level.value <= 0 || !cl.worldmodel || !cl.worldmodel->brushq1.PointInLeaf || (l = cl.worldmodel->brushq1.PointInLeaf(cl.worldmodel, listener_origin)) == NULL) return; // calc ambient sound levels diff --git a/sv_light.c b/sv_light.c index 41b4475f..2a503716 100644 --- a/sv_light.c +++ b/sv_light.c @@ -62,7 +62,7 @@ loc0: mid = startz + distz * (front - node->plane->dist) / (front - back); break; } - + // go down front side if (node->children[side]->contents >= 0 && SV_RecursiveLightPoint (color, node->children[side], x, y, startz, mid)) return true; // hit something @@ -74,7 +74,7 @@ loc0: int i, ds, dt; msurface_t *surf; - surf = sv.worldmodel->surfaces + node->firstsurface; + surf = sv.worldmodel->brushq1.surfaces + node->firstsurface; for (i = 0;i < node->numsurfaces;i++, surf++) { if (!(surf->flags & SURF_LIGHTMAP)) @@ -85,10 +85,10 @@ loc0: if (ds < surf->texturemins[0] || dt < surf->texturemins[1]) continue; - + ds -= surf->texturemins[0]; dt -= surf->texturemins[1]; - + if (ds > surf->extents[0] || dt > surf->extents[1]) continue; @@ -131,13 +131,13 @@ loc0: void SV_LightPoint (vec3_t color, vec3_t p) { Mod_CheckLoaded(sv.worldmodel); - if (!sv.worldmodel->lightdata) + if (!sv.worldmodel->brushq1.lightdata) { color[0] = color[1] = color[2] = 255; return; } color[0] = color[1] = color[2] = 0; - SV_RecursiveLightPoint (color, sv.worldmodel->nodes, p[0], p[1], p[2], p[2] - 65536); + SV_RecursiveLightPoint (color, sv.worldmodel->brushq1.nodes, p[0], p[1], p[2], p[2] - 65536); } diff --git a/sv_main.c b/sv_main.c index b6a23eaf..e4492815 100644 --- a/sv_main.c +++ b/sv_main.c @@ -385,7 +385,7 @@ void SV_AddToFatPVS (vec3_t org, mnode_t *node) { if (node->contents != CONTENTS_SOLID) { - pvs = sv.worldmodel->LeafPVS(sv.worldmodel, (mleaf_t *)node); + pvs = sv.worldmodel->brushq1.LeafPVS(sv.worldmodel, (mleaf_t *)node); for (i=0 ; inumleafs+31)>>3; + fatbytes = (sv.worldmodel->brushq1.numleafs+31)>>3; memset (fatpvs, 0, fatbytes); - SV_AddToFatPVS (org, sv.worldmodel->nodes); + SV_AddToFatPVS (org, sv.worldmodel->brushq1.nodes); return fatpvs; } @@ -434,7 +434,7 @@ loc0: // leaf if (node->contents == CONTENTS_SOLID) return false; - leafnum = (mleaf_t *)node - sv.worldmodel->leafs - 1; + leafnum = (mleaf_t *)node - sv.worldmodel->brushq1.leafs - 1; return pvs[leafnum >> 3] & (1 << (leafnum & 7)); } @@ -584,7 +584,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) totalentities++; // if not touching a visible leaf - if (sv_cullentities_pvs.integer && !SV_BoxTouchingPVS(pvs, entmins, entmaxs, sv.worldmodel->nodes)) + if (sv_cullentities_pvs.integer && !SV_BoxTouchingPVS(pvs, entmins, entmaxs, sv.worldmodel->brushq1.nodes)) { culled_pvs++; continue; @@ -963,7 +963,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) totalentities++; // if not touching a visible leaf - if (sv_cullentities_pvs.integer && !SV_BoxTouchingPVS(pvs, lightmins, lightmaxs, sv.worldmodel->nodes)) + if (sv_cullentities_pvs.integer && !SV_BoxTouchingPVS(pvs, lightmins, lightmaxs, sv.worldmodel->brushq1.nodes)) { culled_pvs++; continue; @@ -1841,7 +1841,7 @@ void SV_SpawnServer (const char *server) sv.model_precache[0] = ""; sv.model_precache[1] = sv.modelname; - for (i = 1;i < sv.worldmodel->numsubmodels;i++) + for (i = 1;i < sv.worldmodel->brushq1.numsubmodels;i++) { sv.model_precache[i+1] = localmodels[i]; sv.models[i+1] = Mod_ForName (localmodels[i], false, false, false); @@ -1879,7 +1879,7 @@ void SV_SpawnServer (const char *server) Mem_Free(entities); } else - ED_LoadFromFile (sv.worldmodel->entities); + ED_LoadFromFile (sv.worldmodel->brush.entities); // LordHavoc: clear world angles (to fix e3m3.bsp) diff --git a/sv_move.c b/sv_move.c index 7c0b0ff1..88e4ce6c 100644 --- a/sv_move.c +++ b/sv_move.c @@ -51,7 +51,7 @@ qboolean SV_CheckBottom (edict_t *ent) { start[0] = x ? maxs[0] : mins[0]; start[1] = y ? maxs[1] : mins[1]; - if (sv.worldmodel->PointContents(sv.worldmodel, start) != CONTENTS_SOLID) + if (sv.worldmodel->brushq1.PointContents(sv.worldmodel, start) != CONTENTS_SOLID) goto realcheck; } @@ -138,7 +138,7 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink) if (trace.fraction == 1) { VectorCopy(trace.endpos, traceendpos); - if ( ((int)ent->v->flags & FL_SWIM) && sv.worldmodel->PointContents(sv.worldmodel, traceendpos) == CONTENTS_EMPTY ) + if ( ((int)ent->v->flags & FL_SWIM) && sv.worldmodel->brushq1.PointContents(sv.worldmodel, traceendpos) == CONTENTS_EMPTY ) return false; // swim monster left water VectorCopy (traceendpos, ent->v->origin); diff --git a/sv_phys.c b/sv_phys.c index 63afdeea..ad5aa985 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -854,18 +854,18 @@ qboolean SV_CheckWater (edict_t *ent) ent->v->waterlevel = 0; ent->v->watertype = CONTENTS_EMPTY; - cont = sv.worldmodel->PointContents(sv.worldmodel, point); + cont = sv.worldmodel->brushq1.PointContents(sv.worldmodel, point); if (cont <= CONTENTS_WATER) { ent->v->watertype = cont; ent->v->waterlevel = 1; point[2] = ent->v->origin[2] + (ent->v->mins[2] + ent->v->maxs[2])*0.5; - cont = sv.worldmodel->PointContents(sv.worldmodel, point); + cont = sv.worldmodel->brushq1.PointContents(sv.worldmodel, point); if (cont <= CONTENTS_WATER) { ent->v->waterlevel = 2; point[2] = ent->v->origin[2] + ent->v->view_ofs[2]; - cont = sv.worldmodel->PointContents(sv.worldmodel, point); + cont = sv.worldmodel->brushq1.PointContents(sv.worldmodel, point); if (cont <= CONTENTS_WATER) ent->v->waterlevel = 3; } @@ -1136,7 +1136,7 @@ SV_CheckWaterTransition void SV_CheckWaterTransition (edict_t *ent) { int cont; - cont = sv.worldmodel->PointContents(sv.worldmodel, ent->v->origin); + cont = sv.worldmodel->brushq1.PointContents(sv.worldmodel, ent->v->origin); if (!ent->v->watertype) { // just spawned here diff --git a/view.c b/view.c index ec1b206b..775a02c4 100644 --- a/view.c +++ b/view.c @@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // view.c -- player eye positioning #include "quakedef.h" +#include "cl_collision.h" /* @@ -397,7 +398,7 @@ void V_CalcRefdef (void) cl.cshifts[CSHIFT_BONUS].percent = 0; // set contents color - switch (cl.worldmodel ? cl.worldmodel->PointContents(cl.worldmodel, r_refdef.vieworg) : CONTENTS_EMPTY) + switch (CL_PointContents(r_refdef.vieworg)) { case CONTENTS_EMPTY: case CONTENTS_SOLID: -- 2.39.2