Don't add indices from other polygons

This commit is contained in:
Robert Beckebans 2022-06-08 23:06:17 +02:00
parent c74ed79e8d
commit c576583b28
2 changed files with 14 additions and 4 deletions

View file

@ -19,11 +19,11 @@ bool idRenderModelStatic::ConvertGltfMeshToModelsurfaces( const gltfMesh* mesh )
void MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh* _mesh, gltfData* data )
{
for( auto* gltfMesh : data->MeshList( ) )
//for( auto* gltfMesh : data->MeshList( ) )
{
for( auto prim : gltfMesh->primitives )
for( auto prim : _mesh->primitives )
{
common->Printf( "primitive for %s\n", gltfMesh->name.c_str() );
common->Printf( "primitive for %s\n", _mesh->name.c_str() );
gltfAccessor* accessor = data->AccessorList( )[prim->indices];
gltfBufferView* bv = data->BufferViewList( )[accessor->bufferView];
@ -47,7 +47,7 @@ void MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh* _mesh, gltfData* data
for( int i = 0; i < accessor->count; i += 3 )
{
MapPolygon& polygon = polygons.Alloc( );
MapPolygon& polygon = polygons.Alloc();
polygon.SetMaterial( "textures/enpro/enwall16" );
polygon.AddIndex( indices[i + 0] );
polygon.AddIndex( indices[i + 1] );
@ -77,6 +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++ )
{
idVec3 pos;

View file

@ -501,6 +501,15 @@ static int ParsePolygonMesh( const MapPolygonMesh* mesh, int primitiveNum, int n
tri->v[1] = verts[ indexes[ 1 ] ];
tri->v[2] = verts[ indexes[ 2 ] ];
#if 0
idLib::Printf( "indices: ( %i %i %i )\n", indexes[ 0 ], indexes[ 1 ], indexes[ 2 ] );
idLib::Printf( "verts: ( %i %i %i ) ( %i %i %i ) ( %i %i %i )\n",
int( tri->v[0].xyz.x ), int( tri->v[0].xyz.y ), int( tri->v[0].xyz.z ),
int( tri->v[1].xyz.x ), int( tri->v[1].xyz.y ), int( tri->v[1].xyz.z ),
int( tri->v[2].xyz.x ), int( tri->v[2].xyz.y ), int( tri->v[2].xyz.z ) );
#endif
idPlane plane;
plane.FromPoints( tri->v[0].xyz, tri->v[1].xyz, tri->v[2].xyz );