First person enhancements (#656)
* only switch first-person mode while spectating closes #655 * use first person view for first-person spectating * don't spectate specators; refactor
This commit is contained in:
parent
228f1b1ee5
commit
266d141e04
@ -723,6 +723,9 @@ namespace spades {
|
||||
continue;
|
||||
if (p->GetFront().GetPoweredLength() < .01f)
|
||||
continue;
|
||||
if (p->GetTeamId() >= 2){
|
||||
continue; // Don't spectate spectators
|
||||
}
|
||||
|
||||
break;
|
||||
} while (nextId != followingPlayerId);
|
||||
|
@ -283,6 +283,7 @@ namespace spades {
|
||||
|
||||
float GetAimDownZoomScale();
|
||||
bool ShouldRenderInThirdPersonView();
|
||||
Player *GetViewedPlayer();
|
||||
SceneDefinition CreateSceneDefinition();
|
||||
|
||||
std::string ScreenShotPath();
|
||||
|
@ -1042,8 +1042,10 @@ namespace spades {
|
||||
}
|
||||
|
||||
bool ClientPlayer::ShouldRenderInThirdPersonView() {
|
||||
if (player != player->GetWorld()->GetLocalPlayer())
|
||||
return true;
|
||||
// the player from whom's perspective the game is seen
|
||||
|
||||
if (player != client->GetViewedPlayer()) return true;
|
||||
|
||||
return client->ShouldRenderInThirdPersonView();
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ namespace spades {
|
||||
} else if (CheckKey(cg_keySneak, name)) {
|
||||
playerInput.sneak = down;
|
||||
} else if (CheckKey(cg_keyJump, name)) {
|
||||
if (down) {
|
||||
if (down && IsFollowing()) {
|
||||
firstPersonSpectate = !firstPersonSpectate;
|
||||
}
|
||||
playerInput.jump = down;
|
||||
|
@ -56,16 +56,35 @@ namespace spades {
|
||||
#pragma mark - Drawing
|
||||
|
||||
bool Client::ShouldRenderInThirdPersonView() {
|
||||
if (IsFollowing()){
|
||||
if (!GetViewedPlayer()->IsAlive()){
|
||||
return true;
|
||||
}
|
||||
return !firstPersonSpectate;
|
||||
}
|
||||
|
||||
if (world && world->GetLocalPlayer()) {
|
||||
if (!world->GetLocalPlayer()->IsAlive())
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((int)cg_thirdperson != 0 && world->GetNumPlayers() <= 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Player *Client::GetViewedPlayer() {
|
||||
// what happens if we are in free mode?
|
||||
// doesn't matter for the current code, but keep this in mind
|
||||
if (IsFollowing()){
|
||||
return world->GetPlayer(followingPlayerId);
|
||||
}
|
||||
else {
|
||||
return world->GetLocalPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
float Client::GetLocalFireVibration() {
|
||||
float localFireVibration = 0.f;
|
||||
localFireVibration = time - localFireVibrationTime;
|
||||
@ -204,7 +223,7 @@ namespace spades {
|
||||
Vector3 front = center - eye;
|
||||
front = front.Normalize();
|
||||
|
||||
if (firstPersonSpectate == false) {
|
||||
if (ShouldRenderInThirdPersonView()) {
|
||||
def.viewOrigin = eye;
|
||||
def.viewAxis[0] = -Vector3::Cross(up, front).Normalize();
|
||||
def.viewAxis[1] = -Vector3::Cross(front, def.viewAxis[0]).Normalize();
|
||||
|
Loading…
x
Reference in New Issue
Block a user