Add support for 32k+ marksurfaces in map

This commit is contained in:
Denis Pauk 2018-09-26 23:33:00 +03:00
parent 316918c29b
commit 659d8e15c5
5 changed files with 41 additions and 20 deletions

View file

@ -54,7 +54,7 @@ void *
Hunk_Begin(int maxsize)
{
/* reserve a huge chunk of memory, but don't commit any yet */
maxhunksize = maxsize + sizeof(int);
maxhunksize = maxsize + sizeof(size_t);
curhunksize = 0;
membase = mmap(0, maxhunksize, PROT_READ | PROT_WRITE,
@ -76,7 +76,7 @@ Hunk_Alloc(int size)
byte *buf;
/* round to cacheline */
size = (size + 31) & ~31;
size = (size + 63) & ~63;
if (curhunksize + size > maxhunksize)
{

View file

@ -220,7 +220,7 @@ Mod_ForName(char *name, qboolean crash)
break;
case IDBSPHEADER:
loadmodel->extradata = Hunk_Begin(0x1000000);
loadmodel->extradata = Hunk_Begin(0x2000000);
Mod_LoadBrushModel(mod, buf);
break;
@ -688,6 +688,8 @@ Mod_LoadLeafs(lump_t *l)
for (i = 0; i < count; i++, in++, out++)
{
unsigned firstleafface;
for (j = 0; j < 3; j++)
{
out->minmaxs[j] = LittleShort(in->mins[j]);
@ -700,9 +702,15 @@ Mod_LoadLeafs(lump_t *l)
out->cluster = LittleShort(in->cluster);
out->area = LittleShort(in->area);
out->firstmarksurface = loadmodel->marksurfaces +
LittleShort(in->firstleafface);
out->nummarksurfaces = LittleShort(in->numleaffaces);
// make unsigned long from signed short
firstleafface = LittleShort(in->firstleafface) & 0xFFFF;
out->nummarksurfaces = LittleShort(in->numleaffaces) & 0xFFFF;
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
{
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: wrong marksurfaces position in %s",loadmodel->name);
}
}
}

View file

@ -571,6 +571,8 @@ Mod_LoadLeafs(lump_t *l)
for (i = 0; i < count; i++, in++, out++)
{
unsigned firstleafface;
for (j = 0; j < 3; j++)
{
out->minmaxs[j] = LittleShort(in->mins[j]);
@ -583,9 +585,15 @@ Mod_LoadLeafs(lump_t *l)
out->cluster = LittleShort(in->cluster);
out->area = LittleShort(in->area);
out->firstmarksurface = loadmodel->marksurfaces +
LittleShort(in->firstleafface);
out->nummarksurfaces = LittleShort(in->numleaffaces);
// make unsigned long from signed short
firstleafface = LittleShort(in->firstleafface) & 0xFFFF;
out->nummarksurfaces = LittleShort(in->numleaffaces) & 0xFFFF;
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
{
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: wrong marksurfaces position in %s",loadmodel->name);
}
}
}
@ -895,7 +903,7 @@ Mod_ForName(char *name, qboolean crash)
break;
case IDBSPHEADER:
loadmodel->extradata = Hunk_Begin(0x1000000);
loadmodel->extradata = Hunk_Begin(0x2000000);
Mod_LoadBrushModel(mod, buf);
break;

View file

@ -46,9 +46,6 @@ static bedge_t bedges[MAX_BMODEL_EDGES];
static mvertex_t *pfrontenter, *pfrontexit;
static qboolean makeclippededge;
//===========================================================================
/*
@ -164,7 +161,8 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m
mplane_t *splitplane, tplane;
mvertex_t *pvert, *plastvert, *ptvert;
mnode_t *pn;
int area;
int area;
qboolean makeclippededge;
psideedges[0] = psideedges[1] = NULL;
@ -252,13 +250,12 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m
{
// entering for front, exiting for back
pfrontenter = ptvert;
makeclippededge = true;
}
else
{
pfrontexit = ptvert;
makeclippededge = true;
}
makeclippededge = true;
}
else
{

View file

@ -172,7 +172,7 @@ Mod_ForName (char *name, qboolean crash)
break;
case IDBSPHEADER:
loadmodel->extradata = Hunk_Begin (0x1000000);
loadmodel->extradata = Hunk_Begin (0x2000000);
Mod_LoadBrushModel (mod, buf);
break;
@ -753,6 +753,8 @@ Mod_LoadLeafs (lump_t *l)
for ( i=0 ; i<count ; i++, in++, out++)
{
unsigned firstleafface;
for (j=0 ; j<3 ; j++)
{
out->minmaxs[j] = LittleShort (in->mins[j]);
@ -763,9 +765,15 @@ Mod_LoadLeafs (lump_t *l)
out->cluster = LittleShort(in->cluster);
out->area = LittleShort(in->area);
out->firstmarksurface = loadmodel->marksurfaces +
LittleShort(in->firstleafface);
out->nummarksurfaces = LittleShort(in->numleaffaces);
// make unsigned long from signed short
firstleafface = LittleShort(in->firstleafface) & 0xFFFF;
out->nummarksurfaces = LittleShort(in->numleaffaces) & 0xFFFF;
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
{
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: wrong marksurfaces position in %s",loadmodel->name);
}
}
}