2 BobToolz plugin for GtkRadiant
3 Copyright (C) 2001 Gordon Biggans
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "funchandlers.h"
21 #include "globaldefs.h"
23 #if GDEF_COMPILER_MSVC
24 #pragma warning(disable : 4786)
27 #include "dialogs/dialogs-gtk.h"
40 #include "DVisDrawer.h"
41 #include "DTrainDrawer.h"
44 #include "ScriptParser.h"
45 #include "DTreePlanter.h"
61 std::list<Str> exclusionList; // whole brush exclusion
62 std::list<Str> exclusionList_Face; // single face exclusion
64 bool el1Loaded = false;
65 bool el2Loaded = false;
66 bool clrLst1Loaded = false;
67 bool clrLst2Loaded = false;
69 DBobView* g_PathView = NULL;
70 DVisDrawer* g_VisView = NULL;
71 DTrainDrawer* g_TrainView = NULL;
72 DTreePlanter* g_TreePlanter = NULL;
75 //========================//
76 // Helper Functions //
77 //========================//
83 el1Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el1.txt" ), &exclusionList );
86 el2Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el2.txt" ), &exclusionList_Face );
91 //========================//
93 //========================//
96 UndoableCommand undo( "bobToolz.intersect" );
99 if ( DoIntersectBox( &rs ) == eIDCANCEL ) {
103 if ( rs.nBrushOptions == BRUSH_OPT_SELECTED ) {
104 if ( GlobalSelectionSystem().countSelected() < 2 ) {
105 //DoMessageBox("Invalid number of brushes selected, choose at least 2", "Error", eMB_OK);
106 globalErrorStream() << "bobToolz Intersect: Invalid number of brushes selected, choose at least 2.\n";
112 switch ( rs.nBrushOptions )
114 case BRUSH_OPT_SELECTED:
117 world.LoadFromEntity( GlobalRadiant().getMapWorldEntity(), false );
118 world.LoadSelectedBrushes();
121 case BRUSH_OPT_WHOLE_MAP:
123 world.LoadFromEntity( GlobalRadiant().getMapWorldEntity(), false );
127 world.RemoveNonCheckBrushes( &exclusionList, rs.bUseDetail );
130 if ( rs.bDuplicateOnly ) {
131 pbSelectList = world.BuildDuplicateList();
134 pbSelectList = world.BuildIntersectList();
137 world.SelectBrushes( pbSelectList );
138 int brushCount = GlobalSelectionSystem().countSelected();
139 globalOutputStream() << "bobToolz Intersect: " << brushCount << " intersecting brushes found.\n";
140 delete[] pbSelectList;
148 UndoableCommand undo( "bobToolz.polygons" );
149 // ensure we have something selected
150 if ( GlobalSelectionSystem().countSelected() != 1 ) {
151 //DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
152 globalErrorStream() << "bobToolz Polygons: Invalid number of brushes selected, choose 1 only.\n";
157 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
158 if ( !Node_isBrush( instance.path().top() ) ) {
159 //DoMessageBox("No brush selected, select ONLY one brush", "Error", eMB_OK);
160 globalErrorStream() << "bobToolz Polygons: No brush selected, select ONLY one brush.\n";
163 // ask user for type, size, etc....
164 if ( DoPolygonBox( &rs ) == eIDOK ) {
171 VectorSubtract( instance.worldAABB().origin, instance.worldAABB().extents, vMin );
172 VectorAdd( instance.worldAABB().origin, instance.worldAABB().extents, vMax );
174 Path_deleteTop( instance.path() );
178 poly.BuildInversePrism( vMin, vMax, rs.nSides, rs.bAlignTop );
182 if ( rs.bUseBorder ) {
183 poly.BuildBorderedPrism( vMin, vMax, rs.nSides, rs.nBorderWidth, rs.bAlignTop );
186 poly.BuildRegularPrism( vMin, vMax, rs.nSides, rs.bAlignTop );
196 UndoableCommand undo( "bobToolz.fixBrushes" );
200 int count = world.FixBrushes();
202 globalOutputStream() << "bobToolz FixBrushes: " << count << " invalid/duplicate planes removed.\n";
205 void DoResetTextures(){
206 UndoableCommand undo( "bobToolz.resetTextures" );
207 static ResetTextureRS rs;
210 if ( 1 /*g_SelectedFaceTable.m_pfnGetSelectedFaceCount() != 1*/ ) {
215 texName = GetCurrentTexture();
216 strcpy( rs.textureName, GetCurrentTexture() );
219 EMessageBoxReturn ret;
220 if ( ( ret = DoResetTextureBox( &rs ) ) == eIDCANCEL ) {
224 if ( rs.bResetTextureName ) {
225 texName = rs.textureName;
228 if ( ret == eIDOK ) {
230 world.LoadSelectedBrushes();
231 world.ResetTextures( texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName,
232 rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation, true );
237 world.LoadAll( true );
238 world.ResetTextures( texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName,
239 rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation );
243 void DoBuildStairs(){
244 UndoableCommand undo( "bobToolz.buildStairs" );
247 strcpy( rs.mainTexture, GetCurrentTexture() );
249 // ensure we have something selected
250 if ( GlobalSelectionSystem().countSelected() != 1 ) {
251 //DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
252 globalErrorStream() << "bobToolz BuildStairs: Invalid number of brushes selected, choose 1 only.\n";
256 // ask user for type, size, etc....
257 if ( DoBuildStairsBox( &rs ) == eIDOK ) {
261 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
262 VectorSubtract( instance.worldAABB().origin, instance.worldAABB().extents, vMin );
263 VectorAdd( instance.worldAABB().origin, instance.worldAABB().extents, vMax );
268 VectorSubtract( vMax, vMin, size );
270 if ( ( (int)size[2] % rs.stairHeight ) != 0 ) {
271 // stairs must fit evenly into brush
272 //DoMessageBox("Invalid stair height\nHeight of block must be divisable by stair height", "Error", eMB_OK);
273 globalErrorStream() << "bobToolz BuildStairs: Invalid stair height. Height of block must be divisable by stair height.\n";
278 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
279 Path_deleteTop( instance.path() );
283 int numSteps = (int)size[2] / rs.stairHeight;
285 if ( rs.style == STYLE_CORNER ) {
286 BuildCornerStairs( vMin, vMax, numSteps, rs.mainTexture, rs.riserTexture );
291 // Get Step Dimensions
292 float stairHeight = (float)rs.stairHeight;
294 if ( ( rs.direction == MOVE_EAST ) || ( rs.direction == MOVE_WEST ) ) {
295 stairWidth = ( size[0] ) / numSteps;
298 stairWidth = ( size[1] ) / numSteps;
302 // Build Base For Stair (bob's style)
303 if ( rs.style == STYLE_BOB ) {
304 Build_Wedge( rs.direction, vMin, vMax, true );
308 // Set First Step Starting Position
309 vMax[2] = vMin[2] + stairHeight;
310 SetInitialStairPos( rs.direction, vMin, vMax, stairWidth );
314 for ( int i = 0; i < numSteps; i++ )
316 if ( rs.style == STYLE_BOB ) {
317 Build_StairStep_Wedge( rs.direction, vMin, vMax, rs.mainTexture, rs.riserTexture, rs.bUseDetail );
319 else if ( rs.style == STYLE_ORIGINAL ) {
320 Build_StairStep( vMin, vMax, rs.mainTexture, rs.riserTexture, rs.direction );
323 // get step into next position
324 MoveBlock( rs.direction, vMin, vMax, stairWidth );
325 vMax[2] += stairHeight;
326 if ( rs.style == STYLE_BOB ) {
327 vMin[2] += stairHeight; // wedge bottom must be raised
336 UndoableCommand undo( "bobToolz.buildDoors" );
337 // ensure we have something selected
338 if ( GlobalSelectionSystem().countSelected() != 1 ) {
339 //DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
340 globalErrorStream() << "bobToolz BuildDoors: Invalid number of brushes selected, choose 1 only.\n";
345 strcpy( rs.mainTexture, GetCurrentTexture() );
347 if ( DoDoorsBox( &rs ) == eIDOK ) {
351 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
352 VectorSubtract( instance.worldAABB().origin, instance.worldAABB().extents, vMin );
353 VectorAdd( instance.worldAABB().origin, instance.worldAABB().extents, vMax );
354 Path_deleteTop( instance.path() );
357 BuildDoorsX2( vMin, vMax,
358 rs.bScaleMainH, rs.bScaleMainV,
359 rs.bScaleTrimH, rs.bScaleTrimV,
360 rs.mainTexture, rs.trimTexture,
361 rs.nOrientation ); // shapes.cpp
365 void DoPathPlotter(){
366 UndoableCommand undo( "bobToolz.pathPlotter" );
368 EMessageBoxReturn ret = DoPathPlotterBox( &rs );
369 if ( ret == eIDCANCEL ) {
372 if ( ret == eIDNO ) {
379 // ensure we have something selected
381 if( GlobalSelectionSystem().countSelected() != 1 )
383 //DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
384 globalOutputStream() << "bobToolz PathPlotter: Invalid number of entities selected, choose 1 trigger_push entity only.\n";
388 Entity* entity = Node_getEntity( GlobalSelectionSystem().ultimateSelected().path().top() );
390 DBobView_setEntity( *entity, rs.fMultiplier, rs.nPoints, rs.fGravity, rs.bNoUpdate, rs.bShowExtra );
392 else{ globalErrorStream() << "bobToolz PathPlotter: No trigger_push entitity selected, select 1 only (Use list to select it).\n"; }
397 UndoableCommand undo( "bobToolz.pitBuilder" );
398 // ensure we have something selected
399 if ( GlobalSelectionSystem().countSelected() != 1 ) {
400 //DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
401 globalErrorStream() << "bobToolz PitBuilder: Invalid number of brushes selected, choose 1 only.\n";
407 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
408 //seems it does this also with a patch with valid dimensions.. but probably better to enforce a brush.
409 if ( !Node_isBrush( instance.path().top() ) ) {
410 //DoMessageBox("No brush selected, select ONLY one brush", "Error", eMB_OK);
411 globalErrorStream() << "bobToolz PitBuilder: No brush selected, select ONLY 1 brush.\n";
415 VectorSubtract( instance.worldAABB().origin, instance.worldAABB().extents, vMin );
416 VectorAdd( instance.worldAABB().origin, instance.worldAABB().extents, vMax );
420 if ( pit.BuildPit( vMin, vMax ) ) {
422 Path_deleteTop( instance.path() );
426 //DoMessageBox("Failed To Make Pit\nTry Making The Brush Bigger", "Error", eMB_OK);
427 globalErrorStream() << "bobToolz PitBuilder: Failed to make Pit, try making the brush bigger.\n";
431 void DoMergePatches(){
432 UndoableCommand undo( "bobToolz.mergePatches" );
433 patch_merge_t merge_info;
434 DPatch mrgPatches[2];
437 // ensure we have something selected
438 if ( GlobalSelectionSystem().countSelected() != 2 ) {
439 globalErrorStream() << "bobToolz MergePatches: Invalid number of patches selected, choose 2 only.\n";
440 //DoMessageBox("Invalid number of patches selected, choose 2 only", "Error", eMB_OK);
444 scene::Instance* patches[2];
445 patches[0] = &GlobalSelectionSystem().ultimateSelected();
446 patches[1] = &GlobalSelectionSystem().penultimateSelected();
448 for ( i = 0; i < 2; i++ )
450 if ( !Node_isPatch( patches[i]->path().top() ) ) {
451 //DoMessageBox("No patches selected, select ONLY patches", "Error", eMB_OK);
452 globalErrorStream() << "bobToolz MergePatches: Invalid number of patches selected, choose ONLY 2 patches.\n";
456 mrgPatches[i].LoadFromPatch( *patches[i] );
459 /* mrgPatches[0].Transpose();
460 mrgPatches[0].RemoveFromRadiant();
461 mrgPatches[0].BuildInRadiant();*/
463 merge_info = mrgPatches[0].IsMergable( &mrgPatches[1] );
465 if ( merge_info.mergable ) {
466 globalOutputStream() << merge_info.pos1 << " " << merge_info.pos2;
467 //Message removed, No tools give feedback on success.
468 //globalOutputStream() << "bobToolz MergePatches: Patches Mergable.\n";
469 DPatch* newPatch = mrgPatches[0].MergePatches( merge_info, &mrgPatches[0], &mrgPatches[1] );
471 /* mrgPatches[0].RemoveFromRadiant();
472 mrgPatches[0].BuildInRadiant();
474 mrgPatches[1].RemoveFromRadiant();
475 mrgPatches[1].BuildInRadiant();
484 Path_deleteTop( patches[0]->path() );
485 Path_deleteTop( patches[1]->path() );
487 newPatch->BuildInRadiant();
493 globalErrorStream() << "bobToolz.mergePatch: The selected patches are not mergable.\n";
498 void DoSplitPatch() {
499 UndoableCommand undo( "bobToolz.splitPatch" );
503 // ensure we have something selected
504 if ( GlobalSelectionSystem().countSelected() != 1 ) {
505 //DoMessageBox("Invalid number of patches selected, choose 1 only", "Error", eMB_OK);
506 globalErrorStream() << "bobToolz SplitPatch: Invalid number of patches selected, choose only 1 patch.\n";
510 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
512 if ( !Node_isPatch( instance.path().top() ) ) {
513 //DoMessageBox("No patch selected, select ONLY one patch", "Error", eMB_OK);
514 globalErrorStream() << "bobToolz SplitPatch: No patch selected, select ONLY 1 patch.\n";
518 patch.LoadFromPatch( instance );
520 std::list<DPatch> patchList = patch.Split();
521 for ( std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++ ) {
522 ( *patches ).BuildInRadiant();
525 Path_deleteTop( instance.path() );
528 void DoSplitPatchCols() {
529 UndoableCommand undo( "bobToolz.splitPatchCols" );
533 // ensure we have something selected
534 if ( GlobalSelectionSystem().countSelected() != 1 ) {
535 //DoMessageBox("Invalid number of patches selected, choose 1 only", "Error", eMB_OK);
536 globalErrorStream() << "bobToolz SplitPatchCols: Invalid number of patches selected, choose 1 only.\n";
540 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
542 if ( !Node_isPatch( instance.path().top() ) ) {
543 //DoMessageBox("No patch selected, select ONLY one patch", "Error", eMB_OK);
544 globalErrorStream() << "bobToolz SplitPatchCols: No patch selected, select ONLY 1 patch.\n";
548 patch.LoadFromPatch( instance );
550 std::list<DPatch> patchList = patch.SplitCols();
551 for ( std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++ ) {
552 ( *patches ).BuildInRadiant();
555 Path_deleteTop( instance.path() );
558 void DoSplitPatchRows() {
559 UndoableCommand undo( "bobToolz.splitPatchRows" );
563 // ensure we have something selected
564 if ( GlobalSelectionSystem().countSelected() != 1 ) {
565 //DoMessageBox("Invalid number of patches selected, choose 1 only", "Error", eMB_OK);
566 globalErrorStream() << "bobToolz SplitPatchRows: Invalid number of patches selected, choose 1 only.\n";
570 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
572 if ( !Node_isPatch( instance.path().top() ) ) {
573 //DoMessageBox("No patch selected, select ONLY one patch", "Error", eMB_OK);
574 globalErrorStream() << "bobToolz SplitPatchRows: No patch selected, select ONLY 1 patch.\n";
578 patch.LoadFromPatch( instance );
580 std::list<DPatch> patchList = patch.SplitRows();
581 for ( std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++ ) {
582 ( *patches ).BuildInRadiant();
585 Path_deleteTop( instance.path() );
591 if ( GlobalSelectionSystem().countSelected() == 0 ) {
592 globalErrorStream() << "bobToolz VisAnalyse: Invalid number of objects selected, choose 1 only.\n";
599 // ensure we have something selected
600 if ( GlobalSelectionSystem().countSelected() != 1 ) {
601 //DoMessageBox("Invalid number of objects selected, choose 1 only", "Error", eMB_OK);
602 globalErrorStream() << "bobToolz VisAnalyse: Invalid number of objects selected, choose 1 only.\n";
606 scene::Instance& brush = GlobalSelectionSystem().ultimateSelected();
607 //ensure we have a brush selected
608 if ( !Node_isBrush( brush.path().top() ) ) {
609 //DoMessageBox("No brush selected, select ONLY one brush", "Error", eMB_OK);
610 globalErrorStream() << "bobToolz VisAnalyse: No brush selected, select ONLY 1 brush.\n";
614 orgBrush.LoadFromBrush( brush, false );
616 orgBrush.BuildBounds();
618 origin[0] = ( orgBrush.bbox_max[0] + orgBrush.bbox_min[0] ) / 2.f;
619 origin[1] = ( orgBrush.bbox_max[1] + orgBrush.bbox_min[1] ) / 2.f;
620 origin[2] = ( orgBrush.bbox_max[2] + orgBrush.bbox_min[2] ) / 2.f;
623 const char* rad_filename = GlobalRadiant().getMapName();
624 if ( !rad_filename ) {
625 //DoMessageBox("An ERROR occurred while trying\n to get the map filename", "Error", eMB_OK);
626 globalErrorStream() << "bobToolz VisAnalyse: An ERROR occurred while trying to get the map filename.\n";
630 strcpy( filename, rad_filename );
632 char* ext = strrchr( filename, '.' ) + 1;
633 strcpy( ext, "bsp" ); // rename the extension
635 std::list<DWinding*> *pointList = BuildTrace( filename, origin );
638 g_VisView = new DVisDrawer;
641 g_VisView->SetList( pointList );
644 void DoTrainPathPlot() {
650 g_TrainView = new DTrainDrawer();
653 void DoCaulkSelection() {
654 UndoableCommand undo( "bobToolz.caulkSelection" );
657 float fScale[2] = { 0.5f, 0.5f };
658 float fShift[2] = { 0.0f, 0.0f };
660 int bResetScale[2] = { false, false };
661 int bResetShift[2] = { false, false };
663 world.LoadSelectedBrushes();
664 world.LoadSelectedPatches();
665 world.ResetTextures( NULL, fScale, fShift, 0, "textures/common/caulk", true, bResetScale, bResetShift, false, true );
668 void DoTreePlanter() {
669 UndoableCommand undo( "bobToolz.treePlanter" );
670 if ( g_TreePlanter ) {
671 delete g_TreePlanter;
672 g_TreePlanter = NULL;
676 g_TreePlanter = new DTreePlanter();
680 UndoableCommand undo( "bobToolz.dropEntities" );
681 if ( g_TreePlanter ) {
682 g_TreePlanter->DropEntsToGround();
688 if ( DoMakeChainBox( &rs ) == eIDOK ) {
689 if ( rs.linkNum > 1001 ) {
690 globalErrorStream() << "bobToolz MakeChain: " << rs.linkNum << " to many Elemets, limited to 1000.\n";
693 UndoableCommand undo( "bobToolz.makeChain" );
695 pl.MakeChain( rs.linkNum,rs.linkName );
699 typedef DPoint* pntTripple[3];
701 bool bFacesNoTop[6] = {true, true, true, true, true, false};
703 void DoFlipTerrain() {
704 UndoableCommand undo( "bobToolz.flipTerrain" );
705 vec3_t vUp = { 0.f, 0.f, 1.f };
708 // ensure we have something selected
709 if ( GlobalSelectionSystem().countSelected() != 2 ) {
710 //DoMessageBox("Invalid number of objects selected, choose 2 only", "Error", eMB_OK);
711 globalErrorStream() << "bobToolz FlipTerrain: Invalid number of objects selected, choose 2 only.\n";
715 scene::Instance* brushes[2];
716 brushes[0] = &GlobalSelectionSystem().ultimateSelected();
717 brushes[1] = &GlobalSelectionSystem().penultimateSelected();
718 //ensure we have only Brushes selected.
719 for ( i = 0; i < 2; i++ )
721 if ( !Node_isBrush( brushes[i]->path().top() ) ) {
722 //DoMessageBox("No brushes selected, select ONLY brushes", "Error", eMB_OK);
723 globalErrorStream() << "bobToolz FlipTerrain: No brushes selected, select ONLY 2 brushes.\n";
729 pntTripple Points[2];
730 for ( i = 0; i < 2; i++ ) {
731 Brushes[i].LoadFromBrush( *brushes[i], false );
732 if ( !( Planes[i] = Brushes[i].FindPlaneWithClosestNormal( vUp ) ) || Brushes[i].FindPointsForPlane( Planes[i], Points[i], 3 ) != 3 ) {
733 //DoMessageBox("Error", "Error", eMB_OK);
734 globalErrorStream() << "bobToolz FlipTerrain: ERROR (FindPlaneWithClosestNormal/FindPointsForPlane).\n";
739 vec3_t mins1, mins2, maxs1, maxs2;
740 Brushes[0].GetBounds( mins1, maxs1 );
741 Brushes[1].GetBounds( mins2, maxs2 );
745 int dontmatch[2] = { -1, -1 };
747 for ( i = 0; i < 3; i++ ) {
748 for ( int j = 0; j < 3 && !found; j++ ) {
749 if ( VectorCompare( ( Points[0] )[i]->_pnt, ( Points[1] )[j]->_pnt ) ) {
760 if ( dontmatch[0] == -1 ) {
761 //DoMessageBox("Error", "Error", eMB_OK);
762 globalErrorStream() << "bobToolz FlipTerrain: ERROR (dontmatch[0]).\n";
766 for ( i = 0; i < 3; i++ ) {
767 for ( int j = 0; j < 3 && !found; j++ ) {
768 if ( VectorCompare( ( Points[1] )[i]->_pnt, ( Points[0] )[j]->_pnt ) ) {
779 if ( dontmatch[1] == -1 ) {
780 //DoMessageBox("Error", "Error", eMB_OK);
781 globalErrorStream() << "bobToolz FlipTerrain: ERROR (dontmatch[1]).\n";
787 vec3_t plnpntsshr[3];
789 VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpnts1[0] );
790 for ( i = 0; i < 3; i++ ) {
791 if ( dontmatch[0] != i ) {
792 VectorCopy( ( Points[0] )[i]->_pnt, plnpnts1[1] );
796 VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpnts1[2] );
798 VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpnts2[0] );
799 for ( i = 0; i < 3; i++ ) {
800 if ( dontmatch[1] != i && !VectorCompare( ( Points[1] )[i]->_pnt, plnpnts1[1] ) ) {
801 VectorCopy( ( Points[1] )[i]->_pnt, plnpnts2[1] );
805 VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpnts2[2] );
807 VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpntsshr[0] );
808 VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpntsshr[1] );
809 if ( ( Points[1] )[dontmatch[1]]->_pnt[2] < ( Points[0] )[dontmatch[0]]->_pnt[2] ) {
810 VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpntsshr[2] );
813 VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpntsshr[2] );
815 plnpntsshr[2][2] -= 16;
817 for ( i = 0; i < 3; i++ ) {
818 if ( mins2[i] < mins1[i] ) {
821 if ( maxs2[i] > maxs1[i] ) {
826 DBrush* newBrushes[2];
827 newBrushes[0] = DShape::GetBoundingCube_Ext( mins1, maxs1, "textures/common/caulk", bFacesAll, true );
828 newBrushes[1] = DShape::GetBoundingCube_Ext( mins1, maxs1, "textures/common/caulk", bFacesAll, true );
831 MakeNormal( plnpnts1[0], plnpnts1[1], plnpnts1[2], normal );
832 if ( normal[2] >= 0 ) {
833 newBrushes[0]->AddFace( plnpnts1[0], plnpnts1[1], plnpnts1[2], "textures/common/terrain", true );
836 newBrushes[0]->AddFace( plnpnts1[2], plnpnts1[1], plnpnts1[0], "textures/common/terrain", true );
839 MakeNormal( plnpnts2[0], plnpnts2[1], plnpnts2[2], normal );
840 if ( normal[2] >= 0 ) {
841 newBrushes[1]->AddFace( plnpnts2[0], plnpnts2[1], plnpnts2[2], "textures/common/terrain", true );
844 newBrushes[1]->AddFace( plnpnts2[2], plnpnts2[1], plnpnts2[0], "textures/common/terrain", true );
848 MakeNormal( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], normal );
850 VectorSubtract( plnpnts1[2], plnpnts1[1], vec );
851 if ( DotProduct( vec, normal ) >= 0 ) {
852 newBrushes[0]->AddFace( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], "textures/common/caulk", true );
855 newBrushes[0]->AddFace( plnpntsshr[2], plnpntsshr[1], plnpntsshr[0], "textures/common/caulk", true );
858 VectorSubtract( plnpnts2[2], plnpnts2[1], vec );
859 if ( DotProduct( vec, normal ) >= 0 ) {
860 newBrushes[1]->AddFace( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], "textures/common/caulk", true );
863 newBrushes[1]->AddFace( plnpntsshr[2], plnpntsshr[1], plnpntsshr[0], "textures/common/caulk", true );
866 for ( i = 0; i < 2; i++ ) {
867 newBrushes[i]->RemoveRedundantPlanes();
868 newBrushes[i]->BuildInRadiant( false, NULL, brushes[i]->path().parent().get_pointer() );
869 Path_deleteTop( brushes[i]->path() );
870 delete newBrushes[i];