From: Mattia Basaglia Date: Mon, 13 Mar 2017 07:30:25 +0000 (+0000) Subject: Remove pointless static guards X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5ad73ab66a21236604ac976727cabc6d82e57176;p=xonotic%2Fnetradiant.git Remove pointless static guards --- diff --git a/contrib/bkgrnd2d/bkgrnd2d.cpp b/contrib/bkgrnd2d/bkgrnd2d.cpp index b1159525..80af5db0 100644 --- a/contrib/bkgrnd2d/bkgrnd2d.cpp +++ b/contrib/bkgrnd2d/bkgrnd2d.cpp @@ -119,7 +119,7 @@ void CBackgroundImage::Render(){ g_QglTable.m_pfn_qglPolygonMode( GL_FRONT,GL_FILL ); // TODO, just so we can tell if we end up going the wrong way - // g_QglTable.m_pfn_qglPolygonMode(GL_BACK,GL_LINE); + // TODO any other state we should not assume ? g_QglTable.m_pfn_qglBindTexture( GL_TEXTURE_2D, m_tex->texture_number ); diff --git a/contrib/gtkgensurf/gensurf.h b/contrib/gtkgensurf/gensurf.h index 99e4a46b..57e9458e 100644 --- a/contrib/gtkgensurf/gensurf.h +++ b/contrib/gtkgensurf/gensurf.h @@ -58,15 +58,7 @@ extern _QERBrushTable __BRUSHTABLENAME; #define PLUGIN #define Q3RADIANT -//#if defined(__linux__) || defined(__APPLE__) -#if 1 #include -#else -template -inline T min( T x, T y ) { return ( x < y ) ? x : y; } -template -inline T max( T x, T y ) { return ( x > y ) ? x : y; } -#endif typedef struct { long x, y; } Point; typedef struct { long left, top, right, bottom; } Rect; @@ -76,7 +68,6 @@ typedef struct { long left, top, right, bottom; } Rect; typedef void* LPVOID; typedef char* LPSTR; -//#endif inline bool PtInRect( Rect *rc, Point pt ){ if ( pt.x < rc->left ) { return false; @@ -107,14 +98,7 @@ inline bool PtInRect( Rect *rc, Point pt ){ #define DegreesToRadians( a ) ( a / 57.2957795 ) #define BOGUS_RANGE 65536 -/* - #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) - #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];} - #define VectorClear(x) {x[0] = x[1] = x[2] = 0;} - #define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];} - #define VectorScale(a,b,c) {c[0]=b*a[0];c[1]=b*a[1];c[2]=b*a[2];} - #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];} - */ + #define XYZVectorSubtract( a,b,c ) {c[0] = (float)a[0] - (float)b[0]; c[1] = (float)a[1] - (float)b[1]; c[2] = (float)a[2] - (float)b[2]; } #define side( u1,v1,u2,v2,u3,v3 ) ( v3 - v1 ) * ( u2 - u1 ) - ( u3 - u1 ) * ( v2 - v1 ) diff --git a/plugins/entity/light.cpp b/plugins/entity/light.cpp index 6c0141b7..d65b8904 100644 --- a/plugins/entity/light.cpp +++ b/plugins/entity/light.cpp @@ -358,55 +358,10 @@ void light_draw( const AABB& aabb_light, RenderStateFlags state ){ 1, 4, 3, 1, 3, 2 }; -#if 1 glVertexPointer( 3, GL_FLOAT, 0, points ); glDrawElements( GL_TRIANGLES, sizeof( indices ) / sizeof( index_t ), RenderIndexTypeID, indices ); -#else - glBegin( GL_TRIANGLES ); - for ( unsigned int i = 0; i < sizeof( indices ) / sizeof( index_t ); ++i ) - { - glVertex3fv( points[indices[i]] ); - } - glEnd(); -#endif } - - // NOTE: prolly not relevant until some time.. - // check for DOOM lights -#if 0 - if ( strlen( ValueForKey( e, "light_right" ) ) > 0 ) { - vec3_t vRight, vUp, vTarget, vTemp; - GetVectorForKey( e, "light_right", vRight ); - GetVectorForKey( e, "light_up", vUp ); - GetVectorForKey( e, "light_target", vTarget ); - - glColor3f( 0, 1, 0 ); - glBegin( GL_LINE_LOOP ); - VectorAdd( vTarget, e->origin, vTemp ); - VectorAdd( vTemp, vRight, vTemp ); - VectorAdd( vTemp, vUp, vTemp ); - glVertex3fv( e->origin ); - glVertex3fv( vTemp ); - VectorAdd( vTarget, e->origin, vTemp ); - VectorAdd( vTemp, vUp, vTemp ); - VectorSubtract( vTemp, vRight, vTemp ); - glVertex3fv( e->origin ); - glVertex3fv( vTemp ); - VectorAdd( vTarget, e->origin, vTemp ); - VectorAdd( vTemp, vRight, vTemp ); - VectorSubtract( vTemp, vUp, vTemp ); - glVertex3fv( e->origin ); - glVertex3fv( vTemp ); - VectorAdd( vTarget, e->origin, vTemp ); - VectorSubtract( vTemp, vUp, vTemp ); - VectorSubtract( vTemp, vRight, vTemp ); - glVertex3fv( e->origin ); - glVertex3fv( vTemp ); - glEnd(); - - } -#endif } // These variables are tweakable on the q3map2 console, setting to q3map2 @@ -602,9 +557,7 @@ void render( RenderStateFlags state ) const { aabb_draw_wire( m_points ); } - #if 1 //disable if you dont want lines going from the center of the light bbox to the corners light_draw_box_lines( m_origin, m_points ); - #endif } }; diff --git a/plugins/entity/targetable.h b/plugins/entity/targetable.h index 6de382cf..82bed400 100644 --- a/plugins/entity/targetable.h +++ b/plugins/entity/targetable.h @@ -342,17 +342,10 @@ void erase( const char* key, EntityKeyValue& value ){ } const Vector3& world_position() const { -#if 1 const AABB& bounds = Instance::worldAABB(); if ( aabb_valid( bounds ) ) { return bounds.origin; } -#else - const AABB& childBounds = Instance::childBounds(); - if ( aabb_valid( childBounds ) ) { - return childBounds.origin; - } -#endif return vector4_to_vector3( localToWorld().t() ); } diff --git a/plugins/image/jpeg.cpp b/plugins/image/jpeg.cpp index 138151a2..22edb0ab 100644 --- a/plugins/image/jpeg.cpp +++ b/plugins/image/jpeg.cpp @@ -315,11 +315,7 @@ static void j_putRGBAScanline( unsigned char* jpegline, int widthPix, unsigned c *oBlu = iBlu; //!\todo fix jpeglib, it leaves alpha channel uninitialised -#if 1 *oAlp = 255; -#else - *oAlp = iAlp; -#endif } } diff --git a/plugins/shaders/shaders.cpp b/plugins/shaders/shaders.cpp index 3dfc9f6e..72757fca 100644 --- a/plugins/shaders/shaders.cpp +++ b/plugins/shaders/shaders.cpp @@ -123,7 +123,6 @@ Image& convertHeightmapToNormalmap( Image& heightmap, float scale ){ byte* in = heightmap.getRGBAPixels(); byte* out = normalmap.getRGBAPixels(); -#if 1 // no filtering const int kernelSize = 2; KernelElement kernel_du[kernelSize] = { @@ -134,26 +133,6 @@ Image& convertHeightmapToNormalmap( Image& heightmap, float scale ){ { 0, 1, 0.5f }, { 0,-1,-0.5f } }; -#else - // 3x3 Prewitt - const int kernelSize = 6; - KernelElement kernel_du[kernelSize] = { - {-1, 1,-1.0f }, - {-1, 0,-1.0f }, - {-1,-1,-1.0f }, - { 1, 1, 1.0f }, - { 1, 0, 1.0f }, - { 1,-1, 1.0f } - }; - KernelElement kernel_dv[kernelSize] = { - {-1, 1, 1.0f }, - { 0, 1, 1.0f }, - { 1, 1, 1.0f }, - {-1,-1,-1.0f }, - { 0,-1,-1.0f }, - { 1,-1,-1.0f } - }; -#endif int x, y = 0; while ( y < h ) diff --git a/radiant/brush.h b/radiant/brush.h index 6c0956f5..9a41dc24 100644 --- a/radiant/brush.h +++ b/radiant/brush.h @@ -1258,19 +1258,9 @@ class RenderableWireframe : public OpenGLRenderable { public: void render( RenderStateFlags state ) const { -#if 1 glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( PointVertex ), &m_vertices->colour ); glVertexPointer( 3, GL_FLOAT, sizeof( PointVertex ), &m_vertices->vertex ); glDrawElements( GL_LINES, GLsizei( m_size << 1 ), RenderIndexTypeID, m_faceVertex.data() ); -#else - glBegin( GL_LINES ); - for ( std::size_t i = 0; i < m_size; ++i ) - { - glVertex3fv( &m_vertices[m_faceVertex[i].first].vertex.x ); - glVertex3fv( &m_vertices[m_faceVertex[i].second].vertex.x ); - } - glEnd(); -#endif } Array m_faceVertex; diff --git a/radiant/brush_primit.cpp b/radiant/brush_primit.cpp index 9cac7a88..5a02f8fe 100644 --- a/radiant/brush_primit.cpp +++ b/radiant/brush_primit.cpp @@ -883,7 +883,6 @@ void Texdef_transformLocked( TextureProjection& projection, std::size_t width, s Texdef_normalise( projection, (float)width, (float)height ); } -#if 1 void Q3_to_matrix( const texdef_t& texdef, float width, float height, const Vector3& normal, Matrix4& matrix ){ Normal_GetTransform( normal, matrix ); @@ -912,4 +911,3 @@ void Q3_to_BP( const texdef_t& texdef, float width, float height, const Vector3& Q3_to_matrix( texdef, width, height, normal, matrix ); BP_from_matrix( bp_texdef, normal, matrix ); } -#endif diff --git a/radiant/brush_primit.h b/radiant/brush_primit.h index 79d27f3e..9c5c5461 100644 --- a/radiant/brush_primit.h +++ b/radiant/brush_primit.h @@ -38,17 +38,14 @@ struct brushprimit_texdef_t coords[1][2] = 0.f; } void removeScale( std::size_t width, std::size_t height ){ -#if 1 coords[0][0] *= width; coords[0][1] *= width; coords[0][2] *= width; coords[1][0] *= height; coords[1][1] *= height; coords[1][2] *= height; -#endif } void addScale( std::size_t width, std::size_t height ){ -#if 1 ASSERT_MESSAGE( width > 0, "shader-width is 0" ); ASSERT_MESSAGE( height > 0, "shader-height is 0" ); coords[0][0] /= width; @@ -57,7 +54,6 @@ struct brushprimit_texdef_t coords[1][0] /= height; coords[1][1] /= height; coords[1][2] /= height; -#endif } float coords[2][3]; }; diff --git a/radiant/brushmanip.cpp b/radiant/brushmanip.cpp index cf6e932c..caf20c24 100644 --- a/radiant/brushmanip.cpp +++ b/radiant/brushmanip.cpp @@ -731,15 +731,10 @@ void Scene_BrushGetTexdef_Selected( scene::Graph& graph, TextureProjection& proj } void Scene_BrushGetTexdef_Component_Selected( scene::Graph& graph, TextureProjection& projection ){ -#if 1 if ( !g_SelectedFaceInstances.empty() ) { FaceInstance& faceInstance = g_SelectedFaceInstances.last(); faceInstance.getFace().GetTexdef( projection ); } -#else - FaceGetTexdef visitor( projection ); - Scene_ForEachSelectedBrushFace( graph, visitor ); -#endif } void Scene_BrushGetShaderSize_Component_Selected( scene::Graph& graph, size_t& width, size_t& height ){ @@ -769,27 +764,19 @@ void operator()( Face& face ) const { void Scene_BrushGetFlags_Selected( scene::Graph& graph, ContentsFlagsValue& flags ){ -#if 1 if ( GlobalSelectionSystem().countSelected() != 0 ) { BrushInstance* brush = Instance_getBrush( GlobalSelectionSystem().ultimateSelected() ); if ( brush != 0 ) { Brush_forEachFace( *brush, FaceGetFlags( flags ) ); } } -#else - Scene_ForEachSelectedBrush_ForEachFace( graph, FaceGetFlags( flags ) ); -#endif } void Scene_BrushGetFlags_Component_Selected( scene::Graph& graph, ContentsFlagsValue& flags ){ -#if 1 if ( !g_SelectedFaceInstances.empty() ) { FaceInstance& faceInstance = g_SelectedFaceInstances.last(); faceInstance.getFace().GetFlags( flags ); } -#else - Scene_ForEachSelectedBrushFace( graph, FaceGetFlags( flags ) ); -#endif } @@ -810,28 +797,19 @@ void operator()( Face& face ) const { }; void Scene_BrushGetShader_Selected( scene::Graph& graph, CopiedString& shader ){ -#if 1 if ( GlobalSelectionSystem().countSelected() != 0 ) { BrushInstance* brush = Instance_getBrush( GlobalSelectionSystem().ultimateSelected() ); if ( brush != 0 ) { Brush_forEachFace( *brush, FaceGetShader( shader ) ); } } -#else - Scene_ForEachSelectedBrush_ForEachFace( graph, FaceGetShader( shader ) ); -#endif } void Scene_BrushGetShader_Component_Selected( scene::Graph& graph, CopiedString& shader ){ -#if 1 if ( !g_SelectedFaceInstances.empty() ) { FaceInstance& faceInstance = g_SelectedFaceInstances.last(); shader = faceInstance.getFace().GetShader(); } -#else - FaceGetShader visitor( shader ); - Scene_ForEachSelectedBrushFace( graph, visitor ); -#endif } diff --git a/radiant/csg.cpp b/radiant/csg.cpp index 5676401e..7d0d5e35 100644 --- a/radiant/csg.cpp +++ b/radiant/csg.cpp @@ -240,7 +240,6 @@ typedef Function3 FaceTe /// \li flipped && brush is FRONT or ON bool Brush_testPlane( const Brush& brush, const Plane3& plane, bool flipped ){ brush.evaluateBRep(); -#if 1 for ( Brush::const_iterator i( brush.begin() ); i != brush.end(); ++i ) { if ( Face_testPlane( *( *i ), plane, flipped ) ) { @@ -248,9 +247,6 @@ bool Brush_testPlane( const Brush& brush, const Plane3& plane, bool flipped ){ } } return true; -#else - return Brush_findIf( brush, bindArguments( FaceTestPlane(), makeReference( plane ), flipped ) ) == 0; -#endif } brushsplit_t Brush_classifyPlane( const Brush& brush, const Plane3& plane ){ diff --git a/radiant/help.cpp b/radiant/help.cpp index d5319f30..cfd1145c 100644 --- a/radiant/help.cpp +++ b/radiant/help.cpp @@ -117,16 +117,7 @@ void create_game_help_menu( GtkMenu *menu ){ filename << AppPath_get() << "global.xlink"; process_xlink( filename.c_str(), "General", AppPath_get(), menu ); -#if 1 filename.clear(); filename << g_pGameDescription->mGameToolsPath.c_str() << "game.xlink"; process_xlink( filename.c_str(), g_pGameDescription->getRequiredKeyValue( "name" ), g_pGameDescription->mGameToolsPath.c_str(), menu ); -#else - for ( std::list::iterator iGame = g_GamesDialog.mGames.begin(); iGame != g_GamesDialog.mGames.end(); ++iGame ) - { - filename.clear(); - filename << ( *iGame )->mGameToolsPath.c_str() << "game.xlink"; - process_xlink( filename.c_str(), ( *iGame )->getRequiredKeyValue( "name" ), ( *iGame )->mGameToolsPath.c_str(), menu ); - } -#endif } diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index 73639e54..5014e975 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -133,16 +133,12 @@ void operator()( Patch& patch ){ }; void Scene_PatchGetFixedSubdivisions( PatchFixedSubdivisions& subdivisions ){ -#if 1 if ( GlobalSelectionSystem().countSelected() != 0 ) { Patch* patch = Node_getPatch( GlobalSelectionSystem().ultimateSelected().path().top() ); if ( patch != 0 ) { Patch_getFixedSubdivisions( *patch, subdivisions ); } } -#else - Scene_forEachVisibleSelectedPatch( PatchGetFixedSubdivisions( subdivisions ) ); -#endif } class PatchSetFixedSubdivisions diff --git a/radiant/select.cpp b/radiant/select.cpp index 49d162c5..a79004e7 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -477,7 +477,6 @@ inline void matrix4_pivoted_rotate_by_axis90( Matrix4& matrix, axis_t axis, sign } inline Quaternion quaternion_for_axis90( axis_t axis, sign_t sign ){ -#if 1 switch ( axis ) { case eAxisX: @@ -505,9 +504,6 @@ inline Quaternion quaternion_for_axis90( axis_t axis, sign_t sign ){ return Quaternion( 0, 0, -c_half_sqrt2f, -c_half_sqrt2f ); } } -#else - quaternion_for_matrix4_rotation( matrix4_rotation_for_axis90( (axis_t)axis, ( deg > 0 ) ? eSignPositive : eSignNegative ) ); -#endif } void Select_RotateAxis( int axis, float deg ){ diff --git a/radiant/selection.cpp b/radiant/selection.cpp index b55a3864..ccb16492 100644 --- a/radiant/selection.cpp +++ b/radiant/selection.cpp @@ -3388,19 +3388,11 @@ typedef Callback1 MouseEventCallback; Single g_mouseMovedCallback; Single g_mouseUpCallback; -#if 1 const ButtonIdentifier c_button_select = c_buttonLeft; const ModifierFlags c_modifier_manipulator = c_modifierNone; const ModifierFlags c_modifier_toggle = c_modifierShift; const ModifierFlags c_modifier_replace = c_modifierShift | c_modifierAlt; const ModifierFlags c_modifier_face = c_modifierControl; -#else -const ButtonIdentifier c_button_select = c_buttonLeft; -const ModifierFlags c_modifier_manipulator = c_modifierNone; -const ModifierFlags c_modifier_toggle = c_modifierControl; -const ModifierFlags c_modifier_replace = c_modifierNone; -const ModifierFlags c_modifier_face = c_modifierShift; -#endif const ModifierFlags c_modifier_toggle_face = c_modifier_toggle | c_modifier_face; const ModifierFlags c_modifier_replace_face = c_modifier_replace | c_modifier_face; diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index 73312a07..11a423b0 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -77,49 +77,8 @@ #include "grid.h" #include "textureentry.h" -//NOTE: Proper functioning of Textool currently requires that the "#if 1" lines in -// brush_primit.h be changed to "#if 0". add/removeScale screws this up ATM. :-) -// Plus, Radiant seems to work just fine without that stuff. ;-) - -#define TEXTOOL_ENABLED 0 - -#if TEXTOOL_ENABLED - -namespace TexTool -{ - -//Shamus: Textool function prototypes -gboolean size_allocate( GtkWidget *, GtkAllocation *, gpointer ); -gboolean expose( GtkWidget *, GdkEventExpose *, gpointer ); -gboolean button_press( GtkWidget *, GdkEventButton *, gpointer ); -gboolean button_release( GtkWidget *, GdkEventButton *, gpointer ); -gboolean motion( GtkWidget *, GdkEventMotion *, gpointer ); -void flipX( GtkToggleButton *, gpointer ); -void flipY( GtkToggleButton *, gpointer ); - -//End Textool function prototypes - -//Shamus: Textool globals -GtkWidget * g_textoolWin; -//End Textool globals - -void queueDraw(){ - gtk_widget_queue_draw( g_textoolWin ); -} - -} - -#endif - inline void spin_button_set_step( GtkSpinButton* spin, gfloat step ){ -#if 1 gtk_spin_button_get_adjustment( spin )->step_increment = step; -#else - GValue gvalue = GValue_default(); - g_value_init( &gvalue, G_TYPE_DOUBLE ); - g_value_set_double( &gvalue, step ); - g_object_set( G_OBJECT( gtk_spin_button_get_adjustment( spin ) ), "step-increment", &gvalue, NULL ); -#endif } class Increment diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 33e7e5c2..f0fd5d49 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -103,12 +103,7 @@ typedef std::set TextureGroups; void TextureGroups_addWad( TextureGroups& groups, const char* archive ){ if ( extension_equal( path_get_extension( archive ), "wad" ) ) { -#if 1 groups.insert( archive ); -#else - CopiedString archiveBaseName( path_get_filename_start( archive ), path_get_filename_base_end( archive ) ); - groups.insert( archiveBaseName ); -#endif } } typedef ReferenceCaller1 TextureGroupsAddWadCaller; diff --git a/radiant/timer.cpp b/radiant/timer.cpp index 1c55d930..96a90669 100644 --- a/radiant/timer.cpp +++ b/radiant/timer.cpp @@ -51,11 +51,7 @@ public: } else { -#if 1 return MillisecondTime(); -#else - return time_from_ticks( timeGetTime(), 1000 ); -#endif } } diff --git a/radiant/timer.h b/radiant/timer.h index 53280a8c..ebbdbcc8 100644 --- a/radiant/timer.h +++ b/radiant/timer.h @@ -22,7 +22,6 @@ #if !defined ( INCLUDED_TIMER_H ) #define INCLUDED_TIMER_H -#if 1 const int msec_per_sec = 1000; @@ -47,36 +46,6 @@ inline MillisecondTime time_from_ticks( tick_type tick_count, tick_type ticks_pe return MillisecondTime( static_cast( tick_count / static_cast( ticks_per_sec / msec_per_sec ) ) ); } -#else - -const unsigned int usec_per_sec = 1000000; - -class MillisecondTime -{ -unsigned int m_sec; -unsigned int m_usec; -public: -MillisecondTime( unsigned int sec, unsigned int usec ) - : m_sec( sec ), m_usec( usec ){ -} -MillisecondTime(){ -} -staticMillisecondTime current(); - -unsigned int milliseconds_since( const MillisecondTime& other ) const { - return static_cast( ( m_sec * static_cast( usec_per_sec ) + m_usec ) - - ( other.m_sec * static_cast( usec_per_sec ) + other.m_usec ) ) / 1000; -} -}; - -template -inline MillisecondTime time_from_ticks( tick_type tick_count, tick_type ticks_per_sec ){ - return MillisecondTime( static_cast( tick_count / ticks_per_sec ), - static_cast( ( tick_count % ticks_per_sec ) * ( usec_per_sec / static_cast( ticks_per_sec ) ) ) ); -} - -#endif - class Timer { MillisecondTime m_start; diff --git a/tools/quake2/extra/bsp/qbsp3/csg.c b/tools/quake2/extra/bsp/qbsp3/csg.c index 2d69aa22..f5b50e5d 100644 --- a/tools/quake2/extra/bsp/qbsp3/csg.c +++ b/tools/quake2/extra/bsp/qbsp3/csg.c @@ -55,12 +55,6 @@ void SplitBrush2 (bspbrush_t *brush, int planenum, bspbrush_t **front, bspbrush_t **back) { SplitBrush (brush, planenum, front, back); -#if 0 - if (*front && (*front)->sides[(*front)->numsides-1].texinfo == -1) - (*front)->sides[(*front)->numsides-1].texinfo = (*front)->sides[0].texinfo; // not -1 - if (*back && (*back)->sides[(*back)->numsides-1].texinfo == -1) - (*back)->sides[(*back)->numsides-1].texinfo = (*back)->sides[0].texinfo; // not -1 -#endif } /* @@ -289,10 +283,6 @@ bspbrush_t *MakeBspBrushList (int startbrush, int endbrush, for (j=0 ; joriginal_sides[j].visible && mb->original_sides[j].winding) vis++; -#if 0 - if (!vis) - continue; // no faces at all -#endif // if the brush is outside the clip area, skip it for (j=0 ; j<3 ; j++) if (mb->mins[j] >= clipmaxs[j] @@ -462,10 +452,6 @@ bspbrush_t *ChopBrushes (bspbrush_t *head) qprintf ("---- ChopBrushes ----\n"); qprintf ("original brushes: %i\n", CountBrushList (head)); -#if 0 - if (startbrush == 0) - WriteBrushList ("before.gl", head, false); -#endif keep = NULL; newlist: @@ -555,12 +541,6 @@ newlist: } qprintf ("output brushes: %i\n", CountBrushList (keep)); -#if 0 - { - WriteBrushList ("after.gl", keep, false); - WriteBrushMap ("after.map", keep); - } -#endif return keep; } @@ -580,13 +560,6 @@ bspbrush_t *InitialBrushList (bspbrush_t *list) out = NULL; for (b=list ; b ; b=b->next) { -#if 0 - for (i=0 ; inumsides ; i++) - if (b->sides[i].visible) - break; - if (i == b->numsides) - continue; -#endif newb = CopyBrush (b); newb->next = out; out = newb; @@ -596,7 +569,6 @@ bspbrush_t *InitialBrushList (bspbrush_t *list) for (i=0 ; inumsides ; i++) { newb->sides[i].original = &b->sides[i]; -// newb->sides[i].visible = true; b->sides[i].visible = false; } } diff --git a/tools/quake2/extra/bsp/qbsp3/faces.c b/tools/quake2/extra/bsp/qbsp3/faces.c index 1bbc922b..53749426 100644 --- a/tools/quake2/extra/bsp/qbsp3/faces.c +++ b/tools/quake2/extra/bsp/qbsp3/faces.c @@ -332,15 +332,6 @@ void FindEdgeVerts (vec3_t v1, vec3_t v2) int x, y; int vnum; -#if 0 -{ - int i; - num_edge_verts = numvertexes-1; - for (i=0 ; i> 7; y1 = (4096 + (int)(v1[1]+0.5)) >> 7; x2 = (4096 + (int)(v2[0]+0.5)) >> 7; @@ -358,20 +349,6 @@ void FindEdgeVerts (vec3_t v1, vec3_t v2) y1 = y2; y2 = t; } -#if 0 - x1--; - x2++; - y1--; - y2++; - if (x1 < 0) - x1 = 0; - if (x2 >= HASH_SIZE) - x2 = HASH_SIZE; - if (y1 < 0) - y1 = 0; - if (y2 >= HASH_SIZE) - y2 = HASH_SIZE; -#endif num_edge_verts = 0; for (x=x1 ; x <= x2 ; x++) { @@ -647,13 +624,6 @@ int GetEdge2 (int v1, int v2, face_t *f) edgefaces[i][1] = f; return -i; } - #if 0 - if (v1 == edge->v[0] && v2 == edge->v[1]) - { - printf ("WARNING: multiple forward edge\n"); - return i; - } - #endif } } @@ -910,10 +880,6 @@ void SubdivideFace (node_t *node, face_t *f) if (v > maxs) maxs = v; } -#if 0 - if (maxs - mins <= 0) - Error ("zero extents"); -#endif if (axis == 2) { // allow double high walls if (maxs - mins <= subdivide_size/* *2 */) diff --git a/tools/quake2/extra/bsp/qbsp3/gldraw.c b/tools/quake2/extra/bsp/qbsp3/gldraw.c index 08ab9c45..0dab2693 100644 --- a/tools/quake2/extra/bsp/qbsp3/gldraw.c +++ b/tools/quake2/extra/bsp/qbsp3/gldraw.c @@ -74,23 +74,11 @@ void Draw_ClearWindow (void) gluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0); glColor3f (0,0,0); -// glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glDisable (GL_DEPTH_TEST); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#if 0 - glColor4f (1,0,0,0.5); - glBegin (GL_POLYGON); - - glVertex3f (0, 500, 0); - glVertex3f (0, 900, 0); - glVertex3f (0, 900, 100); - glVertex3f (0, 500, 100); - - glEnd (); -#endif glFlush (); diff --git a/tools/quake2/extra/bsp/qbsp3/map.c b/tools/quake2/extra/bsp/qbsp3/map.c index 232979c7..ab2d3971 100644 --- a/tools/quake2/extra/bsp/qbsp3/map.c +++ b/tools/quake2/extra/bsp/qbsp3/map.c @@ -97,20 +97,12 @@ PlaneEqual #define DIST_EPSILON 0.01 qboolean PlaneEqual (plane_t *p, vec3_t normal, vec_t dist) { -#if 1 if ( fabs(p->normal[0] - normal[0]) < NORMAL_EPSILON && fabs(p->normal[1] - normal[1]) < NORMAL_EPSILON && fabs(p->normal[2] - normal[2]) < NORMAL_EPSILON && fabs(p->dist - dist) < DIST_EPSILON ) return true; -#else - if (p->normal[0] == normal[0] - && p->normal[1] == normal[1] - && p->normal[2] == normal[2] - && p->dist == dist) - return true; -#endif return false; } diff --git a/tools/quake2/extra/bsp/qbsp3/portals.c b/tools/quake2/extra/bsp/qbsp3/portals.c index ef57caef..d42b40ec 100644 --- a/tools/quake2/extra/bsp/qbsp3/portals.c +++ b/tools/quake2/extra/bsp/qbsp3/portals.c @@ -777,10 +777,6 @@ void FloodAreas_r (node_t *node) for (p=node->portals ; p ; p = p->next[s]) { s = (p->nodes[1] == node); -#if 0 - if (p->nodes[!s]->occupied) - continue; -#endif if (!Portal_EntityFlood (p, s)) continue; diff --git a/tools/quake2/extra/bsp/qbsp3/writebsp.c b/tools/quake2/extra/bsp/qbsp3/writebsp.c index cc5c3266..85c3ae6b 100644 --- a/tools/quake2/extra/bsp/qbsp3/writebsp.c +++ b/tools/quake2/extra/bsp/qbsp3/writebsp.c @@ -507,14 +507,6 @@ void EndBSPFile (void) EmitPlanes (); UnparseEntities (); - // load the pop -#if 0 - sprintf (path, "%s/pics/pop.lmp", gamedir); - len = LoadFile (path, &buf); - memcpy (dpop, buf, sizeof(dpop)); - free (buf); -#endif - // write the map sprintf (path, "%s.bsp", source); printf ("Writing %s\n", path); diff --git a/tools/quake2/extra/bsp/qrad3/lightmap.c b/tools/quake2/extra/bsp/qrad3/lightmap.c index e6a5aaaa..0a678d51 100644 --- a/tools/quake2/extra/bsp/qrad3/lightmap.c +++ b/tools/quake2/extra/bsp/qrad3/lightmap.c @@ -1186,11 +1186,6 @@ void FinalLightFace (int facenum) lightdatasize += fl->numstyles*(fl->numsamples*3); // add green sentinals between lightmaps -#if 0 -lightdatasize += 64*3; -for (i=0 ; i<64 ; i++) -dlightdata[lightdatasize-(i+1)*3 + 1] = 255; -#endif if (lightdatasize > MAX_MAP_LIGHTING) Error ("MAX_MAP_LIGHTING"); diff --git a/tools/quake2/extra/bsp/qrad3/patches.c b/tools/quake2/extra/bsp/qrad3/patches.c index fbae0c32..239da13c 100644 --- a/tools/quake2/extra/bsp/qrad3/patches.c +++ b/tools/quake2/extra/bsp/qrad3/patches.c @@ -106,11 +106,6 @@ void CalcTextureReflectivity (void) scale *= 2; VectorScale (texture_reflectivity[i], scale, texture_reflectivity[i]); } -#if 0 -texture_reflectivity[i][0] = 0.5; -texture_reflectivity[i][1] = 0.5; -texture_reflectivity[i][2] = 0.5; -#endif } } diff --git a/tools/quake2/extra/bsp/qrad3/trace.c b/tools/quake2/extra/bsp/qrad3/trace.c index bb5f4949..1b6b8f69 100644 --- a/tools/quake2/extra/bsp/qrad3/trace.c +++ b/tools/quake2/extra/bsp/qrad3/trace.c @@ -201,15 +201,6 @@ qboolean _TestLine (vec3_t start, vec3_t stop) { if (node == CONTENTS_SOLID) { -#if 0 - float d1, d2, d3; - - d1 = backx - frontx; - d2 = backy - fronty; - d3 = backz - frontz; - - if (d1*d1 + d2*d2 + d3*d3 > 1) -#endif return false; // DONE! } diff --git a/tools/quake2/extra/bsp/qvis3/flow.c b/tools/quake2/extra/bsp/qvis3/flow.c index 66af998e..4f6eff68 100644 --- a/tools/quake2/extra/bsp/qvis3/flow.c +++ b/tools/quake2/extra/bsp/qvis3/flow.c @@ -283,7 +283,6 @@ winding_t *ClipToSeperators (winding_t *source, winding_t *pass, winding_t *targ // find out which side of the generated seperating plane has the // source portal // -#if 1 fliptest = false; for (k=0 ; knumpoints ; k++) { @@ -305,9 +304,6 @@ winding_t *ClipToSeperators (winding_t *source, winding_t *pass, winding_t *targ } if (k == source->numpoints) continue; // planar with source portal -#else - fliptest = flipclip; -#endif // // flip the normal if the source portal is backwards // @@ -316,7 +312,6 @@ winding_t *ClipToSeperators (winding_t *source, winding_t *pass, winding_t *targ VectorSubtract (vec3_origin, plane.normal, plane.normal); plane.dist = -plane.dist; } -#if 1 // // if all of the pass portal points are now on the positive side, // this is the seperating plane @@ -339,16 +334,6 @@ winding_t *ClipToSeperators (winding_t *source, winding_t *pass, winding_t *targ if (!counts[0]) continue; // planar with seperating plane -#else - k = (j+1)%pass->numpoints; - d = DotProduct (pass->points[k], plane.normal) - plane.dist; - if (d < -ON_EPSILON) - continue; - k = (j+pass->numpoints-1)%pass->numpoints; - d = DotProduct (pass->points[k], plane.normal) - plane.dist; - if (d < -ON_EPSILON) - continue; -#endif // // flip the normal if we want the back side // @@ -443,15 +428,12 @@ void RecursiveLeafFlow (int leafnum, threaddata_t *thread, pstack_t *prevstack) VectorSubtract (vec3_origin, p->plane.normal, backplane.normal); backplane.dist = -p->plane.dist; -// c_portalcheck++; - stack.portal = p; stack.next = NULL; stack.freewindings[0] = 1; stack.freewindings[1] = 1; stack.freewindings[2] = 1; -#if 1 { float d; @@ -472,14 +454,8 @@ float d; continue; } } -#else - stack.pass = ChopWinding (p->winding, &stack, &thread->pstack_head.portalplane); - if (!stack.pass) - continue; -#endif -#if 1 { float d; @@ -500,11 +476,6 @@ float d; continue; } } -#else - stack.source = ChopWinding (prevstack->source, &stack, &backplane); - if (!stack.source) - continue; -#endif if (!prevstack->pass) { // the second leaf can only be blocked if coplanar diff --git a/tools/quake2/extra/common/cmdlib.c b/tools/quake2/extra/common/cmdlib.c index 60f615a0..09528093 100644 --- a/tools/quake2/extra/common/cmdlib.c +++ b/tools/quake2/extra/common/cmdlib.c @@ -285,22 +285,6 @@ double I_FloatTime (void) time (&t); return t; -#if 0 -// more precise, less portable - struct timeval tp; - struct timezone tzp; - static int secbase; - - gettimeofday(&tp, &tzp); - - if (!secbase) - { - secbase = tp.tv_sec; - return tp.tv_usec/1000000.0; - } - - return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0; -#endif } void Q_getwd (char *out) diff --git a/tools/quake2/extra/qdata/video.c b/tools/quake2/extra/qdata/video.c index b2df1493..15cec8ec 100644 --- a/tools/quake2/extra/qdata/video.c +++ b/tools/quake2/extra/qdata/video.c @@ -686,7 +686,6 @@ Error ("LZSS: too big"); for (i=0 ; i in.count) - max = in.count - i; - - start = i - BACK_WINDOW; - if (start < 0) - start = 0; - bestlength = 0; - beststart = 0; - for ( ; start < i ; start++) - { - if (in.data[start] != val) - continue; - // count match length - for (j=0 ; j bestlength) - { - bestlength = j; - beststart = start; - } - } -#endif beststart = BACK_WINDOW - (i-beststart); if (bestlength < 3) @@ -901,16 +873,6 @@ void Huffman1_Count (cblock_t in) order0counts[v]++; hnodes1[prev][v].count++; prev = v; -#if 1 - for (rept=1 ; i+rept < in.count && rept < MAX_REPT ; rept++) - if (in.data[i+rept] != v) - break; - if (rept > MIN_REPT) - { - hnodes1[prev][255+rept].count++; - i += rept-1; - } -#endif } } @@ -958,18 +920,6 @@ void Huffman1_Build (FILE *f) BuildTree1 (i); } - -#if 0 - // count up the total bits - total = 0; - for (i=0 ; i<256 ; i++) - for (j=0 ; j<256 ; j++) - total += charbitscount1[i][j] * hnodes1[i][j].count; - - total = (total+7)/8; - printf ("%i bytes huffman1 compressed\n", total); -#endif - fwrite (scaled, 1, sizeof(scaled), f); } @@ -1020,27 +970,6 @@ cblock_t Huffman1 (cblock_t in) } prev = v; -#if 1 - // check for repeat encodes - for (rept=1 ; i+rept < in.count && rept < MAX_REPT ; rept++) - if (in.data[i+rept] != v) - break; - if (rept > MIN_REPT) - { - c = charbitscount1[prev][255+rept]; - bits = charbits1[prev][255+rept]; - if (!c) - Error ("!bits"); - while (c) - { - c--; - if (bits & (1<>3] |= 1<<(outbits&7); - outbits++; - } - i += rept-1; - } -#endif } out_p += (outbits+7)>>3; @@ -1092,14 +1021,6 @@ cblock_t LoadFrame (char *base, int frame, int digits, byte **palette) in.count = width*height; // FIXME: map 0 and 255! -#if 0 - // rle compress - rle = RLE(in); - free (in.data); - - return rle; -#endif - return in; } diff --git a/tools/quake2/extra/qe4/camera.c b/tools/quake2/extra/qe4/camera.c index 8dd7d5f5..94e5b608 100644 --- a/tools/quake2/extra/qe4/camera.c +++ b/tools/quake2/extra/qe4/camera.c @@ -181,12 +181,6 @@ void Cam_MouseControl (float dtime) yl = camera.height/3; yh = yl*2; -#if 0 - // strafe - if (buttony < yl && (buttonx < xl || buttonx > xh)) - VectorMA (camera.origin, xf*dtime*MOVE_SPEED, camera.right, camera.origin); - else -#endif { xf *= 1.0 - fabs(yf); if (xf < 0) @@ -453,20 +447,6 @@ void Cam_Draw (void) glEnable(GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL); -#if 0 - - { - GLfloat fogColor[4] = {0.0, 1.0, 0.0, 0.25}; - - glFogi (GL_FOG_MODE, GL_LINEAR); - glHint (GL_FOG_HINT, GL_NICEST); /* per pixel */ - glFogf (GL_FOG_START, -8192); - glFogf (GL_FOG_END, 65536); - glFogfv (GL_FOG_COLOR, fogColor); - - } - -#endif break; case cd_blend: diff --git a/tools/quake2/extra/qe4/cmdlib.c b/tools/quake2/extra/qe4/cmdlib.c index 87565490..713cfb47 100644 --- a/tools/quake2/extra/qe4/cmdlib.c +++ b/tools/quake2/extra/qe4/cmdlib.c @@ -41,22 +41,6 @@ double I_FloatTime (void) time (&t); return t; -#if 0 -// more precise, less portable - struct timeval tp; - struct timezone tzp; - static int secbase; - - gettimeofday(&tp, &tzp); - - if (!secbase) - { - secbase = tp.tv_sec; - return tp.tv_usec/1000000.0; - } - - return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0; -#endif } diff --git a/tools/quake2/extra/qe4/eclass.c b/tools/quake2/extra/qe4/eclass.c index 466d8a48..0fc14998 100644 --- a/tools/quake2/extra/qe4/eclass.c +++ b/tools/quake2/extra/qe4/eclass.c @@ -130,13 +130,6 @@ eclass_t *Eclass_InitFromText (char *text) len = t-text; e->comments = qmalloc (len+1); memcpy (e->comments, text, len); -#if 0 - for (i=0 ; icomments[i] = '\r'; - else - e->comments[i] = text[i]; -#endif e->comments[len] = 0; return e; diff --git a/tools/quake2/extra/qe4/entity.c b/tools/quake2/extra/qe4/entity.c index 7cbe14ae..d6d09cce 100644 --- a/tools/quake2/extra/qe4/entity.c +++ b/tools/quake2/extra/qe4/entity.c @@ -223,12 +223,6 @@ entity_t *Entity_Parse (qboolean onlypairs) if (ent->brushes.onext != &ent->brushes) { printf ("Warning: Fixed size entity with brushes\n"); -#if 0 - while (ent->brushes.onext != &ent->brushes) - { // FIXME: this will free the entity and crash! - Brush_Free (b); - } -#endif ent->brushes.next = ent->brushes.prev = &ent->brushes; } // create a custom brush diff --git a/tools/quake2/extra/qe4/win_ent.c b/tools/quake2/extra/qe4/win_ent.c index 74fa9589..0477f006 100644 --- a/tools/quake2/extra/qe4/win_ent.c +++ b/tools/quake2/extra/qe4/win_ent.c @@ -264,21 +264,6 @@ void GetEntityControls(HWND ghwndEntity) Error ("CreateWindow failed"); g_qeglobals.d_hwndTexture = CreateTextureWindow (); - -#if 0 - for (i=0 ; i<12 ; i++) - { - hwndEnt[EntCheck1 + i] = CreateWindow ("button", NULL, - BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE, - 5, 100, 180, 99, - entwindow, - (void *)IDC_E_STATUS, - main_instance, - NULL); - if (!hwndEnt[EntCheck1 + i]) - Error ("CreateWindow failed"); - } -#endif } diff --git a/tools/quake2/extra/texpaint/win_skin.c b/tools/quake2/extra/texpaint/win_skin.c index bffc0d82..5e66de48 100644 --- a/tools/quake2/extra/texpaint/win_skin.c +++ b/tools/quake2/extra/texpaint/win_skin.c @@ -780,16 +780,7 @@ void ResampleSkin (void) glDisable (GL_DEPTH_TEST); glDisable (GL_CULL_FACE); BindTextureEXT (GL_TEXTURE_2D, TEXTURE_INDEX); -#if 0 - glDisable(GL_TEXTURE_2D); - glBegin (GL_LINE_LOOP); - glVertex3f (1,1,10); - glVertex3f (skin_width-1,0,10); - glVertex3f (skin_width-1,skin_height-1,10); - glVertex3f (1,skin_height-1,10); - glEnd (); - glEnable(GL_TEXTURE_2D); -#endif + glBegin (GL_TRIANGLES); for (i=0 ; i -1.0 ) ) { ( *epsilonbrush )++; } - -#if 0 - if ( *numsplits == 0 ) { // didn't really need to be split - if ( front ) { - s = PSIDE_FRONT; - } - else if ( back ) { - s = PSIDE_BACK; - } - else{ - s = 0; - } - } -#endif - return s; } @@ -633,12 +618,6 @@ int TestBrushToPlanenum( bspbrush_t *brush, int planenum, */ #define EDGE_LENGTH 0.2 qboolean WindingIsTiny( winding_t *w ){ -#if 0 - if ( WindingArea( w ) < 1 ) { - return true; - } - return false; -#else int i, j; vec_t len; vec3_t delta; @@ -657,7 +636,6 @@ qboolean WindingIsTiny( winding_t *w ){ } } return true; -#endif } /* @@ -1052,19 +1030,9 @@ void SplitBrush( bspbrush_t *brush, int planenum, if ( !cw[j] ) { continue; } -#if 0 - if ( WindingIsTiny( cw[j] ) ) { - FreeWinding( cw[j] ); - continue; - } -#endif cs = &b[j]->sides[b[j]->numsides]; b[j]->numsides++; *cs = *s; -// cs->planenum = s->planenum; -// cs->texinfo = s->texinfo; -// cs->visible = s->visible; -// cs->original = s->original; cs->winding = cw[j]; cs->tested = false; } @@ -1336,18 +1304,6 @@ tree_t *BrushBSP( bspbrush_t *brushlist, vec3_t mins, vec3_t maxs ){ Sys_FPrintf( SYS_VRB, "%5i visible nodes\n", c_nodes / 2 - c_nonvis ); Sys_FPrintf( SYS_VRB, "%5i nonvis nodes\n", c_nonvis ); Sys_FPrintf( SYS_VRB, "%5i leafs\n", ( c_nodes + 1 ) / 2 ); -#if 0 - { // debug code - static node_t *tnode; - vec3_t p; - - p[0] = -1469; - p[1] = -118; - p[2] = 119; - tnode = PointInLeaf( tree->headnode, p ); - Sys_Printf( "contents: %i\n", tnode->contents ); - p[0] = 0; - } -#endif + return tree; } diff --git a/tools/quake2/q2map/csg.c b/tools/quake2/q2map/csg.c index 0b0bda93..321aee2d 100644 --- a/tools/quake2/q2map/csg.c +++ b/tools/quake2/q2map/csg.c @@ -53,14 +53,6 @@ void SplitBrush2( bspbrush_t *brush, int planenum, bspbrush_t **front, bspbrush_t **back ){ SplitBrush( brush, planenum, front, back ); -#if 0 - if ( *front && ( *front )->sides[( *front )->numsides - 1].texinfo == -1 ) { - ( *front )->sides[( *front )->numsides - 1].texinfo = ( *front )->sides[0].texinfo; // not -1 - } - if ( *back && ( *back )->sides[( *back )->numsides - 1].texinfo == -1 ) { - ( *back )->sides[( *back )->numsides - 1].texinfo = ( *back )->sides[0].texinfo; // not -1 - } -#endif } /* @@ -293,11 +285,6 @@ bspbrush_t *MakeBspBrushList( int startbrush, int endbrush, if ( mb->original_sides[j].visible && mb->original_sides[j].winding ) { vis++; } -#if 0 - if ( !vis ) { - continue; // no faces at all - } -#endif // if the brush is outside the clip area, skip it for ( j = 0 ; j < 3 ; j++ ) if ( mb->mins[j] >= clipmaxs[j] @@ -469,11 +456,6 @@ bspbrush_t *ChopBrushes( bspbrush_t *head ){ Sys_FPrintf( SYS_VRB, "---- ChopBrushes ----\n" ); Sys_FPrintf( SYS_VRB, "original brushes: %i\n", CountBrushList( head ) ); -#if 0 - if ( startbrush == 0 ) { - WriteBrushList( "before.gl", head, false ); - } -#endif keep = NULL; newlist: @@ -565,12 +547,6 @@ newlist: } Sys_FPrintf( SYS_VRB, "output brushes: %i\n", CountBrushList( keep ) ); -#if 0 - { - WriteBrushList( "after.gl", keep, false ); - WriteBrushMap( "after.map", keep ); - } -#endif return keep; } @@ -589,15 +565,6 @@ bspbrush_t *InitialBrushList( bspbrush_t *list ){ out = NULL; for ( b = list ; b ; b = b->next ) { -#if 0 - for ( i = 0 ; i < b->numsides ; i++ ) - if ( b->sides[i].visible ) { - break; - } - if ( i == b->numsides ) { - continue; - } -#endif newb = CopyBrush( b ); newb->next = out; out = newb; @@ -607,7 +574,6 @@ bspbrush_t *InitialBrushList( bspbrush_t *list ){ for ( i = 0 ; i < b->numsides ; i++ ) { newb->sides[i].original = &b->sides[i]; -// newb->sides[i].visible = true; b->sides[i].visible = false; } } diff --git a/tools/quake2/q2map/faces.c b/tools/quake2/q2map/faces.c index 7607dbc2..d57620dd 100644 --- a/tools/quake2/q2map/faces.c +++ b/tools/quake2/q2map/faces.c @@ -337,16 +337,6 @@ void FindEdgeVerts( vec3_t v1, vec3_t v2 ){ int x1, x2, y1, y2, t; int x, y; int vnum; - -#if 0 - { - int i; - num_edge_verts = numvertexes - 1; - for ( i = 0 ; i < numvertexes - 1 ; i++ ) - edge_verts[i] = i + 1; - } -#endif - x1 = ( 4096 + (int)( v1[0] + 0.5 ) ) >> 7; y1 = ( 4096 + (int)( v1[1] + 0.5 ) ) >> 7; x2 = ( 4096 + (int)( v2[0] + 0.5 ) ) >> 7; @@ -362,24 +352,6 @@ void FindEdgeVerts( vec3_t v1, vec3_t v2 ){ y1 = y2; y2 = t; } -#if 0 - x1--; - x2++; - y1--; - y2++; - if ( x1 < 0 ) { - x1 = 0; - } - if ( x2 >= HASH_SIZE ) { - x2 = HASH_SIZE; - } - if ( y1 < 0 ) { - y1 = 0; - } - if ( y2 >= HASH_SIZE ) { - y2 = HASH_SIZE; - } -#endif num_edge_verts = 0; for ( x = x1 ; x <= x2 ; x++ ) { @@ -651,12 +623,6 @@ int GetEdge2( int v1, int v2, face_t *f ){ edgefaces[i][1] = f; return -i; } - #if 0 - if ( v1 == edge->v[0] && v2 == edge->v[1] ) { - Sys_Printf( "WARNING: multiple forward edge\n" ); - return i; - } - #endif } } @@ -929,11 +895,6 @@ void SubdivideFace( node_t *node, face_t *f ){ maxs = v; } } -#if 0 - if ( maxs - mins <= 0 ) { - Error( "zero extents" ); - } -#endif if ( axis == 2 ) { // allow double high walls if ( maxs - mins <= subdivide_size /* *2 */ ) { break; diff --git a/tools/quake2/q2map/flow.c b/tools/quake2/q2map/flow.c index 587e1902..199a3be1 100644 --- a/tools/quake2/q2map/flow.c +++ b/tools/quake2/q2map/flow.c @@ -283,7 +283,6 @@ winding_t *ClipToSeperators( winding_t *source, winding_t *pass, winding_t *ta // find out which side of the generated seperating plane has the // source portal // -#if 1 fliptest = false; for ( k = 0 ; k < source->numpoints ; k++ ) { @@ -305,9 +304,7 @@ winding_t *ClipToSeperators( winding_t *source, winding_t *pass, winding_t *ta if ( k == source->numpoints ) { continue; // planar with source portal } -#else - fliptest = flipclip; -#endif + // // flip the normal if the source portal is backwards // @@ -315,7 +312,7 @@ winding_t *ClipToSeperators( winding_t *source, winding_t *pass, winding_t *ta VectorSubtract( vec3_origin, plane.normal, plane.normal ); plane.dist = -plane.dist; } -#if 1 + // // if all of the pass portal points are now on the positive side, // this is the seperating plane @@ -344,18 +341,7 @@ winding_t *ClipToSeperators( winding_t *source, winding_t *pass, winding_t *ta if ( !counts[0] ) { continue; // planar with seperating plane } -#else - k = ( j + 1 ) % pass->numpoints; - d = DotProduct( pass->points[k], plane.normal ) - plane.dist; - if ( d < -ON_EPSILON ) { - continue; - } - k = ( j + pass->numpoints - 1 ) % pass->numpoints; - d = DotProduct( pass->points[k], plane.normal ) - plane.dist; - if ( d < -ON_EPSILON ) { - continue; - } -#endif + // // flip the normal if we want the back side // @@ -446,15 +432,12 @@ void RecursiveLeafFlow( int leafnum, threaddata_t *thread, pstack_t *prevstack ) VectorSubtract( vec3_origin, p->plane.normal, backplane.normal ); backplane.dist = -p->plane.dist; -// c_portalcheck++; - stack.portal = p; stack.next = NULL; stack.freewindings[0] = 1; stack.freewindings[1] = 1; stack.freewindings[2] = 1; -#if 1 { float d; @@ -474,15 +457,7 @@ void RecursiveLeafFlow( int leafnum, threaddata_t *thread, pstack_t *prevstack ) } } } -#else - stack.pass = Vis_ChopWinding( p->winding, &stack, &thread->pstack_head.portalplane ); - if ( !stack.pass ) { - continue; - } -#endif - -#if 1 { float d; @@ -502,12 +477,6 @@ void RecursiveLeafFlow( int leafnum, threaddata_t *thread, pstack_t *prevstack ) } } } -#else - stack.source = Vis_ChopWinding( prevstack->source, &stack, &backplane ); - if ( !stack.source ) { - continue; - } -#endif if ( !prevstack->pass ) { // the second leaf can only be blocked if coplanar diff --git a/tools/quake2/q2map/gldraw.c b/tools/quake2/q2map/gldraw.c index 55c8becf..418774b3 100644 --- a/tools/quake2/q2map/gldraw.c +++ b/tools/quake2/q2map/gldraw.c @@ -77,18 +77,6 @@ void Draw_ClearWindow( void ){ glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); -#if 0 - glColor4f( 1,0,0,0.5 ); - glBegin( GL_POLYGON ); - - glVertex3f( 0, 500, 0 ); - glVertex3f( 0, 900, 0 ); - glVertex3f( 0, 900, 100 ); - glVertex3f( 0, 500, 100 ); - - glEnd(); -#endif - glFlush(); } diff --git a/tools/quake2/q2map/lightmap.c b/tools/quake2/q2map/lightmap.c index 70c04585..abd23d26 100644 --- a/tools/quake2/q2map/lightmap.c +++ b/tools/quake2/q2map/lightmap.c @@ -1194,11 +1194,6 @@ void FinalLightFace( int facenum ){ lightdatasize += fl->numstyles * ( fl->numsamples * 3 ); // add green sentinals between lightmaps -#if 0 - lightdatasize += 64 * 3; - for ( i = 0 ; i < 64 ; i++ ) - dlightdata[lightdatasize - ( i + 1 ) * 3 + 1] = 255; -#endif if ( lightdatasize > MAX_MAP_LIGHTING ) { Error( "MAX_MAP_LIGHTING" ); diff --git a/tools/quake2/q2map/map.c b/tools/quake2/q2map/map.c index ed68ccae..ddfd709a 100644 --- a/tools/quake2/q2map/map.c +++ b/tools/quake2/q2map/map.c @@ -100,7 +100,6 @@ int PlaneTypeForNormal( vec3_t normal ){ #define NORMAL_EPSILON 0.00001 #define DIST_EPSILON 0.01 qboolean PlaneEqual( plane_t *p, vec3_t normal, vec_t dist ){ -#if 1 if ( fabs( p->normal[0] - normal[0] ) < NORMAL_EPSILON && fabs( p->normal[1] - normal[1] ) < NORMAL_EPSILON @@ -108,14 +107,6 @@ qboolean PlaneEqual( plane_t *p, vec3_t normal, vec_t dist ){ && fabs( p->dist - dist ) < DIST_EPSILON ) { return true; } -#else - if ( p->normal[0] == normal[0] - && p->normal[1] == normal[1] - && p->normal[2] == normal[2] - && p->dist == dist ) { - return true; - } -#endif return false; } @@ -796,11 +787,6 @@ void MoveBrushesToWorld( entity_t *mapent ){ temp = malloc( newbrushes * sizeof( mapbrush_t ) ); memcpy( temp, mapbrushes + mapent->firstbrush, newbrushes * sizeof( mapbrush_t ) ); -#if 0 // let them keep their original brush numbers - for ( i = 0 ; i < newbrushes ; i++ ) - temp[i].entitynum = 0; -#endif - // make space to move the brushes (overlapped copy) memmove( mapbrushes + worldbrushes + newbrushes, mapbrushes + worldbrushes, diff --git a/tools/quake2/q2map/patches.c b/tools/quake2/q2map/patches.c index 1e8b91c8..bcd2e951 100644 --- a/tools/quake2/q2map/patches.c +++ b/tools/quake2/q2map/patches.c @@ -102,11 +102,6 @@ void CalcTextureReflectivity_Quake2( void ){ scale *= 2; VectorScale( texture_reflectivity[i], scale, texture_reflectivity[i] ); } -#if 0 - texture_reflectivity[i][0] = 0.5; - texture_reflectivity[i][1] = 0.5; - texture_reflectivity[i][2] = 0.5; -#endif } } diff --git a/tools/quake2/q2map/portals.c b/tools/quake2/q2map/portals.c index 1c83d75d..c7fae604 100644 --- a/tools/quake2/q2map/portals.c +++ b/tools/quake2/q2map/portals.c @@ -776,12 +776,6 @@ void FloodAreas_r( node_t *node ){ for ( p = node->portals ; p ; p = p->next[s] ) { - s = ( p->nodes[1] == node ); -#if 0 - if ( p->nodes[!s]->occupied ) { - continue; - } -#endif if ( !Portal_EntityFlood( p, s ) ) { continue; } diff --git a/tools/quake2/q2map/trace.c b/tools/quake2/q2map/trace.c index af1edfa2..00c933a1 100644 --- a/tools/quake2/q2map/trace.c +++ b/tools/quake2/q2map/trace.c @@ -203,15 +203,6 @@ qboolean _TestLine( vec3_t start, vec3_t stop ){ while ( 1 ) { if ( node == CONTENTS_SOLID ) { -#if 0 - float d1, d2, d3; - - d1 = backx - frontx; - d2 = backy - fronty; - d3 = backz - frontz; - - if ( d1 * d1 + d2 * d2 + d3 * d3 > 1 ) -#endif return false; // DONE! } diff --git a/tools/quake2/q2map/writebsp.c b/tools/quake2/q2map/writebsp.c index 0d3c6a48..9a54e090 100644 --- a/tools/quake2/q2map/writebsp.c +++ b/tools/quake2/q2map/writebsp.c @@ -502,23 +502,10 @@ void BeginBSPFile( void ){ void EndBSPFile( void ){ char path[1024]; -#if 0 - int len; - byte *buf; -#endif - EmitBrushes(); EmitPlanes(); UnparseEntities(); - // load the pop -#if 0 - sprintf( path, "%s/pics/pop.lmp", gamedir ); - len = LoadFile( path, &buf ); - memcpy( dpop, buf, sizeof( dpop ) ); - free( buf ); -#endif - // write the map sprintf( path, "%s.bsp", source ); Sys_Printf( "Writing %s\n", path ); diff --git a/tools/quake2/qdata/video.c b/tools/quake2/qdata/video.c index 0fc06757..424d04a3 100644 --- a/tools/quake2/qdata/video.c +++ b/tools/quake2/qdata/video.c @@ -678,7 +678,6 @@ cblock_t LZSS( cblock_t in ){ for ( i = 0 ; i < in.count ; ) { val = in.data[i]; -#if 1 // chained search bestlength = 0; beststart = 0; @@ -703,36 +702,6 @@ cblock_t LZSS( cblock_t in ){ start = lzss_next[start]; } -#else -// slow simple search - // search for a match - max = FRONT_WINDOW; - if ( i + max > in.count ) { - max = in.count - i; - } - - start = i - BACK_WINDOW; - if ( start < 0 ) { - start = 0; - } - bestlength = 0; - beststart = 0; - for ( ; start < i ; start++ ) - { - if ( in.data[start] != val ) { - continue; - } - // count match length - for ( j = 0 ; j < max ; j++ ) - if ( in.data[start + j] != in.data[i + j] ) { - break; - } - if ( j > bestlength ) { - bestlength = j; - beststart = start; - } - } -#endif beststart = BACK_WINDOW - ( i - beststart ); if ( bestlength < 3 ) { // output a single char @@ -899,7 +868,6 @@ void Huffman1_Count( cblock_t in ){ order0counts[v]++; hnodes1[prev][v].count++; prev = v; -#if 1 for ( rept = 1 ; i + rept < in.count && rept < MAX_REPT ; rept++ ) if ( in.data[i + rept] != v ) { break; @@ -908,7 +876,6 @@ void Huffman1_Count( cblock_t in ){ hnodes1[prev][255 + rept].count++; i += rept - 1; } -#endif } } @@ -960,18 +927,6 @@ void Huffman1_Build( FILE *f ){ BuildTree1( i ); } - -#if 0 - // count up the total bits - total = 0; - for ( i = 0 ; i < 256 ; i++ ) - for ( j = 0 ; j < 256 ; j++ ) - total += charbitscount1[i][j] * hnodes1[i][j].count; - - total = ( total + 7 ) / 8; - printf( "%i bytes huffman1 compressed\n", total ); -#endif - fwrite( scaled, 1, sizeof( scaled ), f ); } @@ -1023,7 +978,6 @@ cblock_t Huffman1( cblock_t in ){ } prev = v; -#if 1 // check for repeat encodes for ( rept = 1 ; i + rept < in.count && rept < MAX_REPT ; rept++ ) if ( in.data[i + rept] != v ) { @@ -1045,7 +999,6 @@ cblock_t Huffman1( cblock_t in ){ } i += rept - 1; } -#endif } out_p += ( outbits + 7 ) >> 3; @@ -1097,14 +1050,6 @@ cblock_t LoadFrame( char *base, int frame, int digits, byte **palette ){ in.count = width * height; // FIXME: map 0 and 255! -#if 0 - // rle compress - rle = RLE( in ); - free( in.data ); - - return rle; -#endif - return in; } diff --git a/tools/quake2/qdata_heretic2/common/cmdlib.c b/tools/quake2/qdata_heretic2/common/cmdlib.c index 514a1c7b..21c1ef0d 100644 --- a/tools/quake2/qdata_heretic2/common/cmdlib.c +++ b/tools/quake2/qdata_heretic2/common/cmdlib.c @@ -322,21 +322,6 @@ double I_FloatTime( void ){ time( &t ); return t; -#if 0 -// more precise, less portable - struct timeval tp; - struct timezone tzp; - static int secbase; - - gettimeofday( &tp, &tzp ); - - if ( !secbase ) { - secbase = tp.tv_sec; - return tp.tv_usec / 1000000.0; - } - - return ( tp.tv_sec - secbase ) + tp.tv_usec / 1000000.0; -#endif } void Q_getwd( char *out ){ diff --git a/tools/quake2/qdata_heretic2/common/inout.c b/tools/quake2/qdata_heretic2/common/inout.c index 30ae39df..ffef9e10 100644 --- a/tools/quake2/qdata_heretic2/common/inout.c +++ b/tools/quake2/qdata_heretic2/common/inout.c @@ -106,33 +106,6 @@ void xml_SendNode( xmlNodePtr node ){ pos += size; } -#if 0 - // NOTE: the NMSG_WriteString is limited to MAX_NETMESSAGE - // we will need to split into chunks - // (we could also go lower level, in the end it's using send and receiv which are not size limited) - //++timo FIXME: MAX_NETMESSAGE is not exactly the max size we can stick in the message - // there's some tweaking to do in l_net for that .. so let's give us a margin for now - - //++timo we need to handle the case of a buffer too big to fit in a single message - // try without checks for now - if ( xml_buf->use > MAX_NETMESSAGE - 10 ) { - // if we send that we are probably gonna break the stream at the other end.. - // and Error will call right there - //Error( "MAX_NETMESSAGE exceeded for XML feedback stream in FPrintf (%d)\n", xml_buf->use); - Sys_FPrintf( SYS_NOXML, "MAX_NETMESSAGE exceeded for XML feedback stream in FPrintf (%d)\n", xml_buf->use ); - xml_buf->content[xml_buf->use] = '\0'; //++timo this corrupts the buffer but we don't care it's for printing - Sys_FPrintf( SYS_NOXML, xml_buf->content ); - - } - - size = xml_buf->use; - memcpy( xmlbuf, xml_buf->content, size ); - xmlbuf[size] = '\0'; - NMSG_Clear( &msg ); - NMSG_WriteString( &msg, xmlbuf ); - Net_Send( brdcst_socket, &msg ); -#endif - xmlBufferFree( xml_buf ); } } diff --git a/tools/quake2/qdata_heretic2/common/trilib.c b/tools/quake2/qdata_heretic2/common/trilib.c index 847b8090..aa7429ab 100644 --- a/tools/quake2/qdata_heretic2/common/trilib.c +++ b/tools/quake2/qdata_heretic2/common/trilib.c @@ -31,9 +31,7 @@ #include "token.h" #include "l3dslib.h" #include "fmodel.h" -#if 1 #include "qd_skeletons.h" -#endif // on disk representation of a face #define FLOAT_START 99999.0 @@ -424,28 +422,12 @@ void HandleHRCModel( triangle_t **triList, int *triangleCount, mesh_node_t **nod tList[i + start_tri].verts[2 - j][0] = vList[tk_IntNumber].v[0]; tList[i + start_tri].verts[2 - j][1] = vList[tk_IntNumber].v[1]; tList[i + start_tri].verts[2 - j][2] = vList[tk_IntNumber].v[2]; -#if 1 - tList[i + start_tri].indicies[2 - j] = tk_IntNumber + vertIndexBase; -#endif TK_BeyondRequire( TK_UVTEXTURE, TK_FLOATNUMBER ); tList[i + start_tri].uv[2 - j][0] = tk_FloatNumber; TK_Fetch(); TK_Require( TK_FLOATNUMBER ); tList[i + start_tri].uv[2 - j][1] = tk_FloatNumber; } - - /* printf("Face %i:\n v0: %f, %f, %f\n v1: %f, %f, %f\n" - " v2: %f, %f, %f\n", i, - tList[i].verts[0][0], - tList[i].verts[0][1], - tList[i].verts[0][2], - tList[i].verts[1][0], - tList[i].verts[1][1], - tList[i].verts[1][2], - tList[i].verts[2][0], - tList[i].verts[2][1], - tList[i].verts[2][2]); - */ } TK_Beyond( TK_RBRACE ); @@ -462,7 +444,6 @@ void HandleHRCModel( triangle_t **triList, int *triangleCount, mesh_node_t **nod // See if there are any other models belonging to this node -#if 1 TK_Fetch(); nextToken = tk_Token; @@ -490,7 +471,6 @@ void HandleHRCModel( triangle_t **triList, int *triangleCount, mesh_node_t **nod meshNode->clustered = false; } } -#endif nextToken = tk_Token; if ( nextToken == TK_SPLINE ) { @@ -903,7 +883,6 @@ static void LoadHTR( char *fileName, triangle_t **triList, int *triangleCount, m tList[i].verts[2 - j][2] = vList[vertexNum].v[2]; } TK_FetchRequire( TK_RPAREN ); -#if 1 if ( Version2 ) { TK_FetchRequire( TK_FLOATNUMBER ); tList[i].uv[2][0] = fmod( 1000 + tk_FloatNumber,1 ); @@ -922,19 +901,6 @@ static void LoadHTR( char *fileName, triangle_t **triList, int *triangleCount, m else{ tList[i].HasUV = 0; } -#endif -/* printf("Face %i:\n v0: %f, %f, %f\n v1: %f, %f, %f\n" - " v2: %f, %f, %f\n", i, - tList[i].verts[0][0], - tList[i].verts[0][1], - tList[i].verts[0][2], - tList[i].verts[1][0], - tList[i].verts[1][1], - tList[i].verts[1][2], - tList[i].verts[2][0], - tList[i].verts[2][1], - tList[i].verts[2][2]); - */ } free( vList ); diff --git a/tools/quake2/qdata_heretic2/common/trilib.h b/tools/quake2/qdata_heretic2/common/trilib.h index 1e3e82c1..87105c23 100644 --- a/tools/quake2/qdata_heretic2/common/trilib.h +++ b/tools/quake2/qdata_heretic2/common/trilib.h @@ -30,11 +30,9 @@ typedef struct { vec3_t verts[3]; -#if 1 int indicies[3]; float uv[3][2]; qboolean HasUV; -#endif } triangle_t; #define NUM_CLUSTERS 8 diff --git a/tools/quake2/qdata_heretic2/fmodels.c b/tools/quake2/qdata_heretic2/fmodels.c index a3e06c0b..ae9a88ee 100644 --- a/tools/quake2/qdata_heretic2/fmodels.c +++ b/tools/quake2/qdata_heretic2/fmodels.c @@ -2674,7 +2674,6 @@ void Cmd_FMSkin( void ){ } else { - #if 1 miptex_t *qtex; qtex = CreateMip( cropped, fmheader.skinwidth, fmheader.skinheight, palette, &size, true ); @@ -2685,15 +2684,6 @@ void Cmd_FMSkin( void ){ CreatePath( savename ); SaveFile( savename, (byte *)qtex, size ); free( qtex ); - #else - strcat( g_skins[fmheader.num_skins - 1],".pcx" ); - strcat( savename,".pcx" ); - - // save off the new image - printf( "saving %s\n", savename ); - CreatePath( savename ); - WritePCXfile( savename, cropped, fmheader.skinwidth, fmheader.skinheight, palette ); - #endif } } else diff --git a/tools/quake2/qdata_heretic2/images.c b/tools/quake2/qdata_heretic2/images.c index 3b07715a..86abaf97 100644 --- a/tools/quake2/qdata_heretic2/images.c +++ b/tools/quake2/qdata_heretic2/images.c @@ -27,9 +27,7 @@ #include -#if 1 extern char *g_outputDir; -#endif // _QDATA char mip_prefix[1024]; // directory to dump the textures in @@ -42,42 +40,6 @@ unsigned total_textures = 0; #define MAX_IMAGE_SIZE 512 -#if 0 -/* - ============== - RemapZero - - Replaces all 0 bytes in an image with the closest palette entry. - This is because NT won't let us change index 0, so any palette - animation leaves those pixels untouched. - ============== - */ -void RemapZero( byte *pixels, byte *palette, int width, int height ){ - int i, c; - int alt_zero; - int value, best; - - alt_zero = 0; - best = 9999999; - for ( i = 1 ; i < 255 ; i++ ) - { - value = palette[i * 3 + 0] + palette[i * 3 + 1] + palette[i * 3 + 2]; - if ( value < best ) { - best = value; - alt_zero = i; - } - } - - c = width * height; - for ( i = 0 ; i < c ; i++ ) - if ( pixels[i] == 0 ) { - pixels[i] = alt_zero; - } -} - -#endif - - // ******************************************************************** // ** Mip Map Pre-Processing Routines // ******************************************************************** diff --git a/tools/quake2/qdata_heretic2/joints.h b/tools/quake2/qdata_heretic2/joints.h index 074734e9..99e58910 100644 --- a/tools/quake2/qdata_heretic2/joints.h +++ b/tools/quake2/qdata_heretic2/joints.h @@ -41,13 +41,11 @@ typedef struct Placement_s vec3_t up; } Placement_t; -#if 1 typedef struct QDataJoint_s { Placement_t placement; vec3_t rotation; } QDataJoint_t; -#endif typedef struct ArrayedListNode_s { diff --git a/tools/quake2/qdata_heretic2/models.c b/tools/quake2/qdata_heretic2/models.c index 22336817..639c7ab4 100644 --- a/tools/quake2/qdata_heretic2/models.c +++ b/tools/quake2/qdata_heretic2/models.c @@ -156,7 +156,6 @@ void H_printf( char *fmt, ... ){ va_end( argptr ); } -#if 1 /* ============ WriteModelFile @@ -392,126 +391,6 @@ void WriteJointedModelFile( FILE *modelouthandle ){ } } } -#else -/* - ============ - WriteModelFile - ============ - */ -static void WriteModelFile( FILE *modelouthandle ){ - int i; - dmdl_t modeltemp; - int j, k; - frame_t *in; - daliasframe_t *out; - byte buffer[MAX_VERTS * 4 + 128]; - float v; - int c_on, c_off; - - model.ident = IDALIASHEADER; - model.version = ALIAS_VERSION; - model.framesize = (int)&( (daliasframe_t *)0 )->verts[model.num_xyz]; - model.num_glcmds = numcommands; - model.ofs_skins = sizeof( dmdl_t ); - model.ofs_st = model.ofs_skins + model.num_skins * MAX_SKINNAME; - model.ofs_tris = model.ofs_st + model.num_st * sizeof( dstvert_t ); - model.ofs_frames = model.ofs_tris + model.num_tris * sizeof( dtriangle_t ); - model.ofs_glcmds = model.ofs_frames + model.num_frames * model.framesize; - model.ofs_end = model.ofs_glcmds + model.num_glcmds * 4; - - // - // write out the model header - // - for ( i = 0 ; i < sizeof( dmdl_t ) / 4 ; i++ ) - ( (int *)&modeltemp )[i] = LittleLong( ( (int *)&model )[i] ); - - SafeWrite( modelouthandle, &modeltemp, sizeof( modeltemp ) ); - - // - // write out the skin names - // - SafeWrite( modelouthandle, g_skins, model.num_skins * MAX_SKINNAME ); - - // - // write out the texture coordinates - // - c_on = c_off = 0; - for ( i = 0 ; i < model.num_st ; i++ ) - { - base_st[i].s = LittleShort( base_st[i].s ); - base_st[i].t = LittleShort( base_st[i].t ); - } - - SafeWrite( modelouthandle, base_st, model.num_st * sizeof( base_st[0] ) ); - - // - // write out the triangles - // - for ( i = 0 ; i < model.num_tris ; i++ ) - { - int j; - dtriangle_t tri; - - for ( j = 0 ; j < 3 ; j++ ) - { - tri.index_xyz[j] = LittleShort( triangles[i].index_xyz[j] ); - tri.index_st[j] = LittleShort( triangles[i].index_st[j] ); - } - - SafeWrite( modelouthandle, &tri, sizeof( tri ) ); - } - - // - // write out the frames - // - for ( i = 0 ; i < model.num_frames ; i++ ) - { - in = &g_frames[i]; - out = (daliasframe_t *)buffer; - - strcpy( out->name, in->name ); - for ( j = 0 ; j < 3 ; j++ ) - { - out->scale[j] = ( in->maxs[j] - in->mins[j] ) / 255; - out->translate[j] = in->mins[j]; - } - - for ( j = 0 ; j < model.num_xyz ; j++ ) - { - // all of these are byte values, so no need to deal with endianness - out->verts[j].lightnormalindex = in->v[j].lightnormalindex; - - for ( k = 0 ; k < 3 ; k++ ) - { - // scale to byte values & min/max check - v = Q_rint( ( in->v[j].v[k] - out->translate[k] ) / out->scale[k] ); - - // clamp, so rounding doesn't wrap from 255.6 to 0 - if ( v > 255.0 ) { - v = 255.0; - } - if ( v < 0 ) { - v = 0; - } - out->verts[j].v[k] = v; - } - } - - for ( j = 0 ; j < 3 ; j++ ) - { - out->scale[j] = LittleFloat( out->scale[j] ); - out->translate[j] = LittleFloat( out->translate[j] ); - } - - SafeWrite( modelouthandle, out, model.framesize ); - } - - // - // write out glcmds - // - SafeWrite( modelouthandle, commands, numcommands * 4 ); -} -#endif /* =============== @@ -560,12 +439,10 @@ void FinishModel( void ){ CreatePath( name ); modelouthandle = SafeOpenWrite( name ); -#if 1 if ( jointed != NOT_JOINTED ) { WriteJointedModelFile( modelouthandle ); } else -#endif WriteModelFile( modelouthandle ); printf( "%3dx%3d skin\n", model.skinwidth, model.skinheight ); @@ -886,106 +763,6 @@ static void BuildGlCmds( void ){ =============================================================== */ -/* - ============ - BuildST - - Builds the triangle_st array for the base frame and - model.skinwidth / model.skinheight - - FIXME: allow this to be loaded from a file for - arbitrary mappings - ============ - */ -#if 0 -static void OldBuildST( triangle_t *ptri, int numtri ){ - int i, j; - int width, height, iwidth, iheight, swidth; - float basex, basey; - float s_scale, t_scale; - float scale; - vec3_t mins, maxs; - float *pbasevert; - vec3_t vtemp1, vtemp2, normal; - - // - // find bounds of all the verts on the base frame - // - ClearBounds( mins, maxs ); - - for ( i = 0 ; i < numtri ; i++ ) - for ( j = 0 ; j < 3 ; j++ ) - AddPointToBounds( ptri[i].verts[j], mins, maxs ); - - for ( i = 0 ; i < 3 ; i++ ) - { - mins[i] = floor( mins[i] ); - maxs[i] = ceil( maxs[i] ); - } - - width = maxs[0] - mins[0]; - height = maxs[2] - mins[2]; - - if ( !g_fixedwidth ) { // old style - scale = 8; - if ( width * scale >= 150 ) { - scale = 150.0 / width; - } - if ( height * scale >= 190 ) { - scale = 190.0 / height; - } - - s_scale = t_scale = scale; - - iwidth = ceil( width * s_scale ); - iheight = ceil( height * t_scale ); - - iwidth += 4; - iheight += 4; - } - else - { // new style - iwidth = g_fixedwidth / 2; - iheight = g_fixedheight; - - s_scale = (float)( iwidth - 4 ) / width; - t_scale = (float)( iheight - 4 ) / height; - } - -// -// determine which side of each triangle to map the texture to -// - for ( i = 0 ; i < numtri ; i++ ) - { - VectorSubtract( ptri[i].verts[0], ptri[i].verts[1], vtemp1 ); - VectorSubtract( ptri[i].verts[2], ptri[i].verts[1], vtemp2 ); - CrossProduct( vtemp1, vtemp2, normal ); - - if ( normal[1] > 0 ) { - basex = iwidth + 2; - } - else - { - basex = 2; - } - basey = 2; - - for ( j = 0 ; j < 3 ; j++ ) - { - pbasevert = ptri[i].verts[j]; - - triangle_st[i][j][0] = Q_rint( ( pbasevert[0] - mins[0] ) * s_scale + basex ); - triangle_st[i][j][1] = Q_rint( ( maxs[2] - pbasevert[2] ) * t_scale + basey ); - } - } - -// make the width a multiple of 4; some hardware requires this, and it ensures -// dword alignment for each scan - swidth = iwidth * 2; - model.skinwidth = ( swidth + 3 ) & ~3; - model.skinheight = iheight; -} -#endif //========================================================================== // @@ -1187,10 +964,6 @@ void Cmd_Base( void ){ vec3_t base_xyz[MAX_VERTS]; triangle_t *ptri; int i, j, k; -#if 1 -#else - int time1; -#endif char file1[1024]; char file2[1024]; @@ -1201,26 +974,12 @@ void Cmd_Base( void ){ } printf( "---------------------\n" ); -#if 1 sprintf( file1, "%s/%s", cdpartial, token ); printf( "%s ", file1 ); ExpandPathAndArchive( file1 ); sprintf( file1, "%s/%s", cddir, token ); -#else - sprintf( file1, "%s/%s.%s", cdarchive, token, trifileext ); - printf( "%s\n", file1 ); - - ExpandPathAndArchive( file1 ); - - sprintf( file1, "%s/%s.%s", cddir, token, trifileext ); - - time1 = FileTime( file1 ); - if ( time1 == -1 ) { - Error( "%s doesn't exist", file1 ); - } -#endif // // load the base triangles // @@ -1622,26 +1381,9 @@ void Cmd_Skin( void ){ return; } -#if 1 sprintf( name, "%s/%s.pcx", cddir, token ); sprintf( savename, "%s/!%s.pcx", g_outputDir, token ); sprintf( g_skins[model.num_skins], "%s/!%s.pcx", cdpartial, token ); -#else - sprintf( name, "%s/%s.lbm", cdarchive, token ); - strcpy( name, ExpandPathAndArchive( name ) ); -// sprintf (name, "%s/%s.lbm", cddir, token); - - if ( ScriptTokenAvailable() ) { - GetScriptToken( false ); - sprintf( g_skins[model.num_skins], "%s.pcx", token ); - sprintf( savename, "%s%s.pcx", g_outputDir, g_skins[model.num_skins] ); - } - else - { - sprintf( savename, "%s/%s.pcx", g_outputDir, token ); - sprintf( g_skins[model.num_skins], "%s/%s.pcx", cdpartial, token ); - } -#endif model.num_skins++; diff --git a/tools/quake2/qdata_heretic2/qcommon/resourcemanager.c b/tools/quake2/qdata_heretic2/qcommon/resourcemanager.c index 2b5a40bb..e8dbc438 100644 --- a/tools/quake2/qdata_heretic2/qcommon/resourcemanager.c +++ b/tools/quake2/qdata_heretic2/qcommon/resourcemanager.c @@ -89,14 +89,6 @@ H2COMMON_API void ResMngr_Con( ResourceManager_t *resource, size_t init_resSize, H2COMMON_API void ResMngr_Des( ResourceManager_t *resource ){ ResMngr_Block_t *toDelete; -#if 0 - if ( resource->numResourcesAllocated ) { - char mess[100]; - sprintf( mess,"Potential memory leak %d bytes unfreed\n",resource->resSize * resource->numResourcesAllocated ); - OutputDebugString( mess ); - } -#endif - while ( resource->blockList ) { toDelete = resource->blockList; diff --git a/tools/quake2/qdata_heretic2/qd_skeletons.c b/tools/quake2/qdata_heretic2/qd_skeletons.c index 4001078d..f8c79cde 100644 --- a/tools/quake2/qdata_heretic2/qd_skeletons.c +++ b/tools/quake2/qdata_heretic2/qd_skeletons.c @@ -85,84 +85,7 @@ static void LoadHRCClustered( char *fileName, int **clusterList, int *num_verts, // mesh_node_t *nodesList; int num_mesh_nodes = 0, triangleCount = 0; -#if 0 - int i; - int j, numVerts; - char stripped[SKELETAL_NAME_MAX]; - - for ( i = 1; i < numJointsInSkeleton[skelType] + 1; ++i ) - { - num_verts[i] = 0; - } - - TK_OpenSource( fileName ); - TK_FetchRequire( TK_HRCH ); - TK_FetchRequire( TK_COLON ); - TK_FetchRequire( TK_SOFTIMAGE ); - - TK_Beyond( TK_CLUSTERS ); - - while ( TK_Search( TK_CLUSTER_NAME ) != TK_EOF ) - { - TK_Require( TK_STRING ); - - StripTrailingDigits( tk_String, stripped ); - - for ( i = 0; i < numJointsInSkeleton[skelType]; ++i ) - { - if ( stricmp( stripped, skeletonJointNames[skeletonNameOffsets[skelType] + i] ) == 0 ) { - i = -i + numJointsInSkeleton[skelType] - 1; - - TK_BeyondRequire( TK_NUM_CLUSTER_VERTICES, TK_INTNUMBER ); - - numVerts = tk_IntNumber; - - if ( !num_verts[i + 1] ) { // first set of verts for cluster - clusterList[i] = SafeMalloc( numVerts * sizeof( int ), "LoadHRCClustered" ); - assert( clusterList[i] ); - } - else // any later sets of verts need to copy current - { - int *temp; - - temp = SafeMalloc( ( num_verts[i + 1] + numVerts ) * sizeof( int ), "LoadHRCClustered" ); - assert( temp ); - - memcpy( temp + numVerts, clusterList[i], num_verts[i + 1] * sizeof( int ) ); - - free( clusterList[i] ); - - clusterList[i] = temp; - } - - // currently this function is only called by LoadModelClusters. - // Apparently the matching free has disappeared, - // should probably be free at the end of FMCmd_Base - - TK_Beyond( TK_LBRACE ); - - for ( j = 0; j < numVerts; ++j ) - { - TK_Require( TK_INTNUMBER ); - clusterList[i][j] = tk_IntNumber; - TK_Fetch(); - } - - num_verts[i + 1] += numVerts; - - break; - } - } - } - - num_verts[0] = numJointsInSkeleton[skelType]; -#endif - -#if 1 // get the index number localized to the root -// for( i = 1; i < numJointsInSkeleton[skelType] + 1; ++i) -// { -// g_skelModel.num_verts[i] = 0; -// } +// get the index number localized to the root TK_OpenSource( fileName ); TK_FetchRequire( TK_HRCH ); @@ -186,7 +109,6 @@ static void LoadHRCClustered( char *fileName, int **clusterList, int *num_verts, free( triList ); num_verts[0] = numJointsInSkeleton[skelType]; -#endif } void ReadHRCClusterList( mesh_node_t *meshNode, int baseIndex ){ @@ -473,70 +395,6 @@ static void LoadHRCJointList( char *fileName, QD_SkeletalJoint_t *jointList, int stackSize = currentStack; -#if 0 - // rotate the direction and up vectors to correspond to the rotation - for ( i = 0; i < numJointsInSkeleton[skelType]; ++i ) - { - rx = jointList[i].rotation[0] * ANGLE_TO_RAD; - ry = jointList[i].rotation[1] * ANGLE_TO_RAD; - rz = jointList[i].rotation[2] * ANGLE_TO_RAD; - - cx = cos( rx ); - sx = sin( rx ); - - cy = cos( ry ); - sy = sin( ry ); - - cz = cos( rz ); - sz = sin( rz ); - - // y-axis rotation for direction - x2 = jointList[i].placement.direction[0] * cy + jointList[i].placement.direction[2] * sy; - z2 = -jointList[i].placement.direction[0] * sy + jointList[i].placement.direction[2] * cy; - jointList[i].placement.direction[0] = x2; - jointList[i].placement.direction[2] = z2; - - // y-axis rotation for up - x2 = jointList[i].placement.up[0] * cy + jointList[i].placement.up[2] * sy; - z2 = -jointList[i].placement.up[0] * sy + jointList[i].placement.up[2] * cy; - jointList[i].placement.up[0] = x2; - jointList[i].placement.up[2] = z2; - - // z-axis rotation for direction - x2 = jointList[i].placement.direction[0] * cz - jointList[i].placement.direction[1] * sz; - y2 = jointList[i].placement.direction[0] * sz + jointList[i].placement.direction[1] * cz; - jointList[i].placement.direction[0] = x2; - jointList[i].placement.direction[1] = y2; - - // z-axis rotation for up - x2 = jointList[i].placement.up[0] * cz - jointList[i].placement.up[1] * sz; - y2 = jointList[i].placement.up[0] * sz + jointList[i].placement.up[1] * cz; - jointList[i].placement.up[0] = x2; - jointList[i].placement.up[1] = y2; - - // x-axis rotation for direction vector - y2 = jointList[i].placement.direction[1] * cx - jointList[i].placement.direction[2] * sx; - z2 = jointList[i].placement.direction[1] * sx + jointList[i].placement.direction[2] * cx; - jointList[i].placement.direction[1] = y2; - jointList[i].placement.direction[2] = z2; - - // x-axis rotation for up vector - y2 = jointList[i].placement.up[1] * cx - jointList[i].placement.up[2] * sx; - z2 = jointList[i].placement.up[1] * sx + jointList[i].placement.up[2] * cx; - jointList[i].placement.up[1] = y2; - jointList[i].placement.up[2] = z2; - - // translate direction to a point in the model - jointList[i].placement.direction[0] += jointList[i].placement.origin[0]; - jointList[i].placement.direction[1] += jointList[i].placement.origin[1]; - jointList[i].placement.direction[2] += jointList[i].placement.origin[2]; - - // translate up to a point in the model - jointList[i].placement.up[0] += jointList[i].placement.origin[0]; - jointList[i].placement.up[1] += jointList[i].placement.origin[1]; - jointList[i].placement.up[2] += jointList[i].placement.origin[2]; - } -#endif for ( i = stackSize - 1; i >= 0; --i ) { @@ -553,7 +411,6 @@ static void LoadHRCJointList( char *fileName, QD_SkeletalJoint_t *jointList, int cz = cos( rz ); sz = sin( rz ); -#if 1 for ( j = i; j < stackSize; ++j ) { if ( curCorrespondingJoint[j] != -1 ) { @@ -629,83 +486,6 @@ static void LoadHRCJointList( char *fileName, QD_SkeletalJoint_t *jointList, int placement->up[2] += curTranslation[i][2]; } } -#else - // This screwed up and needs to be sorted out!!! - // The stack info needs to be written too instead of the jointList for j > numJoints for Skeleton - for ( j = i - 1; j < stackSize - 1; ++j ) - { - // y-axis rotation for origin - x2 = jointList[j].placement.origin[0] * cy + jointList[j].placement.origin[2] * sy; - z2 = -jointList[j].placement.origin[0] * sy + jointList[j].placement.origin[2] * cy; - jointList[j].placement.origin[0] = x2; - jointList[j].placement.origin[2] = z2; - - // y-axis rotation for direction - x2 = jointList[j].placement.direction[0] * cy + jointList[j].placement.direction[2] * sy; - z2 = -jointList[j].placement.direction[0] * sy + jointList[j].placement.direction[2] * cy; - jointList[j].placement.direction[0] = x2; - jointList[j].placement.direction[2] = z2; - - // y-axis rotation for up - x2 = jointList[j].placement.up[0] * cy + jointList[j].placement.up[2] * sy; - z2 = -jointList[j].placement.up[0] * sy + jointList[j].placement.up[2] * cy; - jointList[j].placement.up[0] = x2; - jointList[j].placement.up[2] = z2; - - // z-axis rotation for origin - x2 = jointList[j].placement.origin[0] * cz - jointList[j].placement.origin[1] * sz; - y2 = jointList[j].placement.origin[0] * sz + jointList[j].placement.origin[1] * cz; - jointList[j].placement.origin[0] = x2; - jointList[j].placement.origin[1] = y2; - - // z-axis rotation for direction - x2 = jointList[j].placement.direction[0] * cz - jointList[j].placement.direction[1] * sz; - y2 = jointList[j].placement.direction[0] * sz + jointList[j].placement.direction[1] * cz; - jointList[j].placement.direction[0] = x2; - jointList[j].placement.direction[1] = y2; - - // z-axis rotation for up - x2 = jointList[j].placement.up[0] * cz - jointList[j].placement.up[1] * sz; - y2 = jointList[j].placement.up[0] * sz + jointList[j].placement.up[1] * cz; - jointList[j].placement.up[0] = x2; - jointList[j].placement.up[1] = y2; - - // x-axis rotation for origin - y2 = jointList[j].placement.origin[1] * cx - jointList[j].placement.origin[2] * sx; - z2 = jointList[j].placement.origin[1] * sx + jointList[j].placement.origin[2] * cx; - jointList[j].placement.origin[1] = y2; - jointList[j].placement.origin[2] = z2; - - // x-axis rotation for direction vector - y2 = jointList[j].placement.direction[1] * cx - jointList[j].placement.direction[2] * sx; - z2 = jointList[j].placement.direction[1] * sx + jointList[j].placement.direction[2] * cx; - jointList[j].placement.direction[1] = y2; - jointList[j].placement.direction[2] = z2; - - // x-axis rotation for up vector - y2 = jointList[j].placement.up[1] * cx - jointList[j].placement.up[2] * sx; - z2 = jointList[j].placement.up[1] * sx + jointList[j].placement.up[2] * cx; - jointList[j].placement.up[1] = y2; - jointList[j].placement.up[2] = z2; - - if ( curCorrespondingJoint[j + 1] != -1 ) { - // translate origin - jointList[j].placement.origin[0] += curTranslation[i - 1][0]; - jointList[j].placement.origin[1] += curTranslation[i - 1][1]; - jointList[j].placement.origin[2] += curTranslation[i - 1][2]; - - // translate back to local coord - jointList[j].placement.direction[0] += curTranslation[i - 1][0]; - jointList[j].placement.direction[1] += curTranslation[i - 1][1]; - jointList[j].placement.direction[2] += curTranslation[i - 1][2]; - - // translate back to local coord - jointList[j].placement.up[0] += curTranslation[i - 1][0]; - jointList[j].placement.up[1] += curTranslation[i - 1][1]; - jointList[j].placement.up[2] += curTranslation[i - 1][2]; - } - } -#endif } } diff --git a/tools/quake2/qdata_heretic2/svdcmp.c b/tools/quake2/qdata_heretic2/svdcmp.c index 63811395..db0f00bd 100644 --- a/tools/quake2/qdata_heretic2/svdcmp.c +++ b/tools/quake2/qdata_heretic2/svdcmp.c @@ -289,7 +289,6 @@ void svbksb( double** u, double* w, double** v,int m, int n, double* b, double* #undef PYTHAG -#if 1 void DOsvd( float *a,float *res,float *comp,float *values,int nframes,int framesize,int compressedsize ){ int usedfs; int *remap; @@ -377,71 +376,6 @@ void DOsvd( float *a,float *res,float *comp,float *values,int nframes,int frames free( remap ); } -#else - -void DOsvd( float *a,float *res,float *comp,float *values,int nframes,int framesize,int compressedsize ){ - int *remap; - int i,j; - int nrows; - nrows = nframes; - if ( nrows < framesize ) { - nrows = framesize; - } - double **da = allocMatrix( nrows,framesize ); - double **v = allocMatrix( framesize,framesize ); - double *w = allocVect( framesize ); - float mx; - int bestat; - - for ( j = 0; j < framesize; j++ ) - { - for ( i = 0; i < nframes; i++ ) - da[j + 1][i + 1] = a[i * framesize + j]; - for (; i < nrows; i++ ) - da[j + 1][i + 1] = 0.0; - } - - svdcmp( da,nrows,framesize,w,v ); - - remap = new int[framesize]; - - - for ( i = 0; i < framesize; i++ ) - remap[i] = -1; - for ( j = 0; j < compressedsize; j++ ) - { - mx = -1.0f; - for ( i = 0; i < framesize; i++ ) - { - if ( remap[i] < 0 && fabs( w[i + 1] ) > mx ) { - mx = fabs( w[i + 1] ); - bestat = i; - } - } - assert( mx > -.5f ); - remap[bestat] = j; - } - // josh **DO NOT** put your dof>nframes mod here - for ( i = 0; i < framesize; i++ ) - { - if ( remap[i] < 0 ) { - w[i + 1] = 0.0; - } - else - { - values[remap[i]] = w[i + 1]; - for ( j = 0; j < framesize; j++ ) - res[remap[i] * framesize + j] = v[j + 1][i + 1]; - } - } - freeVect( w ); - freeMatrix( v,framesize ); - freeMatrix( da,nrows ); - delete[] remap; -} - -#endif - void DOsvdPlane( float *pnts,int npnts,float *n,float *base ){ int i,j; double **da = allocMatrix( npnts,3 ); diff --git a/tools/quake2/qdata_heretic2/video.c b/tools/quake2/qdata_heretic2/video.c index 8ebb5fe2..10566df2 100644 --- a/tools/quake2/qdata_heretic2/video.c +++ b/tools/quake2/qdata_heretic2/video.c @@ -25,1129 +25,6 @@ // rle b4 huffing // adpcm encoding of sound -#if 0 -#include "qdata.h" -#include "flex.h" -#include "fc.h" -#include "adpcm.h" - -#define MIN_REPT 15 -#define MAX_REPT 0 -#define HUF_TOKENS ( 256 + MAX_REPT ) - -#define BLOCKSIZE 8 - -#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h -#define SQRT2 1.414213562 - -typedef struct hnode_s -{ - int count; - qboolean used; - int children[2]; -} hnode_t; - -typedef struct -{ - int rate; - int width; - int channels; - int loopstart; - int samples; - int dataofs; // chunk starts this many bytes from file start -} wavinfo_t; - -// These weren`t picked out my ass.... -// They were defined at http://www.rahul.net/jfm/dct.html -// However, I think he plucked them out of his ass..... - -float Quantise[BLOCKSIZE * BLOCKSIZE]; - -float LUT_Quantise[BLOCKSIZE * BLOCKSIZE] = -{ - 16.0F / 16.0F, 11.0F / 16.0F, 10.0F / 16.0F, 16.0F / 16.0F, 24.0F / 16.0F, 40.0F / 16.0F, 51.0F / 16.0F, 61.0F / 16.0F, - 12.0F / 16.0F, 13.0F / 16.0F, 14.0F / 16.0F, 19.0F / 16.0F, 26.0F / 16.0F, 58.0F / 16.0F, 60.0F / 16.0F, 55.0F / 16.0F, - 14.0F / 16.0F, 13.0F / 16.0F, 16.0F / 16.0F, 24.0F / 16.0F, 40.0F / 16.0F, 57.0F / 16.0F, 69.0F / 16.0F, 56.0F / 16.0F, - 14.0F / 16.0F, 17.0F / 16.0F, 22.0F / 16.0F, 29.0F / 16.0F, 51.0F / 16.0F, 87.0F / 16.0F, 80.0F / 16.0F, 62.0F / 16.0F, - 18.0F / 16.0F, 22.0F / 16.0F, 37.0F / 16.0F, 56.0F / 16.0F, 68.0F / 16.0F,109.0F / 16.0F,103.0F / 16.0F, 77.0F / 16.0F, - 24.0F / 16.0F, 35.0F / 16.0F, 55.0F / 16.0F, 64.0F / 16.0F, 81.0F / 16.0F,104.0F / 16.0F,113.0F / 16.0F, 92.0F / 16.0F, - 49.0F / 16.0F, 64.0F / 16.0F, 78.0F / 16.0F, 87.0F / 16.0F,103.0F / 16.0F,121.0F / 16.0F,120.0F / 16.0F,101.0F / 16.0F, - 72.0F / 16.0F, 92.0F / 16.0F, 95.0F / 16.0F, 98.0F / 16.0F,112.0F / 16.0F,100.0F / 16.0F,103.0F / 16.0F, 99.0F / 16.0F -}; - -int LUT_ZZ[BLOCKSIZE * BLOCKSIZE] = -{ - 0, - 1, 8, - 16, 9, 2, - 3, 10, 17, 24, - 32, 25, 18, 11, 4, - 5, 12, 19, 26, 33, 40, - 48, 41, 34, 27, 20, 13, 6, - 7, 14, 21, 28, 35, 42, 49, 56, - 57, 50, 43, 36, 29, 22, 15, - 23, 30, 37, 44, 51, 58, - 59, 52, 45, 38, 31, - 39, 46, 53, 60, - 61, 54, 47, - 55, 62, - 63 -}; - -char base[32]; - -byte *soundtrack; - -byte scaled[256][HUF_TOKENS]; -unsigned int charbits1[256][HUF_TOKENS]; -int charbitscount1[256][HUF_TOKENS]; -hnode_t hnodes1[256][HUF_TOKENS * 2]; -int numhnodes1[256]; -int order0counts[256]; -int numhnodes; -hnode_t hnodes[512]; -unsigned charbits[256]; -int charbitscount[256]; - -CineHead_t cinehead; - -byte *data_p; -byte *iff_end; -byte *last_chunk; -byte *iff_data; -int iff_chunk_len; - -float dctbase[BLOCKSIZE][BLOCKSIZE]; -float red[BLOCKSIZE * BLOCKSIZE]; -float green[BLOCKSIZE * BLOCKSIZE]; -float blue[BLOCKSIZE * BLOCKSIZE]; -float temp[BLOCKSIZE * BLOCKSIZE]; - -wavinfo_t wavinfo; -adpcm_t adpcm; - -/* - =============================================================================== - - WAV loading - - =============================================================================== - */ - -/* Intel ADPCM step variation table */ -static int indexTable[16] = -{ - -1, -1, -1, -1, 2, 4, 6, 8, - -1, -1, -1, -1, 2, 4, 6, 8, -}; - -static int stepsizeTable[89] = -{ - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 -}; - -#if 0 -static void adpcm_decoder( char *indata, short *outdata, int len, adpcm_state_t *state ){ - signed char *inp; /* Input buffer pointer */ - short *outp; /* output buffer pointer */ - int sign; /* Current adpcm sign bit */ - int delta; /* Current adpcm output value */ - int step; /* Stepsize */ - int valpred; /* Predicted value */ - int vpdiff; /* Current change to valpred */ - int index; /* Current step change index */ - int inputbuffer; /* place to keep next 4-bit value */ - int bufferstep; /* toggle between inputbuffer/input */ - - outp = outdata; - inp = (signed char *)indata; - - valpred = state->valprev; - index = state->index; - step = stepsizeTable[index]; - - bufferstep = 0; - - for (; len > 0; len-- ) - { - /* Step 1 - get the delta value */ - if ( bufferstep ) { - delta = inputbuffer & 0xf; - } - else - { - inputbuffer = *inp++; - delta = ( inputbuffer >> 4 ) & 0xf; - } - bufferstep = !bufferstep; - - /* Step 2 - Find new index value (for later) */ - index += indexTable[delta]; - if ( index < 0 ) { - index = 0; - } - if ( index > 88 ) { - index = 88; - } - - /* Step 3 - Separate sign and magnitude */ - sign = delta & 8; - delta = delta & 7; - - /* Step 4 - Compute difference and new predicted value */ - /* - ** Computes 'vpdiff = (delta+0.5)*step/4', but see comment - ** in adpcm_coder. - */ - vpdiff = step >> 3; - if ( delta & 4 ) { - vpdiff += step; - } - if ( delta & 2 ) { - vpdiff += step >> 1; - } - if ( delta & 1 ) { - vpdiff += step >> 2; - } - - if ( sign ) { - valpred -= vpdiff; - } - else{ - valpred += vpdiff; - } - - /* Step 5 - clamp output value */ - if ( valpred > 32767 ) { - valpred = 32767; - } - else if ( valpred < -32768 ) { - valpred = -32768; - } - - /* Step 6 - Update step value */ - step = stepsizeTable[index]; - - /* Step 7 - Output value */ - *outp++ = valpred; - } - - state->valprev = valpred; - state->index = index; -} -#endif - -void adpcm_coder( short *inp, adpcm_t *adpcm ){ - int val; /* Current input sample value */ - int sign; /* Current adpcm sign bit */ - int delta; /* Current adpcm output value */ - int diff; /* Difference between val and valprev */ - int step; /* Stepsize */ - int valpred; /* Predicted output value */ - int vpdiff; /* Current change to valpred */ - int index; /* Current step change index */ - int outputbuffer; /* place to keep previous 4-bit value */ - int bufferstep; /* toggle between outputbuffer/output */ - adpcm_state_t *state; - char *outp; - int len; - - state = &adpcm->state; - len = state->count; - outp = adpcm->adpcm; - - valpred = state->in_valprev; - index = state->in_index; - step = stepsizeTable[index]; - - bufferstep = 1; - while ( len-- ) - { - val = *inp++; - - /* Step 1 - compute difference with previous value */ - diff = val - valpred; - sign = ( diff < 0 ) ? 8 : 0; - if ( sign ) { - diff = -diff; - } - - /* Step 2 - Divide and clamp */ - /* Note: - ** This code *approximately* computes: - ** delta = diff*4/step; - ** vpdiff = (delta+0.5)*step/4; - ** but in shift step bits are dropped. The net result of this is - ** that even if you have fast mul/div hardware you cannot put it to - ** good use since the fixup would be too expensive. - */ - delta = 0; - vpdiff = ( step >> 3 ); - - if ( diff >= step ) { - delta = 4; - diff -= step; - vpdiff += step; - } - step >>= 1; - if ( diff >= step ) { - delta |= 2; - diff -= step; - vpdiff += step; - } - step >>= 1; - if ( diff >= step ) { - delta |= 1; - vpdiff += step; - } - - /* Step 3 - Update previous value */ - if ( sign ) { - valpred -= vpdiff; - } - else{ - valpred += vpdiff; - } - - /* Step 4 - Clamp previous value to 16 bits */ - if ( valpred > 32767 ) { - valpred = 32767; - } - else if ( valpred < -32768 ) { - valpred = -32768; - } - - /* Step 5 - Assemble value, update index and step values */ - delta |= sign; - - index += indexTable[delta]; - if ( index < 0 ) { - index = 0; - } - if ( index > 88 ) { - index = 88; - } - step = stepsizeTable[index]; - - /* Step 6 - Output value */ - if ( bufferstep ) { - outputbuffer = ( delta << 4 ) & 0xf0; - } - else{ - *outp++ = ( delta & 0x0f ) | outputbuffer; - } - - bufferstep = !bufferstep; - } - - /* Output last step, if needed */ - if ( !bufferstep ) { - *outp++ = outputbuffer; - } - - state->out_valprev = valpred; - state->out_index = index; -} - -void FindNextChunk( char *name ){ - while ( 1 ) - { - data_p = last_chunk; - - if ( data_p >= iff_end ) { // didn't find the chunk - data_p = NULL; - return; - } - - data_p += 4; - iff_chunk_len = *(long *)data_p; - data_p += 4; - if ( iff_chunk_len < 0 ) { - data_p = NULL; - return; - } - - data_p -= 8; - last_chunk = data_p + 8 + ( ( iff_chunk_len + 1 ) & ~1 ); - if ( !strncmp( data_p, name, 4 ) ) { - return; - } - } -} - -void FindChunk( char *name ){ - last_chunk = iff_data; - FindNextChunk( name ); -} - -void DumpChunks( void ){ - char str[5]; - - str[4] = 0; - data_p = iff_data; - do - { - memcpy( str, data_p, 4 ); - data_p += 4; - iff_chunk_len = *(long *)data_p; - data_p += 4; - printf( "0x%x : %s (%d)\n", (int)( data_p - 4 ), str, iff_chunk_len ); - data_p += ( iff_chunk_len + 1 ) & ~1; - } - while ( data_p < iff_end ); -} - -/* - ============ - GetWavinfo - ============ - */ -wavinfo_t GetWavinfo( char *name, byte *wav, int wavlength ){ - wavinfo_t info; - int i; - int format; - int samples; - - memset( &info, 0, sizeof( info ) ); - - if ( !wav ) { - return( info ); - } - - iff_data = wav; - iff_end = wav + wavlength; - -// find "RIFF" chunk - FindChunk( "RIFF" ); - if ( !( data_p && !strncmp( data_p + 8, "WAVE", 4 ) ) ) { - printf( "Missing RIFF/WAVE chunks\n" ); - return( info ); - } - -// get "fmt " chunk - iff_data = data_p + 12; - - FindChunk( "fmt " ); - if ( !data_p ) { - printf( "Missing fmt chunk\n" ); - return( info ); - } - data_p += 8; - format = *(short *)data_p; - data_p += 2; - if ( format != 1 ) { - printf( "Microsoft PCM format only\n" ); - return( info ); - } - - info.channels = *(short *)data_p; - data_p += 2; - info.rate = *(long *)data_p; - data_p += 4; - data_p += 6; - info.width = *(short *)data_p / 8; - data_p += 2; - -// get cue chunk - FindChunk( "cue " ); - if ( data_p ) { - data_p += 32; - info.loopstart = *(long *)data_p; - data_p += 4; - -// if the next chunk is a LIST chunk, look for a cue length marker - FindNextChunk( "LIST" ); - if ( data_p ) { -// this is not a proper parse, but it works with cooledit... - if ( !strncmp( data_p + 28, "mark", 4 ) ) { - data_p += 24; - i = *(long *)data_p; // samples in loop - data_p += 4; - info.samples = info.loopstart + i; - } - } - } - else{ - info.loopstart = -1; - } - -// find data chunk - FindChunk( "data" ); - if ( !data_p ) { - printf( "Missing data chunk\n" ); - return( info ); - } - - data_p += 4; - samples = *(long *)data_p; - data_p += 4; - - if ( info.samples ) { - if ( samples < info.samples ) { - Error( "Sound %s has a bad loop length", name ); - } - } - else{ - info.samples = samples; - } - - info.dataofs = data_p - wav; - return( info ); -} - -// ============== -// LoadSoundtrack -// ============== - -void LoadSoundtrack(){ - char name[1024]; - FILE *f; - int len; - - soundtrack = NULL; - sprintf( name, "%svideo/%s/%s.wav", gamedir, base, base ); - printf( "\nLoading sound : %s\n", name ); - f = fopen( name, "rb" ); - if ( !f ) { - printf( "\nNo soundtrack for %s\n", base ); - return; - } - len = Q_filelength( f ); - soundtrack = SafeMalloc( len, "LoadSoundtrack" ); - fread( soundtrack, 1, len, f ); - fclose( f ); - - wavinfo = GetWavinfo( name, soundtrack, len ); - adpcm.state.out_valprev = 0; - adpcm.state.out_index = 0; -} - -// ================== -// WriteSound -// ================== - -int WriteSound( FILE *output, int frame, int numframes ){ - int start, end; - int count; - int empty = 0; - int width; - char *work; - - width = wavinfo.width * wavinfo.channels; - start = ( ( frame * wavinfo.rate / 14 ) + 31 ) & 0xffffffe0; // start sample - end = ( ( ( frame + numframes ) * wavinfo.rate / 14 ) + 31 ) & 0xffffffe0; // end sample - count = end - start; - - work = soundtrack + wavinfo.dataofs + ( start * width ); - adpcm.state.count = count * wavinfo.channels; // Number of samples - adpcm.state.in_valprev = adpcm.state.out_valprev; - adpcm.state.in_index = adpcm.state.out_index; - adpcm_coder( (short *)work, &adpcm ); - WriteHeader( output, FC_SOUND_22KMADPCM, FC_ADPCM_VERSION, ( adpcm.state.count / 2 ) + sizeof( adpcm_state_t ), (char *)&adpcm ); - return( count / 2 ); -} -// ============================== -// Basic run length encoder -// ============================== - -char *RLEZZ( char *in, char *out ){ - int srun; - char count; - int idx = 0; - - while ( idx < 64 ) - { - srun = idx; // Start of run - - while ( idx < 63 ) - { - if ( in[LUT_ZZ[idx]] != in[LUT_ZZ[idx + 1]] ) { - break; - } - idx++; - } - count = (char)( idx - srun ); // count of repeated bytes - - if ( !count ) { - while ( idx < 63 ) - { - if ( in[LUT_ZZ[idx]] == in[LUT_ZZ[idx + 1]] ) { - break; - } - idx++; - } - if ( idx == 63 ) { - idx++; - } - - count = (char)( idx - srun ); // count of unique bytes - *out++ = count; - while ( count-- ) - *out++ = in[LUT_ZZ[srun++]]; - } - else - { - *out++ = -( count + 1 ); - *out++ = in[LUT_ZZ[idx]]; - idx++; - } - } - return( out ); -} - -// ============================== -// Discrete Cosine Transformation -// ============================== - -void init_base( float quant ){ - int y, x; - - for ( y = 0; y < BLOCKSIZE; y++ ) - for ( x = 0; x < BLOCKSIZE; x++ ) - { - if ( y == 0 ) { - dctbase[y][x] = 1; - } - else{ - dctbase[y][x] = SQRT2 * cos( ( ( x * 2 + 1 ) * y * M_PI ) / ( BLOCKSIZE * 2 ) ); - } - } - - for ( y = 0; y < BLOCKSIZE * BLOCKSIZE; y++ ) - Quantise[y] = LUT_Quantise[y] / quant; -} - -void SplitComponents( byte *src, int width, int height ){ - int i, j; - float *tr = red; - float *tg = green; - float *tb = blue; - - for ( i = 0; i < BLOCKSIZE; i++, src += ( width - BLOCKSIZE ) * 4 ) - for ( j = 0; j < BLOCKSIZE; j++ ) - { - *tr++ = ( (float)*src++ ) - 128.0F; - *tg++ = ( (float)*src++ ) - 128.0F; - *tb++ = ( (float)*src++ ) - 128.0F; - src++; - } -} - -void transferH( float *src, float *dst ){ - int y, dx, dy; - float sum; - float *work; - - for ( y = 0; y < BLOCKSIZE; y++, src += BLOCKSIZE ) - { - for ( dy = 0; dy < BLOCKSIZE; dy++ ) - { - sum = 0; - work = src; - for ( dx = 0; dx < BLOCKSIZE; dx++, work++ ) - sum += dctbase[dy][dx] * *work; - - *dst++ = sum / BLOCKSIZE; - } - } -} - -void transferV( float *src, float *dst ){ - int x, dy, fy; - float sum; - float *work; - - for ( x = 0; x < BLOCKSIZE; x++, src++, dst++ ) - { - for ( fy = 0; fy < BLOCKSIZE; fy++ ) - { - sum = 0; - work = src; - for ( dy = 0; dy < BLOCKSIZE; dy++, work += BLOCKSIZE ) - sum += dctbase[fy][dy] * *work; - - dst[fy * BLOCKSIZE] = sum / BLOCKSIZE; - } - } -} - -char *Combine( byte *dst, float *p, float *q ){ - int i, j; - byte rlesrc[BLOCKSIZE * BLOCKSIZE]; - int c; - byte *work; - - work = rlesrc; - for ( j = 0; j < BLOCKSIZE; j++ ) - for ( i = 0; i < BLOCKSIZE; i++ ) - { - c = (int)( ( *p++ / *q++ ) + 128.5F ); - c -= 128; - - if ( c < -128 ) { - c = -128; - } - if ( c > 127 ) { - c = 127; - } - - *work++ = (char)c; - } - - dst = RLEZZ( rlesrc, dst ); - return( dst ); -} - -char *CombineComponents( char *dst, int width, int height ){ - dst = Combine( dst, red, Quantise ); - dst = Combine( dst, green, Quantise ); - dst = Combine( dst, blue, Quantise ); - return( dst ); -} - -void DCT( cblock_t *out, cblock_t in, int width, int height ){ - int x, y; - char *cursrc; - char *curdst; - - curdst = out->data; - for ( y = 0; y < height; y += BLOCKSIZE ) - for ( x = 0; x < width; x += BLOCKSIZE ) - { - cursrc = in.data + ( ( y * width ) + x ) * 4; - SplitComponents( cursrc, width, height ); - transferH( red, temp ); - transferV( temp, red ); - transferH( green, temp ); - transferV( temp, green ); - transferH( blue, temp ); - transferV( temp, blue ); - curdst = CombineComponents( curdst, width, height ); - } - out->count = curdst - out->data; -} - -// ================== -// BuildChars1 -// ================== - -void BuildChars1( int prev, int nodenum, unsigned bits, int bitcount ){ - hnode_t *node; - - if ( nodenum < HUF_TOKENS ) { - if ( bitcount > 32 ) { - Error( "bitcount > 32" ); - } - charbits1[prev][nodenum] = bits; - charbitscount1[prev][nodenum] = bitcount; - return; - } - - node = &hnodes1[prev][nodenum]; - bits <<= 1; - BuildChars1( prev, node->children[0], bits, bitcount + 1 ); - bits |= 1; - BuildChars1( prev, node->children[1], bits, bitcount + 1 ); -} - -// ================== -// SmallestNode1 -// ================== - -int SmallestNode1( hnode_t *hnodes, int numhnodes ){ - int i; - int best, bestnode; - - best = 99999999; - bestnode = -1; - for ( i = 0; i < numhnodes; i++ ) - { - if ( hnodes[i].used ) { - continue; - } - if ( !hnodes[i].count ) { - continue; - } - if ( hnodes[i].count < best ) { - best = hnodes[i].count; - bestnode = i; - } - } - - if ( bestnode == -1 ) { - return( -1 ); - } - - hnodes[bestnode].used = true; - return( bestnode ); -} - -// ================== -// BuildTree1 -// ================== - -void BuildTree1( int prev ){ - hnode_t *node, *nodebase; - int numhnodes; - - // build the nodes - numhnodes = HUF_TOKENS; - nodebase = hnodes1[prev]; - while ( 1 ) - { - node = &nodebase[numhnodes]; - - // pick two lowest counts - node->children[0] = SmallestNode1( nodebase, numhnodes ); - if ( node->children[0] == -1 ) { - break; // no more - - } - node->children[1] = SmallestNode1( nodebase, numhnodes ); - if ( node->children[1] == -1 ) { - break; - } - - node->count = nodebase[node->children[0]].count + - nodebase[node->children[1]].count; - numhnodes++; - } - numhnodes1[prev] = numhnodes - 1; - BuildChars1( prev, numhnodes - 1, 0, 0 ); -} - -// ================== -// Huffman1_Count -// ================== - -void Huffman1_Count( cblock_t in ){ - int i; - int prev; - int v; - int rept; - - prev = 0; - for ( i = 0; i < in.count; i++ ) - { - v = in.data[i]; - order0counts[v]++; - hnodes1[prev][v].count++; - prev = v; - - for ( rept = 1; ( i + rept < in.count ) && ( rept < MAX_REPT ); rept++ ) - if ( in.data[i + rept] != v ) { - break; - } - if ( rept > MIN_REPT ) { - hnodes1[prev][255 + rept].count++; - i += rept - 1; - } - } -} - -// ================== -// Huffman1_Build -// ================== - -void Huffman1_Build(){ - int i, j, v; - int max; - int total; - - for ( i = 0; i < 256; i++ ) - { -// normalize and save the counts - max = 0; - for ( j = 0; j < HUF_TOKENS; j++ ) - { - if ( hnodes1[i][j].count > max ) { - max = hnodes1[i][j].count; - } - } - if ( max == 0 ) { - max = 1; - } - total = 0; -// easy to overflow 32 bits here! - for ( j = 0; j < HUF_TOKENS; j++ ) - { - v = ( hnodes1[i][j].count * (double) 255 + max - 1 ) / max; - if ( v > 255 ) { - Error( "v > 255" ); - } - scaled[i][j] = hnodes1[i][j].count = v; - if ( v ) { - total++; - } - } - if ( total == 1 ) { // must have two tokens - if ( !scaled[i][0] ) { - scaled[i][0] = hnodes1[i][0].count = 1; - } - else{ - scaled[i][1] = hnodes1[i][1].count = 1; - } - } - BuildTree1( i ); - } -} - -// ================== -// Huffman1 -// Order 1 compression with pre-built table -// ================== - -cblock_t Huffman1( cblock_t in ){ - int i; - int outbits, c; - unsigned bits; - byte *out_p; - cblock_t out; - int prev; - int v; - int rept; - - out_p = out.data = SafeMalloc( ( in.count * 2 ) + 1024 + 4, "Huffman" ); - memset( out_p, 0, ( in.count * 2 ) + 1024 + 4 ); - - // leave space for compressed count - out_p += 4; - // write count - *(long *)out_p = in.count; - out_p += 4; - - // write bits - outbits = 0; - prev = 0; - for ( i = 0; i < in.count; i++ ) - { - v = in.data[i]; - - c = charbitscount1[prev][v]; - bits = charbits1[prev][v]; - if ( !c ) { - Error( "!bits" ); - } - while ( c ) - { - c--; - if ( bits & ( 1 << c ) ) { - out_p[outbits >> 3] |= 1 << ( outbits & 7 ); - } - outbits++; - } - - prev = v; - // check for repeat encodes - for ( rept = 1; ( i + rept < in.count ) && ( rept < MAX_REPT ); rept++ ) - if ( in.data[i + rept] != v ) { - break; - } - if ( rept > MIN_REPT ) { - c = charbitscount1[prev][255 + rept]; - bits = charbits1[prev][255 + rept]; - if ( !c ) { - Error( "!bits" ); - } - while ( c ) - { - c--; - if ( bits & ( 1 << c ) ) { - out_p[outbits >> 3] |= 1 << ( outbits & 7 ); - } - outbits++; - } - i += rept - 1; - } - } - out_p += ( outbits + 7 ) >> 3; - out.count = out_p - out.data; - - out_p = out.data; - *(long *)out_p = out.count; - return( out ); -} -// =================== -// LoadFrame -// =================== - -void LoadFrame( cblock_t *out, char *base, int frame ){ - cblock_t in; - int width, height; - char name[1024]; - FILE *f; - - in.data = NULL; - in.count = -1; - sprintf( name, "%svideo/%s/%s%04i.tga", gamedir, base, base, frame ); - - f = fopen( name, "rb" ); - if ( !f ) { - out->data = NULL; - return; - } - fclose( f ); - - LoadTGA( name, &in.data, &width, &height ); - if ( ( width != cinehead.Width ) || ( height != cinehead.Height ) ) { - free( in.data ); - printf( "Invalid picture size\n" ); - out->data = NULL; - return; - } - out->data = SafeMalloc( width * height * 3, "LoadFrame" ); // rle could possibly expand file so this not 100% safe (however DCT should force a lot of compression) - DCT( out, in, width, height ); - free( in.data ); -} - -// ================================== -// Cmd_Video -// -// video -// ================================== - -void Cmd_Video(){ - char savename[256]; - char name[256]; - FILE *output; - int frame; - int width, height; - cblock_t in, huffman; - int size; - float dctconst; - int maxsize, ssize; - int min_rle_size, warnings; - int ave_image, ave_sound; - - GetScriptToken( false ); - strcpy( base, token ); - if ( g_release ) { - return; - } - - GetScriptToken( false ); - dctconst = atof( token ); - GetScriptToken( false ); - maxsize = atoi( token ); - - sprintf( savename, "%svideo/%s.cin", gamedir, base ); - - // clear stuff - memset( charbits1, 0, sizeof( charbits1 ) ); - memset( charbitscount1, 0, sizeof( charbitscount1 ) ); - memset( hnodes1, 0, sizeof( hnodes1 ) ); - memset( numhnodes1, 0, sizeof( numhnodes1 ) ); - memset( order0counts, 0, sizeof( order0counts ) ); - - // load the entire sound wav file if present - LoadSoundtrack(); - - cinehead.SndRate = wavinfo.rate; - cinehead.SndWidth = wavinfo.width; - cinehead.SndChannels = wavinfo.channels; - - sprintf( name, "%svideo/%s/%s0000.tga", gamedir, base, base ); - printf( "Loading sequence : %s\n", name ); - printf( "DCT constant : %f\n", dctconst ); - - LoadTGA( name, NULL, &width, &height ); - - output = fopen( savename, "wb" ); - if ( !output ) { - Error( "Can't open %s", savename ); - } - - if ( ( width % BLOCKSIZE ) || ( height % BLOCKSIZE ) ) { - Error( "Width and height must be a multiple of %d", BLOCKSIZE ); - } - - cinehead.Width = width; - cinehead.Height = height; - init_base( dctconst ); - - // build the dictionary - printf( "Counting : " ); - min_rle_size = 0; - for ( frame = 0; ; frame++ ) - { - printf( "." ); - LoadFrame( &in, base, frame ); - if ( !in.data ) { - break; - } - Huffman1_Count( in ); - if ( in.count > min_rle_size ) { - min_rle_size = in.count; - } - free( in.data ); - } - printf( "\n" ); - cinehead.NumFrames = frame; - printf( "Num Frames : %d\n", frame ); - cinehead.MaxRleSize = ( min_rle_size + 0x1f ) & 0xfffffe0; - cinehead.MaxSndSize = ( ( 4 * wavinfo.rate * wavinfo.channels / 14 ) + 0x1f ) & 0xffffffe0; - - WriteHeader( output, FC_HEADER_NAME, FC_HEADER_VERSION, sizeof( CineHead_t ), &cinehead ); - - // build nodes and write counts - Huffman1_Build(); - WriteHeader( output, FC_HUFFBITS_NAME, FC_HUFFBITS_VERSION, sizeof( scaled ), scaled ); - WriteHeader( output, FC_QUANT_NAME, FC_QUANT_VERSION, sizeof( Quantise ), Quantise ); - - ave_image = 0; - ave_sound = 0; - warnings = 0; - // compress it with the dictionary - if ( soundtrack ) { - ssize = WriteSound( output, frame, 4 ); - ave_sound += ssize; - } - - for ( frame = 0; frame < cinehead.NumFrames; frame++ ) - { - // save some sound samples - printf( "Packing : ", frame ); - LoadFrame( &in, base, frame ); - - // save the image - huffman = Huffman1( in ); - printf( "%d bytes rle, %d bytes huffman", in.count, huffman.count ); - size = ( huffman.count + 3 ) & 0xfffffffc; // round up to longwords - if ( size > maxsize ) { - printf( " ** WARNING **" ); - warnings++; - } - printf( "\n" ); - ave_image += huffman.count; - - WriteHeader( output, FC_IMAGE_NAME, FC_IMAGE_VERSION, size, huffman.data ); - if ( soundtrack ) { - ssize = WriteSound( output, frame + 4, 1 ); - ave_sound += ssize; - } - - free( in.data ); - free( huffman.data ); - } - printf( "\nTotal size: %d (headers + %d image + %d sound)\n", ftell( output ), ave_image, ave_sound ); - printf( "Data rate : %d bytes per sec (image and sound)\n", ( ave_image + ave_sound ) / cinehead.NumFrames ); - printf( "Cin created ok with %d warnings.\n", warnings ); - fclose( output ); - - if ( soundtrack ) { - free( soundtrack ); - } -} -#endif - void Cmd_Video(){ } diff --git a/tools/quake3/common/cmdlib.c b/tools/quake3/common/cmdlib.c index 103047c0..a010ad09 100644 --- a/tools/quake3/common/cmdlib.c +++ b/tools/quake3/common/cmdlib.c @@ -272,21 +272,6 @@ double I_FloatTime( void ){ time( &t ); return t; -#if 0 -// more precise, less portable - struct timeval tp; - struct timezone tzp; - static int secbase; - - gettimeofday( &tp, &tzp ); - - if ( !secbase ) { - secbase = tp.tv_sec; - return tp.tv_usec / 1000000.0; - } - - return ( tp.tv_sec - secbase ) + tp.tv_usec / 1000000.0; -#endif } void Q_getwd( char *out ){ diff --git a/tools/quake3/common/inout.c b/tools/quake3/common/inout.c index 14e9eaaf..0953bd85 100644 --- a/tools/quake3/common/inout.c +++ b/tools/quake3/common/inout.c @@ -109,33 +109,6 @@ void xml_SendNode( xmlNodePtr node ){ pos += size; } -#if 0 - // NOTE: the NMSG_WriteString is limited to MAX_NETMESSAGE - // we will need to split into chunks - // (we could also go lower level, in the end it's using send and receiv which are not size limited) - //++timo FIXME: MAX_NETMESSAGE is not exactly the max size we can stick in the message - // there's some tweaking to do in l_net for that .. so let's give us a margin for now - - //++timo we need to handle the case of a buffer too big to fit in a single message - // try without checks for now - if ( xml_buf->use > MAX_NETMESSAGE - 10 ) { - // if we send that we are probably gonna break the stream at the other end.. - // and Error will call right there - //Error( "MAX_NETMESSAGE exceeded for XML feedback stream in FPrintf (%d)\n", xml_buf->use); - Sys_FPrintf( SYS_NOXML, "MAX_NETMESSAGE exceeded for XML feedback stream in FPrintf (%d)\n", xml_buf->use ); - xml_buf->content[xml_buf->use] = '\0'; //++timo this corrupts the buffer but we don't care it's for printing - Sys_FPrintf( SYS_NOXML, xml_buf->content ); - - } - - size = xml_buf->use; - memcpy( xmlbuf, xml_buf->content, size ); - xmlbuf[size] = '\0'; - NMSG_Clear( &msg ); - NMSG_WriteString( &msg, xmlbuf ); - Net_Send( brdcst_socket, &msg ); -#endif - xmlBufferFree( xml_buf ); } } diff --git a/tools/quake3/q3data/3dslib.c b/tools/quake3/q3data/3dslib.c index 164f9d1b..a63b1c3b 100644 --- a/tools/quake3/q3data/3dslib.c +++ b/tools/quake3/q3data/3dslib.c @@ -644,14 +644,6 @@ void _3DS_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets, } // compute normal data -#if 0 - for ( i = 0; i < numPolysets; i++ ) - { - // unique vertices based solely on vertex position - ComputeNormals( &_3ds.editChunk.pNamedObjects[i].pTriObjects[0], - pPSET[i].triangles ); - } -#endif free( _3ds.editChunk.pMaterials ); free( _3ds.editChunk.pNamedObjects ); diff --git a/tools/quake3/q3data/compress.c b/tools/quake3/q3data/compress.c index e09975b2..7b2a5300 100644 --- a/tools/quake3/q3data/compress.c +++ b/tools/quake3/q3data/compress.c @@ -20,768 +20,3 @@ */ #include "q3data.h" - -#if 0 -/* - ================== - MTF - ================== - */ -cblock_t MTF( cblock_t in ){ - int i, j, b, code; - byte *out_p; - int index[256]; - cblock_t out; - - out_p = out.data = malloc( in.count + 4 ); - - // write count - *out_p++ = in.count & 255; - *out_p++ = ( in.count >> 8 ) & 255; - *out_p++ = ( in.count >> 16 ) & 255; - *out_p++ = ( in.count >> 24 ) & 255; - - for ( i = 0 ; i < 256 ; i++ ) - index[i] = i; - - for ( i = 0 ; i < in.count ; i++ ) - { - b = in.data[i]; - code = index[b]; - *out_p++ = code; - - // shuffle b indexes to 0 - for ( j = 0 ; j < 256 ; j++ ) - if ( index[j] < code ) { - index[j]++; - } - index[b] = 0; - } - - out.count = out_p - out.data; - - return out; -} - - -//========================================================================== - -int bwt_size; -byte *bwt_data; - -int bwtCompare( const void *elem1, const void *elem2 ){ - int i; - int i1, i2; - int b1, b2; - - i1 = *(int *)elem1; - i2 = *(int *)elem2; - - for ( i = 0 ; i < bwt_size ; i++ ) - { - b1 = bwt_data[i1]; - b2 = bwt_data[i2]; - if ( b1 < b2 ) { - return -1; - } - if ( b1 > b2 ) { - return 1; - } - if ( ++i1 == bwt_size ) { - i1 = 0; - } - if ( ++i2 == bwt_size ) { - i2 = 0; - } - } - - return 0; -} - -/* - ================== - BWT - ================== - */ -cblock_t BWT( cblock_t in ){ - int *sorted; - int i; - byte *out_p; - cblock_t out; - - bwt_size = in.count; - bwt_data = in.data; - - sorted = malloc( in.count * sizeof( *sorted ) ); - for ( i = 0 ; i < in.count ; i++ ) - sorted[i] = i; - qsort( sorted, in.count, sizeof( *sorted ), bwtCompare ); - - out_p = out.data = malloc( in.count + 8 ); - - // write count - *out_p++ = in.count & 255; - *out_p++ = ( in.count >> 8 ) & 255; - *out_p++ = ( in.count >> 16 ) & 255; - *out_p++ = ( in.count >> 24 ) & 255; - - // write head index - for ( i = 0 ; i < in.count ; i++ ) - if ( sorted[i] == 0 ) { - break; - } - *out_p++ = i & 255; - *out_p++ = ( i >> 8 ) & 255; - *out_p++ = ( i >> 16 ) & 255; - *out_p++ = ( i >> 24 ) & 255; - - // write the L column - for ( i = 0 ; i < in.count ; i++ ) - *out_p++ = in.data[( sorted[i] + in.count - 1 ) % in.count]; - - free( sorted ); - - out.count = out_p - out.data; - - return out; -} - -//========================================================================== - -typedef struct hnode_s -{ - int count; - qboolean used; - int children[2]; -} hnode_t; - -int numhnodes; -hnode_t hnodes[512]; -unsigned charbits[256]; -int charbitscount[256]; - -int SmallestNode( void ){ - int i; - int best, bestnode; - - best = 99999999; - bestnode = -1; - for ( i = 0 ; i < numhnodes ; i++ ) - { - if ( hnodes[i].used ) { - continue; - } - if ( !hnodes[i].count ) { - continue; - } - if ( hnodes[i].count < best ) { - best = hnodes[i].count; - bestnode = i; - } - } - - if ( bestnode == -1 ) { - return -1; - } - - hnodes[bestnode].used = true; - return bestnode; -} - -void BuildChars( int nodenum, unsigned bits, int bitcount ){ - hnode_t *node; - - if ( nodenum < 256 ) { - if ( bitcount > 32 ) { - Error( "bitcount > 32" ); - } - charbits[nodenum] = bits; - charbitscount[nodenum] = bitcount; - return; - } - - node = &hnodes[nodenum]; - bits <<= 1; - BuildChars( node->children[0], bits, bitcount + 1 ); - bits |= 1; - BuildChars( node->children[1], bits, bitcount + 1 ); -} - -/* - ================== - Huffman - ================== - */ -cblock_t Huffman( cblock_t in ){ - int i; - hnode_t *node; - int outbits, c; - unsigned bits; - byte *out_p; - cblock_t out; - int max, maxchar; - - // count - memset( hnodes, 0, sizeof( hnodes ) ); - for ( i = 0 ; i < in.count ; i++ ) - hnodes[in.data[i]].count++; - - // normalize counts - max = 0; - maxchar = 0; - for ( i = 0 ; i < 256 ; i++ ) - { - if ( hnodes[i].count > max ) { - max = hnodes[i].count; - maxchar = i; - } - } - if ( max == 0 ) { - Error( "Huffman: max == 0" ); - } - - for ( i = 0 ; i < 256 ; i++ ) - { - hnodes[i].count = ( hnodes[i].count * 255 + max - 1 ) / max; - } - - // build the nodes - numhnodes = 256; - while ( numhnodes != 511 ) - { - node = &hnodes[numhnodes]; - - // pick two lowest counts - node->children[0] = SmallestNode(); - if ( node->children[0] == -1 ) { - break; // no more - - } - node->children[1] = SmallestNode(); - if ( node->children[1] == -1 ) { - if ( node->children[0] != numhnodes - 1 ) { - Error( "Bad smallestnode" ); - } - break; - } - node->count = hnodes[node->children[0]].count + - hnodes[node->children[1]].count; - numhnodes++; - } - - BuildChars( numhnodes - 1, 0, 0 ); - - out_p = out.data = malloc( in.count * 2 + 1024 ); - memset( out_p, 0, in.count * 2 + 1024 ); - - // write count - *out_p++ = in.count & 255; - *out_p++ = ( in.count >> 8 ) & 255; - *out_p++ = ( in.count >> 16 ) & 255; - *out_p++ = ( in.count >> 24 ) & 255; - - // save out the 256 normalized counts so the tree can be recreated - for ( i = 0 ; i < 256 ; i++ ) - *out_p++ = hnodes[i].count; - - // write bits - outbits = 0; - for ( i = 0 ; i < in.count ; i++ ) - { - c = charbitscount[in.data[i]]; - bits = charbits[in.data[i]]; - while ( c ) - { - c--; - if ( bits & ( 1 << c ) ) { - out_p[outbits >> 3] |= 1 << ( outbits & 7 ); - } - outbits++; - } - } - - out_p += ( outbits + 7 ) >> 3; - - out.count = out_p - out.data; - - return out; -} - -//========================================================================== - -/* - ================== - RLE - ================== - */ -#define RLE_CODE 0xe8 -#define RLE_TRIPPLE 0xe9 - -int rle_counts[256]; -int rle_bytes[256]; - -cblock_t RLE( cblock_t in ){ - int i; - byte *out_p; - int val; - int repeat; - cblock_t out; - - out_p = out.data = malloc( in.count * 2 ); - - // write count - *out_p++ = in.count & 255; - *out_p++ = ( in.count >> 8 ) & 255; - *out_p++ = ( in.count >> 16 ) & 255; - *out_p++ = ( in.count >> 24 ) & 255; - - for ( i = 0 ; i < in.count ; ) - { - val = in.data[i]; - rle_bytes[val]++; - repeat = 1; - i++; - while ( i < in.count && repeat < 255 && in.data[i] == val ) - { - repeat++; - i++; - } - if ( repeat < 256 ) { - rle_counts[repeat]++; - } - if ( repeat > 3 || val == RLE_CODE ) { - *out_p++ = RLE_CODE; - *out_p++ = val; - *out_p++ = repeat; - } - else - { - while ( repeat-- ) - *out_p++ = val; - } - } - - out.count = out_p - out.data; - return out; -} - -//========================================================================== - -unsigned lzss_head[256]; -unsigned lzss_next[0x20000]; - -/* - ================== - LZSS - ================== - */ -#define BACK_WINDOW 0x10000 -#define BACK_BITS 16 -#define FRONT_WINDOW 16 -#define FRONT_BITS 4 -cblock_t LZSS( cblock_t in ){ - int i; - byte *out_p; - cblock_t out; - int val; - int j, start, max; - int bestlength, beststart; - int outbits; - - if ( in.count >= sizeof( lzss_next ) / 4 ) { - Error( "LZSS: too big" ); - } - - memset( lzss_head, -1, sizeof( lzss_head ) ); - - out_p = out.data = malloc( in.count * 2 ); - memset( out.data, 0, in.count * 2 ); - - // write count - *out_p++ = in.count & 255; - *out_p++ = ( in.count >> 8 ) & 255; - *out_p++ = ( in.count >> 16 ) & 255; - *out_p++ = ( in.count >> 24 ) & 255; - - outbits = 0; - for ( i = 0 ; i < in.count ; ) - { - val = in.data[i]; -#if 1 -// chained search - bestlength = 0; - beststart = 0; - - max = FRONT_WINDOW; - if ( i + max > in.count ) { - max = in.count - i; - } - - start = lzss_head[val]; - while ( start != -1 && start >= i - BACK_WINDOW ) - { - // count match length - for ( j = 0 ; j < max ; j++ ) - if ( in.data[start + j] != in.data[i + j] ) { - break; - } - if ( j > bestlength ) { - bestlength = j; - beststart = start; - } - start = lzss_next[start]; - } - -#else -// slow simple search - // search for a match - max = FRONT_WINDOW; - if ( i + max > in.count ) { - max = in.count - i; - } - - start = i - BACK_WINDOW; - if ( start < 0 ) { - start = 0; - } - bestlength = 0; - beststart = 0; - for ( ; start < i ; start++ ) - { - if ( in.data[start] != val ) { - continue; - } - // count match length - for ( j = 0 ; j < max ; j++ ) - if ( in.data[start + j] != in.data[i + j] ) { - break; - } - if ( j > bestlength ) { - bestlength = j; - beststart = start; - } - } -#endif - beststart = BACK_WINDOW - ( i - beststart ); - - if ( bestlength < 3 ) { // output a single char - bestlength = 1; - - out_p[outbits >> 3] |= 1 << ( outbits & 7 ); // set bit to mark char - outbits++; - for ( j = 0 ; j < 8 ; j++, outbits++ ) - if ( val & ( 1 << j ) ) { - out_p[outbits >> 3] |= 1 << ( outbits & 7 ); - } - } - else - { // output a phrase - outbits++; // leave a 0 bit to mark phrase - for ( j = 0 ; j < BACK_BITS ; j++, outbits++ ) - if ( beststart & ( 1 << j ) ) { - out_p[outbits >> 3] |= 1 << ( outbits & 7 ); - } - for ( j = 0 ; j < FRONT_BITS ; j++, outbits++ ) - if ( bestlength & ( 1 << j ) ) { - out_p[outbits >> 3] |= 1 << ( outbits & 7 ); - } - } - - while ( bestlength-- ) - { - val = in.data[i]; - lzss_next[i] = lzss_head[val]; - lzss_head[val] = i; - i++; - } - } - - out_p += ( outbits + 7 ) >> 3; - out.count = out_p - out.data; - return out; -} - -//========================================================================== - -#define MIN_REPT 15 -#define MAX_REPT 0 -#define HUF_TOKENS ( 256 + MAX_REPT ) - -unsigned charbits1[256][HUF_TOKENS]; -int charbitscount1[256][HUF_TOKENS]; - -hnode_t hnodes1[256][HUF_TOKENS * 2]; -int numhnodes1[256]; - -int order0counts[256]; - -/* - ================== - SmallestNode1 - ================== - */ -int SmallestNode1( hnode_t *hnodes, int numhnodes ){ - int i; - int best, bestnode; - - best = 99999999; - bestnode = -1; - for ( i = 0 ; i < numhnodes ; i++ ) - { - if ( hnodes[i].used ) { - continue; - } - if ( !hnodes[i].count ) { - continue; - } - if ( hnodes[i].count < best ) { - best = hnodes[i].count; - bestnode = i; - } - } - - if ( bestnode == -1 ) { - return -1; - } - - hnodes[bestnode].used = true; - return bestnode; -} - - -/* - ================== - BuildChars1 - ================== - */ -void BuildChars1( int prev, int nodenum, unsigned bits, int bitcount ){ - hnode_t *node; - - if ( nodenum < HUF_TOKENS ) { - if ( bitcount > 32 ) { - Error( "bitcount > 32" ); - } - charbits1[prev][nodenum] = bits; - charbitscount1[prev][nodenum] = bitcount; - return; - } - - node = &hnodes1[prev][nodenum]; - bits <<= 1; - BuildChars1( prev, node->children[0], bits, bitcount + 1 ); - bits |= 1; - BuildChars1( prev, node->children[1], bits, bitcount + 1 ); -} - - -/* - ================== - BuildTree1 - ================== - */ -void BuildTree1( int prev ){ - hnode_t *node, *nodebase; - int numhnodes; - - // build the nodes - numhnodes = HUF_TOKENS; - nodebase = hnodes1[prev]; - while ( 1 ) - { - node = &nodebase[numhnodes]; - - // pick two lowest counts - node->children[0] = SmallestNode1( nodebase, numhnodes ); - if ( node->children[0] == -1 ) { - break; // no more - - } - node->children[1] = SmallestNode1( nodebase, numhnodes ); - if ( node->children[1] == -1 ) { - break; - } - - node->count = nodebase[node->children[0]].count + - nodebase[node->children[1]].count; - numhnodes++; - } - numhnodes1[prev] = numhnodes - 1; - BuildChars1( prev, numhnodes - 1, 0, 0 ); -} - - -/* - ================== - Huffman1_Count - ================== - */ -void Huffman1_Count( cblock_t in ){ - int i; - int prev; - int v; - int rept; - - prev = 0; - for ( i = 0 ; i < in.count ; i++ ) - { - v = in.data[i]; - order0counts[v]++; - hnodes1[prev][v].count++; - prev = v; -#if 1 - for ( rept = 1 ; i + rept < in.count && rept < MAX_REPT ; rept++ ) - if ( in.data[i + rept] != v ) { - break; - } - if ( rept > MIN_REPT ) { - hnodes1[prev][255 + rept].count++; - i += rept - 1; - } -#endif - } -} - - -/* - ================== - Huffman1_Build - ================== - */ -byte scaled[256][HUF_TOKENS]; -void Huffman1_Build( FILE *f ){ - int i, j, v; - int max; - int total; - - for ( i = 0 ; i < 256 ; i++ ) - { - // normalize and save the counts - max = 0; - for ( j = 0 ; j < HUF_TOKENS ; j++ ) - { - if ( hnodes1[i][j].count > max ) { - max = hnodes1[i][j].count; - } - } - if ( max == 0 ) { - max = 1; - } - total = 0; - for ( j = 0 ; j < HUF_TOKENS ; j++ ) - { // easy to overflow 32 bits here! - v = ( hnodes1[i][j].count * (double)255 + max - 1 ) / max; - if ( v > 255 ) { - Error( "v > 255" ); - } - scaled[i][j] = hnodes1[i][j].count = v; - if ( v ) { - total++; - } - } - if ( total == 1 ) { // must have two tokens - if ( !scaled[i][0] ) { - scaled[i][0] = hnodes1[i][0].count = 1; - } - else{ - scaled[i][1] = hnodes1[i][1].count = 1; - } - } - - BuildTree1( i ); - } - -#if 0 - // count up the total bits - total = 0; - for ( i = 0 ; i < 256 ; i++ ) - for ( j = 0 ; j < 256 ; j++ ) - total += charbitscount1[i][j] * hnodes1[i][j].count; - - total = ( total + 7 ) / 8; - printf( "%i bytes huffman1 compressed\n", total ); -#endif - - fwrite( scaled, 1, sizeof( scaled ), f ); -} - -/* - ================== - Huffman1 - - Order 1 compression with pre-built table - ================== - */ -cblock_t Huffman1( cblock_t in ){ - int i; - int outbits, c; - unsigned bits; - byte *out_p; - cblock_t out; - int prev; - int v; - int rept; - - out_p = out.data = malloc( in.count * 2 + 1024 ); - memset( out_p, 0, in.count * 2 + 1024 ); - - // write count - *out_p++ = in.count & 255; - *out_p++ = ( in.count >> 8 ) & 255; - *out_p++ = ( in.count >> 16 ) & 255; - *out_p++ = ( in.count >> 24 ) & 255; - - // write bits - outbits = 0; - prev = 0; - for ( i = 0 ; i < in.count ; i++ ) - { - v = in.data[i]; - - c = charbitscount1[prev][v]; - bits = charbits1[prev][v]; - if ( !c ) { - Error( "!bits" ); - } - while ( c ) - { - c--; - if ( bits & ( 1 << c ) ) { - out_p[outbits >> 3] |= 1 << ( outbits & 7 ); - } - outbits++; - } - - prev = v; -#if 1 - // check for repeat encodes - for ( rept = 1 ; i + rept < in.count && rept < MAX_REPT ; rept++ ) - if ( in.data[i + rept] != v ) { - break; - } - if ( rept > MIN_REPT ) { - c = charbitscount1[prev][255 + rept]; - bits = charbits1[prev][255 + rept]; - if ( !c ) { - Error( "!bits" ); - } - while ( c ) - { - c--; - if ( bits & ( 1 << c ) ) { - out_p[outbits >> 3] |= 1 << ( outbits & 7 ); - } - outbits++; - } - i += rept - 1; - } -#endif - } - - out_p += ( outbits + 7 ) >> 3; - - out.count = out_p - out.data; - - return out; -} - -#endif diff --git a/tools/quake3/q3data/md3lib.c b/tools/quake3/q3data/md3lib.c index f2f0eee5..b45d9997 100644 --- a/tools/quake3/q3data/md3lib.c +++ b/tools/quake3/q3data/md3lib.c @@ -54,22 +54,7 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] ){ len[j] = ( float ) sqrt( DotProduct( sides[j], sides[j] ) ); } - -#if 0 - if ( len[0] > len[1] && len[0] > len[2] ) { - longestSide = 0; shortestSide = 1; origin = 2; - } - else if ( len[1] > len[0] && len[1] > len[2] ) { - longestSide = 1; shortestSide = 2; origin = 0; - } - else if ( len[2] > len[0] && len[2] > len[1] ) { - longestSide = 2; shortestSide = 0; origin = 1; - } - else - { - Error( "invalid tag triangle, must be a right triangle with unequal length sides" ); - } -#endif + if ( len[0] > len[1] && len[0] > len[2] ) { hypotSide = 0; origin = 2; diff --git a/tools/quake3/q3data/models.c b/tools/quake3/q3data/models.c index 65fde858..fd365ae9 100644 --- a/tools/quake3/q3data/models.c +++ b/tools/quake3/q3data/models.c @@ -1445,14 +1445,6 @@ void Cmd_ASEConvert( qboolean grabAnims ){ GetToken( qfalse ); g_data.lowerSkipFrameStart = atoi( token ); -#if 0 - if ( !TokenAvailable() ) { - Error( "missing skip end parameter for -playerparms" ); - } - GetToken( qfalse ); - g_data.lowerSkipFrameEnd = atoi( token ); -#endif - if ( !TokenAvailable() ) { Error( "missing upper parameter for -playerparms" ); } @@ -1461,13 +1453,6 @@ void Cmd_ASEConvert( qboolean grabAnims ){ g_data.lowerSkipFrameEnd = g_data.maxUpperFrames - 1; -#if 0 - if ( !TokenAvailable() ) { - Error( "missing head parameter for -playerparms" ); - } - GetToken( qfalse ); - g_data.maxHeadFrames = atoi( token ); -#endif g_data.maxHeadFrames = 1; if ( type != TYPE_ITEM ) { diff --git a/tools/quake3/q3data/oldstuff.c b/tools/quake3/q3data/oldstuff.c index 00cd5742..9bb7511b 100644 --- a/tools/quake3/q3data/oldstuff.c +++ b/tools/quake3/q3data/oldstuff.c @@ -18,130 +18,3 @@ along with GtkRadiant; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#if 0 - -/* -** ReindexTriangle -** -** Given a triangle_t, find which indices match into the associated -** surface's base triangles. -*/ -static void ReindexTriangle( int surfno, triangle_t *pTri, int indices[3] ){ - int t, i; - md3SurfaceData_t *pSurfData = &g_data.surfData[surfno]; - int matches[3][3]; - int numMatches = 0; - - - indices[0] = -1; - indices[1] = -1; - indices[2] = -1; - - for ( i = 0; i < 3; i++ ) - { - numMatches = 0; - - matches[i][0] = -1; - matches[i][1] = -1; - matches[i][2] = -1; - - for ( t = 0; t < pSurfData->header.numVerts; t++ ) - { - if ( !VectorCompare( pTri->verts[i], pSurfData->baseVertexes[t].xyz ) ) { - continue; - } - -/* - if ( !VectorCompare( pTri->normals[i], pSurfData->baseVertexes[t].normal ) ) - continue; - if ( pTri->texcoords[i][0] != pSurfData->baseVertexes[t].st[0] ) - continue; - if ( pTri->texcoords[i][1] != pSurfData->baseVertexes[t].st[1] ) - continue; - */ - - matches[i][numMatches++] = t; - } - - if ( indices[i] == -1 ) { -// Error( "Could not ReindexTriangle, vertex not found" ); - } - } - -#if 0 - for ( t = 0; t < psets[i].numtriangles; t++ ) - { - int b; - - bTri = &g_data.surfData[i].baseTriangles[t]; - - for ( j = 0 ; j < 3 ; j++ ) - { - bVert = &bTri->v[j]; - - // get the xyz index - for ( k = 0; k < g_data.surfData[i].header.numVerts; k++ ) - { - if ( ( g_data.surfData[i].baseVertexes[k].st[0] == bVert->st[0] ) && - ( g_data.surfData[i].baseVertexes[k].st[1] == bVert->st[1] ) && - ( VectorCompare( bVert->xyz, g_data.surfData[i].baseVertexes[k].xyz ) ) && - ( VectorCompare( bVert->normal, g_data.surfData[i].baseVertexes[k].normal ) ) ) { - break; // this vertex is already in the base vertex list - } - } - - if ( k == g_data.surfData[i].header.numVerts ) { // new index - g_data.surfData[i].baseVertexes[g_data.surfData[i].header.numVerts] = *bVert; - g_data.surfData[i].header.numVerts++; - } - - bVert->index = k; - } - } -#endif -} - -const char *FindFrameFile( const char *frame ){ - int time1; - char file1[1024]; - static char retname[1024]; - char base[32]; - char suffix[32]; - const char *s; - - if ( strstr( frame, "." ) ) { - return frame; // allready in dot format - - } - // split 'run1' into 'run' and '1' - s = frame + strlen( frame ) - 1; - - while ( s != frame && *s >= '0' && *s <= '9' ) - s--; - - strcpy( suffix, s + 1 ); - strcpy( base, frame ); - base[s - frame + 1] = 0; - - // check for 'run1.tri' - sprintf( file1, "%s/%s%s.tri", g_cddir, base, suffix ); - time1 = FileTime( file1 ); - if ( time1 != -1 ) { - sprintf( retname, "%s%s.tri", base, suffix ); - return retname; - } - - // check for 'run.1' - sprintf( file1, "%s/%s.%s",g_cddir, base, suffix ); - time1 = FileTime( file1 ); - if ( time1 != -1 ) { - sprintf( retname, "%s.%s", base, suffix ); - return retname; - } - - Error( "frame %s could not be found",frame ); - return NULL; -} - -#endif diff --git a/tools/quake3/q3data/p3dlib.c b/tools/quake3/q3data/p3dlib.c index 2da1ae9b..81a1635e 100644 --- a/tools/quake3/q3data/p3dlib.c +++ b/tools/quake3/q3data/p3dlib.c @@ -261,10 +261,6 @@ int P3DProcess(){ strcpy( p3d.polysetNames[p3d.numPairs], s_token ); } - // strip off trailing unused color information -// if ( strrchr( p3d.polysetNames[p3d.numPairs], '_' ) != 0 ) -// *strrchr( p3d.polysetNames[p3d.numPairs], '_' ) = 0; - p3d.numPairs++; } else @@ -281,54 +277,4 @@ int P3DProcess(){ return 1; } -#if 0 -void SkinFromP3D( const char *file ){ - char filename[1024]; - char *psetName, *associatedShader; - - /* - ** a P3D file contains a list of polysets, each with a list of associated - ** texture names that constitute it's - ** - ** Thus: - ** - ** P3D file -> skin - ** polyset -> polyset - ** texture -> texture.SHADER becomes polyset's shader - */ - sprintf( filename, "%s/%s", g_cddir, file ); - - if ( !P3DLoad( filename ) ) { - Error( "unable to load '%s'", filename ); - } - - while ( P3DGetNextPair( &psetName, &associatedShader ) ) - { - int i; - - // find the polyset in the object that this particular pset/shader pair - // corresponds to and append the shader to it - for ( i = 0; i < g_data.model.numSurfaces; i++ ) - { - if ( !_strcmpi( g_data.surfData[i].header.name, psetName ) ) { - char *p; - - if ( strstr( associatedShader, gamedir + 1 ) ) { - p = strstr( associatedShader, gamedir + 1 ) + strlen( gamedir ) - 1; - } - else - { - p = associatedShader; - } - - strcpy( g_data.surfData[i].shaders[g_data.surfData[i].header.numShaders].name, p ); - - g_data.surfData[i].header.numShaders++; - } - } - - } - P3DClose(); -} -#endif diff --git a/tools/quake3/q3data/stripper.c b/tools/quake3/q3data/stripper.c index 2e90bcef..a70ee6b4 100644 --- a/tools/quake3/q3data/stripper.c +++ b/tools/quake3/q3data/stripper.c @@ -262,16 +262,6 @@ void OrderMesh( int input[][3], int output[][3], int numTris ){ memset( s_used, 0, sizeof( s_used ) ); -#if 0 - FILE *fp = fopen( "strip.txt", "wt" ); - - for ( i = 0; i < numTris; i++ ) - { - fprintf( fp, "%4d: %3d %3d %3d\n", i, input[i][0], input[i][1], input[i][2] ); - } - fclose( fp ); -#endif - // while there are still triangles that are not part of a strip while ( sumStrippedTriangles < numTris ) { diff --git a/tools/quake3/q3data/video.c b/tools/quake3/q3data/video.c index b7be982c..b11186c9 100644 --- a/tools/quake3/q3data/video.c +++ b/tools/quake3/q3data/video.c @@ -602,14 +602,6 @@ static float BTCCompressBlock( float inBlock[4][4][3], unsigned long out[2] ){ float bestError = 10000000000; unsigned int bestEndPoints[2][2]; -#if 0 - // - // find the "ideal" end points for the color vector - // - BTCFindEndpoints( inBlock, endPoints ); - error = BTCQuantizeBlock( inBlock, endPoints, btcQuantizedBlock ); - memcpy( bestEndPoints, endPoints, sizeof( bestEndPoints ) ); -#else for ( blockY = 0; blockY < 4; blockY++ ) { for ( blockX = 0; blockX < 4; blockX++ ) @@ -641,7 +633,6 @@ static float BTCCompressBlock( float inBlock[4][4][3], unsigned long out[2] ){ } error = BTCQuantizeBlock( inBlock, bestEndPoints, btcQuantizedBlock, -1.0f ); -#endif // // encode the results @@ -869,20 +860,11 @@ cblock_t LoadFrame( char *base, int frame, int digits, byte **palette ){ if ( palette ) { *palette = 0; } -// Load256Image (name, &in.data, palette, &width, &height); in.count = width * height; in.width = width; in.height = height; // FIXME: map 0 and 255! -#if 0 - // rle compress - rle = RLE( in ); - free( in.data ); - - return rle; -#endif - return in; } diff --git a/tools/quake3/q3map2/convert_map.c b/tools/quake3/q3map2/convert_map.c index 04c4a4d0..8d59a009 100644 --- a/tools/quake3/q3map2/convert_map.c +++ b/tools/quake3/q3map2/convert_map.c @@ -542,59 +542,6 @@ static void ConvertBrush( FILE *f, int num, bspBrush_t *brush, vec3_t origin, qb } #undef FRAC -#if 0 -/* iterate through the brush sides (ignore the first 6 bevel planes) */ -for ( i = 0; i < brush->numSides; i++ ) -{ - /* get side */ - side = &bspBrushSides[ brush->firstSide + i ]; - - /* get shader */ - if ( side->shaderNum < 0 || side->shaderNum >= numBSPShaders ) { - continue; - } - shader = &bspShaders[ side->shaderNum ]; - if ( !Q_stricmp( shader->shader, "default" ) || !Q_stricmp( shader->shader, "noshader" ) ) { - continue; - } - - /* get texture name */ - if ( !Q_strncasecmp( shader->shader, "textures/", 9 ) ) { - texture = shader->shader + 9; - } - else{ - texture = shader->shader; - } - - /* get plane */ - plane = &bspPlanes[ side->planeNum ]; - - /* make plane points */ - { - vec3_t vecs[ 2 ]; - - - MakeNormalVectors( plane->normal, vecs[ 0 ], vecs[ 1 ] ); - VectorMA( vec3_origin, plane->dist, plane->normal, pts[ 0 ] ); - VectorMA( pts[ 0 ], 256.0f, vecs[ 0 ], pts[ 1 ] ); - VectorMA( pts[ 0 ], 256.0f, vecs[ 1 ], pts[ 2 ] ); - } - - /* offset by origin */ - for ( j = 0; j < 3; j++ ) - VectorAdd( pts[ j ], origin, pts[ j ] ); - - /* print brush side */ - /* ( 640 24 -224 ) ( 448 24 -224 ) ( 448 -232 -224 ) common/caulk 0 48 0 0.500000 0.500000 0 0 0 */ - fprintf( f, "\t\t( %.3f %.3f %.3f ) ( %.3f %.3f %.3f ) ( %.3f %.3f %.3f ) %s 0 0 0 0.5 0.5 0 0 0\n", - pts[ 0 ][ 0 ], pts[ 0 ][ 1 ], pts[ 0 ][ 2 ], - pts[ 1 ][ 0 ], pts[ 1 ][ 1 ], pts[ 1 ][ 2 ], - pts[ 2 ][ 0 ], pts[ 2 ][ 1 ], pts[ 2 ][ 2 ], - texture ); -} -#endif - - /* ConvertPatch() diff --git a/tools/quake3/q3map2/decals.c b/tools/quake3/q3map2/decals.c index 86421b95..8c9c95a3 100644 --- a/tools/quake3/q3map2/decals.c +++ b/tools/quake3/q3map2/decals.c @@ -114,7 +114,6 @@ static qboolean MakeTextureMatrix( decalProjector_t *dp, vec4_t projection, bspD VectorMA( c->xyz, -d, projection, pc ); /* two methods */ - #if 1 { /* old code */ @@ -124,19 +123,6 @@ static qboolean MakeTextureMatrix( decalProjector_t *dp, vec4_t projection, bspD return qfalse; } - /* calculate texture origin */ - #if 0 - s = 0.0; - t = 0.0; - bary[ 0 ] = ( ( b->st[ 0 ] - s ) * ( c->st[ 1 ] - t ) - ( c->st[ 0 ] - s ) * ( b->st[ 1 ] - t ) ) / bb; - bary[ 1 ] = ( ( c->st[ 0 ] - s ) * ( a->st[ 1 ] - t ) - ( a->st[ 0 ] - s ) * ( c->st[ 1 ] - t ) ) / bb; - bary[ 2 ] = ( ( a->st[ 0 ] - s ) * ( b->st[ 1 ] - t ) - ( b->st[ 0 ] - s ) * ( a->st[ 1 ] - t ) ) / bb; - - origin[ 0 ] = bary[ 0 ] * pa[ 0 ] + bary[ 1 ] * pb[ 0 ] + bary[ 2 ] * pc[ 0 ]; - origin[ 1 ] = bary[ 0 ] * pa[ 1 ] + bary[ 1 ] * pb[ 1 ] + bary[ 2 ] * pc[ 1 ]; - origin[ 2 ] = bary[ 0 ] * pa[ 2 ] + bary[ 1 ] * pb[ 2 ] + bary[ 2 ] * pc[ 2 ]; - #endif - /* calculate s vector */ s = a->st[ 0 ] + 1.0; t = a->st[ 1 ] + 0.0; @@ -181,61 +167,8 @@ static qboolean MakeTextureMatrix( decalProjector_t *dp, vec4_t projection, bspD dp->texMat[ 0 ][ 3 ] = a->st[ 0 ] - DotProduct( a->xyz, dp->texMat[ 0 ] ); dp->texMat[ 1 ][ 3 ] = a->st[ 1 ] - DotProduct( a->xyz, dp->texMat[ 1 ] ); } - #else - { - int k; - dvec3_t origin, deltas[ 3 ]; - double texDeltas[ 3 ][ 2 ]; - double delta, texDelta; - - - /* new code */ - - /* calculate deltas */ - VectorSubtract( pa, pb, deltas[ 0 ] ); - VectorSubtract( pa, pc, deltas[ 1 ] ); - VectorSubtract( pb, pc, deltas[ 2 ] ); - Vector2Subtract( a->st, b->st, texDeltas[ 0 ] ); - Vector2Subtract( a->st, c->st, texDeltas[ 1 ] ); - Vector2Subtract( b->st, c->st, texDeltas[ 2 ] ); - - /* walk st */ - for ( i = 0; i < 2; i++ ) - { - /* walk xyz */ - for ( j = 0; j < 3; j++ ) - { - /* clear deltas */ - delta = 0.0; - texDelta = 0.0; - - /* walk deltas */ - for ( k = 0; k < 3; k++ ) - { - if ( fabs( deltas[ k ][ j ] ) > delta && - fabs( texDeltas[ k ][ i ] ) > texDelta ) { - delta = deltas[ k ][ j ]; - texDelta = texDeltas[ k ][ i ]; - } - } - - /* set texture matrix component */ - if ( fabs( delta ) > 0.0 ) { - dp->texMat[ i ][ j ] = texDelta / delta; - } - else{ - dp->texMat[ i ][ j ] = 0.0; - } - } - - /* set translation component */ - dp->texMat[ i ][ 3 ] = a->st[ i ] - DotProduct( pa, dp->texMat[ i ] ); - } - } - #endif /* debug code */ - #if 1 Sys_Printf( "Mat: [ %f %f %f %f ] [ %f %f %f %f ] Theta: %f (%f)\n", dp->texMat[ 0 ][ 0 ], dp->texMat[ 0 ][ 1 ], dp->texMat[ 0 ][ 2 ], dp->texMat[ 0 ][ 3 ], dp->texMat[ 1 ][ 0 ], dp->texMat[ 1 ][ 1 ], dp->texMat[ 1 ][ 2 ], dp->texMat[ 1 ][ 3 ], @@ -246,7 +179,6 @@ static qboolean MakeTextureMatrix( decalProjector_t *dp, vec4_t projection, bspD a->xyz[ 0 ], a->xyz[ 1 ], a->xyz[ 2 ], a->st[ 0 ], a->st[ 1 ], DotProduct( a->xyz, dp->texMat[ 0 ] ) + dp->texMat[ 0 ][ 3 ], DotProduct( a->xyz, dp->texMat[ 1 ] ) + dp->texMat[ 1 ][ 3 ] ); - #endif /* test texture matrix */ s = DotProduct( a->xyz, dp->texMat[ 0 ] ) + dp->texMat[ 0 ][ 3 ]; @@ -528,11 +460,6 @@ void ProcessDecals( void ){ /* remove patch from entity (fixme: leak!) */ e->patches = p->next; - /* push patch to worldspawn (enable this to debug projectors) */ - #if 0 - p->next = entities[ 0 ].patches; - entities[ 0 ].patches = p; - #endif } } diff --git a/tools/quake3/q3map2/facebsp.c b/tools/quake3/q3map2/facebsp.c index e35f2892..a215e69a 100644 --- a/tools/quake3/q3map2/facebsp.c +++ b/tools/quake3/q3map2/facebsp.c @@ -197,18 +197,6 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum, *splitPlaneNum = bestSplit->planenum; *compileFlags = bestSplit->compileFlags; -#if 0 - if ( bestSplit->compileFlags & C_DETAIL ) { - for ( split = list; split; split = split->next ) - if ( !( split->compileFlags & C_DETAIL ) ) { - Sys_FPrintf( SYS_ERR, "DON'T DO SUCH SPLITS (1)\n" ); - } - } - if ( ( node->compileFlags & C_DETAIL ) && !( bestSplit->compileFlags & C_DETAIL ) ) { - Sys_FPrintf( SYS_ERR, "DON'T DO SUCH SPLITS (2)\n" ); - } -#endif - if ( *splitPlaneNum > -1 ) { mapplanes[ *splitPlaneNum ].counter++; } @@ -248,10 +236,6 @@ void BuildFaceTree_r( node_t *node, face_t *list ){ winding_t *frontWinding, *backWinding; int i; int splitPlaneNum, compileFlags; -#if 0 - qboolean isstruct = qfalse; -#endif - /* count faces left */ i = CountFaceList( list ); @@ -285,13 +269,6 @@ void BuildFaceTree_r( node_t *node, face_t *list ){ FreeBspFace( split ); continue; } - -#if 0 - if ( !( split->compileFlags & C_DETAIL ) ) { - isstruct = 1; - } -#endif - /* determine which side the face falls on */ side = WindingOnPlaneSide( split->w, plane->normal, plane->dist ); @@ -351,25 +328,10 @@ void BuildFaceTree_r( node_t *node, face_t *list ){ } } -#if 0 - if ( ( node->compileFlags & C_DETAIL ) && isstruct ) { - Sys_FPrintf( SYS_ERR, "I am detail, my child is structural, this is a wtf1\n", node->has_structural_children ); - } -#endif - for ( i = 0 ; i < 2 ; i++ ) { BuildFaceTree_r( node->children[i], childLists[i] ); node->has_structural_children |= node->children[i]->has_structural_children; } - -#if 0 - if ( ( node->compileFlags & C_DETAIL ) && !( node->children[0]->compileFlags & C_DETAIL ) && node->children[0]->planenum != PLANENUM_LEAF ) { - Sys_FPrintf( SYS_ERR, "I am detail, my child is structural\n", node->has_structural_children ); - } - if ( ( node->compileFlags & C_DETAIL ) && isstruct ) { - Sys_FPrintf( SYS_ERR, "I am detail, my child is structural, this is a wtf2\n", node->has_structural_children ); - } -#endif } diff --git a/tools/quake3/q3map2/image.c b/tools/quake3/q3map2/image.c index c1c737f5..22b8df73 100644 --- a/tools/quake3/q3map2/image.c +++ b/tools/quake3/q3map2/image.c @@ -417,7 +417,6 @@ image_t *ImageLoad( const char *filename ){ LoadDDSBuffer( buffer, size, &image->pixels, &image->width, &image->height ); /* debug code */ - #if 1 { ddsPF_t pf; DDSGetInfo( (ddsBuffer_t*) buffer, NULL, NULL, &pf ); @@ -428,7 +427,6 @@ image_t *ImageLoad( const char *filename ){ WriteTGA( "C:\\games\\quake3\\baseq3\\textures\\rad\\dds_converted.tga", image->pixels, image->width, image->height ); } } - #endif } else { diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index 2571d4d2..ab1c10a5 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -1759,13 +1759,6 @@ void TraceGrid( int num ){ /* store off sample */ for ( i = 0; i < MAX_LIGHTMAPS; i++ ) { -#if 0 - /* do some fudging to keep the ambient from being too low (2003-07-05: 0.25 -> 0.125) */ - if ( !bouncing ) { - VectorMA( gp->ambient[ i ], 0.125f, gp->directed[ i ], gp->ambient[ i ] ); - } -#endif - /* set minimum light and copy off to bytes */ VectorCopy( gp->ambient[ i ], color ); for ( j = 0; j < 3; j++ ) @@ -1778,15 +1771,6 @@ void TraceGrid( int num ){ ColorToBytes( gp->directed[ i ], bgp->directed[ i ], gridScale ); } - /* debug code */ - #if 0 - //% Sys_FPrintf( SYS_VRB, "%10d %10d %10d ", &gp->ambient[ 0 ][ 0 ], &gp->ambient[ 0 ][ 1 ], &gp->ambient[ 0 ][ 2 ] ); - Sys_FPrintf( SYS_VRB, "%9d Amb: (%03.1f %03.1f %03.1f) Dir: (%03.1f %03.1f %03.1f)\n", - num, - gp->ambient[ 0 ][ 0 ], gp->ambient[ 0 ][ 1 ], gp->ambient[ 0 ][ 2 ], - gp->directed[ 0 ][ 0 ], gp->directed[ 0 ][ 1 ], gp->directed[ 0 ][ 2 ] ); - #endif - /* store direction */ NormalToLatLong( thisdir, bgp->latLong ); } diff --git a/tools/quake3/q3map2/light_trace.c b/tools/quake3/q3map2/light_trace.c index cb22bb44..1a4ebf23 100644 --- a/tools/quake3/q3map2/light_trace.c +++ b/tools/quake3/q3map2/light_trace.c @@ -1345,39 +1345,6 @@ void SetupTraceNodes( void ){ numTraceWindings = 0; maxTraceWindings = 0; deadWinding = -1; - - /* debug code: write out trace triangles to an alias obj file */ - #if 0 - { - int i, j; - FILE *file; - char filename[ 1024 ]; - traceWinding_t *tw; - - - /* open the file */ - strcpy( filename, source ); - StripExtension( filename ); - strcat( filename, ".lin" ); - Sys_Printf( "Opening light trace file %s...\n", filename ); - file = fopen( filename, "w" ); - if ( file == NULL ) { - Error( "Error opening %s for writing", filename ); - } - - /* walk node list */ - for ( i = 0; i < numTraceWindings; i++ ) - { - tw = &traceWindings[ i ]; - for ( j = 0; j < tw->numVerts + 1; j++ ) - fprintf( file, "%f %f %f\n", - tw->v[ j % tw->numVerts ].xyz[ 0 ], tw->v[ j % tw->numVerts ].xyz[ 1 ], tw->v[ j % tw->numVerts ].xyz[ 2 ] ); - } - - /* close it */ - fclose( file ); - } - #endif } diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index e688deb9..17a268c9 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -711,14 +711,6 @@ static void MapTriangle_r( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t bspDrawVert_t mid, *dv2[ 3 ]; int max; - - /* map the vertexes */ - #if 0 - MapSingleLuxel( lm, info, dv[ 0 ], plane, 1, stv, ttv ); - MapSingleLuxel( lm, info, dv[ 1 ], plane, 1, stv, ttv ); - MapSingleLuxel( lm, info, dv[ 2 ], plane, 1, stv, ttv ); - #endif - /* subdivide calc */ { int i; @@ -1091,52 +1083,6 @@ void MapRawLightmap( int rawLightmapNum ){ /* get verts */ verts = mesh->verts; - /* debug code */ - #if 0 - if ( lm->plane ) { - Sys_Printf( "Planar patch: [%1.3f %1.3f %1.3f] [%1.3f %1.3f %1.3f] [%1.3f %1.3f %1.3f]\n", - lm->plane[ 0 ], lm->plane[ 1 ], lm->plane[ 2 ], - lm->vecs[ 0 ][ 0 ], lm->vecs[ 0 ][ 1 ], lm->vecs[ 0 ][ 2 ], - lm->vecs[ 1 ][ 0 ], lm->vecs[ 1 ][ 1 ], lm->vecs[ 1 ][ 2 ] ); - } - #endif - - /* map the mesh quads */ - #if 0 - - for ( mapNonAxial = 0; mapNonAxial < 2; mapNonAxial++ ) - { - for ( y = 0; y < ( mesh->height - 1 ); y++ ) - { - for ( x = 0; x < ( mesh->width - 1 ); x++ ) - { - /* set indexes */ - pw[ 0 ] = x + ( y * mesh->width ); - pw[ 1 ] = x + ( ( y + 1 ) * mesh->width ); - pw[ 2 ] = x + 1 + ( ( y + 1 ) * mesh->width ); - pw[ 3 ] = x + 1 + ( y * mesh->width ); - pw[ 4 ] = x + ( y * mesh->width ); /* same as pw[ 0 ] */ - - /* set radix */ - r = ( x + y ) & 1; - - /* get drawverts and map first triangle */ - dv[ 0 ] = &verts[ pw[ r + 0 ] ]; - dv[ 1 ] = &verts[ pw[ r + 1 ] ]; - dv[ 2 ] = &verts[ pw[ r + 2 ] ]; - MapTriangle( lm, info, dv, mapNonAxial ); - - /* get drawverts and map second triangle */ - dv[ 0 ] = &verts[ pw[ r + 0 ] ]; - dv[ 1 ] = &verts[ pw[ r + 2 ] ]; - dv[ 2 ] = &verts[ pw[ r + 3 ] ]; - MapTriangle( lm, info, dv, mapNonAxial ); - } - } - } - - #else - for ( y = 0; y < ( mesh->height - 1 ); y++ ) { for ( x = 0; x < ( mesh->width - 1 ); x++ ) @@ -1175,8 +1121,6 @@ void MapRawLightmap( int rawLightmapNum ){ } } - #endif - /* free the mesh */ FreeMesh( mesh ); break; @@ -1326,57 +1270,6 @@ void MapRawLightmap( int rawLightmapNum ){ luxel[ 3 ] = 1.0f; } } - - /* debug code */ - #if 0 - Sys_Printf( "\n" ); - for ( y = 0; y < lm->sh; y++ ) - { - for ( x = 0; x < lm->sw; x++ ) - { - vec3_t mins, maxs; - - - cluster = SUPER_CLUSTER( x, y ); - origin = SUPER_ORIGIN( x, y ); - normal = SUPER_NORMAL( x, y ); - luxel = SUPER_LUXEL( x, y ); - - if ( *cluster < 0 ) { - continue; - } - - /* check if within the bounding boxes of all surfaces referenced */ - ClearBounds( mins, maxs ); - for ( n = 0; n < lm->numLightSurfaces; n++ ) - { - int TOL; - info = &surfaceInfos[ lightSurfaces[ lm->firstLightSurface + n ] ]; - TOL = info->sampleSize + 2; - AddPointToBounds( info->mins, mins, maxs ); - AddPointToBounds( info->maxs, mins, maxs ); - if ( origin[ 0 ] > ( info->mins[ 0 ] - TOL ) && origin[ 0 ] < ( info->maxs[ 0 ] + TOL ) && - origin[ 1 ] > ( info->mins[ 1 ] - TOL ) && origin[ 1 ] < ( info->maxs[ 1 ] + TOL ) && - origin[ 2 ] > ( info->mins[ 2 ] - TOL ) && origin[ 2 ] < ( info->maxs[ 2 ] + TOL ) ) { - break; - } - } - - /* inside? */ - if ( n < lm->numLightSurfaces ) { - continue; - } - - /* report bogus origin */ - Sys_Printf( "%6d [%2d,%2d] (%4d): XYZ(%+4.1f %+4.1f %+4.1f) LO(%+4.1f %+4.1f %+4.1f) HI(%+4.1f %+4.1f %+4.1f) <%3.0f>\n", - rawLightmapNum, x, y, *cluster, - origin[ 0 ], origin[ 1 ], origin[ 2 ], - mins[ 0 ], mins[ 1 ], mins[ 2 ], - maxs[ 0 ], maxs[ 1 ], maxs[ 2 ], - luxel[ 3 ] ); - } - } - #endif } @@ -2245,15 +2138,6 @@ void IlluminateRawLightmap( int rawLightmapNum ){ normal = SUPER_NORMAL( x, y ); flag = SUPER_FLAG( x, y ); -#if 0 - ////////// 27's temp hack for testing edge clipping //// - if ( origin[0] == 0 && origin[1] == 0 && origin[2] == 0 ) { - lightLuxel[ 1 ] = 255; - lightLuxel[ 3 ] = 1.0f; - totalLighted++; - } - else -#endif { /* set contribution count */ lightLuxel[ 3 ] = 1.0f; @@ -2734,44 +2618,6 @@ void IlluminateRawLightmap( int rawLightmapNum ){ } } - -#if 0 - // audit pass - for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ ) - { - /* early out */ - if ( lm->superLuxels[ lightmapNum ] == NULL ) { - continue; - } - for ( y = 0; y < lm->sh; y++ ) - for ( x = 0; x < lm->sw; x++ ) - { - /* get cluster */ - cluster = SUPER_CLUSTER( x, y ); - luxel = SUPER_LUXEL( lightmapNum, x, y ); - deluxel = SUPER_DELUXEL( x, y ); - if ( !luxel || !deluxel || !cluster ) { - Sys_FPrintf( SYS_VRB, "WARNING: I got NULL'd.\n" ); - continue; - } - else if ( *cluster < 0 ) { - // unmapped pixel - // should have neither deluxemap nor lightmap - if ( deluxel[3] ) { - Sys_FPrintf( SYS_VRB, "WARNING: I have written deluxe to an unmapped luxel. Sorry.\n" ); - } - } - else - { - // mapped pixel - // should have both deluxemap and lightmap - if ( deluxel[3] ) { - Sys_FPrintf( SYS_VRB, "WARNING: I forgot to write deluxe to a mapped luxel. Sorry.\n" ); - } - } - } - } -#endif } @@ -3997,21 +3843,6 @@ void CreateTraceLightsForBounds( vec3_t mins, vec3_t maxs, vec3_t normal, int nu lightsEnvelopeCulled++; continue; } - - /* check bounding box against light's pvs envelope (note: this code never eliminated any lights, so disabling it) */ - #if 0 - skip = qfalse; - for ( i = 0; i < 3; i++ ) - { - if ( mins[ i ] > light->maxs[ i ] || maxs[ i ] < light->mins[ i ] ) { - skip = qtrue; - } - } - if ( skip ) { - lightsBoundsCulled++; - continue; - } - #endif } /* planar surfaces (except twosided surfaces) have a couple more checks */ @@ -4376,61 +4207,6 @@ void FloodLightRawLightmapPass( rawLightmap_t *lm, vec3_t lmFloodLightRGB, float /* testing no filtering */ return; - -#if 0 - - /* filter "dirt" */ - for ( y = 0; y < lm->sh; y++ ) - { - for ( x = 0; x < lm->sw; x++ ) - { - /* get luxel */ - cluster = SUPER_CLUSTER( x, y ); - floodlight = SUPER_FLOODLIGHT( x, y ); - - /* filter dirt by adjacency to unmapped luxels */ - average = *floodlight; - samples = 1.0f; - for ( sy = ( y - 1 ); sy <= ( y + 1 ); sy++ ) - { - if ( sy < 0 || sy >= lm->sh ) { - continue; - } - - for ( sx = ( x - 1 ); sx <= ( x + 1 ); sx++ ) - { - if ( sx < 0 || sx >= lm->sw || ( sx == x && sy == y ) ) { - continue; - } - - /* get neighboring luxel */ - cluster = SUPER_CLUSTER( sx, sy ); - floodlight2 = SUPER_FLOODLIGHT( sx, sy ); - if ( *cluster < 0 || *floodlight2 <= 0.0f ) { - continue; - } - - /* add it */ - average += *floodlight2; - samples += 1.0f; - } - - /* bail */ - if ( samples <= 0.0f ) { - break; - } - } - - /* bail */ - if ( samples <= 0.0f ) { - continue; - } - - /* scale dirt */ - *floodlight = average / samples; - } - } -#endif } void FloodLightRawLightmap( int rawLightmapNum ){ diff --git a/tools/quake3/q3map2/lightmaps_ydnar.c b/tools/quake3/q3map2/lightmaps_ydnar.c index 462331f1..4772c15b 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -357,7 +357,6 @@ void FinishRawLightmap( rawLightmap_t *lm ){ is = 1.0f / superSample; /* scale the vectors and shift the origin */ - #if 1 /* new code that works for arbitrary supersampling values */ VectorMA( lm->origin, -0.5, lm->vecs[ 0 ], lm->origin ); VectorMA( lm->origin, -0.5, lm->vecs[ 1 ], lm->origin ); @@ -365,13 +364,6 @@ void FinishRawLightmap( rawLightmap_t *lm ){ VectorScale( lm->vecs[ 1 ], is, lm->vecs[ 1 ] ); VectorMA( lm->origin, is, lm->vecs[ 0 ], lm->origin ); VectorMA( lm->origin, is, lm->vecs[ 1 ], lm->origin ); - #else - /* old code that only worked with a value of 2 */ - VectorScale( lm->vecs[ 0 ], is, lm->vecs[ 0 ] ); - VectorScale( lm->vecs[ 1 ], is, lm->vecs[ 1 ] ); - VectorMA( lm->origin, -is, lm->vecs[ 0 ], lm->origin ); - VectorMA( lm->origin, -is, lm->vecs[ 1 ], lm->origin ); - #endif } /* allocate bsp lightmap storage */ @@ -1733,22 +1725,6 @@ static qboolean ApproximateLightmap( rawLightmap_t *lm ){ return qfalse; } - /* test for jmonroe */ - #if 0 - /* don't approx lightmaps with styled twins */ - if ( lm->numStyledTwins > 0 ) { - return qfalse; - } - - /* don't approx lightmaps with styles */ - for ( i = 1; i < MAX_LIGHTMAPS; i++ ) - { - if ( lm->styles[ i ] != LS_NONE ) { - return qfalse; - } - } - #endif - /* assume reduced until shadow detail is found */ approximated = qtrue; diff --git a/tools/quake3/q3map2/map.c b/tools/quake3/q3map2/map.c index d786fc54..0001fa9c 100644 --- a/tools/quake3/q3map2/map.c +++ b/tools/quake3/q3map2/map.c @@ -581,24 +581,10 @@ void AddBrushBevels( void ){ // see if the plane is allready present for ( i = 0, s = buildBrush->sides; i < buildBrush->numsides; i++, s++ ) { - /* ydnar: testing disabling of mre code */ - #if 0 - if ( dir > 0 ) { - if ( mapplanes[s->planenum].normal[axis] >= 0.9999f ) { - break; - } - } - else { - if ( mapplanes[s->planenum].normal[axis] <= -0.9999f ) { - break; - } - } - #else if ( ( dir > 0 && mapplanes[ s->planenum ].normal[ axis ] == 1.0f ) || ( dir < 0 && mapplanes[ s->planenum ].normal[ axis ] == -1.0f ) ) { break; } - #endif } if ( i == buildBrush->numsides ) { diff --git a/tools/quake3/q3map2/model.c b/tools/quake3/q3map2/model.c index 94a80487..40ed72b8 100644 --- a/tools/quake3/q3map2/model.c +++ b/tools/quake3/q3map2/model.c @@ -175,25 +175,7 @@ picoModel_t *LoadModel( const char *name, int frame ){ PicoSetModelName( *pm, name ); PicoSetModelFrameNum( *pm, frame ); } - - /* debug code */ - #if 0 - { - int numSurfaces, numVertexes; - picoSurface_t *ps; - - - Sys_Printf( "Model %s\n", name ); - numSurfaces = PicoGetModelNumSurfaces( *pm ); - for ( i = 0; i < numSurfaces; i++ ) - { - ps = PicoGetModelSurface( *pm, i ); - numVertexes = PicoGetSurfaceNumVertexes( ps ); - Sys_Printf( "Surface %d has %d vertexes\n", i, numVertexes ); - } - } - #endif - + /* set count */ if ( *pm != NULL ) { numPicoModels++; diff --git a/tools/quake3/q3map2/portals.c b/tools/quake3/q3map2/portals.c index aee1446e..2b77f3d3 100644 --- a/tools/quake3/q3map2/portals.c +++ b/tools/quake3/q3map2/portals.c @@ -345,16 +345,6 @@ void MakeNodePortal( node_t *node ){ return; } - - /* ydnar: adding this here to fix degenerate windings */ - #if 0 - if ( FixWinding( w ) == qfalse ) { - c_badportals++; - FreeWinding( w ); - return; - } - #endif - if ( WindingIsTiny( w ) ) { c_tinyportals++; FreeWinding( w ); diff --git a/tools/quake3/q3map2/prtfile.c b/tools/quake3/q3map2/prtfile.c index 2cd7015c..0998a95a 100644 --- a/tools/quake3/q3map2/prtfile.c +++ b/tools/quake3/q3map2/prtfile.c @@ -278,19 +278,11 @@ void WriteFaceFile_r( node_t *node ){ ================ */ void NumberLeafs_r( node_t *node, int c ){ -#if 0 - portal_t *p; -#endif if ( node->planenum != PLANENUM_LEAF ) { // decision node node->cluster = -99; if ( node->has_structural_children ) { -#if 0 - if ( c >= 0 ) { - Sys_FPrintf( SYS_ERR,"THIS CANNOT HAPPEN\n" ); - } -#endif NumberLeafs_r( node->children[0], c ); NumberLeafs_r( node->children[1], c ); } @@ -318,29 +310,6 @@ void NumberLeafs_r( node_t *node, int c ){ } node->cluster = c; - -#if 0 - // count the portals - for ( p = node->portals ; p ; ) - { - if ( p->nodes[0] == node ) { // only write out from first leaf - if ( PortalPassable( p ) ) { - num_visportals++; - } - else{ - num_solidfaces++; - } - p = p->next[0]; - } - else - { - if ( !PortalPassable( p ) ) { - num_solidfaces++; - } - p = p->next[1]; - } - } -#endif } diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 7bbbc42b..6ec56ee1 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -99,14 +99,12 @@ #define MAC_STATIC #endif -#if 1 - #ifdef WIN32 - #define Q_stricmp stricmp - #define Q_strncasecmp strnicmp - #else - #define Q_stricmp strcasecmp - #define Q_strncasecmp strncasecmp - #endif +#ifdef WIN32 + #define Q_stricmp stricmp + #define Q_strncasecmp strnicmp +#else + #define Q_stricmp strcasecmp + #define Q_strncasecmp strncasecmp #endif /* macro version */ diff --git a/tools/quake3/q3map2/shaders.c b/tools/quake3/q3map2/shaders.c index 75cab6b0..58b0157c 100644 --- a/tools/quake3/q3map2/shaders.c +++ b/tools/quake3/q3map2/shaders.c @@ -1975,17 +1975,6 @@ static void ParseShaderFile( const char *filename ){ else if ( !Q_stricmp( token, "q3map_styleMarker2" ) ) { /* uses depthFunc equal */ si->styleMarker = 2; } - - /* ydnar: default to searching for q3map_ */ -#if 0 - else - { - Sys_FPrintf( SYS_VRB, "Attempting to match %s with a known surfaceparm\n", token ); - if ( ApplySurfaceParm( &token[ 6 ], &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) { - Sys_Printf( "WARNING: Unknown q3map_* directive \"%s\"\n", token ); - } - } -#endif } diff --git a/tools/quake3/q3map2/surface.c b/tools/quake3/q3map2/surface.c index 2aeda857..20ea6f0e 100644 --- a/tools/quake3/q3map2/surface.c +++ b/tools/quake3/q3map2/surface.c @@ -717,36 +717,6 @@ byte GetShaderIndexForPoint( indexMap_t *im, vec3_t eMins, vec3_t eMaxs, vec3_t return 0; } - /* this code is really broken */ - #if 0 - /* legacy precision fudges for terrain */ - for ( i = 0; i < 3; i++ ) - { - mins[ i ] = floor( eMins[ i ] + 0.1 ); - maxs[ i ] = floor( eMaxs[ i ] + 0.1 ); - size[ i ] = maxs[ i ] - mins[ i ]; - } - - /* find st (fixme: support more than just z-axis projection) */ - s = floor( point[ 0 ] + 0.1f - mins[ 0 ] ) / size[ 0 ]; - t = floor( maxs[ 1 ] - point[ 1 ] + 0.1f ) / size[ 1 ]; - if ( s < 0.0f ) { - s = 0.0f; - } - else if ( s > 1.0f ) { - s = 1.0f; - } - if ( t < 0.0f ) { - t = 0.0f; - } - else if ( t > 1.0f ) { - t = 1.0f; - } - - /* make xy */ - x = ( im->w - 1 ) * s; - y = ( im->h - 1 ) * t; - #else /* get size */ for ( i = 0; i < 3; i++ ) { @@ -774,7 +744,6 @@ byte GetShaderIndexForPoint( indexMap_t *im, vec3_t eMins, vec3_t eMaxs, vec3_t else if ( y > ( im->h - 1 ) ) { y = ( im->h - 1 ); } - #endif /* return index */ return im->pixels[ y * im->w + x ]; @@ -2167,23 +2136,6 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ){ p2 = &mapplanes[ ds->planeNum ]; VectorCopy( p2->normal, plane2 ); plane2[ 3 ] = p2->dist; - - #if 0 - /* div0: this is the plague (inaccurate) */ - vec4_t reverse; - - /* invert surface plane */ - VectorSubtract( vec3_origin, plane2, reverse ); - reverse[ 3 ] = -plane2[ 3 ]; - - /* compare planes */ - if ( DotProduct( plane1, plane2 ) > 0.999f && fabs( plane1[ 3 ] - plane2[ 3 ] ) < 0.001f ) { - return FilterWindingIntoTree_r( w, ds, node->children[ 0 ] ); - } - if ( DotProduct( plane1, reverse ) > 0.999f && fabs( plane1[ 3 ] - reverse[ 3 ] ) < 0.001f ) { - return FilterWindingIntoTree_r( w, ds, node->children[ 1 ] ); - } - #else /* div0: this is the cholera (doesn't hit enough) */ /* the drawsurf might have an associated plane, if so, force a filter here */ @@ -2193,7 +2145,6 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ){ if ( ds->planeNum == ( node->planenum ^ 1 ) ) { return FilterWindingIntoTree_r( w, ds, node->children[ 1 ] ); } - #endif } /* clip the winding by this plane */ diff --git a/tools/quake3/q3map2/surface_meta.c b/tools/quake3/q3map2/surface_meta.c index 8d4f3c36..83832e86 100644 --- a/tools/quake3/q3map2/surface_meta.c +++ b/tools/quake3/q3map2/surface_meta.c @@ -1090,14 +1090,6 @@ void FixMetaTJunctions( void ){ continue; } - #if 0 - dist = DotProduct( pt, edges[ k ].edge ) - edges[ k ].edge[ 3 ]; - if ( dist <= -0.0f || dist >= edges[ k ].length ) { - continue; - } - amount = dist / edges[ k ].length; - #endif - /* the edge opposite the zero-weighted vertex was hit, so use that as an amount */ a = &metaVerts[ tri->indexes[ k % 3 ] ]; b = &metaVerts[ tri->indexes[ ( k + 1 ) % 3 ] ]; @@ -1450,14 +1442,6 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri, if ( ds->shaderInfo != tri->si || ds->fogNum != tri->fogNum || ds->sampleSize != tri->sampleSize ) { return 0; } - #if 0 - if ( !( ds->shaderInfo->compileFlags & C_VERTEXLIT ) && - //% VectorCompare( ds->lightmapAxis, tri->lightmapAxis ) == qfalse ) - DotProduct( ds->lightmapAxis, tri->plane ) < 0.25f ) { - return 0; - } - #endif - /* planar surfaces will only merge with triangles in the same plane */ if ( npDegrees == 0.0f && ds->shaderInfo->nonplanar == qfalse && ds->planeNum >= 0 ) { if ( VectorCompare( mapplanes[ ds->planeNum ].normal, tri->plane ) == qfalse || mapplanes[ ds->planeNum ].dist != tri->plane[ 3 ] ) { @@ -1817,37 +1801,6 @@ static int CompareMetaTriangles( const void *a, const void *b ){ return -1; } - /* then plane */ - #if 0 - else if ( npDegrees == 0.0f && ( (const metaTriangle_t*) a )->si->nonplanar == qfalse && - ( (const metaTriangle_t*) a )->planeNum >= 0 && ( (const metaTriangle_t*) a )->planeNum >= 0 ) { - if ( ( (const metaTriangle_t*) a )->plane[ 3 ] < ( (const metaTriangle_t*) b )->plane[ 3 ] ) { - return 1; - } - else if ( ( (const metaTriangle_t*) a )->plane[ 3 ] > ( (const metaTriangle_t*) b )->plane[ 3 ] ) { - return -1; - } - else if ( ( (const metaTriangle_t*) a )->plane[ 0 ] < ( (const metaTriangle_t*) b )->plane[ 0 ] ) { - return 1; - } - else if ( ( (const metaTriangle_t*) a )->plane[ 0 ] > ( (const metaTriangle_t*) b )->plane[ 0 ] ) { - return -1; - } - else if ( ( (const metaTriangle_t*) a )->plane[ 1 ] < ( (const metaTriangle_t*) b )->plane[ 1 ] ) { - return 1; - } - else if ( ( (const metaTriangle_t*) a )->plane[ 1 ] > ( (const metaTriangle_t*) b )->plane[ 1 ] ) { - return -1; - } - else if ( ( (const metaTriangle_t*) a )->plane[ 2 ] < ( (const metaTriangle_t*) b )->plane[ 2 ] ) { - return 1; - } - else if ( ( (const metaTriangle_t*) a )->plane[ 2 ] > ( (const metaTriangle_t*) b )->plane[ 2 ] ) { - return -1; - } - } - #endif - /* then position in world */ /* find mins */ diff --git a/tools/quake3/q3map2/visflow.c b/tools/quake3/q3map2/visflow.c index efbfffde..d6c92262 100644 --- a/tools/quake3/q3map2/visflow.c +++ b/tools/quake3/q3map2/visflow.c @@ -301,7 +301,6 @@ fixedWinding_t *ClipToSeperators( fixedWinding_t *source, fixedWinding_t *pass, // find out which side of the generated seperating plane has the // source portal // -#if 1 fliptest = qfalse; for ( k = 0 ; k < source->numpoints ; k++ ) { @@ -323,9 +322,7 @@ fixedWinding_t *ClipToSeperators( fixedWinding_t *source, fixedWinding_t *pass, if ( k == source->numpoints ) { continue; // planar with source portal } -#else - fliptest = flipclip; -#endif + // // flip the normal if the source portal is backwards // @@ -333,7 +330,6 @@ fixedWinding_t *ClipToSeperators( fixedWinding_t *source, fixedWinding_t *pass, VectorSubtract( vec3_origin, plane.normal, plane.normal ); plane.dist = -plane.dist; } -#if 1 // // if all of the pass portal points are now on the positive side, // this is the seperating plane @@ -362,18 +358,7 @@ fixedWinding_t *ClipToSeperators( fixedWinding_t *source, fixedWinding_t *pass, if ( !counts[0] ) { continue; // planar with seperating plane } -#else - k = ( j + 1 ) % pass->numpoints; - d = DotProduct( pass->points[k], plane.normal ) - plane.dist; - if ( d < -ON_EPSILON ) { - continue; - } - k = ( j + pass->numpoints - 1 ) % pass->numpoints; - d = DotProduct( pass->points[k], plane.normal ) - plane.dist; - if ( d < -ON_EPSILON ) { - continue; - } -#endif + // // flip the normal if we want the back side // @@ -510,15 +495,12 @@ void RecursiveLeafFlow( int leafnum, threaddata_t *thread, pstack_t *prevstack ) VectorSubtract( vec3_origin, p->plane.normal, backplane.normal ); backplane.dist = -p->plane.dist; -// c_portalcheck++; - stack.portal = p; stack.next = NULL; stack.freewindings[0] = 1; stack.freewindings[1] = 1; stack.freewindings[2] = 1; -#if 1 { float d; @@ -538,15 +520,7 @@ void RecursiveLeafFlow( int leafnum, threaddata_t *thread, pstack_t *prevstack ) } } } -#else - stack.pass = VisChopWinding( p->winding, &stack, &thread->pstack_head.portalplane ); - if ( !stack.pass ) { - continue; - } -#endif - -#if 1 { float d; @@ -571,12 +545,6 @@ void RecursiveLeafFlow( int leafnum, threaddata_t *thread, pstack_t *prevstack ) } } } -#else - stack.source = VisChopWinding( prevstack->source, &stack, &backplane ); - if ( !stack.source ) { - continue; - } -#endif if ( !prevstack->pass ) { // the second leaf can only be blocked if coplanar @@ -883,15 +851,12 @@ void RecursivePassagePortalFlow( vportal_t *portal, threaddata_t *thread, pstack VectorSubtract( vec3_origin, p->plane.normal, backplane.normal ); backplane.dist = -p->plane.dist; -// c_portalcheck++; - stack.portal = p; stack.next = NULL; stack.freewindings[0] = 1; stack.freewindings[1] = 1; stack.freewindings[2] = 1; -#if 1 { float d; @@ -911,15 +876,7 @@ void RecursivePassagePortalFlow( vportal_t *portal, threaddata_t *thread, pstack } } } -#else - stack.pass = VisChopWinding( p->winding, &stack, &thread->pstack_head.portalplane ); - if ( !stack.pass ) { - continue; - } -#endif - -#if 1 { float d; @@ -944,12 +901,6 @@ void RecursivePassagePortalFlow( vportal_t *portal, threaddata_t *thread, pstack } } } -#else - stack.source = VisChopWinding( prevstack->source, &stack, &backplane ); - if ( !stack.source ) { - continue; - } -#endif if ( !prevstack->pass ) { // the second leaf can only be blocked if coplanar @@ -1208,7 +1159,6 @@ int AddSeperators( fixedWinding_t *source, fixedWinding_t *pass, qboolean flipcl // find out which side of the generated seperating plane has the // source portal // -#if 1 fliptest = qfalse; for ( k = 0 ; k < source->numpoints ; k++ ) { @@ -1230,9 +1180,7 @@ int AddSeperators( fixedWinding_t *source, fixedWinding_t *pass, qboolean flipcl if ( k == source->numpoints ) { continue; // planar with source portal } -#else - fliptest = flipclip; -#endif + // // flip the normal if the source portal is backwards // @@ -1240,7 +1188,7 @@ int AddSeperators( fixedWinding_t *source, fixedWinding_t *pass, qboolean flipcl VectorSubtract( vec3_origin, plane.normal, plane.normal ); plane.dist = -plane.dist; } -#if 1 + // // if all of the pass portal points are now on the positive side, // this is the seperating plane @@ -1269,18 +1217,7 @@ int AddSeperators( fixedWinding_t *source, fixedWinding_t *pass, qboolean flipcl if ( !counts[0] ) { continue; // planar with seperating plane } -#else - k = ( j + 1 ) % pass->numpoints; - d = DotProduct( pass->points[k], plane.normal ) - plane.dist; - if ( d < -ON_EPSILON ) { - continue; - } - k = ( j + pass->numpoints - 1 ) % pass->numpoints; - d = DotProduct( pass->points[k], plane.normal ) - plane.dist; - if ( d < -ON_EPSILON ) { - continue; - } -#endif + // // flip the normal if we want the back side //