- fixed: cached GL nodes should use ZGL3 format for maximum precision.

This commit is contained in:
Christoph Oelckers 2015-02-26 12:08:52 +01:00
parent bcfa8da4a3
commit 84f8c299ce

View file

@ -1116,10 +1116,10 @@ static void CreateCachedNodes(MapData *map)
WriteLong(ZNodes, numnodes); WriteLong(ZNodes, numnodes);
for(int i=0;i<numnodes;i++) for(int i=0;i<numnodes;i++)
{ {
WriteWord(ZNodes, nodes[i].x >> FRACBITS); WriteLong(ZNodes, nodes[i].x);
WriteWord(ZNodes, nodes[i].y >> FRACBITS); WriteLong(ZNodes, nodes[i].y);
WriteWord(ZNodes, nodes[i].dx >> FRACBITS); WriteLong(ZNodes, nodes[i].dx);
WriteWord(ZNodes, nodes[i].dy >> FRACBITS); WriteLong(ZNodes, nodes[i].dy);
for (int j = 0; j < 2; ++j) for (int j = 0; j < 2; ++j)
{ {
for (int k = 0; k < 4; ++k) for (int k = 0; k < 4; ++k)
@ -1168,7 +1168,7 @@ static void CreateCachedNodes(MapData *map)
DWORD ndx[2] = {LittleLong(DWORD(lines[i].v1 - vertexes)), LittleLong(DWORD(lines[i].v2 - vertexes)) }; DWORD ndx[2] = {LittleLong(DWORD(lines[i].v1 - vertexes)), LittleLong(DWORD(lines[i].v2 - vertexes)) };
memcpy(compressed+8+16+8*i, ndx, 8); memcpy(compressed+8+16+8*i, ndx, 8);
} }
memcpy(compressed + offset - 4, "ZGL2", 4); memcpy(compressed + offset - 4, "ZGL3", 4);
FString path = CreateCacheName(map, true); FString path = CreateCacheName(map, true);
FILE *f = fopen(path, "wb"); FILE *f = fopen(path, "wb");
@ -1218,7 +1218,7 @@ static bool CheckCachedNodes(MapData *map)
if (fread(verts, 8, numlin, f) != numlin) goto errorout; if (fread(verts, 8, numlin, f) != numlin) goto errorout;
if (fread(magic, 1, 4, f) != 4) goto errorout; if (fread(magic, 1, 4, f) != 4) goto errorout;
if (memcmp(magic, "ZGL2", 4)) goto errorout; if (memcmp(magic, "ZGL2", 4) && memcmp(magic, "ZGL3", 4)) goto errorout;
try try
@ -1226,7 +1226,7 @@ static bool CheckCachedNodes(MapData *map)
long pos = ftell(f); long pos = ftell(f);
FileReader fr(f); FileReader fr(f);
fr.Seek(pos, SEEK_SET); fr.Seek(pos, SEEK_SET);
P_LoadZNodes (fr, MAKE_ID('Z','G','L','2')); P_LoadZNodes (fr, MAKE_ID(magic[0],magic[1],magic[2],magic[3]));
} }
catch (CRecoverableError &error) catch (CRecoverableError &error)
{ {