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"
23 #pragma warning(disable : 4786)
26 #include "dialogs/dialogs-gtk.h"
39 #include "DVisDrawer.h"
40 #include "DTrainDrawer.h"
43 #include "ScriptParser.h"
44 #include "DTreePlanter.h"
60 std::list<Str> exclusionList; // whole brush exclusion
61 std::list<Str> exclusionList_Face; // single face exclusion
63 bool el1Loaded = false;
64 bool el2Loaded = false;
65 bool clrLst1Loaded = false;
66 bool clrLst2Loaded = false;
68 DBobView* g_PathView = NULL;
69 DVisDrawer* g_VisView = NULL;
70 DTrainDrawer* g_TrainView = NULL;
71 DTreePlanter* g_TreePlanter = NULL;
74 //========================//
75 // Helper Functions //
76 //========================//
82 el1Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el1.txt" ), &exclusionList );
85 el2Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el2.txt" ), &exclusionList_Face );
90 //========================//
92 //========================//
95 UndoableCommand undo( "bobToolz.intersect" );
98 if ( DoIntersectBox( &rs ) == eIDCANCEL ) {
102 if ( rs.nBrushOptions == BRUSH_OPT_SELECTED ) {
103 if ( GlobalSelectionSystem().countSelected() < 2 ) {
104 //DoMessageBox("Invalid number of brushes selected, choose at least 2", "Error", eMB_OK);
105 globalErrorStream() << "bobToolz Intersect: Invalid number of brushes selected, choose at least 2.\n";
111 switch ( rs.nBrushOptions )
113 case BRUSH_OPT_SELECTED:
116 world.LoadFromEntity( GlobalRadiant().getMapWorldEntity(), false );
117 world.LoadSelectedBrushes();
120 case BRUSH_OPT_WHOLE_MAP:
122 world.LoadFromEntity( GlobalRadiant().getMapWorldEntity(), false );
126 world.RemoveNonCheckBrushes( &exclusionList, rs.bUseDetail );
129 if ( rs.bDuplicateOnly ) {
130 pbSelectList = world.BuildDuplicateList();
133 pbSelectList = world.BuildIntersectList();
136 world.SelectBrushes( pbSelectList );
137 int brushCount = GlobalSelectionSystem().countSelected();
138 globalOutputStream() << "bobToolz Intersect: " << brushCount << " intersecting brushes found.\n";
139 delete[] pbSelectList;
147 UndoableCommand undo( "bobToolz.polygons" );
148 // ensure we have something selected
149 if ( GlobalSelectionSystem().countSelected() != 1 ) {
150 //DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
151 globalErrorStream() << "bobToolz Polygons: Invalid number of brushes selected, choose 1 only.\n";
156 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
157 if ( !Node_isBrush( instance.path().top() ) ) {
158 //DoMessageBox("No brush selected, select ONLY one brush", "Error", eMB_OK);
159 globalErrorStream() << "bobToolz Polygons: No brush selected, select ONLY one brush.\n";
162 // ask user for type, size, etc....
163 if ( DoPolygonBox( &rs ) == eIDOK ) {
170 VectorSubtract( instance.worldAABB().origin, instance.worldAABB().extents, vMin );
171 VectorAdd( instance.worldAABB().origin, instance.worldAABB().extents, vMax );
173 Path_deleteTop( instance.path() );
177 poly.BuildInversePrism( vMin, vMax, rs.nSides, rs.bAlignTop );
181 if ( rs.bUseBorder ) {
182 poly.BuildBorderedPrism( vMin, vMax, rs.nSides, rs.nBorderWidth, rs.bAlignTop );
185 poly.BuildRegularPrism( vMin, vMax, rs.nSides, rs.bAlignTop );
195 UndoableCommand undo( "bobToolz.fixBrushes" );
199 int count = world.FixBrushes();
201 globalOutputStream() << "bobToolz FixBrushes: " << count << " invalid/duplicate planes removed.\n";
204 void DoResetTextures(){
205 UndoableCommand undo( "bobToolz.resetTextures" );
206 static ResetTextureRS rs;
209 if ( 1 /*g_SelectedFaceTable.m_pfnGetSelectedFaceCount() != 1*/ ) {
214 texName = GetCurrentTexture();
215 strcpy( rs.textureName, GetCurrentTexture() );
218 EMessageBoxReturn ret;
219 if ( ( ret = DoResetTextureBox( &rs ) ) == eIDCANCEL ) {
223 if ( rs.bResetTextureName ) {
224 texName = rs.textureName;
227 if ( ret == eIDOK ) {
229 world.LoadSelectedBrushes();
230 world.ResetTextures( texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName,
231 rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation, true );
236 world.LoadAll( true );
237 world.ResetTextures( texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName,
238 rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation );
242 void DoBuildStairs(){
243 UndoableCommand undo( "bobToolz.buildStairs" );
246 strcpy( rs.mainTexture, GetCurrentTexture() );
248 // ensure we have something selected
249 if ( GlobalSelectionSystem().countSelected() != 1 ) {
250 //DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
251 globalErrorStream() << "bobToolz BuildStairs: Invalid number of brushes selected, choose 1 only.\n";
255 // ask user for type, size, etc....
256 if ( DoBuildStairsBox( &rs ) == eIDOK ) {
260 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
261 VectorSubtract( instance.worldAABB().origin, instance.worldAABB().extents, vMin );
262 VectorAdd( instance.worldAABB().origin, instance.worldAABB().extents, vMax );
267 VectorSubtract( vMax, vMin, size );
269 if ( ( (int)size[2] % rs.stairHeight ) != 0 ) {
270 // stairs must fit evenly into brush
271 //DoMessageBox("Invalid stair height\nHeight of block must be divisable by stair height", "Error", eMB_OK);
272 globalErrorStream() << "bobToolz BuildStairs: Invalid stair height. Height of block must be divisable by stair height.\n";
277 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
278 Path_deleteTop( instance.path() );
282 int numSteps = (int)size[2] / rs.stairHeight;
284 if ( rs.style == STYLE_CORNER ) {
285 BuildCornerStairs( vMin, vMax, numSteps, rs.mainTexture, rs.riserTexture );
290 // Get Step Dimensions
291 float stairHeight = (float)rs.stairHeight;
293 if ( ( rs.direction == MOVE_EAST ) || ( rs.direction == MOVE_WEST ) ) {
294 stairWidth = ( size[0] ) / numSteps;
297 stairWidth = ( size[1] ) / numSteps;
301 // Build Base For Stair (bob's style)
302 if ( rs.style == STYLE_BOB ) {
303 Build_Wedge( rs.direction, vMin, vMax, true );
307 // Set First Step Starting Position
308 vMax[2] = vMin[2] + stairHeight;
309 SetInitialStairPos( rs.direction, vMin, vMax, stairWidth );
313 for ( int i = 0; i < numSteps; i++ )
315 if ( rs.style == STYLE_BOB ) {
316 Build_StairStep_Wedge( rs.direction, vMin, vMax, rs.mainTexture, rs.riserTexture, rs.bUseDetail );
318 else if ( rs.style == STYLE_ORIGINAL ) {
319 Build_StairStep( vMin, vMax, rs.mainTexture, rs.riserTexture, rs.direction );
322 // get step into next position
323 MoveBlock( rs.direction, vMin, vMax, stairWidth );
324 vMax[2] += stairHeight;
325 if ( rs.style == STYLE_BOB ) {
326 vMin[2] += stairHeight; // wedge bottom must be raised
335 UndoableCommand undo( "bobToolz.buildDoors" );
336 // ensure we have something selected
337 if ( GlobalSelectionSystem().countSelected() != 1 ) {
338 //DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
339 globalErrorStream() << "bobToolz BuildDoors: Invalid number of brushes selected, choose 1 only.\n";
344 strcpy( rs.mainTexture, GetCurrentTexture() );
346 if ( DoDoorsBox( &rs ) == eIDOK ) {
350 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
351 VectorSubtract( instance.worldAABB().origin, instance.worldAABB().extents, vMin );
352 VectorAdd( instance.worldAABB().origin, instance.worldAABB().extents, vMax );
353 Path_deleteTop( instance.path() );
356 BuildDoorsX2( vMin, vMax,
357 rs.bScaleMainH, rs.bScaleMainV,
358 rs.bScaleTrimH, rs.bScaleTrimV,
359 rs.mainTexture, rs.trimTexture,
360 rs.nOrientation ); // shapes.cpp
364 void DoPathPlotter(){
365 UndoableCommand undo( "bobToolz.pathPlotter" );
367 EMessageBoxReturn ret = DoPathPlotterBox( &rs );
368 if ( ret == eIDCANCEL ) {
371 if ( ret == eIDNO ) {
378 // ensure we have something selected
380 if( GlobalSelectionSystem().countSelected() != 1 )
382 //DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
383 globalOutputStream() << "bobToolz PathPlotter: Invalid number of entities selected, choose 1 trigger_push entity only.\n";
387 Entity* entity = Node_getEntity( GlobalSelectionSystem().ultimateSelected().path().top() );
389 DBobView_setEntity( *entity, rs.fMultiplier, rs.nPoints, rs.fGravity, rs.bNoUpdate, rs.bShowExtra );
391 else{ globalErrorStream() << "bobToolz PathPlotter: No trigger_push entitity selected, select 1 only (Use list to select it).\n"; }
396 UndoableCommand undo( "bobToolz.pitBuilder" );
397 // ensure we have something selected
398 if ( GlobalSelectionSystem().countSelected() != 1 ) {
399 //DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
400 globalErrorStream() << "bobToolz PitBuilder: Invalid number of brushes selected, choose 1 only.\n";
406 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
407 //seems it does this also with a patch with valid dimensions.. but probably better to enforce a brush.
408 if ( !Node_isBrush( instance.path().top() ) ) {
409 //DoMessageBox("No brush selected, select ONLY one brush", "Error", eMB_OK);
410 globalErrorStream() << "bobToolz PitBuilder: No brush selected, select ONLY 1 brush.\n";
414 VectorSubtract( instance.worldAABB().origin, instance.worldAABB().extents, vMin );
415 VectorAdd( instance.worldAABB().origin, instance.worldAABB().extents, vMax );
419 if ( pit.BuildPit( vMin, vMax ) ) {
421 Path_deleteTop( instance.path() );
425 //DoMessageBox("Failed To Make Pit\nTry Making The Brush Bigger", "Error", eMB_OK);
426 globalErrorStream() << "bobToolz PitBuilder: Failed to make Pit, try making the brush bigger.\n";
430 void DoMergePatches(){
431 UndoableCommand undo( "bobToolz.mergePatches" );
432 patch_merge_t merge_info;
433 DPatch mrgPatches[2];
436 // ensure we have something selected
437 if ( GlobalSelectionSystem().countSelected() != 2 ) {
438 globalErrorStream() << "bobToolz MergePatches: Invalid number of patches selected, choose 2 only.\n";
439 //DoMessageBox("Invalid number of patches selected, choose 2 only", "Error", eMB_OK);
443 scene::Instance* patches[2];
444 patches[0] = &GlobalSelectionSystem().ultimateSelected();
445 patches[1] = &GlobalSelectionSystem().penultimateSelected();
447 for ( i = 0; i < 2; i++ )
449 if ( !Node_isPatch( patches[i]->path().top() ) ) {
450 //DoMessageBox("No patches selected, select ONLY patches", "Error", eMB_OK);
451 globalErrorStream() << "bobToolz MergePatches: Invalid number of patches selected, choose ONLY 2 patches.\n";
455 mrgPatches[i].LoadFromPatch( *patches[i] );
458 /* mrgPatches[0].Transpose();
459 mrgPatches[0].RemoveFromRadiant();
460 mrgPatches[0].BuildInRadiant();*/
462 merge_info = mrgPatches[0].IsMergable( &mrgPatches[1] );
464 if ( merge_info.mergable ) {
465 globalOutputStream() << merge_info.pos1 << " " << merge_info.pos2;
466 //Message removed, No tools give feedback on success.
467 //globalOutputStream() << "bobToolz MergePatches: Patches Mergable.\n";
468 DPatch* newPatch = mrgPatches[0].MergePatches( merge_info, &mrgPatches[0], &mrgPatches[1] );
470 /* mrgPatches[0].RemoveFromRadiant();
471 mrgPatches[0].BuildInRadiant();
473 mrgPatches[1].RemoveFromRadiant();
474 mrgPatches[1].BuildInRadiant();
483 Path_deleteTop( patches[0]->path() );
484 Path_deleteTop( patches[1]->path() );
486 newPatch->BuildInRadiant();
492 globalErrorStream() << "bobToolz.mergePatch: The selected patches are not mergable.\n";
497 void DoSplitPatch() {
498 UndoableCommand undo( "bobToolz.splitPatch" );
502 // ensure we have something selected
503 if ( GlobalSelectionSystem().countSelected() != 1 ) {
504 //DoMessageBox("Invalid number of patches selected, choose 1 only", "Error", eMB_OK);
505 globalErrorStream() << "bobToolz SplitPatch: Invalid number of patches selected, choose only 1 patch.\n";
509 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
511 if ( !Node_isPatch( instance.path().top() ) ) {
512 //DoMessageBox("No patch selected, select ONLY one patch", "Error", eMB_OK);
513 globalErrorStream() << "bobToolz SplitPatch: No patch selected, select ONLY 1 patch.\n";
517 patch.LoadFromPatch( instance );
519 std::list<DPatch> patchList = patch.Split();
520 for ( std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++ ) {
521 ( *patches ).BuildInRadiant();
524 Path_deleteTop( instance.path() );
527 void DoSplitPatchCols() {
528 UndoableCommand undo( "bobToolz.splitPatchCols" );
532 // ensure we have something selected
533 if ( GlobalSelectionSystem().countSelected() != 1 ) {
534 //DoMessageBox("Invalid number of patches selected, choose 1 only", "Error", eMB_OK);
535 globalErrorStream() << "bobToolz SplitPatchCols: Invalid number of patches selected, choose 1 only.\n";
539 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
541 if ( !Node_isPatch( instance.path().top() ) ) {
542 //DoMessageBox("No patch selected, select ONLY one patch", "Error", eMB_OK);
543 globalErrorStream() << "bobToolz SplitPatchCols: No patch selected, select ONLY 1 patch.\n";
547 patch.LoadFromPatch( instance );
549 std::list<DPatch> patchList = patch.SplitCols();
550 for ( std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++ ) {
551 ( *patches ).BuildInRadiant();
554 Path_deleteTop( instance.path() );
557 void DoSplitPatchRows() {
558 UndoableCommand undo( "bobToolz.splitPatchRows" );
562 // ensure we have something selected
563 if ( GlobalSelectionSystem().countSelected() != 1 ) {
564 //DoMessageBox("Invalid number of patches selected, choose 1 only", "Error", eMB_OK);
565 globalErrorStream() << "bobToolz SplitPatchRows: Invalid number of patches selected, choose 1 only.\n";
569 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
571 if ( !Node_isPatch( instance.path().top() ) ) {
572 //DoMessageBox("No patch selected, select ONLY one patch", "Error", eMB_OK);
573 globalErrorStream() << "bobToolz SplitPatchRows: No patch selected, select ONLY 1 patch.\n";
577 patch.LoadFromPatch( instance );
579 std::list<DPatch> patchList = patch.SplitRows();
580 for ( std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++ ) {
581 ( *patches ).BuildInRadiant();
584 Path_deleteTop( instance.path() );
590 if ( GlobalSelectionSystem().countSelected() == 0 ) {
591 globalErrorStream() << "bobToolz VisAnalyse: Invalid number of objects selected, choose 1 only.\n";
598 // ensure we have something selected
599 if ( GlobalSelectionSystem().countSelected() != 1 ) {
600 //DoMessageBox("Invalid number of objects selected, choose 1 only", "Error", eMB_OK);
601 globalErrorStream() << "bobToolz VisAnalyse: Invalid number of objects selected, choose 1 only.\n";
605 scene::Instance& brush = GlobalSelectionSystem().ultimateSelected();
606 //ensure we have a brush selected
607 if ( !Node_isBrush( brush.path().top() ) ) {
608 //DoMessageBox("No brush selected, select ONLY one brush", "Error", eMB_OK);
609 globalErrorStream() << "bobToolz VisAnalyse: No brush selected, select ONLY 1 brush.\n";
613 orgBrush.LoadFromBrush( brush, false );
615 orgBrush.BuildBounds();
617 origin[0] = ( orgBrush.bbox_max[0] + orgBrush.bbox_min[0] ) / 2.f;
618 origin[1] = ( orgBrush.bbox_max[1] + orgBrush.bbox_min[1] ) / 2.f;
619 origin[2] = ( orgBrush.bbox_max[2] + orgBrush.bbox_min[2] ) / 2.f;
622 const char* rad_filename = GlobalRadiant().getMapName();
623 if ( !rad_filename ) {
624 //DoMessageBox("An ERROR occurred while trying\n to get the map filename", "Error", eMB_OK);
625 globalErrorStream() << "bobToolz VisAnalyse: An ERROR occurred while trying to get the map filename.\n";
629 strcpy( filename, rad_filename );
631 char* ext = strrchr( filename, '.' ) + 1;
632 strcpy( ext, "bsp" ); // rename the extension
634 std::list<DWinding*> *pointList = BuildTrace( filename, origin );
637 g_VisView = new DVisDrawer;
640 g_VisView->SetList( pointList );
643 void DoTrainPathPlot() {
649 g_TrainView = new DTrainDrawer();
652 void DoCaulkSelection() {
653 UndoableCommand undo( "bobToolz.caulkSelection" );
656 float fScale[2] = { 0.5f, 0.5f };
657 float fShift[2] = { 0.0f, 0.0f };
659 int bResetScale[2] = { false, false };
660 int bResetShift[2] = { false, false };
662 world.LoadSelectedBrushes();
663 world.LoadSelectedPatches();
664 world.ResetTextures( NULL, fScale, fShift, 0, "textures/common/caulk", true, bResetScale, bResetShift, false, true );
667 void DoTreePlanter() {
668 UndoableCommand undo( "bobToolz.treePlanter" );
669 if ( g_TreePlanter ) {
670 delete g_TreePlanter;
671 g_TreePlanter = NULL;
675 g_TreePlanter = new DTreePlanter();
679 UndoableCommand undo( "bobToolz.dropEntities" );
680 if ( g_TreePlanter ) {
681 g_TreePlanter->DropEntsToGround();
687 if ( DoMakeChainBox( &rs ) == eIDOK ) {
688 if ( rs.linkNum > 1001 ) {
689 globalErrorStream() << "bobToolz MakeChain: " << rs.linkNum << " to many Elemets, limited to 1000.\n";
692 UndoableCommand undo( "bobToolz.makeChain" );
694 pl.MakeChain( rs.linkNum,rs.linkName );
698 typedef DPoint* pntTripple[3];
700 bool bFacesNoTop[6] = {true, true, true, true, true, false};
702 void DoFlipTerrain() {
703 UndoableCommand undo( "bobToolz.flipTerrain" );
704 vec3_t vUp = { 0.f, 0.f, 1.f };
707 // ensure we have something selected
708 if ( GlobalSelectionSystem().countSelected() != 2 ) {
709 //DoMessageBox("Invalid number of objects selected, choose 2 only", "Error", eMB_OK);
710 globalErrorStream() << "bobToolz FlipTerrain: Invalid number of objects selected, choose 2 only.\n";
714 scene::Instance* brushes[2];
715 brushes[0] = &GlobalSelectionSystem().ultimateSelected();
716 brushes[1] = &GlobalSelectionSystem().penultimateSelected();
717 //ensure we have only Brushes selected.
718 for ( i = 0; i < 2; i++ )
720 if ( !Node_isBrush( brushes[i]->path().top() ) ) {
721 //DoMessageBox("No brushes selected, select ONLY brushes", "Error", eMB_OK);
722 globalErrorStream() << "bobToolz FlipTerrain: No brushes selected, select ONLY 2 brushes.\n";
728 pntTripple Points[2];
729 for ( i = 0; i < 2; i++ ) {
730 Brushes[i].LoadFromBrush( *brushes[i], false );
731 if ( !( Planes[i] = Brushes[i].FindPlaneWithClosestNormal( vUp ) ) || Brushes[i].FindPointsForPlane( Planes[i], Points[i], 3 ) != 3 ) {
732 //DoMessageBox("Error", "Error", eMB_OK);
733 globalErrorStream() << "bobToolz FlipTerrain: ERROR (FindPlaneWithClosestNormal/FindPointsForPlane).\n";
738 vec3_t mins1, mins2, maxs1, maxs2;
739 Brushes[0].GetBounds( mins1, maxs1 );
740 Brushes[1].GetBounds( mins2, maxs2 );
744 int dontmatch[2] = { -1, -1 };
746 for ( i = 0; i < 3; i++ ) {
747 for ( int j = 0; j < 3 && !found; j++ ) {
748 if ( VectorCompare( ( Points[0] )[i]->_pnt, ( Points[1] )[j]->_pnt ) ) {
759 if ( dontmatch[0] == -1 ) {
760 //DoMessageBox("Error", "Error", eMB_OK);
761 globalErrorStream() << "bobToolz FlipTerrain: ERROR (dontmatch[0]).\n";
765 for ( i = 0; i < 3; i++ ) {
766 for ( int j = 0; j < 3 && !found; j++ ) {
767 if ( VectorCompare( ( Points[1] )[i]->_pnt, ( Points[0] )[j]->_pnt ) ) {
778 if ( dontmatch[1] == -1 ) {
779 //DoMessageBox("Error", "Error", eMB_OK);
780 globalErrorStream() << "bobToolz FlipTerrain: ERROR (dontmatch[1]).\n";
786 vec3_t plnpntsshr[3];
788 VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpnts1[0] );
789 for ( i = 0; i < 3; i++ ) {
790 if ( dontmatch[0] != i ) {
791 VectorCopy( ( Points[0] )[i]->_pnt, plnpnts1[1] );
795 VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpnts1[2] );
797 VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpnts2[0] );
798 for ( i = 0; i < 3; i++ ) {
799 if ( dontmatch[1] != i && !VectorCompare( ( Points[1] )[i]->_pnt, plnpnts1[1] ) ) {
800 VectorCopy( ( Points[1] )[i]->_pnt, plnpnts2[1] );
804 VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpnts2[2] );
806 VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpntsshr[0] );
807 VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpntsshr[1] );
808 if ( ( Points[1] )[dontmatch[1]]->_pnt[2] < ( Points[0] )[dontmatch[0]]->_pnt[2] ) {
809 VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpntsshr[2] );
812 VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpntsshr[2] );
814 plnpntsshr[2][2] -= 16;
816 for ( i = 0; i < 3; i++ ) {
817 if ( mins2[i] < mins1[i] ) {
820 if ( maxs2[i] > maxs1[i] ) {
825 DBrush* newBrushes[2];
826 newBrushes[0] = DShape::GetBoundingCube_Ext( mins1, maxs1, "textures/common/caulk", bFacesAll, true );
827 newBrushes[1] = DShape::GetBoundingCube_Ext( mins1, maxs1, "textures/common/caulk", bFacesAll, true );
830 MakeNormal( plnpnts1[0], plnpnts1[1], plnpnts1[2], normal );
831 if ( normal[2] >= 0 ) {
832 newBrushes[0]->AddFace( plnpnts1[0], plnpnts1[1], plnpnts1[2], "textures/common/terrain", true );
835 newBrushes[0]->AddFace( plnpnts1[2], plnpnts1[1], plnpnts1[0], "textures/common/terrain", true );
838 MakeNormal( plnpnts2[0], plnpnts2[1], plnpnts2[2], normal );
839 if ( normal[2] >= 0 ) {
840 newBrushes[1]->AddFace( plnpnts2[0], plnpnts2[1], plnpnts2[2], "textures/common/terrain", true );
843 newBrushes[1]->AddFace( plnpnts2[2], plnpnts2[1], plnpnts2[0], "textures/common/terrain", true );
847 MakeNormal( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], normal );
849 VectorSubtract( plnpnts1[2], plnpnts1[1], vec );
850 if ( DotProduct( vec, normal ) >= 0 ) {
851 newBrushes[0]->AddFace( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], "textures/common/caulk", true );
854 newBrushes[0]->AddFace( plnpntsshr[2], plnpntsshr[1], plnpntsshr[0], "textures/common/caulk", true );
857 VectorSubtract( plnpnts2[2], plnpnts2[1], vec );
858 if ( DotProduct( vec, normal ) >= 0 ) {
859 newBrushes[1]->AddFace( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], "textures/common/caulk", true );
862 newBrushes[1]->AddFace( plnpntsshr[2], plnpntsshr[1], plnpntsshr[0], "textures/common/caulk", true );
865 for ( i = 0; i < 2; i++ ) {
866 newBrushes[i]->RemoveRedundantPlanes();
867 newBrushes[i]->BuildInRadiant( false, NULL, brushes[i]->path().parent().get_pointer() );
868 Path_deleteTop( brushes[i]->path() );
869 delete newBrushes[i];