From 816bfc00814d36da5f14ff39ec5e8f2dd953b8e9 Mon Sep 17 00:00:00 2001 From: Pan7 Date: Sun, 13 Aug 2017 20:46:34 +0200 Subject: [PATCH 01/14] Fix warning missing sentinel in function call 3 --- radiant/preferences.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 97f0b6c3..28ddef39 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -2113,7 +2113,7 @@ void PrefsDlg::BuildDialog(){ spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 1024, 1, 10, 0 ) ), 1, 0 ); gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( spin ), TRUE ); - g_object_set( spin, "xalign", 1.0, NULL ); + g_object_set( spin, "xalign", 1.0, (char*)NULL ); gtk_box_pack_start( GTK_BOX( hbox2 ), spin, FALSE, FALSE, 0 ); gtk_widget_show( spin ); AddDialogData( spin, &m_nFixedTextureSizeWidth, DLG_SPIN_INT ); @@ -2129,7 +2129,7 @@ void PrefsDlg::BuildDialog(){ spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 1024, 1, 10, 0 ) ), 1, 0 ); gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( spin ), TRUE ); - g_object_set( spin, "xalign", 1.0, NULL ); + g_object_set( spin, "xalign", 1.0, (char*)NULL ); gtk_box_pack_start( GTK_BOX( hbox2 ), spin, FALSE, FALSE, 0 ); gtk_widget_show( spin ); AddDialogData( spin, &m_nFixedTextureSizeHeight, DLG_SPIN_INT ); From fc7e215e80745a04228f59933c7a6c8e268aab37 Mon Sep 17 00:00:00 2001 From: Pan7 Date: Tue, 15 Aug 2017 22:02:16 +0200 Subject: [PATCH 02/14] Q3data: Fix warning variable shortestSide is used uninitialized --- tools/quake3/q3data/md3lib.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/quake3/q3data/md3lib.c b/tools/quake3/q3data/md3lib.c index 78805b44..739c8aff 100644 --- a/tools/quake3/q3data/md3lib.c +++ b/tools/quake3/q3data/md3lib.c @@ -82,6 +82,11 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] ){ hypotSide = 2; origin = 1; } + else + { + Error( "invalid tag triangle, must be a right triangle with unequal length sides" ); + return; + } len[hypotSide] = -1; if ( len[0] > len[1] && len[0] > len[2] ) { From 614f97d425b0a96bcb648f24660e6c3f402fe33c Mon Sep 17 00:00:00 2001 From: Pan7 Date: Tue, 15 Aug 2017 22:04:30 +0200 Subject: [PATCH 03/14] Q3data: Fix warning format specifies type int but the argument has type long --- tools/quake3/q3data/video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/quake3/q3data/video.c b/tools/quake3/q3data/video.c index 7fceb79c..436d373e 100644 --- a/tools/quake3/q3data/video.c +++ b/tools/quake3/q3data/video.c @@ -1107,7 +1107,7 @@ void Cmd_Video( void ){ printf( "\n" ); - printf( "Total size: %i\n", ftell( output ) ); + printf( "Total size: %ld\n", ftell( output ) ); printf( "Average error: %f\n", sumError / ( frame - startframe ) ); printf( "Max error: %f\n", maxError ); From 465cb3ce3ff85248620adba57f1dab5123febd84 Mon Sep 17 00:00:00 2001 From: Pan7 Date: Tue, 15 Aug 2017 22:21:05 +0200 Subject: [PATCH 04/14] Q3data: Fix warning variable psets is used uninitialized --- tools/quake3/q3data/polyset.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/quake3/q3data/polyset.c b/tools/quake3/q3data/polyset.c index d8a9f617..e02705df 100644 --- a/tools/quake3/q3data/polyset.c +++ b/tools/quake3/q3data/polyset.c @@ -89,6 +89,7 @@ polyset_t *Polyset_LoadSets( const char *file, int *numpolysets, int maxTrisPerS } else{ Error( "TRI files no longer supported" ); + return; } // TRI_LoadPolysets( file, &psets, numpolysets ); From af45a9d65cc614d182d2346b1eed4f2554e8b53c Mon Sep 17 00:00:00 2001 From: Pan7 Date: Wed, 16 Aug 2017 16:29:45 +0200 Subject: [PATCH 05/14] Q3data: Fix warning incompatible pointer types passing --- tools/quake3/q3data/video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/quake3/q3data/video.c b/tools/quake3/q3data/video.c index 7fceb79c..7447d615 100644 --- a/tools/quake3/q3data/video.c +++ b/tools/quake3/q3data/video.c @@ -596,11 +596,11 @@ static float BTCCompressBlock( float inBlock[4][4][3], unsigned long out[2] ){ int i; int btcQuantizedBlock[4][4]; // values should be [0..3] unsigned long encodedEndPoints, encodedBitmap; - unsigned int endPoints[2][2]; // endPoints[0] = color start, endPoints[1] = color end + unsigned long endPoints[2][2]; // endPoints[0] = color start, endPoints[1] = color end int blockY, blockX; float error = 0; float bestError = 10000000000; - unsigned int bestEndPoints[2][2]; + unsigned long bestEndPoints[2][2]; #if 0 // From a9e28b55075c0c008402df25a1e71c271eb62ee7 Mon Sep 17 00:00:00 2001 From: Pan7 Date: Fri, 18 Aug 2017 02:18:31 +0200 Subject: [PATCH 06/14] Fix warning variable bcHeight is used uninitialized --- tools/quake3/common/imagelib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/quake3/common/imagelib.c b/tools/quake3/common/imagelib.c index e857c73a..0b25d2c5 100644 --- a/tools/quake3/common/imagelib.c +++ b/tools/quake3/common/imagelib.c @@ -755,6 +755,7 @@ void LoadBMP( const char *filename, byte **pic, byte **palette, int *width, int } else { Error( "%s had strange struct size", filename ); + return; } if ( bcPlanes != 1 ) { From d1c1de12532f0aa41f7d6b61cc133ad79431d932 Mon Sep 17 00:00:00 2001 From: Pan7 Date: Fri, 18 Aug 2017 20:00:41 +0200 Subject: [PATCH 07/14] Q3data: Fix warning passing unsigned short * to parameter of type short * --- tools/quake3/q3data/3dslib.c | 2 +- tools/quake3/q3data/polyset.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/quake3/q3data/3dslib.c b/tools/quake3/q3data/3dslib.c index 64c7cb07..3e37f5e4 100644 --- a/tools/quake3/q3data/3dslib.c +++ b/tools/quake3/q3data/3dslib.c @@ -47,7 +47,7 @@ static int ReadString( FILE *fp, char *buffer ){ return bytesRead; } -static int ReadChunkAndLength( FILE *fp, short *chunk, long *len ){ +static int ReadChunkAndLength( FILE *fp, unsigned short *chunk, long *len ){ if ( fread( chunk, sizeof( short ), 1, fp ) != 1 ) { return 0; } diff --git a/tools/quake3/q3data/polyset.c b/tools/quake3/q3data/polyset.c index e02705df..fcfc52a9 100644 --- a/tools/quake3/q3data/polyset.c +++ b/tools/quake3/q3data/polyset.c @@ -89,7 +89,7 @@ polyset_t *Polyset_LoadSets( const char *file, int *numpolysets, int maxTrisPerS } else{ Error( "TRI files no longer supported" ); - return; + return NULL; } // TRI_LoadPolysets( file, &psets, numpolysets ); From b2c2c8d37883ca16346073db7a3cfabc1d29a6a8 Mon Sep 17 00:00:00 2001 From: Pan7 Date: Sat, 19 Aug 2017 03:21:29 +0200 Subject: [PATCH 08/14] Q3data: Fix warning format %d expects argument of type int --- tools/quake3/q3data/md3lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/quake3/q3data/md3lib.c b/tools/quake3/q3data/md3lib.c index 739c8aff..76cc38d5 100644 --- a/tools/quake3/q3data/md3lib.c +++ b/tools/quake3/q3data/md3lib.c @@ -173,7 +173,7 @@ void MD3_Dump( const char *filename ){ printf( " num tags: %d\n", header.numTags ); printf( " num surfaces: %d\n", header.numSurfaces ); printf( " num skins: %d\n", header.numSkins ); - printf( " file size: %d\n", fileSize ); + printf( " file size: %ld\n", fileSize ); printf( "--- TAGS ---\n" ); pTag = ( md3Tag_t * ) ( ( ( char * ) buffer ) + header.ofsTags ); From 5f7efeecc8d2697c1ee137f5ee54489f3ca1f2b4 Mon Sep 17 00:00:00 2001 From: Pan7 Date: Sun, 20 Aug 2017 00:11:53 +0200 Subject: [PATCH 09/14] Fix warning using floating point absolute value function fabs --- plugins/textool/TexTool.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/textool/TexTool.cpp b/plugins/textool/TexTool.cpp index 55c6a443..73edf535 100644 --- a/plugins/textool/TexTool.cpp +++ b/plugins/textool/TexTool.cpp @@ -27,6 +27,7 @@ // #include "StdAfx.h" +#include @@ -260,19 +261,19 @@ void FitView( IWindow* hwndDlg, int TexSize[2] ){ } // we want a texture with the same X / Y ratio // compute XY space / window size ratio - float SSize = (float)fabs( g_2DView.m_Maxs[0] - g_2DView.m_Mins[0] ); - float TSize = (float)fabs( g_2DView.m_Maxs[1] - g_2DView.m_Mins[1] ); + float SSize = std::fabs( g_2DView.m_Maxs[0] - g_2DView.m_Mins[0] ); + float TSize = std::fabs( g_2DView.m_Maxs[1] - g_2DView.m_Mins[1] ); float XSize = TexSize[0] * SSize; float YSize = TexSize[1] * TSize; - float RatioX = XSize / (float)fabs( g_2DView.m_rect.left - g_2DView.m_rect.right ); - float RatioY = YSize / (float)fabs( g_2DView.m_rect.top - g_2DView.m_rect.bottom ); + float RatioX = XSize / std::fabs( g_2DView.m_rect.left - g_2DView.m_rect.right ); + float RatioY = YSize / std::fabs( g_2DView.m_rect.top - g_2DView.m_rect.bottom ); if ( RatioX > RatioY ) { - YSize = (float)fabs( g_2DView.m_rect.top - g_2DView.m_rect.bottom ) * RatioX; + YSize = std::fabs( g_2DView.m_rect.top - g_2DView.m_rect.bottom ) * RatioX; TSize = YSize / (float)TexSize[1]; } else { - XSize = (float)fabs( g_2DView.m_rect.left - g_2DView.m_rect.right ) * RatioY; + XSize = std::fabs( g_2DView.m_rect.left - g_2DView.m_rect.right ) * RatioY; SSize = XSize / (float)TexSize[0]; } g_2DView.m_Mins[0] = g_2DView.m_Center[0] - 0.5f * SSize; From 156fc19c137adaba0b04e6b0ececace3b6216d6b Mon Sep 17 00:00:00 2001 From: Timothee Besset Date: Sun, 20 Aug 2017 15:04:49 -0500 Subject: [PATCH 10/14] fix warning --- tools/quake3/q3data/md3lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/quake3/q3data/md3lib.c b/tools/quake3/q3data/md3lib.c index 76cc38d5..1e25ae62 100644 --- a/tools/quake3/q3data/md3lib.c +++ b/tools/quake3/q3data/md3lib.c @@ -154,8 +154,8 @@ void MD3_Dump( const char *filename ){ Error( "Unable to open '%s'\n", filename ); } - fileSize = filelength( fileno( fp ) ); - _buffer = malloc( filelength( fileno( fp ) ) ); + fileSize = Q_filelength( fp ); + _buffer = malloc( fileSize ); fread( _buffer, fileSize, 1, fp ); fclose( fp ); From 3a6c9d30edb4fc9580ac47f492d0d2faa66a7183 Mon Sep 17 00:00:00 2001 From: Timothee Besset Date: Sun, 20 Aug 2017 15:46:40 -0500 Subject: [PATCH 11/14] fix compile warning --- radiant/xywindow.cpp | 2 +- tools/quake3/q3map2/light_ydnar.c | 27 ++++++++------------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index dda0ec88..05cb99ff 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -2089,7 +2089,7 @@ void XYWnd::ProduceSplitLists(){ memset( &face,0,sizeof( face_t ) ); PlanePointsFromClipPoints( face.planepts, pBrush ); - // decide wether caulking should be applied on the splits + // decide whether caulking should be applied on the splits // FIXME: hack // this should take the first brush face, check shader for NODRAW, if it isn't nodraw then find the appropriate // common/ shader to use, out of solid+nodraw, nonsolid+nodraw, water+nodraw, lava+nodraw, nonsolid+nodraw+trans, water+nodraw+trans, lava+nodraw+trans.. and fog.. etc diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index e951771c..ec2524f1 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -1591,61 +1591,54 @@ void DirtyRawLightmap( int rawLightmapNum ){ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float by, int *sampleCluster, vec3_t sampleOrigin, vec3_t sampleNormal ){ int i, *cluster, *cluster2; - float *origin, *origin2, *normal; //% , *normal2; - vec3_t originVecs[ 2 ]; //% , normalVecs[ 2 ]; - + float *origin, *origin2, *normal; + vec3_t originVecs[ 2 ]; /* calulate x vector */ if ( ( x < ( lm->sw - 1 ) && bx >= 0.0f ) || ( x == 0 && bx <= 0.0f ) ) { cluster = SUPER_CLUSTER( x, y ); origin = SUPER_ORIGIN( x, y ); - //% normal = SUPER_NORMAL( x, y ); cluster2 = SUPER_CLUSTER( x + 1, y ); origin2 = *cluster2 < 0 ? SUPER_ORIGIN( x, y ) : SUPER_ORIGIN( x + 1, y ); - //% normal2 = *cluster2 < 0 ? SUPER_NORMAL( x, y ) : SUPER_NORMAL( x + 1, y ); } else if ( ( x > 0 && bx <= 0.0f ) || ( x == ( lm->sw - 1 ) && bx >= 0.0f ) ) { cluster = SUPER_CLUSTER( x - 1, y ); origin = *cluster < 0 ? SUPER_ORIGIN( x, y ) : SUPER_ORIGIN( x - 1, y ); - //% normal = *cluster < 0 ? SUPER_NORMAL( x, y ) : SUPER_NORMAL( x - 1, y ); cluster2 = SUPER_CLUSTER( x, y ); origin2 = SUPER_ORIGIN( x, y ); - //% normal2 = SUPER_NORMAL( x, y ); } else{ Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap S vector\n" ); + VectorClear( originVecs[0] ); + origin = originVecs[0]; + origin2 = originVecs[0]; } VectorSubtract( origin2, origin, originVecs[ 0 ] ); - //% VectorSubtract( normal2, normal, normalVecs[ 0 ] ); /* calulate y vector */ if ( ( y < ( lm->sh - 1 ) && bx >= 0.0f ) || ( y == 0 && bx <= 0.0f ) ) { cluster = SUPER_CLUSTER( x, y ); origin = SUPER_ORIGIN( x, y ); - //% normal = SUPER_NORMAL( x, y ); cluster2 = SUPER_CLUSTER( x, y + 1 ); origin2 = *cluster2 < 0 ? SUPER_ORIGIN( x, y ) : SUPER_ORIGIN( x, y + 1 ); - //% normal2 = *cluster2 < 0 ? SUPER_NORMAL( x, y ) : SUPER_NORMAL( x, y + 1 ); } else if ( ( y > 0 && bx <= 0.0f ) || ( y == ( lm->sh - 1 ) && bx >= 0.0f ) ) { cluster = SUPER_CLUSTER( x, y - 1 ); origin = *cluster < 0 ? SUPER_ORIGIN( x, y ) : SUPER_ORIGIN( x, y - 1 ); - //% normal = *cluster < 0 ? SUPER_NORMAL( x, y ) : SUPER_NORMAL( x, y - 1 ); cluster2 = SUPER_CLUSTER( x, y ); origin2 = SUPER_ORIGIN( x, y ); - //% normal2 = SUPER_NORMAL( x, y ); } else{ Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap T vector\n" ); + VectorClear( originVecs[1] ); + origin = originVecs[1]; + origin2 = originVecs[1]; } VectorSubtract( origin2, origin, originVecs[ 1 ] ); - //% VectorSubtract( normal2, normal, normalVecs[ 1 ] ); /* calculate new origin */ - //% VectorMA( origin, bx, originVecs[ 0 ], sampleOrigin ); - //% VectorMA( sampleOrigin, by, originVecs[ 1 ], sampleOrigin ); for ( i = 0; i < 3; i++ ) sampleOrigin[ i ] = sampleOrigin[ i ] + ( bx * originVecs[ 0 ][ i ] ) + ( by * originVecs[ 1 ][ i ] ); @@ -1656,10 +1649,6 @@ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float } /* calculate new normal */ - //% VectorMA( normal, bx, normalVecs[ 0 ], sampleNormal ); - //% VectorMA( sampleNormal, by, normalVecs[ 1 ], sampleNormal ); - //% if( VectorNormalize( sampleNormal, sampleNormal ) <= 0.0f ) - //% return qfalse; normal = SUPER_NORMAL( x, y ); VectorCopy( normal, sampleNormal ); From 732497b0980bef47f91c1c713594e27d959c9c56 Mon Sep 17 00:00:00 2001 From: Timothee Besset Date: Sun, 20 Aug 2017 16:24:56 -0500 Subject: [PATCH 12/14] make hollow uses caulk, based on a pref setting --- radiant/csg.cpp | 12 +++--------- radiant/preferences.cpp | 8 ++++++++ radiant/preferences.h | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/radiant/csg.cpp b/radiant/csg.cpp index 4977161a..8ed91b39 100644 --- a/radiant/csg.cpp +++ b/radiant/csg.cpp @@ -67,7 +67,7 @@ void CSG_MakeHollowMode( int mode ){ } else { VectorSubtract( split.planepts[i], move, split.planepts[i] ); } - Brush_SplitBrushByFace( b, &split, &front, &back ); + Brush_SplitBrushByFace( b, &split, &front, &back, g_PrefsDlg.m_bMakeHollowCaulk ); if ( back ) { Brush_Free( back ); } @@ -546,7 +546,7 @@ void CSG_Subtract( void ){ break; } if ( i != 3 ) { - continue; // definately don't touch + continue; // definitely don't touch } fragments = Brush_Subtract( s, b ); // if the brushes did not really intersect @@ -586,7 +586,7 @@ void CSG_Subtract( void ){ break; } if ( i != 3 ) { - continue; // definately don't touch + continue; // definitely don't touch } fragments = Brush_Subtract( s, b ); @@ -623,12 +623,6 @@ void CSG_Subtract( void ){ Undo_EndBrush( frag ); } - /*if (numfragments == 0) - { - Sys_Printf("Selected brush%s did not intersect with any other brushes.\n", - (selected_brushes.next->next == &selected_brushes) ? "":"es"); - return; - }*/ Sys_Printf( "done. (created %d fragment%s out of %d brush%s)\n", numfragments, ( numfragments == 1 ) ? "" : "s", numbrushes, ( numbrushes == 1 ) ? "" : "es" ); Sys_UpdateWindows( W_ALL ); diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 28ddef39..4bb3c681 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -139,6 +139,7 @@ #define DEFAULTTEXURESCALE_KEY "DefaultTextureScale" #define CAULKNEWBRUSHES_KEY "CaulkNewBrushes" #define CLIPCAULK_KEY "ClipCaulk" +#define HOLLOWCAULK_KEY "HollowCaulk" #define PATCHSHOWBOUNDS_KEY "PatchShowBounds" #define NATIVEGUI_KEY "NativeGUI" #define STARTONPRIMMON_KEY "StartOnPrimMon" @@ -2381,6 +2382,12 @@ void PrefsDlg::BuildDialog(){ gtk_widget_show( check ); AddDialogData( check, &m_bClipCaulk, DLG_CHECK_BOOL ); + // Make Hollow uses caulk + check = gtk_check_button_new_with_label( _( "Make Hollow uses caulk" ) ); + gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 ); + gtk_widget_show( check ); + AddDialogData( check, &m_bMakeHollowCaulk, DLG_CHECK_BOOL ); + // Don't clamp plane points check = gtk_check_button_new_with_label( _( "Don't clamp plane points" ) ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 ); @@ -3083,6 +3090,7 @@ void PrefsDlg::LoadPrefs(){ mLocalPrefs.GetPref( CAULKNEWBRUSHES_KEY, &m_bCaulkNewBrushes, TRUE ); mLocalPrefs.GetPref( SUBDIVISIONS_KEY, &m_nSubdivisions, SUBDIVISIONS_DEF ); mLocalPrefs.GetPref( CLIPCAULK_KEY, &m_bClipCaulk, FALSE ); + mLocalPrefs.GetPref( HOLLOWCAULK_KEY, &m_bMakeHollowCaulk, TRUE ); mLocalPrefs.GetPref( SNAPTTOGRID_KEY, &m_bSnapTToGrid, FALSE ); mLocalPrefs.GetPref( TARGETFIX_KEY, &m_bDoTargetFix, TRUE ); mLocalPrefs.GetPref( WHEELINC_KEY, &m_nWheelInc, 64 ); diff --git a/radiant/preferences.h b/radiant/preferences.h index fa2fefe7..ac6ca9d0 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -685,6 +685,7 @@ bool m_bRunQuake; bool m_bDoSleep; bool m_bClipCaulk; +bool m_bMakeHollowCaulk; // make the texture increments match the grid changes bool m_bSnapTToGrid; From 8ea7e52fa0d0bd6745a341d83770a174234418e0 Mon Sep 17 00:00:00 2001 From: Timothee Besset Date: Sun, 20 Aug 2017 16:38:02 -0500 Subject: [PATCH 13/14] if CSG substracting with a (set of) brush(es) that are all caulk, new splits will be caulk --- radiant/csg.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/radiant/csg.cpp b/radiant/csg.cpp index 8ed91b39..a7abb067 100644 --- a/radiant/csg.cpp +++ b/radiant/csg.cpp @@ -468,7 +468,7 @@ brush_t *Brush_MergeList( brush_t *brushlist, int onlyshape ){ The originals are undisturbed. ============= */ -brush_t *Brush_Subtract( brush_t *a, brush_t *b ){ +brush_t *Brush_Subtract( brush_t *a, brush_t *b, bool caulk = false ){ // a - b = out (list) brush_t *front, *back; brush_t *in, *out, *next; @@ -478,7 +478,7 @@ brush_t *Brush_Subtract( brush_t *a, brush_t *b ){ out = NULL; for ( f = b->brush_faces; f && in; f = f->next ) { - Brush_SplitBrushByFace( in, f, &front, &back ); + Brush_SplitBrushByFace( in, f, &front, &back, caulk ); if ( in != a ) { Brush_Free( in ); } @@ -514,6 +514,7 @@ void CSG_Subtract( void ){ brush_t *b, *s, *fragments, *nextfragment, *frag, *next, *snext; brush_t fragmentlist; int i, numfragments, numbrushes; + bool caulk = true; Sys_Printf( "Subtracting...\n" ); @@ -522,6 +523,19 @@ void CSG_Subtract( void ){ return; } + // If the brushes are all caulk, then force caulk into all the new splits + for ( b = selected_brushes.next; b != &selected_brushes; b = b->next ) { + for ( auto f = b->brush_faces; f; f = f->next ) { + if ( strcmp( f->pShader->getName(), g_pGameDescription->mCaulkShader.GetBuffer() ) ) { + caulk = false; + break; + } + } + } + if ( caulk ) { + Sys_Printf( "Subtracting with caulk, will apply caulk to the new splits.\n" ); + } + fragmentlist.next = &fragmentlist; fragmentlist.prev = &fragmentlist; @@ -548,7 +562,7 @@ void CSG_Subtract( void ){ if ( i != 3 ) { continue; // definitely don't touch } - fragments = Brush_Subtract( s, b ); + fragments = Brush_Subtract( s, b, caulk ); // if the brushes did not really intersect if ( fragments == s ) { continue; @@ -589,7 +603,7 @@ void CSG_Subtract( void ){ continue; // definitely don't touch } - fragments = Brush_Subtract( s, b ); + fragments = Brush_Subtract( s, b, caulk ); // if the brushes did not really intersect if ( fragments == s ) { continue; From 62d0a93fda2852ad04790d19151eefefeff0156f Mon Sep 17 00:00:00 2001 From: Timothee Besset Date: Sun, 20 Aug 2017 16:57:09 -0500 Subject: [PATCH 14/14] #162 bobtoolz brush cleanup wasn't loading patches, so it was dropping them from rebuilding func_group entities after fixing bad brushes in them --- contrib/bobtoolz/funchandlers-GTK.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/bobtoolz/funchandlers-GTK.cpp b/contrib/bobtoolz/funchandlers-GTK.cpp index 596c5ac2..03fea696 100644 --- a/contrib/bobtoolz/funchandlers-GTK.cpp +++ b/contrib/bobtoolz/funchandlers-GTK.cpp @@ -169,9 +169,9 @@ void DoPolygons( vec3_t vMin, vec3_t vMax ){ void DoFixBrushes(){ DMap world; - world.LoadAll(); + world.LoadAll( true ); - int count = world.FixBrushes( TRUE ); + int count = world.FixBrushes( true ); Sys_Printf( "%i invalid/duplicate planes removed\n", count ); }