This adds limiting the ghost data to a specific area around the client.

By default it is not included in the build, you must #define GHOSTSCOPING in the torqueConfig.h to enable it.
The distance can be set via the mission file by adding

visibleGhostDistance = "1000";

Or if it is not set in the mission file it will default to what is defined in torqueConfig.h #defined as GHOSTSCOPING_DEFAULT_DISTANCE_IF_NOT_IN_MISSION

The mission default distance can be overridden on a per connection basis by using gameconnection:setVisibleGhostDistance and gameconnection:getVisibleGhostDistance

The logic for setting the scoping distance was moved from shapebase in the original design to SceneObject so that it will affect cameras, players, etc.
This commit is contained in:
Vincent Gee 2014-11-05 23:14:39 -05:00
parent 378a933894
commit 55bdfe5dc3
15 changed files with 138 additions and 1 deletions

View file

@ -388,7 +388,14 @@ F32 GameBase::getUpdatePriority(CameraScopeQuery *camInfo, U32 updateMask, S32 u
// Weight by field of view, objects directly in front
// will be weighted 1, objects behind will be 0
F32 dot = mDot(pos,camInfo->orientation);
#ifdef GHOSTSCOPING
bool inFov = dot > camInfo->cosFov*1.5f;
#else
bool inFov = dot > camInfo->cosFov;
#endif
F32 wFov = inFov? 1.0f: 0;
// Weight by linear velocity parallel to the viewing plane
@ -406,7 +413,11 @@ F32 GameBase::getUpdatePriority(CameraScopeQuery *camInfo, U32 updateMask, S32 u
// Weight by interest.
F32 wInterest;
#ifdef GHOSTSCOPING
if (getTypeMask() & (PlayerObjectType || VehicleObjectType ))
#else
if (getTypeMask() & PlayerObjectType)
#endif
wInterest = 0.75f;
else if (getTypeMask() & ProjectileObjectType)
{

View file

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

View file

@ -226,6 +226,10 @@ GameConnection::GameConnection()
mAddYawToAbsRot = false;
mAddPitchToAbsRot = false;
#ifdef GHOSTSCOPING
mConnectionVisibleDistance = 0.0f;
#endif
clearDisplayDevice();
}
@ -239,6 +243,16 @@ GameConnection::~GameConnection()
}
//----------------------------------------------------------------------------
#ifdef GHOSTSCOPING
void GameConnection::setVisibleGhostDistance(F32 dist)
{
mConnectionVisibleDistance = dist;
}
F32 GameConnection::getVisibleGhostDistance()
{
return mConnectionVisibleDistance;
}
#endif
bool GameConnection::canRemoteCreate()
{
@ -2199,3 +2213,26 @@ DefineEngineMethod( GameConnection, getControlSchemeAbsoluteRotation, bool, (),,
{
return object->getControlSchemeAbsoluteRotation();
}
DefineEngineMethod( GameConnection, setVisibleGhostDistance, void, (F32 dist),,
"@brief Sets the distance that objects around it will be ghosted.\n\n"
"@dist - is the max distance\n\n"
)
{
#ifdef GHOSTSCOPING
object->setVisibleGhostDistance(dist);
#endif
}
DefineEngineMethod( GameConnection, getVisibleGhostDistance, F32, (),,
"@brief Gets the distance that objects around the connection will be ghosted.\n\n"
"@return S32 of distance.\n\n"
)
{
#ifdef GHOSTSCOPING
return object->getVisibleGhostDistance();
#else
return 0;
#endif
}

View file

@ -39,6 +39,8 @@
#include "core/bitVector.h"
#endif
#include "torqueConfig.h"
enum GameConnectionConstants
{
MaxClients = 126,
@ -72,6 +74,10 @@ private:
U32 mMissionCRC; // crc of the current mission file from the server
#ifdef GHOSTSCOPING
F32 mConnectionVisibleDistance;
#endif
private:
U32 mLastControlRequestTime;
S32 mDataBlockModifiedKey;
@ -155,6 +161,11 @@ public:
bool canRemoteCreate();
#ifdef GHOSTSCOPING
void setVisibleGhostDistance(F32 dist);
F32 getVisibleGhostDistance();
#endif
private:
/// @name Connection State
/// This data is set with setConnectArgs() and setJoinPassword(), and