Skip to content

Commit

Permalink
[SDK] в xrLC добавлены параметры запуска:
Browse files Browse the repository at this point in the history
 -norgb,
 -nolmaps,
 -skipinvalid,
 -lmap_quality.
  • Loading branch information
abramcumner committed Jan 29, 2017
1 parent dcf2e2d commit 157ba4a
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 17 deletions.
4 changes: 2 additions & 2 deletions xray/utils/xrLC/Build.cpp
Expand Up @@ -267,8 +267,8 @@ void CBuild::Run (LPCSTR P)
mu_base.wait (500);
mu_secondary.wait (500);
#endif

Light ();
if (!lc_global_data()->b_no_lmaps())
Light ();
RunAfterLight ( fs );

}
Expand Down
5 changes: 4 additions & 1 deletion xray/utils/xrLC/Build_Load.cpp
Expand Up @@ -147,7 +147,10 @@ void CBuild::Load (const b_params& Params, const IReader& _in_FS)
if (InvalideFaces())
{
err_save ();
Debug.fatal (DEBUG_INFO,"* FATAL: %d invalid faces. Compilation aborted",InvalideFaces());
if (lc_global_data()->b_skip_invalid())
clMsg("* Total %d invalid faces. Do something.", InvalideFaces());
else
Debug.fatal(DEBUG_INFO,"* FATAL: %d invalid faces. Compilation aborted",InvalideFaces());
}
}

Expand Down
13 changes: 13 additions & 0 deletions xray/utils/xrLC/xrLC.cpp
Expand Up @@ -26,6 +26,10 @@ static const char* h_str =
"-? or -h == this help\n"
"-o == modify build options\n"
"-nosun == disable sun-lighting\n"
"-norgb == disable common lightmap calculating\n"
"-nolmaps == disable lightmaps calculating\n"
"-skipinvalid == skip crash if invalid faces exists\n"
"-lmap_quality == lightmap quality\n"
"-f<NAME> == compile level in GameData\\Levels\\<NAME>\\\n"
"\n"
"NOTE: The last key is required for any functionality\n";
Expand Down Expand Up @@ -99,6 +103,9 @@ void Startup(LPSTR lpCmdLine)
VERIFY( lc_global_data() );
lc_global_data()->b_nosun_set ( !!strstr(cmd,"-nosun") );
//if (strstr(cmd,"-nosun")) b_nosun = TRUE;
lc_global_data()->b_norgb_set(!!strstr(cmd, "-norgb"));
lc_global_data()->b_no_lmaps_set(!!strstr(cmd, "-nolmaps"));
lc_global_data()->b_skip_invalid_set(!!strstr(cmd, "-skipinvalid"));

// Give a LOG-thread a chance to startup
//_set_sbh_threshold(1920);
Expand Down Expand Up @@ -149,6 +156,12 @@ void Startup(LPSTR lpCmdLine)
b_params Params;
F->r_chunk (EB_Parameters,&Params);

const char* quality = strstr(cmd, "-lmap_quality ");
if (quality) {
int sz = xr_strlen("-lmap_quality ");
sscanf(quality + sz, "%f", &Params.m_lm_pixels_per_meter);
}

// Show options if needed
if (bModifyOptions)
{
Expand Down
8 changes: 1 addition & 7 deletions xray/utils/xrLC/xrLight.cpp
Expand Up @@ -62,12 +62,6 @@ class CLMThread : public CThread
}
};







void CBuild::LMapsLocal ()
{
FPU::m64r ();
Expand Down Expand Up @@ -272,7 +266,7 @@ class CVertexLightThread : public CThread
{
base_color_c vC, old;
V->C._get (old);
LightPoint (&DB, lc_global_data()->RCAST_Model(), vC, V->P, V->N, pBuild->L_static(), (lc_global_data()->b_nosun()?LP_dont_sun:0)|LP_dont_hemi, 0);
LightPoint (&DB, lc_global_data()->RCAST_Model(), vC, V->P, V->N, pBuild->L_static(), LP_dont_hemi | global_light_flags(), 0);
vC._tmp_ = v_trans;
vC.mul (.5f);
vC.hemi = old.hemi; // preserve pre-calculated hemisphere
Expand Down
5 changes: 4 additions & 1 deletion xray/utils/xrLC/xrPreOptimize.cpp
Expand Up @@ -134,7 +134,10 @@ void CBuild::PreOptimize()
if (InvalideFaces())
{
err_save ();
Debug.fatal (DEBUG_INFO,"* FATAL: %d invalid faces. Compilation aborted",InvalideFaces());
if (lc_global_data()->b_skip_invalid())
clMsg("* Total %d invalid faces. Do something.", InvalideFaces());
else
Debug.fatal(DEBUG_INFO,"* FATAL: %d invalid faces. Compilation aborted",InvalideFaces());
}

Status ("Adjacency check...");
Expand Down
15 changes: 13 additions & 2 deletions xray/utils/xrLC_Light/xrDeflectoL_Direct.cpp
Expand Up @@ -9,6 +9,16 @@
#include "net_task.h"
extern void Jitter_Select (Fvector2* &Jitter, u32& Jcount);

u32 global_light_flags()
{
u32 result = 0;
if (inlc_global_data()->b_nosun())
result |= LP_dont_sun;
if (inlc_global_data()->b_norgb())
result |= LP_dont_rgb;
return result;
}

void CDeflector::L_Direct_Edge (CDB::COLLIDER* DB, base_lighting* LightsSelected, Fvector2& p1, Fvector2& p2, Fvector& v1, Fvector& v2, Fvector& N, float texel_size, Face* skip)
{
Fvector vdir;
Expand Down Expand Up @@ -44,7 +54,7 @@ void CDeflector::L_Direct_Edge (CDB::COLLIDER* DB, base_lighting* LightsSelected
VERIFY(inlc_global_data());
VERIFY(inlc_global_data()->RCAST_Model());

LightPoint (DB, inlc_global_data()->RCAST_Model(), C, P, N, *LightsSelected, (inlc_global_data()->b_nosun()?LP_dont_sun:0)|LP_DEFAULT, skip); //.
LightPoint (DB, inlc_global_data()->RCAST_Model(), C, P, N, *LightsSelected, LP_DEFAULT | global_light_flags(), skip);

C.mul (.5f);
lm.surface [_y*lm.width+_x]._set (C);
Expand Down Expand Up @@ -115,7 +125,8 @@ void CDeflector::L_Direct (CDB::COLLIDER* DB, base_lighting* LightsSelected, HAS
try {
VERIFY(inlc_global_data());
VERIFY(inlc_global_data()->RCAST_Model());
LightPoint (DB, inlc_global_data()->RCAST_Model(), C, wP, wN, *LightsSelected, (inlc_global_data()->b_nosun()?LP_dont_sun:0)|LP_UseFaceDisable, F); //.
LightPoint (DB, inlc_global_data()->RCAST_Model(), C, wP, wN,
*LightsSelected, LP_UseFaceDisable | global_light_flags(), F); //.
Fcount += 1;
} catch (...) {
clMsg("* ERROR (CDB). Recovered. ");
Expand Down
4 changes: 3 additions & 1 deletion xray/utils/xrLC_Light/xrDeflector.h
Expand Up @@ -91,4 +91,6 @@ typedef vector_serialize< t_read<CDeflector> > tread_deflectors;
typedef vector_serialize< t_write<CDeflector> > twrite_deflectors;

extern tread_deflectors *read_deflectors ;
extern twrite_deflectors *write_deflectors ;
extern twrite_deflectors *write_deflectors ;

u32 XRLC_LIGHT_API global_light_flags();
13 changes: 12 additions & 1 deletion xray/utils/xrLC_Light/xrLC_GlobalData.h
Expand Up @@ -38,10 +38,14 @@ class XRLC_LIGHT_API xrLC_GlobalData
CDB::MODEL* _RCAST_Model;
bool _b_nosun;
bool _gl_linear;
bool _b_norgb;
bool _b_no_lmaps;
bool _b_skip_invalid;
public:

public:
xrLC_GlobalData ():_RCAST_Model (0), _b_nosun(false),_gl_linear(false){}
xrLC_GlobalData ():_RCAST_Model (0), _b_nosun(false),_gl_linear(false),
_b_norgb(false), _b_no_lmaps(false), _b_skip_invalid(false){}
~xrLC_GlobalData();
IC xr_vector<b_BuildTexture>& textures () { return _textures; }
IC xr_vector<CLightmap*> & lightmaps () { return _g_lightmaps; }
Expand Down Expand Up @@ -76,6 +80,13 @@ IC void b_nosun_set (bool v){ _b_nosun = v; }
void create_read_faces() ;
void destroy_read_faces() ;
void gl_mesh_clear () ;

bool b_norgb() { return _b_norgb; }
void b_norgb_set(bool v) { _b_norgb = v; }
bool b_no_lmaps() { return _b_no_lmaps; }
void b_no_lmaps_set(bool v) { _b_no_lmaps = v; }
bool b_skip_invalid() { return _b_skip_invalid; }
void b_skip_invalid_set(bool v){ _b_skip_invalid = v; }
private:
//std::pair<u32,u32> get_id ( const _face * v ) const;
//std::pair<u32,u32> get_id ( const _vertex * v ) const;
Expand Down
2 changes: 1 addition & 1 deletion xray/utils/xrLC_Light/xrLight_Implicit.cpp
Expand Up @@ -137,7 +137,7 @@ class ImplicitThread : public CThread
wP.from_bary(V1->P,V2->P,V3->P,B);
wN.from_bary(V1->N,V2->N,V3->N,B);
wN.normalize();
LightPoint (&DB, inlc_global_data()->RCAST_Model(), C, wP, wN, inlc_global_data()->L_static(), (inlc_global_data()->b_nosun()?LP_dont_sun:0), F);
LightPoint (&DB, inlc_global_data()->RCAST_Model(), C, wP, wN, inlc_global_data()->L_static(), 0 | global_light_flags(), F);
Fcount ++;
}
}
Expand Down
4 changes: 3 additions & 1 deletion xray/utils/xrLC_Light/xrMU_Model_Reference_Calc_Lighting.cpp
Expand Up @@ -7,6 +7,7 @@
#include "fitter.h"
#include "xrface.h"
#include "xrLC_GlobalData.h"

template <typename T, typename T2>
T simple_optimize (xr_vector<T>& A, xr_vector<T>& B, T2& _scale, T2& _bias)
{
Expand Down Expand Up @@ -99,10 +100,11 @@ void o_test (int iA, int iB, int count, base_color* A, base_color* B, float& C,
simple_optimize (_A,_B,C,D);
}

u32 global_light_flags();

void xrMU_Reference::calc_lighting ()
{
model->calc_lighting (color,xform,inlc_global_data()->RCAST_Model(),inlc_global_data()->L_static(),(inlc_global_data()->b_nosun()?LP_dont_sun:0)|LP_DEFAULT);
model->calc_lighting (color,xform,inlc_global_data()->RCAST_Model(),inlc_global_data()->L_static(), LP_DEFAULT | global_light_flags());

R_ASSERT (color.size()==model->color.size());

Expand Down

0 comments on commit 157ba4a

Please sign in to comment.