if CSG substracting with a (set of) brush(es) that are all caulk, new splits will be caulk

This commit is contained in:
Timothee Besset 2017-08-20 16:38:02 -05:00
parent 732497b098
commit 8ea7e52fa0

View file

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