2007-11-04 03:51:54 +00:00
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
BobToolz plugin for GtkRadiant
|
|
|
|
Copyright (C) 2001 Gordon Biggans
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#pragma warning(disable : 4786)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "dialogs/dialogs-gtk.h"
|
|
|
|
|
|
|
|
#include "DEntity.h"
|
|
|
|
#include "DShape.h"
|
|
|
|
#include "DPatch.h"
|
|
|
|
|
|
|
|
#include "misc.h"
|
|
|
|
#include "shapes.h"
|
|
|
|
#include "lists.h"
|
|
|
|
#include "funchandlers.h"
|
|
|
|
#include "visfind.h"
|
|
|
|
|
|
|
|
// for autocaulk
|
Do not do `using namespace std` to avoid type conflict
The STL now defines `std::byte` so doing `using namespace std`
will conflict will custom definition of `byte`, which this
legacy code is full of.
It looks like NetRadiant went the route of making explicit
usage of `std::` prefixed types and did not renamed the
custom definition of byte, so doing the same reduces diff
noise between the two trees.
This also makes the code future proof if the STL decides
to define some other types with common name.
This patches replaces all usages of `map`, `pair` and
`vector` with `std::map`, `std::pair` and `std::vector`
and remove the `using namespace std` line in `stl_check.h`.
```
libs/mathlib.h:132:44: error: reference to ‘byte’ is ambiguous
132 | void NormalToLatLong( const vec3_t normal, byte bytes[2] );
| ^~~~
In file included from /usr/include/c++/11/bits/stl_algobase.h:61,
from /usr/include/c++/11/bits/char_traits.h:39,
from /usr/include/c++/11/ios:40,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from libs/missing.h:76,
from radiant/qe3.h:40,
from radiant/stdafx.h:39,
from radiant/bp_dlg.cpp:28:
/usr/include/c++/11/bits/cpp_type_traits.h:404:30: note: candidates are: ‘enum class std::byte’
404 | enum class byte : unsigned char;
| ^~~~
```
2022-07-14 15:18:51 +00:00
|
|
|
std::list<Str> exclusionList; // whole brush exclusion
|
|
|
|
std::list<Str> exclusionList_Face; // single face exclusion
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
bool el1Loaded = FALSE;
|
|
|
|
bool el2Loaded = FALSE;
|
|
|
|
bool clrLst1Loaded = FALSE;
|
|
|
|
bool clrLst2Loaded = FALSE;
|
|
|
|
|
|
|
|
DBobView* g_PathView = NULL;
|
|
|
|
DVisDrawer* g_VisView = NULL;
|
|
|
|
DTrainDrawer* g_TrainView = NULL;
|
|
|
|
DTreePlanter* g_TreePlanter = NULL;
|
2007-11-04 03:51:54 +00:00
|
|
|
// -------------
|
|
|
|
|
|
|
|
//========================//
|
|
|
|
// Helper Functions //
|
|
|
|
//========================//
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void LoadLists(){
|
2007-11-04 03:51:54 +00:00
|
|
|
char buffer[256];
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !el1Loaded ) {
|
|
|
|
el1Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el1.txt" ), &exclusionList );
|
|
|
|
}
|
|
|
|
if ( !el2Loaded ) {
|
|
|
|
el2Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el2.txt" ), &exclusionList_Face );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//========================//
|
|
|
|
// Main Functions //
|
|
|
|
//========================//
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DoIntersect(){
|
2007-11-04 03:51:54 +00:00
|
|
|
IntersectRS rs;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( DoIntersectBox( &rs ) == IDCANCEL ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( rs.nBrushOptions == BRUSH_OPT_SELECTED ) {
|
|
|
|
if ( g_FuncTable.m_pfnSelectedBrushCount() < 2 ) {
|
|
|
|
DoMessageBox( "Invalid number of brushes selected, choose at least 2", "Error", MB_OK );
|
|
|
|
return;
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DEntity world;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
switch ( rs.nBrushOptions )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
case BRUSH_OPT_SELECTED:
|
2012-03-17 20:01:54 +00:00
|
|
|
{
|
|
|
|
world.LoadSelectedBrushes();
|
|
|
|
break;
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
case BRUSH_OPT_WHOLE_MAP:
|
2012-03-17 20:01:54 +00:00
|
|
|
{
|
|
|
|
world.LoadFromEntity( 0, FALSE );
|
|
|
|
break;
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
world.RemoveNonCheckBrushes( &exclusionList, rs.bUseDetail );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
bool* pbSelectList;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( rs.bDuplicateOnly ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
pbSelectList = world.BuildDuplicateList();
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else{
|
2007-11-04 03:51:54 +00:00
|
|
|
pbSelectList = world.BuildIntersectList();
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
world.SelectBrushes( pbSelectList );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
delete[] pbSelectList;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DoPolygonsTB(){
|
|
|
|
vec3_t vMin, vMax;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
// figure out vMin and vMax
|
|
|
|
g_FuncTable.m_pfnGetDispatchParams( vMin, vMax, NULL );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
DoPolygons( vMin, vMax );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DoPolygons( vec3_t vMin, vec3_t vMax ){
|
2007-11-04 03:51:54 +00:00
|
|
|
// ensure we have something selected
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) {
|
|
|
|
DoMessageBox( "Invalid number of brushes selected, choose 1 only", "Error", MB_OK );
|
|
|
|
return;
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// tell Radiant we want to access the selected brushes
|
|
|
|
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:51:54 +00:00
|
|
|
// get handle to size definition brush
|
2012-03-17 20:01:54 +00:00
|
|
|
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 );
|
2007-11-04 03:51:54 +00:00
|
|
|
// cant release until we delete the brush, if we do...
|
|
|
|
|
|
|
|
PolygonRS rs;
|
|
|
|
|
|
|
|
// ask user for type, size, etc....
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( DoPolygonBox( &rs ) == IDOK ) {
|
|
|
|
g_FuncTable.m_pfnDeleteBrushHandle( brush );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
DShape poly;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( rs.bInverse ) {
|
|
|
|
poly.BuildInversePrism( vMin, vMax, rs.nSides, rs.bAlignTop );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
else
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( rs.bUseBorder ) {
|
|
|
|
poly.BuildBorderedPrism( vMin, vMax, rs.nSides, rs.nBorderWidth, rs.bAlignTop );
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
poly.BuildRegularPrism( vMin, vMax, rs.nSides, rs.bAlignTop );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
poly.Commit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DoFixBrushes(){
|
2007-11-04 03:51:54 +00:00
|
|
|
DMap world;
|
2017-08-20 21:57:09 +00:00
|
|
|
world.LoadAll( true );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2017-08-20 21:57:09 +00:00
|
|
|
int count = world.FixBrushes( true );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
Sys_Printf( "%i invalid/duplicate planes removed\n", count );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DoResetTextures(){
|
2007-11-04 03:51:54 +00:00
|
|
|
static ResetTextureRS rs;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
const char* texName;
|
|
|
|
if ( g_SelectedFaceTable.m_pfnGetSelectedFaceCount() != 1 ) {
|
|
|
|
texName = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
texName = GetCurrentTexture();
|
|
|
|
strcpy( rs.textureName, GetCurrentTexture() );
|
|
|
|
}
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
if ( ( ret = DoResetTextureBox( &rs ) ) == IDCANCEL ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( rs.bResetTextureName ) {
|
|
|
|
texName = rs.textureName;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ret == IDOK ) {
|
|
|
|
DEntity world;
|
|
|
|
world.LoadSelectedBrushes();
|
|
|
|
world.ResetTextures( texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName,
|
|
|
|
rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation, TRUE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DMap world;
|
|
|
|
world.LoadAll( TRUE );
|
|
|
|
world.ResetTextures( texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName,
|
|
|
|
rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DoBuildStairs( vec3_t vMin, vec3_t vMax ){
|
2007-11-04 03:51:54 +00:00
|
|
|
BuildStairsRS rs;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( rs.mainTexture, GetCurrentTexture() );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
// ensure we have something selected
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) {
|
|
|
|
DoMessageBox( "Invalid number of brushes selected, chose 1 only", "Error", MB_OK );
|
|
|
|
return;
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// tell Radiant we want to access the selected brushes
|
|
|
|
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:51:54 +00:00
|
|
|
// get handle to size definition brush
|
2012-03-17 20:01:54 +00:00
|
|
|
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 );
|
2007-11-04 03:51:54 +00:00
|
|
|
// cant release until we delete the brush, if we do...
|
|
|
|
|
|
|
|
|
|
|
|
// ask user for type, size, etc....
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( DoBuildStairsBox( &rs ) == IDOK ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
// calc brush size
|
|
|
|
vec3_t size;
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorSubtract( vMax, vMin, size );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ( (int)size[2] % rs.stairHeight ) != 0 ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
// stairs must fit evenly into brush
|
2012-03-17 20:01:54 +00:00
|
|
|
DoMessageBox( "Invalid stair height\nHeight of block must be divisable by stair height", "Error", MB_OK );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:51:54 +00:00
|
|
|
// Remove Size Brush
|
2012-03-17 20:01:54 +00:00
|
|
|
g_FuncTable.m_pfnDeleteBrushHandle( brush );
|
|
|
|
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
// Get Step Count
|
|
|
|
int numSteps = (int)size[2] / rs.stairHeight;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
if ( rs.style == STYLE_CORNER ) {
|
|
|
|
BuildCornerStairs( vMin, vMax, numSteps, rs.mainTexture, rs.riserTexture );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
// Get Step Dimensions
|
|
|
|
float stairHeight = (float)rs.stairHeight;
|
|
|
|
float stairWidth;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ( rs.direction == MOVE_EAST ) || ( rs.direction == MOVE_WEST ) ) {
|
|
|
|
stairWidth = ( size[0] ) / numSteps;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
stairWidth = ( size[1] ) / numSteps;
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Build Base For Stair (bob's style)
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( rs.style == STYLE_BOB ) {
|
|
|
|
Build_Wedge( rs.direction, vMin, vMax, TRUE );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Set First Step Starting Position
|
|
|
|
vMax[2] = vMin[2] + stairHeight;
|
2012-03-17 20:01:54 +00:00
|
|
|
SetInitialStairPos( rs.direction, vMin, vMax, stairWidth );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Build The Steps
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( int i = 0; i < numSteps; i++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( rs.style == STYLE_BOB ) {
|
|
|
|
Build_StairStep_Wedge( rs.direction, vMin, vMax, rs.mainTexture, rs.riserTexture, rs.bUseDetail );
|
|
|
|
}
|
|
|
|
else if ( rs.style == STYLE_ORIGINAL ) {
|
|
|
|
Build_StairStep( vMin, vMax, rs.mainTexture, rs.riserTexture, rs.direction );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
// get step into next position
|
2012-03-17 20:01:54 +00:00
|
|
|
MoveBlock( rs.direction, vMin, vMax, stairWidth );
|
2007-11-04 03:51:54 +00:00
|
|
|
vMax[2] += stairHeight;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( rs.style == STYLE_BOB ) {
|
|
|
|
vMin[2] += stairHeight; // wedge bottom must be raised
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DoBuildDoors( vec3_t vMin, vec3_t vMax ){
|
2007-11-04 03:51:54 +00:00
|
|
|
// ensure we have something selected
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) {
|
|
|
|
DoMessageBox( "Invalid number of brushes selected, chose 1 only", "Error", MB_OK );
|
|
|
|
return;
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// tell Radiant we want to access the selected brushes
|
|
|
|
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:51:54 +00:00
|
|
|
// get handle to size definition brush
|
2012-03-17 20:01:54 +00:00
|
|
|
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 );
|
2007-11-04 03:51:54 +00:00
|
|
|
// cant release until we delete the brush, if we do...
|
|
|
|
|
|
|
|
DoorRS rs;
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( rs.mainTexture, GetCurrentTexture() );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( DoDoorsBox( &rs ) == IDOK ) {
|
|
|
|
g_FuncTable.m_pfnDeleteBrushHandle( brush );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
BuildDoorsX2( vMin, vMax,
|
|
|
|
rs.bScaleMainH, rs.bScaleMainV,
|
|
|
|
rs.bScaleTrimH, rs.bScaleTrimV,
|
|
|
|
rs.mainTexture, rs.trimTexture,
|
|
|
|
rs.nOrientation ); // shapes.cpp
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DoPathPlotter(){
|
2007-11-04 03:51:54 +00:00
|
|
|
PathPlotterRS rs;
|
2012-03-17 20:01:54 +00:00
|
|
|
int ret = DoPathPlotterBox( &rs );
|
|
|
|
if ( ret == IDCANCEL ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( ret == IDNO ) {
|
|
|
|
if ( g_PathView ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
delete g_PathView;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) {
|
|
|
|
DoMessageBox( "Invalid number of brushes selected, chose 1 only", "Error", MB_OK );
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// tell Radiant we want to access the selected brushes
|
|
|
|
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 );
|
2007-11-04 03:51:54 +00:00
|
|
|
// should be our trigger brush
|
|
|
|
|
|
|
|
DEntity world;
|
2012-03-17 20:01:54 +00:00
|
|
|
world.LoadEPairList( *g_EntityTable.m_pfnGetEntityKeyValList( brush->owner ) );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
DEPair* trigger_ep = world.FindEPairByKey( "targetname" );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( trigger_ep ) {
|
|
|
|
if ( !strcmp( world.m_Classname, "trigger_push" ) ) {
|
|
|
|
DEPair* target_ep = world.FindEPairByKey( "target" );
|
|
|
|
if ( target_ep ) {
|
|
|
|
entity_s* entTarget = FindEntityFromTargetname( target_ep->value, NULL );
|
|
|
|
if ( entTarget ) {
|
|
|
|
if ( g_PathView ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
delete g_PathView;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
g_PathView = new DBobView;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_PathView->Begin( trigger_ep->value, target_ep->value, rs.fMultiplier, rs.nPoints, rs.fGravity, rs.bNoUpdate, rs.bShowExtra );
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
DoMessageBox( "trigger_push target could not be found.", "Error", MB_OK );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else{
|
|
|
|
DoMessageBox( "trigger_push has no target.", "Error", MB_OK );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else{
|
|
|
|
DoMessageBox( "You must select a 'trigger_push' entity.", "Error", MB_OK );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
DoMessageBox( "Entity must have a targetname", "Error", MB_OK );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DoPitBuilder( vec3_t vMin, vec3_t vMax ){
|
2007-11-04 03:51:54 +00:00
|
|
|
// ensure we have something selected
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) {
|
|
|
|
DoMessageBox( "Invalid number of brushes selected, chose 1 only", "Error", MB_OK );
|
|
|
|
return;
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// tell Radiant we want to access the selected brushes
|
|
|
|
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:51:54 +00:00
|
|
|
// get handle to size definition brush
|
2012-03-17 20:01:54 +00:00
|
|
|
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 );
|
2007-11-04 03:51:54 +00:00
|
|
|
// cant release until we delete the brush, if we do...
|
|
|
|
|
|
|
|
DShape pit;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( pit.BuildPit( vMin, vMax ) ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
pit.Commit();
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_FuncTable.m_pfnDeleteBrushHandle( brush );
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
DoMessageBox( "Failed To Make Pit\nTry Making The Brush Bigger", "Error", MB_OK );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DoMergePatches(){
|
|
|
|
patch_merge_t merge_info;
|
|
|
|
DPatch mrgPatches[2];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// ensure we have something selected
|
|
|
|
if ( g_FuncTable.m_pfnSelectedBrushCount() != 2 ) {
|
|
|
|
DoMessageBox( "Invalid number of objects selected, chose 2 only", "Error", MB_OK );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
|
|
|
|
|
|
|
|
for ( i = 0; i < 2; i++ )
|
|
|
|
{
|
|
|
|
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( i );
|
|
|
|
|
|
|
|
if ( !brush->pPatch ) {
|
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
|
|
|
DoMessageBox( "You must select ONLY patches", "Error", MB_OK );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mrgPatches[i].LoadFromBrush_t( brush );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mrgPatches[0].Transpose();
|
|
|
|
mrgPatches[0].RemoveFromRadiant();
|
|
|
|
mrgPatches[0].BuildInRadiant();*/
|
|
|
|
|
|
|
|
merge_info = mrgPatches[0].IsMergable( &mrgPatches[1] );
|
|
|
|
|
|
|
|
if ( merge_info.mergable ) {
|
|
|
|
Sys_Printf( "%i %i", merge_info.pos1, merge_info.pos2 );
|
|
|
|
|
|
|
|
Sys_Printf( "Patches Mergable\n" );
|
|
|
|
DPatch* newPatch = mrgPatches[0].MergePatches( merge_info, &mrgPatches[0], &mrgPatches[1] );
|
|
|
|
|
|
|
|
/* mrgPatches[0].RemoveFromRadiant();
|
|
|
|
mrgPatches[0].BuildInRadiant();
|
|
|
|
|
|
|
|
mrgPatches[1].RemoveFromRadiant();
|
|
|
|
mrgPatches[1].BuildInRadiant();
|
|
|
|
|
|
|
|
|
|
|
|
delete newPatch;*/
|
|
|
|
|
|
|
|
if ( !newPatch ) {
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mrgPatches[0].RemoveFromRadiant();
|
|
|
|
mrgPatches[1].RemoveFromRadiant();
|
|
|
|
|
|
|
|
newPatch->BuildInRadiant();
|
|
|
|
delete newPatch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DoSplitPatch() {
|
|
|
|
DPatch patch;
|
|
|
|
|
|
|
|
// ensure we have something selected
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) {
|
|
|
|
DoMessageBox( "Invalid number of objects selected, select 1 patch only", "Error", MB_OK );
|
|
|
|
return;
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !brush->pPatch ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
2012-03-17 20:01:54 +00:00
|
|
|
DoMessageBox( "You must select ONLY patches", "Error", MB_OK );
|
|
|
|
return;
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
patch.LoadFromBrush_t( brush );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
Do not do `using namespace std` to avoid type conflict
The STL now defines `std::byte` so doing `using namespace std`
will conflict will custom definition of `byte`, which this
legacy code is full of.
It looks like NetRadiant went the route of making explicit
usage of `std::` prefixed types and did not renamed the
custom definition of byte, so doing the same reduces diff
noise between the two trees.
This also makes the code future proof if the STL decides
to define some other types with common name.
This patches replaces all usages of `map`, `pair` and
`vector` with `std::map`, `std::pair` and `std::vector`
and remove the `using namespace std` line in `stl_check.h`.
```
libs/mathlib.h:132:44: error: reference to ‘byte’ is ambiguous
132 | void NormalToLatLong( const vec3_t normal, byte bytes[2] );
| ^~~~
In file included from /usr/include/c++/11/bits/stl_algobase.h:61,
from /usr/include/c++/11/bits/char_traits.h:39,
from /usr/include/c++/11/ios:40,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from libs/missing.h:76,
from radiant/qe3.h:40,
from radiant/stdafx.h:39,
from radiant/bp_dlg.cpp:28:
/usr/include/c++/11/bits/cpp_type_traits.h:404:30: note: candidates are: ‘enum class std::byte’
404 | enum class byte : unsigned char;
| ^~~~
```
2022-07-14 15:18:51 +00:00
|
|
|
std::list<DPatch> patchList = patch.Split( true, true );
|
|
|
|
for ( std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++ ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
( *patches ).BuildInRadiant();
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
patch.RemoveFromRadiant();
|
|
|
|
|
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DoVisAnalyse(){
|
2007-11-04 03:51:54 +00:00
|
|
|
char filename[1024];
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_FuncTable.m_pfnSelectedBrushCount() == 0 ) {
|
|
|
|
if ( g_VisView ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
delete g_VisView;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) {
|
|
|
|
DoMessageBox( "Invalid number of objects selected, select 1 only", "Error", MB_OK );
|
|
|
|
return;
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
DBrush orgBrush;
|
2012-03-17 20:01:54 +00:00
|
|
|
orgBrush.LoadFromBrush_t( brush, false );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
|
|
|
|
|
|
|
orgBrush.BuildBounds();
|
|
|
|
vec3_t origin;
|
2012-03-17 20:01:54 +00:00
|
|
|
origin[0] = ( orgBrush.bbox_max[0] + orgBrush.bbox_min[0] ) / 2.f;
|
|
|
|
origin[1] = ( orgBrush.bbox_max[1] + orgBrush.bbox_min[1] ) / 2.f;
|
|
|
|
origin[2] = ( orgBrush.bbox_max[2] + orgBrush.bbox_min[2] ) / 2.f;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
char* rad_filename = g_FuncTable.m_pfnGetMapName();
|
|
|
|
if ( !rad_filename ) {
|
|
|
|
DoMessageBox( "An Error Occurred While Trying\n To Get The Map Filename", "Error", MB_OK );
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( filename, rad_filename );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
char* ext = strrchr( filename, '.' ) + 1;
|
|
|
|
strcpy( ext, "bsp" ); // rename the extension
|
2007-11-04 03:51:54 +00:00
|
|
|
|
Do not do `using namespace std` to avoid type conflict
The STL now defines `std::byte` so doing `using namespace std`
will conflict will custom definition of `byte`, which this
legacy code is full of.
It looks like NetRadiant went the route of making explicit
usage of `std::` prefixed types and did not renamed the
custom definition of byte, so doing the same reduces diff
noise between the two trees.
This also makes the code future proof if the STL decides
to define some other types with common name.
This patches replaces all usages of `map`, `pair` and
`vector` with `std::map`, `std::pair` and `std::vector`
and remove the `using namespace std` line in `stl_check.h`.
```
libs/mathlib.h:132:44: error: reference to ‘byte’ is ambiguous
132 | void NormalToLatLong( const vec3_t normal, byte bytes[2] );
| ^~~~
In file included from /usr/include/c++/11/bits/stl_algobase.h:61,
from /usr/include/c++/11/bits/char_traits.h:39,
from /usr/include/c++/11/ios:40,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from libs/missing.h:76,
from radiant/qe3.h:40,
from radiant/stdafx.h:39,
from radiant/bp_dlg.cpp:28:
/usr/include/c++/11/bits/cpp_type_traits.h:404:30: note: candidates are: ‘enum class std::byte’
404 | enum class byte : unsigned char;
| ^~~~
```
2022-07-14 15:18:51 +00:00
|
|
|
std::list<DWinding*> *pointList = BuildTrace( filename, origin );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
if ( !g_VisView ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
g_VisView = new DVisDrawer;
|
|
|
|
g_VisView->Register();
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
g_VisView->SetList( pointList );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DoTrainPathPlot() {
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_TrainView ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
delete g_TrainView;
|
|
|
|
g_TrainView = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_TrainView = new DTrainDrawer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoCaulkSelection( void ) {
|
|
|
|
DEntity world;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:51:54 +00:00
|
|
|
float fScale[2] = { 0.5f, 0.5f };
|
|
|
|
float fShift[2] = { 0.0f, 0.0f };
|
|
|
|
|
|
|
|
int bResetScale[2] = { false, false };
|
|
|
|
int bResetShift[2] = { false, false };
|
|
|
|
|
|
|
|
world.LoadSelectedBrushes();
|
|
|
|
world.LoadSelectedPatches();
|
|
|
|
world.ResetTextures( NULL, fScale, fShift, 0, "textures/common/caulk", true, bResetScale, bResetShift, false, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoTreePlanter( void ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_TreePlanter ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
delete g_TreePlanter;
|
|
|
|
g_TreePlanter = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_TreePlanter = new DTreePlanter();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoDropEnts( void ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_TreePlanter ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
g_TreePlanter->DropEntsToGround();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoMakeChain( void ) {
|
|
|
|
DTreePlanter pl;
|
|
|
|
pl.MakeChain();
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef DPoint* pntTripple[3];
|
|
|
|
|
|
|
|
bool bFacesNoTop[6] = {true, true, true, true, true, false};
|
|
|
|
|
|
|
|
void DoFlipTerrain( void ) {
|
|
|
|
vec3_t vUp = { 0.f, 0.f, 1.f };
|
2012-03-17 20:01:54 +00:00
|
|
|
int i;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
// ensure we have something selected
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_FuncTable.m_pfnSelectedBrushCount() != 2 ) {
|
|
|
|
DoMessageBox( "Invalid number of objects selected, chose 2 only", "Error", MB_OK );
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
|
|
|
|
|
|
|
|
brush_t* brushes[2];
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < 2; i++ ) {
|
|
|
|
brushes[i] = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( i );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DBrush Brushes[2];
|
|
|
|
DPlane* Planes[2];
|
|
|
|
pntTripple Points[2];
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < 2; i++ ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
Brushes[i].LoadFromBrush_t( brushes[i], false );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !( Planes[i] = Brushes[i].FindPlaneWithClosestNormal( vUp ) ) || Brushes[i].FindPointsForPlane( Planes[i], Points[i], 3 ) != 3 ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
2012-03-17 20:01:54 +00:00
|
|
|
DoMessageBox( "Error", "Error", MB_OK );
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3_t mins1, mins2, maxs1, maxs2;
|
|
|
|
Brushes[0].GetBounds( mins1, maxs1 );
|
|
|
|
Brushes[1].GetBounds( mins2, maxs2 );
|
|
|
|
|
|
|
|
entity_t* ents[2];
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < 2; i++ ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
ents[i] = brushes[i]->owner;
|
|
|
|
Brushes[i].RemoveFromRadiant();
|
|
|
|
}
|
|
|
|
|
|
|
|
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int dontmatch[2] = { -1, -1 };
|
|
|
|
bool found = false;
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < 3; i++ ) {
|
|
|
|
for ( int j = 0; j < 3 && !found; j++ ) {
|
|
|
|
if ( VectorCompare( ( Points[0] )[i]->_pnt, ( Points[1] )[j]->_pnt ) ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !found ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
dontmatch[0] = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
found = false;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( dontmatch[0] == -1 ) {
|
|
|
|
DoMessageBox( "Error", "Error", MB_OK );
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < 3; i++ ) {
|
|
|
|
for ( int j = 0; j < 3 && !found; j++ ) {
|
|
|
|
if ( VectorCompare( ( Points[1] )[i]->_pnt, ( Points[0] )[j]->_pnt ) ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !found ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
dontmatch[1] = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
found = false;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( dontmatch[1] == -1 ) {
|
|
|
|
DoMessageBox( "Error", "Error", MB_OK );
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3_t plnpnts1[3];
|
|
|
|
vec3_t plnpnts2[3];
|
|
|
|
vec3_t plnpntsshr[3];
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpnts1[0] );
|
|
|
|
for ( i = 0; i < 3; i++ ) {
|
|
|
|
if ( dontmatch[0] != i ) {
|
|
|
|
VectorCopy( ( Points[0] )[i]->_pnt, plnpnts1[1] );
|
2007-11-04 03:51:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpnts1[2] );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpnts2[0] );
|
|
|
|
for ( i = 0; i < 3; i++ ) {
|
|
|
|
if ( dontmatch[1] != i && !VectorCompare( ( Points[1] )[i]->_pnt, plnpnts1[1] ) ) {
|
|
|
|
VectorCopy( ( Points[1] )[i]->_pnt, plnpnts2[1] );
|
2007-11-04 03:51:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpnts2[2] );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpntsshr[0] );
|
|
|
|
VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpntsshr[1] );
|
|
|
|
if ( ( Points[1] )[dontmatch[1]]->_pnt[2] < ( Points[0] )[dontmatch[0]]->_pnt[2] ) {
|
|
|
|
VectorCopy( ( Points[1] )[dontmatch[1]]->_pnt, plnpntsshr[2] );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
VectorCopy( ( Points[0] )[dontmatch[0]]->_pnt, plnpntsshr[2] );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
plnpntsshr[2][2] -= 16;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < 3; i++ ) {
|
|
|
|
if ( mins2[i] < mins1[i] ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
mins1[i] = mins2[i];
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( maxs2[i] > maxs1[i] ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
maxs1[i] = maxs2[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DBrush* newBrushes[2];
|
2012-03-17 20:01:54 +00:00
|
|
|
newBrushes[0] = DShape::GetBoundingCube_Ext( mins1, maxs1, "textures/common/caulk", bFacesAll, true );
|
|
|
|
newBrushes[1] = DShape::GetBoundingCube_Ext( mins1, maxs1, "textures/common/caulk", bFacesAll, true );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
vec3_t normal;
|
|
|
|
MakeNormal( plnpnts1[0], plnpnts1[1], plnpnts1[2], normal );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( normal[2] >= 0 ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
newBrushes[0]->AddFace( plnpnts1[0], plnpnts1[1], plnpnts1[2], "textures/common/terrain", true );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-11-04 03:51:54 +00:00
|
|
|
newBrushes[0]->AddFace( plnpnts1[2], plnpnts1[1], plnpnts1[0], "textures/common/terrain", true );
|
|
|
|
}
|
|
|
|
|
|
|
|
MakeNormal( plnpnts2[0], plnpnts2[1], plnpnts2[2], normal );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( normal[2] >= 0 ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
newBrushes[1]->AddFace( plnpnts2[0], plnpnts2[1], plnpnts2[2], "textures/common/terrain", true );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-11-04 03:51:54 +00:00
|
|
|
newBrushes[1]->AddFace( plnpnts2[2], plnpnts2[1], plnpnts2[0], "textures/common/terrain", true );
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3_t vec;
|
2012-03-17 20:01:54 +00:00
|
|
|
MakeNormal( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], normal );
|
|
|
|
|
2007-11-04 03:51:54 +00:00
|
|
|
VectorSubtract( plnpnts1[2], plnpnts1[1], vec );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( DotProduct( vec, normal ) >= 0 ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
newBrushes[0]->AddFace( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], "textures/common/caulk", true );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-11-04 03:51:54 +00:00
|
|
|
newBrushes[0]->AddFace( plnpntsshr[2], plnpntsshr[1], plnpntsshr[0], "textures/common/caulk", true );
|
|
|
|
}
|
|
|
|
|
|
|
|
VectorSubtract( plnpnts2[2], plnpnts2[1], vec );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( DotProduct( vec, normal ) >= 0 ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
newBrushes[1]->AddFace( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], "textures/common/caulk", true );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-11-04 03:51:54 +00:00
|
|
|
newBrushes[1]->AddFace( plnpntsshr[2], plnpntsshr[1], plnpntsshr[0], "textures/common/caulk", true );
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < 2; i++ ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
newBrushes[i]->RemoveRedundantPlanes();
|
|
|
|
newBrushes[i]->BuildInRadiant( false, NULL, ents[i] );
|
|
|
|
delete newBrushes[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|