This commit is contained in:
Jay Dolan 2017-08-22 07:57:14 -04:00
commit 98c4cba5da
12 changed files with 64 additions and 50 deletions

View File

@ -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 );
}

View File

@ -27,6 +27,7 @@
//
#include "StdAfx.h"
#include <cmath>
@ -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;

View File

@ -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 );
}
@ -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;
@ -546,9 +560,9 @@ void CSG_Subtract( void ){
break;
}
if ( i != 3 ) {
continue; // definately don't touch
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;
@ -586,10 +600,10 @@ void CSG_Subtract( void ){
break;
}
if ( i != 3 ) {
continue; // definately don't touch
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;
@ -623,12 +637,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 );

View File

@ -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"
@ -2113,7 +2114,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 +2130,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 );
@ -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 );

View File

@ -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;

View File

@ -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

View File

@ -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 ) {

View File

@ -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;
}

View File

@ -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] ) {
@ -149,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 );
@ -168,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 );

View File

@ -89,6 +89,7 @@ polyset_t *Polyset_LoadSets( const char *file, int *numpolysets, int maxTrisPerS
}
else{
Error( "TRI files no longer supported" );
return NULL;
}
// TRI_LoadPolysets( file, &psets, numpolysets );

View File

@ -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
//
@ -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 );

View File

@ -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 );