Skip to content

Commit 62e2063

Browse files
committed
- fix rendermodel normals generation
1 parent 5812afa commit 62e2063

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

DriverLevelTool/driver_routines/models.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,9 @@ int decode_poly(const char* polyList, dpoly_t* out)
354354
POLYFT3* pft3 = (POLYFT3*)polyList;
355355

356356
*(uint*)out->vindices = *(uint*)&pft3->v0;
357-
*(ushort*)out->uv[0] = *(uint*)&pft3->uv0;
358-
*(ushort*)out->uv[1] = *(uint*)&pft3->uv1;
359-
*(ushort*)out->uv[2] = *(uint*)&pft3->uv2;
357+
*(ushort*)out->uv[0] = *(ushort*)&pft3->uv0;
358+
*(ushort*)out->uv[1] = *(ushort*)&pft3->uv1;
359+
*(ushort*)out->uv[2] = *(ushort*)&pft3->uv2;
360360

361361
if(ptype != 10)
362362
*(uint*)out->color = *(uint*)&pft3->color;
@@ -377,18 +377,18 @@ int decode_poly(const char* polyList, dpoly_t* out)
377377
POLYFT4* pft4 = (POLYFT4*)polyList;
378378

379379
*(uint*)out->vindices = *(uint*)&pft4->v0;
380-
*(ushort*)out->uv[0] = *(uint*)&pft4->uv0;
381-
*(ushort*)out->uv[1] = *(uint*)&pft4->uv1;
382-
*(ushort*)out->uv[2] = *(uint*)&pft4->uv2;
383-
*(ushort*)out->uv[3] = *(uint*)&pft4->uv3;
384-
380+
*(ushort*)out->uv[0] = *(ushort*)&pft4->uv0;
381+
*(ushort*)out->uv[1] = *(ushort*)&pft4->uv1;
382+
*(ushort*)out->uv[2] = *(ushort*)&pft4->uv2;
383+
*(ushort*)out->uv[3] = *(ushort*)&pft4->uv3;
384+
385385
if(ptype != 11)
386386
*(uint*)out->color = *(uint*)&pft4->color;
387387

388388
out->page = pft4->texture_set;
389389
out->detail = pft4->texture_id;
390390

391-
//SwapValues(out->vindices[2], out->vindices[3]);
391+
//SwapValues(out->uv[2], out->uv[3]);
392392

393393
out->flags = FACE_IS_QUAD | FACE_TEXTURED;
394394

@@ -400,9 +400,9 @@ int decode_poly(const char* polyList, dpoly_t* out)
400400

401401
*(uint*)out->vindices = *(uint*)&pgt3->v0;
402402
*(uint*)out->nindices = *(uint*)&pgt3->n0;
403-
*(ushort*)out->uv[0] = *(uint*)&pgt3->uv0;
404-
*(ushort*)out->uv[1] = *(uint*)&pgt3->uv1;
405-
*(ushort*)out->uv[2] = *(uint*)&pgt3->uv2;
403+
*(ushort*)out->uv[0] = *(ushort*)&pgt3->uv0;
404+
*(ushort*)out->uv[1] = *(ushort*)&pgt3->uv1;
405+
*(ushort*)out->uv[2] = *(ushort*)&pgt3->uv2;
406406

407407
*(uint*)out->color = *(uint*)&pgt3->color;
408408
out->page = pgt3->texture_set;
@@ -418,10 +418,10 @@ int decode_poly(const char* polyList, dpoly_t* out)
418418

419419
*(uint*)out->vindices = *(uint*)&pgt4->v0;
420420
*(uint*)out->nindices = *(uint*)&pgt4->n0;
421-
*(ushort*)out->uv[0] = *(uint*)&pgt4->uv0;
422-
*(ushort*)out->uv[1] = *(uint*)&pgt4->uv1;
423-
*(ushort*)out->uv[2] = *(uint*)&pgt4->uv2;
424-
*(ushort*)out->uv[3] = *(uint*)&pgt4->uv3;
421+
*(ushort*)out->uv[0] = *(ushort*)&pgt4->uv0;
422+
*(ushort*)out->uv[1] = *(ushort*)&pgt4->uv1;
423+
*(ushort*)out->uv[2] = *(ushort*)&pgt4->uv2;
424+
*(ushort*)out->uv[3] = *(ushort*)&pgt4->uv3;
425425

426426
*(uint*)out->color = *(uint*)&pgt4->color;
427427
out->page = pgt4->texture_set;

DriverLevelTool/driver_routines/regions_d1.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ void CDriver1LevelRegion::LoadRegionData(IVirtualStream* pFile, Spool* spool)
5555

5656
char* packed_cell_pointers = new char[spool->cell_data_size[1] * SPOOL_CD_BLOCK_SIZE];
5757

58-
m_cellPointers = new ushort[m_owner->m_cell_objects_add[2]];
59-
memset(m_cellPointers, 0xFF, sizeof(ushort) * m_owner->m_cell_objects_add[2]);
58+
m_cellPointers = new ushort[m_owner->m_cell_objects_add[5]];
59+
memset(m_cellPointers, 0xFF, sizeof(ushort) * m_owner->m_cell_objects_add[5]);
6060

6161
// read packed cell pointers
6262
pFile->Seek(g_levInfo.spooldata_offset + cellPointersOffset * SPOOL_CD_BLOCK_SIZE, VS_SEEK_SET);

DriverLevelTool/driver_routines/regions_d2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ void CDriver2LevelRegion::LoadRegionData(IVirtualStream* pFile, Spool* spool)
7070

7171
char* packed_cell_pointers = new char[spool->cell_data_size[1] * SPOOL_CD_BLOCK_SIZE];
7272

73-
m_cellPointers = new ushort[m_owner->m_cell_objects_add[2]];
74-
memset(m_cellPointers, 0xFF, sizeof(ushort) * m_owner->m_cell_objects_add[2]);
73+
m_cellPointers = new ushort[m_owner->m_cell_objects_add[5]];
74+
memset(m_cellPointers, 0xFF, sizeof(ushort) * m_owner->m_cell_objects_add[5]);
7575

7676
// read packed cell pointers
7777
pFile->Seek(g_levInfo.spooldata_offset + cellPointersOffset * SPOOL_CD_BLOCK_SIZE, VS_SEEK_SET);

DriverLevelTool/viewer/rendermodel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ int FindGrVertexIndex(const DkList<vertexTuple_t>& whereFind, int flags, int ver
6161
if (whereFind[i].normalIndex != normalIndex)
6262
continue;
6363
}
64+
else
65+
{
66+
return -1;
67+
}
6468

6569
if (flags & FACE_TEXTURED)
6670
{
@@ -216,6 +220,7 @@ void CRenderModel::GenerateBuffers()
216220
vertMap.flags = vflags;
217221
vertMap.normalIndex = -1;
218222
vertMap.vertexIndex = dec_face.vindices[VERT_IDX];
223+
vertMap.uvs = *(ushort*)dec_face.uv[VERT_IDX];
219224

220225
// get the vertex
221226
SVECTOR* vert = vertex_ref->pVertex(dec_face.vindices[VERT_IDX]);

0 commit comments

Comments
 (0)