mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-15 07:00:58 +00:00
- Fixed bsp/worldspawn scene node traversal
This commit is contained in:
parent
0cb72166f8
commit
72b535f0ac
3 changed files with 25 additions and 5 deletions
|
@ -33,6 +33,9 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "../renderer/Image.h"
|
||||
|
||||
|
||||
idCVar gltf_MapSceneName( "gltf_MapSceneName", "Scene", CVAR_SYSTEM , "Scene to use when d-mapping a gltf/glb" );
|
||||
|
||||
/*
|
||||
===============
|
||||
FloatCRC
|
||||
|
@ -1671,7 +1674,7 @@ bool idMapFile::Parse( const char* filename, bool ignoreRegion, bool osPath )
|
|||
else if( isGTLF )
|
||||
{
|
||||
gltfParser->Load( fullName );
|
||||
idMapEntity::GetEntities( gltfParser->currentAsset, entities, gltfParser->currentAsset->GetSceneId( "Scene" ) );
|
||||
idMapEntity::GetEntities( gltfParser->currentAsset, entities, gltfParser->currentAsset->GetSceneId( gltf_MapSceneName.GetString() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1987,6 +1987,7 @@ bool GLTF_Parser::loadGLB( idStr filename )
|
|||
}
|
||||
|
||||
Parse();
|
||||
delete file;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -316,6 +316,25 @@ void ProcessSceneNode( idMapEntity* newEntity, gltfNode* node, idMat4& trans, gl
|
|||
newEntity->epairs.Set( "origin", origin.ToString() );
|
||||
}
|
||||
|
||||
void Map_AddMeshes( idMapEntity* _Entity, gltfNode* _Node, idMat4& _Trans, gltfData* _Data )
|
||||
{
|
||||
gltfData::ResolveNodeMatrix( _Node );
|
||||
idMat4 curTrans = _Trans * _Node->matrix;
|
||||
|
||||
if( _Node->mesh != -1 )
|
||||
{
|
||||
for( auto prim : _Data->MeshList( )[_Node->mesh]->primitives )
|
||||
{
|
||||
_Entity->AddPrimitive( MapPolygonMesh::ConvertFromMeshGltf( prim, _Data, curTrans ) );
|
||||
}
|
||||
}
|
||||
|
||||
for( auto& child : _Node->children )
|
||||
{
|
||||
Map_AddMeshes( _Entity, _Data->NodeList( )[child], curTrans, _Data );
|
||||
}
|
||||
};
|
||||
|
||||
int idMapEntity::GetEntities( gltfData* data, EntityListRef entities, int sceneID )
|
||||
{
|
||||
idMapEntity* worldspawn = new( TAG_IDLIB_GLTF ) idMapEntity();
|
||||
|
@ -341,10 +360,7 @@ int idMapEntity::GetEntities( gltfData* data, EntityListRef entities, int sceneI
|
|||
// account all meshes starting with "worldspawn." or "BSP" in the name
|
||||
if( idStr::Icmpn( node->name, "BSP", 3 ) == 0 || idStr::Icmpn( node->name, "worldspawn.", 11 ) == 0 )
|
||||
{
|
||||
for( auto prim : data->MeshList()[node->mesh]->primitives )
|
||||
{
|
||||
worldspawn->AddPrimitive( MapPolygonMesh::ConvertFromMeshGltf( prim, data , mat4_identity ) );
|
||||
}
|
||||
Map_AddMeshes( worldspawn, node, mat4_identity, data );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue