bool GetEntityCentre( const char* entity, vec3_t centre ) { entity_s* ent = FindEntityFromTargetname( entity, NULL ); if ( !ent ) { return FALSE; } int cnt = g_FuncTable.m_pfnAllocateEntityBrushHandles( ent ); if ( cnt == 0 ) { g_FuncTable.m_pfnReleaseEntityBrushHandles(); return FALSE; } brush_t* brush = (brush_t*)g_FuncTable.m_pfnGetEntityBrushHandle( 0 ); DBrush cBrush; cBrush.LoadFromBrush_t( brush, FALSE ); vec3_t min, max; cBrush.GetBounds( min, max ); VectorAdd( min, max, centre ); VectorScale( centre, 0.5f, centre ); g_FuncTable.m_pfnReleaseEntityBrushHandles(); 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 DoVisAnalyse(){ char filename[1024]; if ( g_FuncTable.m_pfnSelectedBrushCount() == 0 ) { if ( g_VisView ) { delete g_VisView; return; } } if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) { DoMessageBox( "Invalid number of objects selected, select 1 only", "Error", MB_OK ); return; } g_FuncTable.m_pfnAllocateSelectedBrushHandles(); brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 ); DBrush orgBrush; orgBrush.LoadFromBrush_t( brush, false ); g_FuncTable.m_pfnReleaseSelectedBrushHandles(); orgBrush.BuildBounds(); vec3_t origin; origin[0] = ( orgBrush.bbox_max[0] + orgBrush.bbox_min[0] ) / 2.f; origin[1] = ( orgBrush.bbox_max[1] + orgBrush.bbox_min[1] ) / 2.f; origin[2] = ( orgBrush.bbox_max[2] + orgBrush.bbox_min[2] ) / 2.f; char* rad_filename = g_FuncTable.m_pfnGetMapName(); if ( !rad_filename ) { DoMessageBox( "An Error Occurred While Trying\n To Get The Map Filename", "Error", MB_OK ); return; } strcpy( filename, rad_filename ); char* ext = strrchr( filename, '.' ) + 1; strcpy( ext, "bsp" ); // rename the extension list<DWinding*> *pointList = BuildTrace( filename, origin ); if ( !g_VisView ) { g_VisView = new DVisDrawer; g_VisView->Register(); } g_VisView->SetList( pointList ); }
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(); }