//////////////////////////////////////////////////////////////////////
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 );
}
}
-#ifdef _DEBUG
-// Sys_Printf("%i points on brush\n", pointList.size());
-#endif
-
return static_cast<int>( pointList.size() );
}
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 ){
}
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 ){
#include "../StdAfx.h"
#include "AboutDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-//static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CAboutDialog dialog
#include "../bobtoolz.h"
#include "AutoCaulkDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CAutoCaulkDialog dialog
#include "../bobtoolz.h"
#include "AutoCaulkStartDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CAutoCaulkStartDialog dialog
#include "../StdAfx.h"
#include "DoorDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CDoorDialog dialog
#include "../StdAfx.h"
#include "IntersectDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CIntersectDialog dialog
#include "../bobtoolz.h"
#include "IntersectInfoDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CIntersectInfoDialog dialog
#include "PolygonDialog.h"
#include "../shapes.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CPolygonDialog dialog
#include "../StdAfx.h"
#include "StairDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CStairDialog dialog
#include "../bobtoolz.h"
#include "TextureResetDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CTextureResetDialog dialog
#include "../bobtoolz.h"
#include "BrushCheckDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CBrushCheckDialog dialog
#include "../bobtoolz.h"
#include "PathPlotterDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
/////////////////////////////////////////////////////////////////////////////
// CPathPlotterDialog dialog
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
}
}
}
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
}
}
}
-#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
}
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;
}
if ( !ValidSurface() ) {
return;
}
- /*
- ghCursorCurrent = LoadCursor(NULL,IDC_WAIT);
- SetCursor(ghCursorCurrent);
- */
-#if 0
- if ( SingleBrushSelected ) {
- g_FuncTable.m_pfnDeleteSelection();
- }
-#endif
+
GenerateXYZ();
ntri = NH * NV * 2;
if ( Decimate > 0 && ( Game != QUAKE3 || UsePatches == 0 ) ) {
MapOut( gNumNodes,gNumTris,gNode,gTri );
- /*
- ghCursorCurrent = ghCursorDefault;
- SetCursor(ghCursorCurrent);
- */
return;
}
//=============================================================
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;
}
//=============================================================
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 );
}
//=============================================================
}
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
}
};
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:
#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
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;
}
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(){
}
};
-#if 0
-template<typename Element>
-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<Key, Value> 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<typename Element>
class Matrix
{
}
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(){
}
}
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;
}
};
}
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(){
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<StringPreference, const char*, &StringPreference::importString> ImportStringCaller;
-void exportString( StringImportCallback& importer ){
- importer( m_string.c_str() );
-}
-typedef MemberCaller1<StringPreference, StringImportCallback&, &StringPreference::exportString> 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<IntPreference, const char*, &IntPreference::importString> ImportStringCaller;
-void exportString( StringImportCallback& importer ){
- int_export( m_int, importer );
-}
-typedef MemberCaller1<IntPreference, StringImportCallback&, &IntPreference::exportString> 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
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
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
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
typedef MemberCaller<Group, &Group::transformChanged> 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<typename Functor>
-inline void Scene_forEachChildTransformable( const Functor& functor, const scene::Path& path ){
- GlobalSceneGraph().traverse_subgraph( ChildInstanceWalker< InstanceApply<Transformable, Functor> >( functor ), path );
-}
-#endif
class GroupInstance :
public TargetableInstance,
public TransformModifier,
-#if 0
- public Transformable,
-#endif
public Renderable
{
class TypeCasts
TypeCasts(){
m_casts = TargetableInstance::StaticTypeCasts::instance().get();
InstanceStaticCast<GroupInstance, Renderable>::install( m_casts );
-#if 0
- InstanceStaticCast<GroupInstance, Transformable>::install( m_casts );
-#endif
}
InstanceTypeCastTable& get(){
return m_casts;
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 ) {
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 );
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;
}
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" );
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 );
}
void render( RenderStateFlags state ) const {
-#if 1
if ( ( state & RENDER_BUMP ) != 0 ) {
if ( GlobalShaderCache().useShaderLanguage() ) {
glNormalPointer( GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_vertices.data()->normal );
}
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<ArbitraryMeshVertex>::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 {
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<ArbitraryMeshVertex>::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 {
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 );
}
};
-
-#if 0
-
-template<typename Key, typename Type>
-class create_new
-{
-public:
-static Type* construct( const Key& key ){
- return new Type( key );
-}
-static void destroy( Type* value ){
- delete value;
-}
-};
-
-template<typename Key, typename Type, typename creation_policy = create_new<Key, Type> >
-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<char*>( 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 <map>
-
-class ModelCache
-{
-typedef PicoModel value_type;
-
-public:
-typedef PicoModelKey key_type;
-typedef cache_element<key_type, value_type, create_picomodel> elem_type;
-typedef std::map<key_type, elem_type> 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<remap_t*> remaps_t;
-remaps_t m_remaps;
-typedef std::vector<CopiedString> shaders_t;
-shaders_t m_shaders;
-typedef std::vector<Shader*> 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*>( inputStream )->read( buffer, length );
}
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" ) ) {
// 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 );
g_QglTable.m_pfn_qglTexCoord2f( 0.0f, 0.0f );
g_QglTable.m_pfn_qglVertex3f( 0.0f, static_cast<float>( w ), 0.0f - static_cast<float>( 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; i<m_nSurfaces; i++)
- {
- if(m_children[i].TestRay(ray, &depth_local))
- {
- if (depth_local < *dist) *dist = depth_local;
- }
- }
-
- return *dist < depth_start;
- }
- */
return 1;
}
-#if 0
-static void button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
- if ( CanProcess() ) {
- switch ( event->button )
- {
- 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 );
}
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<LPVOID>( &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<LPVOID>( &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<LPVOID>( &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<LPVOID>( &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 );
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
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() );
};
-#define BRUSH_CONNECTIVITY_DEBUG 0
-#define BRUSH_DEGENERATE_DEBUG 0
-
template<typename TextOuputStreamType>
inline TextOuputStreamType& ostream_write( TextOuputStreamType& ostream, const Matrix4& m ){
return ostream << "(" << m[0] << " " << m[1] << " " << m[2] << " " << m[3] << ", "
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
}
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 );
}
}
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] );
if ( mirror ) {
reverse();
}
-
-#if 0
- if ( check_plane_is_integer( planePoints() ) ) {
- if ( !off ) {
- globalErrorStream() << "caused by transform\n";
- }
- }
-#endif
MakePlane();
}
else
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 ) {
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 );
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";
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
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 {
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 ) {
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;
}
}
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;
}
}
{
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
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
}
else
{
-#if BRUSH_CONNECTIVITY_DEBUG
- globalOutputStream() << "face: " << i << "\n";
-#endif
windingForClipPlane( f.getWinding(), f.plane3() );
// update brush bounds
if ( w.numpoints < 3 ) {
return;
}
- //globalOutputStream() << "normal: " << normal << "\n";
Matrix4 local2tex;
Texdef_toTransform( projection, (float)width, (float)height, local2tex );
- //globalOutputStream() << "texdef: " << static_cast<const Vector3&>(local2tex.x()) << static_cast<const Vector3&>(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<const Vector3&>(xyz2st.x()) << static_cast<const Vector3&>(xyz2st.y()) << static_cast<const Vector3&>(xyz2st.z()) << "\n";
matrix4_multiply_by_matrix4( local2tex, xyz2st );
}
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;
// 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;
// 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 );
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 ){
TexMat_Scale( texmat2, static_cast<float>( w1 ) / static_cast<float>( w2 ), static_cast<float>( h1 ) / static_cast<float>( 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.
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
}
}
-
-#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];
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];
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;
}
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 );
// 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 );
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 );
}
}
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<float>( c_quantise_normal - j - i ),
- static_cast<float>( i ),
- static_cast<float>( 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<float>( 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<float>( 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<std::size_t>( zbits );
- std::size_t ybits_q = static_cast<std::size_t>( 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<float>( 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<const Selectable&>
-{
-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 );
}
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 ){
View m_view;
camera_t m_Camera;
RadiantCameraView m_cameraview;
-#if 0
-int m_PositionDragCursorX;
-int m_PositionDragCursorY;
-#endif
guint m_freemove_handle_focusout;
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();
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 ) );
}
-#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 ){
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 );
if ( !dialog.m_waiting_for_key ) {
return false;
}
-
-#if 0
- if ( event->is_modifier ) {
- return false;
- }
-#else
switch ( event->keyval )
{
case GDK_Shift_L:
case GDK_Hyper_R:
return false;
}
-#endif
dialog.m_waiting_for_key = false;
}
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 );
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 );
}
}
-#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
}
#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 );
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;
// 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;
{
}
int main( int argc, char* argv[] ){
- crt_init();
-
streams_init();
#ifdef WIN32
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" );
}
void SelectEdgeMode(){
-#if 0
- if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) {
- GlobalSelectionSystem().Select( false );
- }
-#endif
if ( EdgeMode() ) {
SelectionSystem_DefaultMode();
}
void SelectVertexMode(){
-#if 0
- if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) {
- GlobalSelectionSystem().Select( false );
- }
-#endif
if ( VertexMode() ) {
SelectionSystem_DefaultMode();
}
void SelectFaceMode(){
-#if 0
- if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) {
- GlobalSelectionSystem().Select( false );
- }
-#endif
if ( FaceMode() ) {
SelectionSystem_DefaultMode();
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" );
menu_tearoff( menu );
}
-#if 0
- create_menu_item_with_mnemonic( menu, "_Benchmark", FreeCaller<GlobalCamera_Benchmark>() );
-#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<WXY_Print>());
create_menu_item_with_mnemonic( menu, "_Background select", FreeCaller<WXY_BackgroundSelect>() );
return misc_menu_item;
}
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 ){
}
-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
}
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 ) );
return m_pCamWnd;
}
-void ReleaseContexts();
-void CreateContexts();
-
EViewStyle CurrentStyle(){
return m_nCurrentStyle;
};
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
}
}
resource->setNode( clone.get_pointer() );
{
- //ScopeTimer timer("clone subgraph");
Node_getTraversable( GlobalSceneGraph().root() )->traverse( CloneAll( clone ) );
}
}
}
-#if 0
- {
- Array<RenderIndex>::iterator first = m_tess.m_indices.begin();
- for ( std::size_t s = 0; s < m_tess.m_numStrips; s++ )
- {
- Array<RenderIndex>::iterator last = first + m_tess.m_lenStrips;
-
- for ( Array<RenderIndex>::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<ArbitraryMeshVertex>::iterator i = m_tess.m_vertices.begin(); i != m_tess.m_vertices.end(); ++i )
- {
- vector3_normalise( reinterpret_cast<Vector3&>( ( *i ).tangent ) );
- vector3_normalise( reinterpret_cast<Vector3&>( ( *i ).bitangent ) );
- }
- }
-#endif
-
SceneChangeNotify();
}
}
}
-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
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 );
+ }
}
};
void RenderDebug( RenderStateFlags state ) const;
-void RenderNormals( RenderStateFlags state ) const;
void pushElement( const XMLElement& element ){
switch ( m_xml_state.back().state() )
}
}
-#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 );
}
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"
g_plugins_menu = menu;
//TODO: some modules/plugins do not yet support refresh
-#if 0
- create_menu_item_with_mnemonic( menu, "Refresh", FreeCaller<Restart>() );
-
- // 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();
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 )
#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<float*>( &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;
GlobalOpenGL_debugAssertNoErrors();
- debug_string( "enable bump" );
g_bumpGLSLPass_enabled = true;
}
GlobalOpenGL_debugAssertNoErrors();
- debug_string( "disable bump" );
g_bumpGLSLPass_enabled = false;
}
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 ){
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<GLubyte> buffer( size );
- size = file.read( reinterpret_cast<StreamBase::byte_type*>( 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<const GLubyte*>( 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<const float*>( &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;
void render( OpenGLState& current, unsigned int globalstate, const Vector3& viewer );
};
-#define LIGHT_SHADER_DEBUG 0
-
-#if LIGHT_SHADER_DEBUG
-typedef std::vector<Shader*> LightDebugShaders;
-LightDebugShaders g_lightDebugShaders;
-#endif
-
class OpenGLStateLess
{
public:
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 );
}
}
else
-#endif
{
( *i )->addRenderable( renderable, modelview );
}
typedef std::set<RendererLight*> RendererLights;
-#define DEBUG_LIGHT_SYNC 0
-
class LinearLightList : public LightList
{
LightCullable& m_cullable;
}
}
}
-#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();
glFogfv( GL_FOG_COLOR, vector4_to_array( state.colour ) );
}
-#define DEBUG_SHADERS 0
-
class OpenGLShaderCache : public ShaderCache, public TexturesCacheObserver, public ModuleObserver
{
class CreateOpenGLShader
|| *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<const float*>( &projection ) );
- #if 0
- //qglGetFloatv(GL_PROJECTION_MATRIX, reinterpret_cast<float*>(&projection));
- #endif
glMatrixMode( GL_MODELVIEW );
glLoadMatrixf( reinterpret_cast<const float*>( &modelview ) );
- #if 0
- //qglGetFloatv(GL_MODELVIEW_MATRIX, reinterpret_cast<float*>(&modelview));
- #endif
ASSERT_MESSAGE( realised(), "render states are not realised" );
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 ) {
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
}
}
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 );
}
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();
if ( current.m_program != 0 ) {
current.m_program->disable();
glColor4fv( vector4_to_array( current.m_colour ) );
- debug_colour( "cleaning program" );
}
current.m_program = program;
glEnable( GL_TEXTURE_2D );
glColor4f( 1,1,1,self.m_colour[3] );
- debug_colour( "setting texture" );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
GlobalOpenGL_debugAssertNoErrors();
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();
}
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;
}
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();
}
|| 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;
}
current.m_program->setParameters( viewer, *( *i ).m_transform, lightBounds.origin + ( *i ).m_light->offset(), ( *i ).m_light->colour(), world2light );
- debug_string( "set lightBounds parameters" );
}
}
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();
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;
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];
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;
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;
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 ) );
sz * cy * cx - cz * sy * sx,
cz * cy * cx + sz * sy * sx
);
-#endif
}
struct RotateDialog
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;
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;
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
}
}
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;
: m_library( filename ), m_registerModule( 0 ){
if ( !m_library.failed() ) {
m_registerModule = reinterpret_cast<RegisterModulesFunc>( m_library.findSymbol( "Radiant_RegisterModules" ) );
-#if 0
- if ( !m_registerModule ) {
- m_registerModule = reinterpret_cast<RegisterModulesFunc>( m_library.findSymbol( "Radiant_RegisterModules@4" ) );
- }
-#endif
}
}
bool failed(){
};
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
}
}
-#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<CopiedString, CopiedString, HashStringNoCase, StringEqualNoCase> strings;
- strings["Monkey"] = "bleh";
- strings["MonkeY"] = "blah";
-}
-};
-
-const TestHashtable g_testhashtable;
-
-#endif
-
typedef std::pair<LoadImageCallback, CopiedString> TextureKey;
void qtexture_realise( qtexture_t& texture, const TextureKey& key ){
}
};
-#define DEBUG_TEXTURES 0
-
class TexturesMap : public TexturesCache
{
class TextureConstructor
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 ){
return NodeTypeCast<Nameable>::cast( node );
}
-#if 0
-
-#include "gtkutil/gtktreestore.h"
-
-template<typename value_type>
-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<scene::Instance, graph_tree_model_row_changed>( 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<scene::Instance, graph_tree_model_row_changed>( 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<PathConstReference, scene::Instance*, PathNameLess> graph_type;
-
-struct GraphTreeModel
-{
- GObject parent;
-
- graph_type* graph;
-};
-
-struct GraphTreeModelClass
-{
- GObjectClass parent_class;
-};
-
-#define GRAPH_TREE_MODEL( p ) ( reinterpret_cast<GraphTreeModel*>( 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<graph_type::iterator*>( &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<graph_type::iterator*>( &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<gpointer>( ( *i ).first.get().top() ) );
- }
- else{
- g_value_set_pointer( value, reinterpret_cast<gpointer>( 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<scene::Instance&>( 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<scene::Instance&>( instance ) ) ).first;
-
- graph_tree_model_row_inserted( model, i );
-
- node_attach_name_changed_callback( instance.path().top(), ConstReferenceCaller1<scene::Instance, const char*, graph_tree_model_set_name>( instance ) );
-}
-
-void graph_tree_model_erase( GraphTreeModel* model, const scene::Instance& instance ){
- node_detach_name_changed_callback( instance.path().top(), ConstReferenceCaller1<scene::Instance, const char*, graph_tree_model_set_name>( 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 );
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
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
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++;
#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
}
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 ) {
#endif
GetWatchBSP()->EndMonitoringLoop();
// tell there has been an error
-#if 0
- if ( GetWatchBSP()->HasBSPPlugin() ) {
- g_BSPFrontendTable.m_pfnEndListen( 2 );
- }
-#endif
return;
}
}
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
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 ) {
{
// 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
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.
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"
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 ){
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 );
}
}
|| (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;
}
#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;
}
}
return true;
-#endif
}
/*
{
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;
}
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;
}
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
}
}
}
==================
*/
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
}
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
}
/*
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
}
/*
vportal_t *p;
int c_might, c_can;
-#ifdef MREDEBUG
- Sys_Printf( "\r%6d", portalnum );
-#endif
-
p = sorted_portals[portalnum];
if ( p->removed ) {
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];
p->status = stat_working;
-// c_might = CountBits (p->portalflood, numportals*2);
-
memset( &data, 0, sizeof( data ) );
data.base = p;
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);
- */
}
/*
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];
p->status = stat_working;
-// c_might = CountBits (p->portalflood, numportals*2);
-
memset( &data, 0, sizeof( data ) );
data.base = p;
fixedWinding_t in, out, *res;
-#ifdef MREDEBUG
- Sys_Printf( "\r%6d", portalnum );
-#endif
-
portal = sorted_portals[portalnum];
if ( portal->removed ) {