From 76ea7385dd94aac435a858b05f87820e1cfadfd6 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Fri, 1 Nov 2013 00:24:58 +0000 Subject: [PATCH 1/8] Fixed a number of out of bounds accesses. Visual Studio's static code analyser found a number of out of bounds array accesses. This commit fixes a number of them as well as a few other problems the analyser brought up. This also fixes #1 in the issue tracker. --- tools/quake3/q3map2/bspfile_abstract.c | 9 +++++++-- tools/quake3/q3map2/light_bounce.c | 8 ++++---- tools/quake3/q3map2/lightmaps_ydnar.c | 5 +++++ tools/quake3/q3map2/main.c | 2 +- tools/quake3/q3map2/q3map2.h | 2 +- tools/quake3/q3map2/shaders.c | 1 + tools/quake3/q3map2/surface_meta.c | 3 ++- tools/urt/tools/quake3/q3map2/bspfile_abstract.c | 9 +++++++-- tools/urt/tools/quake3/q3map2/light_bounce.c | 8 ++++---- tools/urt/tools/quake3/q3map2/main.c | 2 +- tools/urt/tools/quake3/q3map2/q3map2.h | 2 +- tools/urt/tools/quake3/q3map2/shaders.c | 2 ++ tools/urt/tools/quake3/q3map2/surface_meta.c | 3 ++- 13 files changed, 38 insertions(+), 18 deletions(-) diff --git a/tools/quake3/q3map2/bspfile_abstract.c b/tools/quake3/q3map2/bspfile_abstract.c index 587cd716..524d5cc3 100644 --- a/tools/quake3/q3map2/bspfile_abstract.c +++ b/tools/quake3/q3map2/bspfile_abstract.c @@ -68,6 +68,8 @@ void IncDrawVerts(){ } else if ( numBSPDrawVerts > numBSPDrawVertsBuffer ) { + bspDrawVert_t *newBspDrawVerts; + numBSPDrawVertsBuffer *= 3; // multiply by 1.5 numBSPDrawVertsBuffer /= 2; @@ -75,11 +77,14 @@ void IncDrawVerts(){ numBSPDrawVertsBuffer = MAX_MAP_DRAW_VERTS; } - bspDrawVerts = realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer ); + newBspDrawVerts = realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer ); - if ( !bspDrawVerts ) { + if ( !newBspDrawVerts ) { + free (bspDrawVerts); Error( "realloc() failed (IncDrawVerts)" ); } + + bspDrawVerts = newBspDrawVerts; } memset( bspDrawVerts + ( numBSPDrawVerts - 1 ), 0, sizeof( bspDrawVert_t ) ); diff --git a/tools/quake3/q3map2/light_bounce.c b/tools/quake3/q3map2/light_bounce.c index 18249457..bc6fb91e 100644 --- a/tools/quake3/q3map2/light_bounce.c +++ b/tools/quake3/q3map2/light_bounce.c @@ -185,10 +185,10 @@ static void RadClipWindingEpsilon( radWinding_t *in, vec3_t normal, vec_t dist, } /* error check */ - if ( front->numVerts > maxPoints || front->numVerts > maxPoints ) { + if ( front->numVerts > maxPoints ) { Error( "RadClipWindingEpsilon: points exceeded estimate" ); } - if ( front->numVerts > MAX_POINTS_ON_WINDING || front->numVerts > MAX_POINTS_ON_WINDING ) { + if ( front->numVerts > MAX_POINTS_ON_WINDING ) { Error( "RadClipWindingEpsilon: MAX_POINTS_ON_WINDING" ); } } @@ -279,7 +279,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, /* multiply by texture color */ if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, rw->verts[ samples ].st, textureColor ) ) { VectorCopy( si->averageColor, textureColor ); - textureColor[ 4 ] = 255.0f; + textureColor[ 3 ] = 255.0f; } for ( i = 0; i < 3; i++ ) color[ i ] = ( textureColor[ i ] / 255 ) * ( rw->verts[ samples ].color[ lightmapNum ][ i ] / 255.0f ); @@ -363,7 +363,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, /* multiply by texture color */ if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, st, textureColor ) ) { VectorCopy( si->averageColor, textureColor ); - textureColor[ 4 ] = 255; + textureColor[ 3 ] = 255; } for ( i = 0; i < 3; i++ ) color[ i ] = ( textureColor[ i ] / 255 ) * ( radLuxel[ i ] / 255 ); diff --git a/tools/quake3/q3map2/lightmaps_ydnar.c b/tools/quake3/q3map2/lightmaps_ydnar.c index b0329349..9f8d6bec 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -2104,6 +2104,11 @@ static void FindOutLightmaps( rawLightmap_t *lm ){ /* allocate two new output lightmaps */ numOutLightmaps += 2; olm = safe_malloc( numOutLightmaps * sizeof( outLightmap_t ) ); + if ( !olm ) + { + Error( "FindOutLightmaps: Failed to allocate memory.\n" ); + } + if ( outLightmaps != NULL && numOutLightmaps > 2 ) { memcpy( olm, outLightmaps, ( numOutLightmaps - 2 ) * sizeof( outLightmap_t ) ); free( outLightmaps ); diff --git a/tools/quake3/q3map2/main.c b/tools/quake3/q3map2/main.c index 07125356..206af096 100644 --- a/tools/quake3/q3map2/main.c +++ b/tools/quake3/q3map2/main.c @@ -279,7 +279,7 @@ int AnalyzeBSP( int argc, char **argv ){ lumpInt = LittleLong( (int) *( (int*) lump ) ); lumpFloat = LittleFloat( (float) *( (float*) lump ) ); memcpy( lumpString, (char*) lump, ( length < 1024 ? length : 1024 ) ); - lumpString[ 1024 ] = '\0'; + lumpString[ 1023 ] = '\0'; /* print basic lump info */ Sys_Printf( "Lump: %d\n", i ); diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 936905d7..0da3f836 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -763,7 +763,7 @@ typedef struct shaderInfo_s sun_t *sun; /* ydnar */ vec3_t color; /* normalized color */ - vec3_t averageColor; + vec4_t averageColor; byte lightStyle; qb_t lmMergable; /* ydnar */ diff --git a/tools/quake3/q3map2/shaders.c b/tools/quake3/q3map2/shaders.c index cc58f64b..f747a27d 100644 --- a/tools/quake3/q3map2/shaders.c +++ b/tools/quake3/q3map2/shaders.c @@ -791,6 +791,7 @@ static void LoadShaderImages( shaderInfo_t *si ){ ColorNormalize( color, si->color ); } VectorScale( color, ( 1.0f / count ), si->averageColor ); + si->averageColor[ 3 ] = color[ 3 ] / count; } diff --git a/tools/quake3/q3map2/surface_meta.c b/tools/quake3/q3map2/surface_meta.c index 77ed7360..d4a5018c 100644 --- a/tools/quake3/q3map2/surface_meta.c +++ b/tools/quake3/q3map2/surface_meta.c @@ -740,7 +740,8 @@ static qboolean PointTriangleIntersect( vec3_t pt, vec4_t plane, vec3_t a, vec3_ typedef struct edge_s { - vec3_t origin, edge; + vec3_t origin; + vec4_t edge; vec_t length, kingpinLength; int kingpin; vec4_t plane; diff --git a/tools/urt/tools/quake3/q3map2/bspfile_abstract.c b/tools/urt/tools/quake3/q3map2/bspfile_abstract.c index 8a6cc6ea..116f3d33 100644 --- a/tools/urt/tools/quake3/q3map2/bspfile_abstract.c +++ b/tools/urt/tools/quake3/q3map2/bspfile_abstract.c @@ -68,6 +68,8 @@ void IncDrawVerts(){ } else if ( numBSPDrawVerts > numBSPDrawVertsBuffer ) { + bspDrawVert_t *newBspDrawVerts; + numBSPDrawVertsBuffer *= 3; // multiply by 1.5 numBSPDrawVertsBuffer /= 2; @@ -75,11 +77,14 @@ void IncDrawVerts(){ numBSPDrawVertsBuffer = MAX_MAP_DRAW_VERTS; } - bspDrawVerts = realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer ); + newBspDrawVerts = realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer ); - if ( !bspDrawVerts ) { + if ( !newBspDrawVerts ) { + free (bspDrawVerts); Error( "realloc() failed (IncDrawVerts)" ); } + + bspDrawVerts = newBspDrawVerts; } memset( bspDrawVerts + ( numBSPDrawVerts - 1 ), 0, sizeof( bspDrawVert_t ) ); diff --git a/tools/urt/tools/quake3/q3map2/light_bounce.c b/tools/urt/tools/quake3/q3map2/light_bounce.c index 686518b1..97ef4781 100644 --- a/tools/urt/tools/quake3/q3map2/light_bounce.c +++ b/tools/urt/tools/quake3/q3map2/light_bounce.c @@ -185,10 +185,10 @@ static void RadClipWindingEpsilon( radWinding_t *in, vec3_t normal, vec_t dist, } /* error check */ - if ( front->numVerts > maxPoints || front->numVerts > maxPoints ) { + if ( front->numVerts > maxPoints ) { Error( "RadClipWindingEpsilon: points exceeded estimate" ); } - if ( front->numVerts > MAX_POINTS_ON_WINDING || front->numVerts > MAX_POINTS_ON_WINDING ) { + if ( front->numVerts > MAX_POINTS_ON_WINDING ) { Error( "RadClipWindingEpsilon: MAX_POINTS_ON_WINDING" ); } } @@ -279,7 +279,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, /* multiply by texture color */ if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, rw->verts[ samples ].st, textureColor ) ) { VectorCopy( si->averageColor, textureColor ); - textureColor[ 4 ] = 255.0f; + textureColor[ 3 ] = 255.0f; } for ( i = 0; i < 3; i++ ) color[ i ] = ( textureColor[ i ] / 255 ) * ( rw->verts[ samples ].color[ lightmapNum ][ i ] / 255.0f ); @@ -363,7 +363,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, /* multiply by texture color */ if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, st, textureColor ) ) { VectorCopy( si->averageColor, textureColor ); - textureColor[ 4 ] = 255; + textureColor[ 3 ] = 255; } for ( i = 0; i < 3; i++ ) color[ i ] = ( textureColor[ i ] / 255 ) * ( radLuxel[ i ] / 255 ); diff --git a/tools/urt/tools/quake3/q3map2/main.c b/tools/urt/tools/quake3/q3map2/main.c index 2e9921b9..4000bd38 100644 --- a/tools/urt/tools/quake3/q3map2/main.c +++ b/tools/urt/tools/quake3/q3map2/main.c @@ -169,7 +169,7 @@ int AnalyzeBSP( int argc, char **argv ){ lumpInt = LittleLong( (int) *( (int*) lump ) ); lumpFloat = LittleFloat( (float) *( (float*) lump ) ); memcpy( lumpString, (char*) lump, ( length < 1024 ? length : 1024 ) ); - lumpString[ 1024 ] = '\0'; + lumpString[ 1023 ] = '\0'; /* print basic lump info */ Sys_Printf( "Lump: %d\n", i ); diff --git a/tools/urt/tools/quake3/q3map2/q3map2.h b/tools/urt/tools/quake3/q3map2/q3map2.h index fe21bd92..8935ef2e 100644 --- a/tools/urt/tools/quake3/q3map2/q3map2.h +++ b/tools/urt/tools/quake3/q3map2/q3map2.h @@ -743,7 +743,7 @@ typedef struct shaderInfo_s int sun_done; vec3_t color; /* normalized color */ - vec3_t averageColor; + vec4_t averageColor; byte lightStyle; qb_t lmMergable; /* ydnar */ diff --git a/tools/urt/tools/quake3/q3map2/shaders.c b/tools/urt/tools/quake3/q3map2/shaders.c index 9df04b84..863a59ef 100644 --- a/tools/urt/tools/quake3/q3map2/shaders.c +++ b/tools/urt/tools/quake3/q3map2/shaders.c @@ -789,10 +789,12 @@ static void LoadShaderImages( shaderInfo_t *si ){ if ( VectorLength( si->color ) <= 0.0f ) { ColorNormalize( color, si->color ); VectorScale( color, ( 1.0f / count ), si->averageColor ); + si->averageColor[ 3 ] = color[ 3 ] / count; } else { VectorCopy( si->color, si->averageColor ); + si->averageColor[ 3 ] = 1.0f; } } diff --git a/tools/urt/tools/quake3/q3map2/surface_meta.c b/tools/urt/tools/quake3/q3map2/surface_meta.c index a2d4747f..21a65146 100644 --- a/tools/urt/tools/quake3/q3map2/surface_meta.c +++ b/tools/urt/tools/quake3/q3map2/surface_meta.c @@ -743,7 +743,8 @@ static qboolean PointTriangleIntersect( vec3_t pt, vec4_t plane, vec3_t a, vec3_ typedef struct edge_s { - vec3_t origin, edge; + vec3_t origin; + vec4_t edge; vec_t length, kingpinLength; int kingpin; vec4_t plane; From 09c0da616cce898ba8ac2aa744f14c561ff3b36a Mon Sep 17 00:00:00 2001 From: neumond Date: Mon, 24 Mar 2014 06:57:46 +0400 Subject: [PATCH 2/8] Improved mousewheel zoom-in --- radiant/camwindow.cpp | 2 +- radiant/camwindow.h | 2 +- radiant/glwindow.cpp | 6 +++--- radiant/glwindow.h | 2 +- radiant/texwindow.cpp | 2 +- radiant/texwindow.h | 2 +- radiant/xywindow.cpp | 10 +++++++++- radiant/xywindow.h | 2 +- 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 4e3b8c0b..8a952be0 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -168,7 +168,7 @@ void CamWnd::OnMouseMove( guint32 flags, int pointx, int pointy ){ update_xor_rectangle( m_XORRectangle ); } -void CamWnd::OnMouseWheel( bool bUp ){ +void CamWnd::OnMouseWheel( bool bUp, int pointx, int pointy ){ if ( bUp ) { VectorMA( m_Camera.origin, g_PrefsDlg.m_nMoveSpeed, m_Camera.forward, m_Camera.origin ); } diff --git a/radiant/camwindow.h b/radiant/camwindow.h index 0978e683..674df16f 100644 --- a/radiant/camwindow.h +++ b/radiant/camwindow.h @@ -148,7 +148,7 @@ void OnLButtonUp( guint32 flags, int pointx, int pointy ); void OnRButtonUp( guint32 flags, int pointx, int pointy ); void OnMButtonUp( guint32 flags, int pointx, int pointy ); void OnMouseMove( guint32 flags, int pointx, int pointy ); -void OnMouseWheel( bool bUp ); +void OnMouseWheel( bool bUp, int pointx, int pointy ); void OnSize( int cx, int cy ); protected: diff --git a/radiant/glwindow.cpp b/radiant/glwindow.cpp index 92ae7c8b..92679836 100644 --- a/radiant/glwindow.cpp +++ b/radiant/glwindow.cpp @@ -79,8 +79,8 @@ static void button_press( GtkWidget *widget, GdkEventButton *event, gpointer dat case 2: flags |= MK_MBUTTON; break; case 3: flags |= MK_RBUTTON; break; #if !GTK_CHECK_VERSION( 1,3,0 ) - case 4: wnd->OnMouseWheel( true ); break; - case 5: wnd->OnMouseWheel( false ); break; + case 4: wnd->OnMouseWheel( true, (int)event->x, (int)event->y ); break; + case 5: wnd->OnMouseWheel( false, (int)event->x, (int)event->y ); break; #endif } @@ -177,7 +177,7 @@ static gint scroll_event( GtkWidget *widget, GdkEventScroll *event, gpointer data ){ GLWindow *wnd = (GLWindow*)data; - wnd->OnMouseWheel( ( event->direction == GDK_SCROLL_UP ) ? true : false ); + wnd->OnMouseWheel( ( event->direction == GDK_SCROLL_UP ) ? true : false, (int)event->x, (int)event->y ); return TRUE; } #endif diff --git a/radiant/glwindow.h b/radiant/glwindow.h index d5f6c732..f0903534 100644 --- a/radiant/glwindow.h +++ b/radiant/glwindow.h @@ -58,7 +58,7 @@ public: virtual void OnSize( int cx, int cy ) { } virtual void OnTimer() { } - virtual void OnMouseWheel( bool bUp ) { } + virtual void OnMouseWheel( bool bUp, int pointx, int pointy ) { } void RedrawWindow() { gtk_widget_queue_draw( m_pWidget ); } diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index db284edf..4223388b 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -1784,7 +1784,7 @@ void TexWnd::FocusEdit() { } } -void TexWnd::OnMouseWheel( bool bUp ){ +void TexWnd::OnMouseWheel( bool bUp, int pointx, int pointy ){ if ( bUp ) { if ( g_qeglobals.d_texturewin.originy < 0 ) { g_qeglobals.d_texturewin.originy += g_PrefsDlg.m_nWheelInc; diff --git a/radiant/texwindow.h b/radiant/texwindow.h index da794345..ae01183a 100644 --- a/radiant/texwindow.h +++ b/radiant/texwindow.h @@ -50,7 +50,7 @@ void OnMButtonUp( guint32 flags, int pointx, int pointy ); void OnMouseMove( guint32 flags, int pointx, int pointy ); void OnSize( int cx, int cy ); -void OnMouseWheel( bool bUp ); +void OnMouseWheel( bool bUp, int pointx, int pointy ); public: void OnVScroll(); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 560eb8fe..aaf19a98 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -1156,9 +1156,17 @@ void XYWnd::OnMouseMove( guint32 nFlags, int pointx, int pointy ){ update_xor_rectangle_xy( m_XORRectangle ); } -void XYWnd::OnMouseWheel( bool bUp ){ +void XYWnd::OnMouseWheel( bool bUp, int pointx, int pointy ){ if ( bUp ) { + // improved zoom-in + // frame coverges to part of window where the cursor currently resides + float old_scale = m_fScale; g_pParentWnd->OnViewZoomin(); + float scale_diff = 1.0 / old_scale - 1.0 / m_fScale; + int nDim1 = ( m_nViewType == YZ ) ? 1 : 0; + int nDim2 = ( m_nViewType == XY ) ? 1 : 2; + m_vOrigin[nDim1] += scale_diff * (pointx - 0.5 * m_nWidth); + m_vOrigin[nDim2] -= scale_diff * (pointy - 0.5 * m_nHeight); } else{ g_pParentWnd->OnViewZoomout(); diff --git a/radiant/xywindow.h b/radiant/xywindow.h index 31bfbeda..5f903d57 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -191,7 +191,7 @@ void OnLButtonUp( guint32 flags, int pointx, int pointy ); void OnRButtonUp( guint32 flags, int pointx, int pointy ); void OnMButtonUp( guint32 flags, int pointx, int pointy ); void OnMouseMove( guint32 nFlags, int pointx, int pointy ); -void OnMouseWheel( bool bUp ); +void OnMouseWheel( bool bUp, int pointx, int pointy ); void OnSize( int cx, int cy ); void OnTimer(); From 27946b2e132966e0c6093413b31df4eed3775426 Mon Sep 17 00:00:00 2001 From: neumond Date: Mon, 24 Mar 2014 07:46:49 +0400 Subject: [PATCH 3/8] Zoom option in preferences --- radiant/preferences.cpp | 9 +++++++++ radiant/preferences.h | 1 + radiant/xywindow.cpp | 23 ++++++++++++++--------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 288448b1..f116b1a7 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -102,6 +102,7 @@ #define ROTATION_KEY "Rotation" #define BUGGYICD_KEY "BuggyICD" #define CHASEMOUSE_KEY "ChaseMouse" +#define MOUSEWHEELZOOM_KEY "MousewheelZoom" #define ENTITYSHOW_KEY "EntityShow" #define TEXTURESCALE_KEY "TextureScale" #define TEXTURESCROLLBAR_KEY "TextureScrollbar" @@ -620,6 +621,7 @@ PrefsDlg::PrefsDlg (){ m_strUserPath = ""; m_nRotation = 0; m_bChaseMouse = FALSE; + m_bMousewheelZoom = FALSE; m_bTextureScrollbar = TRUE; m_bDisplayLists = TRUE; m_bAntialiasedPointsAndLines = FALSE; // Fishman - Add antialiazed points and lines support. 09/03/00 @@ -2271,6 +2273,12 @@ void PrefsDlg::BuildDialog(){ gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 ); AddDialogData( check, &m_bALTEdge, DLG_CHECK_BOOL ); + // Imroved mouse wheel zoom in + check = gtk_check_button_new_with_label( _( "Improved mousewheel zoom-in" ) ); + gtk_widget_show( check ); + gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 ); + AddDialogData( check, &m_bMousewheelZoom, DLG_CHECK_BOOL ); + // Mouse wheel increments // container hbox2 = gtk_hbox_new( FALSE, 5 ); @@ -2996,6 +3004,7 @@ void PrefsDlg::LoadPrefs(){ mLocalPrefs.GetPref( USERINI_KEY, &m_strUserPath, "" ); mLocalPrefs.GetPref( ROTATION_KEY, &m_nRotation, 45 ); mLocalPrefs.GetPref( CHASEMOUSE_KEY, &m_bChaseMouse, TRUE ); + mLocalPrefs.GetPref( MOUSEWHEELZOOM_KEY, &m_bMousewheelZoom, FALSE ); mLocalPrefs.GetPref( ENTITYSHOW_KEY, &m_nEntityShowState, ENTITY_SKINNED_BOXED ); // this will probably need to be 75 or 100 for Q1. diff --git a/radiant/preferences.h b/radiant/preferences.h index 79b43184..aaa2ee23 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -619,6 +619,7 @@ bool m_bSnap; Str m_strUserPath; int m_nRotation; bool m_bChaseMouse; +bool m_bMousewheelZoom; bool m_bTextureScrollbar; bool m_bDisplayLists; bool m_bAntialiasedPointsAndLines; // Fishman - Add antialiazed points and lines support. 09/03/00 diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index aaf19a98..06c0bcec 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -1158,15 +1158,20 @@ void XYWnd::OnMouseMove( guint32 nFlags, int pointx, int pointy ){ void XYWnd::OnMouseWheel( bool bUp, int pointx, int pointy ){ if ( bUp ) { - // improved zoom-in - // frame coverges to part of window where the cursor currently resides - float old_scale = m_fScale; - g_pParentWnd->OnViewZoomin(); - float scale_diff = 1.0 / old_scale - 1.0 / m_fScale; - int nDim1 = ( m_nViewType == YZ ) ? 1 : 0; - int nDim2 = ( m_nViewType == XY ) ? 1 : 2; - m_vOrigin[nDim1] += scale_diff * (pointx - 0.5 * m_nWidth); - m_vOrigin[nDim2] -= scale_diff * (pointy - 0.5 * m_nHeight); + if ( g_PrefsDlg.m_bMousewheelZoom == TRUE ) { + // improved zoom-in + // frame coverges to part of window where the cursor currently resides + float old_scale = m_fScale; + g_pParentWnd->OnViewZoomin(); + float scale_diff = 1.0 / old_scale - 1.0 / m_fScale; + int nDim1 = ( m_nViewType == YZ ) ? 1 : 0; + int nDim2 = ( m_nViewType == XY ) ? 1 : 2; + m_vOrigin[nDim1] += scale_diff * (pointx - 0.5 * m_nWidth); + m_vOrigin[nDim2] -= scale_diff * (pointy - 0.5 * m_nHeight); + } + else{ + g_pParentWnd->OnViewZoomin(); + } } else{ g_pParentWnd->OnViewZoomout(); From 6f6ee7f713597d2d8df8d5cc0b6c4ed7cf279b6e Mon Sep 17 00:00:00 2001 From: neumond Date: Tue, 25 Mar 2014 18:58:25 +0400 Subject: [PATCH 4/8] removed unused flag --- radiant/eclass_def.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/radiant/eclass_def.cpp b/radiant/eclass_def.cpp index 18f3ca6f..7db391c5 100644 --- a/radiant/eclass_def.cpp +++ b/radiant/eclass_def.cpp @@ -159,8 +159,9 @@ eclass_t *Eclass_InitFromText( char *text ){ text++; // get the size - text = COM_Parse( text ); + t = COM_Parse( text ); if ( Get_COM_Token()[0] == '(' ) { // parse the size as two vectors + text = t; e->fixedsize = true; r = sscanf( text,"%f %f %f) (%f %f %f)", &e->mins[0], &e->mins[1], &e->mins[2], &e->maxs[0], &e->maxs[1], &e->maxs[2] ); From 19bd95b0a25ada9f80f7953c66570b0d4e878833 Mon Sep 17 00:00:00 2001 From: Josh Steffen Date: Thu, 15 Jan 2015 07:14:03 -0500 Subject: [PATCH 5/8] Added option to change detail brush color in 2d view --- include/qertypes.h | 4 +++- radiant/mainframe.cpp | 12 ++++++++++++ radiant/mainframe.h | 2 ++ radiant/xywindow.cpp | 5 +++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/qertypes.h b/include/qertypes.h index b3631d88..e63f9c2f 100644 --- a/include/qertypes.h +++ b/include/qertypes.h @@ -68,7 +68,9 @@ typedef bool qboolean; #define COLOR_GRIDMINOR_ALT 13 #define COLOR_GRIDMAJOR_ALT 14 -#define COLOR_LAST 15 +#define COLOR_DETAIL 15 + +#define COLOR_LAST 16 // ---------------------------- diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 72c9e028..e84c47a7 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -549,6 +549,7 @@ gint HandleCommand( GtkWidget *widget, gpointer data ){ case ID_COLORS_SELECTEDBRUSH3D: g_pParentWnd->OnColorsSelectedbrush3D(); break; case ID_COLORS_CLIPPER: g_pParentWnd->OnColorsClipper(); break; case ID_COLORS_VIEWNAME: g_pParentWnd->OnColorsViewname(); break; + case ID_COLORS_DETAIL: g_pParentWnd->OnColorsDetail(); break; case ID_MISC_GAMMA: g_pParentWnd->OnMiscGamma(); break; case ID_MISC_FINDBRUSH: g_pParentWnd->OnMiscFindbrush(); break; case ID_MISC_NEXTLEAKSPOT: g_pParentWnd->OnMiscNextleakspot(); break; @@ -1418,6 +1419,8 @@ void MainFrame::create_main_menu( GtkWidget *window, GtkWidget *vbox ){ GTK_SIGNAL_FUNC( HandleCommand ), ID_COLORS_CLIPPER ); create_menu_item_with_mnemonic( menu_in_menu, _( "Active View name..." ), GTK_SIGNAL_FUNC( HandleCommand ), ID_COLORS_VIEWNAME ); + create_menu_item_with_mnemonic( menu_in_menu, _( "Detail brushes..." ), + GTK_SIGNAL_FUNC( HandleCommand ), ID_COLORS_DETAIL ); create_menu_item_with_mnemonic( menu, _( "_Gamma..." ), GTK_SIGNAL_FUNC( HandleCommand ), ID_MISC_GAMMA ); @@ -5884,6 +5887,10 @@ void MainFrame::OnColorSetoriginal(){ g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][1] = 0.0f; g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][2] = 0.0f; + g_qeglobals.d_savedinfo.colors[COLOR_DETAIL][0] = 0.0f; + g_qeglobals.d_savedinfo.colors[COLOR_DETAIL][1] = 0.0f; + g_qeglobals.d_savedinfo.colors[COLOR_DETAIL][2] = 0.0f; + g_PrefsDlg.SavePrefs(); Sys_UpdateWindows( W_ALL ); } @@ -6088,6 +6095,11 @@ void MainFrame::OnColorsViewname(){ Sys_UpdateWindows( W_ALL ); } +void MainFrame::OnColorsDetail(){ + DoColor( COLOR_DETAIL ); + Sys_UpdateWindows( W_ALL ); +} + void MainFrame::OnMiscGamma(){ float fSave = g_qeglobals.d_savedinfo.fGamma; DoGamma(); diff --git a/radiant/mainframe.h b/radiant/mainframe.h index 73f8ccee..5c3b65bd 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -105,6 +105,7 @@ struct SKeyInfo #define ID_COLORS_CLIPPER 32836 #define ID_COLORS_GRIDBLOCK 32837 #define ID_COLORS_VIEWNAME 32838 +#define ID_COLORS_DETAIL 37002 #define ID_COLOR_SETORIGINAL 32839 #define ID_COLOR_SETQER 32840 #define ID_COLOR_SETBLACK 32841 @@ -735,6 +736,7 @@ void OnColorsSelectedbrush3D(); void OnColorsCameraBack(); void OnColorsGridblock(); void OnColorsViewname(); +void OnColorsDetail(); void OnColorSetoriginal(); void OnColorSetqer(); void OnColorSetblack(); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 560eb8fe..179e130c 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -2856,6 +2856,11 @@ void XYWnd::XY_Draw(){ qglColor3fv( g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES] ); } + //Color detail brushes differently + if ( brush->brush_faces->texdef.contents & CONTENTS_DETAIL ) { + qglColor3fv( g_qeglobals.d_savedinfo.colors[COLOR_DETAIL] ); + } + #ifdef DBG_SCENEDUMP if ( bDump ) { Sys_FPrintf( SYS_WRN, "Active brush: %p ", brush ); From a1fd52a8c2f1a1b23ad1dca70556caa24233ea4f Mon Sep 17 00:00:00 2001 From: Josh Steffen Date: Thu, 15 Jan 2015 11:08:46 -0500 Subject: [PATCH 6/8] Changed 'Detail brushes...' to 'Detail Brush...' for consistency --- radiant/mainframe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index e84c47a7..55ca61be 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -1419,7 +1419,7 @@ void MainFrame::create_main_menu( GtkWidget *window, GtkWidget *vbox ){ GTK_SIGNAL_FUNC( HandleCommand ), ID_COLORS_CLIPPER ); create_menu_item_with_mnemonic( menu_in_menu, _( "Active View name..." ), GTK_SIGNAL_FUNC( HandleCommand ), ID_COLORS_VIEWNAME ); - create_menu_item_with_mnemonic( menu_in_menu, _( "Detail brushes..." ), + create_menu_item_with_mnemonic( menu_in_menu, _( "Detail Brush..." ), GTK_SIGNAL_FUNC( HandleCommand ), ID_COLORS_DETAIL ); create_menu_item_with_mnemonic( menu, _( "_Gamma..." ), From c55e2601142fd3dbfc3adc2098c307345ed1b0c7 Mon Sep 17 00:00:00 2001 From: Josh Steffen Date: Thu, 15 Jan 2015 15:54:54 -0500 Subject: [PATCH 7/8] only color detail brush if it's not part of an entity --- radiant/xywindow.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 179e130c..7b07ba99 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -2851,16 +2851,15 @@ void XYWnd::XY_Draw(){ if ( brush->owner != e && brush->owner ) { qglColor3fv( brush->owner->eclass->color ); } + else if ( brush->brush_faces->texdef.contents & CONTENTS_DETAIL ) + { + qglColor3fv( g_qeglobals.d_savedinfo.colors[COLOR_DETAIL] ); + } else { qglColor3fv( g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES] ); } - //Color detail brushes differently - if ( brush->brush_faces->texdef.contents & CONTENTS_DETAIL ) { - qglColor3fv( g_qeglobals.d_savedinfo.colors[COLOR_DETAIL] ); - } - #ifdef DBG_SCENEDUMP if ( bDump ) { Sys_FPrintf( SYS_WRN, "Active brush: %p ", brush ); From 805ceb9df679e66ff4cafcadcf56168fd2476e06 Mon Sep 17 00:00:00 2001 From: Josh Steffen Date: Fri, 16 Jan 2015 17:10:09 -0500 Subject: [PATCH 8/8] brace alignment --- radiant/xywindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 7b07ba99..e4f0b27e 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -2852,7 +2852,7 @@ void XYWnd::XY_Draw(){ qglColor3fv( brush->owner->eclass->color ); } else if ( brush->brush_faces->texdef.contents & CONTENTS_DETAIL ) - { + { qglColor3fv( g_qeglobals.d_savedinfo.colors[COLOR_DETAIL] ); } else