[10052] Camera System

(based on SilverIce's repo commit 4f2f4ab + next 3 more)

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
SilverIce 2010-06-12 05:00:09 +04:00 committed by VladimirMangos
parent f520c9b1e0
commit e427ce80cc
27 changed files with 515 additions and 207 deletions

View file

@ -405,7 +405,7 @@ void TradeData::SetAccepted(bool state, bool crosssend /*= false*/)
UpdateMask Player::updateVisualBits;
Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputationMgr(this)
Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputationMgr(this), m_camera(this)
{
m_transport = 0;
@ -2409,7 +2409,8 @@ void Player::SetGameMaster(bool on)
getHostileRefManager().setOnlineOfflineState(true);
}
UpdateVisibilityForPlayer();
m_camera.UpdateVisibilityForOwner();
UpdateObjectVisibility();
}
void Player::SetGMVisible(bool on)
@ -4490,8 +4491,10 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
GetZoneAndAreaId(newzone,newarea);
UpdateZone(newzone,newarea);
// update visibility
UpdateVisibilityForPlayer();
// update visibility of world around viewpoint
m_camera.UpdateVisibilityForOwner();
// update visibility of player for nearby cameras
UpdateObjectVisibility();
if(!applySickness)
return;
@ -6073,42 +6076,30 @@ void Player::SaveRecallPosition()
void Player::SendMessageToSet(WorldPacket *data, bool self)
{
Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId());
if(_map)
{
_map->MessageBroadcast(this, data, self);
return;
}
if (Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()))
_map->MessageBroadcast(this, data, false);
//if player is not in world and map in not created/already destroyed
//no need to create one, just send packet for itself!
if(self)
if (self)
GetSession()->SendPacket(data);
}
void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
{
Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId());
if(_map)
{
_map->MessageDistBroadcast(this, data, dist, self);
return;
}
if (Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()))
_map->MessageDistBroadcast(this, data, dist, false);
if(self)
if (self)
GetSession()->SendPacket(data);
}
void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only)
{
Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId());
if(_map)
{
_map->MessageDistBroadcast(this, data, dist, self, own_team_only);
return;
}
if (Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()))
_map->MessageDistBroadcast(this, data, dist, false, own_team_only);
if(self)
if (self)
GetSession()->SendPacket(data);
}
@ -15322,7 +15313,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
SetCreatorGUID(0);
// reset some aura modifiers before aura apply
SetFarSightGUID(0);
SetUInt64Value(PLAYER_FARSIGHT, 0);
SetUInt32Value(PLAYER_TRACK_CREATURES, 0 );
SetUInt32Value(PLAYER_TRACK_RESOURCES, 0 );
@ -18058,7 +18050,7 @@ void Player::HandleStealthedUnitsDetection()
MaNGOS::UnitListSearcher<MaNGOS::AnyStealthedCheck > searcher(this,stealthedUnits, u_check);
Cell::VisitAllObjects(this, searcher, MAX_PLAYER_STEALTH_DETECT_RANGE);
WorldObject const* viewPoint = GetViewPoint();
WorldObject const* viewPoint = GetCamera().GetBody();
for (std::list<Unit*>::const_iterator i = stealthedUnits.begin(); i != stealthedUnits.end(); ++i)
{
@ -19154,17 +19146,6 @@ void Player::ReportedAfkBy(Player* reporter)
}
}
WorldObject const* Player::GetViewPoint() const
{
if(uint64 far_sight = GetFarSight())
{
WorldObject const* viewPoint = GetMap()->GetWorldObject(far_sight);
return viewPoint ? viewPoint : this; // always expected not NULL
}
else
return this;
}
bool Player::IsVisibleInGridForPlayer( Player* pl ) const
{
// gamemaster in GM mode see all, including ghosts
@ -20736,7 +20717,7 @@ void Player::EnterVehicle(Vehicle *vehicle)
vehicle->setFaction(getFaction());
SetCharm(vehicle); // charm
SetFarSightGUID(vehicle->GetGUID()); // set view
m_camera.SetView(vehicle); // set view
SetClientControl(vehicle, 1); // redirect controls to vehicle
SetMover(vehicle);
@ -20788,7 +20769,7 @@ void Player::ExitVehicle(Vehicle *vehicle)
vehicle->setFaction((GetTeam() == ALLIANCE) ? vehicle->GetCreatureInfo()->faction_A : vehicle->GetCreatureInfo()->faction_H);
SetCharm(NULL);
SetFarSightGUID(0);
m_camera.ResetView();
SetClientControl(vehicle, 0);
SetMover(NULL);
@ -22022,38 +22003,6 @@ bool Player::HasMovementFlag( MovementFlags f ) const
return m_movementInfo.HasMovementFlag(f);
}
void Player::SetFarSightGUID( uint64 guid )
{
if(GetFarSight() == guid)
return;
SetUInt64Value(PLAYER_FARSIGHT, guid);
// need triggering load grids around new view point
UpdateVisibilityForPlayer();
}
void Player::UpdateVisibilityForPlayer()
{
WorldObject const* viewPoint = GetViewPoint();
Map* m = GetMap();
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
Cell cell(p);
m->UpdateObjectVisibility(this, cell, p);
if (this != viewPoint)
{
CellPair pView(MaNGOS::ComputeCellPair(viewPoint->GetPositionX(), viewPoint->GetPositionY()));
Cell cellView(pView);
m->UpdateObjectsVisibilityFor(this, cellView, pView);
}
else
m->UpdateObjectsVisibilityFor(this, cell, p);
}
void Player::ResetTimeSync()
{
m_timeSyncCounter = 0;