void Grid::DistributePatches() { #ifdef USE_MPI // Number of processors int nSize; MPI_Comm_size(MPI_COMM_WORLD, &nSize); // Current processor int nRank; MPI_Comm_rank(MPI_COMM_WORLD, &nRank); // Loop over all patches and initialize data m_vecPatchProcessor.resize(m_aPatchBoxes.GetRows()); for (int n = 0; n < m_aPatchBoxes.GetRows(); n++) { int iPatchProcessor = n % nSize; m_vecPatchProcessor[n] = iPatchProcessor; if (iPatchProcessor == nRank) { GridPatch * pPatch = NewPatch(n); pPatch->InitializeDataLocal(); m_vecActiveGridPatches.push_back(pPatch); m_vecActiveGridPatchIndices.push_back(n); } } #endif }
GridPatch * Grid::ActivateEmptyPatch( int ixPatch ) { GridPatch * pPatch = NewPatch(ixPatch); m_vecActiveGridPatches.push_back(pPatch); m_vecActiveGridPatchIndices.push_back(ixPatch); return pPatch; }
//=========================================================================== // PatchNumber // Always returns a valid index (creating new patches if necessary). //=========================================================================== int PatchNumber(char *name) { int i; patch_t *it; for(i = 0, it = plist.next; it != &plist; it = it->next, i++) if(!stricmp(name, it->name)) return i; it = NewPatch(); strcpy(it->name, name); return i; }
void BuildBSurfacePatches( bsurface_t *cs ) { int width, height; surface_points_t *mesh; surface_points_t *nmesh; int u, v; vec3d_t pos; patch_t *patch; ApproxLightmapSizeOfBSurface( cs->ctrl, &width, &height ); // printf( "width = %d, height = %d\n", width, height ); // cs->patches = NULL; mesh = EvalSurfacePoints( cs->ctrl, width, height ); nmesh = EvalSurfaceNormals( mesh ); FixBoarderNormals( nmesh ); Vec3dInitBB( cs->min3d, cs->max3d, 999999.9 ); for ( u = 0; u < width; u++ ) for ( v = 0; v < height; v++ ) { GetSurfacePoint( mesh, u, v, pos ); patch = NewPatch(); // patch->x = v; // patch->y = u; patch->x = u; patch->y = v; Vec3dCopy( patch->light_origin, pos ); Vec3dCopy( patch->trace_origin, pos ); Vec3dAddToBB( cs->min3d, cs->max3d, pos ); GetSurfacePoint( nmesh, u, v, pos ); Vec3dFlip( pos, pos ); Vec3dCopy( patch->norm, pos ); // Vec3dMA( patch->trace_origin, 1.0, patch->norm, patch->center ); patch->next = cs->patches; cs->patches = patch; bsurf_patch_num++; } cs->width = width; cs->height = height; FreeSurfacePoints( mesh ); FreeSurfacePoints( nmesh ); }
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(); }