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
|
|
|
|
|
|
|
// DPatch.cpp: implementation of the DPatch class.
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "DPatch.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "./dialogs/dialogs-gtk.h"
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Construction/Destruction
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Added patch merging, wahey!
|
|
|
|
|
|
|
|
//
|
|
|
|
// problem is, you cant put patches into entities as yet :(
|
|
|
|
//
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
DPatch::DPatch(){
|
2007-11-04 03:51:54 +00:00
|
|
|
width = MIN_PATCH_WIDTH;
|
|
|
|
height = MIN_PATCH_HEIGHT;
|
|
|
|
QER_patch = NULL;
|
|
|
|
QER_brush = NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
DPatch::~DPatch(){
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DPatch::SetTexture( const char *textureName ){
|
|
|
|
strcpy( texture, textureName );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void CopyDrawVert( const drawVert_t* in, drawVert_t* out ){
|
2007-11-04 03:51:54 +00:00
|
|
|
out->lightmap[0] = in->lightmap[0];
|
|
|
|
out->lightmap[1] = in->lightmap[1];
|
|
|
|
out->st[0] = in->st[0];
|
|
|
|
out->st[1] = in->st[1];
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( in->normal, out->normal );
|
|
|
|
VectorCopy( in->xyz, out->xyz );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DPatch::BuildInRadiant( void* entity ){
|
2007-11-04 03:51:54 +00:00
|
|
|
int nIndex = g_FuncTable.m_pfnCreatePatchHandle();
|
2012-03-17 20:01:54 +00:00
|
|
|
//$ FIXME: m_pfnGetPatchHandle
|
|
|
|
patchMesh_t* pm = g_FuncTable.m_pfnGetPatchData( nIndex );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
pm->height = height;
|
|
|
|
pm->width = width;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( int x = 0; x < width; x++ )
|
|
|
|
for ( int y = 0; y < height; y++ )
|
|
|
|
CopyDrawVert( &points[x][y], &pm->ctrl[x][y] );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
QER_patch = pm;
|
|
|
|
|
|
|
|
/* if(entity)
|
2012-03-17 20:01:54 +00:00
|
|
|
{
|
|
|
|
// strcpy(pm->d_texture->name, texture);
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
brush_t* brush = (brush_t*)g_FuncTable.m_pfnCreateBrushHandle();
|
|
|
|
brush->patchBrush = TRUE;
|
|
|
|
brush->pPatch = pm;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
pm->pSymbiot = brush;
|
|
|
|
pm->bSelected = false;
|
|
|
|
pm->bOverlay = false; // bleh, f*cks up, just have to wait for a proper function
|
|
|
|
pm->bDirty = true; // or get my own patch out....
|
|
|
|
pm->nListID = -1;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_FuncTable.m_pfnCommitBrushHandleToEntity(brush, entity);
|
|
|
|
}
|
|
|
|
else*/ // patch to entity just plain dont work atm
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( entity ) {
|
|
|
|
g_FuncTable.m_pfnCommitPatchHandleToEntity( nIndex, pm, texture, entity );
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
g_FuncTable.m_pfnCommitPatchHandleToMap( nIndex, pm, texture );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
QER_brush = pm->pSymbiot;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DPatch::LoadFromBrush_t( brush_t* brush ){
|
2007-11-04 03:51:54 +00:00
|
|
|
QER_brush = brush;
|
|
|
|
QER_patch = brush->pPatch;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
SetTexture( QER_patch->pShader->getName() );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( int x = 0; x < QER_patch->width; x++ )
|
|
|
|
for ( int y = 0; y < QER_patch->height; y++ )
|
|
|
|
CopyDrawVert( &QER_patch->ctrl[x][y], &points[x][y] );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
width = QER_patch->width;
|
|
|
|
height = QER_patch->height;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DPatch::RemoveFromRadiant(){
|
|
|
|
if ( QER_brush ) {
|
|
|
|
g_FuncTable.m_pfnDeleteBrushHandle( QER_brush );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
bool DPatch::ResetTextures( const char *oldTextureName, const char *newTextureName ){
|
|
|
|
if ( !oldTextureName || !strcmp( texture, oldTextureName ) ) {
|
|
|
|
strcpy( texture, newTextureName );
|
2007-11-04 03:51:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void Build1dArray( vec3_t* array, drawVert_t points[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT],
|
|
|
|
int startX, int startY, int number, bool horizontal, bool inverse ){
|
2007-11-04 03:51:54 +00:00
|
|
|
int x = startX, y = startY, i, step;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( inverse ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
step = -1;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else{
|
2007-11-04 03:51:54 +00:00
|
|
|
step = 1;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < number; i++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( points[x][y].xyz, array[i] );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( horizontal ) {
|
|
|
|
x += step;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
y += step;
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void Print1dArray( vec3_t* array, int size ){
|
|
|
|
for ( int i = 0; i < size; i++ )
|
|
|
|
Sys_Printf( "(%.0f %.0f %.0f)\t", array[i][0], array[i][1], array[i][2] );
|
|
|
|
Sys_Printf( "\n" );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
bool Compare1dArrays( vec3_t* a1, vec3_t* a2, int size ){
|
2007-11-04 03:51:54 +00:00
|
|
|
int i;
|
|
|
|
bool equal = true;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < size; i++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !VectorCompare( a1[i], a2[size - i - 1] ) ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
equal = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return equal;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
patch_merge_t DPatch::IsMergable( DPatch *other ){
|
2007-11-04 03:51:54 +00:00
|
|
|
int i, j;
|
|
|
|
vec3_t p1Array[4][MAX_PATCH_HEIGHT];
|
|
|
|
vec3_t p2Array[4][MAX_PATCH_HEIGHT];
|
|
|
|
|
|
|
|
int p1ArraySizes[4];
|
|
|
|
int p2ArraySizes[4];
|
|
|
|
|
|
|
|
patch_merge_t merge_info;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
Build1dArray( p1Array[0], this->points, 0, 0, this->width, true, false );
|
|
|
|
Build1dArray( p1Array[1], this->points, this->width - 1, 0, this->height, false, false );
|
|
|
|
Build1dArray( p1Array[2], this->points, this->width - 1, this->height - 1, this->width, true, true );
|
|
|
|
Build1dArray( p1Array[3], this->points, 0, this->height - 1, this->height, false, true );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
Build1dArray( p2Array[0], other->points, 0, 0, other->width, true, false );
|
|
|
|
Build1dArray( p2Array[1], other->points, other->width - 1, 0, other->height, false, false );
|
|
|
|
Build1dArray( p2Array[2], other->points, other->width - 1, other->height - 1, other->width, true, true );
|
|
|
|
Build1dArray( p2Array[3], other->points, 0, other->height - 1, other->height, false, true );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
p1ArraySizes[0] = this->width;
|
|
|
|
p1ArraySizes[1] = this->height;
|
|
|
|
p1ArraySizes[2] = this->width;
|
|
|
|
p1ArraySizes[3] = this->height;
|
|
|
|
|
|
|
|
p2ArraySizes[0] = other->width;
|
|
|
|
p2ArraySizes[1] = other->height;
|
|
|
|
p2ArraySizes[2] = other->width;
|
|
|
|
p2ArraySizes[3] = other->height;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < 4; i++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( j = 0; j < 4; j++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( p1ArraySizes[i] == p2ArraySizes[j] ) {
|
|
|
|
if ( Compare1dArrays( p1Array[i], p2Array[j], p1ArraySizes[i] ) ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
merge_info.pos1 = i;
|
|
|
|
merge_info.pos2 = j;
|
|
|
|
merge_info.mergable = true;
|
|
|
|
return merge_info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:51:54 +00:00
|
|
|
merge_info.mergable = false;
|
|
|
|
return merge_info;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
DPatch* DPatch::MergePatches( patch_merge_t merge_info, DPatch *p1, DPatch *p2 ){
|
|
|
|
while ( merge_info.pos1 != 2 )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
p1->Transpose();
|
|
|
|
merge_info.pos1--;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( merge_info.pos1 < 0 ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
merge_info.pos1 += 4;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( merge_info.pos2 != 0 )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
p2->Transpose();
|
|
|
|
merge_info.pos2--;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( merge_info.pos2 < 0 ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
merge_info.pos2 += 3;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int newHeight = p1->height + p2->height - 1;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( newHeight > MAX_PATCH_HEIGHT ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return NULL;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
DPatch* newPatch = new DPatch();
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
newPatch->height = newHeight;
|
|
|
|
newPatch->width = p1->width;
|
|
|
|
newPatch->SetTexture( p1->texture );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
int y = 0;
|
|
|
|
int i;
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < p1->height; i++, y++ )
|
|
|
|
for ( int x = 0; x < p1->width; x++ )
|
|
|
|
memcpy( &newPatch->points[x][y], &p1->points[x][i], sizeof( drawVert_t ) );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 1; i < p2->height; i++, y++ )
|
|
|
|
for ( int x = 0; x < p2->width; x++ )
|
|
|
|
memcpy( &newPatch->points[x][y], &p2->points[x][i], sizeof( drawVert_t ) );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
// newPatch->Invert();
|
|
|
|
|
|
|
|
return newPatch;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DPatch::Invert(){
|
2007-11-04 03:51:54 +00:00
|
|
|
drawVert_t vertTemp;
|
|
|
|
int i, j;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0 ; i < width ; i++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( j = 0; j < height / 2; j++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
memcpy( &vertTemp, &points[i][height - 1 - j], sizeof( drawVert_t ) );
|
|
|
|
memcpy( &points[i][height - 1 - j], &points[i][j], sizeof( drawVert_t ) );
|
|
|
|
memcpy( &points[i][j], &vertTemp, sizeof( drawVert_t ) );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DPatch::Transpose(){
|
|
|
|
int i, j, w;
|
2007-11-04 03:51:54 +00:00
|
|
|
drawVert_t dv;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( width > height ) {
|
|
|
|
for ( i = 0 ; i < height ; i++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( j = i + 1 ; j < width ; j++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( j < height ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
// swap the value
|
2012-03-17 20:01:54 +00:00
|
|
|
memcpy( &dv, &points[j][i], sizeof( drawVert_t ) );
|
|
|
|
memcpy( &points[j][i], &points[i][j], sizeof( drawVert_t ) );
|
|
|
|
memcpy( &points[i][j], &dv, sizeof( drawVert_t ) );
|
|
|
|
}
|
|
|
|
else
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
// just copy
|
|
|
|
memcpy( &points[i][j], &points[j][i], sizeof( drawVert_t ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0 ; i < width ; i++ )
|
|
|
|
{
|
|
|
|
for ( j = i + 1 ; j < height ; j++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( j < width ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
// swap the value
|
2012-03-17 20:01:54 +00:00
|
|
|
memcpy( &dv, &points[i][j], sizeof( drawVert_t ) );
|
|
|
|
memcpy( &points[i][j], &points[j][i], sizeof( drawVert_t ) );
|
|
|
|
memcpy( &points[j][i], &dv, sizeof( drawVert_t ) );
|
|
|
|
}
|
|
|
|
else
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
// just copy
|
|
|
|
memcpy( &points[j][i], &points[i][j], sizeof( drawVert_t ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
w = width;
|
|
|
|
width = height;
|
|
|
|
height = w;
|
|
|
|
|
|
|
|
Invert();
|
|
|
|
}
|
|
|
|
|
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> DPatch::Split( bool rows, bool cols ){
|
|
|
|
std::list<DPatch> patchList;
|
2007-11-04 03:51:54 +00:00
|
|
|
int i;
|
|
|
|
int x, y;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( rows && height >= 5 ) {
|
|
|
|
for ( i = 0; i < ( height - 1 ) / 2; i++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
DPatch p;
|
|
|
|
|
|
|
|
p.width = width;
|
|
|
|
p.height = 3;
|
2012-03-17 20:01:54 +00:00
|
|
|
p.SetTexture( texture );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( y = 0; y < 3; y++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( x = 0; x < p.width; x++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
memcpy( &p.points[x][y], &points[x][( i * 2 ) + y], sizeof( drawVert_t ) );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
patchList.push_back( p );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( cols && width >= 5 ) {
|
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> patchList2;
|
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
|
|
|
for ( std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++ )
|
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> patchList3 = ( *patches ).Split( false, true );
|
2012-03-17 20:01: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
|
|
|
for ( std::list<DPatch>::iterator patches2 = patchList3.begin(); patches2 != patchList3.end(); patches2++ )
|
2012-03-17 20:01:54 +00:00
|
|
|
patchList2.push_front( *patches2 );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return patchList2;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( cols && width >= 5 ) {
|
|
|
|
for ( i = 0; i < ( width - 1 ) / 2; i++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
DPatch p;
|
|
|
|
|
|
|
|
p.height = height;
|
|
|
|
p.width = 3;
|
2012-03-17 20:01:54 +00:00
|
|
|
p.SetTexture( texture );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( x = 0; x < 3; x++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( y = 0; y < p.height; y++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
memcpy( &p.points[x][y], &points[( i * 2 ) + x][y], sizeof( drawVert_t ) );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
patchList.push_back( p );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return patchList;
|
|
|
|
}
|