Esempio n. 1
0
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;
}