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"
|
|
|
|
#include "DPoint.h"
|
|
|
|
|
|
|
|
#include "DTrainDrawer.h"
|
|
|
|
#include "DEPair.h"
|
|
|
|
|
|
|
|
#include "misc.h"
|
|
|
|
#include "funchandlers.h"
|
|
|
|
|
|
|
|
#include "dialogs/dialogs-gtk.h"
|
|
|
|
|
|
|
|
DTrainDrawer::DTrainDrawer() {
|
|
|
|
refCount = 1;
|
|
|
|
m_bHooked = FALSE;
|
|
|
|
m_bDisplay = FALSE;
|
|
|
|
|
|
|
|
BuildPaths();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
DTrainDrawer::~DTrainDrawer( void ) {
|
|
|
|
if ( m_bHooked ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
UnRegister();
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
ClearPoints();
|
|
|
|
ClearSplines();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DTrainDrawer::ClearSplines() {
|
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<splinePoint_t *>::const_iterator deadSpline = m_splineList.begin(); deadSpline != m_splineList.end(); deadSpline++ ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
( *deadSpline )->m_pointList.clear();
|
|
|
|
( *deadSpline )->m_vertexList.clear();
|
|
|
|
delete ( *deadSpline );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_splineList.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DTrainDrawer::ClearPoints() {
|
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<controlPoint_t *>::const_iterator deadPoint = m_pointList.begin(); deadPoint != m_pointList.end(); deadPoint++ ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
delete *deadPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pointList.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DTrainDrawer::Register() {
|
|
|
|
g_QglTable.m_pfnHookGL2DWindow( this );
|
|
|
|
g_QglTable.m_pfnHookGL3DWindow( this );
|
|
|
|
m_bHooked = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DTrainDrawer::UnRegister() {
|
|
|
|
g_QglTable.m_pfnUnHookGL2DWindow( this );
|
|
|
|
g_QglTable.m_pfnUnHookGL3DWindow( this );
|
|
|
|
m_bHooked = FALSE;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void CalculateSpline_r( vec3_t* v, int count, vec3_t out, float tension ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
vec3_t dist;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( count < 2 ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( count == 2 ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
VectorSubtract( v[1], v[0], dist );
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorMA( v[0], tension, dist, out );
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
vec3_t* v2 = new vec3_t[count - 1];
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( int i = 0; i < count - 1; i++ ) {
|
|
|
|
VectorSubtract( v[i + 1], v[i], dist );
|
|
|
|
VectorMA( v[i], tension, dist, v2[i] );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
CalculateSpline_r( v2, count - 1, out, tension );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
delete[] v2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DTrainDrawer::Draw3D() {
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !m_bDisplay ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglPushAttrib( GL_ALL_ATTRIB_BITS );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglDisable( GL_BLEND );
|
|
|
|
g_QglTable.m_pfn_qglDisable( GL_LINE_SMOOTH );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
g_QglTable.m_pfn_qglPushMatrix();
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglLineWidth( 2.0f );
|
|
|
|
g_QglTable.m_pfn_qglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglEnable( GL_BLEND );
|
|
|
|
g_QglTable.m_pfn_qglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
g_QglTable.m_pfn_qglDisable( GL_POLYGON_SMOOTH );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglDepthFunc( GL_ALWAYS );
|
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<splinePoint_t* >::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++ ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
splinePoint_t* pSP = ( *sp );
|
|
|
|
|
|
|
|
g_QglTable.m_pfn_qglBegin( GL_LINE_STRIP );
|
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<DPoint >::const_iterator v = pSP->m_vertexList.begin(); v != pSP->m_vertexList.end(); v++ ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglVertex3fv( ( *v )._pnt );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
g_QglTable.m_pfn_qglEnd();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_QglTable.m_pfn_qglPopMatrix();
|
|
|
|
g_QglTable.m_pfn_qglPopAttrib();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DTrainDrawer::Draw2D( VIEWTYPE vt ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !m_bDisplay ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglPushAttrib( GL_ALL_ATTRIB_BITS );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglDisable( GL_BLEND );
|
|
|
|
g_QglTable.m_pfn_qglDisable( GL_LINE_SMOOTH );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
g_QglTable.m_pfn_qglPushMatrix();
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
switch ( vt )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
case XY:
|
|
|
|
break;
|
|
|
|
case XZ:
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglRotatef( 270.0f, 1.0f, 0.0f, 0.0f );
|
2007-11-04 03:51:54 +00:00
|
|
|
break;
|
|
|
|
case YZ:
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglRotatef( 270.0f, 1.0f, 0.0f, 0.0f );
|
|
|
|
g_QglTable.m_pfn_qglRotatef( 270.0f, 0.0f, 0.0f, 1.0f );
|
2007-11-04 03:51:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglLineWidth( 1.0f );
|
|
|
|
g_QglTable.m_pfn_qglColor4f( 1.0f, 0.0f, 0.0f, 0.5f );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglEnable( GL_BLEND );
|
|
|
|
g_QglTable.m_pfn_qglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
g_QglTable.m_pfn_qglDisable( GL_POLYGON_SMOOTH );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglDepthFunc( GL_ALWAYS );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglColor4f( 1.f, 0.f, 0.f, 1.f );
|
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<splinePoint_t* >::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++ ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
splinePoint_t* pSP = ( *sp );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglBegin( GL_LINE_STRIP );
|
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<DPoint >::const_iterator v = pSP->m_vertexList.begin(); v != pSP->m_vertexList.end(); v++ ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
g_QglTable.m_pfn_qglVertex3fv( ( *v )._pnt );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
g_QglTable.m_pfn_qglEnd();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_QglTable.m_pfn_qglPopMatrix();
|
|
|
|
g_QglTable.m_pfn_qglPopAttrib();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void AddSplineControl( const char* control, splinePoint_t* pSP ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
controlPoint_t cp;
|
2012-03-17 20:01:54 +00:00
|
|
|
strncpy( cp.strName, control, 64 );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
pSP->m_pointList.push_front( cp );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DTrainDrawer::BuildPaths() {
|
|
|
|
int count = g_FuncTable.m_pfnGetEntityCount();
|
|
|
|
|
|
|
|
DEntity e;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( int i = 0; i < count; i++ ) {
|
|
|
|
entity_s* ent = (entity_s*)g_FuncTable.m_pfnGetEntityHandle( i );
|
2007-11-04 03:51:54 +00:00
|
|
|
e.ClearEPairs();
|
2012-03-17 20:01:54 +00:00
|
|
|
e.LoadEPairList( *g_EntityTable.m_pfnGetEntityKeyValList( ent ) );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
const char* classname = e.m_Classname.GetBuffer();
|
|
|
|
const char* target;
|
|
|
|
const char* control;
|
|
|
|
const char* targetname;
|
2012-03-17 20:01:54 +00:00
|
|
|
vec3_t vOrigin;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
e.SpawnString( "targetname", NULL, &targetname );
|
|
|
|
e.SpawnVector( "origin", "0 0 0", vOrigin );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !strcmp( classname, "info_train_spline_main" ) ) {
|
|
|
|
if ( !targetname ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
Sys_Printf( "info_train_spline_main with no targetname" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
e.SpawnString( "target", NULL, &target );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !target ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
AddControlPoint( targetname, vOrigin );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-11-04 03:51:54 +00:00
|
|
|
splinePoint_t* pSP = AddSplinePoint( targetname, target, vOrigin );
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
e.SpawnString( "control", NULL, &control );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( control ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
AddSplineControl( control, pSP );
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( int j = 2;; j++ ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
char buffer[16];
|
2012-03-17 20:01:54 +00:00
|
|
|
sprintf( buffer, "control%i", j );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
e.SpawnString( buffer, NULL, &control );
|
|
|
|
if ( !control ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:51:54 +00:00
|
|
|
AddSplineControl( control, pSP );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( !strcmp( classname, "info_train_spline_control" ) ) {
|
|
|
|
if ( !targetname ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
Sys_Printf( "info_train_spline_control with no targetname" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AddControlPoint( targetname, vOrigin );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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<splinePoint_t* >::const_iterator sp;
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( sp = m_splineList.begin(); sp != m_splineList.end(); sp++ ) {
|
|
|
|
splinePoint_t* pSP = ( *sp );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
controlPoint_t* pTarget = FindControlPoint( pSP->strTarget );
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !pTarget ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
Sys_Printf( "couldn't find target %s", pSP->strTarget );
|
|
|
|
return;
|
|
|
|
// continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSP->pTarget = pTarget;
|
|
|
|
|
|
|
|
|
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<controlPoint_t >::iterator cp = pSP->m_pointList.begin(); cp != pSP->m_pointList.end(); cp++ ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
controlPoint_t* pControl = FindControlPoint( ( *cp ).strName );
|
|
|
|
if ( !pControl ) {
|
|
|
|
Sys_Printf( "couldn't find control %s", ( *cp ).strName );
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( pControl->vOrigin, ( *cp ).vOrigin );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_bDisplay = TRUE;
|
|
|
|
Register();
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( sp = m_splineList.begin(); sp != m_splineList.end(); sp++ ) {
|
|
|
|
splinePoint_t* pSP = ( *sp );
|
2007-11-04 03:51:54 +00:00
|
|
|
DPoint out;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !pSP->pTarget ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int count = pSP->m_pointList.size() + 2;
|
|
|
|
vec3_t* v = new vec3_t[count];
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( pSP->point.vOrigin, v[0] );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
int i = 1;
|
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<controlPoint_t>::reverse_iterator cp = pSP->m_pointList.rbegin(); cp != pSP->m_pointList.rend(); cp++ ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( ( *cp ).vOrigin, v[i] );
|
2007-11-04 03:51:54 +00:00
|
|
|
i++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( pSP->pTarget->vOrigin, v[i] );
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( float tension = 0.0f; tension <= 1.f; tension += 0.01f ) {
|
|
|
|
CalculateSpline_r( v, count, out._pnt, tension );
|
|
|
|
pSP->m_vertexList.push_front( out );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete[] v;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorCopy( pSP->pTarget->vOrigin, out._pnt );
|
|
|
|
pSP->m_vertexList.push_front( out );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void DTrainDrawer::AddControlPoint( const char* name, vec_t* origin ){
|
2007-11-04 03:51:54 +00:00
|
|
|
controlPoint_t* pCP = new controlPoint_t;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
strncpy( pCP->strName, name, 64 );
|
2007-11-04 03:51:54 +00:00
|
|
|
VectorCopy( origin, pCP->vOrigin );
|
|
|
|
|
|
|
|
m_pointList.push_back( pCP );
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
splinePoint_t* DTrainDrawer::AddSplinePoint( const char* name, const char* target, vec_t* origin ){
|
2007-11-04 03:51:54 +00:00
|
|
|
splinePoint_t* pSP = new splinePoint_t;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
strncpy( pSP->point.strName, name, 64 );
|
|
|
|
strncpy( pSP->strTarget, target, 64 );
|
2007-11-04 03:51:54 +00:00
|
|
|
VectorCopy( origin, pSP->point.vOrigin );
|
|
|
|
m_splineList.push_back( pSP );
|
|
|
|
|
|
|
|
return pSP;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
controlPoint_t* DTrainDrawer::FindControlPoint( const char* name ){
|
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<controlPoint_t*>::const_iterator cp = m_pointList.begin(); cp != m_pointList.end(); cp++ ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !strcmp( name, ( *cp )->strName ) ) {
|
|
|
|
return ( *cp );
|
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<splinePoint_t*>::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++ ) {
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !strcmp( name, ( *sp )->point.strName ) ) {
|
|
|
|
return &( ( *sp )->point );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|