Made some tweaks so I'm happy with it.

* Removed #defines
 * Fall back to using visible distance if ghost distance is not used
 * Removed ghost distance from level files as it will default
 * Renamed mConnectionVisibleDistance for consistency
This commit is contained in:
Daniel Buckmaster 2014-12-07 19:11:10 +11:00
parent 578c4e8f4f
commit a928d142f7
15 changed files with 21 additions and 100 deletions

View file

@ -389,12 +389,7 @@ F32 GameBase::getUpdatePriority(CameraScopeQuery *camInfo, U32 updateMask, S32 u
// will be weighted 1, objects behind will be 0 // will be weighted 1, objects behind will be 0
F32 dot = mDot(pos,camInfo->orientation); F32 dot = mDot(pos,camInfo->orientation);
#ifdef GHOSTSCOPING bool inFov = dot > camInfo->cosFov * 1.5f;
bool inFov = dot > camInfo->cosFov*1.5f;
#else
bool inFov = dot > camInfo->cosFov;
#endif
F32 wFov = inFov? 1.0f: 0; F32 wFov = inFov? 1.0f: 0;
@ -413,11 +408,7 @@ F32 GameBase::getUpdatePriority(CameraScopeQuery *camInfo, U32 updateMask, S32 u
// Weight by interest. // Weight by interest.
F32 wInterest; F32 wInterest;
#ifdef GHOSTSCOPING
if (getTypeMask() & (PlayerObjectType || VehicleObjectType )) if (getTypeMask() & (PlayerObjectType || VehicleObjectType ))
#else
if (getTypeMask() & PlayerObjectType)
#endif
wInterest = 0.75f; wInterest = 0.75f;
else if (getTypeMask() & ProjectileObjectType) else if (getTypeMask() & ProjectileObjectType)
{ {

View file

@ -35,14 +35,10 @@
#ifndef _DYNAMIC_CONSOLETYPES_H_ #ifndef _DYNAMIC_CONSOLETYPES_H_
#include "console/dynamicTypes.h" #include "console/dynamicTypes.h"
#endif #endif
#include "torqueConfig.h"
#ifdef GHOSTSCOPING
#ifndef __SCENEMANAGER_H__ #ifndef __SCENEMANAGER_H__
#include "scene/sceneManager.h" #include "scene/sceneManager.h"
#define __SCENEMANAGER_H__ #define __SCENEMANAGER_H__
#endif #endif
#endif
class NetConnection; class NetConnection;
class ProcessList; class ProcessList;

View file

@ -226,9 +226,7 @@ GameConnection::GameConnection()
mAddYawToAbsRot = false; mAddYawToAbsRot = false;
mAddPitchToAbsRot = false; mAddPitchToAbsRot = false;
#ifdef GHOSTSCOPING mVisibleGhostDistance = 0.0f;
mConnectionVisibleDistance = 0.0f;
#endif
clearDisplayDevice(); clearDisplayDevice();
} }
@ -243,16 +241,16 @@ GameConnection::~GameConnection()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#ifdef GHOSTSCOPING
void GameConnection::setVisibleGhostDistance(F32 dist) void GameConnection::setVisibleGhostDistance(F32 dist)
{ {
mConnectionVisibleDistance = dist; mVisibleGhostDistance = dist;
} }
F32 GameConnection::getVisibleGhostDistance() F32 GameConnection::getVisibleGhostDistance()
{ {
return mConnectionVisibleDistance; return mVisibleGhostDistance;
} }
#endif
bool GameConnection::canRemoteCreate() bool GameConnection::canRemoteCreate()
{ {
@ -2215,13 +2213,12 @@ DefineEngineMethod( GameConnection, getControlSchemeAbsoluteRotation, bool, (),,
} }
DefineEngineMethod( GameConnection, setVisibleGhostDistance, void, (F32 dist),, DefineEngineMethod( GameConnection, setVisibleGhostDistance, void, (F32 dist),,
"@brief Sets the distance that objects around it will be ghosted.\n\n" "@brief Sets the distance that objects around it will be ghosted. If set to 0, "
"it may be defined by the LevelInfo.\n\n"
"@dist - is the max distance\n\n" "@dist - is the max distance\n\n"
) )
{ {
#ifdef GHOSTSCOPING object->setVisibleGhostDistance(dist);
object->setVisibleGhostDistance(dist);
#endif
} }
DefineEngineMethod( GameConnection, getVisibleGhostDistance, F32, (),, DefineEngineMethod( GameConnection, getVisibleGhostDistance, F32, (),,
@ -2230,9 +2227,5 @@ DefineEngineMethod( GameConnection, getVisibleGhostDistance, F32, (),,
"@return S32 of distance.\n\n" "@return S32 of distance.\n\n"
) )
{ {
#ifdef GHOSTSCOPING return object->getVisibleGhostDistance();
return object->getVisibleGhostDistance();
#else
return 0;
#endif
} }

View file

@ -39,8 +39,6 @@
#include "core/bitVector.h" #include "core/bitVector.h"
#endif #endif
#include "torqueConfig.h"
enum GameConnectionConstants enum GameConnectionConstants
{ {
MaxClients = 126, MaxClients = 126,
@ -74,9 +72,7 @@ private:
U32 mMissionCRC; // crc of the current mission file from the server U32 mMissionCRC; // crc of the current mission file from the server
#ifdef GHOSTSCOPING F32 mVisibleGhostDistance;
F32 mConnectionVisibleDistance;
#endif
private: private:
U32 mLastControlRequestTime; U32 mLastControlRequestTime;
@ -161,10 +157,8 @@ public:
bool canRemoteCreate(); bool canRemoteCreate();
#ifdef GHOSTSCOPING
void setVisibleGhostDistance(F32 dist); void setVisibleGhostDistance(F32 dist);
F32 getVisibleGhostDistance(); F32 getVisibleGhostDistance();
#endif
private: private:
/// @name Connection State /// @name Connection State

View file

@ -79,9 +79,7 @@ static SFXAmbience sDefaultAmbience;
LevelInfo::LevelInfo() LevelInfo::LevelInfo()
: mNearClip( 0.1f ), : mNearClip( 0.1f ),
mVisibleDistance( 1000.0f ), mVisibleDistance( 1000.0f ),
#ifdef GHOSTSCOPING mVisibleGhostDistance ( 0 ),
mVisibleGhostDistance (200.0f),
#endif
mDecalBias( 0.0015f ), mDecalBias( 0.0015f ),
mCanvasClearColor( 255, 0, 255, 255 ), mCanvasClearColor( 255, 0, 255, 255 ),
mSoundAmbience( NULL ), mSoundAmbience( NULL ),
@ -118,10 +116,8 @@ void LevelInfo::initPersistFields()
addGroup( "Visibility" ); addGroup( "Visibility" );
addField( "nearClip", TypeF32, Offset( mNearClip, LevelInfo ), "Closest distance from the camera's position to render the world." ); addField( "nearClip", TypeF32, Offset( mNearClip, LevelInfo ), "Closest distance from the camera's position to render the world." );
addField( "visibleDistance", TypeF32, Offset( mVisibleDistance, LevelInfo ), "Furthest distance fromt he camera's position to render the world." ); addField( "visibleDistance", TypeF32, Offset( mVisibleDistance, LevelInfo ), "Furthest distance from the camera's position to render the world." );
#ifdef GHOSTSCOPING addField( "visibleGhostDistance", TypeF32, Offset( mVisibleGhostDistance, LevelInfo ), "Furthest distance from the camera's position to render players. Defaults to visibleDistance." );
addField( "visibleGhostDistance", TypeF32, Offset( mVisibleGhostDistance, LevelInfo ), "Furthest distance from the camera's position to render players." );
#endif
addField( "decalBias", TypeF32, Offset( mDecalBias, LevelInfo ), addField( "decalBias", TypeF32, Offset( mDecalBias, LevelInfo ),
"NearPlane bias used when rendering Decal and DecalRoad. This should be tuned to the visibleDistance in your level." ); "NearPlane bias used when rendering Decal and DecalRoad. This should be tuned to the visibleDistance in your level." );
@ -308,9 +304,7 @@ void LevelInfo::_updateSceneGraph()
scene->setNearClip( mNearClip ); scene->setNearClip( mNearClip );
scene->setVisibleDistance( mVisibleDistance ); scene->setVisibleDistance( mVisibleDistance );
#ifdef GHOSTSCOPING
scene->setVisibleGhostDistance( mVisibleGhostDistance ); scene->setVisibleGhostDistance( mVisibleGhostDistance );
#endif
gDecalBias = mDecalBias; gDecalBias = mDecalBias;

View file

@ -36,8 +36,6 @@
#include "sfx/sfxCommon.h" #include "sfx/sfxCommon.h"
#endif #endif
#include "torqueConfig.h"
class SFXAmbience; class SFXAmbience;
class SFXSoundscape; class SFXSoundscape;
@ -56,9 +54,8 @@ class LevelInfo : public NetObject
F32 mVisibleDistance; F32 mVisibleDistance;
#ifdef GHOSTSCOPING
F32 mVisibleGhostDistance; F32 mVisibleGhostDistance;
#endif
F32 mDecalBias; F32 mDecalBias;
ColorI mCanvasClearColor; ColorI mCanvasClearColor;

View file

@ -112,9 +112,7 @@ SceneManager::SceneManager( bool isClient )
mDisplayTargetResolution( 0, 0 ), mDisplayTargetResolution( 0, 0 ),
mDefaultRenderPass( NULL ), mDefaultRenderPass( NULL ),
mVisibleDistance( 500.f ), mVisibleDistance( 500.f ),
#ifdef GHOSTSCOPING mVisibleGhostDistance( 0 ),
mVisibleGhostDistance(GHOSTSCOPING_DEFAULT_DISTANCE_IF_NOT_IN_MISSION),
#endif
mNearClip( 0.1f ), mNearClip( 0.1f ),
mAmbientLightColor( ColorF( 0.1f, 0.1f, 0.1f, 1.0f ) ), mAmbientLightColor( ColorF( 0.1f, 0.1f, 0.1f, 1.0f ) ),
mZoneManager( NULL ) mZoneManager( NULL )

View file

@ -59,8 +59,6 @@
#include "core/util/tSignal.h" #include "core/util/tSignal.h"
#endif #endif
#include "torqueConfig.h"
class LightManager; class LightManager;
class SceneRootZone; class SceneRootZone;
@ -143,9 +141,7 @@ class SceneManager
F32 mVisibleDistance; F32 mVisibleDistance;
#ifdef GHOSTSCOPING
F32 mVisibleGhostDistance; F32 mVisibleGhostDistance;
#endif
F32 mNearClip; F32 mNearClip;
FogData mFogData; FogData mFogData;
@ -322,10 +318,9 @@ class SceneManager
/// Returns the default visible distance for the scene. /// Returns the default visible distance for the scene.
F32 getVisibleDistance() { return mVisibleDistance; } F32 getVisibleDistance() { return mVisibleDistance; }
#ifdef GHOSTSCOPING
void setVisibleGhostDistance( F32 dist ) { mVisibleGhostDistance = dist; } void setVisibleGhostDistance( F32 dist ) { mVisibleGhostDistance = dist; }
F32 getVisibleGhostDistance() { return mVisibleGhostDistance;} F32 getVisibleGhostDistance() { return mVisibleGhostDistance;}
#endif
/// Used by LevelInfo to set the default near clip plane /// Used by LevelInfo to set the default near clip plane
/// for rendering the scene. /// for rendering the scene.
/// ///

View file

@ -42,10 +42,7 @@
#include "math/mathIO.h" #include "math/mathIO.h"
#include "math/mTransform.h" #include "math/mTransform.h"
#include "T3D/gameBase/gameProcess.h" #include "T3D/gameBase/gameProcess.h"
#ifdef GHOSTSCOPING
#include "T3D/gameBase/gameConnection.h" #include "T3D/gameBase/gameConnection.h"
#endif
IMPLEMENT_CONOBJECT(SceneObject); IMPLEMENT_CONOBJECT(SceneObject);
@ -668,15 +665,11 @@ static void scopeCallback( SceneObject* obj, void* conPtr )
void SceneObject::onCameraScopeQuery( NetConnection* connection, CameraScopeQuery* query ) void SceneObject::onCameraScopeQuery( NetConnection* connection, CameraScopeQuery* query )
{ {
SceneManager* sceneManager = getSceneManager();
#ifdef GHOSTSCOPING
SceneManager* scenemanager = getSceneManager();
GameConnection* conn = dynamic_cast<GameConnection*> (connection); GameConnection* conn = dynamic_cast<GameConnection*> (connection);
if (conn && conn->getVisibleGhostDistance() == 0.0f) if (conn && (query->visibleDistance = conn->getVisibleGhostDistance()) == 0.0f)
query->visibleDistance = scenemanager->getVisibleGhostDistance(); if ((query->visibleDistance = sceneManager->getVisibleGhostDistance()) == 0.0f)
else query->visibleDistance = sceneManager->getVisibleDistance();
query->visibleDistance = conn->getVisibleGhostDistance();
#endif
// Object itself is in scope. // Object itself is in scope.

View file

@ -5,7 +5,6 @@ new SimGroup(MissionGroup) {
new LevelInfo(theLevelInfo) { new LevelInfo(theLevelInfo) {
visibleDistance = "1000"; visibleDistance = "1000";
visibleGhostDistance = "1000";
fogColor = "0.6 0.6 0.7 1"; fogColor = "0.6 0.6 0.7 1";
fogDensity = "0"; fogDensity = "0";
fogDensityOffset = "700"; fogDensityOffset = "700";

View file

@ -39,19 +39,6 @@
/// Version number is major * 1000 + minor * 100 + revision * 10. /// Version number is major * 1000 + minor * 100 + revision * 10.
#define TORQUE_APP_VERSION 1000 #define TORQUE_APP_VERSION 1000
//Ghost Scoping limits the number of objects being ghosted
//to a gameConnection to the objects around it within X
//distance.
//This is particularly useful for reducing bandwidth usage
//of games in which there are a lot of players and AI
//Basically, anything derived from SceneObject.
//GHOSTSCOPING_DEFAULT_DISTANCE_IF_NOT_IN_MISSION is the default distance
//a game will use if the distance is not defined in the mission file.
//DO NOT USE IF YOU ARE BUILDING A SIDE SCROLLER.
//To enable ghost scoping define:
//#define GHOSTSCOPING
//#define GHOSTSCOPING_DEFAULT_DISTANCE_IF_NOT_IN_MISSION 200.0f
/// Human readable application version string. /// Human readable application version string.
#define TORQUE_APP_VERSION_STRING "1.0" #define TORQUE_APP_VERSION_STRING "1.0"

View file

@ -5,7 +5,6 @@ new SimGroup(MissionGroup) {
new LevelInfo(theLevelInfo) { new LevelInfo(theLevelInfo) {
visibleDistance = "1000"; visibleDistance = "1000";
visibleGhostDistance = "1000";
fogColor = "0.6 0.6 0.7 1"; fogColor = "0.6 0.6 0.7 1";
fogDensity = "0"; fogDensity = "0";
fogDensityOffset = "700"; fogDensityOffset = "700";

View file

@ -6,7 +6,6 @@ new SimGroup(MissionGroup) {
new LevelInfo(theLevelInfo) { new LevelInfo(theLevelInfo) {
nearClip = "0.1"; nearClip = "0.1";
visibleDistance = "2000"; visibleDistance = "2000";
visibleGhostDistance = "2000";
decalBias = "0.0015"; decalBias = "0.0015";
fogColor = "1 1 0.6 1"; fogColor = "1 1 0.6 1";
fogDensity = "0.001"; fogDensity = "0.001";

View file

@ -7,7 +7,6 @@ new SimGroup(MissionGroup) {
new LevelInfo(theLevelInfo) { new LevelInfo(theLevelInfo) {
nearClip = "0.1"; nearClip = "0.1";
visibleDistance = "2000"; visibleDistance = "2000";
visibleGhostDistance = "2000";
decalBias = "0.0015"; decalBias = "0.0015";
fogColor = "0.462745 0.698039 0.729412 1"; fogColor = "0.462745 0.698039 0.729412 1";
fogDensity = "0.005"; fogDensity = "0.005";

View file

@ -39,19 +39,6 @@
/// Version number is major * 1000 + minor * 100 + revision * 10. /// Version number is major * 1000 + minor * 100 + revision * 10.
#define TORQUE_APP_VERSION 1000 #define TORQUE_APP_VERSION 1000
//Ghost Scoping limits the number of objects being ghosted
//to a gameConnection to the objects around it within X
//distance.
//This is particularly useful for reducing bandwidth usage
//of games in which there are a lot of players and AI
//Basically, anything derived from SceneObject.
//GHOSTSCOPING_DEFAULT_DISTANCE_IF_NOT_IN_MISSION is the default distance
//a game will use if the distance is not defined in the mission file.
//DO NOT USE IF YOU ARE BUILDING A SIDE SCROLLER.
//To enable ghost scoping define:
//#define GHOSTSCOPING
//#define GHOSTSCOPING_DEFAULT_DISTANCE_IF_NOT_IN_MISSION 200.0f
/// Human readable application version string. /// Human readable application version string.
#define TORQUE_APP_VERSION_STRING "1.0" #define TORQUE_APP_VERSION_STRING "1.0"