/* ============ idCmdSystemLocal::Shutdown ============ */ void idCmdSystemLocal::Shutdown( void ) { commandDef_t *cmd; for ( cmd = commands; cmd; cmd = commands ) { commands = commands->next; // jmarshall // Mem_Free( cmd->name ); // Mem_Free( cmd->description ); // jmarshall end delete cmd; } completionString.Clear(); completionParms.Clear(); tokenizedCmds.Clear(); postReload.Clear(); }
/* ================ DialogScriptEditor::InitScriptEvents ================ */ void DialogScriptEditor::InitScriptEvents( void ) { int index; idParser src; idToken token; idStr whiteSpace; scriptEventInfo_t info; if ( !src.LoadFile( "script/doom_events.script" ) ) { return; } scriptEvents.Clear(); while( src.ReadToken( &token ) ) { if ( token == "scriptEvent" ) { src.GetLastWhiteSpace( whiteSpace ); index = whiteSpace.Find( "//" ); if ( index != -1 ) { info.help = whiteSpace.Right( whiteSpace.Length() - index ); info.help.Remove( '\r' ); info.help.Replace( "\n", "\r\n" ); } else { info.help = ""; } src.ExpectTokenType( TT_NAME, 0, &token ); info.parms = token; src.ExpectTokenType( TT_NAME, 0, &token ); info.name = token; src.ExpectTokenString( "(" ); info.parms += " " + info.name + "("; while( src.ReadToken( &token ) && token != ";" ) { info.parms.Append( " " + token ); } scriptEvents.Append( info ); } } }
/* ==================== R_GetModeListForDisplay ==================== */ bool R_GetModeListForDisplay( const int requestedDisplayNum, idList<vidMode_t>& modeList ) { assert( requestedDisplayNum >= 0 ); modeList.Clear(); if( requestedDisplayNum >= SDL_GetNumVideoDisplays() ) { // requested invalid displaynum return false; } int numModes = SDL_GetNumDisplayModes( requestedDisplayNum ); if( numModes > 0 ) { for( int i = 0; i < numModes; i++ ) { SDL_DisplayMode m; int ret = SDL_GetDisplayMode( requestedDisplayNum, i, &m ); if( ret != 0 ) { common->Warning( "Can't get video mode no %i, because of %s\n", i, SDL_GetError() ); continue; } vidMode_t mode; mode.width = m.w; mode.height = m.h; mode.displayHz = m.refresh_rate ? m.refresh_rate : 60; // default to 60 if unknown (0) modeList.AddUnique( mode ); } if( modeList.Num() < 1 ) { common->Warning( "Couldn't get a single video mode for display %i, using default ones..!\n", requestedDisplayNum ); FillStaticVidModes( modeList ); } // sort with lowest resolution first modeList.SortWithTemplate( idSort_VidMode() ); } else { common->Warning( "Can't get Video Info, using default modes...\n" ); if( numModes < 0 ) { common->Warning( "Reason was: %s\n", SDL_GetError() ); } FillStaticVidModes( modeList ); } return true; }
/* ================= idRenderModelManagerLocal::FindSkeletalMeshes ================= */ void idRenderModelManagerLocal::FindSkeletalMeshes( idList<idStr> &skeletalMeshes ) { const idDecl *decl; skeletalMeshes.Clear(); for(int i = 0; i < declManager->GetNumDecls( DECL_MODELDEF ); i++) { decl = declManager->DeclByIndex( DECL_MODELDEF, i, false ); // This probley isn't the best way to do this, just check to see if the decl def has the skeletal model extension. char *text = (char *)_alloca( decl->GetTextLength() + 1 ); decl->GetText( text ); if(!strstr(text, ".md5mesh")) { _resetstkoflw(); continue; } _resetstkoflw(); skeletalMeshes.Append( decl->GetName() ); } }
/* ==================== R_GetModeListForDisplay ==================== */ bool R_GetModeListForDisplay( const int requestedDisplayNum, idList<vidMode_t>& modeList ) { modeList.Clear(); bool verbose = false; for( int displayNum = requestedDisplayNum; ; displayNum++ ) { DISPLAY_DEVICE device; device.cb = sizeof( device ); if( !EnumDisplayDevices( 0, // lpDevice displayNum, &device, 0 /* dwFlags */ ) ) { return false; } // get the monitor for this display if( !( device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP ) ) { continue; } DISPLAY_DEVICE monitor; monitor.cb = sizeof( monitor ); if( !EnumDisplayDevices( device.DeviceName, 0, &monitor, 0 /* dwFlags */ ) ) { continue; } DEVMODE devmode; devmode.dmSize = sizeof( devmode ); if( verbose ) { common->Printf( "display device: %i\n", displayNum ); common->Printf( " DeviceName : %s\n", device.DeviceName ); common->Printf( " DeviceString: %s\n", device.DeviceString ); common->Printf( " StateFlags : 0x%x\n", device.StateFlags ); common->Printf( " DeviceID : %s\n", device.DeviceID ); common->Printf( " DeviceKey : %s\n", device.DeviceKey ); common->Printf( " DeviceName : %s\n", monitor.DeviceName ); common->Printf( " DeviceString: %s\n", monitor.DeviceString ); common->Printf( " StateFlags : 0x%x\n", monitor.StateFlags ); common->Printf( " DeviceID : %s\n", monitor.DeviceID ); common->Printf( " DeviceKey : %s\n", monitor.DeviceKey ); } for( int modeNum = 0 ; ; modeNum++ ) { if( !EnumDisplaySettings( device.DeviceName, modeNum, &devmode ) ) { break; } if( devmode.dmBitsPerPel != 32 ) { continue; } if( ( devmode.dmDisplayFrequency != 60 ) && ( devmode.dmDisplayFrequency != 120 ) ) { continue; } if( devmode.dmPelsHeight < 720 ) { continue; } if( verbose ) { common->Printf( " -------------------\n" ); common->Printf( " modeNum : %i\n", modeNum ); common->Printf( " dmPosition.x : %i\n", devmode.dmPosition.x ); common->Printf( " dmPosition.y : %i\n", devmode.dmPosition.y ); common->Printf( " dmBitsPerPel : %i\n", devmode.dmBitsPerPel ); common->Printf( " dmPelsWidth : %i\n", devmode.dmPelsWidth ); common->Printf( " dmPelsHeight : %i\n", devmode.dmPelsHeight ); common->Printf( " dmDisplayFixedOutput: %s\n", DMDFO( devmode.dmDisplayFixedOutput ) ); common->Printf( " dmDisplayFlags : 0x%x\n", devmode.dmDisplayFlags ); common->Printf( " dmDisplayFrequency : %i\n", devmode.dmDisplayFrequency ); } vidMode_t mode; mode.width = devmode.dmPelsWidth; mode.height = devmode.dmPelsHeight; mode.displayHz = devmode.dmDisplayFrequency; modeList.AddUnique( mode ); } if( modeList.Num() > 0 ) { // sort with lowest resolution first modeList.SortWithTemplate( idSort_VidMode() ); return true; } } // Never gets here }
/* ================ sdVehiclePathGrid::SetupPath ================ */ void sdVehiclePathGrid::SetupPath( const idVec3& position, idList< splineSection_t >& inSpline, idList< splineSection_t >& outSpline, int seed ) const { int x, y; int xmin, ymin; GetCoordsForPoint( x, y, xmin, ymin, position ); int nx, ny; GetEdgePoint( x, y, nx, ny, seed, 0, 0 ); idVec3 edgePos; GetPointInternal( nx, ny, edgePos ); AdjustTargetForStart( edgePos, position, x, y, xmin, ymin ); bool ymainaxis = abs( ny - y ) > abs( nx - x ); int loopPos; int loopDir; int loopStart; int loopEnd; float loopLen; if ( ymainaxis ) { loopPos = ny; loopStart = ny; loopDir = ny > y ? -1 : 1; loopLen = ny - y; loopEnd = y; } else { loopPos = nx; loopStart = nx; loopDir = nx > x ? -1 : 1; loopLen = nx - x; loopEnd = x; } idVec3 endPoint; GetPoint( x, y, endPoint ); idVec3 lastPos; GetPoint( nx, ny, lastPos ); idVec3 inVector = ( endPoint - lastPos ); inVector[ 2 ] = 0.f; inVector.Normalize(); float scale = 64.f; // inVector.Normalize(); inSpline.Clear(); while ( loopPos != loopEnd ) { int currentPos[ 2 ]; loopPos += loopDir; float frac = ( loopPos - loopStart ) / loopLen; if ( ymainaxis ) { currentPos[ 0 ] = nx + ( ( nx - x ) * frac ); currentPos[ 1 ] = loopPos; } else { currentPos[ 0 ] = loopPos; currentPos[ 1 ] = ny + ( ( ny - y ) * frac ); } idVec3 newPos; GetPointInternal( currentPos[ 0 ], currentPos[ 1 ], newPos ); AddSection( lastPos, inVector, newPos, endPoint, loopPos != loopEnd, inSpline ); } { idVec3 hoverPos = position; hoverPos[ 2 ] = lastPos[ 2 ]; idVec3 temp = ( hoverPos - lastPos ); scale = temp.Normalize() * 0.125f; idVec3 newInVector( 0.f, 0.f, -1.f ); newInVector += temp * 0.2f; newInVector.Normalize(); splineSection_t& section = inSpline.Alloc(); section.AddValue( 0.f, lastPos ); section.AddValue( 1.f / 3.f, lastPos + ( inVector * ( scale ) ) ); section.AddValue( 2.f / 3.f, hoverPos - ( newInVector * ( scale ) ) ); section.AddValue( 1.f, hoverPos ); lastPos = hoverPos; inVector = newInVector; } { GetCoordsForPoint( nx, ny, xmin, ymin, lastPos ); idVec3 startPoint; GetPoint( nx, ny, startPoint ); idVec3 temp = startPoint - lastPos; scale = temp.Normalize() * 0.125f; inVector[ 2 ] = 0.f; inVector.Normalize(); inVector *= 0.2f; inVector += idVec3( 0.f, 0.f, 1.f ); inVector.Normalize(); GetEdgePoint( nx, ny, x, y, seed, 0, 0 ); GetPoint( x, y, endPoint ); } ymainaxis = abs( ny - y ) > abs( nx - x ); if ( ymainaxis ) { loopPos = ny; loopStart = ny; loopDir = ny > y ? -1 : 1; loopLen = ny - y; loopEnd = y; } else { loopPos = nx; loopStart = nx; loopDir = nx > x ? -1 : 1; loopLen = nx - x; loopEnd = x; } outSpline.Clear(); while ( loopPos != loopEnd ) { int currentPos[ 2 ]; loopPos += loopDir; float frac = ( loopPos - loopStart ) / loopLen; if ( ymainaxis ) { currentPos[ 0 ] = nx + ( ( nx - x ) * frac ); currentPos[ 1 ] = loopPos; } else { currentPos[ 0 ] = loopPos; currentPos[ 1 ] = ny + ( ( ny - y ) * frac ); } idVec3 newPos; GetPointInternal( currentPos[ 0 ], currentPos[ 1 ], newPos ); AddSection( lastPos, inVector, newPos, endPoint, loopPos != loopEnd, outSpline ); } }
/* ================= Sys_ShutdownInput ================= */ void Sys_ShutdownInput() { kbd_polls.Clear(); mouse_polls.Clear(); }
/* ================ ScriptEditorShutdown ================ */ void ScriptEditorShutdown( void ) { delete g_ScriptDialog; g_ScriptDialog = NULL; scriptEvents.Clear(); }
/* ==================== R_GetModeListForDisplay ==================== */ bool R_GetModeListForDisplay( const int requestedDisplayNum, idList<vidMode_t>& modeList ) { assert( requestedDisplayNum >= 0 ); modeList.Clear(); #if SDL_VERSION_ATLEAST(2, 0, 0) // DG: SDL2 implementation if( requestedDisplayNum >= SDL_GetNumVideoDisplays() ) { // requested invalid displaynum return false; } int numModes = SDL_GetNumDisplayModes( requestedDisplayNum ); if( numModes > 0 ) { for( int i = 0; i < numModes; i++ ) { SDL_DisplayMode m; int ret = SDL_GetDisplayMode( requestedDisplayNum, i, &m ); if( ret != 0 ) { common->Warning( "Can't get video mode no %i, because of %s\n", i, SDL_GetError() ); continue; } vidMode_t mode; mode.width = m.w; mode.height = m.h; mode.displayHz = m.refresh_rate ? m.refresh_rate : 60; // default to 60 if unknown (0) modeList.AddUnique( mode ); } if( modeList.Num() < 1 ) { common->Warning( "Couldn't get a single video mode for display %i, using default ones..!\n", requestedDisplayNum ); FillStaticVidModes( modeList ); } // sort with lowest resolution first modeList.SortWithTemplate( idSort_VidMode() ); } else { common->Warning( "Can't get Video Info, using default modes...\n" ); if( numModes < 0 ) { common->Warning( "Reason was: %s\n", SDL_GetError() ); } FillStaticVidModes( modeList ); } return true; // DG end #else // SDL 1 // DG: SDL1 only knows of one display - some functions rely on // R_GetModeListForDisplay() returning false for invalid displaynum to iterate all displays if( requestedDisplayNum >= 1 ) { return false; } // DG end const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo(); if( videoInfo == NULL ) { // DG: yes, this can actually fail, e.g. if SDL_Init( SDL_INIT_VIDEO ) wasn't called common->Warning( "Can't get Video Info, using default modes...\n" ); FillStaticVidModes( modeList ); return true; } SDL_Rect** modes = SDL_ListModes( videoInfo->vfmt, SDL_OPENGL | SDL_FULLSCREEN ); if( !modes ) { common->Warning( "Can't get list of available modes, using default ones...\n" ); FillStaticVidModes( modeList ); return true; } if( modes == ( SDL_Rect** ) - 1 ) { common->Printf( "Display supports any resolution\n" ); FillStaticVidModes( modeList ); return true; } int numModes; for( numModes = 0; modes[numModes]; numModes++ ); if( numModes > 1 ) { for( int i = 0; i < numModes; i++ ) { vidMode_t mode; mode.width = modes[i]->w; mode.height = modes[i]->h; mode.displayHz = 60; // FIXME; modeList.AddUnique( mode ); } // sort with lowest resolution first modeList.SortWithTemplate( idSort_VidMode() ); return true; } return false; #endif }
/* ================================================================================================ idRenderProgManager::LoadGLSLShader ================================================================================================ */ GLuint idRenderProgManager::LoadGLSLShader( GLenum target, const char * name, idList<int> & uniforms ) { idStr inFile; idStr outFileHLSL; idStr outFileGLSL; idStr outFileUniforms; inFile.Format( "renderprogs\\%s", name ); inFile.StripFileExtension(); outFileHLSL.Format( "renderprogs\\glsl\\%s", name ); outFileHLSL.StripFileExtension(); outFileGLSL.Format( "renderprogs\\glsl\\%s", name ); outFileGLSL.StripFileExtension(); outFileUniforms.Format( "renderprogs\\glsl\\%s", name ); outFileUniforms.StripFileExtension(); if ( target == GL_FRAGMENT_SHADER ) { inFile += ".pixel"; outFileHLSL += "_fragment.hlsl"; outFileGLSL += "_fragment.glsl"; outFileUniforms += "_fragment.uniforms"; } else { inFile += ".vertex"; outFileHLSL += "_vertex.hlsl"; outFileGLSL += "_vertex.glsl"; outFileUniforms += "_vertex.uniforms"; } // first check whether we already have a valid GLSL file and compare it to the hlsl timestamp; ID_TIME_T hlslTimeStamp; int hlslFileLength = fileSystem->ReadFile( inFile.c_str(), NULL, &hlslTimeStamp ); ID_TIME_T glslTimeStamp; int glslFileLength = fileSystem->ReadFile( outFileGLSL.c_str(), NULL, &glslTimeStamp ); // if the glsl file doesn't exist or we have a newer HLSL file we need to recreate the glsl file. idStr programGLSL; idStr programUniforms; if ( ( glslFileLength <= 0 ) || ( hlslTimeStamp > glslTimeStamp ) ) { if ( hlslFileLength <= 0 ) { // hlsl file doesn't even exist bail out return false; } void * hlslFileBuffer = NULL; int len = fileSystem->ReadFile( inFile.c_str(), &hlslFileBuffer ); if ( len <= 0 ) { return false; } idStr hlslCode( ( const char* ) hlslFileBuffer ); idStr programHLSL = StripDeadCode( hlslCode, inFile ); programGLSL = ConvertCG2GLSL( programHLSL, inFile, target == GL_VERTEX_SHADER, programUniforms ); fileSystem->WriteFile( outFileHLSL, programHLSL.c_str(), programHLSL.Length(), "fs_basepath" ); fileSystem->WriteFile( outFileGLSL, programGLSL.c_str(), programGLSL.Length(), "fs_basepath" ); if ( r_useUniformArrays.GetBool() ) { fileSystem->WriteFile( outFileUniforms, programUniforms.c_str(), programUniforms.Length(), "fs_basepath" ); } } else { // read in the glsl file void * fileBufferGLSL = NULL; int lengthGLSL = fileSystem->ReadFile( outFileGLSL.c_str(), &fileBufferGLSL ); if ( lengthGLSL <= 0 ) { idLib::Error( "GLSL file %s could not be loaded and may be corrupt", outFileGLSL.c_str() ); } programGLSL = ( const char * ) fileBufferGLSL; Mem_Free( fileBufferGLSL ); if ( r_useUniformArrays.GetBool() ) { // read in the uniform file void * fileBufferUniforms = NULL; int lengthUniforms = fileSystem->ReadFile( outFileUniforms.c_str(), &fileBufferUniforms ); if ( lengthUniforms <= 0 ) { idLib::Error( "uniform file %s could not be loaded and may be corrupt", outFileUniforms.c_str() ); } programUniforms = ( const char* ) fileBufferUniforms; Mem_Free( fileBufferUniforms ); } } // find the uniforms locations in either the vertex or fragment uniform array if ( r_useUniformArrays.GetBool() ) { uniforms.Clear(); idLexer src( programUniforms, programUniforms.Length(), "uniforms" ); idToken token; while ( src.ReadToken( &token ) ) { int index = -1; for ( int i = 0; i < RENDERPARM_TOTAL && index == -1; i++ ) { const char * parmName = GetGLSLParmName( i ); if ( token == parmName ) { index = i; } } for ( int i = 0; i < MAX_GLSL_USER_PARMS && index == -1; i++ ) { const char * parmName = GetGLSLParmName( RENDERPARM_USER + i ); if ( token == parmName ) { index = RENDERPARM_USER + i; } } if ( index == -1 ) { idLib::Error( "couldn't find uniform %s for %s", token.c_str(), outFileGLSL.c_str() ); } uniforms.Append( index ); } } // create and compile the shader const GLuint shader = qglCreateShader( target ); if ( shader ) { const char * source[1] = { programGLSL.c_str() }; qglShaderSource( shader, 1, source, NULL ); qglCompileShader( shader ); int infologLength = 0; qglGetShaderiv( shader, GL_INFO_LOG_LENGTH, &infologLength ); if ( infologLength > 1 ) { idTempArray<char> infoLog( infologLength ); int charsWritten = 0; qglGetShaderInfoLog( shader, infologLength, &charsWritten, infoLog.Ptr() ); // catch the strings the ATI and Intel drivers output on success if ( strstr( infoLog.Ptr(), "successfully compiled to run on hardware" ) != NULL || strstr( infoLog.Ptr(), "No errors." ) != NULL ) { //idLib::Printf( "%s program %s from %s compiled to run on hardware\n", typeName, GetName(), GetFileName() ); } else if ( r_displayGLSLCompilerMessages.GetBool() ) { idLib::Printf( "While compiling %s program %s\n", ( target == GL_FRAGMENT_SHADER ) ? "fragment" : "vertex" , inFile.c_str() ); const char separator = '\n'; idList<idStr> lines; lines.Clear(); idStr source( programGLSL ); lines.Append( source ); for ( int index = 0, ofs = lines[index].Find( separator ); ofs != -1; index++, ofs = lines[index].Find( separator ) ) { lines.Append( lines[index].c_str() + ofs + 1 ); lines[index].CapLength( ofs ); } idLib::Printf( "-----------------\n" ); for ( int i = 0; i < lines.Num(); i++ ) { idLib::Printf( "%3d: %s\n", i+1, lines[i].c_str() ); } idLib::Printf( "-----------------\n" ); idLib::Printf( "%s\n", infoLog.Ptr() ); } } GLint compiled = GL_FALSE; qglGetShaderiv( shader, GL_COMPILE_STATUS, &compiled ); if ( compiled == GL_FALSE ) { qglDeleteShader( shader ); return INVALID_PROGID; } } return shader; }
void Select_AutoCaulk() { /*Sys_Printf*/common->Printf("Caulking...\n"); FacesToCaulk.Clear(); int iSystemBrushesSkipped = 0; face_t *pSelectedFace; brush_t *next; for (brush_t *pSelectedBrush = selected_brushes.next ; pSelectedBrush != &selected_brushes ; pSelectedBrush = next) { next = pSelectedBrush->next; if (pSelectedBrush->owner->eclass->fixedsize) continue; // apparently this means it's a model, so skip it... // new check, we can't caulk a brush that has any "system/" faces... // bool bSystemFacePresent = false; for ( pSelectedFace = pSelectedBrush->brush_faces; pSelectedFace; pSelectedFace = pSelectedFace->next) { if (!strnicmp(pSelectedFace->d_texture->GetName(),"system/",7)) { bSystemFacePresent = true; break; } } if (bSystemFacePresent) { iSystemBrushesSkipped++; continue; // verboten to caulk this. } for (int iBrushListToScan = 0; iBrushListToScan<2; iBrushListToScan++) { brush_t *snext; for (brush_t *pScannedBrush = (iBrushListToScan?active_brushes.next:selected_brushes.next); pScannedBrush != (iBrushListToScan?&active_brushes:&selected_brushes) ; pScannedBrush = snext) { snext = pScannedBrush->next; if ( pScannedBrush == pSelectedBrush) continue; if (pScannedBrush->owner->eclass->fixedsize || pScannedBrush->pPatch || pScannedBrush->hiddenBrush) continue; if (FilterBrush(pScannedBrush)) continue; // idMaterial stuff no longer support this, not sure what else to do. // Searching for other occurences of QER_NOCARVE just shows people REMing the code and ignoring ths issue... // // if (pScannedBrush->brush_faces->d_texture->bFromShader && (pScannedBrush->brush_faces->d_texture->TestMaterialFlag(QER_NOCARVE))) // continue; // basic-reject first to see if brushes can even possibly touch (coplanar counts as touching) // int i; for (i=0 ; i<3 ; i++) { if (pSelectedBrush->mins[i] > pScannedBrush->maxs[i] || pSelectedBrush->maxs[i] < pScannedBrush->mins[i]) { break; } } if (i != 3) continue; // can't be touching // ok, now for the clever stuff, we need to detect only those faces that are both coplanar and smaller // or equal to the face they're coplanar with... // for (pSelectedFace = pSelectedBrush->brush_faces; pSelectedFace; pSelectedFace = pSelectedFace->next) { idWinding *pSelectedWinding = pSelectedFace->face_winding; if (!pSelectedWinding) continue; // freed face, probably won't happen here, but who knows with this program? // SquaredFace_t SelectedSquaredFace; // WindingToSquaredFace( &SelectedSquaredFace, pSelectedWinding); for (face_t *pScannedFace = pScannedBrush->brush_faces; pScannedFace; pScannedFace = pScannedFace->next) { // don't even try caulking against a system face, because these are often transparent and will leave holes // if (!strnicmp(pScannedFace->d_texture->GetName(),"system/",7)) continue; // and don't try caulking against something inherently transparent... // if (pScannedFace->d_texture->TestMaterialFlag(QER_TRANS)) continue; idWinding *pScannedWinding = pScannedFace->face_winding; if (!pScannedWinding) continue; // freed face, probably won't happen here, but who knows with this program? // SquaredFace_t ScannedSquaredFace; // WindingToSquaredFace( &ScannedSquaredFace, pScannedWinding); /* if (VectorCompare(ScannedSquaredFace.v3NormalisedRotationVector, SelectedSquaredFace.v3NormalisedRotationVector) && VectorCompare(ScannedSquaredFace.v3NormalisedElevationVector, SelectedSquaredFace.v3NormalisedElevationVector) ) */ { // brush faces are in parallel planes to each other, so check that their normals // are opposite, by adding them together and testing for zero... // (if normals are opposite, then faces can be against/touching each other?) // idVec3 v3ZeroTest; idVec3 v3Zero;v3Zero.Zero(); //static idVec3 v3Zero={0,0,0}; VectorAdd(pSelectedFace->plane.Normal(),pScannedFace->plane.Normal(),v3ZeroTest); if (v3ZeroTest == v3Zero) { // planes are facing each other... // // coplanar? (this is some maths of Gil's, which I don't even pretend to understand) // float fTotalDist = 0; for (int _i=0; _i<3; _i++) { fTotalDist += fabs( DotProduct(pSelectedFace->plane.Normal(),(*pSelectedWinding)[0]) - DotProduct(pSelectedFace->plane.Normal(),(*pScannedWinding)[i]) ); } //OutputDebugString(va("Dist = %g\n",fTotalDist)); if (fTotalDist > 0.01) continue; // every point in the selected face must be within (or equal to) the bounds of the // scanned face... // // work out the bounds first... // idVec3 v3ScannedBoundsMins, v3ScannedBoundsMaxs; ClearBounds (v3ScannedBoundsMins, v3ScannedBoundsMaxs); int iPoint; for (iPoint=0; iPoint<pScannedWinding->GetNumPoints(); iPoint++) { AddPointToBounds( (*pScannedWinding)[iPoint].ToVec3(), v3ScannedBoundsMins, v3ScannedBoundsMaxs); } // floor 'em... (or .001 differences mess things up... // FloorBounds(v3ScannedBoundsMins, v3ScannedBoundsMaxs); // now check points from selected face... // bool bWithin = true; for (iPoint=0; iPoint < pSelectedWinding->GetNumPoints(); iPoint++) { for (int iXYZ=0; iXYZ<3; iXYZ++) { float f = floor((*pSelectedWinding)[iPoint][iXYZ] + 0.5); if (! ( f >= v3ScannedBoundsMins[iXYZ] && f <= v3ScannedBoundsMaxs[iXYZ] ) ) { bWithin = false; } } } if (bWithin) { PairBrushFace_t PairBrushFace; PairBrushFace.pFace = pSelectedFace; PairBrushFace.pBrush= pSelectedBrush; FacesToCaulk.Append(PairBrushFace); } } } } } } } } // apply caulk... // int iFacesCaulked = 0; if (FacesToCaulk.Num()) { LPCSTR psCaulkName = "textures/common/caulk"; const idMaterial *pCaulk = Texture_ForName(psCaulkName); if (pCaulk) { // // and call some other junk that Radiant wants so so we can use it later... // texdef_t tex; memset (&tex, 0, sizeof(tex)); tex.scale[0] = 1; tex.scale[1] = 1; //tex.flags = pCaulk->flags; // field missing in Q4 //tex.value = pCaulk->value; // ditto //tex.contents = pCaulk->contents; // ditto tex.SetName( pCaulk->GetName() ); //Texture_SetTexture (&tex); for (int iListEntry = 0; iListEntry < FacesToCaulk.Num(); iListEntry++) { PairBrushFace_t &PairBrushFace = FacesToCaulk[iListEntry]; face_t *pFace = PairBrushFace.pFace; brush_t*pBrush= PairBrushFace.pBrush; pFace->d_texture = pCaulk; pFace->texdef = tex; Face_FitTexture(pFace, 1, 1); // this doesn't work here for some reason... duh. Brush_Build(pBrush); iFacesCaulked++; } } else { /*Sys_Printf*/common->Printf(" Unable to locate caulk texture at: \"%s\"!\n",psCaulkName); } } /*Sys_Printf*/common->Printf("( %d faces caulked )\n",iFacesCaulked); if (iSystemBrushesSkipped) { /*Sys_Printf*/common->Printf("( %d system-faced brushes skipped )\n",iSystemBrushesSkipped); } Sys_UpdateWindows (W_ALL); }
/* ======================== idLobbyBackendDirect::GetSearchResults ======================== */ void idLobbyBackendDirect::GetSearchResults( idList< lobbyConnectInfo_t >& searchResults ) { lobbyConnectInfo_t fakeResult; searchResults.Clear(); searchResults.Append( fakeResult ); }
/* ================= Sys_ShutdownInput ================= */ void Sys_ShutdownInput() { kbd_polls.Clear(); mouse_polls.Clear(); joystick_polls.Clear(); event_overflow.Clear(); }