various code cleanups

This commit is contained in:
Garux 2021-10-30 16:04:31 +03:00
parent e62da4c621
commit da98e8fde3
70 changed files with 1158 additions and 1276 deletions

View File

@ -234,8 +234,6 @@ td.formatted_questions ol { margin-top: 0px; margin-bottom: 0px; }
<li><strong><code>-extlmhacksize</code> N or N N:</strong> External lightmaps hack size: similar to -lightmapsize N: Size of lightmaps to generate (must be a power of two), but instead of native external lightmaps enables hack to reference them in autogenerated shader (for vanilla Q3 etc)</li>
<li><strong><code>-extradist</code> F:</strong> Extra distance for lights in map units</li>
<li><strong><code>-extravisnudge</code>:</strong> Broken feature to nudge the luxel origin to a better vis cluster</li>
<li><strong><code>-extrawide</code>:</strong> Deprecated alias for <code>-super 2 -filter</code></li>
<li><strong><code>-extra</code>:</strong> Deprecated alias for <code>-super 2</code></li>
<li><strong><code>-fastbounce</code>:</strong> Use <code>-fast</code> style lighting for radiosity</li>
<li><strong><code>-faster</code>:</strong> Use a faster falloff curve for lighting; also implies <code>-fast</code></li>
<li><strong><code>-fastgrid</code>:</strong> Use <code>-fast</code> style lighting for the light grid</li>
@ -288,7 +286,6 @@ td.formatted_questions ol { margin-top: 0px; margin-bottom: 0px; }
<li><strong><code>-shade</code>:</strong> Enable phong shading at default shade angle</li>
<li><strong><code>-skyscale</code> F, <code>-sky</code> F:</strong> Scaling factor for sky and sun light</li>
<li><strong><code>-slowallocate</code>:</strong> Use old (a bit more careful, but much slower) lightmaps packing algorithm</li>
<li><strong><code>-smooth</code>:</strong> Deprecated alias for <code>-samples 2</code></li>
<li><strong><code>-sphericalscale</code> F, <code>-spherical</code> F:</strong> Scaling factor for spherical point light entities</li>
<li><strong><code>-spotscale</code> F, <code>-spot</code> F:</strong> Scaling factor for spot point light entities</li>
<li><strong><code>-sRGB</code>:</strong> Treat colors, textures, and lightmaps as sRGB colorspace</li>

View File

@ -98,7 +98,7 @@ bool XmlTagBuilder::OpenXmlDoc( const char* file, const char* savefile ){
}
}
bool XmlTagBuilder::SaveXmlDoc( void ){
bool XmlTagBuilder::SaveXmlDoc(){
return SaveXmlDoc( m_savefilename.c_str() );
}

View File

@ -84,7 +84,7 @@ public:
bool CreateXmlDocument();
bool OpenXmlDoc( const char* file, const char* savefile = 0 );
bool SaveXmlDoc( const char* file );
bool SaveXmlDoc( void );
bool SaveXmlDoc();
bool AddShaderNode( const char* shader, TextureType textureType, NodeShaderType nodeShaderType );
bool DeleteShaderNode( const char* shader );
bool CheckShaderTag( const char* shader );

View File

@ -114,7 +114,7 @@ scene::Node& Map_Node(){
return GlobalSceneGraph().root();
}
void QE_CheckAutoSave( void ){
void QE_CheckAutoSave(){
if ( !Map_Valid( g_map ) || !ScreenUpdates_Enabled() ) {
return;
}

View File

@ -24,7 +24,7 @@
extern bool g_SnapShots_Enabled;
void AutoSave_clear();
void QE_CheckAutoSave( void );
void QE_CheckAutoSave();
void Map_Snapshot();
void Autosave_Construct();

View File

@ -2385,7 +2385,7 @@ void CamWnd_SetMode( camera_draw_mode mode ){
}
}
void CamWnd_TogglePreview( void ){
void CamWnd_TogglePreview(){
// gametype must be doom3 for this function to work
// if the gametype is not doom3 something is wrong with the
// global command list or somebody else calls this function.

View File

@ -918,7 +918,7 @@ scene::Path ultimate_group_path(){
return path;
}
void CSG_Merge( void ){
void CSG_Merge(){
brush_vector_t selected_brushes;
// remove selected

View File

@ -1638,7 +1638,7 @@ void Map_RegionBounds( const AABB& bounds ){
Map_RegionBrush
===========
*/
void Map_RegionBrush( void ){
void Map_RegionBrush(){
if ( GlobalSelectionSystem().countSelected() != 0 ) {
scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
Map_RegionBounds( instance.worldAABB() );

View File

@ -172,7 +172,7 @@ void CPointfile::GenerateDisplayList(){
// old (but still relevant) pointfile code -------------------------------------
void Pointfile_Delete( void ){
void Pointfile_Delete(){
const char* mapname = Map_Name( g_map );
file_remove( StringOutputStream( 256 )( PathExtensionless( mapname ), ".lin" ).c_str() );
}
@ -194,7 +194,7 @@ void Pointfile_UpdateViews( CPointfile::const_iterator i ){
}
// advance camera to next point
void Pointfile_Next( void ){
void Pointfile_Next(){
if ( !s_pointfile.shown() ) {
return;
}
@ -208,7 +208,7 @@ void Pointfile_Next( void ){
}
// advance camera to previous point
void Pointfile_Prev( void ){
void Pointfile_Prev(){
if ( !s_pointfile.shown() ) {
return;
}

View File

@ -28,7 +28,7 @@
#pragma once
void Pointfile_Clear();
void Pointfile_Delete( void );
void Pointfile_Delete();
void Pointfile_Construct();
void Pointfile_Destroy();

View File

@ -323,7 +323,7 @@ void Sys_SetTitle( const char *text, bool modified ){
bool g_bWaitCursor = false;
void Sys_BeginWait( void ){
void Sys_BeginWait(){
ScreenUpdates_Disable( "Processing...", "Please Wait" );
GdkCursor *cursor = gdk_cursor_new( GDK_WATCH );
gdk_window_set_cursor( gtk_widget_get_window( GTK_WIDGET( MainFrame_getWindow() ) ), cursor );
@ -331,12 +331,12 @@ void Sys_BeginWait( void ){
g_bWaitCursor = true;
}
void Sys_EndWait( void ){
void Sys_EndWait(){
ScreenUpdates_Enable();
gdk_window_set_cursor( gtk_widget_get_window( GTK_WIDGET( MainFrame_getWindow() ) ), 0 );
g_bWaitCursor = false;
}
void Sys_Beep( void ){
void Sys_Beep(){
gdk_beep();
}

View File

@ -260,7 +260,7 @@ void Scene_DeleteSelected( scene::Graph& graph ){
SceneChangeNotify();
}
void Select_Delete( void ){
void Select_Delete(){
Scene_DeleteSelected( GlobalSceneGraph() );
}
@ -903,11 +903,11 @@ void Select_FacesAndPatchesByShader(){
Scene_PatchSelectByShader( GlobalSceneGraph(), TextureBrowser_GetSelectedShader() );
}
void Select_Inside( void ){
void Select_Inside(){
SelectByBounds<SelectionPolicy_Inside>::DoSelection();
}
void Select_Touching( void ){
void Select_Touching(){
SelectByBounds<SelectionPolicy_Touching>::DoSelection( false );
}

View File

@ -422,7 +422,7 @@ static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){
// DoSurface will always try to show the surface inspector
// or update it because something new has been selected
// Shamus: It does get called when the SI is hidden, but not when you select something new. ;-)
void DoSurface( void ){
void DoSurface(){
if ( getSurfaceInspector().GetWidget() == 0 ) {
getSurfaceInspector().Create();
@ -2189,8 +2189,8 @@ namespace TexTool { // namespace hides these symbols from other object-files
struct Extent
{
float minX, minY, maxX, maxY;
float width( void ) { return fabs( maxX - minX ); }
float height( void ) { return fabs( maxY - minY ); }
float width() { return fabs( maxX - minX ); }
float height() { return fabs( maxY - minY ); }
};
//This seems to control the texture scale... (Yep! ;-)
@ -2232,7 +2232,7 @@ Vector2 oldCenter;
void DrawCircularArc( Vector2 ctr, float startAngle, float endAngle, float radius );
void CopyPointsFromSelectedFace( void ){
void CopyPointsFromSelectedFace(){
// Make sure that there's a face and winding to get!
if ( g_SelectedFaceInstances.empty() ) {
@ -2267,7 +2267,7 @@ void CopyPointsFromSelectedFace( void ){
brushprimit_texdef_t bp;
//This approach is probably wrongheaded and just not right anyway. So, !!! FIX !!! [DONE]
void CommitChanges( void ){
void CommitChanges(){
texdef_t t; // Throwaway, since this is BP only
bp.coords[0][0] = tm.coords[0][0] * origBP.coords[0][0] + tm.coords[0][1] * origBP.coords[1][0];
@ -2296,7 +2296,7 @@ void CommitChanges( void ){
//Yep. :-P
}
void UpdateControlPoints( void ){
void UpdateControlPoints(){
CommitChanges();
// Init texture transform matrix
@ -2362,7 +2362,7 @@ const WidgetColor widgetColor[10] = {
#define COLOR_LT_CYAN 8
#define COLOR_LT_GREY 9
void DrawControlWidgets( void ){
void DrawControlWidgets(){
//Note that the grid should go *behind* the face outline... !!! FIX !!!
// Grid
float xStart = center.x() - ( gridWidth / 2.0f );
@ -2456,7 +2456,7 @@ void DrawControlWidgets( void ){
glPopMatrix();
}
void DrawControlPoints( void ){
void DrawControlPoints(){
glColor3f( 1, 1, 1 );
glBegin( GL_LINE_LOOP );

View File

@ -560,7 +560,7 @@ static void graph_tree_model_drag_dest_init( GtkTreeDragDestIface *iface ){
iface->row_drop_possible = graph_tree_model_row_drop_possible;
}
GType graph_tree_model_get_type( void ){
GType graph_tree_model_get_type(){
static GType graph_tree_model_type = 0;
if ( !graph_tree_model_type ) {
@ -1050,7 +1050,7 @@ static void graph_tree_model_tree_model_init( GtkTreeModelIface *iface ){
iface->iter_parent = graph_tree_model_iter_parent;
}
GType graph_tree_model_get_type( void ){
GType graph_tree_model_get_type(){
static GType graph_tree_model_type = 0;
if ( !graph_tree_model_type ) {

View File

@ -1428,7 +1428,7 @@ void WXY_SetBackgroundImage(){
==============
*/
void XYWnd::XY_DrawAxis( void ){
void XYWnd::XY_DrawAxis(){
const char g_AxisName[3] = { 'X', 'Y', 'Z' };
NDIM1NDIM2( m_viewType )
const float w = ( m_nWidth / 2 / m_fScale );
@ -1475,7 +1475,7 @@ void XYWnd::XY_DrawAxis( void ){
GlobalOpenGL().drawChar( g_AxisName[nDim2] );
}
void XYWnd::XY_DrawGrid( void ) {
void XYWnd::XY_DrawGrid() {
float x, y;
char text[32];
float step, minor_step, stepx, stepy;

View File

@ -87,7 +87,7 @@ char *ExpandArg( const char *path ){
I_FloatTime
================
*/
double I_FloatTime( void ){
double I_FloatTime(){
time_t t;
time( &t );

View File

@ -91,7 +91,7 @@ void Q_mkdir( const char *path );
char *ExpandArg( const char *path ); // from cmd line
double I_FloatTime( void );
double I_FloatTime();
FILE *SafeOpenWrite( const char *filename, const char *mode = "wb" );
FILE *SafeOpenRead( const char *filename, const char *mode = "rb" );

View File

@ -28,7 +28,12 @@
*/
#include <string.h> /* XoXus: needed for memset call */
#include "md4.h"
#include <cstdint>
struct mdfour {
std::uint32_t A, B, C, D;
std::uint32_t totalN;
};
/* NOTE: This code makes no attempt to be fast!
@ -47,7 +52,7 @@ static struct mdfour *m;
#define ROUND3( a,b,c,d,k,s ) a = lshift( a + H( b,c,d ) + X[k] + 0x6ED9EBA1,s )
/* this applies md4 to 64 byte chunks */
static void mdfour64( std::uint32_t *M ){
inline void mdfour64( std::uint32_t *M ){
int j;
std::uint32_t AA, BB, CC, DD;
std::uint32_t X[16];
@ -94,22 +99,20 @@ static void mdfour64( std::uint32_t *M ){
m->A = A; m->B = B; m->C = C; m->D = D;
}
static void copy64( std::uint32_t *M, unsigned char *in ){
int i;
for ( i = 0; i < 16; i++ )
inline void copy64( std::uint32_t *M, unsigned char *in ){
for ( int i = 0; i < 16; ++i )
M[i] = ( in[i * 4 + 3] << 24 ) | ( in[i * 4 + 2] << 16 ) |
( in[i * 4 + 1] << 8 ) | ( in[i * 4 + 0] << 0 );
}
static void copy4( unsigned char *out, std::uint32_t x ){
inline void copy4( unsigned char *out, std::uint32_t x ){
out[0] = x & 0xFF;
out[1] = ( x >> 8 ) & 0xFF;
out[2] = ( x >> 16 ) & 0xFF;
out[3] = ( x >> 24 ) & 0xFF;
}
void mdfour_begin( struct mdfour *md ){
inline void mdfour_begin( struct mdfour *md ){
md->A = 0x67452301;
md->B = 0xefcdab89;
md->C = 0x98badcfe;
@ -118,7 +121,7 @@ void mdfour_begin( struct mdfour *md ){
}
static void mdfour_tail( unsigned char *in, int n ){
inline void mdfour_tail( unsigned char *in, int n ){
unsigned char buf[128] = {0};
std::uint32_t M[16];
std::uint32_t b;
@ -146,7 +149,7 @@ static void mdfour_tail( unsigned char *in, int n ){
}
}
void mdfour_update( struct mdfour *md, unsigned char *in, int n ){
inline void mdfour_update( struct mdfour *md, unsigned char *in, int n ){
std::uint32_t M[16];
// start of edit by Forest 'LordHavoc' Hale
@ -168,7 +171,7 @@ void mdfour_update( struct mdfour *md, unsigned char *in, int n ){
}
void mdfour_result( struct mdfour *md, unsigned char *out ){
inline void mdfour_result( struct mdfour *md, unsigned char *out ){
m = md;
copy4( out, m->A );
@ -178,7 +181,7 @@ void mdfour_result( struct mdfour *md, unsigned char *out ){
}
void mdfour( unsigned char *out, unsigned char *in, int n ){
inline void mdfour( unsigned char *out, unsigned char *in, int n ){
struct mdfour md;
mdfour_begin( &md );
mdfour_update( &md, in, n );

View File

@ -27,17 +27,5 @@
#pragma once
#include <cstdint>
struct mdfour {
std::uint32_t A, B, C, D;
std::uint32_t totalN;
};
void mdfour_begin( struct mdfour *md ); // old: MD4Init
void mdfour_update( struct mdfour *md, unsigned char *in, int n ); //old: MD4Update
void mdfour_result( struct mdfour *md, unsigned char *out ); // old: MD4Final
void mdfour( unsigned char *out, unsigned char *in, int n );
unsigned Com_BlockChecksum( void *buffer, int length );
void Com_BlockFullChecksum( void *buffer, int len, unsigned char *outbuf );

View File

@ -57,7 +57,7 @@ void MutexUnlock( mutex_t *m ){
LeaveCriticalSection( crit );
}
mutex_t *MutexAlloc( void ){
mutex_t *MutexAlloc(){
CRITICAL_SECTION *crit;
if ( numthreads == 1 ) {
@ -103,7 +103,7 @@ void MutexUnlock( mutex_t *m ){
pthread_mutex_unlock( my_mutex );
}
mutex_t *MutexAlloc( void ){
mutex_t *MutexAlloc(){
pthread_mutex_t *my_mutex;
pthread_mutexattr_t mattrib;
@ -161,7 +161,7 @@ void MutexUnlock( mutex_t *m ){
release_lock( lck );
}
mutex_t *MutexAlloc( void ){
mutex_t *MutexAlloc(){
abilock_t *lck;
if ( numthreads == 1 ) {
@ -190,7 +190,7 @@ void MutexLock( mutex_t *m ){
void MutexUnlock( mutex_t *m ){
}
mutex_t *MutexAlloc( void ){
mutex_t *MutexAlloc(){
return NULL;
}

View File

@ -26,4 +26,4 @@ typedef void *mutex_t;
void MutexLock( mutex_t *m );
void MutexUnlock( mutex_t *m );
mutex_t *MutexAlloc( void );
mutex_t *MutexAlloc();

View File

@ -23,9 +23,9 @@
extern int numthreads;
void ThreadSetDefault( void );
int GetThreadWork( void );
void ThreadSetDefault();
int GetThreadWork();
void RunThreadsOnIndividual( int workcnt, bool showpacifier, void ( *func )( int ) );
void RunThreadsOn( int workcnt, bool showpacifier, void ( *func )( int ) );
void ThreadLock( void );
void ThreadUnlock( void );
void ThreadLock();
void ThreadUnlock();

View File

@ -128,7 +128,7 @@ void ParseFromMemory( char *buffer, size_t size ){
could cross a line boundary.
==============
*/
void UnGetToken( void ){
void UnGetToken(){
ENSURE( !tokenready && "Can't UnGetToken() twice in a row!" );
tokenready = true;
}
@ -280,7 +280,7 @@ skipspace:
Returns true if there is another token on the line
==============
*/
bool TokenAvailable( void ) {
bool TokenAvailable() {
/* save */
const int oldLine = scriptline;

View File

@ -40,11 +40,11 @@ bool GetToken( bool crossline );
/// \brief Signals that the current token was not used, and should be reported for the next \c GetToken().
/// Only may be used once between the \c GetToken() calls.
void UnGetToken( void );
void UnGetToken();
/// \brief
/// \return true, if there is another token on the line.
bool TokenAvailable( void );
bool TokenAvailable();
/// \brief Parses next token and emits \c Error, if it's not equal to \p match.
/// Allowed to cross a line.

View File

@ -45,7 +45,7 @@ bool threaded;
=============
*/
int GetThreadWork( void ){
int GetThreadWork(){
int r;
int f;
@ -125,7 +125,7 @@ int numthreads = -1;
CRITICAL_SECTION crit;
static int enter;
void ThreadSetDefault( void ){
void ThreadSetDefault(){
SYSTEM_INFO info;
if ( numthreads == -1 ) { // not set manually
@ -140,7 +140,7 @@ void ThreadSetDefault( void ){
}
void ThreadLock( void ){
void ThreadLock(){
if ( !threaded ) {
return;
}
@ -151,7 +151,7 @@ void ThreadLock( void ){
enter = 1;
}
void ThreadUnlock( void ){
void ThreadUnlock(){
if ( !threaded ) {
return;
}
@ -232,7 +232,7 @@ void RunThreadsOn( int workcnt, bool showpacifier, void ( *func )( int ) ){
int numthreads = 4;
void ThreadSetDefault( void ){
void ThreadSetDefault(){
if ( numthreads == -1 ) { // not set manually
numthreads = 4;
}
@ -243,13 +243,13 @@ void ThreadSetDefault( void ){
pthread_mutex_t *my_mutex;
void ThreadLock( void ){
void ThreadLock(){
if ( my_mutex ) {
pthread_mutex_lock( my_mutex );
}
}
void ThreadUnlock( void ){
void ThreadUnlock(){
if ( my_mutex ) {
pthread_mutex_unlock( my_mutex );
}
@ -346,7 +346,7 @@ void RunThreadsOn( int workcnt, bool showpacifier, void ( *func )( int ) ){
int numthreads = -1;
abilock_t lck;
void ThreadSetDefault( void ){
void ThreadSetDefault(){
if ( numthreads == -1 ) {
numthreads = prctl( PR_MAXPPROCS );
}
@ -355,11 +355,11 @@ void ThreadSetDefault( void ){
}
void ThreadLock( void ){
void ThreadLock(){
spin_lock( &lck );
}
void ThreadUnlock( void ){
void ThreadUnlock(){
release_lock( &lck );
}
@ -429,7 +429,7 @@ void RunThreadsOn( int workcnt, bool showpacifier, void ( *func )( int ) ){
int numthreads = -1;
void ThreadSetDefault( void ){
void ThreadSetDefault(){
if ( numthreads == -1 ) { // not set manually
#ifdef _SC_NPROCESSORS_ONLN
long cpus = sysconf( _SC_NPROCESSORS_ONLN );
@ -459,7 +459,7 @@ struct pt_mutex_t
pt_mutex_t global_lock;
void ThreadLock( void ){
void ThreadLock(){
pt_mutex_t *pt_mutex = &global_lock;
if ( !threaded ) {
@ -492,7 +492,7 @@ void ThreadLock( void ){
pthread_mutex_unlock( &pt_mutex->a_mutex );
}
void ThreadUnlock( void ){
void ThreadUnlock(){
pt_mutex_t *pt_mutex = &global_lock;
if ( !threaded ) {
@ -608,14 +608,14 @@ void RunThreadsOn( int workcnt, bool showpacifier, void ( *func )( int ) ){
int numthreads = 1;
void ThreadSetDefault( void ){
void ThreadSetDefault(){
numthreads = 1;
}
void ThreadLock( void ){
void ThreadLock(){
}
void ThreadUnlock( void ){
void ThreadUnlock(){
}
/*

View File

@ -67,7 +67,7 @@ sideRef_t *AllocSideRef( const side_t *side, sideRef_t *next ){
returns false if the brush doesn't enclose a valid volume
*/
bool BoundBrush( brush_t& brush ){
static bool BoundBrush( brush_t& brush ){
brush.minmax.clear();
for ( const side_t& side : brush.sides )
{
@ -132,7 +132,7 @@ Vector3 SnapWeldVector( const Vector3& a, const Vector3& b ){
instead of averaging.
==================
*/
DoubleVector3 SnapWeldVectorAccu( const DoubleVector3& a, const DoubleVector3& b ){
static DoubleVector3 SnapWeldVectorAccu( const DoubleVector3& a, const DoubleVector3& b ){
// I'm just preserving what I think was the intended logic of the original
// SnapWeldVector(). I'm not actually sure where this function should even
// be used. I'd like to know which kinds of problems this function addresses.
@ -180,7 +180,7 @@ DoubleVector3 SnapWeldVectorAccu( const DoubleVector3& a, const DoubleVector3& b
#define DEGENERATE_EPSILON 0.1
bool FixWinding( winding_t& w ){
static bool FixWinding( winding_t& w ){
bool valid = true;
/* dummy check */
@ -236,7 +236,7 @@ bool FixWinding( winding_t& w ){
if the some of the winding's points are close together.
==================
*/
bool FixWindingAccu( winding_accu_t& w ){
static bool FixWindingAccu( winding_accu_t& w ){
bool altered = false;
while ( true )
@ -349,7 +349,7 @@ bool CreateBrushWindings( brush_t& brush ){
Creates a new axial brush
==================
*/
brush_t BrushFromBounds( const Vector3& mins, const Vector3& maxs ){
static brush_t BrushFromBounds( const Vector3& mins, const Vector3& maxs ){
brush_t b;
b.sides.resize( 6 );
for ( int i = 0; i < 3; ++i )
@ -372,7 +372,7 @@ brush_t BrushFromBounds( const Vector3& mins, const Vector3& maxs ){
==================
*/
float BrushVolume( const brush_t& brush ){
static float BrushVolume( const brush_t& brush ){
float volume = 0;
for ( auto i = brush.sides.cbegin(); i != brush.sides.cend(); ++i ){
@ -438,8 +438,9 @@ void WriteBSPBrushMap( const char *name, const brushlist_t& list ){
FilterBrushIntoTree_r()
adds brush reference to any intersecting bsp leafnode
*/
static std::pair<brush_t, brush_t> SplitBrush( const brush_t& brush, int planenum );
int FilterBrushIntoTree_r( brush_t&& b, node_t *node ){
static int FilterBrushIntoTree_r( brush_t&& b, node_t *node ){
/* dummy check */
if ( b.sides.empty() ) {
return 0;
@ -567,7 +568,7 @@ bool WindingIsTiny( const winding_t& w ){
from basewinding for plane
================
*/
bool WindingIsHuge( const winding_t& w ){
static bool WindingIsHuge( const winding_t& w ){
for ( const Vector3& p : w )
if ( !c_worldMinmax.test( p ) )
return true;
@ -582,9 +583,9 @@ bool WindingIsHuge( const winding_t& w ){
==================
*/
int BrushMostlyOnSide( const brush_t& brush, const Plane3f& plane ){
static EPlaneSide BrushMostlyOnSide( const brush_t& brush, const Plane3f& plane ){
float max = 0;
int side = PSIDE_FRONT;
EPlaneSide side = eSideFront;
for ( const side_t& s : brush.sides )
{
for ( const Vector3& p : s.winding )
@ -592,11 +593,11 @@ int BrushMostlyOnSide( const brush_t& brush, const Plane3f& plane ){
const double d = plane3_distance_to_point( plane, p );
if ( d > max ) {
max = d;
side = PSIDE_FRONT;
side = eSideFront;
}
if ( -d > max ) {
max = -d;
side = PSIDE_BACK;
side = eSideBack;
}
}
}
@ -610,7 +611,7 @@ int BrushMostlyOnSide( const brush_t& brush, const Plane3f& plane ){
generates two new brushes, leaving the original unchanged
*/
std::pair<brush_t, brush_t> SplitBrush( const brush_t& brush, int planenum ){
static std::pair<brush_t, brush_t> SplitBrush( const brush_t& brush, int planenum ){
const Plane3f& plane = mapplanes[planenum].plane;
// check all points
@ -649,11 +650,10 @@ std::pair<brush_t, brush_t> SplitBrush( const brush_t& brush, int planenum ){
}
if ( midwinding.empty() || WindingIsTiny( midwinding ) ) { // the brush isn't really split
const int side = BrushMostlyOnSide( brush, plane );
if ( side == PSIDE_BACK ) {
if ( BrushMostlyOnSide( brush, plane ) == eSideBack ) {
return { {}, brush };
}
else { // side == PSIDE_FRONT
else { // side == eSideFront
return { brush, {} };
}
}

View File

@ -91,7 +91,7 @@ static void autocaulk_write(){
copies advertisement info into the BSP structures
*/
static void ProcessAdvertisements( void ) {
static void ProcessAdvertisements() {
Sys_FPrintf( SYS_VRB, "--- ProcessAdvertisements ---\n" );
for ( const auto& e : entities ) {
@ -142,7 +142,7 @@ static void ProcessAdvertisements( void ) {
sets the model numbers for brush entities
*/
static void SetCloneModelNumbers( void ){
static void SetCloneModelNumbers(){
int models;
char modelValue[ 16 ];
const char *value, *value2, *value3;
@ -259,7 +259,7 @@ static void FixBrushSides( entity_t *e ){
creates a full bsp + surfaces for the worldspawn entity
*/
void ProcessWorldModel( void ){
static void ProcessWorldModel(){
entity_t *e;
const char *value;
@ -458,7 +458,7 @@ void ProcessWorldModel( void ){
creates bsp + surfaces for other brush models
*/
void ProcessSubModel( void ){
static void ProcessSubModel(){
/* start a brush model */
BeginModel();
entity_t *e = &entities[ mapEntityNum ];
@ -530,12 +530,9 @@ void ProcessSubModel( void ){
process world + other models into the bsp
*/
void ProcessModels( void ){
bool oldVerbose;
static void ProcessModels(){
/* preserve -v setting */
oldVerbose = verbose;
const bool oldVerbose = verbose;
/* start a new bsp */
BeginBSPFile();
@ -584,7 +581,7 @@ void ProcessModels( void ){
this is probably broken unless teamed with a radiant version that preserves entity order
*/
void OnlyEnts( const char *filename ){
static void OnlyEnts( const char *filename ){
/* note it */
Sys_Printf( "--- OnlyEnts ---\n" );
@ -861,7 +858,7 @@ int BSPMain( Args& args ){
}
while ( args.takeArg( "-noob" ) ) {
Sys_Printf( "No oBs!\n" );
noob = true;
g_noob = true;
}
while ( args.takeArg( "-autocaulk" ) ) {
Sys_Printf( "\trunning in autocaulk mode\n" );

View File

@ -31,6 +31,7 @@
/* dependencies */
#include "q3map2.h"
#include "bspfile_ibsp.h"
#include <ctime>
@ -57,9 +58,6 @@
*/
void SwapBlock( int *block, int size ){
int i;
/* dummy check */
if ( block == NULL ) {
return;
@ -67,7 +65,7 @@ void SwapBlock( int *block, int size ){
/* swap */
size >>= 2;
for ( i = 0; i < size; i++ )
for ( int i = 0; i < size; ++i )
block[ i ] = LittleLong( block[ i ] );
}
@ -91,7 +89,7 @@ void SwapBlock( std::vector<T>& block ){
byte swaps all data in the abstract bsp
*/
void SwapBSPFile( void ){
static void SwapBSPFile(){
/* models */
SwapBlock( bspModels );
@ -256,7 +254,7 @@ void WriteBSPFile( const char *filename ){
dumps info about current file
*/
void PrintBSPFileSizes( void ){
void PrintBSPFileSizes(){
/* parse entities first */
if ( entities.empty() ) {
ParseEntities();
@ -336,7 +334,7 @@ void PrintBSPFileSizes( void ){
strips low byte chars off the end of a string
*/
StringRange StripTrailing( const char *string ){
inline StringRange StripTrailing( const char *string ){
const char *end = string + strlen( string );
while ( end != string && end[-1] <= 32 ){
--end;
@ -372,7 +370,7 @@ void ParseEPair( std::list<epair_t>& epairs ){
parses an entity's epairs
*/
bool ParseEntity( void ){
static bool ParseEntity(){
/* dummy check */
if ( !GetToken( true ) ) {
return false;
@ -407,7 +405,7 @@ bool ParseEntity( void ){
parses the bsp entity data string into entities
*/
void ParseEntities( void ){
void ParseEntities(){
entities.clear();
ParseFromMemory( bspEntData.data(), bspEntData.size() );
while ( ParseEntity() ){};
@ -444,11 +442,11 @@ void InjectCommandLine( const char *stage, const std::vector<const char *>& args
pairs to the data created by the map editor
*/
void UnparseEntities( void ){
void UnparseEntities(){
StringOutputStream data( 8192 );
/* run through entity list */
for ( std::size_t i = 0; i < numBSPEntities && i < entities.size(); i++ )
for ( std::size_t i = 0; i < numBSPEntities && i < entities.size(); ++i )
{
const entity_t& e = entities[ i ];
/* get epair */

View File

@ -18,13 +18,7 @@
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
----------------------------------------------------------------------------------
This code has been altered significantly from its original form, to support
several games based on the Quake III Arena engine, in the form of "Q3Map2."
------------------------------------------------------------------------------- */
*/
#pragma once

View File

@ -31,6 +31,7 @@
/* dependencies */
#include "q3map2.h"
#include "bspfile_abstract.h"
#include <ctime>

View File

@ -31,6 +31,7 @@
/* dependencies */
#include "q3map2.h"
#include "bspfile_abstract.h"
#include <ctime>

View File

@ -39,7 +39,7 @@
converts a bsp drawsurface to an ase chunk
*/
int numLightmapsASE = 0;
static int numLightmapsASE = 0;
static void ConvertSurface( FILE *f, int modelNum, int surfaceNum, const Vector3& origin, const std::vector<int>& lmIndices ){
char name[ 1024 ];

View File

@ -33,8 +33,8 @@
static void AAS_DData( unsigned char *data, int size ){
for ( int i = 0; i < size; i++ )
inline void AAS_DData( unsigned char *data, int size ){
for ( int i = 0; i < size; ++i )
data[i] ^= (unsigned char) i * 119;
}
@ -943,7 +943,7 @@ int MergeBSPMain( Args& args ){
PseudoCompileBSP()
a stripped down ProcessModels
*/
void PseudoCompileBSP( bool need_tree ){
static void PseudoCompileBSP( bool need_tree ){
int models;
char modelValue[16];
entity_t *entity;

View File

@ -38,7 +38,7 @@
exports a map brush
*/
static float Det3x3( float a00, float a01, float a02,
inline float Det3x3( float a00, float a01, float a02,
float a10, float a11, float a12,
float a20, float a21, float a22 ){
return
@ -47,7 +47,7 @@ static float Det3x3( float a00, float a01, float a02,
+ a02 * ( a10 * a21 - a11 * a20 );
}
void GetBestSurfaceTriangleMatchForBrushside( const side_t& buildSide, const bspDrawVert_t *bestVert[3] ){
static void GetBestSurfaceTriangleMatchForBrushside( const side_t& buildSide, const bspDrawVert_t *bestVert[3] ){
float best = 0;
float thisarea;
const bspDrawVert_t *vert[3];
@ -845,7 +845,7 @@ static void ConvertEPairs( FILE *f, const entity_t& e, bool skip_origin ){
exports an quake map file from the bsp
*/
int ConvertBSPToMap_Ext( char *bspName, bool brushPrimitives ){
static int ConvertBSPToMap_Ext( char *bspName, bool brushPrimitives ){
/* setup brush conversion prerequisites */
{
/* convert bsp planes to map planes */

View File

@ -38,11 +38,11 @@
converts a bsp drawsurface to an obj chunk
*/
int firstLightmap = 0;
int lastLightmap = -1;
static int firstLightmap = 0;
static int lastLightmap = -1;
int objVertexCount = 0;
int objLastShaderNum = -1;
static int objVertexCount = 0;
static int objLastShaderNum = -1;
static void ConvertSurfaceToOBJ( FILE *f, int modelNum, int surfaceNum, const Vector3& origin, const std::vector<int>& lmIndices ){
const bspDrawSurface_t& ds = bspDrawSurfaces[ surfaceNum ];

View File

@ -346,8 +346,7 @@ static int MakeDecalProjector( shaderInfo_t *si, const Plane3f& projection, floa
}
/* return ok */
numProjectors++;
return numProjectors - 1;
return numProjectors++;
}
@ -359,7 +358,7 @@ static int MakeDecalProjector( shaderInfo_t *si, const Plane3f& projection, floa
#define PLANAR_EPSILON 0.5f
void ProcessDecals( void ){
void ProcessDecals(){
int x, y, pw[ 5 ], r, iterations;
float distance;
Plane3f projection, plane;

View File

@ -45,7 +45,7 @@
exports the entities to a text file (.ent)
*/
void ExportEntities( void ){
static void ExportEntities(){
/* note it */
Sys_FPrintf( SYS_VRB, "--- ExportEntities ---\n" );

View File

@ -33,7 +33,7 @@
int c_faceLeafs;
static int c_faceLeafs;
@ -172,7 +172,7 @@ static void SelectSplitPlaneNum( const node_t *node, const facelist_t& list, int
recursively builds the bsp, splitting on face planes
*/
void BuildFaceTree_r( node_t *node, facelist_t& list ){
static void BuildFaceTree_r( node_t *node, facelist_t& list ){
facelist_t childLists[2];
int splitPlaneNum, compileFlags;
#if 0
@ -331,6 +331,12 @@ tree_t FaceBSP( facelist_t& list ) {
get structural brush faces
*/
#define HINT_PRIORITY 1000 /* ydnar: force hint splits first and antiportal/areaportal splits last */
#define ANTIPORTAL_PRIORITY -1000
#define AREAPORTAL_PRIORITY -1000
#define DETAIL_PRIORITY -3000
facelist_t MakeStructuralBSPFaceList( const brushlist_t& list ){
facelist_t flist;

View File

@ -33,8 +33,8 @@
int numFogFragments;
int numFogPatchFragments;
static int numFogFragments;
static int numFogPatchFragments;
@ -43,7 +43,7 @@ int numFogPatchFragments;
converts a patch drawsurface to a mesh_t
*/
mesh_t *DrawSurfToMesh( mapDrawSurface_t *ds ){
static mesh_t *DrawSurfToMesh( mapDrawSurface_t *ds ){
mesh_t *m;
@ -63,7 +63,7 @@ mesh_t *DrawSurfToMesh( mapDrawSurface_t *ds ){
chops a mesh by a plane
*/
void SplitMeshByPlane( mesh_t *in, const Plane3f& plane, mesh_t **front, mesh_t **back ){
static void SplitMeshByPlane( mesh_t *in, const Plane3f& plane, mesh_t **front, mesh_t **back ){
int w, h, split;
float d[MAX_PATCH_SIZE][MAX_PATCH_SIZE];
bspDrawVert_t *dv, *v1, *v2;
@ -244,7 +244,7 @@ void SplitMeshByPlane( mesh_t *in, const Plane3f& plane, mesh_t **front, mesh_t
chops a patch up by a fog brush
*/
bool ChopPatchSurfaceByBrush( entity_t *e, mapDrawSurface_t *ds, const brush_t *b ){
static bool ChopPatchSurfaceByBrush( entity_t *e, mapDrawSurface_t *ds, const brush_t *b ){
int i, j;
mesh_t *outside[MAX_BRUSH_SIDES];
int numOutside;
@ -357,7 +357,7 @@ winding_t WindingFromDrawSurf( const mapDrawSurface_t *ds ){
chops up a face drawsurface by a fog brush, with a potential fragment left inside
*/
bool ChopFaceSurfaceByBrush( entity_t *e, mapDrawSurface_t *ds, const brush_t *b ){
static bool ChopFaceSurfaceByBrush( entity_t *e, mapDrawSurface_t *ds, const brush_t *b ){
std::list<winding_t> outside;
mapDrawSurface_t *newds;
@ -635,7 +635,7 @@ int FogForBounds( const MinMax& minmax, float epsilon ){
generates a list of map fogs
*/
void CreateMapFogs( void ){
void CreateMapFogs(){
/* skip? */
if ( nofog ) {
return;

View File

@ -18,13 +18,7 @@
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
----------------------------------------------------------------------------------
This code has been altered significantly from its original form, to support
several games based on the Quake III Arena engine, in the form of "Q3Map2."
------------------------------------------------------------------------------- */
*/

View File

@ -39,7 +39,7 @@ struct HelpOption
const char* description;
};
void HelpOptions(const char* group_name, int indentation, int width, const std::vector<HelpOption>& options)
static void HelpOptions(const char* group_name, int indentation, int width, const std::vector<HelpOption>& options)
{
indentation *= 2;
char* indent = safe_malloc(indentation+1);
@ -82,7 +82,7 @@ void HelpOptions(const char* group_name, int indentation, int width, const std::
free(indent);
}
void HelpBsp()
static void HelpBsp()
{
const std::vector<HelpOption> options = {
{"-bsp [options] <filename.map>", "Switch that enters this stage"},
@ -138,7 +138,7 @@ void HelpBsp()
HelpOptions("BSP Stage", 0, 80, options);
}
void HelpVis()
static void HelpVis()
{
const std::vector<HelpOption> options = {
{"-vis [options] <filename.map>", "Switch that enters this stage"},
@ -155,7 +155,7 @@ void HelpVis()
HelpOptions("VIS Stage", 0, 80, options);
}
void HelpLight()
static void HelpLight()
{
const std::vector<HelpOption> options = {
{"-light [options] <filename.map>", "Switch that enters this stage"},
@ -201,8 +201,6 @@ void HelpLight()
{"-extlmhacksize <N|N N>", "External lightmaps hack size: similar to -lightmapsize N: Size of lightmaps to generate (must be a power of two), but instead of native external lightmaps enables hack to reference them in autogenerated shader (for vanilla Q3 etc)"},
{"-extradist <F>", "Extra distance for lights in map units"},
{"-extravisnudge", "Broken feature to nudge the luxel origin to a better vis cluster"},
{"-extrawide", "Deprecated alias for `-super 2 -filter`"},
{"-extra", "Deprecated alias for `-super 2`"},
{"-fastbounce", "Use `-fast` style lighting for radiosity"},
{"-faster", "Use a faster falloff curve for lighting; also implies `-fast`"},
{"-fastgrid", "Use `-fast` style lighting for the light grid"},
@ -255,7 +253,6 @@ void HelpLight()
{"-shade", "Enable phong shading at default shade angle"},
{"-skyscale <F>, -sky <F>", "Scaling factor for sky and sun light"},
{"-slowallocate", "Use old (a bit more careful, but much slower) lightmaps packing algorithm"},
{"-smooth", "Deprecated alias for `-samples 2`"},
{"-sphericalscale <F>, -spherical <F>", "Scaling factor for spherical point light entities"},
{"-spotscale <F>, -spot <F>", "Scaling factor for spot point light entities"},
{"-sRGB", "Treat colors, textures, and lightmaps as sRGB colorspace"},
@ -275,7 +272,7 @@ void HelpLight()
HelpOptions("Light Stage", 0, 80, options);
}
void HelpAnalyze()
static void HelpAnalyze()
{
const std::vector<HelpOption> options = {
{"-analyze [options] <filename.bsp>", "Switch that enters this mode"},
@ -285,7 +282,7 @@ void HelpAnalyze()
HelpOptions("Analyzing BSP-like file structure", 0, 80, options);
}
void HelpScale()
static void HelpScale()
{
const std::vector<HelpOption> options = {
{"-scale [options] <S filename.bsp>", "Scale uniformly"},
@ -296,7 +293,7 @@ void HelpScale()
HelpOptions("BSP Scaling", 0, 80, options);
}
void HelpShift()
static void HelpShift()
{
const std::vector<HelpOption> options = {
{"-shift <S filename.bsp>", "Shift uniformly"},
@ -305,7 +302,7 @@ void HelpShift()
HelpOptions("BSP Shift", 0, 80, options);
}
void HelpConvert()
static void HelpConvert()
{
const std::vector<HelpOption> options = {
{"-convert [options] <filename.bsp>", "Switch that enters this mode"},
@ -325,7 +322,7 @@ void HelpConvert()
HelpOptions("Converting & Decompiling", 0, 80, options);
}
void HelpExport()
static void HelpExport()
{
const std::vector<HelpOption> options = {
{"-export <filename.bsp>", "Copies lightmaps from the BSP to `filename/lightmap_0000.tga` ff"}
@ -334,7 +331,7 @@ void HelpExport()
HelpOptions("Exporting lightmaps", 0, 80, options);
}
void HelpImport()
static void HelpImport()
{
const std::vector<HelpOption> options = {
{"-import <filename.bsp>", "Copies lightmaps from `filename/lightmap_0000.tga` ff into the BSP"},
@ -343,7 +340,7 @@ void HelpImport()
HelpOptions("Importing lightmaps", 0, 80, options);
}
void HelpExportEnts()
static void HelpExportEnts()
{
const std::vector<HelpOption> options = {
{"-exportents <filename.bsp>", "Exports the entities to a text file (.ent)"},
@ -351,7 +348,7 @@ void HelpExportEnts()
HelpOptions("ExportEnts Stage", 0, 80, options);
}
void HelpFixaas()
static void HelpFixaas()
{
const std::vector<HelpOption> options = {
{"-fixaas <filename.bsp>", "Writes BSP checksum to AAS file, so that it's accepted as valid by engine"},
@ -360,7 +357,7 @@ void HelpFixaas()
HelpOptions("Fixing AAS checksum", 0, 80, options);
}
void HelpInfo()
static void HelpInfo()
{
const std::vector<HelpOption> options = {
{"-info <filename.bsp .. filenameN.bsp>", "Switch that enters this mode"},
@ -369,7 +366,7 @@ void HelpInfo()
HelpOptions("Get info about BSP file", 0, 80, options);
}
void HelpMinimap()
static void HelpMinimap()
{
const std::vector<HelpOption> options = {
{"-minimap [options] <filename.bsp>", "Creates a minimap of the BSP, by default writes to `../gfx/filename_mini.tga`"},
@ -395,7 +392,7 @@ void HelpMinimap()
HelpOptions("MiniMap", 0, 80, options);
}
void HelpPk3()
static void HelpPk3()
{
const std::vector<HelpOption> options = {
{"-pk3 [options] <filename.bsp .. filenameN.bsp>", "Creates a pk3 for the BSP(s) (complete Q3 support). Using file 'gamename.exclude' to exclude vanilla game resources."},
@ -407,7 +404,7 @@ void HelpPk3()
HelpOptions("PK3 creation", 0, 80, options);
}
void HelpRepack()
static void HelpRepack()
{
const std::vector<HelpOption> options = {
{"-repack [options] <filename.bsp .. filenameN.bsp|filenames.txt>", "Creates repack of BSP(s) (complete Q3 support). Rips off only used shaders to new shader file. Using file 'gamename.exclude' to exclude vanilla game resources and 'repack.exclude' to exclude resources of existing repack."},
@ -420,7 +417,7 @@ void HelpRepack()
HelpOptions("Maps repack creation", 0, 80, options);
}
void HelpJson()
static void HelpJson()
{
const std::vector<HelpOption> options = {
{"-json [options] <filename.bsp>", "Export/import BSP to/from json text files for debugging and editing purposes"},
@ -433,7 +430,7 @@ void HelpJson()
HelpOptions("BSP json export/import", 0, 80, options);
}
void HelpMergeBsp()
static void HelpMergeBsp()
{
const std::vector<HelpOption> options = {
{"-mergebsp [options] <mainBsp.bsp> <bspToinject.bsp>", "Inject latter BSP to former. Tree and vis data of the main one are preserved."},
@ -444,7 +441,7 @@ void HelpMergeBsp()
HelpOptions("BSP merge", 0, 80, options);
}
void HelpCommon()
static void HelpCommon()
{
const std::vector<HelpOption> options = {
{"-connect <address>", "Talk to a NetRadiant instance using a specific XML based protocol"},

View File

@ -30,6 +30,8 @@
/* dependencies */
#include "q3map2.h"
#include "png.h"
#include "ddslib.h"
@ -95,7 +97,7 @@ struct pngBuffer_t
png_size_t size, offset;
};
void PNGReadData( png_struct *png, png_byte *buffer, png_size_t size ){
static void PNGReadData( png_struct *png, png_byte *buffer, png_size_t size ){
pngBuffer_t *pb = (pngBuffer_t*) png_get_io_ptr( png );

View File

@ -55,7 +55,7 @@
TTimo: builds a polyline xml node
=============
*/
xmlNodePtr LeakFile( const tree_t& tree ){
static xmlNodePtr LeakFile( const tree_t& tree ){
Vector3 mid;
FILE *linefile;
const node_t *node;

View File

@ -199,7 +199,7 @@ static void CreateSkyLights( const Vector3& color, float value, int iterations,
creates lights from light entities
*/
void CreateEntityLights( void ){
static void CreateEntityLights(){
/* go through entity list and find lights */
for ( std::size_t i = 0; i < entities.size(); ++i )
{
@ -466,7 +466,7 @@ void CreateEntityLights( void ){
#define APPROX_BOUNCE 1.0f
void CreateSurfaceLights( void ){
static void CreateSurfaceLights(){
clipWork_t cw;
@ -549,7 +549,7 @@ void CreateSurfaceLights( void ){
find the offset values for inline models
*/
void SetEntityOrigins( void ){
static void SetEntityOrigins(){
/* ydnar: copy drawverts into private storage for nefarious purposes */
yDrawVerts = bspDrawVerts;
@ -596,54 +596,46 @@ void SetEntityOrigins( void ){
between this and the approximation
*/
#define ONE_OVER_2PI 0.159154942f //% (1.0f / (2.0f * 3.141592657f))
float PointToPolygonFormFactor( const Vector3& point, const Vector3& normal, const winding_t& w ){
Vector3 dirs[ MAX_POINTS_ON_WINDING ];
float total;
float angle, facing;
double total = 0;
/* this is expensive */
size_t i;
for ( i = 0; i < w.size(); i++ )
for ( size_t i = 0; i < w.size(); ++i )
{
dirs[ i ] = w[ i ] - point;
VectorFastNormalize( dirs[ i ] );
}
/* duplicate first vertex to avoid mod operation */
dirs[ i ] = dirs[ 0 ];
dirs[ w.size() ] = dirs[ 0 ];
/* calculcate relative area */
total = 0.0f;
for ( i = 0; i < w.size(); i++ )
for ( size_t i = 0; i < w.size(); ++i )
{
/* get a triangle */
const size_t j = i + 1;
/* get the angle */
/* roundoff can cause slight creep, which gives an IND from acos, thus clamp */
angle = acos( std::clamp( vector3_dot( dirs[ i ], dirs[ j ] ), -1.0, 1.0 ) );
Vector3 triNormal = vector3_cross( dirs[ i ], dirs[ j ] );
Vector3 triNormal = vector3_cross( dirs[ i ], dirs[ i + 1 ] );
if ( VectorFastNormalize( triNormal ) < 0.0001f ) {
continue;
}
facing = vector3_dot( normal, triNormal );
/* get the angle */
/* roundoff can cause slight creep, which gives an IND from acos, thus clamp */
const double angle = acos( std::clamp( vector3_dot( dirs[ i ], dirs[ i + 1 ] ), -1.0, 1.0 ) );
const double facing = vector3_dot( normal, triNormal );
total += facing * angle;
/* ydnar: this was throwing too many errors with radiosity + crappy maps. ignoring it. */
if ( total > 6.3f || total < -6.3f ) {
if ( total > 6.3 || total < -6.3 ) {
return 0.0f;
}
}
/* now in the range of 0 to 1 over the entire incoming hemisphere */
//% total /= (2.0f * 3.141592657f);
total *= ONE_OVER_2PI;
return total;
return total * c_inv_2pi;
}
@ -1135,7 +1127,7 @@ void LightingAtSample( trace_t *trace, byte styles[ MAX_LIGHTMAPS ], Vector3 (&c
note: this is similar to LightContributionToSample() but optimized for omnidirectional sampling
*/
bool LightContributionToPoint( trace_t *trace ){
static bool LightContributionToPoint( trace_t *trace ){
float add, dist;
/* get light */
@ -1339,7 +1331,7 @@ struct contribution_t
int style;
};
void TraceGrid( int num ){
static void TraceGrid( int num ){
int i, j, x, y, z, mod, numCon, numStyles;
float d, step;
Vector3 cheapColor, thisdir;
@ -1602,7 +1594,7 @@ void TraceGrid( int num ){
calculates the size of the lightgrid and allocates memory
*/
void SetupGrid( void ){
static void SetupGrid(){
/* don't do this if not grid lighting */
if ( noGridLighting ) {
return;
@ -1678,7 +1670,7 @@ void SetupGrid( void ){
does what it says...
*/
void LightWorld( bool fastAllocate ){
static void LightWorld( bool fastAllocate ){
Vector3 color;
float f;
int b, bt;
@ -2037,7 +2029,7 @@ int LightMain( Args& args ){
}
while ( args.takeArg( "-nolm" ) ) {
nolm = true;
noLightmaps = true;
Sys_Printf( "No lightmaps yo\n" );
}
@ -2370,11 +2362,6 @@ int LightMain( Args& args ){
}
}
while ( args.takeArg( "-smooth" ) ) {
lightSamples = EXTRA_SCALE;
Sys_Printf( "The -smooth argument is deprecated, use \"-samples 2\" instead\n" );
}
while ( args.takeArg( "-nofastpoint" ) ) {
fastpoint = false;
Sys_Printf( "Automatic fast mode for point lights disabled\n" );
@ -2475,15 +2462,6 @@ int LightMain( Args& args ){
patchShadows = true;
Sys_Printf( "Patch shadow casting enabled\n" );
}
while ( args.takeArg( "-extra" ) ) {
superSample = EXTRA_SCALE; /* ydnar */
Sys_Printf( "The -extra argument is deprecated, use \"-super 2\" instead\n" );
}
while ( args.takeArg( "-extrawide" ) ) {
superSample = EXTRAWIDE_SCALE; /* ydnar */
filter = true; /* ydnar */
Sys_Printf( "The -extrawide argument is deprecated, use \"-filter [-super 2]\" instead\n" );
}
while ( args.takeArg( "-samplesize" ) ) {
sampleSize = std::max( 1, atoi( args.takeNext() ) );
Sys_Printf( "Default lightmap sample size set to %dx%d units\n", sampleSize, sampleSize );

View File

@ -154,7 +154,7 @@ static void RadClipWindingEpsilon( radWinding_t *in, const Vector3& normal, floa
float Modulo1IfNegative( float f ){
inline float Modulo1IfNegative( float f ){
return f < 0.0f ? f - floor( f ) : f;
}
@ -783,7 +783,7 @@ void RadLightForPatch( int num, int lightmapNum, rawLightmap_t *lm, const shader
creates unbounced diffuse lights for a given surface
*/
void RadLight( int num ){
static void RadLight( int num ){
int lightmapNum;
float scale, subdivide;
int contentFlags, surfaceFlags, compileFlags;
@ -856,9 +856,7 @@ void RadLight( int num ){
creates lights for unbounced light on surfaces in the bsp
*/
int iterations = 0;
void RadCreateDiffuseLights( void ){
void RadCreateDiffuseLights(){
/* startup */
Sys_FPrintf( SYS_VRB, "--- RadCreateDiffuseLights ---\n" );
numDiffuseSurfaces = 0;
@ -866,6 +864,7 @@ void RadCreateDiffuseLights( void ){
numBrushDiffuseLights = 0;
numTriangleDiffuseLights = 0;
numPatchDiffuseLights = 0;
int iterations = 0;
/* hit every surface (threaded) */
RunThreadsOnIndividual( bspDrawSurfaces.size(), true, RadLight );

View File

@ -32,11 +32,6 @@
#include "q3map2.h"
/* dependencies */
#include "q3map2.h"
#define MAX_NODE_ITEMS 5
#define MAX_NODE_TRIANGLES 5
#define MAX_TRACE_DEPTH 32
@ -93,6 +88,8 @@ struct traceNode_t
};
namespace
{
int noDrawContentFlags, noDrawSurfaceFlags, noDrawCompileFlags;
int numTraceInfos = 0, maxTraceInfos = 0, firstTraceInfo = 0;
@ -107,6 +104,7 @@ traceTriangle_t *traceTriangles = NULL;
int headNodeNum = 0, skyboxNodeNum = 0, maxTraceDepth = 0, numTraceLeafNodes = 0;
int numTraceNodes = 0, maxTraceNodes = 0;
traceNode_t *traceNodes = NULL;
}
@ -155,7 +153,7 @@ static int AddTraceInfo( traceInfo_t *ti ){
allocates a new trace node
*/
static int AllocTraceNode( void ){
static int AllocTraceNode(){
/* enough space? */
AUTOEXPAND_BY_REALLOC_ADD( traceNodes, numTraceNodes, maxTraceNodes, GROW_TRACE_NODES );
@ -1048,7 +1046,7 @@ static void PopulateWithPicoModel( int castShadows, const std::vector<const AssM
fills the raytracing tree with world and entity occluders
*/
static void PopulateTraceNodes( void ){
static void PopulateTraceNodes(){
size_t m;
const char *value;
@ -1162,7 +1160,7 @@ static void PopulateTraceNodes( void ){
creates a balanced bsp with axis-aligned splits for efficient raytracing
*/
void SetupTraceNodes( void ){
void SetupTraceNodes(){
/* note it */
Sys_FPrintf( SYS_VRB, "--- SetupTraceNodes ---\n" );
@ -1255,7 +1253,7 @@ void SetupTraceNodes( void ){
#define NEAR_SHADOW_EPSILON 1.5f //% 1.25f
#define SELF_SHADOW_EPSILON 0.5f
bool TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace ){
static bool TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace ){
int i;
Vector3 tvec, pvec, qvec;
float det, invDet, depth;
@ -1420,7 +1418,7 @@ bool TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace ){
temporary hack
*/
bool TraceWinding( traceWinding_t *tw, trace_t *trace ){
static bool TraceWinding( traceWinding_t *tw, trace_t *trace ){
int i;
traceTriangle_t tt;

View File

@ -156,7 +156,7 @@ Vector3b ColorToBytes( const Vector3& color, float scale ){
#define THETA_EPSILON 0.000001
#define EQUAL_NORMAL_EPSILON 0.01f
void SmoothNormals( void ){
void SmoothNormals(){
int fOld, start;
float shadeAngle, defaultShadeAngle, maxShadeAngle;
int indexes[ MAX_SAMPLES ];
@ -302,6 +302,285 @@ void SmoothNormals( void ){
/* ------------------------------------------------------------------------------- */
/*
ClusterVisible()
determines if two clusters are visible to each other using the PVS
*/
bool ClusterVisible( int a, int b ){
/* dummy check */
if ( a < 0 || b < 0 ) {
return false;
}
/* early out */
if ( a == b ) {
return true;
}
/* not vised? */
if ( bspVisBytes.size() <= 8 ) {
return true;
}
/* get pvs data */
/* portalClusters = ((int *) bspVisBytes)[ 0 ]; */
const int leafBytes = ( (int*) bspVisBytes.data() )[ 1 ];
const byte *pvs = bspVisBytes.data() + VIS_HEADER_SIZE + ( a * leafBytes );
/* check */
return bit_is_enabled( pvs, b );
}
/*
PointInLeafNum_r()
borrowed from vlight.c
*/
static int PointInLeafNum_r( const Vector3& point, int nodenum ){
int leafnum;
while ( nodenum >= 0 )
{
const bspNode_t& node = bspNodes[ nodenum ];
const bspPlane_t& plane = bspPlanes[ node.planeNum ];
const double dist = plane3_distance_to_point( plane, point );
if ( dist > 0.1 ) {
nodenum = node.children[ 0 ];
}
else if ( dist < -0.1 ) {
nodenum = node.children[ 1 ];
}
else
{
leafnum = PointInLeafNum_r( point, node.children[ 0 ] );
if ( bspLeafs[ leafnum ].cluster != -1 ) {
return leafnum;
}
nodenum = node.children[ 1 ];
}
}
leafnum = -nodenum - 1;
return leafnum;
}
/*
PointInLeafnum()
borrowed from vlight.c
*/
static int PointInLeafNum( const Vector3& point ){
return PointInLeafNum_r( point, 0 );
}
/*
ClusterForPoint() - ydnar
returns the pvs cluster for point
*/
static int ClusterForPoint( const Vector3& point ){
int leafNum;
/* get leafNum for point */
leafNum = PointInLeafNum( point );
if ( leafNum < 0 ) {
return -1;
}
/* return the cluster */
return bspLeafs[ leafNum ].cluster;
}
/*
ClusterVisibleToPoint() - ydnar
returns true if point can "see" cluster
*/
static bool ClusterVisibleToPoint( const Vector3& point, int cluster ){
int pointCluster;
/* get leafNum for point */
pointCluster = ClusterForPoint( point );
if ( pointCluster < 0 ) {
return false;
}
/* check pvs */
return ClusterVisible( pointCluster, cluster );
}
/*
ClusterForPointExt() - ydnar
also takes brushes into account for occlusion testing
*/
int ClusterForPointExt( const Vector3& point, float epsilon ){
/* get leaf for point */
const int leafNum = PointInLeafNum( point );
if ( leafNum < 0 ) {
return -1;
}
const bspLeaf_t& leaf = bspLeafs[ leafNum ];
/* get the cluster */
const int cluster = leaf.cluster;
if ( cluster < 0 ) {
return -1;
}
/* transparent leaf, so check point against all brushes in the leaf */
const int *brushes = &bspLeafBrushes[ leaf.firstBSPLeafBrush ];
const int numBSPBrushes = leaf.numBSPLeafBrushes;
for ( int i = 0; i < numBSPBrushes; i++ )
{
/* get parts */
const int b = brushes[ i ];
if ( b > maxOpaqueBrush ) {
continue;
}
if ( !opaqueBrushes[ b ] ) {
continue;
}
const bspBrush_t& brush = bspBrushes[ b ];
/* check point against all planes */
bool inside = true;
for ( int j = 0; j < brush.numSides && inside; j++ )
{
const bspPlane_t& plane = bspPlanes[ bspBrushSides[ brush.firstSide + j ].planeNum ];
if ( plane3_distance_to_point( plane, point ) > epsilon ) {
inside = false;
}
}
/* if inside, return bogus cluster */
if ( inside ) {
return -1 - b;
}
}
/* if the point made it this far, it's not inside any opaque brushes */
return cluster;
}
/*
ClusterForPointExtFilter() - ydnar
adds cluster checking against a list of known valid clusters
*/
static int ClusterForPointExtFilter( const Vector3& point, float epsilon, int numClusters, int *clusters ){
int i, cluster;
/* get cluster for point */
cluster = ClusterForPointExt( point, epsilon );
/* check if filtering is necessary */
if ( cluster < 0 || numClusters <= 0 || clusters == NULL ) {
return cluster;
}
/* filter */
for ( i = 0; i < numClusters; i++ )
{
if ( cluster == clusters[ i ] || ClusterVisible( cluster, clusters[ i ] ) ) {
return cluster;
}
}
/* failed */
return -1;
}
/*
ShaderForPointInLeaf() - ydnar
checks a point against all brushes in a leaf, returning the shader of the brush
also sets the cumulative surface and content flags for the brush hit
*/
static int ShaderForPointInLeaf( const Vector3& point, int leafNum, float epsilon, int wantContentFlags, int wantSurfaceFlags, int *contentFlags, int *surfaceFlags ){
int allSurfaceFlags, allContentFlags;
/* clear things out first */
*surfaceFlags = 0;
*contentFlags = 0;
/* get leaf */
if ( leafNum < 0 ) {
return -1;
}
const bspLeaf_t& leaf = bspLeafs[ leafNum ];
/* transparent leaf, so check point against all brushes in the leaf */
const int *brushes = &bspLeafBrushes[ leaf.firstBSPLeafBrush ];
const int numBSPBrushes = leaf.numBSPLeafBrushes;
for ( int i = 0; i < numBSPBrushes; i++ )
{
/* get parts */
const bspBrush_t& brush = bspBrushes[ brushes[ i ] ];
/* check point against all planes */
bool inside = true;
allSurfaceFlags = 0;
allContentFlags = 0;
for ( int j = 0; j < brush.numSides && inside; j++ )
{
const bspBrushSide_t& side = bspBrushSides[ brush.firstSide + j ];
const bspPlane_t& plane = bspPlanes[ side.planeNum ];
if ( plane3_distance_to_point( plane, point ) > epsilon ) {
inside = false;
}
else
{
const bspShader_t& shader = bspShaders[ side.shaderNum ];
allSurfaceFlags |= shader.surfaceFlags;
allContentFlags |= shader.contentFlags;
}
}
/* handle if inside */
if ( inside ) {
/* if there are desired flags, check for same and continue if they aren't matched */
if ( wantContentFlags && !( wantContentFlags & allContentFlags ) ) {
continue;
}
if ( wantSurfaceFlags && !( wantSurfaceFlags & allSurfaceFlags ) ) {
continue;
}
/* store the cumulative flags and return the brush shader (which is mostly useless) */
*surfaceFlags = allSurfaceFlags;
*contentFlags = allContentFlags;
return brush.shaderNum;
}
}
/* if the point made it this far, it's not inside any brushes */
return -1;
}
/* -------------------------------------------------------------------------------
this section deals with phong shaded lightmap tracing
@ -1284,7 +1563,7 @@ void MapRawLightmap( int rawLightmapNum ){
static Vector3 dirtVectors[ DIRT_NUM_VECTORS ];
static int numDirtVectors = 0;
void SetupDirt( void ){
void SetupDirt(){
int i, j;
float angle, elevation, angleStep, elevationStep;
@ -1320,7 +1599,7 @@ void SetupDirt( void ){
calculates dirt value for a given sample
*/
float DirtForSample( trace_t *trace ){
static float DirtForSample( trace_t *trace ){
int i;
float gatherDirt, outDirt, angle, elevation, ooDepth;
Vector3 myUp, myRt;
@ -1825,10 +2104,157 @@ static void RandomSubsampleRawLuxel( rawLightmap_t *lm, trace_t *trace, const Ve
/*
CreateTraceLightsForBounds()
creates a list of lights that affect the given bounding box and pvs clusters (bsp leaves)
*/
static void CreateTraceLightsForBounds( const MinMax& minmax, const Vector3 *normal, int numClusters, int *clusters, LightFlags flags, trace_t *trace ){
int i;
float length;
/* debug code */
//% Sys_Printf( "CTWLFB: (%4.1f %4.1f %4.1f) (%4.1f %4.1f %4.1f)\n", minmax.mins[ 0 ], minmax.mins[ 1 ], minmax.mins[ 2 ], minmax.maxs[ 0 ], minmax.maxs[ 1 ], minmax.maxs[ 2 ] );
/* allocate the light list */
trace->lights = safe_malloc( sizeof( light_t* ) * ( lights.size() + 1 ) );
trace->numLights = 0;
/* calculate spherical bounds */
const Vector3 origin = minmax.origin();
const float radius = vector3_length( minmax.maxs - origin );
/* get length of normal vector */
if ( normal != NULL ) {
length = vector3_length( *normal );
}
else
{
normal = &g_vector3_identity;
length = 0;
}
/* test each light and see if it reaches the sphere */
/* note: the attenuation code MUST match LightingAtSample() */
for ( const light_t& light : lights )
{
/* check zero sized envelope */
if ( light.envelope <= 0 ) {
lightsEnvelopeCulled++;
continue;
}
/* check flags */
if ( !( light.flags & flags ) ) {
continue;
}
/* sunlight skips all this nonsense */
if ( light.type != ELightType::Sun ) {
/* sun only? */
if ( sunOnly ) {
continue;
}
/* check against pvs cluster */
if ( numClusters > 0 && clusters != NULL ) {
for ( i = 0; i < numClusters; i++ )
{
if ( ClusterVisible( light.cluster, clusters[ i ] ) ) {
break;
}
}
/* fixme! */
if ( i == numClusters ) {
lightsClusterCulled++;
continue;
}
}
/* if the light's bounding sphere intersects with the bounding sphere then this light needs to be tested */
if ( vector3_length( light.origin - origin ) - light.envelope - radius > 0 ) {
lightsEnvelopeCulled++;
continue;
}
/* check bounding box against light's pvs envelope (note: this code never eliminated any lights, so disabling it) */
#if 0
if( !minmax.test( light.minmax ) ){
lightsBoundsCulled++;
continue;
}
#endif
}
/* planar surfaces (except twosided surfaces) have a couple more checks */
if ( length > 0.0f && !trace->twoSided ) {
/* lights coplanar with a surface won't light it */
if ( !( light.flags & LightFlags::Twosided ) && vector3_dot( light.normal, *normal ) > 0.999f ) {
lightsPlaneCulled++;
continue;
}
/* check to see if light is behind the plane */
if ( vector3_dot( light.origin, *normal ) - vector3_dot( origin, *normal ) < -1.0f ) {
lightsPlaneCulled++;
continue;
}
}
/* add this light */
trace->lights[ trace->numLights++ ] = &light;
}
/* make last night null */
trace->lights[ trace->numLights ] = NULL;
}
/*
CreateTraceLightsForSurface()
creates a list of lights that can potentially affect a drawsurface
*/
static void CreateTraceLightsForSurface( int num, trace_t *trace ){
/* dummy check */
if ( num < 0 ) {
return;
}
/* get drawsurface and info */
const bspDrawSurface_t& ds = bspDrawSurfaces[ num ];
const surfaceInfo_t& info = surfaceInfos[ num ];
/* get the mins/maxs for the dsurf */
MinMax minmax;
Vector3 normal = bspDrawVerts[ ds.firstVert ].normal;
for ( int i = 0; i < ds.numVerts; i++ )
{
const bspDrawVert_t& dv = yDrawVerts[ ds.firstVert + i ];
minmax.extend( dv.xyz );
if ( !VectorCompare( dv.normal, normal ) ) {
normal.set( 0 );
}
}
/* create the lights for the bounding box */
CreateTraceLightsForBounds( minmax, &normal, info.numSurfaceClusters, &surfaceClusters[ info.firstSurfaceCluster ], LightFlags::Surfaces, trace );
}
inline void FreeTraceLights( trace_t *trace ){
free( trace->lights );
}
/*
IlluminateRawLightmap()
illuminates the luxels
*/
static void FloodlightIlluminateLightmap( rawLightmap_t *lm );
void IlluminateRawLightmap( int rawLightmapNum ){
int i, t, x, y, sx, sy, size, luxelFilterRadius, lightmapNum;
@ -2986,289 +3412,12 @@ void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all )
/* emit some statistics */
Sys_FPrintf( SYS_VRB, "%9d opaque brushes\n", numOpaqueBrushes );
}
void SetupBrushes( void ){
void SetupBrushes(){
SetupBrushesFlags( C_TRANSLUCENT, 0, 0, 0 );
}
/*
ClusterVisible()
determines if two clusters are visible to each other using the PVS
*/
bool ClusterVisible( int a, int b ){
/* dummy check */
if ( a < 0 || b < 0 ) {
return false;
}
/* early out */
if ( a == b ) {
return true;
}
/* not vised? */
if ( bspVisBytes.size() <= 8 ) {
return true;
}
/* get pvs data */
/* portalClusters = ((int *) bspVisBytes)[ 0 ]; */
const int leafBytes = ( (int*) bspVisBytes.data() )[ 1 ];
const byte *pvs = bspVisBytes.data() + VIS_HEADER_SIZE + ( a * leafBytes );
/* check */
return bit_is_enabled( pvs, b );
}
/*
PointInLeafNum_r()
borrowed from vlight.c
*/
int PointInLeafNum_r( const Vector3& point, int nodenum ){
int leafnum;
while ( nodenum >= 0 )
{
const bspNode_t& node = bspNodes[ nodenum ];
const bspPlane_t& plane = bspPlanes[ node.planeNum ];
const double dist = plane3_distance_to_point( plane, point );
if ( dist > 0.1 ) {
nodenum = node.children[ 0 ];
}
else if ( dist < -0.1 ) {
nodenum = node.children[ 1 ];
}
else
{
leafnum = PointInLeafNum_r( point, node.children[ 0 ] );
if ( bspLeafs[ leafnum ].cluster != -1 ) {
return leafnum;
}
nodenum = node.children[ 1 ];
}
}
leafnum = -nodenum - 1;
return leafnum;
}
/*
PointInLeafnum()
borrowed from vlight.c
*/
int PointInLeafNum( const Vector3& point ){
return PointInLeafNum_r( point, 0 );
}
/*
ClusterVisibleToPoint() - ydnar
returns true if point can "see" cluster
*/
bool ClusterVisibleToPoint( const Vector3& point, int cluster ){
int pointCluster;
/* get leafNum for point */
pointCluster = ClusterForPoint( point );
if ( pointCluster < 0 ) {
return false;
}
/* check pvs */
return ClusterVisible( pointCluster, cluster );
}
/*
ClusterForPoint() - ydnar
returns the pvs cluster for point
*/
int ClusterForPoint( const Vector3& point ){
int leafNum;
/* get leafNum for point */
leafNum = PointInLeafNum( point );
if ( leafNum < 0 ) {
return -1;
}
/* return the cluster */
return bspLeafs[ leafNum ].cluster;
}
/*
ClusterForPointExt() - ydnar
also takes brushes into account for occlusion testing
*/
int ClusterForPointExt( const Vector3& point, float epsilon ){
/* get leaf for point */
const int leafNum = PointInLeafNum( point );
if ( leafNum < 0 ) {
return -1;
}
const bspLeaf_t& leaf = bspLeafs[ leafNum ];
/* get the cluster */
const int cluster = leaf.cluster;
if ( cluster < 0 ) {
return -1;
}
/* transparent leaf, so check point against all brushes in the leaf */
const int *brushes = &bspLeafBrushes[ leaf.firstBSPLeafBrush ];
const int numBSPBrushes = leaf.numBSPLeafBrushes;
for ( int i = 0; i < numBSPBrushes; i++ )
{
/* get parts */
const int b = brushes[ i ];
if ( b > maxOpaqueBrush ) {
continue;
}
if ( !opaqueBrushes[ b ] ) {
continue;
}
const bspBrush_t& brush = bspBrushes[ b ];
/* check point against all planes */
bool inside = true;
for ( int j = 0; j < brush.numSides && inside; j++ )
{
const bspPlane_t& plane = bspPlanes[ bspBrushSides[ brush.firstSide + j ].planeNum ];
if ( plane3_distance_to_point( plane, point ) > epsilon ) {
inside = false;
}
}
/* if inside, return bogus cluster */
if ( inside ) {
return -1 - b;
}
}
/* if the point made it this far, it's not inside any opaque brushes */
return cluster;
}
/*
ClusterForPointExtFilter() - ydnar
adds cluster checking against a list of known valid clusters
*/
int ClusterForPointExtFilter( const Vector3& point, float epsilon, int numClusters, int *clusters ){
int i, cluster;
/* get cluster for point */
cluster = ClusterForPointExt( point, epsilon );
/* check if filtering is necessary */
if ( cluster < 0 || numClusters <= 0 || clusters == NULL ) {
return cluster;
}
/* filter */
for ( i = 0; i < numClusters; i++ )
{
if ( cluster == clusters[ i ] || ClusterVisible( cluster, clusters[ i ] ) ) {
return cluster;
}
}
/* failed */
return -1;
}
/*
ShaderForPointInLeaf() - ydnar
checks a point against all brushes in a leaf, returning the shader of the brush
also sets the cumulative surface and content flags for the brush hit
*/
int ShaderForPointInLeaf( const Vector3& point, int leafNum, float epsilon, int wantContentFlags, int wantSurfaceFlags, int *contentFlags, int *surfaceFlags ){
int allSurfaceFlags, allContentFlags;
/* clear things out first */
*surfaceFlags = 0;
*contentFlags = 0;
/* get leaf */
if ( leafNum < 0 ) {
return -1;
}
const bspLeaf_t& leaf = bspLeafs[ leafNum ];
/* transparent leaf, so check point against all brushes in the leaf */
const int *brushes = &bspLeafBrushes[ leaf.firstBSPLeafBrush ];
const int numBSPBrushes = leaf.numBSPLeafBrushes;
for ( int i = 0; i < numBSPBrushes; i++ )
{
/* get parts */
const bspBrush_t& brush = bspBrushes[ brushes[ i ] ];
/* check point against all planes */
bool inside = true;
allSurfaceFlags = 0;
allContentFlags = 0;
for ( int j = 0; j < brush.numSides && inside; j++ )
{
const bspBrushSide_t& side = bspBrushSides[ brush.firstSide + j ];
const bspPlane_t& plane = bspPlanes[ side.planeNum ];
if ( plane3_distance_to_point( plane, point ) > epsilon ) {
inside = false;
}
else
{
const bspShader_t& shader = bspShaders[ side.shaderNum ];
allSurfaceFlags |= shader.surfaceFlags;
allContentFlags |= shader.contentFlags;
}
}
/* handle if inside */
if ( inside ) {
/* if there are desired flags, check for same and continue if they aren't matched */
if ( wantContentFlags && !( wantContentFlags & allContentFlags ) ) {
continue;
}
if ( wantSurfaceFlags && !( wantSurfaceFlags & allSurfaceFlags ) ) {
continue;
}
/* store the cumulative flags and return the brush shader (which is mostly useless) */
*surfaceFlags = allSurfaceFlags;
*contentFlags = allContentFlags;
return brush.shaderNum;
}
}
/* if the point made it this far, it's not inside any brushes */
return -1;
}
/*
ChopBounds()
chops a bounding box by the plane defined by origin and normal
@ -3277,7 +3426,7 @@ int ShaderForPointInLeaf( const Vector3& point, int leafNum, float epsilon, int
this is not exactly the fastest way to do this...
*/
bool ChopBounds( MinMax& minmax, const Vector3& origin, const Vector3& normal ){
inline bool ChopBounds( MinMax& minmax, const Vector3& origin, const Vector3& normal ){
/* FIXME: rewrite this so it doesn't use bloody brushes */
return true;
}
@ -3306,8 +3455,8 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
Sys_FPrintf( SYS_VRB, "--- SetupEnvelopes%s ---\n", fastFlag ? " (fast)" : "" );
/* count lights */
numCulledLights = 0;
for( decltype( lights )::iterator light = lights.begin(); light != lights.end(); )
int numCulledLights = 0;
for( auto light = lights.begin(); light != lights.end(); )
{
/* handle negative lights */
if ( light->photons < 0.0f || light->add < 0.0f ) {
@ -3555,152 +3704,6 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
/*
CreateTraceLightsForBounds()
creates a list of lights that affect the given bounding box and pvs clusters (bsp leaves)
*/
void CreateTraceLightsForBounds( const MinMax& minmax, const Vector3 *normal, int numClusters, int *clusters, LightFlags flags, trace_t *trace ){
int i;
float length;
/* debug code */
//% Sys_Printf( "CTWLFB: (%4.1f %4.1f %4.1f) (%4.1f %4.1f %4.1f)\n", minmax.mins[ 0 ], minmax.mins[ 1 ], minmax.mins[ 2 ], minmax.maxs[ 0 ], minmax.maxs[ 1 ], minmax.maxs[ 2 ] );
/* allocate the light list */
trace->lights = safe_malloc( sizeof( light_t* ) * ( lights.size() + 1 ) );
trace->numLights = 0;
/* calculate spherical bounds */
const Vector3 origin = minmax.origin();
const float radius = vector3_length( minmax.maxs - origin );
/* get length of normal vector */
if ( normal != NULL ) {
length = vector3_length( *normal );
}
else
{
normal = &g_vector3_identity;
length = 0;
}
/* test each light and see if it reaches the sphere */
/* note: the attenuation code MUST match LightingAtSample() */
for ( const light_t& light : lights )
{
/* check zero sized envelope */
if ( light.envelope <= 0 ) {
lightsEnvelopeCulled++;
continue;
}
/* check flags */
if ( !( light.flags & flags ) ) {
continue;
}
/* sunlight skips all this nonsense */
if ( light.type != ELightType::Sun ) {
/* sun only? */
if ( sunOnly ) {
continue;
}
/* check against pvs cluster */
if ( numClusters > 0 && clusters != NULL ) {
for ( i = 0; i < numClusters; i++ )
{
if ( ClusterVisible( light.cluster, clusters[ i ] ) ) {
break;
}
}
/* fixme! */
if ( i == numClusters ) {
lightsClusterCulled++;
continue;
}
}
/* if the light's bounding sphere intersects with the bounding sphere then this light needs to be tested */
if ( vector3_length( light.origin - origin ) - light.envelope - radius > 0 ) {
lightsEnvelopeCulled++;
continue;
}
/* check bounding box against light's pvs envelope (note: this code never eliminated any lights, so disabling it) */
#if 0
if( !minmax.test( light.minmax ) ){
lightsBoundsCulled++;
continue;
}
#endif
}
/* planar surfaces (except twosided surfaces) have a couple more checks */
if ( length > 0.0f && !trace->twoSided ) {
/* lights coplanar with a surface won't light it */
if ( !( light.flags & LightFlags::Twosided ) && vector3_dot( light.normal, *normal ) > 0.999f ) {
lightsPlaneCulled++;
continue;
}
/* check to see if light is behind the plane */
if ( vector3_dot( light.origin, *normal ) - vector3_dot( origin, *normal ) < -1.0f ) {
lightsPlaneCulled++;
continue;
}
}
/* add this light */
trace->lights[ trace->numLights++ ] = &light;
}
/* make last night null */
trace->lights[ trace->numLights ] = NULL;
}
void FreeTraceLights( trace_t *trace ){
free( trace->lights );
}
/*
CreateTraceLightsForSurface()
creates a list of lights that can potentially affect a drawsurface
*/
void CreateTraceLightsForSurface( int num, trace_t *trace ){
/* dummy check */
if ( num < 0 ) {
return;
}
/* get drawsurface and info */
const bspDrawSurface_t& ds = bspDrawSurfaces[ num ];
const surfaceInfo_t& info = surfaceInfos[ num ];
/* get the mins/maxs for the dsurf */
MinMax minmax;
Vector3 normal = bspDrawVerts[ ds.firstVert ].normal;
for ( int i = 0; i < ds.numVerts; i++ )
{
const bspDrawVert_t& dv = yDrawVerts[ ds.firstVert + i ];
minmax.extend( dv.xyz );
if ( !VectorCompare( dv.normal, normal ) ) {
normal.set( 0 );
}
}
/* create the lights for the bounding box */
CreateTraceLightsForBounds( minmax, &normal, info.numSurfaceClusters, &surfaceClusters[ info.firstSurfaceCluster ], LightFlags::Surfaces, trace );
}
/////////////////////////////////////////////////////////////
#define FLOODLIGHT_CONE_ANGLE 88 /* degrees */
@ -3711,7 +3714,7 @@ void CreateTraceLightsForSurface( int num, trace_t *trace ){
static Vector3 floodVectors[ FLOODLIGHT_NUM_VECTORS ];
static int numFloodVectors = 0;
void SetupFloodLight( void ){
void SetupFloodLight(){
int i, j;
float angle, elevation, angleStep, elevationStep;
@ -3896,7 +3899,7 @@ float FloodLightForSample( trace_t *trace, float floodLightDistance, bool floodL
*/
// floodlight pass on a lightmap
void FloodLightRawLightmapPass( rawLightmap_t *lm, Vector3& lmFloodLightRGB, float lmFloodLightIntensity, float lmFloodLightDistance, bool lmFloodLightLowQuality, float floodlightDirectionScale ){
static void FloodLightRawLightmapPass( rawLightmap_t *lm, Vector3& lmFloodLightRGB, float lmFloodLightIntensity, float lmFloodLightDistance, bool lmFloodLightLowQuality, float floodlightDirectionScale ){
int i, x, y;
surfaceInfo_t *info;
trace_t trace;
@ -4018,7 +4021,9 @@ void FloodLightRawLightmapPass( rawLightmap_t *lm, Vector3& lmFloodLightRGB, flo
#endif
}
void FloodLightRawLightmap( int rawLightmapNum ){
static int numSurfacesFloodlighten;
static void FloodLightRawLightmap( int rawLightmapNum ){
rawLightmap_t *lm;
/* bail if this number exceeds the number of raw lightmaps */
@ -4052,7 +4057,7 @@ void FloodlightRawLightmaps(){
illuminate floodlight into lightmap luxels
*/
void FloodlightIlluminateLightmap( rawLightmap_t *lm ){
static void FloodlightIlluminateLightmap( rawLightmap_t *lm ){
int x, y, lightmapNum;
/* walk lightmaps */

View File

@ -31,6 +31,7 @@
/* dependencies */
#include "q3map2.h"
#include "bspfile_rbsp.h"
#include "surface_extra.h"
@ -55,7 +56,7 @@
based on WriteTGA() from imagelib.c
*/
void WriteTGA24( char *filename, byte *data, int width, int height, bool flip ){
static void WriteTGA24( char *filename, byte *data, int width, int height, bool flip ){
int i;
const int headSz = 18;
const int sz = width * height * 3 + headSz;
@ -106,7 +107,7 @@ void WriteTGA24( char *filename, byte *data, int width, int height, bool flip ){
exports the lightmaps as a list of numbered tga images
*/
void ExportLightmaps( void ){
void ExportLightmaps(){
int i;
char dirname[ 1024 ], filename[ 1024 ];
byte *lightmap;
@ -264,12 +265,24 @@ int ImportLightmapsMain( Args& args ){
------------------------------------------------------------------------------- */
namespace
{
int numSurfsVertexLit;
int numSurfsVertexForced;
int numSurfsVertexApproximated;
int numSurfsLightmapped;
int numPlanarsLightmapped;
int numNonPlanarsLightmapped;
int numPatchesLightmapped;
int numPlanarPatchesLightmapped;
}
/*
FinishRawLightmap()
allocates a raw lightmap's necessary buffers
*/
void FinishRawLightmap( rawLightmap_t *lm ){
static void FinishRawLightmap( rawLightmap_t *lm ){
int i, j, c, size, *sc;
float is;
surfaceInfo_t *info;
@ -438,7 +451,7 @@ void FinishRawLightmap( rawLightmap_t *lm ){
based on AllocateLightmapForPatch()
*/
bool AddPatchToRawLightmap( int num, rawLightmap_t *lm ){
static bool AddPatchToRawLightmap( int num, rawLightmap_t *lm ){
bspDrawSurface_t *ds;
surfaceInfo_t *info;
int x, y;
@ -555,7 +568,7 @@ bool AddPatchToRawLightmap( int num, rawLightmap_t *lm ){
based on AllocateLightmapForSurface()
*/
bool AddSurfaceToRawLightmap( int num, rawLightmap_t *lm ){
static bool AddSurfaceToRawLightmap( int num, rawLightmap_t *lm ){
bspDrawSurface_t *ds, *ds2;
surfaceInfo_t *info;
int num2, n, i, axisNum;
@ -922,7 +935,7 @@ struct CompareSurfaceInfo
this depends on yDrawVerts being allocated
*/
void SetupSurfaceLightmaps( void ){
void SetupSurfaceLightmaps(){
int i, j, k, s,num, num2;
bspDrawSurface_t *ds;
surfaceInfo_t *info, *info2;
@ -955,7 +968,7 @@ void SetupSurfaceLightmaps( void ){
surfaceInfos[ i ].childSurfaceNum = -1;
/* allocate a list of surface indexes to be sorted */
sortSurfaces = safe_calloc( numBSPDrawSurfaces * sizeof( int ) );
int *sortSurfaces = safe_calloc( numBSPDrawSurfaces * sizeof( int ) );
/* walk each model in the bsp */
for ( const bspModel_t& model : bspModels )
@ -979,19 +992,21 @@ void SetupSurfaceLightmaps( void ){
info->plane = NULL;
info->firstSurfaceCluster = numSurfaceClusters;
/* get extra data */
info->si = GetSurfaceExtraShaderInfo( num );
if ( info->si == NULL ) {
info->si = ShaderInfoForShader( bspShaders[ ds->shaderNum ].shader );
{ /* get extra data */
const surfaceExtra_t& se = GetSurfaceExtra( num );
info->si = se.si;
if ( info->si == NULL ) {
info->si = ShaderInfoForShader( bspShaders[ ds->shaderNum ].shader );
}
info->parentSurfaceNum = se.parentSurfaceNum;
info->entityNum = se.entityNum;
info->castShadows = se.castShadows;
info->recvShadows = se.recvShadows;
info->sampleSize = se.sampleSize;
info->longestCurve = se.longestCurve;
info->patchIterations = IterationsForCurve( info->longestCurve, patchSubdivisions );
info->axis = se.lightmapAxis;
}
info->parentSurfaceNum = GetSurfaceExtraParentSurfaceNum( num );
info->entityNum = GetSurfaceExtraEntityNum( num );
info->castShadows = GetSurfaceExtraCastShadows( num );
info->recvShadows = GetSurfaceExtraRecvShadows( num );
info->sampleSize = GetSurfaceExtraSampleSize( num );
info->longestCurve = GetSurfaceExtraLongestCurve( num );
info->patchIterations = IterationsForCurve( info->longestCurve, patchSubdivisions );
info->axis = GetSurfaceExtraLightmapAxis( num );
/* mark parent */
if ( info->parentSurfaceNum >= 0 ) {
@ -1040,7 +1055,7 @@ void SetupSurfaceLightmaps( void ){
if ( ds->surfaceType == MST_TRIANGLE_SOUP ||
ds->surfaceType == MST_FOLIAGE ||
( info->si->compileFlags & C_VERTEXLIT ) ||
nolm ) {
noLightmaps ) {
numSurfsVertexLit++;
}
else
@ -1173,7 +1188,7 @@ void SetupSurfaceLightmaps( void ){
#define MAX_STITCH_CANDIDATES 32
#define MAX_STITCH_LUXELS 64
void StitchSurfaceLightmaps( void ){
void StitchSurfaceLightmaps(){
int i, j, x, y, x2, y2,
numStitched, numCandidates, numLuxels, f, fOld, start;
rawLightmap_t *lm, *a, *b, *c[ MAX_STITCH_CANDIDATES ];
@ -2205,7 +2220,7 @@ struct CompareRawLightmap
}
};
void FillOutLightmap( outLightmap_t *olm ){
static void FillOutLightmap( outLightmap_t *olm ){
int x, y;
int ofs;
int cnt, filled;

View File

@ -43,7 +43,7 @@ static void new_handler(){
cleanup routine
*/
static void ExitQ3Map( void ){
static void ExitQ3Map(){
/* flush xml send buffer, shut down connection */
Broadcast_Shutdown();
free( mapDrawSurfs );
@ -58,7 +58,6 @@ static void ExitQ3Map( void ){
int main( int argc, char **argv ){
int r;
double start, end;
#ifdef WIN32
_setmaxstdio(2048);
@ -68,7 +67,7 @@ int main( int argc, char **argv ){
srand( 0 );
/* start timer */
start = I_FloatTime();
const double start = I_FloatTime();
/* this was changed to emit version number over the network */
printf( Q3MAP_VERSION "\n" );
@ -121,13 +120,6 @@ int main( int argc, char **argv ){
/* set number of threads */
ThreadSetDefault();
/* generate sinusoid jitter table */
for ( int i = 0; i < MAX_JITTERS; i++ )
{
jitters[ i ] = sin( i * 139.54152147 );
//% Sys_Printf( "Jitter %4d: %f\n", i, jitters[ i ] );
}
/* we print out two versions, q3map's main version (since it evolves a bit out of GtkRadiant)
and we put the GtkRadiant version to make it easy to track with what version of Radiant it was built with */
@ -236,8 +228,7 @@ int main( int argc, char **argv ){
}
/* emit time */
end = I_FloatTime();
Sys_Printf( "%9.0f seconds elapsed\n", end - start );
Sys_Printf( "%9.0f seconds elapsed\n", I_FloatTime() - start );
/* return any error code */
return r;

View File

@ -39,6 +39,7 @@
#define USE_HASHING
#define PLANE_HASHES 8192
namespace{
int planehash[ PLANE_HASHES ];
int c_boxbevels;
@ -46,6 +47,8 @@ int c_edgebevels;
int c_areaportals;
int c_detail;
int c_structural;
int c_patches;
}
@ -81,7 +84,7 @@ bool PlaneEqual( const plane_t& p, const Plane3f& plane ){
AddPlaneToHash()
*/
void AddPlaneToHash( plane_t& p ){
inline void AddPlaneToHash( plane_t& p ){
const int hash = ( PLANE_HASHES - 1 ) & (int) fabs( p.dist() );
p.hash_chain = planehash[hash];
@ -93,7 +96,7 @@ void AddPlaneToHash( plane_t& p ){
CreateNewFloatPlane
================
*/
int CreateNewFloatPlane( const Plane3f& plane ){
static int CreateNewFloatPlane( const Plane3f& plane ){
if ( vector3_length( plane.normal() ) < 0.5 ) {
Sys_Printf( "FloatPlane: bad normal\n" );
@ -133,7 +136,7 @@ int CreateNewFloatPlane( const Plane3f& plane ){
Returns true if and only if the normal was adjusted.
*/
bool SnapNormal( Vector3& normal ){
static bool SnapNormal( Vector3& normal ){
#if Q3MAP2_EXPERIMENTAL_SNAP_NORMAL_FIX
int i;
bool adjusted = false;
@ -256,7 +259,7 @@ bool SnapNormal( Vector3& normal ){
snaps a plane to normal/distance epsilons
*/
void SnapPlane( Plane3f& plane ){
static void SnapPlane( Plane3f& plane ){
// SnapPlane disabled by LordHavoc because it often messes up collision
// brushes made from triangles of embedded models, and it has little effect
// on anything else (axial planes are usually derived from snapped points)
@ -296,7 +299,7 @@ void SnapPlane( Plane3f& plane ){
SnapPlaneImproved()
snaps a plane to normal/distance epsilons, improved code
*/
void SnapPlaneImproved( Plane3f& plane, int numPoints, const Vector3 *points ){
static void SnapPlaneImproved( Plane3f& plane, int numPoints, const Vector3 *points ){
if ( SnapNormal( plane.normal() ) ) {
if ( numPoints > 0 ) {
// Adjust the dist so that the provided points don't drift away.
@ -434,7 +437,7 @@ int FindFloatPlane( const Plane3f& inplane, int numPoints, const Vector3 *points
takes 3 points and finds the plane they lie in
*/
int MapPlaneFromPoints( DoubleVector3 p[3] ){
inline int MapPlaneFromPoints( DoubleVector3 p[3] ){
#if Q3MAP2_EXPERIMENTAL_HIGH_PRECISION_MATH_FIXES
Plane3 plane;
PlaneFromPoints( plane, p );
@ -457,7 +460,7 @@ int MapPlaneFromPoints( DoubleVector3 p[3] ){
the content flags and compile flags on all sides of a brush should be the same
*/
void SetBrushContents( brush_t& b ){
static void SetBrushContents( brush_t& b ){
if( b.sides.empty() )
return;
@ -565,7 +568,7 @@ void SetBrushContents( brush_t& b ){
ydnar 2003-01-20: added mrelusive fixes
*/
void AddBrushBevels( void ){
void AddBrushBevels(){
const int surfaceFlagsMask = g_game->brushBevelsSurfaceFlagsMask;
auto& sides = buildBrush.sides;
@ -839,7 +842,7 @@ static void FinishBrush( bool noCollapseGroups ){
(must be identical in radiant!)
*/
const Vector3 baseaxis[18] =
static const Vector3 baseaxis[18] =
{
g_vector3_axis_z, g_vector3_axis_x, -g_vector3_axis_y, // floor
-g_vector3_axis_z, g_vector3_axis_x, -g_vector3_axis_y, // ceiling
@ -873,7 +876,7 @@ std::array<Vector3, 2> TextureAxisFromPlane( const plane_t& plane ){
creates world-to-texture mapping vecs for crappy quake plane arrangements
*/
void QuakeTextureVecs( const plane_t& plane, float shift[ 2 ], float rotate, float scale[ 2 ], Vector4 mappingVecs[ 2 ] ){
static void QuakeTextureVecs( const plane_t& plane, float shift[ 2 ], float rotate, float scale[ 2 ], Vector4 mappingVecs[ 2 ] ){
int sv, tv;
float sinv, cosv;
auto vecs = TextureAxisFromPlane( plane );
@ -1117,7 +1120,7 @@ static void ParseRawBrush( bool onlyLights ){
also removes planes without any normal
*/
bool RemoveDuplicateBrushPlanes( brush_t& b ){
static bool RemoveDuplicateBrushPlanes( brush_t& b ){
auto& sides = b.sides;
for( auto it = sides.cbegin(); it != sides.cend(); ){
@ -1211,7 +1214,8 @@ static void ParseBrush( bool onlyLights, bool noCollapseGroups ){
(used by func_group)
*/
void AdjustBrushesForOrigin( entity_t *ent );
static void AdjustBrushesForOrigin( entity_t *ent );
void MoveBrushesToWorld( entity_t *ent ){
/* we need to undo the common/origin adjustment, and instead shift them by the entity key origin */
ent->originbrush_origin = -ent->origin;
@ -1258,7 +1262,7 @@ void MoveBrushesToWorld( entity_t *ent ){
AdjustBrushesForOrigin()
*/
void AdjustBrushesForOrigin( entity_t *ent ){
static void AdjustBrushesForOrigin( entity_t *ent ){
/* walk brush list */
for ( brush_t& b : ent->brushes )
{
@ -1292,7 +1296,7 @@ void AdjustBrushesForOrigin( entity_t *ent ){
finds the bounds of an entity's brushes (necessary for terrain-style generic metashaders)
*/
void SetEntityBounds( entity_t *e ){
static void SetEntityBounds( entity_t *e ){
MinMax minmax;
/* walk the entity's brushes/patches and determine bounds */
@ -1328,7 +1332,7 @@ void SetEntityBounds( entity_t *e ){
based on LoadAlphaMap() from terrain.c, a little more generic
*/
void LoadEntityIndexMap( entity_t *e ){
static void LoadEntityIndexMap( entity_t *e ){
int numLayers, w, h;
const char *indexMapFilename, *shader;
byte *pixels;
@ -1486,8 +1490,7 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups ){
mapEnt = &entities.emplace_back();
/* ydnar: true entity numbering */
mapEnt->mapEntityNum = numMapEntities;
numMapEntities++;
mapEnt->mapEntityNum = numMapEntities++;
/* loop */
while ( 1 )
@ -1511,7 +1514,7 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups ){
/* check */
if ( strEqual( token, "patchDef2" ) ) {
numMapPatches++;
++c_patches;
ParsePatch( onlyLights );
}
else if ( strEqual( token, "terrainDef" ) ) {
@ -1707,7 +1710,7 @@ void LoadMapFile( const char *filename, bool onlyLights, bool noCollapseGroups )
/* emit some statistics */
Sys_FPrintf( SYS_VRB, "%9d total world brushes\n", numMapBrushes );
Sys_FPrintf( SYS_VRB, "%9d detail brushes\n", c_detail );
Sys_FPrintf( SYS_VRB, "%9d patches\n", numMapPatches );
Sys_FPrintf( SYS_VRB, "%9d patches\n", c_patches );
Sys_FPrintf( SYS_VRB, "%9d boxbevels\n", c_boxbevels );
Sys_FPrintf( SYS_VRB, "%9d edgebevels\n", c_edgebevels );
Sys_FPrintf( SYS_VRB, "%9zu entities\n", entities.size() );

View File

@ -554,7 +554,7 @@ mesh_t *SubdivideMesh2( mesh_t in, int iterations ){
ProjectPointOntoVector
================
*/
Vector3 ProjectPointOntoVector( const Vector3& point, const Vector3& vStart, const Vector3& vEnd ){
inline Vector3 ProjectPointOntoVector( const Vector3& point, const Vector3& vStart, const Vector3& vEnd ){
const Vector3 pVec = point - vStart;
const Vector3 vec = VectorNormalized( vEnd - vStart );
// project onto the directional vector for this segment
@ -628,7 +628,7 @@ mesh_t *RemoveLinearMeshColumnsRows( mesh_t *in ) {
SubdivideMeshQuads
=================
*/
mesh_t *SubdivideMeshQuads( mesh_t *in, float minLength, int maxsize, int *widthtable, int *heighttable ){
static mesh_t *SubdivideMeshQuads( mesh_t *in, float minLength, int maxsize, int *widthtable, int *heighttable ){
int i, j, k, w, h, maxsubdivisions, subdivisions;
mesh_t out;
bspDrawVert_t expand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS];

View File

@ -50,7 +50,7 @@ struct minimap_t
static minimap_t minimap;
bool BrushIntersectionWithLine( const bspBrush_t& brush, const Vector3& start, const Vector3& dir, float *t_in, float *t_out ){
static bool BrushIntersectionWithLine( const bspBrush_t& brush, const Vector3& start, const Vector3& dir, float *t_in, float *t_out ){
bool in = false, out = false;
for ( const bspBrushSide_t& side : Span( &bspBrushSides[brush.firstSide], brush.numSides ) )
@ -133,7 +133,7 @@ static float MiniMapSample( float x, float y ){
return samp;
}
void RandomVector2f( float v[2] ){
inline void RandomVector2f( float v[2] ){
do
{
v[0] = 2 * Random() - 1;
@ -271,7 +271,7 @@ static void MiniMapBrightnessContrast( int y ){
}
}
void MiniMapMakeMinsMaxs( const Vector3& mins_in, const Vector3& maxs_in, float border, bool keepaspect ){
static void MiniMapMakeMinsMaxs( const Vector3& mins_in, const Vector3& maxs_in, float border, bool keepaspect ){
Vector3 mins = mins_in;
Vector3 maxs = maxs_in;
Vector3 extend;
@ -312,14 +312,14 @@ void MiniMapMakeMinsMaxs( const Vector3& mins_in, const Vector3& maxs_in, float
determines solid non-sky brushes in the world
*/
void MiniMapSetupBrushes( void ){
static void MiniMapSetupBrushes(){
SetupBrushesFlags( C_SOLID | C_SKY, C_SOLID, 0, 0 );
// at least one must be solid
// none may be sky
// not all may be nodraw
}
bool MiniMapEvaluateSampleOffsets( int *bestj, int *bestk, float *bestval ){
static bool MiniMapEvaluateSampleOffsets( int *bestj, int *bestk, float *bestval ){
float val, dx, dy;
int j, k;
@ -354,7 +354,7 @@ bool MiniMapEvaluateSampleOffsets( int *bestj, int *bestk, float *bestval ){
return *bestval < 3;
}
void MiniMapMakeSampleOffsets(){
static void MiniMapMakeSampleOffsets(){
int i, j, k, jj, kk;
float val, valj, valk, sx, sy, rx, ry;
@ -422,7 +422,7 @@ void MiniMapMakeSampleOffsets(){
}
}
void MergeRelativePath( char *out, const char *absolute, const char *relative ){
static void MergeRelativePath( char *out, const char *absolute, const char *relative ){
const char *endpos = absolute + strlen( absolute );
while ( endpos != absolute && path_separator( endpos[-1] ) )
--endpos;
@ -466,7 +466,6 @@ int MiniMapBSPMain( Args& args ){
strcpy( source, ExpandArg( fileName ) );
path_set_extension( source, ".bsp" );
Sys_Printf( "Loading %s\n", source );
//BeginMapShaderFile( source ); //do not delete q3map2_*.shader on minimap generation
LoadShaderInfo();
LoadBSPFile( source );

View File

@ -291,7 +291,7 @@ static std::map<ModelNameFrame, AssModel> s_assModels;
loads a picoModel and returns a pointer to the picoModel_t struct or NULL if not found
*/
AssModel *LoadModel( const char *name, int frame ){
static AssModel *LoadModel( const char *name, int frame ){
/* dummy check */
if ( strEmptyOrNull( name ) ) {
return nullptr;

View File

@ -42,7 +42,7 @@
gets the user's home dir (for ~/.q3a)
*/
CopiedString LokiGetHomeDir( void ){
static CopiedString LokiGetHomeDir(){
#ifndef Q_UNIX
return "";
#else
@ -73,7 +73,7 @@ CopiedString LokiGetHomeDir( void ){
initializes some paths on linux/os x
*/
void LokiInitPaths( const char *argv0, CopiedString& homePath, CopiedString& installPath ){
static void LokiInitPaths( const char *argv0, CopiedString& homePath, CopiedString& installPath ){
if ( homePath.empty() ) {
/* get home dir */
homePath = LokiGetHomeDir();
@ -218,7 +218,7 @@ inline void insert_unique( std::vector<CopiedString>& list, const char *string )
adds a base path to the list
*/
void AddBasePath( std::vector<CopiedString>& basePaths, const char *path ){
static void AddBasePath( std::vector<CopiedString>& basePaths, const char *path ){
/* dummy check */
if ( !strEmptyOrNull( path ) ) {
/* add it to the list */
@ -235,7 +235,7 @@ void AddBasePath( std::vector<CopiedString>& basePaths, const char *path ){
adds a base path to the beginning of the list, prefixed by ~/
*/
void AddHomeBasePath( std::vector<CopiedString>& basePaths, const char *homePath, const char *homeBasePath ){
static void AddHomeBasePath( std::vector<CopiedString>& basePaths, const char *homePath, const char *homeBasePath ){
if ( strEmpty( homePath ) ) {
return;
}

View File

@ -32,12 +32,6 @@
#include "q3map2.h"
/* ydnar: to fix broken portal windings */
extern bool FixWinding( winding_t& w );
/*
PortalPassable
returns true if the portal has non-opaque leafs on both sides
@ -72,15 +66,15 @@ bool PortalPassable( const portal_t *p ){
int c_tinyportals;
int c_badportals; /* ydnar */
static int c_tinyportals;
static int c_badportals; /* ydnar */
/*
=============
AddPortalToNodes
=============
*/
void AddPortalToNodes( portal_t *p, node_t *front, node_t *back ){
static void AddPortalToNodes( portal_t *p, node_t *front, node_t *back ){
if ( p->nodes[0] || p->nodes[1] ) {
Error( "AddPortalToNode: already included" );
}
@ -139,7 +133,7 @@ void RemovePortalFromNode( portal_t *portal, node_t *l ){
//============================================================================
void PrintPortal( const portal_t *p ){
static void PrintPortal( const portal_t *p ){
for ( const Vector3& point : p->winding )
Sys_Printf( "(%5.0f,%5.0f,%5.0f)\n", point[0], point[1], point[2] );
}
@ -152,7 +146,7 @@ void PrintPortal( const portal_t *p ){
================
*/
#define SIDESPACE 8
void MakeHeadnodePortals( tree_t& tree ){
static void MakeHeadnodePortals( tree_t& tree ){
portal_t *portals[6];
// pad with some space so there will never be null volume leafs
@ -207,7 +201,7 @@ void MakeHeadnodePortals( tree_t& tree ){
#define BASE_WINDING_EPSILON 0.001
#define SPLIT_WINDING_EPSILON 0.001
winding_t BaseWindingForNode( const node_t *node ){
static winding_t BaseWindingForNode( const node_t *node ){
winding_t w = BaseWindingForPlane( mapplanes[node->planenum].plane );
// clip by all the parents
@ -239,7 +233,7 @@ winding_t BaseWindingForNode( const node_t *node ){
and clipping it by all of parents of this node
==================
*/
void MakeNodePortal( node_t *node ){
static void MakeNodePortal( node_t *node ){
int side;
winding_t w = BaseWindingForNode( node );
@ -296,7 +290,7 @@ void MakeNodePortal( node_t *node ){
children have portals instead of node.
==============
*/
void SplitNodePortals( node_t *node ){
static void SplitNodePortals( node_t *node ){
node_t *f, *b, *other_node;
const plane_t& plane = mapplanes[node->planenum];
@ -403,7 +397,7 @@ void SplitNodePortals( node_t *node ){
CalcNodeBounds
================
*/
void CalcNodeBounds( node_t *node ){
static void CalcNodeBounds( node_t *node ){
portal_t *p;
int s;
@ -421,7 +415,7 @@ void CalcNodeBounds( node_t *node ){
MakeTreePortals_r
==================
*/
void MakeTreePortals_r( node_t *node ){
static void MakeTreePortals_r( node_t *node ){
CalcNodeBounds( node );
if ( !node->minmax.valid() ) {
Sys_Warning( "node without a volume\n"
@ -470,9 +464,9 @@ void MakeTreePortals( tree_t& tree ){
=========================================================
*/
int c_floodedleafs;
static int c_floodedleafs;
void FloodPortals( node_t *node, bool skybox ){
static void FloodPortals( node_t *node, bool skybox ){
int dist = 1;
std::vector<node_t*> nodes{ node };
while( !nodes.empty() ){
@ -512,7 +506,7 @@ void FloodPortals( node_t *node, bool skybox ){
=============
*/
bool PlaceOccupant( node_t *headnode, const Vector3& origin, const entity_t *occupant, bool skybox ){
static bool PlaceOccupant( node_t *headnode, const Vector3& origin, const entity_t *occupant, bool skybox ){
node_t *node;
// find the leaf to start in
@ -637,7 +631,7 @@ EFloodEntities FloodEntities( tree_t& tree ){
=========================================================
*/
int c_areas;
static int c_areas;
@ -646,7 +640,7 @@ int c_areas;
floods through leaf portals to tag leafs with an area
*/
void FloodAreas_r( node_t *node ){
static void FloodAreas_r( node_t *node ){
int s;
portal_t *p;
@ -718,7 +712,7 @@ void FloodAreas_r( node_t *node ){
area set, flood fill out from there
=============
*/
void FindAreas_r( node_t *node ){
static void FindAreas_r( node_t *node ){
if ( node->planenum != PLANENUM_LEAF ) {
FindAreas_r( node->children[ 0 ] );
FindAreas_r( node->children[ 1 ] );
@ -738,7 +732,7 @@ void FindAreas_r( node_t *node ){
CheckAreas_r
=============
*/
void CheckAreas_r( const node_t *node ){
static void CheckAreas_r( const node_t *node ){
if ( node->planenum != PLANENUM_LEAF ) {
CheckAreas_r( node->children[0] );
CheckAreas_r( node->children[1] );
@ -771,7 +765,7 @@ void CheckAreas_r( const node_t *node ){
sets all nodes with the skybox area to skybox
*/
void FloodSkyboxArea_r( node_t *node ){
static void FloodSkyboxArea_r( node_t *node ){
if ( skyboxArea < 0 ) {
return;
}
@ -814,11 +808,11 @@ void FloodAreas( tree_t& tree ){
//======================================================
int c_outside;
int c_inside;
int c_solid;
static int c_outside;
static int c_inside;
static int c_solid;
void FillOutside_r( node_t *node ){
static void FillOutside_r( node_t *node ){
if ( node->planenum != PLANENUM_LEAF ) {
FillOutside_r( node->children[0] );
FillOutside_r( node->children[1] );

View File

@ -42,15 +42,15 @@
==============================================================================
*/
#define PORTALFILE "PRT1"
namespace
{
FILE *pf;
int num_visclusters; // clusters the player can be in
int num_visportals;
int num_solidfaces;
}
void WriteFloat( FILE *f, float v ){
inline void WriteFloat( FILE *f, float v ){
if ( fabs( v - std::rint( v ) ) < 0.001 ) {
fprintf( f, "%li ", std::lrint( v ) );
}
@ -59,7 +59,7 @@ void WriteFloat( FILE *f, float v ){
}
}
void CountVisportals_r( const node_t *node ){
static void CountVisportals_r( const node_t *node ){
int s;
// decision node
@ -93,7 +93,7 @@ void CountVisportals_r( const node_t *node ){
WritePortalFile_r
=================
*/
void WritePortalFile_r( const node_t *node ){
static void WritePortalFile_r( const node_t *node ){
int s, flags;
// decision node
@ -161,7 +161,7 @@ void WritePortalFile_r( const node_t *node ){
}
void CountSolidFaces_r( const node_t *node ){
static void CountSolidFaces_r( const node_t *node ){
int s;
// decision node
@ -197,7 +197,7 @@ void CountSolidFaces_r( const node_t *node ){
WriteFaceFile_r
=================
*/
void WriteFaceFile_r( const node_t *node ){
static void WriteFaceFile_r( const node_t *node ){
int s;
// decision node
@ -258,7 +258,7 @@ void WriteFaceFile_r( const node_t *node ){
NumberLeafs_r
================
*/
void NumberLeafs_r( node_t *node, int c ){
static void NumberLeafs_r( node_t *node, int c ){
#if 0
portal_t *p;
#endif

View File

@ -67,8 +67,6 @@
#include "cmdlib.h"
#include "qstringops.h"
#include "qpathops.h"
#include "md5lib.h"
#include "ddslib.h"
#include "scriplib.h"
#include "polylib.h"
@ -77,7 +75,6 @@
#include "inout.h"
#include "inout_xml.h"
#include "vfs.h"
#include "png.h"
#include "md4.h"
#include "stringfixedsize.h"
@ -119,9 +116,6 @@
#define DEF_RADIOSITY_BOUNCE 1.0f /* ydnar: default to 100% re-emitted light */
#define MAX_SHADER_INFO 8192
#define MAX_CUST_SURFACEPARMS 256
#define MAX_JITTERS 256
/* epair parsing (note case-sensitivity directive) */
@ -152,16 +146,6 @@
#define PLANESIDE_EPSILON 0.001f
#define PLANENUM_LEAF -1
#define HINT_PRIORITY 1000 /* ydnar: force hint splits first and antiportal/areaportal splits last */
#define ANTIPORTAL_PRIORITY -1000
#define AREAPORTAL_PRIORITY -1000
#define DETAIL_PRIORITY -3000
#define PSIDE_FRONT 1
#define PSIDE_BACK 2
#define PSIDE_BOTH ( PSIDE_FRONT | PSIDE_BACK )
#define PSIDE_FACING 4
enum class EBrushType
{
Undefined,
@ -196,9 +180,6 @@ enum class EBrushType
#define DEFAULT_LIGHTMAP_SAMPLE_OFFSET 1.0f
#define DEFAULT_SUBDIVIDE_THRESHOLD 1.0f
#define EXTRA_SCALE 2 /* -extrawide = -super 2 */
#define EXTRAWIDE_SCALE 2 /* -extrawide = -super 2 -filter */
#define CLUSTER_UNMAPPED -1
#define CLUSTER_OCCLUDED -2
#define CLUSTER_FLOODED -3
@ -216,7 +197,6 @@ enum class EBrushType
#define EXTERNAL_LIGHTMAP "lm_%04d.tga"
#define MAX_LIGHTMAPS 4 /* RBSP */
#define MAX_LIGHT_STYLES 64
#define MAX_SWITCHED_LIGHTS 32
#define LS_NORMAL 0x00
#define LS_UNUSED 0xFE
@ -1020,99 +1000,6 @@ struct tree_t
/* -------------------------------------------------------------------------------
vis structures
------------------------------------------------------------------------------- */
using visPlane_t = Plane3f;
struct fixedWinding_t
{
int numpoints;
Vector3 points[ MAX_POINTS_ON_FIXED_WINDING ]; /* variable sized */
};
struct passage_t
{
struct passage_t *next;
byte cansee[ 1 ]; /* all portals that can be seen through this passage */
};
enum class EVStatus
{
None,
Working,
Done
};
struct vportal_t
{
int num;
bool hint; /* true if this portal was created from a hint splitter */
bool sky; /* true if this portal belongs to a sky leaf */
bool removed;
visPlane_t plane; /* normal pointing into neighbor */
int leaf; /* neighbor */
Vector3 origin; /* for fast clip testing */
float radius;
fixedWinding_t *winding;
EVStatus status;
byte *portalfront; /* [portals], preliminary */
byte *portalflood; /* [portals], intermediate */
byte *portalvis; /* [portals], final */
int nummightsee; /* bit count on portalflood for sort */
passage_t *passages; /* there are just as many passages as there */
/* are portals in the leaf this portal leads */
};
struct leaf_t
{
int numportals;
int merged;
vportal_t *portals[MAX_PORTALS_ON_LEAF];
};
struct pstack_t
{
byte mightsee[ MAX_PORTALS / 8 ];
pstack_t *next;
leaf_t *leaf;
vportal_t *portal; /* portal exiting */
fixedWinding_t *source;
fixedWinding_t *pass;
fixedWinding_t windings[ 3 ]; /* source, pass, temp in any order */
int freewindings[ 3 ];
visPlane_t portalplane;
int depth;
#ifdef SEPERATORCACHE
visPlane_t seperators[ 2 ][ MAX_SEPERATORS ];
int numseperators[ 2 ];
#endif
};
struct threaddata_t
{
vportal_t *base;
int c_chains;
pstack_t pstack_head;
};
/* -------------------------------------------------------------------------------
light structures
@ -1495,7 +1382,7 @@ public:
------------------------------------------------------------------------------- */
inline float Random( void ){ /* returns a pseudorandom number between 0 and 1 */
inline float Random(){ /* returns a pseudorandom number between 0 and 1 */
return (float) rand() / RAND_MAX;
}
@ -1541,11 +1428,8 @@ int ConvertJsonMain( Args& args );
/* brush.c */
sideRef_t *AllocSideRef( const side_t *side, sideRef_t *next );
bool BoundBrush( brush_t& brush );
Vector3 SnapWeldVector( const Vector3& a, const Vector3& b );
bool CreateBrushWindings( brush_t& brush );
brush_t BrushFromBounds( const Vector3& mins, const Vector3& maxs );
float BrushVolume( const brush_t& brush );
void WriteBSPBrushMap( const char *name, const brushlist_t& list );
void FilterDetailBrushesIntoTree( entity_t *e, tree_t& tree );
@ -1553,8 +1437,6 @@ void FilterStructuralBrushesIntoTree( entity_t *e, tree_t
bool WindingIsTiny( const winding_t& w );
std::pair<brush_t, brush_t> SplitBrush( const brush_t& brush, int planenum );
/* mesh.c */
void LerpDrawVert( const bspDrawVert_t *a, const bspDrawVert_t *b, bspDrawVert_t *out );
@ -1567,7 +1449,6 @@ void InvertMesh( mesh_t *m );
mesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength );
int IterationsForCurve( float len, int subdivisions );
mesh_t *SubdivideMesh2( mesh_t in, int iterations );
mesh_t *SubdivideMeshQuads( mesh_t *in, float minLength, int maxsize, int *widthtable, int *heighttable );
mesh_t *RemoveLinearMeshColumnsRows( mesh_t *in );
void MakeMeshNormals( mesh_t in );
void PutMeshOnCurve( mesh_t in );
@ -1580,15 +1461,12 @@ inline int FindFloatPlane( const Vector3& normal, float dist, i
return FindFloatPlane( Plane3f( normal, dist ), numPoints, points );
}
bool PlaneEqual( const plane_t& p, const Plane3f& plane );
void AddBrushBevels( void );
void AddBrushBevels();
/* portals.c */
void MakeHeadnodePortals( tree_t& tree );
void MakeNodePortal( node_t *node );
void SplitNodePortals( node_t *node );
bool PortalPassable( const portal_t *p );
void RemovePortalFromNode( portal_t *portal, node_t *l );
enum class EFloodEntities
{
@ -1599,7 +1477,7 @@ enum class EFloodEntities
EFloodEntities FloodEntities( tree_t& tree );
void FillOutside( node_t *headnode );
void FloodAreas( tree_t& tree );
inline portal_t *AllocPortal( void ){ return new portal_t(); }
inline portal_t *AllocPortal(){ return new portal_t(); }
inline void FreePortal( portal_t *p ){ delete p; }
void MakeTreePortals( tree_t& tree );
@ -1615,33 +1493,28 @@ void WritePortalFile( const tree_t& tree );
/* writebsp.c */
void SetModelNumbers( void );
void SetLightStyles( void );
void SetModelNumbers();
void SetLightStyles();
int EmitShader( const char *shader, const int *contentFlags, const int *surfaceFlags );
void BeginBSPFile( void );
void BeginBSPFile();
void EndBSPFile( bool do_write );
void EmitBrushes( brushlist_t& brushes, int *firstBrush, int *numBrushes );
void EmitFogs( void );
void EmitFogs();
void BeginModel( void );
void BeginModel();
void EndModel( entity_t *e, node_t *headnode );
/* tree.c */
void FreeTree( tree_t& tree );
void FreeTree_r( node_t *node );
void PrintTree_r( const node_t *node, int depth );
void FreeTreePortals_r( node_t *node );
inline node_t *AllocNode(){ return new node_t(); }
/* patch.c */
void ParsePatch( bool onlyLights );
mesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength );
void PatchMapDrawSurfs( entity_t *e );
void TriangulatePatchSurface( entity_t *e, mapDrawSurface_t *ds );
/* tjunction.c */
@ -1653,7 +1526,7 @@ winding_t WindingFromDrawSurf( const mapDrawSurface_t *ds );
void FogDrawSurfaces( entity_t *e );
int FogForPoint( const Vector3& point, float epsilon );
int FogForBounds( const MinMax& minmax, float epsilon );
void CreateMapFogs( void );
void CreateMapFogs();
/* facebsp.c */
@ -1670,7 +1543,6 @@ void AddTriangleModels( entity_t *e );
/* surface.c */
mapDrawSurface_t *AllocDrawSurface( ESurfaceType type );
void FinishSurface( mapDrawSurface_t *ds );
void StripFaceSurface( mapDrawSurface_t *ds );
void MaxAreaFaceSurface( mapDrawSurface_t *ds );
Vector3 CalcLightmapAxis( const Vector3& normal );
@ -1678,23 +1550,18 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds
void ClassifyEntitySurfaces( entity_t *e );
void TidyEntitySurfaces( entity_t *e );
mapDrawSurface_t *CloneSurface( mapDrawSurface_t *src, shaderInfo_t *si );
mapDrawSurface_t *MakeCelSurface( mapDrawSurface_t *src, shaderInfo_t *si );
bool IsTriangleDegenerate( bspDrawVert_t *points, int a, int b, int c );
void ClearSurface( mapDrawSurface_t *ds );
void AddEntitySurfaceModels( entity_t *e );
mapDrawSurface_t *DrawSurfaceForSide( const entity_t *e, const brush_t& b, const side_t& s, const winding_t& w );
mapDrawSurface_t *DrawSurfaceForMesh( entity_t *e, parseMesh_t *p, mesh_t *mesh );
mapDrawSurface_t *DrawSurfaceForFlare( int entNum, const Vector3& origin, const Vector3& normal, const Vector3& color, const char *flareShader, int lightStyle );
mapDrawSurface_t *DrawSurfaceForShader( const char *shader );
void ClipSidesIntoTree( entity_t *e, const tree_t& tree );
void MakeDebugPortalSurfs( const tree_t& tree );
void MakeFogHullSurfs( entity_t *e, const char *shader );
void SubdivideFaceSurfaces( entity_t *e );
void AddEntitySurfaceModels( entity_t *e );
int AddSurfaceModels( mapDrawSurface_t *ds );
void FilterDrawsurfsIntoTree( entity_t *e, tree_t& tree );
void EmitPatchSurface( entity_t *e, mapDrawSurface_t *ds );
void EmitTriangleSurface( mapDrawSurface_t *ds );
/* surface_fur.c */
@ -1706,35 +1573,23 @@ void Foliage( mapDrawSurface_t *src );
/* ydnar: surface_meta.c */
void ClearMetaTriangles( void );
void ClearMetaTriangles();
void MakeEntityMetaTriangles( entity_t *e );
void FixMetaTJunctions( void );
void SmoothMetaTriangles( void );
void MergeMetaTriangles( void );
void FixMetaTJunctions();
void SmoothMetaTriangles();
void MergeMetaTriangles();
void EmitMetaStats(); // vortex: print meta statistics even in no-verbose mode
/* surface_extra.c */
void SetDefaultSampleSize( int sampleSize );
void SetSurfaceExtra( const mapDrawSurface_t& ds );
const shaderInfo_t *GetSurfaceExtraShaderInfo( int num );
int GetSurfaceExtraParentSurfaceNum( int num );
int GetSurfaceExtraEntityNum( int num );
int GetSurfaceExtraCastShadows( int num );
int GetSurfaceExtraRecvShadows( int num );
int GetSurfaceExtraSampleSize( int num );
int GetSurfaceExtraMinSampleSize( int num );
float GetSurfaceExtraLongestCurve( int num );
Vector3 GetSurfaceExtraLightmapAxis( int num );
void WriteSurfaceExtraFile( const char *path );
void LoadSurfaceExtraFile( const char *path );
/* decals.c */
void ProcessDecals( void );
void ProcessDecals();
void MakeEntityDecals( entity_t *e );
/* map.c */
@ -1743,28 +1598,16 @@ std::array<Vector3, 2> TextureAxisFromPlane( const plane_t& plane );
/* vis.c */
int VisMain( Args& args );
/* visflow.c */
int CountBits( const byte *bits, int numbits );
void PassageFlow( int portalnum );
void CreatePassages( int portalnum );
void PassageMemory( void );
void BasePortalVis( int portalnum );
void BetterPortalVis( int portalnum );
void PortalFlow( int portalnum );
void PassagePortalFlow( int portalnum );
/* light.c */
float PointToPolygonFormFactor( const Vector3& point, const Vector3& normal, const winding_t& w );
int LightContributionToSample( trace_t *trace );
void LightingAtSample( trace_t * trace, byte styles[ MAX_LIGHTMAPS ], Vector3 (&colors)[ MAX_LIGHTMAPS ] );
bool LightContributionToPoint( trace_t *trace );
int LightMain( Args& args );
/* light_trace.c */
void SetupTraceNodes( void );
void SetupTraceNodes();
void TraceLine( trace_t *trace );
float SetupTrace( trace_t *trace );
@ -1773,56 +1616,44 @@ float SetupTrace( trace_t *trace );
bool RadSampleImage( const byte * pixels, int width, int height, const Vector2& st, Color4f& color );
void RadLightForTriangles( int num, int lightmapNum, rawLightmap_t *lm, const shaderInfo_t *si, float scale, float subdivide, clipWork_t *cw );
void RadLightForPatch( int num, int lightmapNum, rawLightmap_t *lm, const shaderInfo_t *si, float scale, float subdivide, clipWork_t *cw );
void RadCreateDiffuseLights( void );
void RadCreateDiffuseLights();
/* light_ydnar.c */
Vector3b ColorToBytes( const Vector3& color, float scale );
void SmoothNormals( void );
void SmoothNormals();
void MapRawLightmap( int num );
void SetupDirt();
float DirtForSample( trace_t *trace );
void DirtyRawLightmap( int num );
void SetupFloodLight();
void FloodlightRawLightmaps();
void FloodlightIlluminateLightmap( rawLightmap_t *lm );
float FloodLightForSample( trace_t *trace, float floodLightDistance, bool floodLightLowQuality );
void FloodLightRawLightmap( int num );
void IlluminateRawLightmap( int num );
void IlluminateVertexes( int num );
void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all );
void SetupBrushes( void );
void SetupClusters( void );
void SetupBrushes();
bool ClusterVisible( int a, int b );
bool ClusterVisibleToPoint( const Vector3& point, int cluster );
int ClusterForPoint( const Vector3& point );
int ClusterForPointExt( const Vector3& point, float epsilon );
int ClusterForPointExtFilter( const Vector3& point, float epsilon, int numClusters, int *clusters );
int ShaderForPointInLeaf( const Vector3& point, int leafNum, float epsilon, int wantContentFlags, int wantSurfaceFlags, int *contentFlags, int *surfaceFlags );
void SetupEnvelopes( bool forGrid, bool fastFlag );
void FreeTraceLights( trace_t *trace );
void CreateTraceLightsForBounds( const MinMax& minmax, const Vector3 *normal, int numClusters, int *clusters, LightFlags flags, trace_t *trace );
void CreateTraceLightsForSurface( int num, trace_t *trace );
/* lightmaps_ydnar.c */
void ExportLightmaps( void );
void ExportLightmaps();
int ExportLightmapsMain( Args& args );
int ImportLightmapsMain( Args& args );
void SetupSurfaceLightmaps( void );
void StitchSurfaceLightmaps( void );
void SetupSurfaceLightmaps();
void StitchSurfaceLightmaps();
void StoreSurfaceLightmaps( bool fastAllocate );
/* exportents.c */
void ExportEntities( void );
int ExportEntitiesMain( Args& args );
@ -1834,11 +1665,6 @@ const image_t *ImageLoad( const char *name );
void ColorMod( colorMod_t *am, int numVerts, bspDrawVert_t *drawVerts );
void TCMod( const tcMod_t& mod, Vector2& st );
void TCModIdentity( tcMod_t& mod );
void TCModMultiply( const tcMod_t& a, const tcMod_t& b, tcMod_t& out );
void TCModTranslate( tcMod_t& mod, float s, float t );
void TCModScale( tcMod_t& mod, float s, float t );
void TCModRotate( tcMod_t& mod, float euler );
bool ApplySurfaceParm( const char *name, int *contentFlags, int *surfaceFlags, int *compileFlags );
const surfaceParm_t *GetSurfaceParm( const char *name );
@ -1859,11 +1685,11 @@ const surfaceParm_t &GetRequiredSurfaceParm( const TemplateString<chars.
}
void BeginMapShaderFile( const char *mapFile );
void WriteMapShaderFile( void );
void WriteMapShaderFile();
const shaderInfo_t *CustomShader( const shaderInfo_t *si, const char *find, char *replace );
void EmitVertexRemapShader( char *from, char *to );
void LoadShaderInfo( void );
void LoadShaderInfo();
shaderInfo_t *ShaderInfoForShader( const char *shader );
shaderInfo_t *ShaderInfoForShaderNull( const char *shader );
@ -1874,11 +1700,11 @@ void SwapBlock( int *block, int size );
void LoadBSPFile( const char *filename );
void LoadBSPFilePartially( const char *filename );
void WriteBSPFile( const char *filename );
void PrintBSPFileSizes( void );
void PrintBSPFileSizes();
void ParseEPair( std::list<epair_t>& epairs );
void ParseEntities( void );
void UnparseEntities( void );
void ParseEntities();
void UnparseEntities();
void PrintEntity( const entity_t *ent );
entity_t *FindTargetEntity( const char *target );
@ -1897,22 +1723,22 @@ void InjectCommandLine( const char *stage, const std::vec
inline shaderInfo_t *shaderInfo;
inline int numShaderInfo;
inline surfaceParm_t custSurfaceParms[ MAX_CUST_SURFACEPARMS ];
inline int numCustSurfaceParms;
inline String64 mapName; /* ydnar: per-map custom shaders for larger lightmaps */
inline CopiedString mapShaderFile;
inline bool warnImage = true;
/* ydnar: sinusoid samples */
inline float jitters[ MAX_JITTERS ];
/* can't code */
inline bool doingBSP;
// for .ase conversion
inline bool shadersAsBitmap;
inline bool lightmapsAsTexcoord;
/* general commandline arguments */
inline bool force;
inline int patchSubdivisions = 8; /* ydnar: -patchmeta subdivisions */
/* commandline arguments */
inline bool verboseEntities;
inline bool force;
inline bool useCustomInfoParms;
inline bool leaktest;
inline bool nodetail;
@ -1930,8 +1756,6 @@ inline bool bspAlternateSplitWeights; /* 27 */
inline bool deepBSP; /* div0 */
inline bool maxAreaFaceSurface; /* divVerent */
inline int patchSubdivisions = 8; /* ydnar: -patchmeta subdivisions */
inline int maxLMSurfaceVerts = 64; /* ydnar */
inline int maxSurfaceVerts = 999; /* ydnar */
inline int maxSurfaceIndexes = 6000; /* ydnar */
@ -1946,13 +1770,11 @@ inline bool debugInset;
inline bool debugPortals;
inline bool debugClip; /* debug model autoclipping */
inline float clipDepthGlobal = 2.0f;
inline bool lightmapTriangleCheck;
inline bool lightmapExtraVisClusterNudge;
inline bool lightmapFill;
inline bool lightmapPink;
inline int metaAdequateScore = -1;
inline int metaGoodScore = -1;
inline bool noob;
inline bool g_noob;
inline String64 globalCelShader;
inline bool keepLights;
#if Q3MAP2_EXPERIMENTAL_SNAP_NORMAL_FIX
// Increasing the normalEpsilon to compensate for new logic in SnapNormal(), where
@ -1998,7 +1820,6 @@ inline std::size_t mapEntityNum;
inline int entitySourceBrushes;
inline std::vector<plane_t> mapplanes; /* mapplanes[ num ^ 1 ] will always be the mirror or mapplanes[ num ] */ /* nummapplanes will always be even */
inline int numMapPatches;
inline MinMax g_mapMinmax;
inline const MinMax c_worldMinmax( Vector3( MIN_WORLD_COORD ), Vector3( MAX_WORLD_COORD ) );
@ -2010,8 +1831,6 @@ inline entity_t *mapEnt;
inline brush_t buildBrush;
inline EBrushType g_brushType = EBrushType::Undefined;
inline int numStrippedLights;
/* surface stuff */
inline mapDrawSurface_t *mapDrawSurfs;
@ -2049,44 +1868,6 @@ inline Matrix4 skyboxTransform;
/* -------------------------------------------------------------------------------
vis global variables
------------------------------------------------------------------------------- */
/* commandline arguments */
inline bool fastvis;
inline bool noPassageVis;
inline bool passageVisOnly;
inline bool mergevis;
inline bool mergevisportals;
inline bool nosort;
inline bool saveprt;
inline bool hint; /* ydnar */
inline String64 globalCelShader;
inline float farPlaneDist; /* rr2do2, rf, mre, ydnar all contributed to this one... */
inline int farPlaneDistMode;
inline int numportals;
inline int portalclusters;
inline vportal_t *portals;
inline leaf_t *leafs;
inline vportal_t *faces;
inline leaf_t *faceleafs;
inline int numfaces;
inline int leafbytes;
inline int portalbytes, portallongs;
inline vportal_t *sorted_portals[ MAX_MAP_PORTALS * 2 ];
/* -------------------------------------------------------------------------------
light global variables
@ -2098,12 +1879,11 @@ inline bool wolfLight;
inline float extraDist;
inline bool loMem;
inline bool noStyles;
inline bool keepLights;
//inline int sampleSize = DEFAULT_LIGHTMAP_SAMPLE_SIZE;
//inline int minSampleSize = DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE;
inline float noVertexLighting;
inline bool nolm;
inline bool noLightmaps;
inline bool noGridLighting;
inline bool noTrace;
@ -2147,6 +1927,11 @@ inline int lmCustomSizeH = LIGHTMAP_WIDTH;
inline const char * lmCustomDir;
inline int lmLimitSize;
inline bool lightmapTriangleCheck;
inline bool lightmapExtraVisClusterNudge;
inline bool lightmapFill;
inline bool lightmapPink;
inline bool dirty;
inline bool dirtDebug;
inline int dirtMode;
@ -2169,8 +1954,7 @@ inline bool debugAxis;
inline bool debugCluster;
inline bool debugOrigin;
inline bool lightmapBorder;
//1=warn; 0=warn if lmsize>128
inline int debugSampleSize;
inline int debugSampleSize; // 1=warn; 0=warn if lmsize>128
/* for run time tweaking of light sources */
inline float pointScale = 7500.0f;
@ -2206,13 +1990,9 @@ inline float g_lightmapSaturation = 1;
/* ydnar: for runtime tweaking of falloff tolerance */
inline float falloffTolerance = 1.0f;
inline bool exactPointToPolygon = true;
inline float formFactorValueScale = 3.0f;
inline float linearScale = 1.0f / 8000.0f;
// for .ase conversion
inline bool shadersAsBitmap;
inline bool lightmapsAsTexcoord;
inline const bool exactPointToPolygon = true;
inline const float formFactorValueScale = 3.0f;
inline const float linearScale = 1.0f / 8000.0f;
inline std::list<light_t> lights;
inline int numPointLights;
@ -2228,11 +2008,14 @@ inline int numDiffuseLights;
inline int numBrushDiffuseLights;
inline int numTriangleDiffuseLights;
inline int numPatchDiffuseLights;
inline const float diffuseSubdivide = 256.0f;
inline const float minDiffuseSubdivide = 64.0f;
inline int numDiffuseSurfaces;
/* ydnar: general purpose extra copy of drawvert list */
inline std::vector<bspDrawVert_t> yDrawVerts;
inline int defaultLightSubdivide = 999;
inline const int defaultLightSubdivide = 999;
inline Vector3 ambientColor;
inline Vector3 minLight, minVertexLight, minGridLight;
@ -2244,8 +2027,6 @@ inline float subdivideThreshold = DEFAULT_SUBDIVIDE_THRESHOLD;
inline int maxOpaqueBrush;
inline std::vector<std::uint8_t> opaqueBrushes;
inline int numCulledLights;
inline int gridBoundsCulled;
inline int gridEnvelopeCulled;
@ -2254,17 +2035,9 @@ inline int lightsEnvelopeCulled;
inline int lightsPlaneCulled;
inline int lightsClusterCulled;
/* ydnar: radiosity */
inline float diffuseSubdivide = 256.0f;
inline float minDiffuseSubdivide = 64.0f;
inline int numDiffuseSurfaces;
/* ydnar: list of surface information necessary for lightmap calculation */
inline surfaceInfo_t *surfaceInfos;
/* ydnar: sorted list of surfaces */
inline int *sortSurfaces;
/* clumps of surfaces that share a raw lightmap */
inline int numLightSurfaces;
inline int *lightSurfaces;
@ -2293,21 +2066,9 @@ inline int numBSPLightmaps;
inline int numExtLightmaps;
inline outLightmap_t *outLightmaps;
/* vortex: per surface floodlight statistics */
inline int numSurfacesFloodlighten;
/* grid points */
inline std::vector<rawGridPoint_t> rawGridPoints;
inline int numSurfsVertexLit;
inline int numSurfsVertexForced;
inline int numSurfsVertexApproximated;
inline int numSurfsLightmapped;
inline int numPlanarsLightmapped;
inline int numNonPlanarsLightmapped;
inline int numPatchesLightmapped;
inline int numPlanarPatchesLightmapped;
inline int numLuxels;
inline int numLuxelsMapped;
inline int numLuxelsOccluded;

View File

@ -33,6 +33,12 @@
#include "shaders.h"
static bool g_warnImage = true;
static surfaceParm_t custSurfaceParms[ 256 ];
static int numCustSurfaceParms;
/*
ColorMod()
@ -153,14 +159,14 @@ void TCMod( const tcMod_t& mod, Vector2& st ){
}
void TCModIdentity( tcMod_t& mod ){
static void TCModIdentity( tcMod_t& mod ){
mod[ 0 ][ 0 ] = 1.0f; mod[ 0 ][ 1 ] = 0.0f; mod[ 0 ][ 2 ] = 0.0f;
mod[ 1 ][ 0 ] = 0.0f; mod[ 1 ][ 1 ] = 1.0f; mod[ 1 ][ 2 ] = 0.0f;
mod[ 2 ][ 0 ] = 0.0f; mod[ 2 ][ 1 ] = 0.0f; mod[ 2 ][ 2 ] = 1.0f; /* this row is only used for multiples, not transformation */
}
void TCModMultiply( const tcMod_t& a, const tcMod_t& b, tcMod_t& out ){
static void TCModMultiply( const tcMod_t& a, const tcMod_t& b, tcMod_t& out ){
for ( int i = 0; i < 3; i++ )
{
out[ i ][ 0 ] = ( a[ i ][ 0 ] * b[ 0 ][ 0 ] ) + ( a[ i ][ 1 ] * b[ 1 ][ 0 ] ) + ( a[ i ][ 2 ] * b[ 2 ][ 0 ] );
@ -170,19 +176,19 @@ void TCModMultiply( const tcMod_t& a, const tcMod_t& b, tcMod_t& out ){
}
void TCModTranslate( tcMod_t& mod, float s, float t ){
static void TCModTranslate( tcMod_t& mod, float s, float t ){
mod[ 0 ][ 2 ] += s;
mod[ 1 ][ 2 ] += t;
}
void TCModScale( tcMod_t& mod, float s, float t ){
static void TCModScale( tcMod_t& mod, float s, float t ){
mod[ 0 ][ 0 ] *= s;
mod[ 1 ][ 1 ] *= t;
}
void TCModRotate( tcMod_t& mod, float euler ){
static void TCModRotate( tcMod_t& mod, float euler ){
tcMod_t old, temp;
float radians, sinv, cosv;
@ -269,7 +275,7 @@ void BeginMapShaderFile( const char *mapFile ){
remove( mapShaderFile.c_str() );
/* stop making warnings about missing images */
warnImage = false;
g_warnImage = false;
}
@ -279,7 +285,7 @@ void BeginMapShaderFile( const char *mapFile ){
writes a shader to the map shader script
*/
void WriteMapShaderFile( void ){
void WriteMapShaderFile(){
/* dummy check */
if ( mapShaderFile.empty() ) {
return;
@ -531,7 +537,7 @@ void EmitVertexRemapShader( char *from, char *to ){
allocates and initializes a new shader
*/
static shaderInfo_t *AllocShaderInfo( void ){
static shaderInfo_t *AllocShaderInfo(){
shaderInfo_t *si;
@ -592,7 +598,7 @@ static shaderInfo_t *AllocShaderInfo( void ){
sets a shader's width and height among other things
*/
void FinishShader( shaderInfo_t *si ){
static void FinishShader( shaderInfo_t *si ){
int x, y;
Vector2 st;
@ -636,7 +642,7 @@ void FinishShader( shaderInfo_t *si ){
}
}
if( noob && !( si->compileFlags & C_OB ) ){
if( g_noob && !( si->compileFlags & C_OB ) ){
ApplySurfaceParm( "noob", nullptr, &si->surfaceFlags, nullptr );
}
@ -681,7 +687,7 @@ static void LoadShaderImages( shaderInfo_t *si ){
/* otherwise, use default image */
if ( si->shaderImage == NULL ) {
si->shaderImage = ImageLoad( DEFAULT_IMAGE );
if ( warnImage && !strEqual( si->shader, "noshader" ) ) {
if ( g_warnImage && !strEqual( si->shader, "noshader" ) ) {
Sys_Warning( "Couldn't find image for shader %s\n", si->shader.c_str() );
}
}
@ -1136,17 +1142,12 @@ static void ParseShaderFile( const char *filename ){
else if ( striEqualPrefix( token, "q3map_" ) ) {
/* ydnar: q3map_baseShader <shader> (inherit this shader's parameters) */
if ( striEqual( token, "q3map_baseShader" ) ) {
shaderInfo_t *si2;
bool oldWarnImage;
/* get shader */
text.GetToken( false );
//% Sys_FPrintf( SYS_VRB, "Shader %s has base shader %s\n", si->shader, token );
oldWarnImage = warnImage;
warnImage = false;
si2 = ShaderInfoForShader( token );
warnImage = oldWarnImage;
const bool oldWarnImage = std::exchange( g_warnImage, false );
shaderInfo_t *si2 = ShaderInfoForShader( token );
g_warnImage = oldWarnImage;
/* subclass it */
if ( si2 != NULL ) {
@ -1772,7 +1773,7 @@ static void ParseShaderFile( const char *filename ){
loads custom info parms file for mods
*/
static void ParseCustomInfoParms( void ){
static void ParseCustomInfoParms(){
/* file exists? */
if ( vfsGetFileCount( "scripts/custinfoparms.txt" ) == 0 ) {
return;
@ -1829,7 +1830,7 @@ static void ParseCustomInfoParms( void ){
on linux there's an additional twist, we actually merge the stuff from ~/.q3a/ and from the base dir
*/
void LoadShaderInfo( void ){
void LoadShaderInfo(){
std::vector<CopiedString> shaderFiles;

View File

@ -18,13 +18,7 @@
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
----------------------------------------------------------------------------------
This code has been altered significantly from its original form, to support
several games based on the Quake III Arena engine, in the form of "Q3Map2."
------------------------------------------------------------------------------- */
*/
#pragma once

View File

@ -63,8 +63,9 @@ mapDrawSurface_t *AllocDrawSurface( ESurfaceType type ){
FinishSurface()
ydnar: general surface finish pass
*/
static mapDrawSurface_t *MakeCelSurface( mapDrawSurface_t *src, shaderInfo_t *si );
void FinishSurface( mapDrawSurface_t *ds ){
static void FinishSurface( mapDrawSurface_t *ds ){
mapDrawSurface_t *ds2;
@ -149,7 +150,7 @@ mapDrawSurface_t *CloneSurface( mapDrawSurface_t *src, shaderInfo_t *si ){
makes a copy of a surface, but specific to cel shading
*/
mapDrawSurface_t *MakeCelSurface( mapDrawSurface_t *src, shaderInfo_t *si ){
static mapDrawSurface_t *MakeCelSurface( mapDrawSurface_t *src, shaderInfo_t *si ){
/* dummy check */
if ( src == NULL || si == NULL ) {
return NULL;
@ -183,7 +184,7 @@ mapDrawSurface_t *MakeCelSurface( mapDrawSurface_t *src, shaderInfo_t *si ){
generates a skybox surface, viewable from everywhere there is sky
*/
mapDrawSurface_t *MakeSkyboxSurface( mapDrawSurface_t *src ){
static mapDrawSurface_t *MakeSkyboxSurface( mapDrawSurface_t *src ){
/* dummy check */
if ( src == NULL ) {
return NULL;
@ -491,7 +492,7 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ){
----------------------------------------------------------------- */
/* vertex lit surfaces don't need this information */
if ( si->compileFlags & C_VERTEXLIT || ds->type == ESurfaceType::Triangles || nolm ) {
if ( si->compileFlags & C_VERTEXLIT || ds->type == ESurfaceType::Triangles || noLightmaps ) {
ds->lightmapAxis.set( 0 );
//% ds->lightmapVecs[ 2 ].set( 0 );
ds->sampleSize = 0;
@ -588,7 +589,7 @@ void ClassifyEntitySurfaces( entity_t *e ){
for shader-indexed surfaces (terrain), find a matching index from the indexmap
*/
byte GetShaderIndexForPoint( const indexMap_t *im, const MinMax& eMinmax, const Vector3& point ){
static byte GetShaderIndexForPoint( const indexMap_t *im, const MinMax& eMinmax, const Vector3& point ){
/* early out if no indexmap */
if ( im == NULL ) {
return 0;
@ -637,7 +638,7 @@ byte GetShaderIndexForPoint( const indexMap_t *im, const MinMax& eMinmax, const
this combines a couple different functions from terrain.c
*/
shaderInfo_t *GetIndexedShader( const shaderInfo_t *parent, const indexMap_t *im, int numPoints, byte *shaderIndexes ){
static shaderInfo_t *GetIndexedShader( const shaderInfo_t *parent, const indexMap_t *im, int numPoints, byte *shaderIndexes ){
/* early out if bad data */
if ( im == NULL || numPoints <= 0 || shaderIndexes == NULL ) {
return ShaderInfoForShader( "default" );
@ -709,6 +710,8 @@ shaderInfo_t *GetIndexedShader( const shaderInfo_t *parent, const indexMap_t *im
const double SNAP_FLOAT_TO_INT = 8.0;
const double SNAP_INT_TO_FLOAT = ( 1.0 / SNAP_FLOAT_TO_INT );
static mapDrawSurface_t *DrawSurfaceForShader( const char *shader );
mapDrawSurface_t *DrawSurfaceForSide( const entity_t *e, const brush_t& b, const side_t& s, const winding_t& w ){
mapDrawSurface_t *ds;
shaderInfo_t *si, *parent;
@ -1086,7 +1089,7 @@ mapDrawSurface_t *DrawSurfaceForFlare( int entNum, const Vector3& origin, const
creates a bogus surface to forcing the game to load a shader
*/
mapDrawSurface_t *DrawSurfaceForShader( const char *shader ){
static mapDrawSurface_t *DrawSurfaceForShader( const char *shader ){
/* get shader */
shaderInfo_t *si = ShaderInfoForShader( shader );
@ -1261,7 +1264,7 @@ void SubdivideFaceSurfaces( entity_t *e ){
====================
*/
void ClipSideIntoTree_r( const winding_t& w, side_t& side, const node_t *node ){
static void ClipSideIntoTree_r( const winding_t& w, side_t& side, const node_t *node ){
if ( w.empty() ) {
return;
}
@ -1312,7 +1315,7 @@ static int g_numHiddenFaces, g_numCoinFaces;
determines if a brushside lies inside another brush
*/
bool SideInBrush( side_t& side, const brush_t& b ){
static bool SideInBrush( side_t& side, const brush_t& b ){
/* ignore sides w/o windings or shaders */
if ( side.winding.empty() || side.shaderInfo == NULL ) {
return true;
@ -1358,7 +1361,7 @@ bool SideInBrush( side_t& side, const brush_t& b ){
culls obscured or buried brushsides from the map
*/
void CullSides( entity_t *e ){
static void CullSides( entity_t *e ){
int k, l, first, second, dir;
@ -1610,7 +1613,7 @@ void ClipSidesIntoTree( entity_t *e, const tree_t& tree ){
adds a reference to surface ds in the bsp leaf node
*/
int AddReferenceToLeaf( mapDrawSurface_t *ds, node_t *node ){
static int AddReferenceToLeaf( mapDrawSurface_t *ds, node_t *node ){
drawSurfRef_t *dsr;
const int numBSPDrawSurfaces = bspDrawSurfaces.size();
@ -1653,7 +1656,7 @@ int AddReferenceToLeaf( mapDrawSurface_t *ds, node_t *node ){
adds a reference to the specified drawsurface to every leaf in the tree
*/
int AddReferenceToTree_r( mapDrawSurface_t *ds, node_t *node, bool skybox ){
static int AddReferenceToTree_r( mapDrawSurface_t *ds, node_t *node, bool skybox ){
int refs = 0;
@ -1693,7 +1696,7 @@ int AddReferenceToTree_r( mapDrawSurface_t *ds, node_t *node, bool skybox ){
filters a single point from a surface into the tree
*/
int FilterPointIntoTree_r( const Vector3& point, mapDrawSurface_t *ds, node_t *node ){
static int FilterPointIntoTree_r( const Vector3& point, mapDrawSurface_t *ds, node_t *node ){
float d;
int refs = 0;
@ -1725,7 +1728,7 @@ int FilterPointIntoTree_r( const Vector3& point, mapDrawSurface_t *ds, node_t *n
filters the convex hull of multiple points from a surface into the tree
*/
int FilterPointConvexHullIntoTree_r( Vector3 *points[], const int npoints, mapDrawSurface_t *ds, node_t *node ){
static int FilterPointConvexHullIntoTree_r( Vector3 *points[], const int npoints, mapDrawSurface_t *ds, node_t *node ){
if ( !points ) {
return 0;
}
@ -1767,7 +1770,7 @@ int FilterPointConvexHullIntoTree_r( Vector3 *points[], const int npoints, mapDr
filters a winding from a drawsurface into the tree
*/
int FilterWindingIntoTree_r( winding_t& w, mapDrawSurface_t *ds, node_t *node ){
static int FilterWindingIntoTree_r( winding_t& w, mapDrawSurface_t *ds, node_t *node ){
int refs = 0;
/* get shaderinfo */
@ -1874,7 +1877,7 @@ int FilterWindingIntoTree_r( winding_t& w, mapDrawSurface_t *ds, node_t *node ){
filters a planar winding face drawsurface into the bsp tree
*/
int FilterFaceIntoTree( mapDrawSurface_t *ds, tree_t& tree ){
static int FilterFaceIntoTree( mapDrawSurface_t *ds, tree_t& tree ){
/* make a winding and filter it into the tree */
winding_t w = WindingFromDrawSurf( ds );
int refs = FilterWindingIntoTree_r( w, ds, tree.headnode );
@ -2013,7 +2016,7 @@ static int FilterFlareSurfIntoTree( mapDrawSurface_t *ds, tree_t& tree ){
emits bsp drawverts from a map drawsurface
*/
void EmitDrawVerts( const mapDrawSurface_t *ds, bspDrawSurface_t& out ){
static void EmitDrawVerts( const mapDrawSurface_t *ds, bspDrawSurface_t& out ){
/* get stuff */
const float offset = ds->shaderInfo->offset;
@ -2054,7 +2057,7 @@ void EmitDrawVerts( const mapDrawSurface_t *ds, bspDrawSurface_t& out ){
returns numIndexes + 1 if the search failed
*/
int FindDrawIndexes( int numIndexes, const int *indexes ){
static int FindDrawIndexes( int numIndexes, const int *indexes ){
int i, j, numTestIndexes;
const int numBSPDrawIndexes = bspDrawIndexes.size();
@ -2123,7 +2126,7 @@ int FindDrawIndexes( int numIndexes, const int *indexes ){
attempts to find an existing run of drawindexes before adding new ones
*/
void EmitDrawIndexes( const mapDrawSurface_t *ds, bspDrawSurface_t& out ){
static void EmitDrawIndexes( const mapDrawSurface_t *ds, bspDrawSurface_t& out ){
/* attempt to use redundant indexing */
out.firstIndex = FindDrawIndexes( ds->numIndexes, ds->indexes );
out.numIndexes = ds->numIndexes;
@ -2156,7 +2159,7 @@ void EmitDrawIndexes( const mapDrawSurface_t *ds, bspDrawSurface_t& out ){
emits a bsp flare drawsurface
*/
void EmitFlareSurface( mapDrawSurface_t *ds ){
static void EmitFlareSurface( mapDrawSurface_t *ds ){
/* ydnar: nuking useless flare drawsurfaces */
if ( !emitFlares && ds->type != ESurfaceType::Shader ) {
return;
@ -2195,7 +2198,7 @@ void EmitFlareSurface( mapDrawSurface_t *ds ){
emits a bsp patch drawsurface
*/
void EmitPatchSurface( entity_t *e, mapDrawSurface_t *ds ){
static void EmitPatchSurface( entity_t *e, mapDrawSurface_t *ds ){
/* vortex: _patchMeta support */
const bool forcePatchMeta = e->boolForKey( "_patchMeta", "patchMeta" );
@ -2403,7 +2406,7 @@ static void OptimizeTriangleSurface( mapDrawSurface_t *ds ){
creates a bsp drawsurface from arbitrary triangle surfaces
*/
void EmitTriangleSurface( mapDrawSurface_t *ds ){
static void EmitTriangleSurface( mapDrawSurface_t *ds ){
int i, temp;
/* invert the surface if necessary */
@ -2693,7 +2696,7 @@ void MakeFogHullSurfs( entity_t *e, const char *shader ){
biases a surface's texcoords as close to 0 as possible
*/
void BiasSurfaceTextures( mapDrawSurface_t *ds ){
static void BiasSurfaceTextures( mapDrawSurface_t *ds ){
/* don't bias globaltextured shaders */
if ( ds->shaderInfo->globalTexture ) {
return;
@ -2716,7 +2719,7 @@ void BiasSurfaceTextures( mapDrawSurface_t *ds ){
adds models to a specified triangle, returns the number of models added
*/
int AddSurfaceModelsToTriangle_r( mapDrawSurface_t *ds, const surfaceModel_t& model, bspDrawVert_t **tri ){
static int AddSurfaceModelsToTriangle_r( mapDrawSurface_t *ds, const surfaceModel_t& model, bspDrawVert_t **tri ){
bspDrawVert_t mid, *tri2[ 3 ];
int max, n, localNumSurfaceModels;
@ -2847,7 +2850,7 @@ int AddSurfaceModelsToTriangle_r( mapDrawSurface_t *ds, const surfaceModel_t& mo
adds a surface's shader models to the surface
*/
int AddSurfaceModels( mapDrawSurface_t *ds ){
static int AddSurfaceModels( mapDrawSurface_t *ds ){
int i, x, y, n, pw[ 5 ], r, localNumSurfaceModels, iterations;
mesh_t src, *mesh, *subdivided;
bspDrawVert_t centroid, *tri[ 3 ];

View File

@ -30,7 +30,7 @@
/* dependencies */
#include "q3map2.h"
#include "surface_extra.h"
/* -------------------------------------------------------------------------------
@ -39,24 +39,13 @@
------------------------------------------------------------------------------- */
struct surfaceExtra_t
{
const mapDrawSurface_t *mds;
const shaderInfo_t *si;
int parentSurfaceNum;
int entityNum;
int castShadows, recvShadows;
int sampleSize;
float longestCurve;
Vector3 lightmapAxis;
};
#define GROW_SURFACE_EXTRAS 1024
int numSurfaceExtras = 0;
int maxSurfaceExtras = 0;
surfaceExtra_t *surfaceExtras;
surfaceExtra_t seDefault = { NULL, NULL, -1, 0, WORLDSPAWN_CAST_SHADOWS, WORLDSPAWN_RECV_SHADOWS, 0, 0, { 0, 0, 0 } };
static int numSurfaceExtras = 0;
static int maxSurfaceExtras = 0;
static surfaceExtra_t *surfaceExtras;
static surfaceExtra_t seDefault;
@ -65,14 +54,13 @@ surfaceExtra_t seDefault = { NULL, NULL, -1, 0, WORLDSPAWN_CAST_SHADOWS, WORLDSP
allocates a new extra storage
*/
static surfaceExtra_t *AllocSurfaceExtra( void ){
static surfaceExtra_t& AllocSurfaceExtra(){
/* enough space? */
AUTOEXPAND_BY_REALLOC_ADD( surfaceExtras, numSurfaceExtras, maxSurfaceExtras, GROW_SURFACE_EXTRAS );
/* add another */
surfaceExtra_t *se = &surfaceExtras[ numSurfaceExtras ];
numSurfaceExtras++;
memcpy( se, &seDefault, sizeof( surfaceExtra_t ) );
surfaceExtra_t& se = surfaceExtras[ numSurfaceExtras++ ];
se = seDefault;
/* return it */
return se;
@ -98,18 +86,18 @@ void SetDefaultSampleSize( int sampleSize ){
void SetSurfaceExtra( const mapDrawSurface_t& ds ){
/* get a new extra */
surfaceExtra_t *se = AllocSurfaceExtra();
surfaceExtra_t& se = AllocSurfaceExtra();
/* copy out the relevant bits */
se->mds = &ds;
se->si = ds.shaderInfo;
se->parentSurfaceNum = ds.parent != NULL ? ds.parent->outputNum : -1;
se->entityNum = ds.entityNum;
se->castShadows = ds.castShadows;
se->recvShadows = ds.recvShadows;
se->sampleSize = ds.sampleSize;
se->longestCurve = ds.longestCurve;
se->lightmapAxis = ds.lightmapAxis;
se.mds = &ds;
se.si = ds.shaderInfo;
se.parentSurfaceNum = ds.parent != NULL ? ds.parent->outputNum : -1;
se.entityNum = ds.entityNum;
se.castShadows = ds.castShadows;
se.recvShadows = ds.recvShadows;
se.sampleSize = ds.sampleSize;
se.longestCurve = ds.longestCurve;
se.lightmapAxis = ds.lightmapAxis;
/* debug code */
//% Sys_FPrintf( SYS_VRB, "SetSurfaceExtra(): entityNum = %d\n", ds.entityNum );
@ -122,55 +110,14 @@ void SetSurfaceExtra( const mapDrawSurface_t& ds ){
getter functions for extra surface data
*/
static surfaceExtra_t *GetSurfaceExtra( int num ){
const surfaceExtra_t& GetSurfaceExtra( int num ){
if ( num < 0 || num >= numSurfaceExtras ) {
return &seDefault;
return seDefault;
}
return &surfaceExtras[ num ];
return surfaceExtras[ num ];
}
const shaderInfo_t *GetSurfaceExtraShaderInfo( int num ){
return GetSurfaceExtra( num )->si;
}
int GetSurfaceExtraParentSurfaceNum( int num ){
return GetSurfaceExtra( num )->parentSurfaceNum;
}
int GetSurfaceExtraEntityNum( int num ){
return GetSurfaceExtra( num )->entityNum;
}
int GetSurfaceExtraCastShadows( int num ){
return GetSurfaceExtra( num )->castShadows;
}
int GetSurfaceExtraRecvShadows( int num ){
return GetSurfaceExtra( num )->recvShadows;
}
int GetSurfaceExtraSampleSize( int num ){
return GetSurfaceExtra( num )->sampleSize;
}
float GetSurfaceExtraLongestCurve( int num ){
return GetSurfaceExtra( num )->longestCurve;
}
Vector3 GetSurfaceExtraLightmapAxis( int num ){
return GetSurfaceExtra( num )->lightmapAxis;
}
/*
WriteSurfaceExtraFile()
@ -178,9 +125,6 @@ Vector3 GetSurfaceExtraLightmapAxis( int num ){
*/
void WriteSurfaceExtraFile( const char *path ){
surfaceExtra_t *se;
int i;
/* dummy check */
if ( strEmptyOrNull( path ) ) {
return;
@ -195,10 +139,10 @@ void WriteSurfaceExtraFile( const char *path ){
FILE *sf = SafeOpenWrite( srfPath, "wt" );
/* lap through the extras list */
for ( i = -1; i < numSurfaceExtras; i++ )
for ( int i = -1; i < numSurfaceExtras; i++ )
{
/* get extra */
se = GetSurfaceExtra( i );
const surfaceExtra_t *se = &GetSurfaceExtra( i );
/* default or surface num? */
if ( i < 0 ) {
@ -309,7 +253,7 @@ void LoadSurfaceExtraFile( const char *path ){
Error( "ReadSurfaceExtraFile(): %s, line %d: bogus surface num %d", srfPath.c_str(), scriptline, surfaceNum );
}
while ( surfaceNum >= numSurfaceExtras )
se = AllocSurfaceExtra();
AllocSurfaceExtra();
se = &surfaceExtras[ surfaceNum ];
}

View File

@ -0,0 +1,39 @@
/* -------------------------------------------------------------------------------
Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
struct surfaceExtra_t
{
const mapDrawSurface_t *mds = nullptr;
const shaderInfo_t *si = nullptr;
int parentSurfaceNum = -1;
int entityNum = 0;
int castShadows = WORLDSPAWN_CAST_SHADOWS;
int recvShadows = WORLDSPAWN_RECV_SHADOWS;
int sampleSize = 0;
float longestCurve = 0;
Vector3 lightmapAxis{ 0, 0, 0 };
};
const surfaceExtra_t& GetSurfaceExtra( int num );

View File

@ -95,7 +95,7 @@ static std::list<metaTriangle_t> metaTriangles;
called before staring a new entity to clear out the triangle list
*/
void ClearMetaTriangles( void ){
void ClearMetaTriangles(){
metaVerts.clear();
metaTriangles.clear();
}
@ -340,7 +340,7 @@ static void SurfaceToMetaTriangles( mapDrawSurface_t *ds ){
creates triangles from a patch
*/
void TriangulatePatchSurface( entity_t *e, mapDrawSurface_t *ds ){
static void TriangulatePatchSurface( entity_t *e, mapDrawSurface_t *ds ){
int x, y, pw[ 5 ], r;
mapDrawSurface_t *dsNew;
mesh_t src, *subdivided, *mesh;
@ -436,7 +436,7 @@ void TriangulatePatchSurface( entity_t *e, mapDrawSurface_t *ds ){
#define TINY_AREA 1.0f
#define MAXAREA_MAXTRIES 8
int MaxAreaIndexes( bspDrawVert_t *vert, int cnt, int *indexes ){
static int MaxAreaIndexes( bspDrawVert_t *vert, int cnt, int *indexes ){
int r, s, t, bestR = 0, bestS = 1, bestT = 2;
int i, j;
double A, bestA = -1, V, bestV = -1;
@ -645,7 +645,7 @@ void MaxAreaFaceSurface( mapDrawSurface_t *ds ){
loosely based on SurfaceAsTriFan()
*/
void FanFaceSurface( mapDrawSurface_t *ds ){
static void FanFaceSurface( mapDrawSurface_t *ds ){
int i, k, a, b, c;
Color4f color[ MAX_LIGHTMAPS ];
for ( auto& co : color )
@ -952,7 +952,7 @@ struct edge_t
Plane3f plane;
};
void CreateEdge( const Plane3f& plane, const Vector3& a, const Vector3& b, edge_t *edge ){
static void CreateEdge( const Plane3f& plane, const Vector3& a, const Vector3& b, edge_t *edge ){
/* copy edge origin */
edge->origin = a;
@ -982,7 +982,7 @@ void CreateEdge( const Plane3f& plane, const Vector3& a, const Vector3& b, edge_
#define TJ_EDGE_EPSILON ( 1.0f / 8.0f )
#define TJ_POINT_EPSILON ( 1.0f / 8.0f )
void FixMetaTJunctions( void ){
void FixMetaTJunctions(){
#if 0
int i, j, k, f, fOld, start, vertIndex, triIndex, numTJuncs;
metaTriangle_t *tri, *newTri;
@ -1156,7 +1156,7 @@ void FixMetaTJunctions( void ){
#define THETA_EPSILON 0.000001
#define EQUAL_NORMAL_EPSILON 0.01f
void SmoothMetaTriangles( void ){
void SmoothMetaTriangles(){
const double start = I_FloatTime();
int numSmoothed = 0;
@ -1284,7 +1284,7 @@ int>; // index of bspDrawVert_t in mapDrawSurface_t::verts array
returns the index of that vert (or < 0 on failure)
*/
int AddMetaVertToSurface( mapDrawSurface_t *ds, const bspDrawVert_t& dv1, const Sorted_indices& sorted_indices, int *coincident ){
static int AddMetaVertToSurface( mapDrawSurface_t *ds, const bspDrawVert_t& dv1, const Sorted_indices& sorted_indices, int *coincident ){
/* go through the verts and find a suitable candidate */
const auto begin = sorted_indices.lower_bound( spatial_distance( dv1.xyz ) - c_spatial_EQUAL_EPSILON );
const auto end = sorted_indices.upper_bound( spatial_distance( dv1.xyz ) + c_spatial_EQUAL_EPSILON );
@ -1663,7 +1663,7 @@ static void MetaTrianglesToSurface( int *fOld, int *numAdded ){
merges meta triangles into drawsurfaces
*/
void MergeMetaTriangles( void ){
void MergeMetaTriangles(){
/* only do this if there are meta triangles */
if ( metaTriangles.empty() ) {
return;

View File

@ -61,20 +61,24 @@ struct originalEdge_t
bspDrawVert_t *dv[2];
};
originalEdge_t *originalEdges = NULL;
namespace
{
originalEdge_t *originalEdges;
int numOriginalEdges;
int allocatedOriginalEdges = 0;
int allocatedOriginalEdges;
edgeLine_t *edgeLines = NULL;
edgeLine_t *edgeLines;
int numEdgeLines;
int allocatedEdgeLines = 0;
int allocatedEdgeLines;
int c_degenerateEdges;
int c_addedVerts;
int c_totalVerts;
int c_natural, c_rotate, c_cant;
int c_broken;
}
// these should be whatever epsilon we actually expect,
// plus SNAP_INT_TO_FLOAT
@ -86,7 +90,7 @@ int c_natural, c_rotate, c_cant;
InsertPointOnEdge
====================
*/
void InsertPointOnEdge( const Vector3 &v, edgeLine_t *e ) {
static void InsertPointOnEdge( const Vector3 &v, edgeLine_t *e ) {
edgePoint_t *p, *scan;
p = safe_malloc( sizeof( edgePoint_t ) );
@ -129,7 +133,7 @@ void InsertPointOnEdge( const Vector3 &v, edgeLine_t *e ) {
AddEdge
====================
*/
int AddEdge( bspDrawVert_t& dv1, bspDrawVert_t& dv2, bool createNonAxial ) {
static int AddEdge( bspDrawVert_t& dv1, bspDrawVert_t& dv2, bool createNonAxial ) {
int i;
edgeLine_t *e;
float d;
@ -201,7 +205,7 @@ int AddEdge( bspDrawVert_t& dv1, bspDrawVert_t& dv2, bool createNonAxial ) {
adds a surface's edges
*/
void AddSurfaceEdges( mapDrawSurface_t& ds ){
static void AddSurfaceEdges( mapDrawSurface_t& ds ){
for ( int i = 0; i < ds.numVerts; i++ )
{
/* save the edge number in the lightmap field so we don't need to look it up again */
@ -217,7 +221,7 @@ void AddSurfaceEdges( mapDrawSurface_t& ds ){
determines if an edge is colinear
*/
bool ColinearEdge( const Vector3& v1, const Vector3& v2, const Vector3& v3 ){
static bool ColinearEdge( const Vector3& v1, const Vector3& v2, const Vector3& v3 ){
Vector3 midpoint, dir, offset, on;
float d;
@ -249,7 +253,7 @@ bool ColinearEdge( const Vector3& v1, const Vector3& v2, const Vector3& v3 ){
brush tjunctions
====================
*/
void AddPatchEdges( mapDrawSurface_t& ds ) {
static void AddPatchEdges( mapDrawSurface_t& ds ) {
for ( int i = 0; i < ds.patchWidth - 2; i += 2 ) {
{
bspDrawVert_t& v1 = ds.verts[ i + 0 ];
@ -304,7 +308,7 @@ void AddPatchEdges( mapDrawSurface_t& ds ) {
====================
*/
#define MAX_SURFACE_VERTS 256
void FixSurfaceJunctions( mapDrawSurface_t& ds ) {
static void FixSurfaceJunctions( mapDrawSurface_t& ds ) {
int i, j, k;
edgeLine_t *e;
edgePoint_t *p;
@ -480,9 +484,7 @@ void FixSurfaceJunctions( mapDrawSurface_t& ds ) {
#define DEGENERATE_EPSILON 0.1
int c_broken = 0;
bool FixBrokenSurface( mapDrawSurface_t& ds ){
static bool FixBrokenSurface( mapDrawSurface_t& ds ){
/* dummy check */
if ( ds.type != ESurfaceType::Face ) {
return false;

View File

@ -34,9 +34,7 @@
void RemovePortalFromNode( portal_t *portal, node_t *l );
node_t *NodeForPoint( node_t *node, const Vector3& origin ){
static node_t *NodeForPoint( node_t *node, const Vector3& origin ){
while ( node->planenum != PLANENUM_LEAF )
{
if ( plane3_distance_to_point( mapplanes[node->planenum].plane, origin ) >= 0 ) {
@ -57,7 +55,7 @@ node_t *NodeForPoint( node_t *node, const Vector3& origin ){
FreeTreePortals_r
=============
*/
void FreeTreePortals_r( node_t *node ){
static void FreeTreePortals_r( node_t *node ){
portal_t *p, *nextp;
int s;
@ -84,7 +82,7 @@ void FreeTreePortals_r( node_t *node ){
FreeTree_r
=============
*/
void FreeTree_r( node_t *node ){
static void FreeTree_r( node_t *node ){
// free children
if ( node->planenum != PLANENUM_LEAF ) {
FreeTree_r( node->children[0] );
@ -108,7 +106,7 @@ void FreeTree( tree_t& tree ){
//===============================================================
void PrintTree_r( const node_t *node, int depth ){
static void PrintTree_r( const node_t *node, int depth ){
for ( int i = 0; i < depth; i++ )
Sys_Printf( " " );
if ( node->planenum == PLANENUM_LEAF ) {

View File

@ -30,11 +30,13 @@
/* dependencies */
#include "q3map2.h"
#include "vis.h"
#include "visflow.h"
vportal_t *sorted_portals[ MAX_MAP_PORTALS * 2 ];
visPlane_t PlaneFromWinding( const fixedWinding_t *w ){
static visPlane_t PlaneFromWinding( const fixedWinding_t *w ){
// calc plane
visPlane_t plane;
PlaneFromPoints( plane, w->points[0], w->points[1], w->points[2] );
@ -48,7 +50,7 @@ visPlane_t PlaneFromWinding( const fixedWinding_t *w ){
ydnar: altered this a bit to reconcile multiply-defined winding_t
*/
fixedWinding_t *NewFixedWinding( int numpoints ){
static fixedWinding_t *NewFixedWinding( int numpoints ){
if ( numpoints > MAX_POINTS_ON_WINDING ) {
Error( "NewWinding: %i points", numpoints );
}
@ -57,7 +59,7 @@ fixedWinding_t *NewFixedWinding( int numpoints ){
void prl( leaf_t *l ){
static void print_leaf( const leaf_t *l ){
for ( const vportal_t *p : Span( l->portals, l->numportals ) )
{
const visPlane_t pl = p->plane;
@ -76,7 +78,7 @@ void prl( leaf_t *l ){
the earlier information.
=============
*/
void SortPortals( void ){
static void SortPortals(){
for ( int i = 0; i < numportals * 2; ++i )
sorted_portals[i] = &portals[i];
@ -93,7 +95,7 @@ void SortPortals( void ){
LeafVectorFromPortalVector
==============
*/
int LeafVectorFromPortalVector( byte *portalbits, byte *leafbits ){
static int LeafVectorFromPortalVector( byte *portalbits, byte *leafbits ){
for ( int i = 0; i < numportals * 2; ++i )
{
if ( bit_is_enabled( portalbits, i ) ) {
@ -124,7 +126,8 @@ int LeafVectorFromPortalVector( byte *portalbits, byte *leafbits ){
===============
*/
static int clustersizehistogram[MAX_MAP_LEAFS] = {0};
void ClusterMerge( int leafnum ){
static void ClusterMerge( int leafnum ){
byte portalvector[MAX_PORTALS / 8];
byte uncompressed[MAX_MAP_LEAFS / 8];
int numvis, mergedleafnum;
@ -175,7 +178,7 @@ void ClusterMerge( int leafnum ){
CalcPortalVis
==================
*/
void CalcPortalVis( void ){
static void CalcPortalVis(){
#ifdef MREDEBUG
Sys_Printf( "%6d portals out of %d", 0, numportals * 2 );
//get rid of the counter
@ -191,7 +194,7 @@ void CalcPortalVis( void ){
CalcPassageVis
==================
*/
void CalcPassageVis( void ){
static void CalcPassageVis(){
PassageMemory();
#ifdef MREDEBUG
@ -215,7 +218,7 @@ void CalcPassageVis( void ){
CalcPassagePortalVis
==================
*/
void CalcPassagePortalVis( void ){
static void CalcPassagePortalVis(){
PassageMemory();
#ifdef MREDEBUG
@ -239,7 +242,7 @@ void CalcPassagePortalVis( void ){
CalcFastVis
==================
*/
void CalcFastVis( void ){
static void CalcFastVis(){
// fastvis just uses mightsee for a very loose bound
for ( vportal_t& p : Span( portals, numportals * 2 ) )
{
@ -253,7 +256,7 @@ void CalcFastVis( void ){
CalcVis
==================
*/
void CalcVis( void ){
static void CalcVis(){
int i, minvis, maxvis;
double mu, sigma, totalvis, totalvis2;
@ -337,7 +340,7 @@ void CalcVis( void ){
SetPortalSphere
==================
*/
void SetPortalSphere( vportal_t& p ){
static void SetPortalSphere( vportal_t& p ){
Vector3 origin( 0 );
for ( const Vector3& point : Span( p.winding->points, p.winding->numpoints ) )
@ -451,7 +454,7 @@ static bool TryMergeLeaves( int l1num, int l2num ){
UpdatePortals
============
*/
void UpdatePortals( void ){
static void UpdatePortals(){
for ( vportal_t& p : Span( portals, numportals * 2 ) )
if ( !p.removed )
while ( leafs[p.leaf].merged >= 0 )
@ -465,7 +468,7 @@ void UpdatePortals( void ){
try to merge leaves but don't merge through hint splitters
============
*/
void MergeLeaves( void ){
static void MergeLeaves(){
int nummerges, totalnummerges = 0;
do
@ -506,7 +509,7 @@ void MergeLeaves( void ){
*/
#define CONTINUOUS_EPSILON 0.005
fixedWinding_t *TryMergeWinding( fixedWinding_t *f1, fixedWinding_t *f2, const Vector3& planenormal ){
static fixedWinding_t *TryMergeWinding( fixedWinding_t *f1, fixedWinding_t *f2, const Vector3& planenormal ){
const Vector3 *p1, *p2, *p3, *p4, *back;
fixedWinding_t *newf;
int i, j, k, l;
@ -609,7 +612,7 @@ fixedWinding_t *TryMergeWinding( fixedWinding_t *f1, fixedWinding_t *f2, const V
MergeLeafPortals
============
*/
void MergeLeafPortals( void ){
static void MergeLeafPortals(){
int i, j, k, nummerges, hintsmerged;
leaf_t *leaf;
vportal_t *p1, *p2;
@ -667,7 +670,7 @@ void MergeLeafPortals( void ){
WritePortals
============
*/
int CountActivePortals( void ){
static int CountActivePortals(){
int num = 0, hints = 0;
for ( const vportal_t& p : Span( portals, numportals * 2 ) )
@ -688,7 +691,7 @@ int CountActivePortals( void ){
LoadPortals
============
*/
void LoadPortals( char *name ){
static void LoadPortals( char *name ){
char magic[80];
FILE *f;
int numpoints, leafnums[2], flags;

143
tools/quake3/q3map2/vis.h Normal file
View File

@ -0,0 +1,143 @@
/* -------------------------------------------------------------------------------
Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
/* vis structures */
using visPlane_t = Plane3f;
struct fixedWinding_t
{
int numpoints;
Vector3 points[ MAX_POINTS_ON_FIXED_WINDING ]; /* variable sized */
};
struct passage_t
{
struct passage_t *next;
byte cansee[ 1 ]; /* all portals that can be seen through this passage */
};
enum class EVStatus
{
None,
Working,
Done
};
struct vportal_t
{
int num;
bool hint; /* true if this portal was created from a hint splitter */
bool sky; /* true if this portal belongs to a sky leaf */
bool removed;
visPlane_t plane; /* normal pointing into neighbor */
int leaf; /* neighbor */
Vector3 origin; /* for fast clip testing */
float radius;
fixedWinding_t *winding;
EVStatus status;
byte *portalfront; /* [portals], preliminary */
byte *portalflood; /* [portals], intermediate */
byte *portalvis; /* [portals], final */
int nummightsee; /* bit count on portalflood for sort */
passage_t *passages; /* there are just as many passages as there */
/* are portals in the leaf this portal leads */
};
struct leaf_t
{
int numportals;
int merged;
vportal_t *portals[MAX_PORTALS_ON_LEAF];
};
struct pstack_t
{
byte mightsee[ MAX_PORTALS / 8 ];
pstack_t *next;
leaf_t *leaf;
vportal_t *portal; /* portal exiting */
fixedWinding_t *source;
fixedWinding_t *pass;
fixedWinding_t windings[ 3 ]; /* source, pass, temp in any order */
int freewindings[ 3 ];
visPlane_t portalplane;
int depth;
#ifdef SEPERATORCACHE
visPlane_t seperators[ 2 ][ MAX_SEPERATORS ];
int numseperators[ 2 ];
#endif
};
struct threaddata_t
{
vportal_t *base;
int c_chains;
pstack_t pstack_head;
};
/* commandline arguments */
inline bool fastvis;
inline bool noPassageVis;
inline bool passageVisOnly;
inline bool mergevis;
inline bool mergevisportals;
inline bool nosort;
inline bool saveprt;
inline bool hint; /* ydnar */
inline float farPlaneDist; /* rr2do2, rf, mre, ydnar all contributed to this one... */
inline int farPlaneDistMode;
/* global variables */
inline int numportals;
inline int portalclusters;
inline vportal_t *portals;
inline leaf_t *leafs;
inline vportal_t *faces;
inline leaf_t *faceleafs;
inline int numfaces;
inline int leafbytes;
inline int portalbytes, portallongs;
extern vportal_t *sorted_portals[ MAX_MAP_PORTALS * 2 ];

View File

@ -30,6 +30,7 @@
/* dependencies */
#include "q3map2.h"
#include "vis.h"
@ -64,7 +65,7 @@ int CountBits( const byte *bits, int numbits ){
}
void CheckStack( leaf_t *leaf, threaddata_t *thread ){
static void CheckStack( leaf_t *leaf, threaddata_t *thread ){
for ( pstack_t *p = thread->pstack_head.next; p; p = p->next )
{
// Sys_Printf ("=");
@ -80,7 +81,7 @@ void CheckStack( leaf_t *leaf, threaddata_t *thread ){
}
fixedWinding_t *AllocStackWinding( pstack_t *stack ){
static fixedWinding_t *AllocStackWinding( pstack_t *stack ){
for ( int i = 0; i < 3; ++i )
{
if ( stack->freewindings[i] ) {
@ -94,7 +95,7 @@ fixedWinding_t *AllocStackWinding( pstack_t *stack ){
return NULL;
}
void FreeStackWinding( fixedWinding_t *w, pstack_t *stack ){
static void FreeStackWinding( fixedWinding_t *w, pstack_t *stack ){
const int i = w - stack->windings;
if ( i < 0 || i > 2 ) {
@ -113,7 +114,7 @@ void FreeStackWinding( fixedWinding_t *w, pstack_t *stack ){
==============
*/
fixedWinding_t *VisChopWinding( fixedWinding_t *in, pstack_t *stack, const visPlane_t& split ){
static fixedWinding_t *VisChopWinding( fixedWinding_t *in, pstack_t *stack, const visPlane_t& split ){
float dists[128];
EPlaneSide sides[128];
int counts[3];
@ -229,7 +230,7 @@ fixedWinding_t *VisChopWinding( fixedWinding_t *in, pstack_t *stack, const visP
flipclip should be set.
==============
*/
fixedWinding_t *ClipToSeperators( fixedWinding_t *source, fixedWinding_t *pass, fixedWinding_t *target, bool flipclip, pstack_t *stack ){
static fixedWinding_t *ClipToSeperators( fixedWinding_t *source, fixedWinding_t *pass, fixedWinding_t *target, bool flipclip, pstack_t *stack ){
int i, j, k, l;
float d;
int counts[3];
@ -374,7 +375,7 @@ fixedWinding_t *ClipToSeperators( fixedWinding_t *source, fixedWinding_t *pass,
If src_portal is NULL, this is the originating leaf
==================
*/
void RecursiveLeafFlow( int leafnum, threaddata_t *thread, pstack_t *prevstack ){
static void RecursiveLeafFlow( int leafnum, threaddata_t *thread, pstack_t *prevstack ){
pstack_t stack;
visPlane_t backplane;
leaf_t *leaf;
@ -633,7 +634,7 @@ void PortalFlow( int portalnum ){
RecursivePassageFlow
==================
*/
void RecursivePassageFlow( vportal_t *portal, threaddata_t *thread, pstack_t *prevstack ){
static void RecursivePassageFlow( vportal_t *portal, threaddata_t *thread, pstack_t *prevstack ){
pstack_t stack;
vportal_t *p;
leaf_t *leaf;
@ -754,7 +755,7 @@ void PassageFlow( int portalnum ){
RecursivePassagePortalFlow
==================
*/
void RecursivePassagePortalFlow( vportal_t *portal, threaddata_t *thread, pstack_t *prevstack ){
static void RecursivePassagePortalFlow( vportal_t *portal, threaddata_t *thread, pstack_t *prevstack ){
pstack_t stack;
vportal_t *p;
leaf_t *leaf;
@ -998,7 +999,7 @@ void PassagePortalFlow( int portalnum ){
*/
}
fixedWinding_t *PassageChopWinding( fixedWinding_t *in, fixedWinding_t *out, const visPlane_t& split ){
static fixedWinding_t *PassageChopWinding( fixedWinding_t *in, fixedWinding_t *out, const visPlane_t& split ){
float dists[128];
EPlaneSide sides[128];
int counts[3];
@ -1097,7 +1098,7 @@ fixedWinding_t *PassageChopWinding( fixedWinding_t *in, fixedWinding_t *out, con
AddSeperators
===============
*/
int AddSeperators( const fixedWinding_t *source, const fixedWinding_t *pass, bool flipclip, visPlane_t *seperators, int maxseperators ){
static int AddSeperators( const fixedWinding_t *source, const fixedWinding_t *pass, bool flipclip, visPlane_t *seperators, int maxseperators ){
int i, j, k, l;
int counts[3], numseperators;
bool fliptest;
@ -1337,7 +1338,7 @@ void CreatePassages( int portalnum ){
}
}
void PassageMemory( void ){
void PassageMemory(){
int totalmem = 0, totalportals = 0;
for ( const vportal_t *portal : Span( sorted_portals, numportals ) )
@ -1408,7 +1409,7 @@ void PassageMemory( void ){
==================
*/
void SimpleFlood( vportal_t *srcportal, int leafnum ){
static void SimpleFlood( vportal_t *srcportal, int leafnum ){
for ( const vportal_t *p : Span( leafs[leafnum].portals, leafs[leafnum].numportals ) )
{
if ( p->removed ) {
@ -1544,7 +1545,7 @@ void BasePortalVis( int portalnum ){
==================
*/
void RecursiveLeafBitFlow( int leafnum, byte *mightsee, byte *cansee ){
static void RecursiveLeafBitFlow( int leafnum, byte *mightsee, byte *cansee ){
byte newmight[MAX_PORTALS / 8];

View File

@ -0,0 +1,33 @@
/* -------------------------------------------------------------------------------
Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
int CountBits( const byte *bits, int numbits );
void PassageFlow( int portalnum );
void CreatePassages( int portalnum );
void PassageMemory();
void BasePortalVis( int portalnum );
void BetterPortalVis( int portalnum );
void PortalFlow( int portalnum );
void PassagePortalFlow( int portalnum );

View File

@ -99,7 +99,7 @@ int EmitShader( const char *shader, const int *contentFlags, const int *surfaceF
brushes will be saved in the map
*/
void EmitPlanes( void ){
static void EmitPlanes(){
bspPlanes.reserve( mapplanes.size() );
/* walk plane list */
for ( const plane_t& plane : mapplanes )
@ -118,7 +118,7 @@ void EmitPlanes( void ){
emits a leafnode to the bsp file
*/
void EmitLeaf( node_t *node ){
static void EmitLeaf( node_t *node ){
bspLeaf_t& leaf = bspLeafs.emplace_back();
leaf.cluster = node->cluster;
@ -158,7 +158,7 @@ void EmitLeaf( node_t *node ){
recursively emit the bsp nodes
*/
int EmitDrawNode_r( node_t *node ){
static int EmitDrawNode_r( node_t *node ){
/* check for leafnode */
if ( node->planenum == PLANENUM_LEAF ) {
EmitLeaf( node );
@ -206,7 +206,7 @@ int EmitDrawNode_r( node_t *node ){
SetModelNumbers
============
*/
void SetModelNumbers( void ){
void SetModelNumbers(){
int models = 1;
for ( std::size_t i = 1; i < entities.size(); ++i ) {
if ( !entities[i].brushes.empty() || entities[i].patches ) {
@ -227,11 +227,12 @@ void SetModelNumbers( void ){
sets style keys for entity lights
*/
void SetLightStyles( void ){
void SetLightStyles(){
int j, numStyles;
char value[ 10 ];
char lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ];
int lightStyles[ MAX_SWITCHED_LIGHTS ];
int numStrippedLights = 0;
/* -keeplights option: force lights to be kept and ignore what the map file says */
if ( keepLights ) {
@ -306,7 +307,7 @@ void SetLightStyles( void ){
starts a new bsp file
*/
void BeginBSPFile( void ){
void BeginBSPFile(){
/* these values may actually be initialized if the file existed when loaded, so clear them explicitly */
bspModels.clear();
bspNodes.clear();
@ -410,7 +411,7 @@ void EmitBrushes( brushlist_t& brushes, int *firstBrush, int *numBrushes ){
turns map fogs into bsp fogs
*/
void EmitFogs( void ){
void EmitFogs(){
/* walk list */
for ( size_t i = 0; i < mapFogs.size(); ++i )
{
@ -475,7 +476,7 @@ void EmitFogs( void ){
sets up a new brush model
*/
void BeginModel( void ){
void BeginModel(){
MinMax minmax;
MinMax lgMinmax; /* ydnar: lightgrid mins/maxs */