bool DEntity::LoadFromEntity( scene::Node& ent, bool bLoadPatches ) { ClearPatches(); ClearBrushes(); ClearEPairs(); QER_Entity = &ent; LoadEPairList( Node_getEntity( ent ) ); bool keep = false; int i; for ( i = 0; brushEntityList[i]; i++ ) { if ( string_equal_nocase( brushEntityList[i], m_Classname ) ) { keep = true; break; } } if ( !keep ) { return false; } if ( Node_getTraversable( ent ) ) { class load_brushes_t : public scene::Traversable::Walker { DEntity* m_entity; mutable int m_count; public: load_brushes_t( DEntity* entity ) : m_entity( entity ), m_count( 0 ){ } bool pre( scene::Node& node ) const { scene::Path path( NodeReference( GlobalSceneGraph().root() ) ); path.push( NodeReference( *m_entity->QER_Entity ) ); path.push( NodeReference( node ) ); scene::Instance* instance = GlobalSceneGraph().find( path ); ASSERT_MESSAGE( instance != 0, "" ); if ( Node_isPatch( node ) ) { DPatch* loadPatch = m_entity->NewPatch(); loadPatch->LoadFromPatch( *instance ); } else if ( Node_isBrush( node ) ) { DBrush* loadBrush = m_entity->NewBrush( m_count++ ); loadBrush->LoadFromBrush( *instance, true ); } return false; } } load_brushes( this ); Node_getTraversable( ent )->traverse( load_brushes ); } return true; }
bool DEntity::LoadFromPrt( char *filename ){ CPortals portals; strcpy( portals.fn, filename ); portals.Load(); if ( portals.node_count == 0 ) { return false; } ClearBrushes(); ClearEPairs(); bool build = false; for ( unsigned int i = 0; i < portals.node_count; i++ ) { build = false; DBrush* brush = NewBrush(); for ( unsigned int j = 0; j < portals.node[i].portal_count; j++ ) { for ( unsigned int k = 0; k < portals.node[i].portal[j].point_count - 2; k++ ) { vec3_t v1{}, v2{}, normal{}, n{}; VectorSubtract( portals.node[i].portal[j].point[k + 2].p, portals.node[i].portal[j].point[k + 1].p, v1 ); VectorSubtract( portals.node[i].portal[j].point[k].p, portals.node[i].portal[j].point[k + 1].p, v2 ); CrossProduct( v1, v2, n ); VectorNormalize( n, v2 ); if ( k == 0 ) { VectorCopy( v2, normal ); } else { VectorSubtract( v2, normal, v1 ); if ( VectorLength( v1 ) > 0.01 ) { build = true; break; } } } if ( !build ) { brush->AddFace( portals.node[i].portal[j].point[2].p, portals.node[i].portal[j].point[1].p, portals.node[i].portal[j].point[0].p, "textures/common/caulk", false ); } else{ brush->AddFace( portals.node[i].portal[j].point[0].p, portals.node[i].portal[j].point[1].p, portals.node[i].portal[j].point[2].p, "textures/common/caulk", false ); } } if ( build ) { brush->BuildInRadiant( false, NULL ); } } return true; }
bool DEntity::LoadFromEntity( entity_t* ent, bool bLoadPatches ) { ClearPatches(); ClearBrushes(); ClearEPairs(); QER_Entity = ent; epair_t* epl = *g_EntityTable.m_pfnGetEntityKeyValList( QER_Entity ); LoadEPairList( epl ); bool keep = FALSE; int i; for ( i = 0; brushEntityList[i]; i++ ) { if ( !stricmp( brushEntityList[i], m_Classname ) ) { keep = TRUE; break; } } if ( !keep ) { return FALSE; } int count = g_FuncTable.m_pfnAllocateEntityBrushHandles( QER_Entity ); for ( i = 0; i < count; i++ ) { brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetEntityBrushHandle( i ); if ( brush == NULL ) { DoMessageBox( "GTKRadiant returned a NULL pointer, NOT a good sign", "WARNING!!!", MB_OK ); continue; } if ( brush->pPatch ) { if ( bLoadPatches ) { DPatch* loadPatch = NewPatch(); loadPatch->LoadFromBrush_t( brush ); } } else { DBrush* loadBrush = NewBrush( i ); loadBrush->LoadFromBrush_t( brush, TRUE ); } } g_FuncTable.m_pfnReleaseEntityBrushHandles(); return TRUE; }
void DEntity::LoadSelectedPatches(){ ClearPatches(); ClearEPairs(); int count = g_FuncTable.m_pfnAllocateSelectedPatchHandles(); for ( int i = 0; i < count; i++ ) { //$ FIXME: m_pfnGetPatchHandle patchMesh_t *pmesh = (patchMesh_t*)g_FuncTable.m_pfnGetPatchData( i ); DPatch* loadPatch = NewPatch(); loadPatch->LoadFromBrush_t( pmesh->pSymbiot ); } g_FuncTable.m_pfnReleasePatchHandles(); }
void DEntity::LoadSelectedBrushes(){ ClearBrushes(); ClearEPairs(); int count = g_FuncTable.m_pfnAllocateSelectedBrushHandles(); for ( int i = 0; i < count; i++ ) { brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( i ); if ( brush->pPatch ) { continue; } DBrush* loadBrush = NewBrush( i ); loadBrush->LoadFromBrush_t( brush, TRUE ); } g_FuncTable.m_pfnReleaseSelectedBrushHandles(); }
DEntity::~DEntity(){ ClearPatches(); ClearBrushes(); ClearEPairs(); }
void DEntity::LoadSelectedPatches(){ ClearPatches(); ClearEPairs(); Scene_forEachSelectedPatch( DEntityLoadPatchCaller( *this ) ); }
void DEntity::LoadSelectedBrushes(){ ClearBrushes(); ClearEPairs(); Scene_forEachSelectedBrush( DEntityLoadBrushCaller( *this ) ); }