This commit is contained in:
Biel Bestué de Luna 2013-09-17 14:04:38 -07:00
commit 4dfd89eef1
12 changed files with 469 additions and 2 deletions

View file

@ -252,6 +252,13 @@ void idGameLocal::Clear( void ) {
savedEventQueue.Init();
memset( lagometer, 0, sizeof( lagometer ) );
//neuro start
portalSkyEnt = NULL;
portalSkyActive = false;
playerOldEyePos.Zero(); // 7318
globalPortalSky = false; // 7318
//neuro end
}
/*
@ -536,6 +543,17 @@ void idGameLocal::SaveGame( idFile *f ) {
savegame.WriteBool( isNewFrame );
savegame.WriteFloat( clientSmoothing );
//neuro start
portalSkyEnt.Save( &savegame );
savegame.WriteBool( portalSkyActive );
savegame.WriteBool( globalPortalSky ); // 7318
savegame.WriteInt( currentPortalSkyType ); // 7318
savegame.WriteVec3( playerOldEyePos ); // 7318
savegame.WriteVec3( portalSkyGlobalOrigin ); // 7318
savegame.WriteVec3( portalSkyOrigin ); // 7318
//neuro end
savegame.WriteBool( mapCycleLoaded );
savegame.WriteInt( spawnCount );
@ -906,6 +924,13 @@ void idGameLocal::LoadMap( const char *mapName, int randseed ) {
sessionCommand = "";
nextGibTime = 0;
//neuro start
portalSkyEnt = NULL;
portalSkyActive = false;
playerOldEyePos.Zero(); // 7318
globalPortalSky = false;// 7318
//neuro end
vacuumAreaNum = -1; // if an info_vacuum is spawned, it will set this
if ( !editEntities ) {
@ -1353,6 +1378,16 @@ bool idGameLocal::InitFromSaveGame( const char *mapName, idRenderWorld *renderWo
savegame.ReadBool( isNewFrame );
savegame.ReadFloat( clientSmoothing );
//neuro start
portalSkyEnt.Restore( &savegame );
savegame.ReadBool( portalSkyActive );
savegame.ReadBool( globalPortalSky ); // 7318
savegame.ReadInt( currentPortalSkyType ); // 7318
savegame.ReadVec3( playerOldEyePos ); // 7318
savegame.ReadVec3( portalSkyGlobalOrigin ); // 7318
savegame.ReadVec3( portalSkyOrigin ); // 7318
//neuro end
savegame.ReadBool( mapCycleLoaded );
savegame.ReadInt( spawnCount );
@ -1999,6 +2034,25 @@ void idGameLocal::SetupPlayerPVS( void ) {
pvs.FreeCurrentPVS( otherPVS );
playerConnectedAreas = newPVS;
}
//neuro start
// if portalSky is preset, then merge into pvs so we get rotating brushes, etc
if ( portalSkyEnt.GetEntity() ) {
idEntity *skyEnt = portalSkyEnt.GetEntity();
otherPVS = pvs.SetupCurrentPVS( skyEnt->GetPVSAreas(), skyEnt->GetNumPVSAreas() );
newPVS = pvs.MergeCurrentPVS( playerPVS, otherPVS );
pvs.FreeCurrentPVS( playerPVS );
pvs.FreeCurrentPVS( otherPVS );
playerPVS = newPVS;
otherPVS = pvs.SetupCurrentPVS( skyEnt->GetPVSAreas(), skyEnt->GetNumPVSAreas() );
newPVS = pvs.MergeCurrentPVS( playerConnectedAreas, otherPVS );
pvs.FreeCurrentPVS( playerConnectedAreas );
pvs.FreeCurrentPVS( otherPVS );
playerConnectedAreas = newPVS;
}
//neuro end
}
}
@ -4268,6 +4322,69 @@ void idGameLocal::ThrottleUserInfo( void ) {
mpGame.ThrottleUserInfo();
}
//neuro start
/*
=================
idGameLocal::SetPortalSkyEnt
=================
*/
void idGameLocal::SetPortalSkyEnt( idEntity *ent ) {
portalSkyEnt = ent;
}
/*
=================
idGameLocal::IsPortalSkyAcive
=================
*/
bool idGameLocal::IsPortalSkyAcive() {
return portalSkyActive;
}
/*
=================
idGameLocal::CheckGlobalPortalSky --> 7318
=================
*/
bool idGameLocal::CheckGlobalPortalSky() {
return globalPortalSky;
}
/*
=================
idGameLocal::SetGlobalPortalSky --> 7318
=================
*/
void idGameLocal::SetGlobalPortalSky( const char *name ) {
if ( CheckGlobalPortalSky() ) {
Error( "more than one global portalSky:\ndelete them until you have just one.\nportalSky '%s' causes it.", name );
}
else {
globalPortalSky = true;
}
}
/*
=================
idGameLocal::SetCurrentPortalSkyType --> 7318
=================
*/
void idGameLocal::SetCurrentPortalSkyType( int type ) {
currentPortalSkyType = type;
}
/*
=================
idGameLocal::GetCurrentPortalSkyType --> 7318
=================
*/
int idGameLocal::GetCurrentPortalSkyType() {
return currentPortalSkyType;
}
//neuro end
/*
===========
idGameLocal::SelectTimeGroup

View file

@ -165,6 +165,16 @@ typedef struct {
//============================================================================
//7318 start
enum {
PORTALSKY_STANDARD = 0, // classic portalsky
PORTALSKY_GLOBAL = 1, // always following portal sky
PORTALSKY_LOCAL = 2, // following portal sky from a spot
};
//7318 end
//============================================================================
class idEventQueue {
public:
typedef enum {
@ -294,6 +304,30 @@ public:
idEntityPtr<idEntity> lastGUIEnt; // last entity with a GUI, used by Cmd_NextGUI_f
int lastGUI; // last GUI on the lastGUIEnt
//neuro start
idEntityPtr<idEntity> portalSkyEnt;
bool portalSkyActive;
//7318 start
bool globalPortalSky;
int portalSkyScale;
int currentPortalSkyType; //0 = classic, 1 = global, 2 = local
idVec3 portalSkyOrigin;
idVec3 portalSkyGlobalOrigin;
idVec3 playerOldEyePos;
//7318 end
void SetPortalSkyEnt( idEntity *ent );
bool IsPortalSkyAcive();
//7318 start
bool CheckGlobalPortalSky();
void SetGlobalPortalSky(const char *name);
void SetCurrentPortalSkyType(int type); // 0 = classic, 1 = global, 2 = local
int GetCurrentPortalSkyType(); //0 = classic, 1 = global, 2 = local
//7318 end
//neuro end
// ---------------------- Public idGame Interface -------------------
idGameLocal();
@ -387,6 +421,10 @@ public:
bool InPlayerPVS( idEntity *ent ) const;
bool InPlayerConnectedArea( idEntity *ent ) const;
//Ivan_the_B start
pvsHandle_t GetPlayerPVS() { return playerPVS; };
//Ivan_the_B end
void SetCamera( idCamera *cam );
idCamera * GetCamera( void ) const;
bool SkipCinematic( void );

View file

@ -712,6 +712,44 @@ void idObjective::Event_CamShot( ) {
renderView_t fullView = *view;
fullView.width = SCREEN_WIDTH;
fullView.height = SCREEN_HEIGHT;
//neuro start
// HACK : always draw sky-portal view if there is one in the map, this isn't real-time
if ( gameLocal.portalSkyEnt.GetEntity() && g_enablePortalSky.GetBool() ) {
renderView_t portalView = fullView;
portalView.vieworg = gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetOrigin();
// setup global fixup projection vars
if ( 1 ) {
int vidWidth, vidHeight;
idVec2 shiftScale;
renderSystem->GetGLSettings( vidWidth, vidHeight );
float pot;
int temp;
int w = vidWidth;
for (temp = 1 ; temp < w ; temp<<=1) {
}
pot = (float)temp;
shiftScale.x = (float)w / pot;
int h = vidHeight;
for (temp = 1 ; temp < h ; temp<<=1) {
}
pot = (float)temp;
shiftScale.y = (float)h / pot;
fullView.shaderParms[4] = shiftScale.x;
fullView.shaderParms[5] = shiftScale.y;
}
gameRenderWorld->RenderScene( &portalView );
renderSystem->CaptureRenderToImage( "_currentRender" );
}
//neuro end
// draw a view to a texture
renderSystem->CropRenderSize( 256, 256, true );
gameRenderWorld->RenderScene( &fullView );

View file

@ -3156,3 +3156,93 @@ void idPhantomObjects::Think( void ) {
BecomeInactive( TH_THINK );
}
}
//neuro start
/*
===============================================================================
idPortalSky
===============================================================================
*/
CLASS_DECLARATION( idEntity, idPortalSky )
EVENT( EV_PostSpawn, idPortalSky::Event_PostSpawn )
EVENT( EV_Activate, idPortalSky::Event_Activate )
END_CLASS
/*
===============
idPortalSky::idPortalSky
===============
*/
idPortalSky::idPortalSky( void ) {
}
/*
===============
idPortalSky::~idPortalSky
===============
*/
idPortalSky::~idPortalSky( void ) {
}
/*
===============
idPortalSky::Spawn
===============
*/
void idPortalSky::Spawn( void ) {
if ( spawnArgs.GetInt( "type" ) == PORTALSKY_GLOBAL ) {
gameLocal.SetGlobalPortalSky( spawnArgs.GetString( "name" ) );
gameLocal.portalSkyGlobalOrigin = GetPhysics()->GetOrigin();
}
if ( !spawnArgs.GetBool( "triggered" ) ) {
if ( spawnArgs.GetInt( "type" ) != PORTALSKY_STANDARD ) {
gameLocal.portalSkyScale = spawnArgs.GetInt( "scale", "16" );
}
PostEventMS( &EV_PostSpawn, 1 );
}
}
/*
================
idPortalSky::Event_PostSpawn
================
*/
void idPortalSky::Event_PostSpawn() {
gameLocal.SetCurrentPortalSkyType( spawnArgs.GetInt( "type", "0" ) );
if ( gameLocal.GetCurrentPortalSkyType() != PORTALSKY_GLOBAL ) {
gameLocal.portalSkyOrigin = GetPhysics()->GetOrigin();
// both standard and local portalSky share the origin, it's in the execution that things change.
}
gameLocal.SetPortalSkyEnt( this );
}
/*
================
idPortalSky::Event_Activate
================
*/
void idPortalSky::Event_Activate( idEntity *activator ) {
gameLocal.SetCurrentPortalSkyType( spawnArgs.GetInt( "type", "0" ) );
if ( gameLocal.GetCurrentPortalSkyType() != PORTALSKY_GLOBAL ) {
gameLocal.portalSkyOrigin = GetPhysics()->GetOrigin();
// both standard and local portalSky share the origin, it's in the execution that things change.
}
gameLocal.portalSkyScale = spawnArgs.GetInt( "scale", "16" );
gameLocal.SetPortalSkyEnt( this );
}
//neuro end

View file

@ -765,4 +765,25 @@ private:
idList<idVec3> lastTargetPos;
};
//neuro start
/*
===============================================================================
idPortalSky
===============================================================================
*/
class idPortalSky : public idEntity {
public:
CLASS_PROTOTYPE( idPortalSky );
idPortalSky();
~idPortalSky();
void Spawn( void );
void Event_PostSpawn();
void Event_Activate( idEntity *activator );
};
//neuro end
#endif /* !__GAME_MISC_H__ */

View file

@ -6394,6 +6394,11 @@ void idPlayer::Think( void ) {
}
gameLocal.Printf( "%d: enemies\n", num );
}
//neuro start
// determine if portal sky is in pvs
gameLocal.portalSkyActive = gameLocal.pvs.CheckAreasForPortalSky( gameLocal.GetPlayerPVS(), GetPhysics()->GetOrigin() );
//neuro end
}
/*
@ -7923,6 +7928,12 @@ void idPlayer::ClientPredictionThink( void ) {
if ( gameLocal.isNewFrame && entityNumber == gameLocal.localClientNum ) {
playerView.CalculateShake();
}
//neuro start
// determine if portal sky is in pvs
pvsHandle_t clientPVS = gameLocal.pvs.SetupCurrentPVS( GetPVSAreas(), GetNumPVSAreas() );
gameLocal.portalSkyActive = gameLocal.pvs.CheckAreasForPortalSky( clientPVS, GetPhysics()->GetOrigin() );
gameLocal.pvs.FreeCurrentPVS( clientPVS );
//neuro end
}
/*

View file

@ -36,6 +36,15 @@ If you have questions concerning this license or the applicable additional terms
#include "PlayerView.h"
//Ivan_the_B start
static int MakePowerOfTwo( int num ) {
int pot;
for (pot = 1 ; pot < num ; pot<<=1) {
}
return pot;
}
//Ivan_the_B end
const int IMPULSE_DELAY = 150;
/*
==============
@ -452,7 +461,88 @@ void idPlayerView::SingleView( idUserInterface *hud, const renderView_t *view )
renderView_t hackedView = *view;
hackedView.viewaxis = hackedView.viewaxis * ShakeAxis();
gameRenderWorld->RenderScene( &hackedView );
//neuro start
//7318 start
idVec3 diff, currentEyePos, PSOrigin, Zero;
Zero.Zero();
//if ( gameLocal.CheckGlobalPortalSky() ) {
if ( ( gameLocal.CheckGlobalPortalSky() ) || ( gameLocal.GetCurrentPortalSkyType() == PORTALSKY_LOCAL ) ) {
// in a case of a moving portalSky
currentEyePos = hackedView.vieworg;
if ( gameLocal.playerOldEyePos == Zero ) {
gameLocal.playerOldEyePos = currentEyePos;
//initialize playerOldEyePos, this will only happen in one tick.
}
diff = ( currentEyePos - gameLocal.playerOldEyePos) / gameLocal.portalSkyScale;
gameLocal.portalSkyGlobalOrigin += diff; // this is for the global portalSky.
// It should keep going even when not active.
}
if ( gameLocal.portalSkyEnt.GetEntity() && gameLocal.IsPortalSkyAcive() && g_enablePortalSky.GetBool() ) {
if ( gameLocal.GetCurrentPortalSkyType() == PORTALSKY_STANDARD ) {
PSOrigin = gameLocal.portalSkyOrigin;
}
if ( gameLocal.GetCurrentPortalSkyType() == PORTALSKY_GLOBAL ) {
PSOrigin = gameLocal.portalSkyGlobalOrigin;
}
if ( gameLocal.GetCurrentPortalSkyType() == PORTALSKY_LOCAL ) {
gameLocal.portalSkyOrigin += diff;
PSOrigin = gameLocal.portalSkyOrigin;
}
gameLocal.playerOldEyePos = currentEyePos;
// 7318 end
renderView_t portalView = hackedView;
portalView.vieworg = PSOrigin; // 7318 moded
// setup global fixup projection vars
if ( 1 ) {
int vidWidth, vidHeight;
idVec2 shiftScale;
renderSystem->GetGLSettings( vidWidth, vidHeight );
float pot;
int w = vidWidth;
pot = MakePowerOfTwo( w );
shiftScale.x = (float)w / pot;
int h = vidHeight;
pot = MakePowerOfTwo( h );
shiftScale.y = (float)h / pot;
hackedView.shaderParms[4] = shiftScale.x;
hackedView.shaderParms[5] = shiftScale.y;
}
gameRenderWorld->RenderScene( &portalView );
renderSystem->CaptureRenderToImage( "_currentRender" );
hackedView.forceUpdate = true; // FIX: for smoke particles not drawing when portalSky present
}
else {
gameLocal.playerOldEyePos = currentEyePos; // 7318 moded
// so if g_enablePortalSky is disabled GlobalPortalSkies don't broke
// when g_enablePortalSky gets re-enabled GlPS keep working
}
gameRenderWorld->RenderScene( &hackedView ); //was fxManager->Process( &hackedView );
//neuro end
if ( player->spectating ) {
return;

View file

@ -1420,3 +1420,55 @@ void idPVS::ReadPVS( const pvsHandle_t handle, const idBitMsg &msg ) {
}
#endif
//neuro start
/*
================
idPVS::CheckAreasForPortalSky
================
*/
bool idPVS::CheckAreasForPortalSky( const pvsHandle_t handle, const idVec3 &origin ) {
int j, sourceArea;
if ( handle.i < 0 || handle.i >= MAX_CURRENT_PVS || handle.h != currentPVS[handle.i].handle.h ) {
return false;
}
sourceArea = gameRenderWorld->PointInArea( origin );
if ( sourceArea == -1 ) {
// 7318 start
// this is the case where the player is not in any AAS area;
// this is, he is in noclip mode out of the map. let's do a global/local PS check!
if ( gameLocal.CheckGlobalPortalSky() || ( gameLocal.GetCurrentPortalSkyType() == PORTALSKY_LOCAL ) ) {
//this is... if the current PS is local, or there exist a global PS in the map, even if it's not current...
return true; // in any one of those cases keep callculating for the global or the local portalSky
}
return false;
}
for ( j = 0; j < numAreas; j++ ) {
if ( !( currentPVS[handle.i].pvs[j>>3] & (1 << (j&7)) ) ) {
continue;
}
if ( gameRenderWorld->CheckAreaForPortalSky( j ) ) {
return true;
}
}
// here if the player is in an unreachable AAS like inisde a sealed room, where he teleports in,
// the function will return false. so let's repeat the global/local PS check!
if ( gameLocal.CheckGlobalPortalSky() || ( gameLocal.GetCurrentPortalSkyType() == PORTALSKY_LOCAL ) ) {
//this is... if the current PS is local, or there exist a global PS in the map, even if it's not current...
return true; // in any one of those cases keep callculating for the global or the local portalSky
}
// 7318 end
return false;
}
//neuro end

View file

@ -97,6 +97,10 @@ public:
void ReadPVS( const pvsHandle_t handle, const idBitMsg &msg );
#endif
//neuro start
bool CheckAreasForPortalSky( const pvsHandle_t handle, const idVec3 &origin );
//neuro end
private:
int numAreas;
int numPortals;

View file

@ -335,3 +335,6 @@ idCVar mod_validSkins( "mod_validSkins", "skins/characters/player/marine_mp
idCVar net_serverDownload( "net_serverDownload", "0", CVAR_GAME | CVAR_INTEGER | CVAR_ARCHIVE, "enable server download redirects. 0: off 1: redirect to si_serverURL 2: use builtin download. see net_serverDl cvars for configuration" );
idCVar net_serverDlBaseURL( "net_serverDlBaseURL", "", CVAR_GAME | CVAR_ARCHIVE, "base URL for the download redirection" );
idCVar net_serverDlTable( "net_serverDlTable", "", CVAR_GAME | CVAR_ARCHIVE, "pak names for which download is provided, seperated by ;" );
//neuro start
idCVar g_enablePortalSky( "g_enablePortalSky", "1", CVAR_GAME | CVAR_BOOL, "enables the portal sky" );
//neuro end

View file

@ -254,4 +254,7 @@ extern const char *si_gameTypeArgs[];
extern const char *ui_skinArgs[];
//neuro start
extern idCVar g_enablePortalSky;
//neuro end
#endif /* !__SYS_CVAR_H__ */

View file

@ -655,7 +655,7 @@ void idRenderWorldLocal::AddWorldModelEntities() {
for ( int j = 0; j < hModel->NumSurfaces(); j++ ) {
const modelSurface_t *surf = hModel->Surface( j );
if ( surf->shader->GetName() == idStr( "textures/smf/portal_sky" ) ) {
if ( ( surf->shader->GetName() == idStr( "textures/smf/portal_sky" ) ) || ( surf->shader->GetName() == idStr( "textures/editor/portal_sky" ) ) ) { //7318 - portalsky - moded
def->needsPortalSky = true;
}
}