Moved CommandlineProgressBar out of RenderCommon.h to its own files

This commit is contained in:
Robert Beckebans 2022-01-22 16:20:21 +01:00
parent 2e3c4eb048
commit b31840bda1
8 changed files with 179 additions and 291 deletions

View file

@ -690,7 +690,6 @@ Copyright (c) 2019 Maximiliano Ruben Viamonte aka 'Stradex'
CC0 1.0 Universal (CC0 1.0)
Public Domain Dedication
No Copyright
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.

View file

@ -33,7 +33,7 @@ You need to call exportImagesToTrenchBroom and exportModelsToTrenchBroom once an
* Added new icons to TrenchBroom for certain entities like lights, speakers or particle emitters
* TrenchBroom allows to select the Quake 1 light style
* TrenchBroom offers a dropdown menu to select the Quake 1 light style for lights
* Drastically improved loading time of textures for materials in TrenchBroom
@ -53,6 +53,8 @@ You need to call exportImagesToTrenchBroom and exportModelsToTrenchBroom once an
* Added new Creative Commons CC0 textures/common/ and textures/editor/ replacement textures because they didn't ship with the BFG edition
* Added base/convert_maps_to_valve220.cfg which lets you convert all maps to the Valve 220 .map format in one shot
_______________________________________
30 October 2021 - RBDOOM-3-BFG 1.3.0 - Download it from the [RBDOOM-3-BFG ModDB Page](https://www.moddb.com/mods/rbdoom-3-bfg)

View file

@ -3,7 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2015-2021 Robert Beckebans
Copyright (C) 2015-2022 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -32,6 +32,7 @@ If you have questions concerning this license or the applicable additional terms
#include "../renderer/Image.h"
#include "../renderer/DXT/DXTCodec.h"
#include "../renderer/Color/ColorSpace.h"
#include "../renderer/CmdlineProgressbar.h"
/*
@ -2823,12 +2824,17 @@ void idDeclManagerLocal::ExportImagesToTrenchBroom_f( const idCmdArgs& args )
idFileList* files = fileSystem->ListFilesTree( "generated", ".bimage", true, true );
CommandlineProgressBar progressBar( files->GetList().Num(), renderSystem->GetWidth(), renderSystem->GetHeight() );
progressBar.Start();
int totalStart = Sys_Milliseconds();
for( int f = 0; f < files->GetList().Num(); f++ )
{
idStr imageName = files->GetList()[ f ];
progressBar.Increment( true );
if( idStr::Icmpn( imageName, "generated/images/env/maps/game/", 31 ) == 0 )
{
// skip HDR cache data
@ -2887,7 +2893,7 @@ void idDeclManagerLocal::ExportImagesToTrenchBroom_f( const idCmdArgs& args )
if( ( imgHeader.format == FMT_DXT5 || imgHeader.format == FMT_DXT1 ) && ( imgHeader.colorFormat != CFM_GREEN_ALPHA ) )
{
idLib::Printf( "Exporting image '%s'\n", imageName.c_str() );
//idLib::Printf( "Exporting image '%s'\n", imageName.c_str() );
// RB: Images that are were DXT compressed and aren't multiples of 4 were padded out before compressing
// however the idBinaryImageData stores the original input width and height.

View file

@ -0,0 +1,107 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 2018-2022 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "precompiled.h"
#pragma hdrstop
#include "RenderCommon.h"
#include "CmdlineProgressbar.h"
void CommandlineProgressBar::Start()
{
// restore the original resolution, same as "vid_restart"
glConfig.nativeScreenWidth = sysWidth;
glConfig.nativeScreenHeight = sysHeight;
R_SetNewMode( false );
common->Printf( "0%% 10 20 30 40 50 60 70 80 90 100%%\n" );
common->Printf( "|----|----|----|----|----|----|----|----|----|----|\n" );
common->UpdateScreen( false );
}
void CommandlineProgressBar::Increment( bool updateScreen )
{
if( ( count + 1 ) >= nextTicCount )
{
if( updateScreen )
{
// restore the original resolution, same as "vid_restart"
glConfig.nativeScreenWidth = sysWidth;
glConfig.nativeScreenHeight = sysHeight;
R_SetNewMode( false );
// resize frame buffers (this triggers SwapBuffers)
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
}
size_t ticsNeeded = ( size_t )( ( ( double )( count + 1 ) / expectedCount ) * 50.0 );
do
{
common->Printf( "*" );
}
while( ++tics < ticsNeeded );
nextTicCount = ( size_t )( ( tics / 50.0 ) * expectedCount );
if( count == ( expectedCount - 1 ) )
{
if( tics < 51 )
{
common->Printf( "*" );
}
common->Printf( "\n" );
}
if( updateScreen )
{
common->UpdateScreen( false );
// swap front / back buffers
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
}
}
count++;
}
void CommandlineProgressBar::Reset()
{
count = 0;
tics = 0;
nextTicCount = 0;
}
void CommandlineProgressBar::Reset( int expected )
{
expectedCount = expected;
count = 0;
tics = 0;
nextTicCount = 0;
}

View file

@ -0,0 +1,59 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 2018-2022 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __CMDLINE_PROGRESSBAR_H__
#define __CMDLINE_PROGRESSBAR_H__
// CommandlineProgressBar draws a nice progressbar in the console like you would get with boost
class CommandlineProgressBar
{
private:
size_t tics = 0;
size_t nextTicCount = 0;
int count = 0;
int expectedCount = 0;
int sysWidth = 1280;
int sysHeight = 720;
public:
CommandlineProgressBar( int _expectedCount, int width, int height )
{
expectedCount = _expectedCount;
sysWidth = width;
sysHeight = height;
}
void Start();
void Increment( bool updateScreen );
void Reset();
void Reset( int expected );
};
#endif /* !__CMDLINE_PROGRESSBAR_H__ */

View file

@ -40,7 +40,6 @@ If you have questions concerning this license or the applicable additional terms
#include "Framebuffer.h"
// maximum texture units
const int MAX_PROG_TEXTURE_PARMS = 16;
@ -1410,99 +1409,6 @@ void R_SampleCubeMapHDR16F( const idVec3& dir, int size, halfFloat_t* buffers[6]
idVec2 NormalizedOctCoord( int x, int y, const int probeSideLength );
class CommandlineProgressBar
{
private:
size_t tics = 0;
size_t nextTicCount = 0;
int count = 0;
int expectedCount = 0;
int sysWidth = 1280;
int sysHeight = 720;
public:
CommandlineProgressBar( int _expectedCount, int width, int height )
{
expectedCount = _expectedCount;
sysWidth = width;
sysHeight = height;
}
void Start()
{
// restore the original resolution, same as "vid_restart"
glConfig.nativeScreenWidth = sysWidth;
glConfig.nativeScreenHeight = sysHeight;
R_SetNewMode( false );
common->Printf( "0%% 10 20 30 40 50 60 70 80 90 100%%\n" );
common->Printf( "|----|----|----|----|----|----|----|----|----|----|\n" );
common->UpdateScreen( false );
}
void Increment( bool updateScreen )
{
if( ( count + 1 ) >= nextTicCount )
{
if( updateScreen )
{
// restore the original resolution, same as "vid_restart"
glConfig.nativeScreenWidth = sysWidth;
glConfig.nativeScreenHeight = sysHeight;
R_SetNewMode( false );
// resize frame buffers (this triggers SwapBuffers)
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
}
size_t ticsNeeded = ( size_t )( ( ( double )( count + 1 ) / expectedCount ) * 50.0 );
do
{
common->Printf( "*" );
}
while( ++tics < ticsNeeded );
nextTicCount = ( size_t )( ( tics / 50.0 ) * expectedCount );
if( count == ( expectedCount - 1 ) )
{
if( tics < 51 )
{
common->Printf( "*" );
}
common->Printf( "\n" );
}
if( updateScreen )
{
common->UpdateScreen( false );
// swap front / back buffers
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
}
}
count++;
}
void Reset()
{
count = 0;
tics = 0;
nextTicCount = 0;
}
void Reset( int expected )
{
expectedCount = expected;
count = 0;
tics = 0;
nextTicCount = 0;
}
};
/*
====================================================================

View file

@ -33,6 +33,7 @@ If you have questions concerning this license or the applicable additional terms
#include "../libs/mesa/format_r11g11b10f.h"
#include "RenderCommon.h"
#include "CmdlineProgressbar.h"
#include "../framework/Common_local.h" // commonLocal.WaitGameThread();
/*

View file

@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms
#pragma hdrstop
#include "RenderCommon.h"
#include "CmdlineProgressbar.h"
#include "../framework/Common_local.h" // commonLocal.WaitGameThread();
@ -1443,196 +1444,3 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
common->Printf( "Baked light grid irradiance in %5.1f minutes\n\n", ( totalEnd - totalStart ) / ( 1000.0f * 60 ) );
}
#if 0
// straight port of Quake 3 / XreaL
void idRenderWorldLocal::SetupEntityGridLighting( idRenderEntityLocal* def )
{
// lighting calculations
#if 0
if( def->lightgridCalculated )
{
return;
}
def->lightgridCalculated = true;
#endif
if( lightGridPoints.Num() > 0 )
{
idVec3 lightOrigin;
int pos[3];
int i, j;
int gridPointIndex;
lightGridPoint_t* gridPoint;
lightGridPoint_t* gridPoint2;
float frac[3];
int gridStep[3];
idVec3 direction;
idVec3 direction2;
float lattitude;
float longitude;
float totalFactor;
#if 0
if( forcedOrigin )
{
VectorCopy( forcedOrigin, lightOrigin );
}
else
{
if( ent->e.renderfx & RF_LIGHTING_ORIGIN )
{
// seperate lightOrigins are needed so an object that is
// sinking into the ground can still be lit, and so
// multi-part models can be lit identically
VectorCopy( ent->e.lightingOrigin, lightOrigin );
}
else
{
VectorCopy( ent->e.origin, lightOrigin );
}
}
#else
// some models, like empty particles have no volume
#if 1
lightOrigin = def->parms.origin;
#else
if( def->referenceBounds.IsCleared() )
{
lightOrigin = def->parms.origin;
}
else
{
lightOrigin = def->volumeMidPoint;
}
#endif
#endif
lightOrigin -= lightGridOrigin;
for( i = 0; i < 3; i++ )
{
float v;
v = lightOrigin[i] * ( 1.0f / lightGridSize[i] );
pos[i] = floor( v );
frac[i] = v - pos[i];
if( pos[i] < 0 )
{
pos[i] = 0;
}
else if( pos[i] >= lightGridBounds[i] - 1 )
{
pos[i] = lightGridBounds[i] - 1;
}
}
def->ambientLight.Zero();
def->directedLight.Zero();
direction.Zero();
// trilerp the light value
gridStep[0] = 1;
gridStep[1] = lightGridBounds[0];
gridStep[2] = lightGridBounds[0] * lightGridBounds[1];
gridPointIndex = pos[0] * gridStep[0] + pos[1] * gridStep[1] + pos[2] * gridStep[2];
gridPoint = &lightGridPoints[ gridPointIndex ];
totalFactor = 0;
for( i = 0; i < 8; i++ )
{
float factor;
factor = 1.0;
gridPoint2 = gridPoint;
for( int j = 0; j < 3; j++ )
{
if( i & ( 1 << j ) )
{
factor *= frac[j];
#if 1
gridPointIndex2 += gridStep[j];
if( gridPointIndex2 < 0 || gridPointIndex2 >= area->lightGrid.lightGridPoints.Num() )
{
// ignore values outside lightgrid
continue;
}
gridPoint2 = &area->lightGrid.lightGridPoints[ gridPointIndex2 ];
#else
if( pos[j] + 1 > area->lightGrid.lightGridBounds[j] - 1 )
{
// ignore values outside lightgrid
break;
}
gridPoint2 += gridStep[j];
#endif
}
else
{
factor *= ( 1.0f - frac[j] );
}
}
if( !( gridPoint2->ambient[0] + gridPoint2->ambient[1] + gridPoint2->ambient[2] ) )
{
continue; // ignore samples in walls
}
totalFactor += factor;
def->ambientLight[0] += factor * gridPoint2->ambient[0] * ( 1.0f / 255.0f );
def->ambientLight[1] += factor * gridPoint2->ambient[1] * ( 1.0f / 255.0f );
def->ambientLight[2] += factor * gridPoint2->ambient[2] * ( 1.0f / 255.0f );
def->directedLight[0] += factor * gridPoint2->directed[0] * ( 1.0f / 255.0f );
def->directedLight[1] += factor * gridPoint2->directed[1] * ( 1.0f / 255.0f );
def->directedLight[2] += factor * gridPoint2->directed[2] * ( 1.0f / 255.0f );
lattitude = DEG2RAD( gridPoint2->latLong[1] * ( 360.0f / 255.0f ) );
longitude = DEG2RAD( gridPoint2->latLong[0] * ( 360.0f / 255.0f ) );
direction2[0] = idMath::Cos( lattitude ) * idMath::Sin( longitude );
direction2[1] = idMath::Sin( lattitude ) * idMath::Sin( longitude );
direction2[2] = idMath::Cos( longitude );
direction += ( direction2 * factor );
//direction += ( gridPoint2->dir * factor );
}
#if 1
if( totalFactor > 0 && totalFactor < 0.99 )
{
totalFactor = 1.0f / totalFactor;
def->ambientLight *= totalFactor;
def->directedLight *= totalFactor;
}
#endif
def->ambientLight[0] = idMath::ClampFloat( 0, 1, def->ambientLight[0] );
def->ambientLight[1] = idMath::ClampFloat( 0, 1, def->ambientLight[1] );
def->ambientLight[2] = idMath::ClampFloat( 0, 1, def->ambientLight[2] );
def->directedLight[0] = idMath::ClampFloat( 0, 1, def->directedLight[0] );
def->directedLight[1] = idMath::ClampFloat( 0, 1, def->directedLight[1] );
def->directedLight[2] = idMath::ClampFloat( 0, 1, def->directedLight[2] );
def->lightDir = direction;
def->lightDir.Normalize();
#if 0
if( VectorLength( ent->ambientLight ) < r_forceAmbient->value )
{
ent->ambientLight[0] = r_forceAmbient->value;
ent->ambientLight[1] = r_forceAmbient->value;
ent->ambientLight[2] = r_forceAmbient->value;
}
#endif
}
}
#endif