mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
glTF2 -> dmap triangulation bugfixes
This commit is contained in:
parent
e86a8d1734
commit
e095e95173
2 changed files with 42 additions and 14 deletions
|
@ -49,9 +49,9 @@ void MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh* _mesh, gltfData* data
|
|||
{
|
||||
MapPolygon& polygon = polygons.Alloc( );
|
||||
polygon.SetMaterial( "textures/enpro/enwall16" );
|
||||
polygon.AddIndex( indices[i + 0] );
|
||||
polygon.AddIndex( indices[i + 1] );
|
||||
polygon.AddIndex( indices[i + 2] );
|
||||
polygon.AddIndex( indices[i + 0] );
|
||||
}
|
||||
|
||||
Mem_Free( indices );
|
||||
|
@ -77,8 +77,7 @@ void MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh* _mesh, gltfData* data
|
|||
{
|
||||
case gltfMesh_Primitive_Attribute::Type::Position:
|
||||
{
|
||||
for( int i = attrAcc->count - 1; i >= 0; i-- )
|
||||
//for( int i = 0; i < attrAcc->count; i++ )
|
||||
for( int i = 0; i < attrAcc->count; i++ )
|
||||
{
|
||||
idVec3 pos;
|
||||
|
||||
|
@ -87,7 +86,7 @@ void MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh* _mesh, gltfData* data
|
|||
bin.Read( ( void* )( &pos.z ), attrAcc->typeSize );
|
||||
|
||||
#if 1
|
||||
// RB: proper glTF2 convention
|
||||
// RB: proper glTF2 convention, requires Y-up export option ticked on in Blender
|
||||
verts[i].xyz.x = pos.z;
|
||||
verts[i].xyz.y = pos.x;
|
||||
verts[i].xyz.z = pos.y;
|
||||
|
|
|
@ -492,20 +492,14 @@ static int ParsePolygonMesh( const MapPolygonMesh* mesh, int primitiveNum, int n
|
|||
|
||||
// TODO use WindingToTriList instead ?
|
||||
|
||||
for( int j = 1; j < indexes.Num() - 1; j++ )
|
||||
//for( int j = indexes.Num() -2; j >= 1; j-- )
|
||||
if( indexes.Num() == 3 )
|
||||
{
|
||||
// RB: glTF2 workflow insists to use triangles instead of n-gons or quads
|
||||
mapTri_t* tri = AllocTri();
|
||||
|
||||
#if 1
|
||||
tri->v[0] = verts[ indexes[ j + 1] ];
|
||||
tri->v[1] = verts[ indexes[ j + 0] ];
|
||||
tri->v[2] = verts[ indexes[ 0 ] ];
|
||||
#else
|
||||
tri->v[2] = verts[ indexes[ j + 1] ];
|
||||
tri->v[1] = verts[ indexes[ j + 0] ];
|
||||
tri->v[0] = verts[ indexes[ 0 ] ];
|
||||
#endif
|
||||
tri->v[1] = verts[ indexes[ 1 ] ];
|
||||
tri->v[2] = verts[ indexes[ 2 ] ];
|
||||
|
||||
idPlane plane;
|
||||
plane.FromPoints( tri->v[0].xyz, tri->v[1].xyz, tri->v[2].xyz );
|
||||
|
@ -531,6 +525,41 @@ static int ParsePolygonMesh( const MapPolygonMesh* mesh, int primitiveNum, int n
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int j = 1; j < indexes.Num() - 1; j++ )
|
||||
{
|
||||
mapTri_t* tri = AllocTri();
|
||||
|
||||
tri->v[0] = verts[ indexes[ j + 1] ];
|
||||
tri->v[1] = verts[ indexes[ j + 0] ];
|
||||
tri->v[2] = verts[ indexes[ 0 ] ];
|
||||
|
||||
idPlane plane;
|
||||
plane.FromPoints( tri->v[0].xyz, tri->v[1].xyz, tri->v[2].xyz );
|
||||
|
||||
bool fixedDegeneracies = false;
|
||||
tri->planeNum = FindFloatPlane( plane, &fixedDegeneracies );
|
||||
|
||||
tri->polygonId = numPolygons + i;
|
||||
|
||||
tri->material = mat;
|
||||
tri->next = prim->bsptris;
|
||||
prim->bsptris = tri;
|
||||
|
||||
tri->originalMapMesh = mesh;
|
||||
|
||||
// set merge groups if needed, to prevent multiple sides from being
|
||||
// merged into a single surface in the case of gui shaders, mirrors, and autosprites
|
||||
if( mat->IsDiscrete() )
|
||||
{
|
||||
for( tri = prim->bsptris ; tri ; tri = tri->next )
|
||||
{
|
||||
tri->mergeGroup = ( void* )mesh;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mesh->GetNumPolygons();
|
||||
|
|
Loading…
Reference in a new issue