From 3646c894a9193c8b9c09e3d61eace065feede473 Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Sun, 12 Mar 2017 22:08:21 +0000 Subject: [PATCH] Remove some dead/debug code --- contrib/bobtoolz/DBrush.cpp | 7 - contrib/bobtoolz/DPatch.cpp | 60 -- contrib/bobtoolz/dialogs/AboutDialog.cpp | 6 - contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp | 6 - .../bobtoolz/dialogs/AutoCaulkStartDialog.cpp | 6 - contrib/bobtoolz/dialogs/DoorDialog.cpp | 6 - contrib/bobtoolz/dialogs/IntersectDialog.cpp | 6 - .../bobtoolz/dialogs/IntersectInfoDialog.cpp | 6 - contrib/bobtoolz/dialogs/PolygonDialog.cpp | 6 - contrib/bobtoolz/dialogs/StairDialog.cpp | 6 - .../bobtoolz/dialogs/TextureResetDialog.cpp | 6 - contrib/bobtoolz/dialogs/brushcheckdialog.cpp | 6 - .../bobtoolz/dialogs/pathplotterdialog.cpp | 5 - contrib/gtkgensurf/face.cpp | 125 --- contrib/gtkgensurf/gendlgs.cpp | 212 ----- contrib/gtkgensurf/genmap.cpp | 77 +- contrib/ufoaiplug/ufoai_filters.cpp | 7 +- include/ibrush.h | 48 - include/igl.h | 95 +- include/ipatch.h | 61 -- include/modulesystem.h | 4 - include/preferencesystem.cpp | 167 ---- plugins/archivepak/archive.cpp | 68 -- plugins/archivewad/archive.cpp | 44 - plugins/archivezip/archive.cpp | 40 - plugins/entity/group.cpp | 85 -- plugins/entity/light.cpp | 52 +- plugins/imagehl/sprite.cpp | 14 - plugins/md3model/model.h | 23 - plugins/model/model.cpp | 336 ------- plugins/shaders/shaders.cpp | 5 - plugins/spritemodel/spritemodel.cpp | 36 - plugins/textool/TexTool.cpp | 199 ---- plugins/vfspk3/archive.cpp | 43 - radiant/brush.cpp | 15 - radiant/brush.h | 116 +-- radiant/brush_primit.cpp | 451 +-------- radiant/brushmanip.cpp | 226 ----- radiant/build.cpp | 13 - radiant/camwindow.cpp | 52 - radiant/commands.cpp | 7 - radiant/dialog.cpp | 17 - radiant/entity.cpp | 46 +- radiant/error.cpp | 17 - radiant/main.cpp | 15 - radiant/mainframe.cpp | 184 ---- radiant/mainframe.h | 3 - radiant/map.cpp | 5 - radiant/patch.cpp | 67 -- radiant/patch.h | 78 +- radiant/pluginapi.cpp | 8 - radiant/pluginmenu.cpp | 6 - radiant/referencecache.cpp | 8 - radiant/renderstate.cpp | 382 +------- radiant/select.cpp | 12 - radiant/selection.cpp | 55 -- radiant/server.cpp | 5 - radiant/stacktrace.cpp | 52 - radiant/textures.cpp | 75 -- radiant/treemodel.cpp | 894 ------------------ radiant/undo.cpp | 22 - radiant/watchbsp.cpp | 46 - radiant/winding.cpp | 6 - radiant/xywindow.cpp | 86 -- tools/quake2/common/cmdlib.c | 15 - tools/quake2/common/inout.c | 27 - tools/quake2/extra/bsp/qbsp3/brushbsp.c | 42 - tools/quake3/q3map2/light_ydnar.c | 3 - tools/quake3/q3map2/vis.c | 24 - tools/quake3/q3map2/visflow.c | 28 - 70 files changed, 32 insertions(+), 4949 deletions(-) diff --git a/contrib/bobtoolz/DBrush.cpp b/contrib/bobtoolz/DBrush.cpp index 4a2b9c09..6daa23ca 100644 --- a/contrib/bobtoolz/DBrush.cpp +++ b/contrib/bobtoolz/DBrush.cpp @@ -68,9 +68,6 @@ DBrush::~DBrush(){ ////////////////////////////////////////////////////////////////////// DPlane* DBrush::AddFace( const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData* texData ){ -#ifdef _DEBUG -// Sys_Printf("(%f %f %f) (%f %f %f) (%f %f %f)\n", va[0], va[1], va[2], vb[0], vb[1], vb[2], vc[0], vc[1], vc[2]); -#endif bBoundsBuilt = false; DPlane* newFace = new DPlane( va, vb, vc, texData ); faceList.push_back( newFace ); @@ -117,10 +114,6 @@ int DBrush::BuildPoints(){ } } -#ifdef _DEBUG -// Sys_Printf("%i points on brush\n", pointList.size()); -#endif - return static_cast( pointList.size() ); } diff --git a/contrib/bobtoolz/DPatch.cpp b/contrib/bobtoolz/DPatch.cpp index be49df4e..f46164c4 100644 --- a/contrib/bobtoolz/DPatch.cpp +++ b/contrib/bobtoolz/DPatch.cpp @@ -92,47 +92,6 @@ void DPatch::BuildInRadiant( scene::Node* entity ){ QER_entity = entity; QER_brush = patch.get_pointer(); - -#if 0 - int nIndex = g_FuncTable.m_pfnCreatePatchHandle(); - //$ FIXME: m_pfnGetPatchHandle - patchMesh_t* pm = g_FuncTable.m_pfnGetPatchData( nIndex ); - - b->patchBrush = true; - b->pPatch = Patch_Alloc(); - b->pPatch->setDims( width,height ); - - for ( int x = 0; x < width; x++ ) - for ( int y = 0; y < height; y++ ) - CopyDrawVert( &points[x][y], &pm->ctrl[x][y] ); - -/* if(entity) - { - // strcpy(pm->d_texture->name, texture); - - brush_t* brush = (brush_t*)g_FuncTable.m_pfnCreateBrushHandle(); - brush->patchBrush = true; - brush->pPatch = pm; - - pm->pSymbiot = brush; - pm->bSelected = false; - pm->bOverlay = false; // bleh, f*cks up, just have to wait for a proper function - pm->bDirty = true; // or get my own patch out.... - pm->nListID = -1; - - g_FuncTable.m_pfnCommitBrushHandleToEntity(brush, entity); - } - else*/ // patch to entity just plain dont work atm - - if ( entity ) { - g_FuncTable.m_pfnCommitPatchHandleToEntity( nIndex, pm, texture, entity ); - } - else{ - g_FuncTable.m_pfnCommitPatchHandleToMap( nIndex, pm, texture ); - } - - QER_brush = pm->pSymbiot; -#endif } void DPatch::LoadFromPatch( scene::Instance& patch ){ @@ -158,25 +117,6 @@ void DPatch::LoadFromPatch( scene::Instance& patch ){ } SetTexture( GlobalPatchCreator().Patch_getShader( patch.path().top() ) ); -#if 0 - SetTexture( brush->pPatch->GetShader() ); - - width = brush->pPatch->getWidth(); - height = brush->pPatch->getHeight(); - - for ( int x = 0; x < height; x++ ) - { - for ( int y = 0; y < width; y++ ) - { - float *p = brush->pPatch->ctrlAt( ROW,x,y ); - p[0] = points[x][y].xyz[0]; - p[1] = points[x][y].xyz[1]; - p[2] = points[x][y].xyz[2]; - p[3] = points[x][y].st[0]; - p[4] = points[x][y].st[1]; - } - } -#endif } bool DPatch::ResetTextures( const char *oldTextureName, const char *newTextureName ){ diff --git a/contrib/bobtoolz/dialogs/AboutDialog.cpp b/contrib/bobtoolz/dialogs/AboutDialog.cpp index 6ba6df14..0f5ef44f 100644 --- a/contrib/bobtoolz/dialogs/AboutDialog.cpp +++ b/contrib/bobtoolz/dialogs/AboutDialog.cpp @@ -23,12 +23,6 @@ #include "../StdAfx.h" #include "AboutDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -//static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CAboutDialog dialog diff --git a/contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp b/contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp index bcbb4957..a04c604c 100644 --- a/contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp +++ b/contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp @@ -24,12 +24,6 @@ #include "../bobtoolz.h" #include "AutoCaulkDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CAutoCaulkDialog dialog diff --git a/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.cpp b/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.cpp index f59dfd33..f112f02b 100644 --- a/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.cpp +++ b/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.cpp @@ -24,12 +24,6 @@ #include "../bobtoolz.h" #include "AutoCaulkStartDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CAutoCaulkStartDialog dialog diff --git a/contrib/bobtoolz/dialogs/DoorDialog.cpp b/contrib/bobtoolz/dialogs/DoorDialog.cpp index ce0d6213..50e7ef76 100644 --- a/contrib/bobtoolz/dialogs/DoorDialog.cpp +++ b/contrib/bobtoolz/dialogs/DoorDialog.cpp @@ -23,12 +23,6 @@ #include "../StdAfx.h" #include "DoorDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CDoorDialog dialog diff --git a/contrib/bobtoolz/dialogs/IntersectDialog.cpp b/contrib/bobtoolz/dialogs/IntersectDialog.cpp index 4bcc8373..8b2a0c72 100644 --- a/contrib/bobtoolz/dialogs/IntersectDialog.cpp +++ b/contrib/bobtoolz/dialogs/IntersectDialog.cpp @@ -23,12 +23,6 @@ #include "../StdAfx.h" #include "IntersectDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CIntersectDialog dialog diff --git a/contrib/bobtoolz/dialogs/IntersectInfoDialog.cpp b/contrib/bobtoolz/dialogs/IntersectInfoDialog.cpp index c74a635e..6d61f6ce 100644 --- a/contrib/bobtoolz/dialogs/IntersectInfoDialog.cpp +++ b/contrib/bobtoolz/dialogs/IntersectInfoDialog.cpp @@ -24,12 +24,6 @@ #include "../bobtoolz.h" #include "IntersectInfoDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CIntersectInfoDialog dialog diff --git a/contrib/bobtoolz/dialogs/PolygonDialog.cpp b/contrib/bobtoolz/dialogs/PolygonDialog.cpp index 652d9cb0..ec7ee2cd 100644 --- a/contrib/bobtoolz/dialogs/PolygonDialog.cpp +++ b/contrib/bobtoolz/dialogs/PolygonDialog.cpp @@ -24,12 +24,6 @@ #include "PolygonDialog.h" #include "../shapes.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CPolygonDialog dialog diff --git a/contrib/bobtoolz/dialogs/StairDialog.cpp b/contrib/bobtoolz/dialogs/StairDialog.cpp index 8b94092f..e0cd2f14 100644 --- a/contrib/bobtoolz/dialogs/StairDialog.cpp +++ b/contrib/bobtoolz/dialogs/StairDialog.cpp @@ -23,12 +23,6 @@ #include "../StdAfx.h" #include "StairDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CStairDialog dialog diff --git a/contrib/bobtoolz/dialogs/TextureResetDialog.cpp b/contrib/bobtoolz/dialogs/TextureResetDialog.cpp index 0913f51b..4b9991a0 100644 --- a/contrib/bobtoolz/dialogs/TextureResetDialog.cpp +++ b/contrib/bobtoolz/dialogs/TextureResetDialog.cpp @@ -24,12 +24,6 @@ #include "../bobtoolz.h" #include "TextureResetDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CTextureResetDialog dialog diff --git a/contrib/bobtoolz/dialogs/brushcheckdialog.cpp b/contrib/bobtoolz/dialogs/brushcheckdialog.cpp index 3b3ac607..0b36f21f 100644 --- a/contrib/bobtoolz/dialogs/brushcheckdialog.cpp +++ b/contrib/bobtoolz/dialogs/brushcheckdialog.cpp @@ -24,12 +24,6 @@ #include "../bobtoolz.h" #include "BrushCheckDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CBrushCheckDialog dialog diff --git a/contrib/bobtoolz/dialogs/pathplotterdialog.cpp b/contrib/bobtoolz/dialogs/pathplotterdialog.cpp index ea64f26e..1928352b 100644 --- a/contrib/bobtoolz/dialogs/pathplotterdialog.cpp +++ b/contrib/bobtoolz/dialogs/pathplotterdialog.cpp @@ -24,11 +24,6 @@ #include "../bobtoolz.h" #include "PathPlotterDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif ///////////////////////////////////////////////////////////////////////////// // CPathPlotterDialog dialog diff --git a/contrib/gtkgensurf/face.cpp b/contrib/gtkgensurf/face.cpp index 77ce7dec..2bc90fe5 100644 --- a/contrib/gtkgensurf/face.cpp +++ b/contrib/gtkgensurf/face.cpp @@ -334,129 +334,4 @@ void UseFaceBounds(){ SurfNormal[2] = 1.0; } -#if 0 - i = g_FuncTable.m_pfnAllocateSelectedBrushHandles(); - vp = g_FuncTable.m_pfnGetSelectedBrushHandle( 0 ); - NumFaces = g_FuncTable.m_pfnGetFaceCount( vp ); - - BestFace = -1; - BestDot = 0.0; - - for ( i = 0; i < NumFaces; i++ ) - { - _QERFaceData* QERFaceData = g_FuncTable.m_pfnGetFaceData( vp,i ); - planepts[0][0] = QERFaceData->m_v1[0]; - planepts[0][1] = QERFaceData->m_v1[1]; - planepts[0][2] = QERFaceData->m_v1[2]; - planepts[1][0] = QERFaceData->m_v2[0]; - planepts[1][1] = QERFaceData->m_v2[1]; - planepts[1][2] = QERFaceData->m_v2[2]; - planepts[2][0] = QERFaceData->m_v3[0]; - planepts[2][1] = QERFaceData->m_v3[1]; - planepts[2][2] = QERFaceData->m_v3[2]; - - PlaneFromPoints( planepts[0], planepts[1], planepts[2], &plane[2 * i] ); - VectorSubtract( vec3_origin, plane[2 * i].normal, plane[2 * i + 1].normal ); - plane[2 * i + 1].dist = -plane[2 * i].dist; - - Dot = DotProduct( plane[2 * i].normal,SurfNormal ); - if ( Dot > BestDot ) { - BestDot = Dot; - BestFace = i; - if ( strlen( QERFaceData->m_TextureName ) ) { - strcpy( Texture[Game][0],QERFaceData->m_TextureName ); - } - } - } - for ( i = 0; i < NumFaces; i++ ) - { - if ( i == BestFace ) { - continue; - } - _QERFaceData* QERFaceData = g_FuncTable.m_pfnGetFaceData( vp,i ); - if ( strlen( QERFaceData->m_TextureName ) ) { - if ( strcmp( Texture[Game][0],QERFaceData->m_TextureName ) ) { - strcpy( Texture[Game][1],QERFaceData->m_TextureName ); - } - } - } - - - g_FuncTable.m_pfnReleaseSelectedBrushHandles(); - - w = BaseWindingForPlane( plane[BestFace * 2].normal, plane[BestFace * 2].dist ); - - for ( i = 0 ; i < NumFaces && w; i++ ) - { - if ( BestFace == i ) { - continue; - } - ChopWindingInPlace( &w, plane[i * 2 + 1].normal, plane[i * 2 + 1].dist, 0 ); - } - if ( !w ) { - return; - } - - // Get bounding box for this face - vmin[0] = vmax[0] = w->p[0][0]; - vmin[1] = vmax[1] = w->p[0][1]; - vmin[2] = vmax[2] = w->p[0][2]; - for ( j = 1; j < w->numpoints; j++ ) - { - vmin[0] = min( vmin[0],w->p[j][0] ); - vmin[1] = min( vmin[1],w->p[j][1] ); - vmin[2] = min( vmin[2],w->p[j][2] ); - vmax[0] = max( vmax[0],w->p[j][0] ); - vmax[1] = max( vmax[1],w->p[j][1] ); - vmax[2] = max( vmax[2],w->p[j][2] ); - } - - FreeWinding( w ); - - VectorCopy( plane[BestFace * 2].normal,pface.normal ); - pface.dist = plane[BestFace * 2].dist; - switch ( Plane ) - { - case PLANE_XZ0: - case PLANE_XZ1: - if ( pface.normal[1] == 0. ) { - return; - } - Hll = vmin[0]; - Hur = vmax[0]; - Vll = vmin[2]; - Vur = vmax[2]; - Z00 = ( pface.dist - pface.normal[0] * Hll - pface.normal[2] * Vll ) / pface.normal[1]; - Z01 = ( pface.dist - pface.normal[0] * Hll - pface.normal[2] * Vur ) / pface.normal[1]; - Z10 = ( pface.dist - pface.normal[0] * Hur - pface.normal[2] * Vll ) / pface.normal[1]; - Z11 = ( pface.dist - pface.normal[0] * Hur - pface.normal[2] * Vur ) / pface.normal[1]; - break; - case PLANE_YZ0: - case PLANE_YZ1: - if ( pface.normal[0] == 0. ) { - return; - } - Hll = vmin[1]; - Hur = vmax[1]; - Vll = vmin[2]; - Vur = vmax[2]; - Z00 = ( pface.dist - pface.normal[1] * Hll - pface.normal[2] * Vll ) / pface.normal[0]; - Z01 = ( pface.dist - pface.normal[1] * Hll - pface.normal[2] * Vur ) / pface.normal[0]; - Z10 = ( pface.dist - pface.normal[1] * Hur - pface.normal[2] * Vll ) / pface.normal[0]; - Z11 = ( pface.dist - pface.normal[1] * Hur - pface.normal[2] * Vur ) / pface.normal[0]; - break; - default: - if ( pface.normal[2] == 0. ) { - return; - } - Hll = vmin[0]; - Hur = vmax[0]; - Vll = vmin[1]; - Vur = vmax[1]; - Z00 = ( pface.dist - pface.normal[0] * Hll - pface.normal[1] * Vll ) / pface.normal[2]; - Z01 = ( pface.dist - pface.normal[0] * Hll - pface.normal[1] * Vur ) / pface.normal[2]; - Z10 = ( pface.dist - pface.normal[0] * Hur - pface.normal[1] * Vll ) / pface.normal[2]; - Z11 = ( pface.dist - pface.normal[0] * Hur - pface.normal[1] * Vur ) / pface.normal[2]; - } -#endif } diff --git a/contrib/gtkgensurf/gendlgs.cpp b/contrib/gtkgensurf/gendlgs.cpp index bfaf9849..3100ef4a 100644 --- a/contrib/gtkgensurf/gendlgs.cpp +++ b/contrib/gtkgensurf/gendlgs.cpp @@ -542,99 +542,6 @@ static void ReadDlgValues( int tab ){ } } break; - -#if 0 - case BITMAP_TAB: - - if ( WaveType == WAVE_BITMAP ) { - GetDlgItemText( hwnd,DLG_BMP_FILE,gbmp.name,sizeof( gbmp.name ) ); - CheckValidDIB( hwnd ); - GetDlgItemText( hwnd,DLG_BMP_BLACK,Text,sizeof( Text ) ); - gbmp.black_value = atof( Text ); - GetDlgItemText( hwnd,DLG_BMP_WHITE,Text,sizeof( Text ) ); - gbmp.white_value = atof( Text ); - UpdatePreview( TRUE ); - } - break; - - case FIXPOINTS_TAB: - GetDlgItemText( hwnd,DLG_FIX_VALUE,Text,sizeof( Text ) ); - temp.fixed_value = atoi( Text ); - GetDlgItemText( hwnd,DLG_FIX_RANGE,Text,sizeof( Text ) ); - temp.range = atoi( Text ); - GetDlgItemText( hwnd,DLG_FIX_RATE, Text,sizeof( Text ) ); - temp.rate = atof( Text ); - for ( k = 0; k < NumVerticesSelected; k++ ) - { - xyz[Vertex[k].i][Vertex[k].j].fixed_value = temp.fixed_value; - xyz[Vertex[k].i][Vertex[k].j].range = temp.range; - xyz[Vertex[k].i][Vertex[k].j].rate = temp.rate; - } - if ( !OldPreview ) { - Preview = 0; - CheckDlgButton( ghwnd,DLG_PREVIEW,0 ); - SendMessage( ghwnd,WM_COMMAND,DLG_PREVIEW,0 ); - } - VertexMode = 0; - UpdatePreview( TRUE ); - break; - - case TEXTURE_TAB: - if ( UsePak[Game] ) { - i = SendDlgItemMessage( hwndDisplay, DLG_TEX_LIST1, CB_GETCURSEL, 0, 0 ); - if ( i == CB_ERR ) { - Texture[Game][0][0] = '\0'; - } - else{ - SendDlgItemMessage( hwndDisplay, DLG_TEX_LIST1, CB_GETLBTEXT, i, - (LPARAM)(LPCSTR)Texture[Game][0] ); - } - - i = SendDlgItemMessage( hwndDisplay, DLG_TEX_LIST2, CB_GETCURSEL, 0, 0 ); - if ( i == CB_ERR ) { - Texture[Game][1][0] = '\0'; - } - else{ - SendDlgItemMessage( hwndDisplay, DLG_TEX_LIST2, CB_GETLBTEXT, i, - (LPARAM)(LPCSTR)Texture[Game][1] ); - } - - i = SendDlgItemMessage( hwndDisplay, DLG_TEX_LIST3, CB_GETCURSEL, 0, 0 ); - if ( i == CB_ERR ) { - Texture[Game][2][0] = '\0'; - } - else{ - SendDlgItemMessage( hwndDisplay, DLG_TEX_LIST3, CB_GETLBTEXT, i, - (LPARAM)(LPCSTR)Texture[Game][2] ); - } - } - else - { - GetDlgItemText( hwndDisplay,DLG_TEXTURE, Texture[Game][0],sizeof( Texture[Game][0] ) ); - GetDlgItemText( hwndDisplay,DLG_TEXTURE2,Texture[Game][1],sizeof( Texture[Game][1] ) ); - GetDlgItemText( hwndDisplay,DLG_TEXTURE3,Texture[Game][2],sizeof( Texture[Game][2] ) ); - } - GetDlgItemText( hwndDisplay,DLG_TEX_SLANT,Text,sizeof( Text ) ); - SlantAngle = atoi( Text ); - SlantAngle = max( 0,min( SlantAngle,90 ) ); - GetDlgItemText( hwndDisplay,DLG_TEXOFFSETX,Text,sizeof( Text ) ); - TexOffset[0] = atof( Text ); - GetDlgItemText( hwndDisplay,DLG_TEXOFFSETY,Text,sizeof( Text ) ); - TexOffset[1] = atof( Text ); - GetDlgItemText( hwndDisplay,DLG_TEXSCALEX,Text,sizeof( Text ) ); - TexScale[0] = atof( Text ); - if ( TexScale[0] == 0. ) { - TexScale[0] = 1.0; - } - GetDlgItemText( hwndDisplay,DLG_TEXSCALEY,Text,sizeof( Text ) ); - TexScale[1] = atof( Text ); - if ( TexScale[1] == 0. ) { - TexScale[1] = 1.0; - } - GetDlgItemText( hwndDisplay,DLG_ARGHRAD2,Text,sizeof( Text ) ); - ArghRad2 = atoi( Text ); - break; -#endif } } @@ -2198,122 +2105,3 @@ GtkWidget* create_main_dialog(){ } -#if 0 - -HWND hwndDisplay = (HWND)NULL; -HWND ghwndTab = (HWND)NULL; -int iTab = 0; -Rect rcTab; -FILE *ftex; - -char GenSurfURL[40] = {"http://tarot.telefragged.com/gensurf"}; -char GenSurfBoard[40] = {"http://tarot.telefragged.com/board"}; - -/* - * AboutDlgProc - processes messages for the about dialog. - */ - -qboolean CALLBACK AboutDlgProc( HWND hwnd, unsigned msg, UINT wparam, LONG lparam ){ - char szText[256]; - DRAWITEMSTRUCT *dis; - HDC hdc; - HPEN hpen; - HWND hwndURL; - Rect rc; - SIZE size; - - lparam = lparam; /* turn off warning */ - - switch ( msg ) { - case WM_INITDIALOG: - strcpy( szText,"About " ); - strcat( szText,gszCaption ); - SetWindowText( hwnd,gszCaption ); - SetDlgItemText( hwnd,DLG_ABOUT_APP,szText ); - /* Application icon: */ - SendDlgItemMessage( hwnd, DLG_ABOUT_ICON, - STM_SETICON, (WPARAM)(HICON)LoadIcon( ghInst,"GENSURF" ), - (LPARAM) NULL ); - - hwndURL = GetDlgItem( hwnd,DLG_ABOUT_URL ); - hdc = GetDC( hwndURL ); - GetTextExtentPoint( hdc,GenSurfURL,strlen( GenSurfURL ),&size ); - ReleaseDC( hwndURL,hdc ); - GetWindowRect( hwndURL,&rc ); - SetWindowPos( hwndURL,(HWND)NULL,0,0,size.cx,size.cy + 2, - SWP_NOMOVE | SWP_NOZORDER ); - - hwndURL = GetDlgItem( hwnd,DLG_ABOUT_BOARD ); - hdc = GetDC( hwndURL ); - GetTextExtentPoint( hdc,GenSurfBoard,strlen( GenSurfBoard ),&size ); - ReleaseDC( hwndURL,hdc ); - GetWindowRect( hwndURL,&rc ); - SetWindowPos( hwndURL,(HWND)NULL,0,0,size.cx,size.cy + 2, - SWP_NOMOVE | SWP_NOZORDER ); - - return TRUE; - - case WM_COMMAND: - switch ( LOWORD( wparam ) ) - { - case DLG_ABOUT_URL: - HTTP( GenSurfURL ); - break; - case DLG_ABOUT_BOARD: - HTTP( GenSurfBoard ); - break; - case IDOK: - EndDialog( hwnd,1 ); - return TRUE; - } - break; - - case WM_DRAWITEM: - if ( wparam == DLG_ABOUT_URL ) { - dis = (LPDRAWITEMSTRUCT)lparam; - SetTextColor( dis->hDC,RGB( 0,0,255 ) ); - TextOut( dis->hDC,0,0,GenSurfURL,strlen( GenSurfURL ) ); - GetWindowRect( dis->hwndItem,&rc ); - GetTextExtentPoint( dis->hDC,GenSurfURL,strlen( GenSurfURL ),&size ); - hpen = CreatePen( PS_SOLID,0,RGB( 0,0,255 ) ); - SelectObject( dis->hDC,hpen ); - MoveToEx( dis->hDC,0,size.cy,NULL ); - LineTo( dis->hDC,size.cx,size.cy ); - SelectObject( dis->hDC,GetStockObject( BLACK_PEN ) ); - DeleteObject( hpen ); - } - else if ( wparam == DLG_ABOUT_BOARD ) { - dis = (LPDRAWITEMSTRUCT)lparam; - SetTextColor( dis->hDC,RGB( 0,0,255 ) ); - TextOut( dis->hDC,0,0,GenSurfBoard,strlen( GenSurfBoard ) ); - GetWindowRect( dis->hwndItem,&rc ); - GetTextExtentPoint( dis->hDC,GenSurfBoard,strlen( GenSurfBoard ),&size ); - hpen = CreatePen( PS_SOLID,0,RGB( 0,0,255 ) ); - SelectObject( dis->hDC,hpen ); - MoveToEx( dis->hDC,0,size.cy,NULL ); - LineTo( dis->hDC,size.cx,size.cy ); - SelectObject( dis->hDC,GetStockObject( BLACK_PEN ) ); - DeleteObject( hpen ); - } - break; - - case WM_CLOSE: - EndDialog( hwnd,1 ); - return TRUE; - - default: - return FALSE; - } - return FALSE; - -} /* AboutDlgProc */ - -void About(){ - if ( DialogBox( ghInst,"About", ghwnd_main, (DLGPROC)AboutDlgProc ) < 0 ) { - char Text[256]; - sprintf( Text,"In About(), GetLastError()=0x%08x",GetLastError() ); - MessageBox( ghwnd_main,Text,"GenSurf",eMB_ICONWARNING ); - } -} - -#endif diff --git a/contrib/gtkgensurf/genmap.cpp b/contrib/gtkgensurf/genmap.cpp index a31bfbcb..377544cb 100644 --- a/contrib/gtkgensurf/genmap.cpp +++ b/contrib/gtkgensurf/genmap.cpp @@ -249,31 +249,6 @@ int MapPatches(){ } scene::Node* patch = MakePatch(); -#if 0 - b->pPatch->setDims( NH_patch, NV_patch ); - for ( i = 0; i < NH_patch; i++ ) - { - switch ( Plane ) - { - case PLANE_XY1: - case PLANE_XZ0: - case PLANE_YZ1: - ii = i0 + NH_patch - 1 - i; - break; - default: - ii = i0 + i; - } - for ( j = 0; j < NV_patch; j++ ) - { - b->pPatch->ctrlAt( COL,i,j )[0] = (float)xyz[ii][j0 + j].pp[0]; - b->pPatch->ctrlAt( COL,i,j )[1] = (float)xyz[ii][j0 + j].pp[1]; - b->pPatch->ctrlAt( COL,i,j )[2] = (float)xyz[ii][j0 + j].pp[2]; - b->pPatch->ctrlAt( COL,i,j )[3] = (float)i; - b->pPatch->ctrlAt( COL,i,j )[4] = (float)j; - } - } - b->pPatch->UpdateCachedData(); -#endif BrushNum++; j0 += NV_patch - 1; } @@ -1082,15 +1057,7 @@ void GenerateMap(){ if ( !ValidSurface() ) { return; } - /* - ghCursorCurrent = LoadCursor(NULL,IDC_WAIT); - SetCursor(ghCursorCurrent); - */ -#if 0 - if ( SingleBrushSelected ) { - g_FuncTable.m_pfnDeleteSelection(); - } -#endif + GenerateXYZ(); ntri = NH * NV * 2; @@ -1101,10 +1068,6 @@ void GenerateMap(){ if ( Decimate > 0 && ( Game != QUAKE3 || UsePatches == 0 ) ) { MapOut( gNumNodes,gNumTris,gNode,gTri ); - /* - ghCursorCurrent = ghCursorDefault; - SetCursor(ghCursorCurrent); - */ return; } @@ -2024,9 +1987,6 @@ void XYZtoV( XYZ *xyz, vec3 *v ){ //============================================================= scene::Node* MakePatch( void ){ scene::Node* patch = Patch_AllocNode(); -#if 0 - patch->m_patch->SetShader( Texture[Game][0] ); -#endif Node_getTraversable( h_worldspawn )->insert( patch ); return patch; } @@ -2034,41 +1994,6 @@ scene::Node* MakePatch( void ){ //============================================================= void MakeBrush( BRUSH *brush ){ NodePtr node( Brush_AllocNode() ); - -#if 0 - for ( int i = 0; i < brush->NumFaces; i++ ) - { - _QERFaceData QERFaceData; - if ( !strncmp( brush->face[i].texture, "textures/", 9 ) ) { - strcpy( QERFaceData.m_TextureName,brush->face[i].texture ); - } - else - { - strcpy( QERFaceData.m_TextureName,"textures/" ); - strcpy( QERFaceData.m_TextureName + 9,brush->face[i].texture ); - } - QERFaceData.m_nContents = brush->face[i].Contents; - QERFaceData.m_nFlags = brush->face[i].Surface; - QERFaceData.m_nValue = brush->face[i].Value; - QERFaceData.m_fShift[0] = brush->face[i].Shift[0]; - QERFaceData.m_fShift[1] = brush->face[i].Shift[1]; - QERFaceData.m_fRotate = brush->face[i].Rotate; - QERFaceData.m_fScale[0] = brush->face[i].Scale[0]; - QERFaceData.m_fScale[1] = brush->face[i].Scale[1]; - QERFaceData.m_v1[0] = brush->face[i].v[0][0]; - QERFaceData.m_v1[1] = brush->face[i].v[0][1]; - QERFaceData.m_v1[2] = brush->face[i].v[0][2]; - QERFaceData.m_v2[0] = brush->face[i].v[1][0]; - QERFaceData.m_v2[1] = brush->face[i].v[1][1]; - QERFaceData.m_v2[2] = brush->face[i].v[1][2]; - QERFaceData.m_v3[0] = brush->face[i].v[2][0]; - QERFaceData.m_v3[1] = brush->face[i].v[2][1]; - QERFaceData.m_v3[2] = brush->face[i].v[2][2]; - QERFaceData.m_bBPrimit = false; - ( g_FuncTable.m_pfnAddFaceData )( vp,&QERFaceData ); - } -#endif - Node_getTraversable( h_func_group )->insert( node ); } //============================================================= diff --git a/contrib/ufoaiplug/ufoai_filters.cpp b/contrib/ufoaiplug/ufoai_filters.cpp index 84a96652..54322369 100644 --- a/contrib/ufoaiplug/ufoai_filters.cpp +++ b/contrib/ufoaiplug/ufoai_filters.cpp @@ -100,22 +100,21 @@ ForEachFace( Brush& brush ) } void visit( Face& face ) const { -#if _DEBUG if ( m_surfaceFlagsVis < 0 ) { m_surfaceFlagsVis = face.getShader().m_flags.m_surfaceFlags; } +#if _DEBUG else if ( m_surfaceFlagsVis >= 0 && m_surfaceFlagsVis != face.getShader().m_flags.m_surfaceFlags ) { globalOutputStream() << "Faces with different surfaceflags at brush\n"; } +#endif if ( m_contentFlagsVis < 0 ) { m_contentFlagsVis = face.getShader().m_flags.m_contentFlags; } +#if _DEBUG else if ( m_contentFlagsVis >= 0 && m_contentFlagsVis != face.getShader().m_flags.m_contentFlags ) { globalOutputStream() << "Faces with different contentflags at brush\n"; } -#else - m_surfaceFlagsVis = face.getShader().m_flags.m_surfaceFlags; - m_contentFlagsVis = face.getShader().m_flags.m_contentFlags; #endif } }; diff --git a/include/ibrush.h b/include/ibrush.h index 1171f8a7..78cef4ba 100644 --- a/include/ibrush.h +++ b/include/ibrush.h @@ -32,54 +32,6 @@ namespace scene class Node; } -#if 0 -class IBrushFace -{ -public: -virtual const char* GetShader() const = 0; -virtual void SetShader( const char* name ) = 0; -virtual const TextureProjection& GetTexdef() const = 0; -virtual void GetTexdef( TextureProjection& projection ) const = 0; -virtual void SetTexdef( const TextureProjection& projection ) = 0; -virtual void GetFlags( ContentsFlagsValue& flags ) const = 0; -virtual void SetFlags( const ContentsFlagsValue& flags ) = 0; -virtual void ShiftTexdef( float s, float t ) = 0; -virtual void ScaleTexdef( float s, float t ) = 0; -virtual void RotateTexdef( float angle ) = 0; -virtual void FitTexture( float s_repeat, float t_repeat ) = 0; -virtual bool isDetail() const = 0; -virtual void setDetail( bool detail ) = 0; -}; - -class IBrush -{ -public: -STRING_CONSTANT( Name, "IBrush" ); -virtual void reserve( std::size_t count ) = 0; -virtual void clear() = 0; -virtual void copy( const IBrush& other ) = 0; -virtual IBrushFace* addPlane( const Vector3& p0, const Vector3& p1, const Vector3& p2, const char* shader, const TextureProjection& projection ) = 0; -virtual const AABB& localAABB() const = 0; -virtual void removeEmptyFaces() = 0; -}; - -class IBrushFaceInstance -{ -public: -virtual IBrushFace& getFace() = 0; -virtual const IBrushFace& getFace() const = 0; -virtual bool isSelected() const = 0; -virtual void setSelected( SelectionSystem::EComponentMode mode, bool select ) const = 0; -}; - -class IBrushInstance -{ -public: -STRING_CONSTANT( Name, "IBrushInstance" ); -virtual void forEachFaceInstance( const BrushInstanceVisitor& visitor ) = 0; -}; -#endif - class _QERFaceData { public: diff --git a/include/igl.h b/include/igl.h index eca09ae7..6575a573 100644 --- a/include/igl.h +++ b/include/igl.h @@ -1758,56 +1758,9 @@ typedef unsigned int GLhandleARB; #define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 #define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#if 0 -#define glVertexAttrib1fARB GlobalOpenGL().m_glVertexAttrib1fARB -#define glVertexAttrib1sARB GlobalOpenGL().m_glVertexAttrib1sARB -#define glVertexAttrib1dARB GlobalOpenGL().m_glVertexAttrib1dARB -#define glVertexAttrib2fARB GlobalOpenGL().m_glVertexAttrib2fARB -#define glVertexAttrib2sARB GlobalOpenGL().m_glVertexAttrib2sARB -#define glVertexAttrib2dARB GlobalOpenGL().m_glVertexAttrib2dARB -#define glVertexAttrib3fARB GlobalOpenGL().m_glVertexAttrib3fARB -#define glVertexAttrib3sARB GlobalOpenGL().m_glVertexAttrib3sARB -#define glVertexAttrib3dARB GlobalOpenGL().m_glVertexAttrib3dARB -#define glVertexAttrib4fARB GlobalOpenGL().m_glVertexAttrib4fARB -#define glVertexAttrib4sARB GlobalOpenGL().m_glVertexAttrib4sARB -#define glVertexAttrib4dARB GlobalOpenGL().m_glVertexAttrib4dARB -#define glVertexAttrib4NubARB GlobalOpenGL().m_glVertexAttrib4NubARB -#define glVertexAttrib1fvARB GlobalOpenGL().m_glVertexAttrib1fvARB -#define glVertexAttrib1svARB GlobalOpenGL().m_glVertexAttrib1svARB -#define glVertexAttrib1dvARB GlobalOpenGL().m_glVertexAttrib1dvARB -#define glVertexAttrib2fvARB GlobalOpenGL().m_glVertexAttrib2fvARB -#define glVertexAttrib2svARB GlobalOpenGL().m_glVertexAttrib2svARB -#define glVertexAttrib2dvARB GlobalOpenGL().m_glVertexAttrib2dvARB -#define glVertexAttrib3fvARB GlobalOpenGL().m_glVertexAttrib3fvARB -#define glVertexAttrib3svARB GlobalOpenGL().m_glVertexAttrib3svARB -#define glVertexAttrib3dvARB GlobalOpenGL().m_glVertexAttrib3dvARB -#define glVertexAttrib4fvARB GlobalOpenGL().m_glVertexAttrib4fvARB -#define glVertexAttrib4svARB GlobalOpenGL().m_glVertexAttrib4svARB -#define glVertexAttrib4dvARB GlobalOpenGL().m_glVertexAttrib4dvARB -#define glVertexAttrib4ivARB GlobalOpenGL().m_glVertexAttrib4ivARB -#define glVertexAttrib4bvARB GlobalOpenGL().m_glVertexAttrib4bvARB -#define glVertexAttrib4ubvARB GlobalOpenGL().m_glVertexAttrib4ubvARB -#define glVertexAttrib4usvARB GlobalOpenGL().m_glVertexAttrib4usvARB -#define glVertexAttrib4uivARB GlobalOpenGL().m_glVertexAttrib4uivARB -#define glVertexAttrib4NbvARB GlobalOpenGL().m_glVertexAttrib4NbvARB -#define glVertexAttrib4NsvARB GlobalOpenGL().m_glVertexAttrib4NsvARB -#define glVertexAttrib4NivARB GlobalOpenGL().m_glVertexAttrib4NivARB -#define glVertexAttrib4NubvARB GlobalOpenGL().m_glVertexAttrib4NubvARB -#define glVertexAttrib4NusvARB GlobalOpenGL().m_glVertexAttrib4NusvARB -#define glVertexAttrib4NuivARB GlobalOpenGL().m_glVertexAttrib4NuivARB -#define glVertexAttribPointerARB GlobalOpenGL().m_glVertexAttribPointerARB -#define glEnableVertexAttribArrayARB GlobalOpenGL().m_glEnableVertexAttribArrayARB -#define glDisableVertexAttribArrayARB GlobalOpenGL().m_glDisableVertexAttribArrayARB -#endif #define glBindAttribLocationARB GlobalOpenGL().m_glBindAttribLocationARB #define glGetActiveAttribARB GlobalOpenGL().m_glGetActiveAttribARB #define glGetAttribLocationARB GlobalOpenGL().m_glGetAttribLocationARB -#if 0 -#define glGetVertexAttribdvARB GlobalOpenGL().m_glGetVertexAttribdvARB -#define glGetVertexAttribfvARB GlobalOpenGL().m_glGetVertexAttribfvARB -#define glGetVertexAttribivARB GlobalOpenGL().m_glGetVertexAttribivARB -#define glGetVertexAttribPointervARB GlobalOpenGL().m_glGetVertexAttribPointervARB -#endif #endif @@ -2678,56 +2631,10 @@ struct OpenGLBinding bool ARB_vertex_shader(){ return support_ARB_vertex_shader; } -#if 0 - void ( QGL_DLLEXPORT *m_glVertexAttrib1fARB )( GLuint index, GLfloat v0 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib1sARB )( GLuint index, GLshort v0 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib1dARB )( GLuint index, GLdouble v0 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib2fARB )( GLuint index, GLfloat v0, GLfloat v1 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib2sARB )( GLuint index, GLshort v0, GLshort v1 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib2dARB )( GLuint index, GLdouble v0, GLdouble v1 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib3fARB )( GLuint index, GLfloat v0, GLfloat v1, GLfloat v2 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib3sARB )( GLuint index, GLshort v0, GLshort v1, GLshort v2 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib3dARB )( GLuint index, GLdouble v0, GLdouble v1, GLdouble v2 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4fARB )( GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4sARB )( GLuint index, GLshort v0, GLshort v1, GLshort v2, GLshort v3 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4dARB )( GLuint index, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3 ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4NubARB )( GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w ); - void ( QGL_DLLEXPORT *m_glVertexAttrib1fvARB )( GLuint index, const GLfloat *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib1svARB )( GLuint index, const GLshort *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib1dvARB )( GLuint index, const GLdouble *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib2fvARB )( GLuint index, const GLfloat *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib2svARB )( GLuint index, const GLshort *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib2dvARB )( GLuint index, const GLdouble *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib3fvARB )( GLuint index, const GLfloat *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib3svARB )( GLuint index, const GLshort *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib3dvARB )( GLuint index, const GLdouble *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4fvARB )( GLuint index, const GLfloat *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4svARB )( GLuint index, const GLshort *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4dvARB )( GLuint index, const GLdouble *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4ivARB )( GLuint index, const GLint *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4bvARB )( GLuint index, const GLbyte *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4ubvARB )( GLuint index, const GLubyte *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4usvARB )( GLuint index, const GLushort *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4uivARB )( GLuint index, const GLuint *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4NbvARB )( GLuint index, const GLbyte *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4NsvARB )( GLuint index, const GLshort *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4NivARB )( GLuint index, const GLint *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4NubvARB )( GLuint index, const GLubyte *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4NusvARB )( GLuint index, const GLushort *v ); - void ( QGL_DLLEXPORT *m_glVertexAttrib4NuivARB )( GLuint index, const GLuint *v ); - void ( QGL_DLLEXPORT *m_glVertexAttribPointerARB )( GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer ); - void ( QGL_DLLEXPORT *m_glEnableVertexAttribArrayARB )( GLuint index ); - void ( QGL_DLLEXPORT *m_glDisableVertexAttribArrayARB )( GLuint index ); -#endif void ( QGL_DLLEXPORT *m_glBindAttribLocationARB )( GLhandleARB programObj, GLuint index, const GLcharARB *name ); void ( QGL_DLLEXPORT *m_glGetActiveAttribARB )( GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name ); GLint ( QGL_DLLEXPORT *m_glGetAttribLocationARB )( GLhandleARB programObj, const GLcharARB *name ); -#if 0 - void ( QGL_DLLEXPORT *m_glGetVertexAttribdvARB )( GLuint index, GLenum pname, GLdouble *params ); - void ( QGL_DLLEXPORT *m_glGetVertexAttribfvARB )( GLuint index, GLenum pname, GLfloat *params ); - void ( QGL_DLLEXPORT *m_glGetVertexAttribivARB )( GLuint index, GLenum pname, GLint *params ); - void ( QGL_DLLEXPORT *m_glGetVertexAttribPointervARB )( GLuint index, GLenum pname, GLvoid **pointer ); -#endif + // ARB_fragment_shader bool support_ARB_fragment_shader; diff --git a/include/ipatch.h b/include/ipatch.h index 81cba69a..998ea3a9 100644 --- a/include/ipatch.h +++ b/include/ipatch.h @@ -62,15 +62,11 @@ const_iterator end() const { } value_type& operator[]( std::size_t index ){ -#if defined( _DEBUG ) ASSERT_MESSAGE( index < size(), "array index out of bounds" ); -#endif return m_data[index]; } const value_type& operator[]( std::size_t index ) const { -#if defined( _DEBUG ) ASSERT_MESSAGE( index < size(), "array index out of bounds" ); -#endif return m_data[index]; } value_type* data(){ @@ -87,55 +83,6 @@ bool empty() const { } }; -#if 0 -template -class MatrixIterator -{ -Element* m_position; - -void increment(){ - ++m_position; -} - -public: -typedef std::bidirectional_iterator_tag iterator_category; -typedef std::ptrdiff_t difference_type; -typedef difference_type distance_type; -typedef KeyValue value_type; -typedef value_type* pointer; -typedef value_type& reference; - -MatrixIterator( Element* position ) : m_position( position ){ -} - -Element* position(){ - return m_position; -} - -bool operator==( const MatrixIterator& other ) const { - return m_position == other.m_position; -} -bool operator!=( const MatrixIterator& other ) const { - return !operator==( other ); -} -MatrixIterator& operator++(){ - increment(); - return *this; -} -MatrixIterator operator++( int ){ - MatrixIterator tmp = *this; - increment(); - return tmp; -} -value_type& operator*() const { - return m_position->m_value; -} -value_type* operator->() const { - return &( operator*() ); -} -}; -#endif - template class Matrix { @@ -167,27 +114,19 @@ const_iterator end() const { } value_type& operator[]( std::size_t index ){ -#if defined( _DEBUG ) ASSERT_MESSAGE( index < size(), "array index out of bounds" ); -#endif return m_data[index]; } const value_type& operator[]( std::size_t index ) const { -#if defined( _DEBUG ) ASSERT_MESSAGE( index < size(), "array index out of bounds" ); -#endif return m_data[index]; } value_type& operator()( std::size_t x, std::size_t y ){ -#if defined( _DEBUG ) ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" ); -#endif return m_data[x * m_y + y]; } const value_type& operator()( std::size_t x, std::size_t y ) const { -#if defined( _DEBUG ) ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" ); -#endif return m_data[x * m_y + y]; } value_type* data(){ diff --git a/include/modulesystem.h b/include/modulesystem.h index 8b1913fb..7fb88f54 100644 --- a/include/modulesystem.h +++ b/include/modulesystem.h @@ -150,9 +150,7 @@ ModuleRef( const char* name ) : m_table( 0 ){ } } Type* getTable(){ -#if defined( _DEBUG ) ASSERT_MESSAGE( m_table != 0, "ModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" ); -#endif return m_table; } }; @@ -181,9 +179,7 @@ void initialise( const char* name ){ } Type* getTable(){ -#if defined( _DEBUG ) ASSERT_MESSAGE( m_table != 0, "SingletonModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" ); -#endif return m_table; } void capture(){ diff --git a/include/preferencesystem.cpp b/include/preferencesystem.cpp index 6152cb14..7d9e31ca 100644 --- a/include/preferencesystem.cpp +++ b/include/preferencesystem.cpp @@ -18,170 +18,3 @@ along with GtkRadiant; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#if 0 - -#include "preferencesystem.h" -#include "preferencedictionary.h" - -#include "xml/xmlparser.h" -#include "xml/xmlwriter.h" - - -void LoadPrefs( PreferenceDictionary& preferences, const char* filename ){ - TextFileInputStream file( filename ); - if ( !file.failed() ) { - XMLStreamParser parser( file ); - XMLPreferenceDictionaryImporter importer( preferences ); - parser.exportXML( importer ); - } - else - { - // error - } -} - -void SavePrefs( PreferenceDictionary& preferences, const char* filename ){ - TextFileOutputStream file( filename ); - if ( !file.failed() ) { - XMLStreamWriter writer( file ); - XMLPreferenceDictionaryExporter exporter( preferences, "1" ); - exporter.exportXML( writer ); - } - else - { - // error - } -} - - -class StringPreference -{ -public: -class Observer -{ -public: -virtual void onChanged() = 0; -}; - -private: -CopiedString m_string; -Observer& m_observer; -public: -StringPreference( Observer& observer ) - : m_observer( observer ){ -} -void importString( const char* value ){ - m_string = value; - m_observer.onChanged(); -} -typedef MemberCaller1 ImportStringCaller; -void exportString( StringImportCallback& importer ){ - importer( m_string.c_str() ); -} -typedef MemberCaller1 ExportStringCaller; -}; - -inline void int_export( int i, StringImportCallback& importer ){ - char buffer[16]; - sprintf( buffer, "%d", i ); - importer( buffer ); -} - -inline int int_import( const char* value ){ - return atoi( value ); -} - -class IntPreference -{ -public: -class Observer -{ -public: -virtual void onChanged() = 0; -}; - -private: -int m_int; -Observer& m_observer; -public: - -IntPreference( Observer& observer ) - : m_observer( observer ){ -} -void importString( const char* value ){ - m_int = int_import( value ); - m_observer.onChanged(); -} -typedef MemberCaller1 ImportStringCaller; -void exportString( StringImportCallback& importer ){ - int_export( m_int, importer ); -} -typedef MemberCaller1 ExportStringCaller; -}; - -class IntPreferenceImporter -{ -int& m_i; -public: - -IntPreferenceImporter( int& i ) - : m_i( i ){ -} -void importString( const char* value ){ - m_i = int_import( value ); -} -}; - - -class TestPrefs -{ -public: -TestPrefs(){ - PreferenceDictionary preferences; - - class StringObserver : public StringPreference::Observer - { -public: - void onChanged(){ - int bleh = 0; - } - } string_observer; - StringPreference string1( string_observer ); - string1.importString( "twenty-three" ); - - class IntObserver : public IntPreference::Observer - { -public: - void onChanged(){ - int bleh = 0; - } - - } int_observer; - IntPreference int1( int_observer ); - int1.importString( "23" ); - - preferences.registerPreference( "string1", StringPreference::ImportStringCaller( string1 ), StringPreference::ExportStringCaller( string1 ) ); - preferences.registerPreference( "int1", IntPreference::ImportStringCaller( int1 ), IntPreference::ExportStringCaller( int1 ) ); - - LoadPrefs( preferences, "test.pref" ); - SavePrefs( preferences, "test.pref" ); - -} -}; - -#if 0 -TestPrefs g_TestPrefs; -#endif - -void readpref( PreferenceDictionary& preferences, int& int_variable ){ - PreferenceDictionary::iterator i = preferences.find( "int_variable" ); - IntPreferenceImporter importer( int_variable ); - ( *i ).second.exporter().exportString( importer ); -} - -void writepref( PreferenceDictionary& preferences, int& int_variable ){ - PreferenceDictionary::iterator i = preferences.find( "int_variable" ); - int_export( int_variable, ( *i ).second.importer() ); -} -#endif diff --git a/plugins/archivepak/archive.cpp b/plugins/archivepak/archive.cpp index 785c2dda..be882038 100644 --- a/plugins/archivepak/archive.cpp +++ b/plugins/archivepak/archive.cpp @@ -140,71 +140,3 @@ void forEachFile( VisitorFunc visitor, const char* root ){ Archive* OpenArchive( const char* name ){ return new PakArchive( name ); } - -#if 0 - -class TestArchive -{ -public: -TestArchive(){ - Archive* archive = OpenArchive( "c:/quake3/baseq3/pak0.pak" ); - ArchiveFile* file = archive->openFile( "gfx/palette.lmp" ); - if ( file != 0 ) { - char buffer[1024]; - file->getInputStream().read( (InputStream::byte_type*)buffer, 1024 ); - file->release(); - } - archive->release(); -} -}; - -TestArchive g_test; - -#endif - -#if 0 - -class TestArchive -{ -class TestVisitor : public Archive::IVisitor -{ -public: -void visit( const char* name ){ - int bleh = 0; -} -}; -public: -TestArchive(){ - { - Archive* archive = OpenArchive( "" ); - archive->release(); - } - { - Archive* archive = OpenArchive( "NONEXISTANTFILE" ); - archive->release(); - } - { - Archive* archive = OpenArchive( "c:/quake/id1/pak0.pak" ); - ArchiveFile* file = archive->openFile( "gfx/palette.lmp" ); - if ( file != 0 ) { - char buffer[1024]; - file->getInputStream().read( (InputStream::byte_type*)buffer, 1024 ); - file->release(); - } - TestVisitor visitor; - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 0 ), "" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFiles, 0 ), "progs/" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFiles, 0 ), "maps/" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFiles, 1 ), "sound/ambience/" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 1 ), "sound/" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eDirectories, 1 ), "sound/" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 2 ), "sound/" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 2 ), "" ); - archive->release(); - } -} -}; - -TestArchive g_test; - -#endif diff --git a/plugins/archivewad/archive.cpp b/plugins/archivewad/archive.cpp index 793cb0e7..7bc147d8 100644 --- a/plugins/archivewad/archive.cpp +++ b/plugins/archivewad/archive.cpp @@ -167,47 +167,3 @@ void forEachFile( VisitorFunc visitor, const char* root ){ Archive* OpenArchive( const char* name ){ return new WadArchive( name ); } - -#if 0 - -class TestArchive -{ -class TestVisitor : public Archive::IVisitor -{ -public: -void visit( const char* name ){ - int bleh = 0; -} -}; -public: -TestArchive(){ - { - Archive* archive = OpenArchive( "" ); - archive->release(); - } - { - Archive* archive = OpenArchive( "NONEXISTANTFILE" ); - archive->release(); - } - { - Archive* archive = OpenArchive( "c:/quake/id1/quake101.wad" ); - ArchiveFile* file = archive->openFile( "textures/sky1.mip" ); - if ( file != 0 ) { - unsigned char* buffer = new unsigned char[file->size()]; - file->getInputStream().read( (InputStream::byte_type*)buffer, file->size() ); - delete[] buffer; - file->release(); - } - TestVisitor visitor; - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 1 ), "" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 0 ), "" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 0 ), "textures/" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 1 ), "textures/" ); - archive->release(); - } -} -}; - -TestArchive g_test; - -#endif diff --git a/plugins/archivezip/archive.cpp b/plugins/archivezip/archive.cpp index a8616e62..dc8590ca 100644 --- a/plugins/archivezip/archive.cpp +++ b/plugins/archivezip/archive.cpp @@ -274,43 +274,3 @@ void forEachFile( VisitorFunc visitor, const char* root ){ Archive* OpenArchive( const char* name ){ return new ZipArchive( name ); } - -#if 0 - -class TestZip -{ -class TestVisitor : public Archive::IVisitor -{ -public: -void visit( const char* name ){ - int bleh = 0; -} -}; -public: -TestZip(){ - testzip( "c:/quake3/baseq3/mapmedia.pk3", "textures/radiant/notex.tga" ); -} - -void testzip( const char* name, const char* filename ){ - Archive* archive = OpenArchive( name ); - ArchiveFile* file = archive->openFile( filename ); - if ( file != 0 ) { - unsigned char buffer[4096]; - std::size_t count = file->getInputStream().read( (InputStream::byte_type*)buffer, 4096 ); - file->release(); - } - TestVisitor visitor; - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 0 ), "" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 1 ), "" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFiles, 1 ), "" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eDirectories, 1 ), "" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 1 ), "textures" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 1 ), "textures/" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 2 ), "" ); - archive->release(); -} -}; - -TestZip g_TestZip; - -#endif diff --git a/plugins/entity/group.cpp b/plugins/entity/group.cpp index 8e308c4c..ae4c237f 100644 --- a/plugins/entity/group.cpp +++ b/plugins/entity/group.cpp @@ -198,72 +198,10 @@ void transformChanged(){ typedef MemberCaller TransformChangedCaller; }; -#if 0 -class TransformableSetTranslation -{ -Translation m_value; -public: -TransformableSetTranslation( const Translation& value ) : m_value( value ){ -} -void operator()( Transformable& transformable ) const { - transformable.setTranslation( m_value ); -} -}; - -class TransformableSetRotation -{ -Rotation m_value; -public: -TransformableSetRotation( const Rotation& value ) : m_value( value ){ -} -void operator()( Transformable& transformable ) const { - transformable.setRotation( m_value ); -} -}; - -class TransformableSetScale -{ -Scale m_value; -public: -TransformableSetScale( const Scale& value ) : m_value( value ){ -} -void operator()( Transformable& transformable ) const { - transformable.setScale( m_value ); -} -}; - -class TransformableSetType -{ -TransformModifierType m_value; -public: -TransformableSetType( const TransformModifierType& value ) : m_value( value ){ -} -void operator()( Transformable& transformable ) const { - transformable.setType( m_value ); -} -}; - -class TransformableFreezeTransform -{ -TransformModifierType m_value; -public: -void operator()( Transformable& transformable ) const { - transformable.freezeTransform(); -} -}; - -template -inline void Scene_forEachChildTransformable( const Functor& functor, const scene::Path& path ){ - GlobalSceneGraph().traverse_subgraph( ChildInstanceWalker< InstanceApply >( functor ), path ); -} -#endif class GroupInstance : public TargetableInstance, public TransformModifier, -#if 0 - public Transformable, -#endif public Renderable { class TypeCasts @@ -273,9 +211,6 @@ public: TypeCasts(){ m_casts = TargetableInstance::StaticTypeCasts::instance().get(); InstanceStaticCast::install( m_casts ); -#if 0 - InstanceStaticCast::install( m_casts ); -#endif } InstanceTypeCastTable& get(){ return m_casts; @@ -306,26 +241,6 @@ void renderWireframe( Renderer& renderer, const VolumeTest& volume ) const { STRING_CONSTANT( Name, "GroupInstance" ); -#if 0 -void setType( TransformModifierType type ){ - Scene_forEachChildTransformable( TransformableSetType( type ), Instance::path() ); -} -void setTranslation( const Translation& value ){ - Scene_forEachChildTransformable( TransformableSetTranslation( value ), Instance::path() ); -} -void setRotation( const Rotation& value ){ - Scene_forEachChildTransformable( TransformableSetRotation( value ), Instance::path() ); -} -void setScale( const Scale& value ){ - Scene_forEachChildTransformable( TransformableSetScale( value ), Instance::path() ); -} -void freezeTransform(){ - Scene_forEachChildTransformable( TransformableFreezeTransform(), Instance::path() ); -} - -void evaluateTransform(){ -} -#endif void evaluateTransform(){ if ( getType() == TRANSFORM_PRIMITIVE ) { diff --git a/plugins/entity/light.cpp b/plugins/entity/light.cpp index dbde66c1..6c0141b7 100644 --- a/plugins/entity/light.cpp +++ b/plugins/entity/light.cpp @@ -1301,52 +1301,6 @@ const Matrix4& projection() const { matrix4_translate_by_vec3( m_doom3Projection, Vector3( 0.5f, 0.5f, 0 ) ); matrix4_scale_by_vec3( m_doom3Projection, Vector3( 0.5f, 0.5f, 1 ) ); -#if 0 - Vector3 right = vector3_cross( m_lightUp, vector3_normalised( m_lightTarget ) ); - Vector3 up = vector3_cross( vector3_normalised( m_lightTarget ), m_lightRight ); - Vector3 target = m_lightTarget; - Matrix4 test( - -right.x(), -right.y(), -right.z(), 0, - -up.x(), -up.y(), -up.z(), 0, - -target.x(), -target.y(), -target.z(), 0, - 0, 0, 0, 1 - ); - Matrix4 frustum = matrix4_frustum( -0.01, 0.01, -0.01, 0.01, 0.01, 1.0 ); - test = matrix4_full_inverse( test ); - matrix4_premultiply_by_matrix4( test, frustum ); - matrix4_multiply_by_matrix4( m_doom3Projection, test ); -#elif 0 - const float nearFar = 1 / 49.5f; - Vector3 right = vector3_cross( m_lightUp, vector3_normalised( m_lightTarget + m_lightRight ) ); - Vector3 up = vector3_cross( vector3_normalised( m_lightTarget + m_lightUp ), m_lightRight ); - Vector3 target = vector3_negated( m_lightTarget * ( 1 + nearFar ) ); - float scale = -1 / vector3_length( m_lightTarget ); - Matrix4 test( - -inverse( right.x() ), -inverse( up.x() ), -inverse( target.x() ), 0, - -inverse( right.y() ), -inverse( up.y() ), -inverse( target.y() ), 0, - -inverse( right.z() ), -inverse( up.z() ), -inverse( target.z() ), scale, - 0, 0, -nearFar, 0 - ); - matrix4_multiply_by_matrix4( m_doom3Projection, test ); -#elif 0 - Vector3 leftA( m_lightTarget - m_lightRight ); - Vector3 leftB( m_lightRight + m_lightUp ); - Plane3 left( vector3_normalised( vector3_cross( leftA, leftB ) ) * ( 1.0 / 128 ), 0 ); - Vector3 rightA( m_lightTarget + m_lightRight ); - Vector3 rightB( vector3_cross( rightA, m_lightTarget ) ); - Plane3 right( vector3_normalised( vector3_cross( rightA, rightB ) ) * ( 1.0 / 128 ), 0 ); - Vector3 bottomA( m_lightTarget - m_lightUp ); - Vector3 bottomB( vector3_cross( bottomA, m_lightTarget ) ); - Plane3 bottom( vector3_normalised( vector3_cross( bottomA, bottomB ) ) * ( 1.0 / 128 ), 0 ); - Vector3 topA( m_lightTarget + m_lightUp ); - Vector3 topB( vector3_cross( topA, m_lightTarget ) ); - Plane3 top( vector3_normalised( vector3_cross( topA, topB ) ) * ( 1.0 / 128 ), 0 ); - Plane3 front( vector3_normalised( m_lightTarget ) * ( 1.0 / 128 ), 1 ); - Plane3 back( vector3_normalised( vector3_negated( m_lightTarget ) ) * ( 1.0 / 128 ), 0 ); - Matrix4 test( matrix4_from_planes( plane3_flipped( left ), plane3_flipped( right ), plane3_flipped( bottom ), plane3_flipped( top ), plane3_flipped( front ), plane3_flipped( back ) ) ); - matrix4_multiply_by_matrix4( m_doom3Projection, test ); -#else - Plane3 lightProject[4]; Vector3 start = m_useLightStart && m_useLightEnd ? m_lightStart : vector3_normalised( m_lightTarget ); @@ -1418,8 +1372,7 @@ const Matrix4& projection() const { m_doom3Frustum.top = plane3_normalised( m_doom3Frustum.top ); m_doom3Frustum.back = plane3_normalised( m_doom3Frustum.back ); m_doom3Frustum.front = plane3_normalised( m_doom3Frustum.front ); -#endif - //matrix4_scale_by_vec3(m_doom3Projection, Vector3(1.0 / 128, 1.0 / 128, 1.0 / 128)); + return m_doom3Projection; } @@ -1701,9 +1654,6 @@ void Light_Construct( LightType lightType ){ g_lightType = lightType; if ( g_lightType == LIGHTTYPE_DOOM3 ) { LightShader::m_defaultShader = "lights/defaultPointLight"; -#if 0 - LightShader::m_defaultShader = "lights/defaultProjectedLight"; -#endif } RenderLightRadiiFill::m_state = GlobalShaderCache().capture( "$Q3MAP2_LIGHT_SPHERE" ); RenderLightCenter::m_state = GlobalShaderCache().capture( "$BIGPOINT" ); diff --git a/plugins/imagehl/sprite.cpp b/plugins/imagehl/sprite.cpp index b6347ec4..efdcfa70 100644 --- a/plugins/imagehl/sprite.cpp +++ b/plugins/imagehl/sprite.cpp @@ -163,20 +163,6 @@ Image* LoadIDSPBuff( byte *buffer ){ RGBAImage* image = new RGBAImage( columns, rows ); -#ifdef DEBUG - frametype = spriteframetype_t( pframetype->type ); - if ( frametype == SPR_SINGLE ) { - globalOutputStream() << "Single Frame\n"; - } - else if ( frametype == SPR_GROUP ) { - globalOutputStream() << "Group of Frames\n"; - } - else - { - globalOutputStream() << "Bleh!\n"; // <-- we always get this, wtf! - } -#endif - palette = (byte *)( pframetype + 1 ); spriteframe = (dspriteframe_t *)( palette + ( 256 * 3 ) + 4 ); // what are those 4 extra bytes ? what's missing ? buf_p = (byte *)( spriteframe + 1 ); diff --git a/plugins/md3model/model.h b/plugins/md3model/model.h index ee760064..d7896673 100644 --- a/plugins/md3model/model.h +++ b/plugins/md3model/model.h @@ -146,7 +146,6 @@ void updateAABB(){ } void render( RenderStateFlags state ) const { -#if 1 if ( ( state & RENDER_BUMP ) != 0 ) { if ( GlobalShaderCache().useShaderLanguage() ) { glNormalPointer( GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_vertices.data()->normal ); @@ -169,28 +168,6 @@ void render( RenderStateFlags state ) const { } glVertexPointer( 3, GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_vertices.data()->vertex ); glDrawElements( GL_TRIANGLES, GLsizei( m_indices.size() ), RenderIndexTypeID, m_indices.data() ); -#else - glBegin( GL_TRIANGLES ); - for ( unsigned int i = 0; i < m_indices.size(); ++i ) - { - glTexCoord2fv( &m_vertices[m_indices[i]].texcoord.s ); - glNormal3fv( &m_vertices[m_indices[i]].normal.x ); - glVertex3fv( &m_vertices[m_indices[i]].vertex.x ); - } - glEnd(); -#endif - -#if defined( _DEBUG ) - glBegin( GL_LINES ); - - for ( VertexBuffer::const_iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) - { - Vector3 normal = vector3_added( vertex3f_to_vector3( ( *i ).vertex ), vector3_scaled( normal3f_to_vector3( ( *i ).normal ), 8 ) ); - glVertex3fv( vertex3f_to_array( ( *i ).vertex ) ); - glVertex3fv( vector3_to_array( normal ) ); - } - glEnd(); -#endif } VolumeIntersectionValue intersectVolume( const VolumeTest& test, const Matrix4& localToWorld ) const { diff --git a/plugins/model/model.cpp b/plugins/model/model.cpp index defa472a..c3dbb6e6 100644 --- a/plugins/model/model.cpp +++ b/plugins/model/model.cpp @@ -113,29 +113,6 @@ void render( RenderStateFlags state ) const { glVertexPointer( 3, GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_vertices.data()->vertex ); glDrawElements( GL_TRIANGLES, GLsizei( m_indices.size() ), RenderIndexTypeID, m_indices.data() ); -#if defined( _DEBUG ) - GLfloat modelview[16]; - glGetFloatv( GL_MODELVIEW_MATRIX, modelview ); // I know this is slow as hell, but hey - we're in _DEBUG - Matrix4 modelview_inv( - modelview[0], modelview[1], modelview[2], modelview[3], - modelview[4], modelview[5], modelview[6], modelview[7], - modelview[8], modelview[9], modelview[10], modelview[11], - modelview[12], modelview[13], modelview[14], modelview[15] ); - matrix4_full_invert( modelview_inv ); - Matrix4 modelview_inv_transposed = matrix4_transposed( modelview_inv ); - - glBegin( GL_LINES ); - - for ( Array::const_iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) - { - Vector3 normal = normal3f_to_vector3( ( *i ).normal ); - normal = matrix4_transformed_direction( modelview_inv, vector3_normalised( matrix4_transformed_direction( modelview_inv_transposed, normal ) ) ); // do some magic - Vector3 normalTransformed = vector3_added( vertex3f_to_vector3( ( *i ).vertex ), vector3_scaled( normal, 8 ) ); - glVertex3fv( vertex3f_to_array( ( *i ).vertex ) ); - glVertex3fv( vector3_to_array( normalTransformed ) ); - } - glEnd(); -#endif } VolumeIntersectionValue intersectVolume( const VolumeTest& test, const Matrix4& localToWorld ) const { @@ -234,10 +211,6 @@ void CopyPicoSurface( picoSurface_t* surface ){ picoVec_t* st = PicoGetSurfaceST( surface, 0, int(i) ); m_vertices[i].texcoord = TexCoord2f( st[0], st[1] ); -#if 0 - picoVec_t* color = PicoGetSurfaceColor( surface, 0, int(i) ); - m_vertices[i].colour = Colour4b( color[0], color[1], color[2], color[3] ); -#endif } picoIndex_t* indexes = PicoGetSurfaceIndexes( surface, 0 ); @@ -621,315 +594,6 @@ scene::Instance* erase( scene::Instantiable::Observer* observer, const scene::Pa } }; - -#if 0 - -template -class create_new -{ -public: -static Type* construct( const Key& key ){ - return new Type( key ); -} -static void destroy( Type* value ){ - delete value; -} -}; - -template > -class cache_element : public creation_policy -{ -public: -inline cache_element() : m_count( 0 ), m_value( 0 ) {} -inline ~cache_element(){ - ASSERT_MESSAGE( m_count == 0, "destroyed a reference before it was released\n" ); - if ( m_count > 0 ) { - destroy(); - } -} -inline Type* capture( const Key& key ){ - if ( ++m_count == 1 ) { - construct( key ); - } - return m_value; -} -inline void release(){ - ASSERT_MESSAGE( !empty(), "failed to release reference - not found in cache\n" ); - if ( --m_count == 0 ) { - destroy(); - } -} -inline bool empty(){ - return m_count == 0; -} -inline void refresh( const Key& key ){ - m_value->refresh( key ); -} -private: -inline void construct( const Key& key ){ - m_value = creation_policy::construct( key ); -} -inline void destroy(){ - creation_policy::destroy( m_value ); -} - -std::size_t m_count; -Type* m_value; -}; - -class create_picomodel -{ -typedef PicoModelKey key_type; -typedef PicoModel value_type; -public: -static value_type* construct( const key_type& key ){ - picoModel_t* picomodel = PicoLoadModel( const_cast( key.first.c_str() ), key.second ); - value_type* value = new value_type( picomodel ); - PicoFreeModel( picomodel ); - return value; -} -static void destroy( value_type* value ){ - delete value; -} -}; - -#include - -class ModelCache -{ -typedef PicoModel value_type; - -public: -typedef PicoModelKey key_type; -typedef cache_element elem_type; -typedef std::map cache_type; - -value_type* capture( const key_type& key ){ - return m_cache[key].capture( key ); -} -void release( const key_type& key ){ - m_cache[key].release(); -} - -private: -cache_type m_cache; -}; - -ModelCache g_model_cache; - - - -typedef struct remap_s { - char m_remapbuff[64 + 1024]; - char *original; - char *remap; -} remap_t; - -class RemapWrapper : - public Cullable, - public Bounded -{ -public: -RemapWrapper( const char* name ){ - parse_namestr( name ); - - m_model = g_model_cache.capture( ModelCache::key_type( m_name, m_frame ) ); - - construct_shaders(); -} -virtual ~RemapWrapper(){ - g_model_cache.release( ModelCache::key_type( m_name, m_frame ) ); - - for ( shaders_t::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i ) - { - GlobalShaderCache().release( ( *i ).c_str() ); - } - - for ( remaps_t::iterator j = m_remaps.begin(); j != m_remaps.end(); ++j ) - { - delete ( *j ); - } -} - -VolumeIntersectionValue intersectVolume( const VolumeTest& test, const Matrix4& localToWorld ) const { - return m_model->intersectVolume( test, localToWorld ); -} - -virtual const AABB& localAABB() const { - return m_model->localAABB(); -} - -void render( Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld ) const { - m_model->render( renderer, volume, localToWorld, m_states ); -} - -void testSelect( Selector& selector, SelectionTest& test, const Matrix4& localToWorld ){ - m_model->testSelect( selector, test, localToWorld ); -} - -private: -void add_remap( const char *remap ){ - const char *ch; - remap_t *pRemap; - - ch = remap; - - while ( *ch && *ch != ';' ) - ch++; - - if ( *ch == '\0' ) { - // bad remap - globalErrorStream() << "WARNING: Shader _remap key found in a model entity without a ; character\n"; - } - else { - pRemap = new remap_t; - - strncpy( pRemap->m_remapbuff, remap, sizeof( pRemap->m_remapbuff ) ); - - pRemap->m_remapbuff[ch - remap] = '\0'; - - pRemap->original = pRemap->m_remapbuff; - pRemap->remap = pRemap->m_remapbuff + ( ch - remap ) + 1; - - m_remaps.push_back( pRemap ); - } -} - -void parse_namestr( const char *name ){ - const char *ptr, *s; - bool hasName, hasFrame; - - hasName = hasFrame = false; - - m_frame = 0; - - for ( s = ptr = name; ; ++ptr ) - { - if ( !hasName && ( *ptr == ':' || *ptr == '\0' ) ) { - // model name - hasName = true; - m_name = CopiedString( s, ptr ); - s = ptr + 1; - } - else if ( *ptr == '?' || *ptr == '\0' ) { - // model frame - hasFrame = true; - m_frame = atoi( CopiedString( s, ptr ).c_str() ); - s = ptr + 1; - } - else if ( *ptr == '&' || *ptr == '\0' ) { - // a remap - add_remap( CopiedString( s, ptr ).c_str() ); - s = ptr + 1; - } - - if ( *ptr == '\0' ) { - break; - } - } -} - -void construct_shaders(){ - const char* global_shader = shader_for_remap( "*" ); - - m_shaders.reserve( m_model->size() ); - m_states.reserve( m_model->size() ); - for ( PicoModel::iterator i = m_model->begin(); i != m_model->end(); ++i ) - { - const char* shader = shader_for_remap( ( *i )->getShader() ); - m_shaders.push_back( - ( shader[0] != '\0' ) - ? shader - : ( global_shader[0] != '\0' ) - ? global_shader - : ( *i )->getShader() ); - m_states.push_back( GlobalShaderCache().capture( m_shaders.back().c_str() ) ); - } -} - -inline const char* shader_for_remap( const char* remap ){ - for ( remaps_t::iterator i = m_remaps.begin(); i != m_remaps.end(); ++i ) - { - if ( shader_equal( remap, ( *i )->original ) ) { - return ( *i )->remap; - } - } - return ""; -} - -CopiedString m_name; -int m_frame; -PicoModel* m_model; - -typedef std::vector remaps_t; -remaps_t m_remaps; -typedef std::vector shaders_t; -shaders_t m_shaders; -typedef std::vector states_t; -states_t m_states; -}; - -class RemapWrapperInstance : public scene::Instance, public Renderable, public SelectionTestable -{ -RemapWrapper& m_remapwrapper; -public: -RemapWrapperInstance( const scene::Path& path, scene::Instance* parent, RemapWrapper& remapwrapper ) : Instance( path, parent ), m_remapwrapper( remapwrapper ){ - scene::Instance::m_cullable = &m_remapwrapper; - scene::Instance::m_render = this; - scene::Instance::m_select = this; -} - -void renderSolid( Renderer& renderer, const VolumeTest& volume ) const { - m_remapwrapper.render( renderer, volume, Instance::localToWorld() ); -} -void renderWireframe( Renderer& renderer, const VolumeTest& volume ) const { - renderSolid( renderer, volume ); -} - -void testSelect( Selector& selector, SelectionTest& test ){ - m_remapwrapper.testSelect( selector, test, Instance::localToWorld() ); -} -}; - -class RemapWrapperNode : public scene::Node::Symbiot, public scene::Instantiable -{ -scene::Node m_node; -typedef RemapWrapperInstance instance_type; -InstanceSet m_instances; -RemapWrapper m_remapwrapper; -public: -RemapWrapperNode( const char* name ) : m_node( this ), m_remapwrapper( name ){ - m_node.m_instance = this; -} - -void release(){ - delete this; -} -scene::Node& node(){ - return m_node; -} - -scene::Instance* create( const scene::Path& path, scene::Instance* parent ){ - return new instance_type( path, parent, m_remapwrapper ); -} -void forEachInstance( const scene::Instantiable::Visitor& visitor ){ - m_instances.forEachInstance( visitor ); -} -void insert( scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance ){ - m_instances.insert( observer, path, instance ); -} -scene::Instance* erase( scene::Instantiable::Observer* observer, const scene::Path& path ){ - return m_instances.erase( observer, path ); -} -}; - -scene::Node& LoadRemapModel( const char* name ){ - return ( new RemapWrapperNode( name ) )->node(); -} - -#endif - - size_t picoInputStreamReam( void* inputStream, unsigned char* buffer, size_t length ){ return reinterpret_cast( inputStream )->read( buffer, length ); } diff --git a/plugins/shaders/shaders.cpp b/plugins/shaders/shaders.cpp index a7a3078d..3dfc9f6e 100644 --- a/plugins/shaders/shaders.cpp +++ b/plugins/shaders/shaders.cpp @@ -591,11 +591,6 @@ bool ShaderTemplate::parseDoom3( Tokeniser& tokeniser ){ else if ( string_equal_nocase( token, "zeroclamp" ) ) { currentLayer.m_clampToBorder = true; } -#if 0 - else if ( string_equal_nocase( token, "alphaTest" ) ) { - Tokeniser_getFloat( tokeniser, currentLayer.m_alphaTest ); - } -#endif } else if ( depth == 1 ) { if ( string_equal_nocase( token, "qer_editorimage" ) ) { diff --git a/plugins/spritemodel/spritemodel.cpp b/plugins/spritemodel/spritemodel.cpp index 8308416f..513b4584 100644 --- a/plugins/spritemodel/spritemodel.cpp +++ b/plugins/spritemodel/spritemodel.cpp @@ -118,20 +118,6 @@ void CSpriteModel::Draw( int state, int rflags ) const { // draw the sprite -#if 0 - // using x/y axis, it appears FLAT without the proper transform and rotation. - - g_QglTable.m_pfn_qglBegin( GL_QUADS ); - g_QglTable.m_pfn_qglTexCoord2f( 0,0 ); - g_QglTable.m_pfn_qglVertex3f( 0 - w,0 - h, 0 ); - g_QglTable.m_pfn_qglTexCoord2f( 1,0 ); - g_QglTable.m_pfn_qglVertex3f( w,0 - h, 0 ); - g_QglTable.m_pfn_qglTexCoord2f( 1,1 ); - g_QglTable.m_pfn_qglVertex3f( w, h, 0 ); - g_QglTable.m_pfn_qglTexCoord2f( 0,1 ); - g_QglTable.m_pfn_qglVertex3f( 0 - w, h, 0 ); - g_QglTable.m_pfn_qglEnd(); -#else // so draw it using y/z instead. g_QglTable.m_pfn_qglBegin( GL_QUADS ); @@ -144,29 +130,7 @@ void CSpriteModel::Draw( int state, int rflags ) const { g_QglTable.m_pfn_qglTexCoord2f( 0.0f, 0.0f ); g_QglTable.m_pfn_qglVertex3f( 0.0f, static_cast( w ), 0.0f - static_cast( h ) ); g_QglTable.m_pfn_qglEnd(); -#endif g_QglTable.m_pfn_qglBindTexture( GL_TEXTURE_2D, 0 ); g_QglTable.m_pfn_qglPopAttrib(); } - -/* - bool CSpriteModel::TestRay(const ray_t *ray, vec_t *dist) const - { - vec_t depth_start = *dist; - vec_t depth_local = *dist; - - if (aabb_test_ray(&m_BBox, ray) == 0) - return false; - - for(int i=0; ibutton ) - { - case 1: - g_pManager->OnLButtonDown( event->x, event->y ); break; - case 3: - g_2DView.OnRButtonDown( event->x, event->y ); break; - } - } -} - -static void button_release( GtkWidget *widget, GdkEventButton *event, gpointer data ){ - if ( CanProcess() ) { - switch ( event->button ) - { - case 1: - g_pManager->OnLButtonUp( event->x, event->y ); break; - case 3: - g_2DView.OnRButtonUp( event->x, event->y ); break; - } - } -} - -static void motion( GtkWidget *widget, GdkEventMotion *event, gpointer data ){ - if ( CanProcess() ) { - if ( g_2DView.OnMouseMove( event->x, event->y ) ) { - return; - } - - if ( g_pManager->OnMouseMove( event->x, event->y ) ) { - return; - } - } -} - -static gint expose( GtkWidget *widget, GdkEventExpose *event, gpointer data ){ - if ( event->count > 0 ) { - return TRUE; - } - - if ( !CanProcess() ) { - return TRUE; - } - - if ( g_bTexViewReady ) { - g_2DView.m_rect.bottom = widget->allocation.height; - g_2DView.m_rect.right = widget->allocation.width; - - if ( !g_QglTable.m_pfn_glwidget_make_current( g_pToolWidget ) ) { - Sys_Printf( "TexTool: glMakeCurrent failed\n" ); - return TRUE; - } - - DoExpose(); - - g_QglTable.m_pfn_glwidget_swap_buffers( g_pToolWidget ); - } - - return TRUE; -} - -static gint keypress( GtkWidget* widget, GdkEventKey* event, gpointer data ){ - unsigned int code = gdk_keyval_to_upper( event->keyval ); - - if ( code == GDK_Escape ) { - gtk_widget_destroy( g_pToolWnd ); - g_pToolWnd = NULL; - return TRUE; - } - - if ( CanProcess() ) { - if ( g_2DView.OnKeyDown( code ) ) { - return FALSE; - } - - if ( code == GDK_Return ) { - Textool_Validate(); - return FALSE; - } - } - - return TRUE; -} - -static gint close( GtkWidget *widget, GdkEvent* event, gpointer data ){ - gtk_widget_destroy( widget ); - g_pToolWnd = NULL; - - return TRUE; -} - -static GtkWidget* CreateOpenGLWidget(){ - g_pToolWidget = g_QglTable.m_pfn_glwidget_new( FALSE, g_QglTable.m_pfn_GetQeglobalsGLWidget() ); - - gtk_widget_set_events( g_pToolWidget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK | - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ); - - // Connect signal handlers - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "expose_event", GTK_SIGNAL_FUNC( expose ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "motion_notify_event", - GTK_SIGNAL_FUNC( motion ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "button_press_event", - GTK_SIGNAL_FUNC( button_press ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "button_release_event", - GTK_SIGNAL_FUNC( button_release ), NULL ); - - gtk_signal_connect( GTK_OBJECT( g_pToolWnd ), "delete_event", GTK_SIGNAL_FUNC( close ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWnd ), "key_press_event", - GTK_SIGNAL_FUNC( keypress ), NULL ); - - return g_pToolWidget; -} -#endif - -#if 0 -static void DoPaint(){ - if ( !CanProcess() ) { - return; - } - - if ( g_bTexViewReady ) { - g_2DView.m_rect.bottom = g_pToolWnd->getHeight(); - g_2DView.m_rect.right = g_pToolWnd->getWidth(); - - // set GL_PROJECTION - g_2DView.PreparePaint(); - // render the objects - // the master is not rendered the same way, draw over a unified texture background - g_2DView.TextureBackground( g_DrawObjects[0].pObject->getTextureNumber() ); - if ( g_nDrawObjects >= 1 ) { - int i; - for ( i = 1; i < g_nDrawObjects; i++ ) - { - // we use a first step to the GL_MODELVIEW for the master object - // GL_MODELVIEW will be altered in RenderAuxiliary too - g_DrawObjects[0].pObject->PrepareModelView( g_DrawObjects[i].pTopo ); - g_DrawObjects[i].pObject->RenderAuxiliary(); - } - } - // draw the polygon outline and control points - g_DrawObjects[0].pObject->PrepareModelView( NULL ); - g_DrawObjects[0].pObject->RenderUI(); - } -} -#endif - bool CWindowListener::OnLButtonDown( guint32 nFlags, double x, double y ){ if ( CanProcess() ) { g_pManager->OnLButtonDown( (int)x, (int)y ); @@ -771,57 +623,6 @@ bool CWindowListener::OnKeyPressed( char *s ){ } extern "C" void QERPlug_Dispatch( const char* p, vec3_t vMin, vec3_t vMax, bool bSingleBrush ){ - #if 0 - // if it's the first call, perhaps we need some additional init steps - if ( !g_bQglInitDone ) { - g_QglTable.m_nSize = sizeof( OpenGLBinding ); - if ( g_FuncTable.m_pfnRequestInterface( QERQglTable_GUID, static_cast( &g_QglTable ) ) ) { - g_bQglInitDone = true; - } - else - { - Sys_Printf( "TexTool plugin: OpenGLBinding interface request failed\n" ); - return; - } - } - - if ( !g_bSelectedFaceInitDone ) { - g_SelectedFaceTable.m_nSize = sizeof( _QERSelectedFaceTable ); - if ( g_FuncTable.m_pfnRequestInterface( QERSelectedFaceTable_GUID, - static_cast( &g_SelectedFaceTable ) ) ) { - g_bSelectedFaceInitDone = true; - } - else - { - Sys_Printf( "TexTool plugin: _QERSelectedFaceTable interface request failed\n" ); - return; - } - } - - if ( !g_bSurfaceTableInitDone ) { - g_SurfaceTable.m_nSize = sizeof( _QERAppSurfaceTable ); - if ( g_FuncTable.m_pfnRequestInterface( QERAppSurfaceTable_GUID, static_cast( &g_SurfaceTable ) ) ) { - g_bSurfaceTableInitDone = true; - } - else - { - Sys_Printf( "TexTool plugin: _QERAppSurfaceTable interface request failed\n" ); - return; - } - } - - if ( !g_bUITable ) { - g_UITable.m_nSize = sizeof( _QERUITable ); - if ( g_FuncTable.m_pfnRequestInterface( QERUI_GUID, static_cast( &g_UITable ) ) ) { - g_bUITable = true; - } - else - { - Sys_Printf( "TexTool plugin: _QERUITable interface request failed\n" ); - return; - } - } - #endif if ( !strcmp( p, "About..." ) ) { DoMessageBox( PLUGIN_ABOUT, "About ...", MB_OK ); diff --git a/plugins/vfspk3/archive.cpp b/plugins/vfspk3/archive.cpp index a77b0728..d5f3ec41 100644 --- a/plugins/vfspk3/archive.cpp +++ b/plugins/vfspk3/archive.cpp @@ -119,46 +119,3 @@ virtual void forEachFile( VisitorFunc visitor, const char* root ){ Archive* OpenArchive( const char* name ){ return new DirectoryArchive( name ); } - -#if 0 - -class TestArchive -{ -class TestVisitor : public Archive::IVisitor -{ -public: -virtual void visit( const char* name ){ - int bleh = 0; -} -}; -public: -void test1(){ - Archive* archive = OpenArchive( "d:/quake/id1/" ); - ArchiveFile* file = archive->openFile( "quake101.wad" ); - if ( file != 0 ) { - char buffer[1024]; - file->getInputStream().read( buffer, 1024 ); - file->release(); - } - TestVisitor visitor; - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 0 ), "" ); - archive->release(); -} -void test2(){ - Archive* archive = OpenArchive( "d:/gtkradiant_root/baseq3/" ); - TestVisitor visitor; - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 2 ), "" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFiles, 1 ), "textures" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eDirectories, 1 ), "textures" ); - archive->forEachFile( Archive::VisitorFunc( &visitor, Archive::eFilesAndDirectories, 1 ), "textures" ); - archive->release(); -} -TestArchive(){ - test1(); - test2(); -} -}; - -TestArchive g_test; - -#endif diff --git a/radiant/brush.cpp b/radiant/brush.cpp index 5e38cc1d..bb03f43a 100644 --- a/radiant/brush.cpp +++ b/radiant/brush.cpp @@ -262,21 +262,6 @@ void Brush::buildBRep(){ globalErrorStream() << "Final B-Rep: inconsistent vertex count\n"; } -#if BRUSH_CONNECTIVITY_DEBUG - if ( ( uniqueVertices.size() + faces_size ) - uniqueEdges.size() != 2 ) { - for ( Faces::iterator i = m_faces.begin(); i != m_faces.end(); ++i ) - { - std::size_t faceIndex = std::distance( m_faces.begin(), i ); - - if ( !( *i )->contributes() ) { - globalOutputStream() << "face: " << Unsigned( faceIndex ) << " does not contribute\n"; - } - - Winding_printConnectivity( ( *i )->getWinding() ); - } - } -#endif - // edge-index list for wireframe rendering { m_edge_indices.resize( uniqueEdgeIndices.size() ); diff --git a/radiant/brush.h b/radiant/brush.h index 0fb6ffe2..6c0956f5 100644 --- a/radiant/brush.h +++ b/radiant/brush.h @@ -80,9 +80,6 @@ enum EBrushType }; -#define BRUSH_CONNECTIVITY_DEBUG 0 -#define BRUSH_DEGENERATE_DEBUG 0 - template inline TextOuputStreamType& ostream_write( TextOuputStreamType& ostream, const Matrix4& m ){ return ostream << "(" << m[0] << " " << m[1] << " " << m[2] << " " << m[3] << ", " @@ -153,42 +150,9 @@ inline void Winding_Draw( const Winding& winding, const Vector3& normal, RenderS glTexCoordPointer( 2, GL_FLOAT, sizeof( WindingVertex ), &winding.points.data()->texcoord ); } } -#if 0 - if ( state & RENDER_FILL ) { - glDrawArrays( GL_TRIANGLE_FAN, 0, GLsizei( winding.numpoints ) ); - } - else - { - glDrawArrays( GL_LINE_LOOP, 0, GLsizei( winding.numpoints ) ); - } -#else - glDrawArrays( GL_POLYGON, 0, GLsizei( winding.numpoints ) ); -#endif - -#if 0 - const Winding& winding = winding; - - if ( state & RENDER_FILL ) { - glBegin( GL_POLYGON ); - } - else - { - glBegin( GL_LINE_LOOP ); - } - if ( state & RENDER_LIGHTING ) { - glNormal3fv( normal ); - } + glDrawArrays( GL_POLYGON, 0, GLsizei( winding.numpoints ) ); - for ( int i = 0; i < winding.numpoints; ++i ) - { - if ( state & RENDER_TEXTURE ) { - glTexCoord2fv( &winding.points[i][3] ); - } - glVertex3fv( winding.points[i] ); - } - glEnd(); -#endif } @@ -697,13 +661,7 @@ FacePlane( const FacePlane& other ) : m_funcStaticOrigin( 0, 0, 0 ){ void MakePlane(){ if ( !isDoom3Plane() ) { -#if 0 - if ( check_plane_is_integer( m_planepts ) ) { - globalErrorStream() << "non-integer planepts: "; - planepts_print( m_planepts, globalErrorStream() ); - globalErrorStream() << "\n"; - } -#endif + m_planeCached = plane3_for_points( m_planepts ); } } @@ -722,10 +680,6 @@ void reverse(){ void transform( const Matrix4& matrix, bool mirror ){ if ( !isDoom3Plane() ) { -#if 0 - bool off = check_plane_is_integer( planePoints() ); -#endif - matrix4_transform_point( matrix, m_planepts[0] ); matrix4_transform_point( matrix, m_planepts[1] ); matrix4_transform_point( matrix, m_planepts[2] ); @@ -733,14 +687,6 @@ void transform( const Matrix4& matrix, bool mirror ){ if ( mirror ) { reverse(); } - -#if 0 - if ( check_plane_is_integer( planePoints() ) ) { - if ( !off ) { - globalErrorStream() << "caused by transform\n"; - } - } -#endif MakePlane(); } else @@ -1058,9 +1004,6 @@ void transform( const Matrix4& matrix, bool mirror ){ m_planeTransformed.transform( matrix, mirror ); -#if 0 - ASSERT_MESSAGE( projectionaxis_for_normal( normal ) == projectionaxis_for_normal( plane3().normal() ), "bleh" ); -#endif m_observer->planeChanged(); if ( g_brush_texturelock_enabled ) { @@ -1101,11 +1044,6 @@ void update_move_planepts_vertex( std::size_t index, PlanePoints planePoints ){ void snapto( float snap ){ if ( contributes() ) { -#if 0 - ASSERT_MESSAGE( plane3_valid( m_plane.plane3() ), "invalid plane before snap to grid" ); - planepts_snap( m_plane.planePoints(), snap ); - ASSERT_MESSAGE( plane3_valid( m_plane.plane3() ), "invalid plane after snap to grid" ); -#else PlanePoints planePoints; update_move_planepts_vertex( 0, planePoints ); vector3_snap( planePoints[0], snap ); @@ -1113,7 +1051,6 @@ void snapto( float snap ){ vector3_snap( planePoints[2], snap ); assign_planepts( planePoints ); freezeTransform(); -#endif SceneChangeNotify(); if ( !plane3_valid( m_plane.plane3() ) ) { globalErrorStream() << "WARNING: invalid plane after snap to grid\n"; @@ -2016,9 +1953,6 @@ void windingForClipPlane( Winding& winding, const Plane3& plane ) const { buffer[!swap].clear(); -#if BRUSH_CONNECTIVITY_DEBUG - globalOutputStream() << "clip vs face: " << i << "\n"; -#endif { // flip the plane, because we want to keep the back side @@ -2026,33 +1960,11 @@ void windingForClipPlane( Winding& winding, const Plane3& plane ) const { Winding_Clip( buffer[swap], plane, clipPlane, i, buffer[!swap] ); } -#if BRUSH_CONNECTIVITY_DEBUG - for ( FixedWinding::Points::iterator k = buffer[!swap].points.begin(), j = buffer[!swap].points.end() - 1; k != buffer[!swap].points.end(); j = k, ++k ) - { - if ( vector3_length_squared( vector3_subtracted( ( *k ).vertex, ( *j ).vertex ) ) < 1 ) { - globalOutputStream() << "v: " << std::distance( buffer[!swap].points.begin(), j ) << " tiny edge adjacent to face " << ( *j ).adjacent << "\n"; - } - } -#endif - - //ASSERT_MESSAGE(buffer[!swap].numpoints != 1, "created single-point winding"); - swap = !swap; } } Winding_forFixedWinding( winding, buffer[swap] ); - -#if BRUSH_CONNECTIVITY_DEBUG - Winding_printConnectivity( winding ); - - for ( Winding::iterator i = winding.begin(), j = winding.end() - 1; i != winding.end(); j = i, ++i ) - { - if ( vector3_length_squared( vector3_subtracted( ( *i ).vertex, ( *j ).vertex ) ) < 1 ) { - globalOutputStream() << "v: " << std::distance( winding.begin(), j ) << " tiny edge adjacent to face " << ( *j ).adjacent << "\n"; - } - } -#endif } void update_wireframe( RenderableWireframe& wire, const bool* faces_visible ) const { @@ -2149,9 +2061,6 @@ void removeDegenerateEdges(){ std::size_t index = std::distance( winding.begin(), j ); std::size_t next = Winding_next( winding, index ); if ( Edge_isDegenerate( winding[index].vertex, winding[next].vertex ) ) { -#if BRUSH_DEGENERATE_DEBUG - globalOutputStream() << "Brush::buildWindings: face " << i << ": degenerate edge adjacent to " << winding[index].adjacent << "\n"; -#endif Winding& other = m_faces[winding[index].adjacent]->getWinding(); std::size_t adjacent = Winding_FindAdjacent( other, i ); if ( adjacent != c_brush_maxFaces ) { @@ -2175,17 +2084,11 @@ void removeDegenerateFaces(){ Winding& degen = m_faces[i]->getWinding(); if ( degen.numpoints == 2 ) { -#if BRUSH_DEGENERATE_DEBUG - globalOutputStream() << "Brush::buildWindings: face " << i << ": degenerate winding adjacent to " << degen[0].adjacent << ", " << degen[1].adjacent << "\n"; -#endif // this is an "edge" face, where the plane touches the edge of the brush { Winding& winding = m_faces[degen[0].adjacent]->getWinding(); std::size_t index = Winding_FindAdjacent( winding, i ); if ( index != c_brush_maxFaces ) { -#if BRUSH_DEGENERATE_DEBUG - globalOutputStream() << "Brush::buildWindings: face " << degen[0].adjacent << ": remapping adjacent " << winding[index].adjacent << " to " << degen[1].adjacent << "\n"; -#endif winding[index].adjacent = degen[1].adjacent; } } @@ -2194,9 +2097,6 @@ void removeDegenerateFaces(){ Winding& winding = m_faces[degen[1].adjacent]->getWinding(); std::size_t index = Winding_FindAdjacent( winding, i ); if ( index != c_brush_maxFaces ) { -#if BRUSH_DEGENERATE_DEBUG - globalOutputStream() << "Brush::buildWindings: face " << degen[1].adjacent << ": remapping adjacent " << winding[index].adjacent << " to " << degen[0].adjacent << "\n"; -#endif winding[index].adjacent = degen[0].adjacent; } } @@ -2218,9 +2118,6 @@ void removeDuplicateEdges(){ { std::size_t next = Winding_next( winding, j ); if ( winding[j].adjacent == winding[next].adjacent ) { -#if BRUSH_DEGENERATE_DEBUG - globalOutputStream() << "Brush::buildWindings: face " << i << ": removed duplicate edge adjacent to face " << winding[j].adjacent << "\n"; -#endif winding.erase( winding.begin() + next ); } else @@ -2242,15 +2139,9 @@ void verifyConnectivityGraph(){ Winding& winding = m_faces[i]->getWinding(); for ( Winding::iterator j = winding.begin(); j != winding.end(); ) { -#if BRUSH_CONNECTIVITY_DEBUG - globalOutputStream() << "Brush::buildWindings: face " << i << ": adjacent to face " << ( *j ).adjacent << "\n"; -#endif // remove unidirectional graph edges if ( ( *j ).adjacent == c_brush_maxFaces || Winding_FindAdjacent( m_faces[( *j ).adjacent]->getWinding(), i ) == c_brush_maxFaces ) { -#if BRUSH_CONNECTIVITY_DEBUG - globalOutputStream() << "Brush::buildWindings: face " << i << ": removing unidirectional connectivity graph edge adjacent to face " << ( *j ).adjacent << "\n"; -#endif winding.erase( j ); } else @@ -2288,9 +2179,6 @@ bool buildWindings(){ } else { -#if BRUSH_CONNECTIVITY_DEBUG - globalOutputStream() << "face: " << i << "\n"; -#endif windingForClipPlane( f.getWinding(), f.plane3() ); // update brush bounds diff --git a/radiant/brush_primit.cpp b/radiant/brush_primit.cpp index 4ea73c03..9cac7a88 100644 --- a/radiant/brush_primit.cpp +++ b/radiant/brush_primit.cpp @@ -257,27 +257,14 @@ void Texdef_EmitTextureCoordinates( const TextureProjection& projection, std::si if ( w.numpoints < 3 ) { return; } - //globalOutputStream() << "normal: " << normal << "\n"; Matrix4 local2tex; Texdef_toTransform( projection, (float)width, (float)height, local2tex ); - //globalOutputStream() << "texdef: " << static_cast(local2tex.x()) << static_cast(local2tex.y()) << "\n"; - -#if 0 - { - TextureProjection tmp; - Texdef_fromTransform( tmp, (float)width, (float)height, local2tex ); - Matrix4 tmpTransform; - Texdef_toTransform( tmp, (float)width, (float)height, tmpTransform ); - ASSERT_MESSAGE( matrix4_equal_epsilon( local2tex, tmpTransform, 0.0001f ), "bleh" ); - } -#endif { Matrix4 xyz2st; // we don't care if it's not normalised... Texdef_basisForNormal( projection, matrix4_transformed_direction( localToWorld, normal ), xyz2st ); - //globalOutputStream() << "basis: " << static_cast(xyz2st.x()) << static_cast(xyz2st.y()) << static_cast(xyz2st.z()) << "\n"; matrix4_multiply_by_matrix4( local2tex, xyz2st ); } @@ -397,13 +384,7 @@ inline BasicVector3 vector3_inverse( const BasicVector3& self void BPMatMul( float A[2][3], float B[2][3], float C[2][3] ); // apply a rotation (degrees) void BPMatRotate( float A[2][3], float theta ); -#ifdef _DEBUG -void BPMatDump( float A[2][3] ); -#endif -#ifdef _DEBUG -//#define DBG_BP -#endif bp_globals_t g_bp_globals; @@ -425,22 +406,9 @@ inline float SarrusDet( const Vector3& a, const Vector3& b, const Vector3& c ){ // NOTE: see the commented out section to fill M and D //++timo TODO: update the other members to use this when possible void MatrixForPoints( Vector3 M[3], Vector3 D[2], brushprimit_texdef_t *T ){ -// Vector3 M[3]; // columns of the matrix .. easier that way (the indexing is not standard! it's column-line .. later computations are easier that way) float det; -// Vector3 D[2]; M[2][0] = 1.0f; M[2][1] = 1.0f; M[2][2] = 1.0f; -#if 0 - // fill the data vectors - M[0][0] = A2[0]; M[0][1] = B2[0]; M[0][2] = C2[0]; - M[1][0] = A2[1]; M[1][1] = B2[1]; M[1][2] = C2[1]; - M[2][0] = 1.0f; M[2][1] = 1.0f; M[2][2] = 1.0f; - D[0][0] = A1[0]; - D[0][1] = B1[0]; - D[0][2] = C1[0]; - D[1][0] = A1[1]; - D[1][1] = B1[1]; - D[1][2] = C1[1]; -#endif + // solve det = SarrusDet( M[0], M[1], M[2] ); T->coords[0][0] = SarrusDet( D[0], M[1], M[2] ) / det; @@ -456,7 +424,6 @@ void MatrixForPoints( Vector3 M[3], Vector3 D[2], brushprimit_texdef_t *T ){ // WARNING : special case behaviour of atan2(y,x) <-> atan(y/x) might not be the same everywhere when x == 0 // rotation by (0,RotY,RotZ) assigns X to normal void ComputeAxisBase( const Vector3& normal, Vector3& texS, Vector3& texT ){ -#if 1 const Vector3 up( 0, 0, 1 ); const Vector3 down( 0, 0, -1 ); @@ -474,119 +441,8 @@ void ComputeAxisBase( const Vector3& normal, Vector3& texS, Vector3& texT ){ texT = vector3_normalised( vector3_cross( normal, texS ) ); vector3_negate( texS ); } - -#else - float RotY,RotZ; - // do some cleaning - /* - if (fabs(normal[0])<1e-6) - normal[0]=0.0f; - if (fabs(normal[1])<1e-6) - normal[1]=0.0f; - if (fabs(normal[2])<1e-6) - normal[2]=0.0f; - */ - RotY = -atan2( normal[2],sqrt( normal[1] * normal[1] + normal[0] * normal[0] ) ); - RotZ = atan2( normal[1],normal[0] ); - // rotate (0,1,0) and (0,0,1) to compute texS and texT - texS[0] = -sin( RotZ ); - texS[1] = cos( RotZ ); - texS[2] = 0; - // the texT vector is along -Z ( T texture coorinates axis ) - texT[0] = -sin( RotY ) * cos( RotZ ); - texT[1] = -sin( RotY ) * sin( RotZ ); - texT[2] = -cos( RotY ); -#endif } -#if 0 // texdef conversion -void FaceToBrushPrimitFace( face_t *f ){ - Vector3 texX,texY; - Vector3 proj; - // ST of (0,0) (1,0) (0,1) - float ST[3][5]; // [ point index ] [ xyz ST ] - //++timo not used as long as brushprimit_texdef and texdef are static -/* f->brushprimit_texdef.contents=f->texdef.contents; - f->brushprimit_texdef.flags=f->texdef.flags; - f->brushprimit_texdef.value=f->texdef.value; - strcpy(f->brushprimit_texdef.name,f->texdef.name); */ -#ifdef DBG_BP - if ( f->plane.normal[0] == 0.0f && f->plane.normal[1] == 0.0f && f->plane.normal[2] == 0.0f ) { - globalOutputStream() << "Warning : f->plane.normal is (0,0,0) in FaceToBrushPrimitFace\n"; - } - // check d_texture - if ( !f->d_texture ) { - globalOutputStream() << "Warning : f.d_texture is 0 in FaceToBrushPrimitFace\n"; - return; - } -#endif - // compute axis base - ComputeAxisBase( f->plane.normal,texX,texY ); - // compute projection vector - VectorCopy( f->plane.normal,proj ); - VectorScale( proj,f->plane.dist,proj ); - // (0,0) in plane axis base is (0,0,0) in world coordinates + projection on the affine plane - // (1,0) in plane axis base is texX in world coordinates + projection on the affine plane - // (0,1) in plane axis base is texY in world coordinates + projection on the affine plane - // use old texture code to compute the ST coords of these points - VectorCopy( proj,ST[0] ); - EmitTextureCoordinates( ST[0], f->pShader->getTexture(), f ); - VectorCopy( texX,ST[1] ); - VectorAdd( ST[1],proj,ST[1] ); - EmitTextureCoordinates( ST[1], f->pShader->getTexture(), f ); - VectorCopy( texY,ST[2] ); - VectorAdd( ST[2],proj,ST[2] ); - EmitTextureCoordinates( ST[2], f->pShader->getTexture(), f ); - // compute texture matrix - f->brushprimit_texdef.coords[0][2] = ST[0][3]; - f->brushprimit_texdef.coords[1][2] = ST[0][4]; - f->brushprimit_texdef.coords[0][0] = ST[1][3] - f->brushprimit_texdef.coords[0][2]; - f->brushprimit_texdef.coords[1][0] = ST[1][4] - f->brushprimit_texdef.coords[1][2]; - f->brushprimit_texdef.coords[0][1] = ST[2][3] - f->brushprimit_texdef.coords[0][2]; - f->brushprimit_texdef.coords[1][1] = ST[2][4] - f->brushprimit_texdef.coords[1][2]; -} - -// compute texture coordinates for the winding points -void EmitBrushPrimitTextureCoordinates( face_t * f, Winding * w ){ - Vector3 texX,texY; - float x,y; - // compute axis base - ComputeAxisBase( f->plane.normal,texX,texY ); - // in case the texcoords matrix is empty, build a default one - // same behaviour as if scale[0]==0 && scale[1]==0 in old code - if ( f->brushprimit_texdef.coords[0][0] == 0 && f->brushprimit_texdef.coords[1][0] == 0 && f->brushprimit_texdef.coords[0][1] == 0 && f->brushprimit_texdef.coords[1][1] == 0 ) { - f->brushprimit_texdef.coords[0][0] = 1.0f; - f->brushprimit_texdef.coords[1][1] = 1.0f; - ConvertTexMatWithQTexture( &f->brushprimit_texdef, 0, &f->brushprimit_texdef, f->pShader->getTexture() ); - } - int i; - for ( i = 0 ; i < w.numpoints ; i++ ) - { - x = vector3_dot( w.point_at( i ),texX ); - y = vector3_dot( w.point_at( i ),texY ); -#if 0 -#ifdef DBG_BP - if ( g_bp_globals.bNeedConvert ) { - // check we compute the same ST as the traditional texture computation used before - float S = f->brushprimit_texdef.coords[0][0] * x + f->brushprimit_texdef.coords[0][1] * y + f->brushprimit_texdef.coords[0][2]; - float T = f->brushprimit_texdef.coords[1][0] * x + f->brushprimit_texdef.coords[1][1] * y + f->brushprimit_texdef.coords[1][2]; - if ( fabs( S - w.point_at( i )[3] ) > 1e-2 || fabs( T - w.point_at( i )[4] ) > 1e-2 ) { - if ( fabs( S - w.point_at( i )[3] ) > 1e-4 || fabs( T - w.point_at( i )[4] ) > 1e-4 ) { - globalOutputStream() << "Warning : precision loss in brush -> brush primitive texture computation\n"; - } - else{ - globalOutputStream() << "Warning : brush -> brush primitive texture computation bug detected\n"; - } - } - } -#endif -#endif - w.point_at( i )[3] = f->brushprimit_texdef.coords[0][0] * x + f->brushprimit_texdef.coords[0][1] * y + f->brushprimit_texdef.coords[0][2]; - w.point_at( i )[4] = f->brushprimit_texdef.coords[1][0] * x + f->brushprimit_texdef.coords[1][1] * y + f->brushprimit_texdef.coords[1][2]; - } -} -#endif - typedef float texmat_t[2][3]; void TexMat_Scale( texmat_t texmat, float s, float t ){ @@ -613,19 +469,6 @@ void ConvertTexMatWithDimensions( const texmat_t texmat1, std::size_t w1, std::s TexMat_Scale( texmat2, static_cast( w1 ) / static_cast( w2 ), static_cast( h1 ) / static_cast( h2 ) ); } -#if 0 -// convert a texture matrix between two qtexture_t -// if 0 for qtexture_t, basic 2x2 texture is assumed ( straight mapping between s/t coordinates and geometric coordinates ) -void ConvertTexMatWithQTexture( const float texMat1[2][3], const qtexture_t *qtex1, float texMat2[2][3], const qtexture_t *qtex2 ){ - ConvertTexMatWithDimensions( texMat1, ( qtex1 ) ? qtex1->width : 2, ( qtex1 ) ? qtex1->height : 2, - texMat2, ( qtex2 ) ? qtex2->width : 2, ( qtex2 ) ? qtex2->height : 2 ); -} - -void ConvertTexMatWithQTexture( const brushprimit_texdef_t *texMat1, const qtexture_t *qtex1, brushprimit_texdef_t *texMat2, const qtexture_t *qtex2 ){ - ConvertTexMatWithQTexture( texMat1->coords, qtex1, texMat2->coords, qtex2 ); -} -#endif - // compute a fake shift scale rot representation from the texture matrix // these shift scale rot values are to be understood in the local axis base // Note: this code looks similar to Texdef_fromTransform, but the algorithm is slightly different. @@ -672,54 +515,6 @@ void FakeTexCoordsToTexMat( const texdef_t& texdef, brushprimit_texdef_t& bp_tex bp_texdef.coords[1][2] = texdef.shift[1]; } -#if 0 // texture locking (brush primit) -// used for texture locking -// will move the texture according to a geometric vector -void ShiftTextureGeometric_BrushPrimit( face_t *f, Vector3& delta ){ - Vector3 texS,texT; - float tx,ty; - Vector3 M[3]; // columns of the matrix .. easier that way - float det; - Vector3 D[2]; - // compute plane axis base ( doesn't change with translation ) - ComputeAxisBase( f->plane.normal, texS, texT ); - // compute translation vector in plane axis base - tx = vector3_dot( delta, texS ); - ty = vector3_dot( delta, texT ); - // fill the data vectors - M[0][0] = tx; M[0][1] = 1.0f + tx; M[0][2] = tx; - M[1][0] = ty; M[1][1] = ty; M[1][2] = 1.0f + ty; - M[2][0] = 1.0f; M[2][1] = 1.0f; M[2][2] = 1.0f; - D[0][0] = f->brushprimit_texdef.coords[0][2]; - D[0][1] = f->brushprimit_texdef.coords[0][0] + f->brushprimit_texdef.coords[0][2]; - D[0][2] = f->brushprimit_texdef.coords[0][1] + f->brushprimit_texdef.coords[0][2]; - D[1][0] = f->brushprimit_texdef.coords[1][2]; - D[1][1] = f->brushprimit_texdef.coords[1][0] + f->brushprimit_texdef.coords[1][2]; - D[1][2] = f->brushprimit_texdef.coords[1][1] + f->brushprimit_texdef.coords[1][2]; - // solve - det = SarrusDet( M[0], M[1], M[2] ); - f->brushprimit_texdef.coords[0][0] = SarrusDet( D[0], M[1], M[2] ) / det; - f->brushprimit_texdef.coords[0][1] = SarrusDet( M[0], D[0], M[2] ) / det; - f->brushprimit_texdef.coords[0][2] = SarrusDet( M[0], M[1], D[0] ) / det; - f->brushprimit_texdef.coords[1][0] = SarrusDet( D[1], M[1], M[2] ) / det; - f->brushprimit_texdef.coords[1][1] = SarrusDet( M[0], D[1], M[2] ) / det; - f->brushprimit_texdef.coords[1][2] = SarrusDet( M[0], M[1], D[1] ) / det; -} - -// shift a texture (texture adjustments) along it's current texture axes -// x and y are geometric values, which we must compute as ST increments -// this depends on the texture size and the pixel/texel ratio -void ShiftTextureRelative_BrushPrimit( face_t *f, float x, float y ){ - float s,t; - // as a ratio against texture size - // the scale of the texture is not relevant here (we work directly on a transformation from the base vectors) - s = ( x * 2.0 ) / (float)f->pShader->getTexture().width; - t = ( y * 2.0 ) / (float)f->pShader->getTexture().height; - f->brushprimit_texdef.coords[0][2] -= s; - f->brushprimit_texdef.coords[1][2] -= t; -} -#endif - // TTimo: FIXME: I don't like that, it feels broken // (and it's likely that it's not used anymore) // best fitted 2D vector is x.X+y.Y @@ -748,142 +543,6 @@ void ComputeBest2DVector( Vector3& v, Vector3& X, Vector3& Y, int &x, int &y ){ } } - -#if 0 // texdef conversion -void BrushPrimitFaceToFace( face_t *face ){ - // we have parsed brush primitives and need conversion back to standard format - // NOTE: converting back is a quick hack, there's some information lost and we can't do anything about it - // FIXME: if we normalize the texture matrix to a standard 2x2 size, we end up with wrong scaling - // I tried various tweaks, no luck .. seems shifting is lost - brushprimit_texdef_t aux; - ConvertTexMatWithQTexture( &face->brushprimit_texdef, face->pShader->getTexture(), &aux, 0 ); - TexMatToFakeTexCoords( aux.coords, face->texdef.shift, &face->texdef.rotate, face->texdef.scale ); - face->texdef.scale[0] /= 2.0; - face->texdef.scale[1] /= 2.0; -} -#endif - - -#if 0 // texture locking (brush primit) -// TEXTURE LOCKING ----------------------------------------------------------------------------------------------------- -// (Relevant to the editor only?) - -// internally used for texture locking on rotation and flipping -// the general algorithm is the same for both lockings, it's only the geometric transformation part that changes -// so I wanted to keep it in a single function -// if there are more linear transformations that need the locking, going to a C++ or code pointer solution would be best -// (but right now I want to keep brush_primit.cpp striclty C) - -bool txlock_bRotation; - -// rotation locking params -int txl_nAxis; -float txl_fDeg; -Vector3 txl_vOrigin; - -// flip locking params -Vector3 txl_matrix[3]; -Vector3 txl_origin; - -void TextureLockTransformation_BrushPrimit( face_t *f ){ - Vector3 Orig,texS,texT; // axis base of initial plane - // used by transformation algo - Vector3 temp; int j; - Vector3 vRotate; // rotation vector - - Vector3 rOrig,rvecS,rvecT; // geometric transformation of (0,0) (1,0) (0,1) { initial plane axis base } - Vector3 rNormal,rtexS,rtexT; // axis base for the transformed plane - Vector3 lOrig,lvecS,lvecT; // [2] are not used ( but usefull for debugging ) - Vector3 M[3]; - float det; - Vector3 D[2]; - - // compute plane axis base - ComputeAxisBase( f->plane.normal, texS, texT ); - VectorSet( Orig, 0.0f, 0.0f, 0.0f ); - - // compute coordinates of (0,0) (1,0) (0,1) ( expressed in initial plane axis base ) after transformation - // (0,0) (1,0) (0,1) ( expressed in initial plane axis base ) <-> (0,0,0) texS texT ( expressed world axis base ) - // input: Orig, texS, texT (and the global locking params) - // ouput: rOrig, rvecS, rvecT, rNormal - if ( txlock_bRotation ) { - // rotation vector - VectorSet( vRotate, 0.0f, 0.0f, 0.0f ); - vRotate[txl_nAxis] = txl_fDeg; - VectorRotateOrigin( Orig, vRotate, txl_vOrigin, rOrig ); - VectorRotateOrigin( texS, vRotate, txl_vOrigin, rvecS ); - VectorRotateOrigin( texT, vRotate, txl_vOrigin, rvecT ); - // compute normal of plane after rotation - VectorRotate( f->plane.normal, vRotate, rNormal ); - } - else - { - for ( j = 0 ; j < 3 ; j++ ) - rOrig[j] = vector3_dot( vector3_subtracted( Orig, txl_origin ), txl_matrix[j] ) + txl_origin[j]; - for ( j = 0 ; j < 3 ; j++ ) - rvecS[j] = vector3_dot( vector3_subtracted( texS, txl_origin ), txl_matrix[j] ) + txl_origin[j]; - for ( j = 0 ; j < 3 ; j++ ) - rvecT[j] = vector3_dot( vector3_subtracted( texT, txl_origin ), txl_matrix[j] ) + txl_origin[j]; - // we also need the axis base of the target plane, apply the transformation matrix to the normal too.. - for ( j = 0 ; j < 3 ; j++ ) - rNormal[j] = vector3_dot( f->plane.normal, txl_matrix[j] ); - } - - // compute rotated plane axis base - ComputeAxisBase( rNormal, rtexS, rtexT ); - // compute S/T coordinates of the three points in rotated axis base ( in M matrix ) - lOrig[0] = vector3_dot( rOrig, rtexS ); - lOrig[1] = vector3_dot( rOrig, rtexT ); - lvecS[0] = vector3_dot( rvecS, rtexS ); - lvecS[1] = vector3_dot( rvecS, rtexT ); - lvecT[0] = vector3_dot( rvecT, rtexS ); - lvecT[1] = vector3_dot( rvecT, rtexT ); - M[0][0] = lOrig[0]; M[1][0] = lOrig[1]; M[2][0] = 1.0f; - M[0][1] = lvecS[0]; M[1][1] = lvecS[1]; M[2][1] = 1.0f; - M[0][2] = lvecT[0]; M[1][2] = lvecT[1]; M[2][2] = 1.0f; - // fill data vector - D[0][0] = f->brushprimit_texdef.coords[0][2]; - D[0][1] = f->brushprimit_texdef.coords[0][0] + f->brushprimit_texdef.coords[0][2]; - D[0][2] = f->brushprimit_texdef.coords[0][1] + f->brushprimit_texdef.coords[0][2]; - D[1][0] = f->brushprimit_texdef.coords[1][2]; - D[1][1] = f->brushprimit_texdef.coords[1][0] + f->brushprimit_texdef.coords[1][2]; - D[1][2] = f->brushprimit_texdef.coords[1][1] + f->brushprimit_texdef.coords[1][2]; - // solve - det = SarrusDet( M[0], M[1], M[2] ); - f->brushprimit_texdef.coords[0][0] = SarrusDet( D[0], M[1], M[2] ) / det; - f->brushprimit_texdef.coords[0][1] = SarrusDet( M[0], D[0], M[2] ) / det; - f->brushprimit_texdef.coords[0][2] = SarrusDet( M[0], M[1], D[0] ) / det; - f->brushprimit_texdef.coords[1][0] = SarrusDet( D[1], M[1], M[2] ) / det; - f->brushprimit_texdef.coords[1][1] = SarrusDet( M[0], D[1], M[2] ) / det; - f->brushprimit_texdef.coords[1][2] = SarrusDet( M[0], M[1], D[1] ) / det; -} - -// texture locking -// called before the points on the face are actually rotated -void RotateFaceTexture_BrushPrimit( face_t *f, int nAxis, float fDeg, Vector3& vOrigin ){ - // this is a placeholder to call the general texture locking algorithm - txlock_bRotation = true; - txl_nAxis = nAxis; - txl_fDeg = fDeg; - VectorCopy( vOrigin, txl_vOrigin ); - TextureLockTransformation_BrushPrimit( f ); -} - -// compute the new brush primit texture matrix for a transformation matrix and a flip order flag (change plane orientation) -// this matches the select_matrix algo used in select.cpp -// this needs to be called on the face BEFORE any geometric transformation -// it will compute the texture matrix that will represent the same texture on the face after the geometric transformation is done -void ApplyMatrix_BrushPrimit( face_t *f, Vector3 matrix[3], Vector3& origin ){ - // this is a placeholder to call the general texture locking algorithm - txlock_bRotation = false; - VectorCopy( matrix[0], txl_matrix[0] ); - VectorCopy( matrix[1], txl_matrix[1] ); - VectorCopy( matrix[2], txl_matrix[2] ); - VectorCopy( origin, txl_origin ); - TextureLockTransformation_BrushPrimit( f ); -} -#endif - // don't do C==A! void BPMatMul( float A[2][3], float B[2][3], float C[2][3] ){ C[0][0] = A[0][0] * B[0][0] + A[0][1] * B[1][0]; @@ -894,16 +553,6 @@ void BPMatMul( float A[2][3], float B[2][3], float C[2][3] ){ C[1][2] = A[1][0] * B[0][2] + A[1][1] * B[1][2] + A[1][2]; } -void BPMatDump( float A[2][3] ){ - globalOutputStream() << "" << A[0][0] - << " " << A[0][1] - << " " << A[0][2] - << "\n" << A[1][0] - << " " << A[1][2] - << " " << A[1][2] - << "\n0 0 1\n"; -} - void BPMatRotate( float A[2][3], float theta ){ float m[2][3]; float aux[2][3]; @@ -916,84 +565,6 @@ void BPMatRotate( float A[2][3], float theta ){ BPMatCopy( aux,A ); } -#if 0 // camera-relative texture shift -// get the relative axes of the current texturing -void BrushPrimit_GetRelativeAxes( face_t *f, Vector3& vecS, Vector3& vecT ){ - float vS[2],vT[2]; - // first we compute them as expressed in plane axis base - // BP matrix has coordinates of plane axis base expressed in geometric axis base - // so we use the line vectors - vS[0] = f->brushprimit_texdef.coords[0][0]; - vS[1] = f->brushprimit_texdef.coords[0][1]; - vT[0] = f->brushprimit_texdef.coords[1][0]; - vT[1] = f->brushprimit_texdef.coords[1][1]; - // now compute those vectors in geometric space - Vector3 texS, texT; // axis base of the plane (geometric) - ComputeAxisBase( f->plane.normal, texS, texT ); - // vecS[] = vS[0].texS[] + vS[1].texT[] - // vecT[] = vT[0].texS[] + vT[1].texT[] - vecS[0] = vS[0] * texS[0] + vS[1] * texT[0]; - vecS[1] = vS[0] * texS[1] + vS[1] * texT[1]; - vecS[2] = vS[0] * texS[2] + vS[1] * texT[2]; - vecT[0] = vT[0] * texS[0] + vT[1] * texT[0]; - vecT[1] = vT[0] * texS[1] + vT[1] * texT[1]; - vecT[2] = vT[0] * texS[2] + vT[1] * texT[2]; -} - -// brush primitive texture adjustments, use the camera view to map adjustments -// ShiftTextureRelative_BrushPrimit ( s , t ) will shift relative to the texture -void ShiftTextureRelative_Camera( face_t *f, int x, int y ){ - Vector3 vecS, vecT; - float XY[2]; // the values we are going to send for translation - float sgn[2]; // +1 or -1 - int axis[2]; - CamWnd* pCam; - - // get the two relative texture axes for the current texturing - BrushPrimit_GetRelativeAxes( f, vecS, vecT ); - - // center point of the face, project it on the camera space - Vector3 C; - VectorClear( C ); - int i; - for ( i = 0; i < f->face_winding->numpoints; i++ ) - { - VectorAdd( C,f->face_winding->point_at( i ),C ); - } - VectorScale( C,1.0 / f->face_winding->numpoints,C ); - - pCam = g_pParentWnd->GetCamWnd(); - pCam->MatchViewAxes( C, vecS, axis[0], sgn[0] ); - pCam->MatchViewAxes( C, vecT, axis[1], sgn[1] ); - - // this happens when the two directions can't be mapped on two different directions on the screen - // then the move will occur against a single axis - // (i.e. the user is not positioned well enough to send understandable shift commands) - // NOTE: in most cases this warning is not very relevant because the user would use one of the two axes - // for which the solution is easy (the other one being unknown) - // so this warning could be removed - if ( axis[0] == axis[1] ) { - globalOutputStream() << "Warning: degenerate in ShiftTextureRelative_Camera\n"; - } - - // compute the X Y geometric increments - // those geometric increments will be applied along the texture axes (the ones we computed above) - XY[0] = 0; - XY[1] = 0; - if ( x != 0 ) { - // moving right/left - XY[axis[0]] += sgn[0] * x; - } - if ( y != 0 ) { - XY[axis[1]] += sgn[1] * y; - } - // we worked out a move along vecS vecT, and we now it's geometric amplitude - // apply it - ShiftTextureRelative_BrushPrimit( f, XY[0], XY[1] ); -} -#endif - - void BPTexdef_Assign( brushprimit_texdef_t& bp_td, const brushprimit_texdef_t& bp_other ){ bp_td = bp_other; } @@ -1240,16 +811,6 @@ inline Matrix4 matrix4_reflection_for_plane45( const Plane3& plane, const Vector second = vector3_negated( second ); } -#if 0 - globalOutputStream() << "normal: "; - print_vector3( plane.normal() ); - - globalOutputStream() << "from: "; - print_vector3( first ); - - globalOutputStream() << "to: "; - print_vector3( second ); -#endif Matrix4 swap = matrix4_swap_axes( first, second ); @@ -1310,16 +871,6 @@ void Texdef_transformLocked( TextureProjection& projection, std::size_t width, s // to the transformed projection axis chosen for the original normal. // This happens when the projection axis is ambiguous - e.g. for the plane // 'X == Y' the projection axis could be either X or Y. - //globalOutputStream() << "flipped\n"; -#if 0 - globalOutputStream() << "projection off by 90\n"; - globalOutputStream() << "normal: "; - print_vector3( plane.normal() ); - globalOutputStream() << "original projection: "; - print_vector3( originalProjectionAxis ); - globalOutputStream() << "transformed projection: "; - print_vector3( transformedProjectionAxis ); -#endif Matrix4 identityCorrected = matrix4_reflection_for_plane45( plane, originalProjectionAxis, transformedProjectionAxis ); diff --git a/radiant/brushmanip.cpp b/radiant/brushmanip.cpp index c49464be..cf6e932c 100644 --- a/radiant/brushmanip.cpp +++ b/radiant/brushmanip.cpp @@ -293,20 +293,6 @@ void Brush_ConstructRock( Brush& brush, const AABB& bounds, std::size_t sides, c planepts[1] = vector3_added( planepts[0], vector3_scaled( planepts[1], radius ) ); planepts[2] = vector3_added( planepts[0], vector3_scaled( planepts[2], radius ) ); -#if 0 - // make sure the orientation is right - if ( vector3_dot( vector3_subtracted( planepts[0], mid ), vector3_cross( vector3_subtracted( planepts[1], mid ), vector3_subtracted( planepts[2], mid ) ) ) > 0 ) { - Vector3 h; - h = planepts[1]; - planepts[1] = planepts[2]; - planepts[2] = h; - globalOutputStream() << "flip\n"; - } - else{ - globalOutputStream() << "no flip\n"; - } -#endif - brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection ); } } @@ -1035,218 +1021,6 @@ void BrushFilters_construct(){ add_brush_filter( g_filter_brush_decals, EXCLUDE_DECALS ); } -#if 0 - -void normalquantisation_draw(){ - glPointSize( 1 ); - glBegin( GL_POINTS ); - for ( std::size_t i = 0; i <= c_quantise_normal; ++i ) - { - for ( std::size_t j = 0; j <= c_quantise_normal; ++j ) - { - Normal3f vertex( normal3f_normalised( Normal3f( - static_cast( c_quantise_normal - j - i ), - static_cast( i ), - static_cast( j ) - ) ) ); - VectorScale( normal3f_to_array( vertex ), 64.f, normal3f_to_array( vertex ) ); - glVertex3fv( normal3f_to_array( vertex ) ); - vertex.x = -vertex.x; - glVertex3fv( normal3f_to_array( vertex ) ); - } - } - glEnd(); -} - -class RenderableNormalQuantisation : public OpenGLRenderable -{ -public: -void render( RenderStateFlags state ) const { - normalquantisation_draw(); -} -}; - -const float g_test_quantise_normal = 1.f / static_cast( 1 << 3 ); - -class TestNormalQuantisation -{ -void check_normal( const Normal3f& normal, const Normal3f& other ){ - spherical_t spherical = spherical_from_normal3f( normal ); - double longditude = RAD2DEG( spherical.longditude ); - double latitude = RAD2DEG( spherical.latitude ); - double x = cos( spherical.longditude ) * sin( spherical.latitude ); - double y = sin( spherical.longditude ) * sin( spherical.latitude ); - double z = cos( spherical.latitude ); - - ASSERT_MESSAGE( normal3f_dot( normal, other ) > 0.99, "bleh" ); -} - -void test_normal( const Normal3f& normal ){ - Normal3f test = normal3f_from_spherical( spherical_from_normal3f( normal ) ); - check_normal( normal, test ); - - EOctant octant = normal3f_classify_octant( normal ); - Normal3f folded = normal3f_fold_octant( normal, octant ); - ESextant sextant = normal3f_classify_sextant( folded ); - folded = normal3f_fold_sextant( folded, sextant ); - - double scale = static_cast( c_quantise_normal ) / ( folded.x + folded.y + folded.z ); - - double zbits = folded.z * scale; - double ybits = folded.y * scale; - - std::size_t zbits_q = static_cast( zbits ); - std::size_t ybits_q = static_cast( ybits ); - - ASSERT_MESSAGE( zbits_q <= ( c_quantise_normal / 8 ) * 3, "bleh" ); - ASSERT_MESSAGE( ybits_q <= ( c_quantise_normal / 2 ), "bleh" ); - ASSERT_MESSAGE( zbits_q + ( ( c_quantise_normal / 2 ) - ybits_q ) <= ( c_quantise_normal / 2 ), "bleh" ); - - std::size_t y_t = ( zbits_q < ( c_quantise_normal / 4 ) ) ? ybits_q : ( c_quantise_normal / 2 ) - ybits_q; - std::size_t z_t = ( zbits_q < ( c_quantise_normal / 4 ) ) ? zbits_q : ( c_quantise_normal / 2 ) - zbits_q; - std::size_t index = ( c_quantise_normal / 4 ) * y_t + z_t; - ASSERT_MESSAGE( index <= ( c_quantise_normal / 4 ) * ( c_quantise_normal / 2 ), "bleh" ); - - Normal3f tmp( c_quantise_normal - zbits_q - ybits_q, ybits_q, zbits_q ); - tmp = normal3f_normalised( tmp ); - - Normal3f unfolded = normal3f_unfold_octant( normal3f_unfold_sextant( tmp, sextant ), octant ); - - check_normal( normal, unfolded ); - - double dot = normal3f_dot( normal, unfolded ); - float length = VectorLength( normal3f_to_array( unfolded ) ); - float inv_length = 1 / length; - - Normal3f quantised = normal3f_quantised( normal ); - check_normal( normal, quantised ); -} -void test2( const Normal3f& normal, const Normal3f& other ){ - if ( normal3f_quantised( normal ) != normal3f_quantised( other ) ) { - int bleh = 0; - } -} - -static Normal3f normalise( float x, float y, float z ){ - return normal3f_normalised( Normal3f( x, y, z ) ); -} - -float vec_rand(){ - return static_cast( rand() - ( RAND_MAX / 2 ) ); -} - -Normal3f normal3f_rand(){ - return normalise( vec_rand(), vec_rand(), vec_rand() ); -} - -public: -TestNormalQuantisation(){ - for ( int i = 4096; i > 0; --i ) - test_normal( normal3f_rand() ); - - test_normal( normalise( 1, 0, 0 ) ); - test_normal( normalise( 0, 1, 0 ) ); - test_normal( normalise( 0, 0, 1 ) ); - test_normal( normalise( 1, 1, 0 ) ); - test_normal( normalise( 1, 0, 1 ) ); - test_normal( normalise( 0, 1, 1 ) ); - - test_normal( normalise( 10000, 10000, 10000 ) ); - test_normal( normalise( 10000, 10000, 10001 ) ); - test_normal( normalise( 10000, 10000, 10002 ) ); - test_normal( normalise( 10000, 10000, 10010 ) ); - test_normal( normalise( 10000, 10000, 10020 ) ); - test_normal( normalise( 10000, 10000, 10030 ) ); - test_normal( normalise( 10000, 10000, 10100 ) ); - test_normal( normalise( 10000, 10000, 10101 ) ); - test_normal( normalise( 10000, 10000, 10102 ) ); - test_normal( normalise( 10000, 10000, 10200 ) ); - test_normal( normalise( 10000, 10000, 10201 ) ); - test_normal( normalise( 10000, 10000, 10202 ) ); - test_normal( normalise( 10000, 10000, 10203 ) ); - test_normal( normalise( 10000, 10000, 10300 ) ); - - - test2( normalise( 10000, 10000, 10000 ), normalise( 10000, 10000, 10001 ) ); - test2( normalise( 10000, 10000, 10001 ), normalise( 10000, 10001, 10000 ) ); -} -}; - -TestNormalQuantisation g_testNormalQuantisation; - - -#endif - -#if 0 -class TestSelectableObserver : public observer_template -{ -public: -void notify( const Selectable& arguments ){ - bool bleh = arguments.isSelected(); -} -}; - -inline void test_bleh(){ - TestSelectableObserver test; - ObservableSelectableInstance< SingleObservable< SelectionChangeCallback > > bleh; - bleh.attach( test ); - bleh.setSelected( true ); - bleh.detach( test ); -} - -class TestBleh -{ -public: -TestBleh(){ - test_bleh(); -} -}; - -const TestBleh testbleh; -#endif - - -#if 0 -class TestRefcountedString -{ -public: -TestRefcountedString(){ - { - // copy construct - SmartString string1( "string1" ); - SmartString string2( string1 ); - SmartString string3( string2 ); - } - { - // refcounted assignment - SmartString string1( "string1" ); - SmartString string2( "string2" ); - string1 = string2; - } - { - // copy assignment - SmartString string1( "string1" ); - SmartString string2( "string2" ); - string1 = string2.c_str(); - } - { - // self-assignment - SmartString string1( "string1" ); - string1 = string1; - } - { - // self-assignment via another reference - SmartString string1( "string1" ); - SmartString string2( string1 ); - string1 = string2; - } -} -}; - -const TestRefcountedString g_testRefcountedString; - -#endif - void Select_MakeDetail(){ UndoableCommand undo( "brushSetDetail" ); Scene_BrushSetDetail_Selected( GlobalSceneGraph(), true ); diff --git a/radiant/build.cpp b/radiant/build.cpp index 073e0ddf..bdd6416d 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -462,19 +462,6 @@ void build_error_undefined_tool( const char* build, const char* tool ){ } void project_verify( Project& project, Tools& tools ){ -#if 0 - for ( Project::iterator i = project.begin(); i != project.end(); ++i ) - { - Build& build = ( *i ).second; - for ( Build::iterator j = build.begin(); j != build.end(); ++j ) - { - Tools::iterator k = tools.find( ( *j ).first ); - if ( k == g_build_tools.end() ) { - build_error_undefined_tool( ( *i ).first.c_str(), ( *j ).first.c_str() ); - } - } - } -#endif } void build_run( const char* name, CommandListener& listener ){ diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 9e97ce96..a9f19224 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -656,10 +656,6 @@ class CamWnd View m_view; camera_t m_Camera; RadiantCameraView m_cameraview; -#if 0 -int m_PositionDragCursorX; -int m_PositionDragCursorY; -#endif guint m_freemove_handle_focusout; @@ -692,11 +688,9 @@ CamWnd(); bool m_drawing; void queue_draw(){ - //ASSERT_MESSAGE(!m_drawing, "CamWnd::queue_draw(): called while draw is already in progress"); if ( m_drawing ) { return; } - //globalOutputStream() << "queue... "; m_deferredDraw.draw(); } void draw(); @@ -815,15 +809,6 @@ gboolean disable_freelook_button_press( GtkWidget* widget, GdkEventButton* event return FALSE; } -#if 0 -gboolean mousecontrol_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ - if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { - Cam_MouseControl( camwnd->getCamera(), event->x, widget->allocation.height - 1 - event->y ); - } - return FALSE; -} -#endif - void camwnd_update_xor_rectangle( CamWnd& self, rect_t area ){ if ( GTK_WIDGET_VISIBLE( self.m_gl_widget ) ) { self.m_XORRectangle.set( rectangle_from_area( area.min, area.max, self.getCamera().width, self.getCamera().height ) ); @@ -1243,39 +1228,6 @@ void CamWnd::Cam_ChangeFloor( bool up ){ } -#if 0 - -// button_press -Sys_GetCursorPos( &m_PositionDragCursorX, &m_PositionDragCursorY ); - -// motion -if ( ( m_bFreeMove && ( buttons == ( RAD_CONTROL | RAD_SHIFT ) ) ) - || ( !m_bFreeMove && ( buttons == ( RAD_RBUTTON | RAD_CONTROL ) ) ) ) { - Cam_PositionDrag(); - CamWnd_Update( camwnd ); - CameraMovedNotify(); - return; -} - -void CamWnd::Cam_PositionDrag(){ - int x, y; - - Sys_GetCursorPos( GTK_WINDOW( m_gl_widget ), &x, &y ); - if ( x != m_PositionDragCursorX || y != m_PositionDragCursorY ) { - x -= m_PositionDragCursorX; - vector3_add( m_Camera.origin, vector3_scaled( m_Camera.vright, x ) ); - y -= m_PositionDragCursorY; - m_Camera.origin[2] -= y; - Camera_updateModelview(); - CamWnd_Update( camwnd ); - CameraMovedNotify(); - - Sys_SetCursorPos( GTK_WINDOW( m_parent ), m_PositionDragCursorX, m_PositionDragCursorY ); - } -} -#endif - - // NOTE TTimo if there's an OS-level focus out of the application // then we can release the camera cursor grab static gboolean camwindow_freemove_focusout( GtkWidget* widget, GdkEventFocus* event, gpointer data ){ @@ -1409,10 +1361,6 @@ ToggleItem g_show_stats( g_show_stats_callback ); void CamWnd::Cam_Draw(){ glViewport( 0, 0, m_Camera.width, m_Camera.height ); -#if 0 - GLint viewprt[4]; - glGetIntegerv( GL_VIEWPORT, viewprt ); -#endif // enable depth buffer writes glDepthMask( GL_TRUE ); diff --git a/radiant/commands.cpp b/radiant/commands.cpp index f608ea49..44a5e2e3 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -245,12 +245,6 @@ gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gp if ( !dialog.m_waiting_for_key ) { return false; } - -#if 0 - if ( event->is_modifier ) { - return false; - } -#else switch ( event->keyval ) { case GDK_Shift_L: @@ -269,7 +263,6 @@ gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gp case GDK_Hyper_R: return false; } -#endif dialog.m_waiting_for_key = false; diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index e98cac92..1532839f 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -503,23 +503,6 @@ void Dialog::addCombo( GtkWidget* vbox, const char* name, int& data, StringArray } void Dialog::addSlider( GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){ -#if 0 - if ( draw_value == FALSE ) { - GtkWidget* hbox2 = gtk_hbox_new( FALSE, 0 ); - gtk_widget_show( hbox2 ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 ); - { - GtkWidget* label = gtk_label_new( low ); - gtk_widget_show( label ); - gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 ); - } - { - GtkWidget* label = gtk_label_new( high ); - gtk_widget_show( label ); - gtk_box_pack_end( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 ); - } - } -#endif // adjustment GtkObject* adj = gtk_adjustment_new( value, lower, upper, step_increment, page_increment, 0 ); diff --git a/radiant/entity.cpp b/radiant/entity.cpp index ab3243b0..c7cf0dac 100644 --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@ -285,12 +285,7 @@ AABB Doom3Light_getBounds( const AABB& workzone ){ int g_iLastLightIntensity; void Entity_createFromSelection( const char* name, const Vector3& origin ){ -#if 0 - if ( string_equal_nocase( name, "worldspawn" ) ) { - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "Can't create an entity with worldspawn.", "info" ); - return; - } -#endif + EntityClass* entityClass = GlobalEntityClassManager().findOrInsert( name, true ); @@ -388,45 +383,6 @@ void Entity_createFromSelection( const char* name, const Vector3& origin ){ } } -#if 0 -bool DoNormalisedColor( Vector3& color ){ - if ( !color_dialog( GTK_WIDGET( MainFrame_getWindow() ), color ) ) { - return false; - } - /* - ** scale colors so that at least one component is at 1.0F - */ - - float largest = 0.0F; - - if ( color[0] > largest ) { - largest = color[0]; - } - if ( color[1] > largest ) { - largest = color[1]; - } - if ( color[2] > largest ) { - largest = color[2]; - } - - if ( largest == 0.0F ) { - color[0] = 1.0F; - color[1] = 1.0F; - color[2] = 1.0F; - } - else - { - float scaler = 1.0F / largest; - - color[0] *= scaler; - color[1] *= scaler; - color[2] *= scaler; - } - - return true; -} -#endif - void NormalizeColor( Vector3& color ){ // scale colors so that at least one component is at 1.0F diff --git a/radiant/error.cpp b/radiant/error.cpp index fda7f79f..8125df38 100644 --- a/radiant/error.cpp +++ b/radiant/error.cpp @@ -107,23 +107,6 @@ void Error( const char *error, ... ){ } #endif - -#if 0 - // we need to have a current context to call glError() - if ( g_glwindow_globals.d_glBase != 0 ) { - // glGetError .. can record several errors, clears after calling - //++timo TODO: be able to deal with several errors if necessary, for now I'm just warning about pending error messages - // NOTE: forget that, most boards don't seem to follow the OpenGL standard - GLenum iGLError = glGetError(); - if ( iGLError != GL_NO_ERROR ) { - // use our own gluErrorString - strcat( text, "gluErrorString: " ); - strcat( text, (char*)gluErrorString( iGLError ) ); - strcat( text, "\n" ); - } - } -#endif - strcat( text, "An unrecoverable error has occured.\n" ); ERROR_MESSAGE( text ); diff --git a/radiant/main.cpp b/radiant/main.cpp index c669aba4..a196adfe 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -215,16 +215,6 @@ void error_redirect( const gchar *domain, GLogLevelFlags log_level, const gchar ERROR_MESSAGE( "GTK+ error: " << buf ); } -#if defined ( _DEBUG ) && defined ( WIN32 ) && defined ( _MSC_VER ) -#include "crtdbg.h" -#endif - -void crt_init(){ -#if defined ( _DEBUG ) && defined ( WIN32 ) && defined ( _MSC_VER ) - _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); -#endif -} - class Lock { bool m_locked; @@ -377,9 +367,6 @@ bool check_version(){ // let's leave it disabled in debug mode in any case // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=431 #ifndef _DEBUG -#define CHECK_VERSION -#endif -#ifdef CHECK_VERSION // locate and open RADIANT_MAJOR and RADIANT_MINOR bool bVerIsGood = true; { @@ -544,8 +531,6 @@ void user_shortcuts_save(){ } int main( int argc, char* argv[] ){ - crt_init(); - streams_init(); #ifdef WIN32 diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 0e430f11..1b688609 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -342,19 +342,6 @@ void setEnginePath( const char* path ){ StringOutputStream buffer( 256 ); buffer << DirectoryCleaned( path ); if ( !path_equal( buffer.c_str(), g_strEnginePath.c_str() ) ) { -#if 0 - while ( !ConfirmModified( "Paths Changed" ) ) - { - if ( Map_Unnamed( g_map ) ) { - Map_SaveAs(); - } - else - { - Map_Save(); - } - } - Map_RegionOff(); -#endif ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Changing Engine Path" ); @@ -1057,11 +1044,6 @@ void ComponentMode_SelectionChanged( const Selectable& selectable ){ } void SelectEdgeMode(){ -#if 0 - if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) { - GlobalSelectionSystem().Select( false ); - } -#endif if ( EdgeMode() ) { SelectionSystem_DefaultMode(); @@ -1081,11 +1063,6 @@ void SelectEdgeMode(){ } void SelectVertexMode(){ -#if 0 - if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) { - GlobalSelectionSystem().Select( false ); - } -#endif if ( VertexMode() ) { SelectionSystem_DefaultMode(); @@ -1105,11 +1082,6 @@ void SelectVertexMode(){ } void SelectFaceMode(){ -#if 0 - if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) { - GlobalSelectionSystem().Select( false ); - } -#endif if ( FaceMode() ) { SelectionSystem_DefaultMode(); @@ -1811,12 +1783,6 @@ GtkMenuItem* create_file_menu(){ create_menu_item_with_mnemonic( menu, "_New Map", "NewMap" ); menu_separator( menu ); -#if 0 - //++timo temporary experimental stuff for sleep mode.. - create_menu_item_with_mnemonic( menu, "_Sleep", "Sleep" ); - menu_separator( menu ); - // end experimental -#endif create_menu_item_with_mnemonic( menu, "_Open...", "OpenMap" ); @@ -2108,15 +2074,11 @@ GtkMenuItem* create_misc_menu(){ menu_tearoff( menu ); } -#if 0 - create_menu_item_with_mnemonic( menu, "_Benchmark", FreeCaller() ); -#endif gtk_container_add( GTK_CONTAINER( menu ), GTK_WIDGET( create_colours_menu() ) ); create_menu_item_with_mnemonic( menu, "Find brush...", "FindBrush" ); create_menu_item_with_mnemonic( menu, "Map Info...", "MapInfo" ); // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394 -// create_menu_item_with_mnemonic(menu, "_Print XY View", FreeCaller()); create_menu_item_with_mnemonic( menu, "_Background select", FreeCaller() ); return misc_menu_item; } @@ -2434,48 +2396,6 @@ GtkWidget* create_main_statusbar( GtkWidget *pStatusLabel[c_count_status] ){ return GTK_WIDGET( table ); } -#if 0 - - -WidgetFocusPrinter g_mainframeWidgetFocusPrinter( "mainframe" ); - -class WindowFocusPrinter -{ -const char* m_name; - -static gboolean frame_event( GtkWidget *widget, GdkEvent* event, WindowFocusPrinter* self ){ - globalOutputStream() << self->m_name << " frame_event\n"; - return FALSE; -} -static gboolean keys_changed( GtkWidget *widget, WindowFocusPrinter* self ){ - globalOutputStream() << self->m_name << " keys_changed\n"; - return FALSE; -} -static gboolean notify( GtkWindow* window, gpointer dummy, WindowFocusPrinter* self ){ - if ( gtk_window_is_active( window ) ) { - globalOutputStream() << self->m_name << " takes toplevel focus\n"; - } - else - { - globalOutputStream() << self->m_name << " loses toplevel focus\n"; - } - return FALSE; -} -public: -WindowFocusPrinter( const char* name ) : m_name( name ){ -} -void connect( GtkWindow* toplevel_window ){ - g_signal_connect( G_OBJECT( toplevel_window ), "notify::has_toplevel_focus", G_CALLBACK( notify ), this ); - g_signal_connect( G_OBJECT( toplevel_window ), "notify::is_active", G_CALLBACK( notify ), this ); - g_signal_connect( G_OBJECT( toplevel_window ), "keys_changed", G_CALLBACK( keys_changed ), this ); - g_signal_connect( G_OBJECT( toplevel_window ), "frame_event", G_CALLBACK( frame_event ), this ); -} -}; - -WindowFocusPrinter g_mainframeFocusPrinter( "mainframe" ); - -#endif - class MainWindowActive { static gboolean notify( GtkWindow* window, gpointer dummy, MainWindowActive* self ){ @@ -2569,107 +2489,8 @@ void MainFrame::SetActiveXY( XYWnd* p ){ } -void MainFrame::ReleaseContexts(){ -#if 0 - if ( m_pXYWnd ) { - m_pXYWnd->DestroyContext(); - } - if ( m_pYZWnd ) { - m_pYZWnd->DestroyContext(); - } - if ( m_pXZWnd ) { - m_pXZWnd->DestroyContext(); - } - if ( m_pCamWnd ) { - m_pCamWnd->DestroyContext(); - } - if ( m_pTexWnd ) { - m_pTexWnd->DestroyContext(); - } - if ( m_pZWnd ) { - m_pZWnd->DestroyContext(); - } -#endif -} - -void MainFrame::CreateContexts(){ -#if 0 - if ( m_pCamWnd ) { - m_pCamWnd->CreateContext(); - } - if ( m_pXYWnd ) { - m_pXYWnd->CreateContext(); - } - if ( m_pYZWnd ) { - m_pYZWnd->CreateContext(); - } - if ( m_pXZWnd ) { - m_pXZWnd->CreateContext(); - } - if ( m_pTexWnd ) { - m_pTexWnd->CreateContext(); - } - if ( m_pZWnd ) { - m_pZWnd->CreateContext(); - } -#endif -} - -#ifdef _DEBUG -//#define DBG_SLEEP -#endif void MainFrame::OnSleep(){ -#if 0 - m_bSleeping ^= 1; - if ( m_bSleeping ) { - // useful when trying to debug crashes in the sleep code - globalOutputStream() << "Going into sleep mode..\n"; - - globalOutputStream() << "Dispatching sleep msg..."; - DispatchRadiantMsg( RADIANT_SLEEP ); - globalOutputStream() << "Done.\n"; - - gtk_window_iconify( m_window ); - GlobalSelectionSystem().setSelectedAll( false ); - - GlobalShaderCache().unrealise(); - Shaders_Free(); - GlobalOpenGL_debugAssertNoErrors(); - ScreenUpdates_Disable(); - - // release contexts - globalOutputStream() << "Releasing contexts..."; - ReleaseContexts(); - globalOutputStream() << "Done.\n"; - } - else - { - globalOutputStream() << "Waking up\n"; - - gtk_window_deiconify( m_window ); - - // create contexts - globalOutputStream() << "Creating contexts..."; - CreateContexts(); - globalOutputStream() << "Done.\n"; - - globalOutputStream() << "Making current on camera..."; - m_pCamWnd->MakeCurrent(); - globalOutputStream() << "Done.\n"; - - globalOutputStream() << "Reloading shaders..."; - Shaders_Load(); - GlobalShaderCache().realise(); - globalOutputStream() << "Done.\n"; - - ScreenUpdates_Enable(); - - globalOutputStream() << "Dispatching wake msg..."; - DispatchRadiantMsg( RADIANT_WAKEUP ); - globalOutputStream() << "Done\n"; - } -#endif } @@ -2739,11 +2560,6 @@ void MainFrame::Create(){ m_position_tracker.connect( window ); -#if 0 - g_mainframeWidgetFocusPrinter.connect( window ); - g_mainframeFocusPrinter.connect( window ); -#endif - g_MainWindowActive.connect( window ); GetPlugInMgr().Init( GTK_WIDGET( window ) ); diff --git a/radiant/mainframe.h b/radiant/mainframe.h index 0b008a6b..a587319c 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -129,9 +129,6 @@ CamWnd* GetCamWnd(){ return m_pCamWnd; } -void ReleaseContexts(); -void CreateContexts(); - EViewStyle CurrentStyle(){ return m_nCurrentStyle; }; diff --git a/radiant/map.cpp b/radiant/map.cpp index fae78de3..b61a038a 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -1120,11 +1120,7 @@ void post( scene::Node& node ) const { void Map_Traverse_Selected( scene::Node& root, const scene::Traversable::Walker& walker ){ scene::Traversable* traversable = Node_getTraversable( root ); if ( traversable != 0 ) { -#if 0 - traversable->traverse( ExcludeWalker( walker, SelectionExcluder() ) ); -#else traversable->traverse( IncludeSelectedWalker( walker ) ); -#endif } } @@ -1171,7 +1167,6 @@ void Map_RenameAbsolute( const char* absolute ){ resource->setNode( clone.get_pointer() ); { - //ScopeTimer timer("clone subgraph"); Node_getTraversable( GlobalSceneGraph().root() )->traverse( CloneAll( clone ) ); } diff --git a/radiant/patch.cpp b/radiant/patch.cpp index b31def46..2ea79216 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -278,30 +278,6 @@ void Patch::UpdateCachedData(){ } } -#if 0 - { - Array::iterator first = m_tess.m_indices.begin(); - for ( std::size_t s = 0; s < m_tess.m_numStrips; s++ ) - { - Array::iterator last = first + m_tess.m_lenStrips; - - for ( Array::iterator i( first ); i + 2 != last; i += 2 ) - { - ArbitraryMeshTriangle_sumTangents( m_tess.m_vertices[*( i + 0 )], m_tess.m_vertices[*( i + 1 )], m_tess.m_vertices[*( i + 2 )] ); - ArbitraryMeshTriangle_sumTangents( m_tess.m_vertices[*( i + 2 )], m_tess.m_vertices[*( i + 1 )], m_tess.m_vertices[*( i + 3 )] ); - } - - first = last; - } - - for ( Array::iterator i = m_tess.m_vertices.begin(); i != m_tess.m_vertices.end(); ++i ) - { - vector3_normalise( reinterpret_cast( ( *i ).tangent ) ); - vector3_normalise( reinterpret_cast( ( *i ).bitangent ) ); - } - } -#endif - SceneChangeNotify(); } @@ -1505,49 +1481,6 @@ void Patch::RenderDebug( RenderStateFlags state ) const { } } -void RenderablePatchSolid::RenderNormals() const { - const std::size_t width = m_tess.m_numStrips + 1; - const std::size_t height = m_tess.m_lenStrips >> 1; - glBegin( GL_LINES ); - for ( std::size_t i = 0; i < width; i++ ) - { - for ( std::size_t j = 0; j < height; j++ ) - { - { - Vector3 vNormal( - vector3_added( - vertex3f_to_vector3( ( m_tess.m_vertices.data() + ( j * width + i ) )->vertex ), - vector3_scaled( normal3f_to_vector3( ( m_tess.m_vertices.data() + ( j * width + i ) )->normal ), 8 ) - ) - ); - glVertex3fv( vertex3f_to_array( ( m_tess.m_vertices.data() + ( j * width + i ) )->vertex ) ); - glVertex3fv( &vNormal[0] ); - } - { - Vector3 vNormal( - vector3_added( - vertex3f_to_vector3( ( m_tess.m_vertices.data() + ( j * width + i ) )->vertex ), - vector3_scaled( normal3f_to_vector3( ( m_tess.m_vertices.data() + ( j * width + i ) )->tangent ), 8 ) - ) - ); - glVertex3fv( vertex3f_to_array( ( m_tess.m_vertices.data() + ( j * width + i ) )->vertex ) ); - glVertex3fv( &vNormal[0] ); - } - { - Vector3 vNormal( - vector3_added( - vertex3f_to_vector3( ( m_tess.m_vertices.data() + ( j * width + i ) )->vertex ), - vector3_scaled( normal3f_to_vector3( ( m_tess.m_vertices.data() + ( j * width + i ) )->bitangent ), 8 ) - ) - ); - glVertex3fv( vertex3f_to_array( ( m_tess.m_vertices.data() + ( j * width + i ) )->vertex ) ); - glVertex3fv( &vNormal[0] ); - } - } - } - glEnd(); -} - #define DEGEN_0a 0x01 #define DEGEN_1a 0x02 #define DEGEN_2a 0x04 diff --git a/radiant/patch.h b/radiant/patch.h index a1f1d272..7a11eb9c 100644 --- a/radiant/patch.h +++ b/radiant/patch.h @@ -280,46 +280,33 @@ PatchTesselation& m_tess; public: RenderablePatchSolid( PatchTesselation& tess ) : m_tess( tess ){ } -void RenderNormals() const; void render( RenderStateFlags state ) const { -#if 0 - if ( ( state & RENDER_FILL ) == 0 ) { - RenderablePatchWireframe( m_tess ).render( state ); - } - else -#endif - { - if ( ( state & RENDER_BUMP ) != 0 ) { - if ( GlobalShaderCache().useShaderLanguage() ) { - glNormalPointer( GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->normal ); - glVertexAttribPointerARB( c_attr_TexCoord0, 2, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->texcoord ); - glVertexAttribPointerARB( c_attr_Tangent, 3, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->tangent ); - glVertexAttribPointerARB( c_attr_Binormal, 3, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->bitangent ); - } - else - { - glVertexAttribPointerARB( 11, 3, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->normal ); - glVertexAttribPointerARB( 8, 2, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->texcoord ); - glVertexAttribPointerARB( 9, 3, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->tangent ); - glVertexAttribPointerARB( 10, 3, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->bitangent ); - } - } - else - { + if ( ( state & RENDER_BUMP ) != 0 ) { + if ( GlobalShaderCache().useShaderLanguage() ) { glNormalPointer( GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->normal ); - glTexCoordPointer( 2, GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->texcoord ); + glVertexAttribPointerARB( c_attr_TexCoord0, 2, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->texcoord ); + glVertexAttribPointerARB( c_attr_Tangent, 3, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->tangent ); + glVertexAttribPointerARB( c_attr_Binormal, 3, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->bitangent ); } - glVertexPointer( 3, GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->vertex ); - const RenderIndex* strip_indices = m_tess.m_indices.data(); - for ( std::size_t i = 0; i < m_tess.m_numStrips; i++, strip_indices += m_tess.m_lenStrips ) + else { - glDrawElements( GL_QUAD_STRIP, GLsizei( m_tess.m_lenStrips ), RenderIndexTypeID, strip_indices ); + glVertexAttribPointerARB( 11, 3, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->normal ); + glVertexAttribPointerARB( 8, 2, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->texcoord ); + glVertexAttribPointerARB( 9, 3, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->tangent ); + glVertexAttribPointerARB( 10, 3, GL_FLOAT, 0, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->bitangent ); } } - -#if defined( _DEBUG ) - RenderNormals(); -#endif + else + { + glNormalPointer( GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->normal ); + glTexCoordPointer( 2, GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->texcoord ); + } + glVertexPointer( 3, GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_tess.m_vertices.data()->vertex ); + const RenderIndex* strip_indices = m_tess.m_indices.data(); + for ( std::size_t i = 0; i < m_tess.m_numStrips; i++, strip_indices += m_tess.m_lenStrips ) + { + glDrawElements( GL_QUAD_STRIP, GLsizei( m_tess.m_lenStrips ), RenderIndexTypeID, strip_indices ); + } } }; @@ -716,7 +703,6 @@ void snapto( float snap ){ void RenderDebug( RenderStateFlags state ) const; -void RenderNormals( RenderStateFlags state ) const; void pushElement( const XMLElement& element ){ switch ( m_xml_state.back().state() ) @@ -1432,28 +1418,6 @@ void update_selected() const { } } -#if 0 -void render( Renderer& renderer, const VolumeTest& volume ) const { - if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent - && m_selectable.isSelected() ) { - renderer.Highlight( Renderer::eFace, false ); - - m_patch.render( renderer, volume, localToWorld() ); - - if ( GlobalSelectionSystem().ComponentMode() == SelectionSystem::eVertex ) { - renderer.Highlight( Renderer::ePrimitive, false ); - - m_patch.render_component( renderer, volume, localToWorld() ); - - renderComponentsSelected( renderer, volume ); - } - } - else{ - m_patch.render( renderer, volume, localToWorld() ); - } -} -#endif - void renderSolid( Renderer& renderer, const VolumeTest& volume ) const { m_patch.evaluateTransform(); renderer.setLights( *m_lightList ); diff --git a/radiant/pluginapi.cpp b/radiant/pluginapi.cpp index fff61864..1286e0eb 100644 --- a/radiant/pluginapi.cpp +++ b/radiant/pluginapi.cpp @@ -48,14 +48,6 @@ void QERApp_SetCamera( const Vector3& origin, const Vector3& angles ){ } void QERApp_GetCamWindowExtents( int *x, int *y, int *width, int *height ){ -#if 0 - CamWnd* camwnd = g_pParentWnd->GetCamWnd(); - - gtk_window_get_position( GTK_WINDOW( camwnd->m_window ), x, y ); - - *width = camwnd->Camera()->width; - *height = camwnd->Camera()->height; -#endif } #include "icamera.h" diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index 4708a78c..d5d3f36e 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -166,12 +166,6 @@ GtkMenuItem* create_plugins_menu(){ g_plugins_menu = menu; //TODO: some modules/plugins do not yet support refresh -#if 0 - create_menu_item_with_mnemonic( menu, "Refresh", FreeCaller() ); - - // NOTE: the seperator is used when doing a refresh of the list, everything past the seperator is removed - g_plugins_menu_separator = menu_separator( menu ); -#endif PluginsMenu_populate(); diff --git a/radiant/referencecache.cpp b/radiant/referencecache.cpp index ee3ab806..dc5c52ca 100644 --- a/radiant/referencecache.cpp +++ b/radiant/referencecache.cpp @@ -626,14 +626,6 @@ namespace HashtableReferenceCache g_referenceCache; } -#if 0 -class ResourceVisitor -{ -public: -virtual void visit( const char* name, const char* path, const - }; -#endif - void SaveReferences(){ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Saving Map" ); for ( HashtableReferenceCache::iterator i = g_referenceCache.begin(); i != g_referenceCache.end(); ++i ) diff --git a/radiant/renderstate.cpp b/radiant/renderstate.cpp index 0c274918..166ddc89 100644 --- a/radiant/renderstate.cpp +++ b/radiant/renderstate.cpp @@ -54,40 +54,6 @@ #include "xywindow.h" - -#define DEBUG_RENDER 0 - -inline void debug_string( const char* string ){ -#if (DEBUG_RENDER) - globalOutputStream() << string << "\n"; -#endif -} - -inline void debug_int( const char* comment, int i ){ -#if (DEBUG_RENDER) - globalOutputStream() << comment << " " << i << "\n"; -#endif -} - -inline void debug_colour( const char* comment ){ -#if ( DEBUG_RENDER ) - Vector4 v; - glGetFloatv( GL_CURRENT_COLOR, reinterpret_cast( &v ) ); - globalOutputStream() << comment << " colour: " - << v[0] << " " - << v[1] << " " - << v[2] << " " - << v[3]; - if ( glIsEnabled( GL_COLOR_ARRAY ) ) { - globalOutputStream() << " ARRAY"; - } - if ( glIsEnabled( GL_COLOR_MATERIAL ) ) { - globalOutputStream() << " MATERIAL"; - } - globalOutputStream() << "\n"; -#endif -} - #include "timer.h" StringOutputStream g_renderer_stats; @@ -272,7 +238,6 @@ void enable(){ GlobalOpenGL_debugAssertNoErrors(); - debug_string( "enable bump" ); g_bumpGLSLPass_enabled = true; } @@ -285,7 +250,6 @@ void disable(){ GlobalOpenGL_debugAssertNoErrors(); - debug_string( "disable bump" ); g_bumpGLSLPass_enabled = false; } @@ -354,13 +318,11 @@ void destroy(){ void enable(){ glUseProgramObjectARB( m_program ); GlobalOpenGL_debugAssertNoErrors(); - debug_string( "enable depthfill" ); g_depthfillPass_enabled = true; } void disable(){ glUseProgramObjectARB( 0 ); GlobalOpenGL_debugAssertNoErrors(); - debug_string( "disable depthfill" ); g_depthfillPass_enabled = false; } void setParameters( const Vector3& viewer, const Matrix4& localToWorld, const Vector3& origin, const Vector3& colour, const Matrix4& world2light ){ @@ -553,219 +515,6 @@ void setParameters( const Vector3& viewer, const Matrix4& localToWorld, const Ve ARBBumpProgram g_bumpARB; ARBDepthFillProgram g_depthFillARB; - -#if 0 -// NV20 path (unfinished) - -void createProgram( GLint program, const char* filename, GLenum type ){ - std::size_t size = file_size( filename ); - FileInputStream file( filename ); - ASSERT_MESSAGE( !file.failed(), "failed to open " << makeQuoted( filename ) ); - Array buffer( size ); - size = file.read( reinterpret_cast( buffer.data() ), size ); - - glLoadProgramNV( type, program, GLsizei( size ), buffer.data() ); - - if ( GL_INVALID_OPERATION == glGetError() ) { - GLint errPos; - glGetIntegerv( GL_PROGRAM_ERROR_POSITION_NV, &errPos ); - const GLubyte* errString = glGetString( GL_PROGRAM_ERROR_STRING_NV ); - - globalErrorStream() << filename << ":" << errPos << "\n" << errString; - - ERROR_MESSAGE( "error in gl program" ); - } -} - -GLuint m_vertex_program; -GLuint m_fragment_program; -qtexture_t* g_cube = 0; -qtexture_t* g_specular_lookup = 0; -qtexture_t* g_attenuation_xy = 0; -qtexture_t* g_attenuation_z = 0; - -void createVertexProgram(){ - { - glGenProgramsNV( 1, &m_vertex_program ); - glBindProgramNV( GL_VERTEX_PROGRAM_NV, m_vertex_program ); - StringOutputStream filename( 256 ); - filename << GlobalRadiant().getAppPath() << "gl/lighting_DBS_omni_vp.nv30"; - createProgram( m_vertex_program, filename.c_str(), GL_VERTEX_PROGRAM_NV ); - - glGenProgramsNV( 1, &m_fragment_program ); - glBindProgramNV( GL_FRAGMENT_PROGRAM_NV, m_fragment_program ); - filename.clear(); - filename << GlobalRadiant().getAppPath() << "gl/lighting_DBS_omni_fp.nv30"; - createProgram( m_fragment_program, filename.c_str(), GL_FRAGMENT_PROGRAM_NV ); - } - - g_cube = GlobalTexturesCache().capture( "generated/cube" ); - g_specular_lookup = GlobalTexturesCache().capture( "generated/specular" ); - - g_attenuation_xy = GlobalTexturesCache().capture( "lights/squarelight1" ); - glActiveTexture( GL_TEXTURE0 ); - glBindTexture( GL_TEXTURE_2D, g_attenuation_xy->texture_number ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER ); - - g_attenuation_z = GlobalTexturesCache().capture( "lights/squarelight1a" ); - glActiveTexture( GL_TEXTURE0 ); - glBindTexture( GL_TEXTURE_2D, g_attenuation_z->texture_number ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - - GlobalOpenGL_debugAssertNoErrors(); -} - -void destroyVertexProgram(){ - glDeleteProgramsNV( 1, &m_vertex_program ); - glDeleteProgramsNV( 1, &m_fragment_program ); - GlobalOpenGL_debugAssertNoErrors(); - - GlobalTexturesCache().release( g_cube ); - GlobalTexturesCache().release( g_specular_lookup ); - GlobalTexturesCache().release( g_attenuation_xy ); - GlobalTexturesCache().release( g_attenuation_z ); -} - -bool g_vertexProgram_enabled = false; - -void enableVertexProgram(){ - //set up the register combiners - //two general combiners - glCombinerParameteriNV( GL_NUM_GENERAL_COMBINERS_NV, 2 ); - - //combiner 0 does tex0+tex1 -> spare0 - glCombinerInputNV( GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB, - GL_UNSIGNED_IDENTITY_NV, GL_RGB ); - glCombinerInputNV( GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO, - GL_UNSIGNED_INVERT_NV, GL_RGB ); - glCombinerInputNV( GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE1_ARB, - GL_UNSIGNED_IDENTITY_NV, GL_RGB ); - glCombinerInputNV( GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, - GL_UNSIGNED_INVERT_NV, GL_RGB ); - glCombinerOutputNV( GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV, - GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE ); - - //combiner 1 does tex2 dot tex3 -> spare1 - glCombinerInputNV( GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE2_ARB, - GL_EXPAND_NORMAL_NV, GL_RGB ); - glCombinerInputNV( GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV, GL_TEXTURE3_ARB, - GL_EXPAND_NORMAL_NV, GL_RGB ); - glCombinerOutputNV( GL_COMBINER1_NV, GL_RGB, GL_SPARE1_NV, GL_DISCARD_NV, GL_DISCARD_NV, - GL_NONE, GL_NONE, GL_TRUE, GL_FALSE, GL_FALSE ); - - - - //final combiner outputs (1-spare0)*constant color 0*spare1 - //do constant color 0*spare1 in the EF multiplier - glFinalCombinerInputNV( GL_VARIABLE_E_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB ); - glFinalCombinerInputNV( GL_VARIABLE_F_NV, GL_CONSTANT_COLOR0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB ); - - //now do (1-spare0)*EF - glFinalCombinerInputNV( GL_VARIABLE_A_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB ); - glFinalCombinerInputNV( GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB ); - glFinalCombinerInputNV( GL_VARIABLE_C_NV, GL_E_TIMES_F_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB ); - glFinalCombinerInputNV( GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB ); - - glEnable( GL_VERTEX_PROGRAM_NV ); - glEnable( GL_REGISTER_COMBINERS_NV ); - glBindProgramNV( GL_VERTEX_PROGRAM_NV, m_vertex_program ); - glBindProgramNV( GL_FRAGMENT_PROGRAM_NV, m_fragment_program ); - - glActiveTexture( GL_TEXTURE0 ); - glEnable( GL_TEXTURE_2D ); - glActiveTexture( GL_TEXTURE1 ); - glEnable( GL_TEXTURE_1D ); - glActiveTexture( GL_TEXTURE2 ); - glEnable( GL_TEXTURE_2D ); - glActiveTexture( GL_TEXTURE3 ); - glEnable( GL_TEXTURE_2D ); - - glEnableClientState( GL_VERTEX_ATTRIB_ARRAY8_NV ); - glEnableClientState( GL_VERTEX_ATTRIB_ARRAY9_NV ); - glEnableClientState( GL_VERTEX_ATTRIB_ARRAY10_NV ); - glEnableClientState( GL_VERTEX_ATTRIB_ARRAY11_NV ); - - GlobalOpenGL_debugAssertNoErrors(); - g_vertexProgram_enabled = true; -} - -void disableVertexProgram(){ - glDisable( GL_VERTEX_PROGRAM_NV ); - glDisable( GL_REGISTER_COMBINERS_NV ); - - glActiveTexture( GL_TEXTURE0 ); - glDisable( GL_TEXTURE_2D ); - glActiveTexture( GL_TEXTURE1 ); - glDisable( GL_TEXTURE_1D ); - glActiveTexture( GL_TEXTURE2 ); - glDisable( GL_TEXTURE_2D ); - glActiveTexture( GL_TEXTURE3 ); - glDisable( GL_TEXTURE_2D ); - - glDisableClientState( GL_VERTEX_ATTRIB_ARRAY8_NV ); - glDisableClientState( GL_VERTEX_ATTRIB_ARRAY9_NV ); - glDisableClientState( GL_VERTEX_ATTRIB_ARRAY10_NV ); - glDisableClientState( GL_VERTEX_ATTRIB_ARRAY11_NV ); - - GlobalOpenGL_debugAssertNoErrors(); - g_vertexProgram_enabled = false; -} - -class GLstringNV -{ -public: -const GLubyte* m_string; -const GLint m_length; -GLstringNV( const char* string ) : m_string( reinterpret_cast( string ) ), m_length( GLint( string_length( string ) ) ){ -} -}; - -GLstringNV g_light_origin( "light_origin" ); -GLstringNV g_view_origin( "view_origin" ); -GLstringNV g_light_color( "light_color" ); -GLstringNV g_bumpGLSL_scale( "bump_scale" ); -GLstringNV g_specular_exponent( "specular_exponent" ); - -void setVertexProgramEnvironment( const Vector3& localViewer ){ - Matrix4 local2light( g_matrix4_identity ); - matrix4_translate_by_vec3( local2light, Vector3( 0.5, 0.5, 0.5 ) ); - matrix4_scale_by_vec3( local2light, Vector3( 0.5, 0.5, 0.5 ) ); - matrix4_scale_by_vec3( local2light, Vector3( 1.0 / 512.0, 1.0 / 512.0, 1.0 / 512.0 ) ); - matrix4_translate_by_vec3( local2light, vector3_negated( localViewer ) ); - - glActiveTexture( GL_TEXTURE3 ); - glClientActiveTexture( GL_TEXTURE3 ); - - glMatrixMode( GL_TEXTURE ); - glLoadMatrixf( reinterpret_cast( &local2light ) ); - glMatrixMode( GL_MODELVIEW ); - - glTrackMatrixNV( GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV ); - glTrackMatrixNV( GL_VERTEX_PROGRAM_NV, 4, GL_TEXTURE0_ARB, GL_IDENTITY_NV ); - - // view origin - //qglProgramNamedParameter4fNV(m_fragment_program, g_view_origin.m_length, g_view_origin.m_string, localViewer.x(), localViewer.y(), localViewer.z(), 0); - - // light origin - glProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 8, localViewer.x(), localViewer.y(), localViewer.z(), 1.0f ); - - // light colour - glCombinerParameterfNV( GL_CONSTANT_COLOR0_NV, 1, 1, 1, 1 ) - - // bump scale - //qglProgramNamedParameter4fNV(m_fragment_program, g_bumpGLSL_scale.m_length, g_bumpGLSL_scale.m_string, 1, 0, 0, 0); - - // specular exponent - //qglProgramNamedParameter4fNV(m_fragment_program, g_specular_exponent.m_length, g_specular_exponent.m_string, 32, 0, 0, 0); - - GlobalOpenGL_debugAssertNoErrors(); -} - -#endif - - bool g_vertexArray_enabled = false; bool g_normalArray_enabled = false; bool g_texcoordArray_enabled = false; @@ -883,13 +632,6 @@ OpenGLState& state(){ void render( OpenGLState& current, unsigned int globalstate, const Vector3& viewer ); }; -#define LIGHT_SHADER_DEBUG 0 - -#if LIGHT_SHADER_DEBUG -typedef std::vector LightDebugShaders; -LightDebugShaders g_lightDebugShaders; -#endif - class OpenGLStateLess { public: @@ -962,20 +704,6 @@ void destroy(){ void addRenderable( const OpenGLRenderable& renderable, const Matrix4& modelview, const LightList* lights ){ for ( Passes::iterator i = m_passes.begin(); i != m_passes.end(); ++i ) { -#if LIGHT_SHADER_DEBUG - if ( ( ( *i )->state().m_state & RENDER_BUMP ) != 0 ) { - if ( lights != 0 ) { - CountLights counter; - lights->forEachLight( makeCallback1( counter ) ); - globalOutputStream() << "count = " << counter.count() << "\n"; - for ( std::size_t i = 0; i < counter.count(); ++i ) - { - g_lightDebugShaders[counter.count()]->addRenderable( renderable, modelview ); - } - } - } - else -#else if ( ( ( *i )->state().m_state & RENDER_BUMP ) != 0 ) { if ( lights != 0 ) { OpenGLStateBucketAdd add( *( *i ), renderable, modelview ); @@ -983,7 +711,6 @@ void addRenderable( const OpenGLRenderable& renderable, const Matrix4& modelview } } else -#endif { ( *i )->addRenderable( renderable, modelview ); } @@ -1065,8 +792,6 @@ inline bool lightEnabled( const RendererLight& light, const LightCullable& culla typedef std::set RendererLights; -#define DEBUG_LIGHT_SYNC 0 - class LinearLightList : public LightList { LightCullable& m_cullable; @@ -1096,23 +821,6 @@ void evaluateLights() const { } } } -#if ( DEBUG_LIGHT_SYNC ) - else - { - Lights lights; - for ( RendererLights::const_iterator i = m_allLights.begin(); i != m_allLights.end(); ++i ) - { - if ( lightEnabled( *( *i ), m_cullable ) ) { - lights.push_back( *i ); - } - } - ASSERT_MESSAGE( - !std::lexicographical_compare( lights.begin(), lights.end(), m_lights.begin(), m_lights.end() ) - && !std::lexicographical_compare( m_lights.begin(), m_lights.end(), lights.begin(), lights.end() ), - "lights out of sync" - ); - } -#endif } void forEachLight( const RendererLightCallback& callback ) const { evaluateLights(); @@ -1136,8 +844,6 @@ inline void setFogState( const OpenGLFogState& state ){ glFogfv( GL_FOG_COLOR, vector4_to_array( state.colour ) ); } -#define DEBUG_SHADERS 0 - class OpenGLShaderCache : public ShaderCache, public TexturesCacheObserver, public ModuleObserver { class CreateOpenGLShader @@ -1192,29 +898,18 @@ Shader* capture( const char* name ){ || *name == '<' || *name == '(' || strchr( name, '\\' ) == 0, "shader name contains invalid characters: \"" << name << "\"" ); -#if DEBUG_SHADERS - globalOutputStream() << "shaders capture: " << makeQuoted( name ) << '\n'; -#endif return m_shaders.capture( name ).get(); } void release( const char *name ){ -#if DEBUG_SHADERS - globalOutputStream() << "shaders release: " << makeQuoted( name ) << '\n'; -#endif + m_shaders.release( name ); } void render( RenderStateFlags globalstate, const Matrix4& modelview, const Matrix4& projection, const Vector3& viewer ){ glMatrixMode( GL_PROJECTION ); glLoadMatrixf( reinterpret_cast( &projection ) ); - #if 0 - //qglGetFloatv(GL_PROJECTION_MATRIX, reinterpret_cast(&projection)); - #endif glMatrixMode( GL_MODELVIEW ); glLoadMatrixf( reinterpret_cast( &modelview ) ); - #if 0 - //qglGetFloatv(GL_MODELVIEW_MATRIX, reinterpret_cast(&modelview)); - #endif ASSERT_MESSAGE( realised(), "render states are not realised" ); @@ -1304,12 +999,10 @@ void render( RenderStateFlags globalstate, const Matrix4& modelview, const Matri GlobalOpenGL_debugAssertNoErrors(); - debug_string( "begin rendering" ); for ( OpenGLStates::iterator i = g_state_sorted.begin(); i != g_state_sorted.end(); ++i ) { ( *i ).second->render( current, globalstate, viewer ); } - debug_string( "end rendering" ); } void realise(){ if ( --m_unrealised == 0 ) { @@ -1514,35 +1207,6 @@ void ShaderCache_Construct(){ g_defaultPointLight = g_ShaderCache->capture( "lights/defaultPointLight" ); //Shader* overbright = g_ShaderCache->capture( "$OVERBRIGHT" ); - -#if LIGHT_SHADER_DEBUG - for ( std::size_t i = 0; i < 256; ++i ) - { - g_DebugShaderColours[i] = Vector3( i / 256.0, i / 256.0, i / 256.0 ); - } - - g_DebugShaderColours[0] = Vector3( 1, 0, 0 ); - g_DebugShaderColours[1] = Vector3( 1, 0.5, 0 ); - g_DebugShaderColours[2] = Vector3( 1, 1, 0 ); - g_DebugShaderColours[3] = Vector3( 0.5, 1, 0 ); - g_DebugShaderColours[4] = Vector3( 0, 1, 0 ); - g_DebugShaderColours[5] = Vector3( 0, 1, 0.5 ); - g_DebugShaderColours[6] = Vector3( 0, 1, 1 ); - g_DebugShaderColours[7] = Vector3( 0, 0.5, 1 ); - g_DebugShaderColours[8] = Vector3( 0, 0, 1 ); - g_DebugShaderColours[9] = Vector3( 0.5, 0, 1 ); - g_DebugShaderColours[10] = Vector3( 1, 0, 1 ); - g_DebugShaderColours[11] = Vector3( 1, 0, 0.5 ); - - g_lightDebugShaders.reserve( 256 ); - StringOutputStream buffer( 256 ); - for ( std::size_t i = 0; i < 256; ++i ) - { - buffer << "(" << g_DebugShaderColours[i].x() << " " << g_DebugShaderColours[i].y() << " " << g_DebugShaderColours[i].z() << ")"; - g_lightDebugShaders.push_back( g_ShaderCache->capture( buffer.c_str() ) ); - buffer.clear(); - } -#endif } } @@ -1552,15 +1216,6 @@ void ShaderCache_Destroy(){ g_ShaderCache->release( "$OVERBRIGHT" ); g_defaultPointLight = 0; -#if LIGHT_SHADER_DEBUG - g_lightDebugShaders.clear(); - StringOutputStream buffer( 256 ); - for ( std::size_t i = 0; i < 256; ++i ) - { - buffer << "(" << g_DebugShaderColours[i].x() << " " << g_DebugShaderColours[i].y() << " " << g_DebugShaderColours[i].z() << ")"; - g_ShaderCache->release( buffer.c_str() ); - } -#endif } GlobalShaderSystem().detach( *g_ShaderCache ); @@ -1602,10 +1257,6 @@ inline void setState( unsigned int state, unsigned int delta, unsigned int flag, } void OpenGLState_apply( const OpenGLState& self, OpenGLState& current, unsigned int globalstate ){ - debug_int( "sort", int(self.m_sort) ); - debug_int( "texture", self.m_texture ); - debug_int( "state", self.m_state ); - debug_int( "address", int(std::size_t( &self ) ) ); count_state(); @@ -1624,7 +1275,6 @@ void OpenGLState_apply( const OpenGLState& self, OpenGLState& current, unsigned if ( current.m_program != 0 ) { current.m_program->disable(); glColor4fv( vector4_to_array( current.m_colour ) ); - debug_colour( "cleaning program" ); } current.m_program = program; @@ -1675,7 +1325,6 @@ void OpenGLState_apply( const OpenGLState& self, OpenGLState& current, unsigned glEnable( GL_TEXTURE_2D ); glColor4f( 1,1,1,self.m_colour[3] ); - debug_colour( "setting texture" ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); GlobalOpenGL_debugAssertNoErrors(); @@ -1736,25 +1385,12 @@ void OpenGLState_apply( const OpenGLState& self, OpenGLState& current, unsigned if ( delta & state & RENDER_DEPTHWRITE ) { glDepthMask( GL_TRUE ); -#if DEBUG_RENDER - GLboolean depthEnabled; - glGetBooleanv( GL_DEPTH_WRITEMASK, &depthEnabled ); - ASSERT_MESSAGE( depthEnabled, "failed to set depth buffer mask bit" ); -#endif - debug_string( "enabled depth-buffer writing" ); GlobalOpenGL_debugAssertNoErrors(); } else if ( delta & ~state & RENDER_DEPTHWRITE ) { glDepthMask( GL_FALSE ); -#if DEBUG_RENDER - GLboolean depthEnabled; - glGetBooleanv( GL_DEPTH_WRITEMASK, &depthEnabled ); - ASSERT_MESSAGE( !depthEnabled, "failed to set depth buffer mask bit" ); -#endif - debug_string( "disabled depth-buffer writing" ); - GlobalOpenGL_debugAssertNoErrors(); } @@ -1772,13 +1408,11 @@ void OpenGLState_apply( const OpenGLState& self, OpenGLState& current, unsigned if ( delta & state & RENDER_COLOURARRAY ) { glEnableClientState( GL_COLOR_ARRAY ); GlobalOpenGL_debugAssertNoErrors(); - debug_colour( "enabling color_array" ); g_colorArray_enabled = true; } else if ( delta & ~state & RENDER_COLOURARRAY ) { glDisableClientState( GL_COLOR_ARRAY ); glColor4fv( vector4_to_array( self.m_colour ) ); - debug_colour( "cleaning color_array" ); GlobalOpenGL_debugAssertNoErrors(); g_colorArray_enabled = false; } @@ -1866,7 +1500,6 @@ void OpenGLState_apply( const OpenGLState& self, OpenGLState& current, unsigned if ( state & RENDER_TEXTURE && self.m_colour[3] != current.m_colour[3] ) { - debug_colour( "setting alpha" ); glColor4f( 1,1,1,self.m_colour[3] ); GlobalOpenGL_debugAssertNoErrors(); } @@ -1877,7 +1510,6 @@ void OpenGLState_apply( const OpenGLState& self, OpenGLState& current, unsigned || self.m_colour[2] != current.m_colour[2] || self.m_colour[3] != current.m_colour[3] ) ) { glColor4fv( vector4_to_array( self.m_colour ) ); - debug_colour( "setting non-texture" ); GlobalOpenGL_debugAssertNoErrors(); } current.m_colour = self.m_colour; @@ -1965,7 +1597,6 @@ void Renderables_flush( OpenGLStateBucket::Renderables& renderables, OpenGLState } current.m_program->setParameters( viewer, *( *i ).m_transform, lightBounds.origin + ( *i ).m_light->offset(), ( *i ).m_light->colour(), world2light ); - debug_string( "set lightBounds parameters" ); } } @@ -1978,7 +1609,6 @@ void Renderables_flush( OpenGLStateBucket::Renderables& renderables, OpenGLState void OpenGLStateBucket::render( OpenGLState& current, unsigned int globalstate, const Vector3& viewer ){ if ( ( globalstate & m_state.m_state & RENDER_SCREEN ) != 0 ) { OpenGLState_apply( m_state, current, globalstate ); - debug_colour( "screen fill" ); glMatrixMode( GL_PROJECTION ); glPushMatrix(); @@ -2160,10 +1790,6 @@ void OpenGLShader::construct( const char* name ){ state.m_depthfunc = GL_LEQUAL; } else if ( string_equal( name + 1, "CAM_OVERLAY" ) ) { -#if 0 - state.m_state = RENDER_CULLFACE | RENDER_COLOURWRITE | RENDER_DEPTHWRITE; - state.m_sort = OpenGLState::eSortOverlayFirst; -#else state.m_state = RENDER_CULLFACE | RENDER_DEPTHTEST | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_OFFSETLINE; state.m_sort = OpenGLState::eSortOverlayFirst + 1; state.m_depthfunc = GL_LEQUAL; @@ -2177,7 +1803,6 @@ void OpenGLShader::construct( const char* name ){ hiddenLine.m_sort = OpenGLState::eSortOverlayFirst; hiddenLine.m_depthfunc = GL_GREATER; hiddenLine.m_linestipple_factor = 2; -#endif } else if ( string_equal( name + 1, "XY_OVERLAY" ) ) { state.m_colour[0] = g_xywindow_globals.color_selbrushes[0]; @@ -2223,10 +1848,6 @@ void OpenGLShader::construct( const char* name ){ state.m_sort = OpenGLState::eSortTranslucent; } else if ( string_equal( name + 1, "WIRE_OVERLAY" ) ) { -#if 0 - state.m_state = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_DEPTHTEST | RENDER_OVERRIDE; - state.m_sort = OpenGLState::eSortOverlayFirst; -#else state.m_state = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_DEPTHTEST | RENDER_OVERRIDE; state.m_sort = OpenGLState::eSortGUI1; state.m_depthfunc = GL_LEQUAL; @@ -2235,7 +1856,6 @@ void OpenGLShader::construct( const char* name ){ hiddenLine.m_state = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_DEPTHTEST | RENDER_OVERRIDE | RENDER_LINESTIPPLE; hiddenLine.m_sort = OpenGLState::eSortGUI0; hiddenLine.m_depthfunc = GL_GREATER; -#endif } else if ( string_equal( name + 1, "FLATSHADE_OVERLAY" ) ) { state.m_state = RENDER_CULLFACE | RENDER_LIGHTING | RENDER_SMOOTH | RENDER_SCALED | RENDER_COLOURARRAY | RENDER_FILL | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_DEPTHTEST | RENDER_OVERRIDE; diff --git a/radiant/select.cpp b/radiant/select.cpp index 5d34645a..49d162c5 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -838,17 +838,6 @@ void Selection_destroy(){ inline Quaternion quaternion_for_euler_xyz_degrees( const Vector3& eulerXYZ ){ -#if 0 - return quaternion_for_matrix4_rotation( matrix4_rotation_for_euler_xyz_degrees( eulerXYZ ) ); -#elif 0 - return quaternion_multiplied_by_quaternion( - quaternion_multiplied_by_quaternion( - quaternion_for_z( degrees_to_radians( eulerXYZ[2] ) ), - quaternion_for_y( degrees_to_radians( eulerXYZ[1] ) ) - ), - quaternion_for_x( degrees_to_radians( eulerXYZ[0] ) ) - ); -#elif 1 double cx = cos( degrees_to_radians( eulerXYZ[0] * 0.5 ) ); double sx = sin( degrees_to_radians( eulerXYZ[0] * 0.5 ) ); double cy = cos( degrees_to_radians( eulerXYZ[1] * 0.5 ) ); @@ -862,7 +851,6 @@ inline Quaternion quaternion_for_euler_xyz_degrees( const Vector3& eulerXYZ ){ sz * cy * cx - cz * sy * sx, cz * cy * cx + sz * sy * sx ); -#endif } struct RotateDialog diff --git a/radiant/selection.cpp b/radiant/selection.cpp index 5013af7b..b55a3864 100644 --- a/radiant/selection.cpp +++ b/radiant/selection.cpp @@ -472,25 +472,6 @@ Shader* g_state_clipped; RenderableClippedPrimitive g_render_clipped; #endif - -#if 0 -// dist_Point_to_Line(): get the distance of a point to a line. -// Input: a Point P and a Line L (in any dimension) -// Return: the shortest distance from P to L -float -dist_Point_to_Line( Point P, Line L ){ - Vector v = L.P1 - L.P0; - Vector w = P - L.P0; - - double c1 = dot( w,v ); - double c2 = dot( v,v ); - double b = c1 / c2; - - Point Pb = L.P0 + b * v; - return d( P, Pb ); -} -#endif - class Segment3D { typedef Vector3 point_type; @@ -770,19 +751,8 @@ inline void draw_semicircle( const std::size_t segments, const float radius, Poi PointVertex* k = i + ( segments << 1 ); PointVertex* l = j + ( segments << 1 ); -#if 0 - PointVertex* m = i + ( segments << 2 ); - PointVertex* n = j + ( segments << 2 ); - PointVertex* o = k + ( segments << 2 ); - PointVertex* p = l + ( segments << 2 ); -#endif - remap_policy::set( i->vertex, x,-y, 0 ); remap_policy::set( k->vertex,-y,-x, 0 ); -#if 0 - remap_policy::set( m->vertex,-x, y, 0 ); - remap_policy::set( o->vertex, y, x, 0 ); -#endif ++count; @@ -794,10 +764,6 @@ inline void draw_semicircle( const std::size_t segments, const float radius, Poi remap_policy::set( j->vertex, y,-x, 0 ); remap_policy::set( l->vertex,-x,-y, 0 ); -#if 0 - remap_policy::set( n->vertex,-y, x, 0 ); - remap_policy::set( p->vertex, x, y, 0 ); -#endif } } @@ -3289,27 +3255,6 @@ void Scene_BoundsSelectedComponent( scene::Graph& graph, AABB& bounds ){ graph.traverse( bounds_selected_component( bounds ) ); } -#if 0 -inline void pivot_for_node( Matrix4& pivot, scene::Node& node, scene::Instance& instance ){ - ComponentEditable* componentEditable = Instance_getComponentEditable( instance ); - if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent - && componentEditable != 0 ) { - pivot = matrix4_translation_for_vec3( componentEditable->getSelectedComponentsBounds().origin ); - } - else - { - Bounded* bounded = Instance_getBounded( instance ); - if ( bounded != 0 ) { - pivot = matrix4_translation_for_vec3( bounded->localAABB().origin ); - } - else - { - pivot = g_matrix4_identity; - } - } -} -#endif - void RadiantSelectionSystem::ConstructPivot() const { if ( !m_pivotChanged || m_pivot_moving ) { return; diff --git a/radiant/server.cpp b/radiant/server.cpp index c58ad879..1a5fe26d 100644 --- a/radiant/server.cpp +++ b/radiant/server.cpp @@ -187,11 +187,6 @@ DynamicLibraryModule( const char* filename ) : m_library( filename ), m_registerModule( 0 ){ if ( !m_library.failed() ) { m_registerModule = reinterpret_cast( m_library.findSymbol( "Radiant_RegisterModules" ) ); -#if 0 - if ( !m_registerModule ) { - m_registerModule = reinterpret_cast( m_library.findSymbol( "Radiant_RegisterModules@4" ) ); - } -#endif } } bool failed(){ diff --git a/radiant/stacktrace.cpp b/radiant/stacktrace.cpp index 51ef5038..dfe0a324 100644 --- a/radiant/stacktrace.cpp +++ b/radiant/stacktrace.cpp @@ -107,58 +107,6 @@ struct EnumerateSymbolsContext }; void write_symbol( PSYMBOL_INFO pSym, STACKFRAME64& sf, TextOutputStream& outputStream, std::size_t& count ){ -#if 0 - if ( pSym->Flags & SYMFLAG_PARAMETER ) { - - DWORD basicType; - if ( SymGetTypeInfo( GetCurrentProcess(), pSym->ModBase, pSym->TypeIndex, - TI_GET_BASETYPE, &basicType ) ) { - int bleh = 0; - } - else - { - DWORD typeId; - if ( SymGetTypeInfo( GetCurrentProcess(), pSym->ModBase, pSym->TypeIndex, - TI_GET_TYPEID, &typeId ) ) { - if ( SymGetTypeInfo( GetCurrentProcess(), pSym->ModBase, pSym->TypeIndex, - TI_GET_BASETYPE, &basicType ) ) { - int bleh = 0; - } - else - { - const char* FormatGetLastError(); - const char* error = FormatGetLastError(); - int bleh = 0; - - WCHAR* name; - if ( SymGetTypeInfo( GetCurrentProcess(), pSym->ModBase, typeId, - TI_GET_SYMNAME, &name ) ) { - outputStream << name << " "; - LocalFree( name ); - int bleh = 0; - } - else - { - const char* FormatGetLastError(); - const char* error = FormatGetLastError(); - int bleh = 0; - } - } - } - else - { - const char* FormatGetLastError(); - const char* error = FormatGetLastError(); - int bleh = 0; - } - } - if ( count != 0 ) { - outputStream << ", "; - } - outputStream << pSym->Name; - ++count; - } -#endif } BOOL CALLBACK diff --git a/radiant/textures.cpp b/radiant/textures.cpp index b223e2ee..5fd025c7 100644 --- a/radiant/textures.cpp +++ b/radiant/textures.cpp @@ -264,73 +264,6 @@ void LoadTextureRGBA( qtexture_t* q, unsigned char* pPixels, int nWidth, int nHe } } -#if 0 -/* - ============== - Texture_InitPalette - ============== - */ -void Texture_InitPalette( byte *pal ){ - int r,g,b; - int i; - int inf; - byte gammatable[256]; - float gamma; - - gamma = g_texture_globals.fGamma; - - if ( gamma == 1.0 ) { - for ( i = 0 ; i < 256 ; i++ ) - gammatable[i] = i; - } - else - { - for ( i = 0 ; i < 256 ; i++ ) - { - inf = (int)( 255 * pow( ( i + 0.5 ) / 255.5, gamma ) + 0.5 ); - if ( inf < 0 ) { - inf = 0; - } - if ( inf > 255 ) { - inf = 255; - } - gammatable[i] = inf; - } - } - - for ( i = 0 ; i < 256 ; i++ ) - { - r = gammatable[pal[0]]; - g = gammatable[pal[1]]; - b = gammatable[pal[2]]; - pal += 3; - - //v = (r<<24) + (g<<16) + (b<<8) + 255; - //v = BigLong (v); - - //tex_palette[i] = v; - tex_palette[i * 3 + 0] = r; - tex_palette[i * 3 + 1] = g; - tex_palette[i * 3 + 2] = b; - } -} -#endif - -#if 0 -class TestHashtable -{ -public: -TestHashtable(){ - HashTable strings; - strings["Monkey"] = "bleh"; - strings["MonkeY"] = "blah"; -} -}; - -const TestHashtable g_testhashtable; - -#endif - typedef std::pair TextureKey; void qtexture_realise( qtexture_t& texture, const TextureKey& key ){ @@ -377,8 +310,6 @@ hash_t operator()( const TextureKey& key ) const { } }; -#define DEBUG_TEXTURES 0 - class TexturesMap : public TexturesCache { class TextureConstructor @@ -430,15 +361,9 @@ qtexture_t* capture( const char* name ){ return capture( defaultLoader(), name ); } qtexture_t* capture( const LoadImageCallback& loader, const char* name ){ -#if DEBUG_TEXTURES - globalOutputStream() << "textures capture: " << makeQuoted( name ) << '\n'; -#endif return m_qtextures.capture( TextureKey( loader, name ) ).get(); } void release( qtexture_t* texture ){ -#if DEBUG_TEXTURES - globalOutputStream() << "textures release: " << makeQuoted( texture->name ) << '\n'; -#endif m_qtextures.release( TextureKey( texture->load, texture->name ) ); } void attach( TexturesCacheObserver& observer ){ diff --git a/radiant/treemodel.cpp b/radiant/treemodel.cpp index d36e492a..670e1f76 100644 --- a/radiant/treemodel.cpp +++ b/radiant/treemodel.cpp @@ -40,706 +40,6 @@ inline Nameable* Node_getNameable( scene::Node& node ){ return NodeTypeCast::cast( node ); } -#if 0 - -#include "gtkutil/gtktreestore.h" - -template -inline void gtk_tree_model_get_pointer( GtkTreeModel* model, GtkTreeIter* iter, gint column, value_type** pointer ){ - GValue value = GValue_default(); - gtk_tree_model_get_value( model, iter, column, &value ); - *pointer = (value_type*)g_value_get_pointer( &value ); -} - - -typedef GtkTreeStore GraphTreeModel; - -GtkTreeStore* graph_tree_model_new( graph_type* graph ){ - return gtk_tree_store_new( 2, G_TYPE_POINTER, G_TYPE_POINTER ); -} - -void graph_tree_model_delete( GraphTreeModel* model ){ - g_object_unref( G_OBJECT( model ) ); -} - - -bool graph_tree_model_subtree_find_node( GraphTreeModel* model, GtkTreeIter* parent, const scene::Node& node, GtkTreeIter* iter ){ - for ( gboolean success = gtk_tree_model_iter_children( GTK_TREE_MODEL( model ), iter, parent ); - success != FALSE; - success = gtk_tree_model_iter_next( GTK_TREE_MODEL( model ), iter ) ) - { - scene::Node* current; - gtk_tree_model_get_pointer( GTK_TREE_MODEL( model ), iter, 0, ¤t ); - if ( current == node ) { - return true; - } - } - return false; -} - -typedef GtkTreeIter DoubleGtkTreeIter[2]; - -bool graph_tree_model_find_top( GraphTreeModel* model, const scene::Path& path, GtkTreeIter& iter ){ - int swap = 0; - GtkTreeIter* parent_pointer = NULL; - GtkTreeIter parent; - for ( scene::Path::const_iterator i = path.begin(); i != path.end(); ++i ) - { - if ( !graph_tree_model_subtree_find_node( model, parent_pointer, *i, &iter ) ) { - return false; - } - parent = iter; - parent_pointer = &parent; - } - return true; -} - -bool graph_tree_model_find_parent( GraphTreeModel* model, const scene::Path& path, GtkTreeIter& iter ){ - int swap = 0; - GtkTreeIter* parent_pointer = NULL; - ASSERT_MESSAGE( path.size() > 1, "path too short" ); - for ( scene::Path::const_iterator i = path.begin(); i != path.end() - 1; ++i ) - { - GtkTreeIter child; - if ( !graph_tree_model_subtree_find_node( model, parent_pointer, *i, &child ) ) { - return false; - } - iter = child; - parent_pointer = &iter; - } - return true; -} - -void node_attach_name_changed_callback( scene::Node& node, const Callback& callback ){ - if ( node != 0 ) { - Nameable* nameable = Node_getNameable( node ); - if ( nameable != 0 ) { - nameable->attach( callback ); - } - } -} -void node_detach_name_changed_callback( scene::Node& node, const Callback& callback ){ - if ( node != 0 ) { - Nameable* nameable = Node_getNameable( node ); - if ( nameable != 0 ) { - nameable->detach( callback ); - } - } -} - -GraphTreeModel* scene_graph_get_tree_model(); // temp hack - -void graph_tree_model_row_changed( const scene::Instance& instance ){ - GraphTreeModel* model = scene_graph_get_tree_model(); - - GtkTreeIter child; - ASSERT_MESSAGE( graph_tree_model_find_top( model, instance.path(), child ), "RUNTIME ERROR" ); - - gtk_tree_store_set( GTK_TREE_STORE( model ), &child, 0, instance.path().top(), -1 ); -} - -void graph_tree_model_row_inserted( GraphTreeModel* model, const scene::Instance& instance ){ - GtkTreeIter parent; - GtkTreeIter* parent_pointer = NULL; - if ( instance.path().size() != 1 ) { - ASSERT_MESSAGE( graph_tree_model_find_parent( model, instance.path(), parent ), "RUNTIME ERROR" ); - parent_pointer = &parent; - } - - gpointer node = instance.path().top(); - gconstpointer selectable = Instance_getSelectable( instance ); - - GtkTreeIter child; - gtk_tree_store_append( GTK_TREE_STORE( model ), &child, parent_pointer ); - gtk_tree_store_set( GTK_TREE_STORE( model ), &child, 0, node, 1, selectable, -1 ); - - node_attach_name_changed_callback( instance.path().top(), ConstReferenceCaller( instance ) ); -} - -void graph_tree_model_row_deleted( GraphTreeModel* model, const scene::Instance& instance ){ - GtkTreeIter child; - ASSERT_MESSAGE( graph_tree_model_find_top( model, instance.path(), child ), "RUNTIME ERROR" ); - - node_detach_name_changed_callback( instance.path().top(), ConstReferenceCaller( instance ) ); - - gtk_tree_store_remove( GTK_TREE_STORE( model ), &child ); -} - -#elif 0 - -const char* node_get_name( scene::Node& node ); - -typedef scene::Node* NodePointer; - -class NodeNameLess -{ -public: -bool operator()( const NodePointer& self, const NodePointer& other ) const { - if ( self == 0 ) { - return true; - } - if ( other == 0 ) { - return false; - } - int result = string_compare( node_get_name( self ), node_get_name( other ) ); - if ( result == 0 ) { - return self < other; - } - return result < 0; -} -}; - -class PathNameLess -{ -public: -bool operator()( const PathConstReference& self, const PathConstReference& other ) const { - return std::lexicographical_compare( self.get().begin(), self.get().end(), other.get().begin(), other.get().end(), NodeNameLess() ); -} -}; - -typedef std::map graph_type; - -struct GraphTreeModel -{ - GObject parent; - - graph_type* graph; -}; - -struct GraphTreeModelClass -{ - GObjectClass parent_class; -}; - -#define GRAPH_TREE_MODEL( p ) ( reinterpret_cast( p ) ) - -static GtkTreeModelFlags graph_tree_model_get_flags( GtkTreeModel* tree_model ){ - return GTK_TREE_MODEL_ITERS_PERSIST; -} - -static gint graph_tree_model_get_n_columns( GtkTreeModel* tree_model ){ - ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - GraphTreeModel* graph_tree_model = (GraphTreeModel*) tree_model; - - return 2; -} - -static const gint c_stamp = 0xabcdef; - -inline graph_type::iterator graph_iterator_read_tree_iter( GtkTreeIter* iter ){ - ASSERT_MESSAGE( iter != 0, "tree model error" ); - ASSERT_MESSAGE( iter->user_data != 0, "tree model error" ); - ASSERT_MESSAGE( iter->stamp == c_stamp, "tree model error" ); - return *reinterpret_cast( &iter->user_data ); -} - -inline void graph_iterator_write_tree_iter( graph_type::iterator i, GtkTreeIter* iter ){ - ASSERT_MESSAGE( iter != 0, "tree model error" ); - iter->stamp = c_stamp; - *reinterpret_cast( &iter->user_data ) = i; - ASSERT_MESSAGE( iter->user_data != 0, "tree model error" ); -} - -static GType graph_tree_model_get_column_type( GtkTreeModel *tree_model, gint index ){ - ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - GraphTreeModel *graph_tree_model = (GraphTreeModel *) tree_model; - - return G_TYPE_POINTER; -} - -static gboolean graph_tree_model_get_iter( GtkTreeModel* tree_model, GtkTreeIter* iter, GtkTreePath* path ){ - ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - gint* indices = gtk_tree_path_get_indices( path ); - gint depth = gtk_tree_path_get_depth( path ); - - g_return_val_if_fail( depth > 0, FALSE ); - - graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph; - - if ( graph.empty() ) { - return FALSE; - } - - GtkTreeIter tmp; - GtkTreeIter* parent = 0; - - for ( gint i = 0; i < depth; i++ ) - { - if ( !gtk_tree_model_iter_nth_child( tree_model, iter, parent, indices[i] ) ) { - return FALSE; - } - tmp = *iter; - parent = &tmp; - } - - return TRUE; -} - -static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTreeIter* iter ){ - ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph; - graph_type::iterator i = graph_iterator_read_tree_iter( iter ); - - GtkTreePath* path = gtk_tree_path_new(); - - for ( std::size_t depth = ( *i ).first.get().size(); depth != 0; --depth ) - { - std::size_t index = 0; - - while ( i != graph.begin() && ( *i ).first.get().size() >= depth ) - { - --i; - if ( ( *i ).first.get().size() == depth ) { - ++index; - } - } - - gtk_tree_path_prepend_index( path, index ); - } - - return path; -} - - -static void graph_tree_model_get_value( GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value ){ - ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - ASSERT_MESSAGE( column == 0 || column == 1, "tree model error" ); - - graph_type::iterator i = graph_iterator_read_tree_iter( iter ); - - g_value_init( value, G_TYPE_POINTER ); - - if ( column == 0 ) { - g_value_set_pointer( value, reinterpret_cast( ( *i ).first.get().top() ) ); - } - else{ - g_value_set_pointer( value, reinterpret_cast( Instance_getSelectable( *( *i ).second ) ) ); - } -} - -static gboolean graph_tree_model_iter_next( GtkTreeModel *tree_model, GtkTreeIter *iter ){ - ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph; - graph_type::iterator i = graph_iterator_read_tree_iter( iter ); - std::size_t depth = ( *i ).first.get().size(); - - ++i; - - while ( i != graph.end() && ( *i ).first.get().size() > depth ) - { - ++i; - } - - if ( i == graph.end() || ( *i ).first.get().size() != depth ) { - return FALSE; - } - - graph_iterator_write_tree_iter( i, iter ); - - return TRUE; -} - -static gboolean graph_tree_model_iter_children( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent ){ - ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph; - graph_type::iterator i = ( parent == 0 ) ? graph.begin() : graph_iterator_read_tree_iter( parent ); - std::size_t depth = ( parent == 0 ) ? 1 : ( *i ).first.get().size() + 1; - - if ( parent != 0 ) { - ++i; - } - - if ( i != graph.end() && ( *i ).first.get().size() == depth ) { - graph_iterator_write_tree_iter( i, iter ); - return TRUE; - } - - return FALSE; -} - -static gboolean graph_tree_model_iter_has_child( GtkTreeModel *tree_model, GtkTreeIter *iter ){ - ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph; - graph_type::iterator i = graph_iterator_read_tree_iter( iter ); - std::size_t depth = ( *i ).first.get().size() + 1; - - return ++i != graph.end() && ( *i ).first.get().size() == depth; -} - -static gint graph_tree_model_iter_n_children( GtkTreeModel *tree_model, GtkTreeIter *parent ){ - ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph; - graph_type::iterator i = ( parent == 0 ) ? graph.begin() : graph_iterator_read_tree_iter( parent ); - std::size_t depth = ( parent == 0 ) ? 1 : ( *i ).first.get().size() + 1; - - if ( parent != 0 ) { - ++i; - } - - gint count = 0; - while ( i != graph.end() && ( *i ).first.get().size() >= depth ) - { - ++count; - ++i; - } - - return count; -} - -static gboolean graph_tree_model_iter_nth_child( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n ){ - ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph; - graph_type::iterator i = ( parent == 0 ) ? graph.begin() : graph_iterator_read_tree_iter( parent ); - std::size_t depth = ( parent == 0 ) ? 1 : ( *i ).first.get().size() + 1; - - if ( parent != 0 ) { - ++i; - } - - while ( i != graph.end() && ( *i ).first.get().size() >= depth ) - { - if ( ( *i ).first.get().size() == depth && n-- == 0 ) { - graph_iterator_write_tree_iter( i, iter ); - return TRUE; - } - ++i; - } - - return FALSE; -} - -static gboolean graph_tree_model_iter_parent( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child ){ - ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph; - graph_type::iterator i = graph_iterator_read_tree_iter( child ); - std::size_t depth = ( *i ).first.get().size(); - if ( depth == 1 ) { - return FALSE; - } - else - { - do - { - --i; - } - while ( ( *i ).first.get().size() >= depth ); - graph_iterator_write_tree_iter( i, iter ); - return TRUE; - } -} - -static GObjectClass *g_parent_class = 0; - -static void graph_tree_model_init( GraphTreeModel *graph_tree_model ){ - graph_tree_model->graph = 0; -} - -static void graph_tree_model_finalize( GObject* object ){ - GraphTreeModel* graph_tree_model = GRAPH_TREE_MODEL( object ); - - /* must chain up */ - ( *g_parent_class->finalize )( object ); -} - -static void graph_tree_model_class_init( GraphTreeModelClass *class_ ){ - GObjectClass *object_class; - - g_parent_class = (GObjectClass*)g_type_class_peek_parent( class_ ); - object_class = (GObjectClass *) class_; - - object_class->finalize = graph_tree_model_finalize; -} - -static void graph_tree_model_tree_model_init( GtkTreeModelIface *iface ){ - iface->get_flags = graph_tree_model_get_flags; - iface->get_n_columns = graph_tree_model_get_n_columns; - iface->get_column_type = graph_tree_model_get_column_type; - iface->get_iter = graph_tree_model_get_iter; - iface->get_path = graph_tree_model_get_path; - iface->get_value = graph_tree_model_get_value; - iface->iter_next = graph_tree_model_iter_next; - iface->iter_children = graph_tree_model_iter_children; - iface->iter_has_child = graph_tree_model_iter_has_child; - iface->iter_n_children = graph_tree_model_iter_n_children; - iface->iter_nth_child = graph_tree_model_iter_nth_child; - iface->iter_parent = graph_tree_model_iter_parent; -} - -static gboolean graph_tree_model_row_draggable( GtkTreeDragSource *drag_source, GtkTreePath *path ){ -#ifdef _DEBUG - gint depth = gtk_tree_path_get_depth( path ); -#endif - return gtk_tree_path_get_depth( path ) > 1; -} - -static gboolean graph_tree_model_drag_data_delete( GtkTreeDragSource *drag_source, GtkTreePath *path ){ - GtkTreeIter iter; - - if ( gtk_tree_model_get_iter( GTK_TREE_MODEL( drag_source ), &iter, path ) ) { - graph_type::iterator i = graph_iterator_read_tree_iter( &iter ); - Path_deleteTop( ( *i ).first ); - return TRUE; - } - else - { - return FALSE; - } -} - -static gboolean graph_tree_model_drag_data_get( GtkTreeDragSource *drag_source, GtkTreePath *path, GtkSelectionData *selection_data ){ - if ( gtk_tree_set_row_drag_data( selection_data, GTK_TREE_MODEL( drag_source ), path ) ) { - return TRUE; - } - else - { - /* FIXME handle text targets at least. */ - } - - return FALSE; -} - -static void graph_tree_model_drag_source_init( GtkTreeDragSourceIface *iface ){ - iface->row_draggable = graph_tree_model_row_draggable; - iface->drag_data_delete = graph_tree_model_drag_data_delete; - iface->drag_data_get = graph_tree_model_drag_data_get; -} - -static gboolean graph_tree_model_drag_data_received( GtkTreeDragDest *drag_dest, GtkTreePath *dest, GtkSelectionData *selection_data ){ - GtkTreeModel *tree_model = GTK_TREE_MODEL( drag_dest ); - - GtkTreeModel *src_model = 0; - GtkTreePath *src_path = 0; - if ( gtk_tree_get_row_drag_data( selection_data, &src_model, &src_path ) - && src_model == tree_model ) { - /* Copy the given row to a new position */ - GtkTreeIter iter; - - if ( gtk_tree_model_get_iter( src_model, &iter, src_path ) ) { - int bleh = 0; - } - } - else - { - /* FIXME maybe add some data targets eventually, or handle text - * targets in the simple case. - */ - } - - return FALSE; -} - -static gboolean graph_tree_model_row_drop_possible( GtkTreeDragDest *drag_dest, GtkTreePath *dest_path, GtkSelectionData *selection_data ){ - gboolean retval = FALSE; - - GtkTreeModel *src_model = 0; - GtkTreePath *src_path = 0; - if ( gtk_tree_get_row_drag_data( selection_data, &src_model, &src_path ) != FALSE ) { - /* can only drag to ourselves */ - if ( src_model == GTK_TREE_MODEL( drag_dest ) ) { - /* Can't drop into ourself. */ - if ( !gtk_tree_path_is_ancestor( src_path, dest_path ) ) { - /* Can't drop if dest_path's parent doesn't exist */ - if ( gtk_tree_path_get_depth( dest_path ) > 1 ) { - GtkTreePath* tmp = gtk_tree_path_copy( dest_path ); - gtk_tree_path_up( tmp ); - - GtkTreeIter iter; - retval = gtk_tree_model_get_iter( GTK_TREE_MODEL( drag_dest ), &iter, tmp ); - - gtk_tree_path_free( tmp ); - } - } - } - - gtk_tree_path_free( src_path ); - } - - return retval; -} - -static void graph_tree_model_drag_dest_init( GtkTreeDragDestIface *iface ){ - iface->drag_data_received = graph_tree_model_drag_data_received; - iface->row_drop_possible = graph_tree_model_row_drop_possible; -} - -GType graph_tree_model_get_type( void ){ - static GType graph_tree_model_type = 0; - - if ( !graph_tree_model_type ) { - static const GTypeInfo graph_tree_model_info = - { - sizeof( GraphTreeModelClass ), - 0, /* base_init */ - 0, /* base_finalize */ - (GClassInitFunc) graph_tree_model_class_init, - 0, /* class_finalize */ - 0, /* class_data */ - sizeof( GraphTreeModel ), - 0, /* n_preallocs */ - (GInstanceInitFunc) graph_tree_model_init - }; - - static const GInterfaceInfo tree_model_info = - { - (GInterfaceInitFunc) graph_tree_model_tree_model_init, - 0, - 0 - }; - - static const GInterfaceInfo drag_source_info = - { - (GInterfaceInitFunc) graph_tree_model_drag_source_init, - 0, - 0 - }; - - static const GInterfaceInfo drag_dest_info = - { - (GInterfaceInitFunc) graph_tree_model_drag_dest_init, - 0, - 0 - }; - - graph_tree_model_type = g_type_register_static( G_TYPE_OBJECT, "GraphTreeModel", - &graph_tree_model_info, (GTypeFlags)0 ); - - g_type_add_interface_static( graph_tree_model_type, - GTK_TYPE_TREE_MODEL, - &tree_model_info ); - g_type_add_interface_static( graph_tree_model_type, - GTK_TYPE_TREE_DRAG_SOURCE, - &drag_source_info ); - g_type_add_interface_static( graph_tree_model_type, - GTK_TYPE_TREE_DRAG_DEST, - &drag_dest_info ); - } - - return graph_tree_model_type; -} - -GraphTreeModel* graph_tree_model_new(){ - GraphTreeModel* graph_tree_model = GRAPH_TREE_MODEL( g_object_new( graph_tree_model_get_type(), 0 ) ); - - graph_tree_model->graph = new graph_type; - - return graph_tree_model; -} - -void graph_tree_model_delete( GraphTreeModel* model ){ - delete model->graph; - g_object_unref( G_OBJECT( model ) ); -} - - -class TempNameable : public Nameable -{ -const char* m_name; -public: -TempNameable( const char* name ) : m_name( name ){ -} -const char* name() const { - return m_name; -} -void attach( const NameCallback& callback ){ -} -void detach( const NameCallback& callback ){ -} -}; - -void node_attach_name_changed_callback( scene::Node& node, const NameCallback& callback ){ - // Reference cannot be bound to dereferenced null pointer in well-defined - // C++ code, and Clang will assume that comparison below always evaluates - // to true, resulting in a segmentation fault. Use a dirty hack to force - // Clang to check those "bad" references for null nonetheless. - volatile intptr_t n = (intptr_t)&node; - - if ( n != 0 ) { - Nameable* nameable = Node_getNameable( node ); - if ( nameable != 0 ) { - nameable->attach( callback ); - } - } -} -void node_detach_name_changed_callback( scene::Node& node, const NameCallback& callback ){ - volatile intptr_t n = (intptr_t)&node; // see the comment on line 650 - - if ( n != 0 ) { - Nameable* nameable = Node_getNameable( node ); - if ( nameable != 0 ) { - nameable->detach( callback ); - } - } -} - -GraphTreeModel* scene_graph_get_tree_model(); // temp hack - -void graph_tree_model_row_inserted( GraphTreeModel* model, graph_type::iterator i ){ - GtkTreeIter iter; - graph_iterator_write_tree_iter( i, &iter ); - - GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter ); - - gint depth = gtk_tree_path_get_depth( tree_path ); - gint* indices = gtk_tree_path_get_indices( tree_path ); - - gtk_tree_model_row_inserted( GTK_TREE_MODEL( model ), tree_path, &iter ); - - gtk_tree_path_free( tree_path ); -} - -void graph_tree_model_row_deleted( GraphTreeModel* model, graph_type::iterator i ){ - GtkTreeIter iter; - graph_iterator_write_tree_iter( i, &iter ); - - GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter ); - - gtk_tree_model_row_deleted( GTK_TREE_MODEL( model ), tree_path ); - - gtk_tree_path_free( tree_path ); -} - -#include "generic/referencecounted.h" - -void graph_tree_model_set_name( const scene::Instance& instance, const char* name ){ - GraphTreeModel* model = scene_graph_get_tree_model(); - - if ( string_empty( name ) ) { // hack! - graph_type::iterator i = model->graph->find( PathConstReference( instance.path() ) ); - ASSERT_MESSAGE( i != model->graph->end(), "ERROR" ); - - graph_tree_model_row_deleted( model, i ); - - model->graph->erase( i ); - } - else - { - graph_type::iterator i = model->graph->insert( graph_type::value_type( PathConstReference( instance.path() ), &const_cast( instance ) ) ).first; - - graph_tree_model_row_inserted( model, i ); - } -} - -void graph_tree_model_insert( GraphTreeModel* model, const scene::Instance& instance ){ - graph_type::iterator i = model->graph->insert( graph_type::value_type( PathConstReference( instance.path() ), &const_cast( instance ) ) ).first; - - graph_tree_model_row_inserted( model, i ); - - node_attach_name_changed_callback( instance.path().top(), ConstReferenceCaller1( instance ) ); -} - -void graph_tree_model_erase( GraphTreeModel* model, const scene::Instance& instance ){ - node_detach_name_changed_callback( instance.path().top(), ConstReferenceCaller1( instance ) ); - - graph_type::iterator i = model->graph->find( PathConstReference( instance.path() ) ); - ASSERT_MESSAGE( i != model->graph->end(), "ERROR" ); - - graph_tree_model_row_deleted( model, i ); - - model->graph->erase( i ); -} - -#elif 1 - class GraphTreeNode; void graph_tree_model_row_changed( GraphTreeNode& node ); @@ -1232,197 +532,3 @@ void graph_tree_model_erase( GraphTreeModel* model, const scene::Instance& insta parent->erase( i ); delete node; } - - - -#endif - - - - -#if 0 -class TestGraphTreeModel -{ -public: -TestGraphTreeModel(){ - gtk_init( 0, 0 ); - - graph_type graph; - - scene::Node* root = *(scene::Node*)0xa0000000; - scene::Node* node1 = (scene::Node*)0xa0000001; - scene::Node* node2 = (scene::Node*)0xa0000002; - scene::Node* node3 = (scene::Node*)0xa0000003; - scene::Node* node4 = (scene::Node*)0xa0000004; - scene::Instance* instance = (scene::Instance*)0xaaaaaaaa; - - scene::Path rootpath( root ); - - graph.insert( graph_type::value_type( rootpath, instance ) ); - - rootpath.push( node1 ); - graph.insert( graph_type::value_type( rootpath, instance ) ); - rootpath.pop(); - - rootpath.push( node2 ); - graph.insert( graph_type::value_type( rootpath, instance ) ); - rootpath.push( node3 ); - graph.insert( graph_type::value_type( rootpath, instance ) ); - rootpath.pop(); - rootpath.push( node4 ); - graph.insert( graph_type::value_type( rootpath, instance ) ); - rootpath.pop(); - rootpath.pop(); - - GtkTreeModel* model = GTK_TREE_MODEL( graph_tree_model_new( &graph ) ); - - { - gint n_columns = gtk_tree_model_get_n_columns( model ); - ASSERT_MESSAGE( n_columns == 2, "test failed!" ); - } - - { - GType type = gtk_tree_model_get_column_type( model, 0 ); - ASSERT_MESSAGE( type == G_TYPE_POINTER, "test failed!" ); - } - - { - GType type = gtk_tree_model_get_column_type( model, 1 ); - ASSERT_MESSAGE( type == G_TYPE_POINTER, "test failed!" ); - } - - - { - GtkTreeIter iter; - gtk_tree_model_get_iter_first( model, &iter ); - - graph_type::iterator i = graph_iterator_read_tree_iter( &iter ); - ASSERT_MESSAGE( ( *i ).first.get().size() == 2 && ( *i ).first.get().top() == node1, "test failed!" ); - } - - { - GtkTreeIter iter; - gtk_tree_model_get_iter_first( model, &iter ); - - ASSERT_MESSAGE( gtk_tree_model_iter_has_child( model, &iter ) == FALSE, "test failed!" ); - - ASSERT_MESSAGE( gtk_tree_model_iter_n_children( model, &iter ) == 0, "test failed!" ); - - gtk_tree_model_iter_next( model, &iter ); - - ASSERT_MESSAGE( gtk_tree_model_iter_has_child( model, &iter ) != FALSE, "test failed!" ); - - ASSERT_MESSAGE( gtk_tree_model_iter_n_children( model, &iter ) == 2, "test failed!" ); - - { - GtkTreeIter child; - gtk_tree_model_iter_nth_child( model, &child, &iter, 0 ); - - scene::Node* test; - gtk_tree_model_get_value( model, &child, 0, (GValue*)&test ); - ASSERT_MESSAGE( test == node3, "test failed!" ); - - { - GtkTreeIter parent; - gtk_tree_model_iter_parent( model, &parent, &child ); - - scene::Node* test; - gtk_tree_model_get_value( model, &parent, 0, (GValue*)&test ); - ASSERT_MESSAGE( test == node2, "test failed!" ); - } - } - - { - GtkTreeIter child; - gtk_tree_model_iter_nth_child( model, &child, &iter, 1 ); - - scene::Node* test; - gtk_tree_model_get_value( model, &child, 0, (GValue*)&test ); - ASSERT_MESSAGE( test == node4, "test failed!" ); - } - } - - { - GtkTreeIter iter; - std::size_t count = 0; - for ( gboolean good = gtk_tree_model_get_iter_first( model, &iter ); good; good = gtk_tree_model_iter_next( model, &iter ) ) - { - scene::Node* test; - gtk_tree_model_get_value( model, &iter, 0, (GValue*)&test ); - - ASSERT_MESSAGE( ( count == 0 && test == node1 ) || ( count == 1 && test == node2 ), "test failed!" ); - ++count; - } - - ASSERT_MESSAGE( count == 2, "test failed!" ); - - } - - { - GtkTreeIter iter; - gtk_tree_model_get_iter_first( model, &iter ); - - scene::Node* test; - gtk_tree_model_get_value( model, &iter, 0, (GValue*)&test ); - ASSERT_MESSAGE( test == node1, "test failed!" ); - } - - { - GtkTreeIter iter; - GtkTreePath* path = gtk_tree_path_new_from_string( "0" ); - gtk_tree_model_get_iter( model, &iter, path ); - gtk_tree_path_free( path ); - - graph_type::iterator i = graph_iterator_read_tree_iter( &iter ); - ASSERT_MESSAGE( ( *i ).first.get().size() == 2 && ( *i ).first.get().top() == node1, "test failed!" ); - } - - { - GtkTreeIter iter; - GtkTreePath* path = gtk_tree_path_new_from_string( "1" ); - gtk_tree_model_get_iter( model, &iter, path ); - gtk_tree_path_free( path ); - - graph_type::iterator i = graph_iterator_read_tree_iter( &iter ); - ASSERT_MESSAGE( ( *i ).first.get().size() == 2 && ( *i ).first.get().top() == node2, "test failed!" ); - } - - { - GtkTreeIter iter; - graph_type::iterator i = graph.begin(); - ++i; - graph_iterator_write_tree_iter( i, &iter ); - - GtkTreePath* path = gtk_tree_model_get_path( model, &iter ); - - gint depth = gtk_tree_path_get_depth( path ); - gint* indices = gtk_tree_path_get_indices( path ); - - ASSERT_MESSAGE( depth == 1 && indices[0] == 0, "test failed!" ); - - gtk_tree_path_free( path ); - } - - { - GtkTreeIter iter; - graph_type::iterator i = graph.begin(); - ++i; - ++i; - graph_iterator_write_tree_iter( i, &iter ); - - GtkTreePath* path = gtk_tree_model_get_path( model, &iter ); - - gint depth = gtk_tree_path_get_depth( path ); - gint* indices = gtk_tree_path_get_indices( path ); - - ASSERT_MESSAGE( depth == 1 && indices[0] == 1, "test failed!" ); - - gtk_tree_path_free( path ); - } -} -}; - - -TestGraphTreeModel g_TestGraphTreeModel; - -#endif diff --git a/radiant/undo.cpp b/radiant/undo.cpp index 9910fb98..c2bbaf93 100644 --- a/radiant/undo.cpp +++ b/radiant/undo.cpp @@ -484,25 +484,3 @@ void mutate( unsigned int data ){ m_state.test_data = data; } }; - -#if 0 - -class TestUndo -{ -public: -TestUndo(){ - undoable_test test; - GlobalUndoSystem().begin( "bleh" ); - test.mutate( 3 ); - GlobalUndoSystem().begin( "blah" ); - test.mutate( 4 ); - GlobalUndoSystem().undo(); - GlobalUndoSystem().undo(); - GlobalUndoSystem().redo(); - GlobalUndoSystem().redo(); -} -}; - -TestUndo g_TestUndo; - -#endif diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index f3d1ae6f..0bc45cfd 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -227,11 +227,6 @@ void BuildMonitor_Run( GPtrArray* commands, const char* mapName ){ static void abortStream( message_info_t *data ){ GetWatchBSP()->EndMonitoringLoop(); // tell there has been an error -#if 0 - if ( GetWatchBSP()->HasBSPPlugin() ) { - g_BSPFrontendTable.m_pfnEndListen( 2 ); - } -#endif // yeah this doesn't look good.. but it's needed so that everything will be ignored until the stream goes out data->ignore_depth = -1; data->recurse++; @@ -240,17 +235,6 @@ static void abortStream( message_info_t *data ){ #include "stream_version.h" static void saxStartElement( message_info_t *data, const xmlChar *name, const xmlChar **attrs ){ -#if 0 - globalOutputStream() << "<" << name; - if ( attrs != 0 ) { - for ( const xmlChar** p = attrs; *p != 0; p += 2 ) - { - globalOutputStream() << " " << p[0] << "=" << makeQuoted( p[1] ); - } - } - globalOutputStream() << ">\n"; -#endif - if ( data->ignore_depth == 0 ) { if ( data->pGeometry != 0 ) { // we have a handler @@ -323,10 +307,6 @@ static void saxStartElement( message_info_t *data, const xmlChar *name, const xm } static void saxEndElement( message_info_t *data, const xmlChar *name ){ -#if 0 - globalOutputStream() << "<" << name << "/>\n"; -#endif - data->recurse--; // we are out of an ignored chunk if ( data->recurse == data->ignore_depth ) { @@ -348,11 +328,6 @@ static void saxEndElement( message_info_t *data, const xmlChar *name ){ #endif GetWatchBSP()->EndMonitoringLoop(); // tell there has been an error -#if 0 - if ( GetWatchBSP()->HasBSPPlugin() ) { - g_BSPFrontendTable.m_pfnEndListen( 2 ); - } -#endif return; } } @@ -613,12 +588,6 @@ void CWatchBSP::RoutineProcessing(){ if ( g_timer_elapsed( m_pTimer, NULL ) > g_WatchBSP_Timeout ) { gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", eMB_OK ); EndMonitoringLoop(); -#if 0 - if ( m_bBSPPlugin ) { - // status == 1 : didn't get the connection - g_BSPFrontendTable.m_pfnEndListen( 1 ); - } -#endif return; } #ifdef _DEBUG @@ -687,14 +656,6 @@ void CWatchBSP::RoutineProcessing(){ Net_Disconnect( m_pInSocket ); m_pInSocket = NULL; globalOutputStream() << "Connection closed.\n"; -#if 0 - if ( m_bBSPPlugin ) { - EndMonitoringLoop(); - // let the BSP plugin know that the job is done - g_BSPFrontendTable.m_pfnEndListen( 0 ); - return; - } -#endif // move to next step or finish m_iCurrentStep++; if ( m_iCurrentStep < m_pCmd->len ) { @@ -704,13 +665,6 @@ void CWatchBSP::RoutineProcessing(){ { // launch the engine .. OMG if ( g_WatchBSP_RunQuake ) { -#if 0 - // do we enter sleep mode before? - if ( g_WatchBSP_DoSleep ) { - globalOutputStream() << "Going into sleep mode..\n"; - g_pParentWnd->OnSleep(); - } -#endif globalOutputStream() << "Running engine...\n"; StringOutputStream cmd( 256 ); // build the command line diff --git a/radiant/winding.cpp b/radiant/winding.cpp index 9651af2c..b2339008 100644 --- a/radiant/winding.cpp +++ b/radiant/winding.cpp @@ -183,12 +183,6 @@ brushsplit_t Winding_ClassifyPlane( const Winding& winding, const Plane3& plane return split; } - -#define DEBUG_EPSILON ON_EPSILON -const double DEBUG_EPSILON_SQUARED = DEBUG_EPSILON * DEBUG_EPSILON; - -#define WINDING_DEBUG 0 - /// \brief Clip \p winding which lies on \p plane by \p clipPlane, resulting in \p clipped. /// If \p winding is completely in front of the plane, \p clipped will be identical to \p winding. /// If \p winding is completely in back of the plane, \p clipped will be empty. diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index b094b774..f8c20b8c 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -538,92 +538,6 @@ bool g_bCrossHairs = false; GtkMenu* XYWnd::m_mnuDrop = 0; -// this is disabled, and broken -// http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394 -#if 0 -void WXY_Print(){ - long width, height; - width = g_pParentWnd->ActiveXY()->Width(); - height = g_pParentWnd->ActiveXY()->Height(); - unsigned char* img; - const char* filename; - - filename = file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, "Save Image", 0, FILTER_BMP ); - if ( !filename ) { - return; - } - - g_pParentWnd->ActiveXY()->MakeCurrent(); - img = (unsigned char*)malloc( width * height * 3 ); - glReadPixels( 0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,img ); - - FILE *fp; - fp = fopen( filename, "wb" ); - if ( fp ) { - unsigned short bits; - unsigned long cmap, bfSize; - - bits = 24; - cmap = 0; - bfSize = 54 + width * height * 3; - - long byteswritten = 0; - long pixoff = 54 + cmap * 4; - short res = 0; - char m1 = 'B', m2 = 'M'; - fwrite( &m1, 1, 1, fp ); byteswritten++; // B - fwrite( &m2, 1, 1, fp ); byteswritten++; // M - fwrite( &bfSize, 4, 1, fp ); byteswritten += 4; // bfSize - fwrite( &res, 2, 1, fp ); byteswritten += 2; // bfReserved1 - fwrite( &res, 2, 1, fp ); byteswritten += 2; // bfReserved2 - fwrite( &pixoff, 4, 1, fp ); byteswritten += 4; // bfOffBits - - unsigned long biSize = 40, compress = 0, size = 0; - long pixels = 0; - unsigned short planes = 1; - fwrite( &biSize, 4, 1, fp ); byteswritten += 4; // biSize - fwrite( &width, 4, 1, fp ); byteswritten += 4; // biWidth - fwrite( &height, 4, 1, fp ); byteswritten += 4; // biHeight - fwrite( &planes, 2, 1, fp ); byteswritten += 2; // biPlanes - fwrite( &bits, 2, 1, fp ); byteswritten += 2; // biBitCount - fwrite( &compress, 4, 1, fp ); byteswritten += 4; // biCompression - fwrite( &size, 4, 1, fp ); byteswritten += 4; // biSizeImage - fwrite( &pixels, 4, 1, fp ); byteswritten += 4; // biXPelsPerMeter - fwrite( &pixels, 4, 1, fp ); byteswritten += 4; // biYPelsPerMeter - fwrite( &cmap, 4, 1, fp ); byteswritten += 4; // biClrUsed - fwrite( &cmap, 4, 1, fp ); byteswritten += 4; // biClrImportant - - unsigned long widthDW = ( ( ( width * 24 ) + 31 ) / 32 * 4 ); - long row, row_size = width * 3; - for ( row = 0; row < height; row++ ) - { - unsigned char* buf = img + row * row_size; - - // write a row - int col; - for ( col = 0; col < row_size; col += 3 ) - { - putc( buf[col + 2], fp ); - putc( buf[col + 1], fp ); - putc( buf[col], fp ); - } - byteswritten += row_size; - - unsigned long count; - for ( count = row_size; count < widthDW; count++ ) - { - putc( 0, fp ); // dummy - byteswritten++; - } - } - - fclose( fp ); - } - - free( img ); -} -#endif - #include "timer.h" diff --git a/tools/quake2/common/cmdlib.c b/tools/quake2/common/cmdlib.c index db6e2418..90c2453e 100644 --- a/tools/quake2/common/cmdlib.c +++ b/tools/quake2/common/cmdlib.c @@ -308,21 +308,6 @@ double I_FloatTime( void ){ time( &t ); return t; -#if 0 -// more precise, less portable - struct timeval tp; - struct timezone tzp; - static int secbase; - - gettimeofday( &tp, &tzp ); - - if ( !secbase ) { - secbase = tp.tv_sec; - return tp.tv_usec / 1000000.0; - } - - return ( tp.tv_sec - secbase ) + tp.tv_usec / 1000000.0; -#endif } void Q_getwd( char *out ){ diff --git a/tools/quake2/common/inout.c b/tools/quake2/common/inout.c index 30ae39df..ffef9e10 100644 --- a/tools/quake2/common/inout.c +++ b/tools/quake2/common/inout.c @@ -106,33 +106,6 @@ void xml_SendNode( xmlNodePtr node ){ pos += size; } -#if 0 - // NOTE: the NMSG_WriteString is limited to MAX_NETMESSAGE - // we will need to split into chunks - // (we could also go lower level, in the end it's using send and receiv which are not size limited) - //++timo FIXME: MAX_NETMESSAGE is not exactly the max size we can stick in the message - // there's some tweaking to do in l_net for that .. so let's give us a margin for now - - //++timo we need to handle the case of a buffer too big to fit in a single message - // try without checks for now - if ( xml_buf->use > MAX_NETMESSAGE - 10 ) { - // if we send that we are probably gonna break the stream at the other end.. - // and Error will call right there - //Error( "MAX_NETMESSAGE exceeded for XML feedback stream in FPrintf (%d)\n", xml_buf->use); - Sys_FPrintf( SYS_NOXML, "MAX_NETMESSAGE exceeded for XML feedback stream in FPrintf (%d)\n", xml_buf->use ); - xml_buf->content[xml_buf->use] = '\0'; //++timo this corrupts the buffer but we don't care it's for printing - Sys_FPrintf( SYS_NOXML, xml_buf->content ); - - } - - size = xml_buf->use; - memcpy( xmlbuf, xml_buf->content, size ); - xmlbuf[size] = '\0'; - NMSG_Clear( &msg ); - NMSG_WriteString( &msg, xmlbuf ); - Net_Send( brdcst_socket, &msg ); -#endif - xmlBufferFree( xml_buf ); } } diff --git a/tools/quake2/extra/bsp/qbsp3/brushbsp.c b/tools/quake2/extra/bsp/qbsp3/brushbsp.c index a111bd3b..edf3e363 100644 --- a/tools/quake2/extra/bsp/qbsp3/brushbsp.c +++ b/tools/quake2/extra/bsp/qbsp3/brushbsp.c @@ -590,18 +590,6 @@ int TestBrushToPlanenum (bspbrush_t *brush, int planenum, || (d_back < 0.0 && d_back > -1.0) ) (*epsilonbrush)++; -#if 0 - if (*numsplits == 0) - { // didn't really need to be split - if (front) - s = PSIDE_FRONT; - else if (back) - s = PSIDE_BACK; - else - s = 0; - } -#endif - return s; } @@ -618,11 +606,6 @@ existance by the vertex snapping. #define EDGE_LENGTH 0.2 qboolean WindingIsTiny (winding_t *w) { -#if 0 - if (WindingArea (w) < 1) - return true; - return false; -#else int i, j; vec_t len; vec3_t delta; @@ -641,7 +624,6 @@ qboolean WindingIsTiny (winding_t *w) } } return true; -#endif } /* @@ -1022,20 +1004,9 @@ void SplitBrush (bspbrush_t *brush, int planenum, { if (!cw[j]) continue; -#if 0 - if (WindingIsTiny (cw[j])) - { - FreeWinding (cw[j]); - continue; - } -#endif cs = &b[j]->sides[b[j]->numsides]; b[j]->numsides++; *cs = *s; -// cs->planenum = s->planenum; -// cs->texinfo = s->texinfo; -// cs->visible = s->visible; -// cs->original = s->original; cs->winding = cw[j]; cs->tested = false; } @@ -1312,19 +1283,6 @@ tree_t *BrushBSP (bspbrush_t *brushlist, vec3_t mins, vec3_t maxs) qprintf ("%5i visible nodes\n", c_nodes/2 - c_nonvis); qprintf ("%5i nonvis nodes\n", c_nonvis); qprintf ("%5i leafs\n", (c_nodes+1)/2); -#if 0 -{ // debug code -static node_t *tnode; -vec3_t p; - -p[0] = -1469; -p[1] = -118; -p[2] = 119; -tnode = PointInLeaf (tree->headnode, p); -printf ("contents: %i\n", tnode->contents); -p[0] = 0; -} -#endif return tree; } diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index 91f5e047..e688deb9 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -575,9 +575,6 @@ static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t origin[0] -= sideplane[0] * ( e + 1 ); origin[1] -= sideplane[1] * ( e + 1 ); origin[2] -= sideplane[2] * ( e + 1 ); -#ifdef DEBUG_27_1 - VectorClear( origin ); -#endif } } } diff --git a/tools/quake3/q3map2/vis.c b/tools/quake3/q3map2/vis.c index 702b7bfe..e47f8723 100644 --- a/tools/quake3/q3map2/vis.c +++ b/tools/quake3/q3map2/vis.c @@ -222,13 +222,7 @@ void ClusterMerge( int leafnum ){ ================== */ void CalcPortalVis( void ){ -#ifdef MREDEBUG - Sys_Printf( "%6d portals out of %d", 0, numportals * 2 ); - //get rid of the counter - RunThreadsOnIndividual( numportals * 2, qfalse, PortalFlow ); -#else RunThreadsOnIndividual( numportals * 2, qtrue, PortalFlow ); -#endif } @@ -240,20 +234,11 @@ void CalcPortalVis( void ){ void CalcPassageVis( void ){ PassageMemory(); -#ifdef MREDEBUG - _printf( "%6d portals out of %d", 0, numportals * 2 ); - RunThreadsOnIndividual( numportals * 2, qfalse, CreatePassages ); - _printf( "\n" ); - _printf( "%6d portals out of %d", 0, numportals * 2 ); - RunThreadsOnIndividual( numportals * 2, qfalse, PassageFlow ); - _printf( "\n" ); -#else Sys_Printf( "\n--- CreatePassages (%d) ---\n", numportals * 2 ); RunThreadsOnIndividual( numportals * 2, qtrue, CreatePassages ); Sys_Printf( "\n--- PassageFlow (%d) ---\n", numportals * 2 ); RunThreadsOnIndividual( numportals * 2, qtrue, PassageFlow ); -#endif } /* @@ -264,20 +249,11 @@ void CalcPassageVis( void ){ void CalcPassagePortalVis( void ){ PassageMemory(); -#ifdef MREDEBUG - Sys_Printf( "%6d portals out of %d", 0, numportals * 2 ); - RunThreadsOnIndividual( numportals * 2, qfalse, CreatePassages ); - Sys_Printf( "\n" ); - Sys_Printf( "%6d portals out of %d", 0, numportals * 2 ); - RunThreadsOnIndividual( numportals * 2, qfalse, PassagePortalFlow ); - Sys_Printf( "\n" ); -#else Sys_Printf( "\n--- CreatePassages (%d) ---\n", numportals * 2 ); RunThreadsOnIndividual( numportals * 2, qtrue, CreatePassages ); Sys_Printf( "\n--- PassagePortalFlow (%d) ---\n", numportals * 2 ); RunThreadsOnIndividual( numportals * 2, qtrue, PassagePortalFlow ); -#endif } /* diff --git a/tools/quake3/q3map2/visflow.c b/tools/quake3/q3map2/visflow.c index 5a7ffd92..efbfffde 100644 --- a/tools/quake3/q3map2/visflow.c +++ b/tools/quake3/q3map2/visflow.c @@ -655,10 +655,6 @@ void PortalFlow( int portalnum ){ vportal_t *p; int c_might, c_can; -#ifdef MREDEBUG - Sys_Printf( "\r%6d", portalnum ); -#endif - p = sorted_portals[portalnum]; if ( p->removed ) { @@ -778,11 +774,6 @@ void PassageFlow( int portalnum ){ threaddata_t data; int i; vportal_t *p; -// int c_might, c_can; - -#ifdef MREDEBUG - Sys_Printf( "\r%6d", portalnum ); -#endif p = sorted_portals[portalnum]; @@ -793,8 +784,6 @@ void PassageFlow( int portalnum ){ p->status = stat_working; -// c_might = CountBits (p->portalflood, numportals*2); - memset( &data, 0, sizeof( data ) ); data.base = p; @@ -808,13 +797,6 @@ void PassageFlow( int portalnum ){ RecursivePassageFlow( p, &data, &data.pstack_head ); p->status = stat_done; - - /* - c_can = CountBits (p->portalvis, numportals*2); - - Sys_FPrintf (SYS_VRB,"portal:%4i mightsee:%4i cansee:%4i (%i chains)\n", - (int)(p - portals), c_might, c_can, data.c_chains); - */ } /* @@ -1042,11 +1024,7 @@ void PassagePortalFlow( int portalnum ){ threaddata_t data; int i; vportal_t *p; -// int c_might, c_can; -#ifdef MREDEBUG - Sys_Printf( "\r%6d", portalnum ); -#endif p = sorted_portals[portalnum]; @@ -1057,8 +1035,6 @@ void PassagePortalFlow( int portalnum ){ p->status = stat_working; -// c_might = CountBits (p->portalflood, numportals*2); - memset( &data, 0, sizeof( data ) ); data.base = p; @@ -1344,10 +1320,6 @@ void CreatePassages( int portalnum ){ fixedWinding_t in, out, *res; -#ifdef MREDEBUG - Sys_Printf( "\r%6d", portalnum ); -#endif - portal = sorted_portals[portalnum]; if ( portal->removed ) { -- 2.39.2