Merge pull request #2146 from aws-lumberyard-dev/mp_lerp_jitter
Fix inconsistent client lerp and account for blend factor on server
This commit is contained in:
@@ -36,6 +36,8 @@ namespace Multiplayer
|
||||
void OnScaleChangedEvent(float scale);
|
||||
void OnResetCountChangedEvent();
|
||||
|
||||
void UpdateTargetHostFrameId();
|
||||
|
||||
AZ::Transform m_previousTransform = AZ::Transform::CreateIdentity();
|
||||
AZ::Transform m_targetTransform = AZ::Transform::CreateIdentity();
|
||||
|
||||
@@ -45,6 +47,8 @@ namespace Multiplayer
|
||||
AZ::Event<uint8_t>::Handler m_resetCountEventHandler;
|
||||
|
||||
EntityPreRenderEvent::Handler m_entityPreRenderEventHandler;
|
||||
|
||||
Multiplayer::HostFrameId m_targetHostFrameId = HostFrameId(0);
|
||||
};
|
||||
|
||||
class NetworkTransformComponentController
|
||||
|
||||
@@ -122,6 +122,11 @@ namespace Multiplayer
|
||||
//! @return the current server time in milliseconds
|
||||
virtual AZ::TimeMs GetCurrentHostTimeMs() const = 0;
|
||||
|
||||
//! Returns the current blend factor for client side interpolation
|
||||
//! This value is only relevant on the client and is used to smooth between host frames
|
||||
//! @return the current blend factor
|
||||
virtual float GetCurrentBlendFactor() const = 0;
|
||||
|
||||
//! Returns the network time instance bound to this multiplayer instance.
|
||||
//! @return pointer to the network time instance bound to this multiplayer instance
|
||||
virtual INetworkTime* GetNetworkTime() = 0;
|
||||
@@ -182,23 +187,27 @@ namespace Multiplayer
|
||||
class ScopedAlterTime final
|
||||
{
|
||||
public:
|
||||
inline ScopedAlterTime(HostFrameId frameId, AZ::TimeMs timeMs, AzNetworking::ConnectionId connectionId)
|
||||
inline ScopedAlterTime(HostFrameId frameId, AZ::TimeMs timeMs, float blendFactor, AzNetworking::ConnectionId connectionId)
|
||||
{
|
||||
INetworkTime* time = GetNetworkTime();
|
||||
m_previousHostFrameId = time->GetHostFrameId();
|
||||
m_previousHostTimeMs = time->GetHostTimeMs();
|
||||
m_previousRewindConnectionId = time->GetRewindingConnectionId();
|
||||
time->AlterTime(frameId, timeMs, connectionId);
|
||||
m_previousBlendFactor = time->GetHostBlendFactor();
|
||||
time->AlterBlendFactor(blendFactor);
|
||||
}
|
||||
inline ~ScopedAlterTime()
|
||||
{
|
||||
INetworkTime* time = GetNetworkTime();
|
||||
time->AlterTime(m_previousHostFrameId, m_previousHostTimeMs, m_previousRewindConnectionId);
|
||||
time->AlterBlendFactor(m_previousBlendFactor);
|
||||
}
|
||||
private:
|
||||
HostFrameId m_previousHostFrameId = InvalidHostFrameId;
|
||||
AZ::TimeMs m_previousHostTimeMs = AZ::TimeMs{ 0 };
|
||||
AzNetworking::ConnectionId m_previousRewindConnectionId = AzNetworking::InvalidConnectionId;
|
||||
float m_previousBlendFactor = DefaultBlendFactor;
|
||||
};
|
||||
|
||||
inline const char* GetEnumString(MultiplayerAgentType value)
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace Multiplayer
|
||||
//! The default number of rewindable samples for us to store.
|
||||
static constexpr uint32_t RewindHistorySize = 128;
|
||||
|
||||
//! The default blend factor for ScopedAlterTime
|
||||
static constexpr float DefaultBlendFactor = 1.f;
|
||||
|
||||
AZ_TYPE_SAFE_INTEGRAL(HostId, uint32_t);
|
||||
static constexpr HostId InvalidHostId = static_cast<HostId>(-1);
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@ namespace Multiplayer
|
||||
AZ::TimeMs GetHostTimeMs() const;
|
||||
AZ::TimeMs& ModifyHostTimeMs();
|
||||
|
||||
void SetHostBlendFactor(float hostBlendFactor);
|
||||
float GetHostBlendFactor() const;
|
||||
|
||||
void AttachNetBindComponent(NetBindComponent* netBindComponent);
|
||||
|
||||
bool Serialize(AzNetworking::ISerializer& serializer);
|
||||
@@ -73,6 +76,7 @@ namespace Multiplayer
|
||||
ClientInputId m_inputId = ClientInputId{ 0 };
|
||||
HostFrameId m_hostFrameId = InvalidHostFrameId;
|
||||
AZ::TimeMs m_hostTimeMs = AZ::TimeMs{ 0 };
|
||||
float m_hostBlendFactor = 0.f;
|
||||
ConstNetworkEntityHandle m_owner;
|
||||
bool m_wasAttached = false;
|
||||
};
|
||||
|
||||
@@ -43,6 +43,10 @@ namespace Multiplayer
|
||||
//! @return the hosts current timeMs
|
||||
virtual AZ::TimeMs GetHostTimeMs() const = 0;
|
||||
|
||||
//! Retrieves the hosts current blend factor (may be rewound on the server during backward reconciliation).
|
||||
//! @return the hosts current blend factor
|
||||
virtual float GetHostBlendFactor() const = 0;
|
||||
|
||||
//! Get the controlling connection that may be currently altering global game time.
|
||||
//! Note this abstraction is required at a relatively high level to allow for 'don't rewind the shooter' semantics
|
||||
//! @return the ConnectionId of the connection requesting the rewind operation
|
||||
@@ -60,6 +64,10 @@ namespace Multiplayer
|
||||
//! @param rewindConnectionId the rewinding ConnectionId
|
||||
virtual void AlterTime(HostFrameId frameId, AZ::TimeMs timeMs, AzNetworking::ConnectionId rewindConnectionId) = 0;
|
||||
|
||||
//! Alters the current Host blend factor. Used to drive interpolation in rewound states.
|
||||
//! @param blendFactor the blend factor to use
|
||||
virtual void AlterBlendFactor(float blendFactor) = 0;
|
||||
|
||||
//! Syncs all entities contained within a volume to the current rewind state.
|
||||
//! @param rewindVolume the volume to rewind entities within (needed for physics entities)
|
||||
virtual void SyncEntitiesToRewindState(const AZ::Aabb& rewindVolume) = 0;
|
||||
|
||||
@@ -60,6 +60,10 @@ namespace Multiplayer
|
||||
//! @return value in const base type form
|
||||
const BASE_TYPE& Get() const;
|
||||
|
||||
//! Const base type retriever for one host frame behind Get(). Only intended for use in SyncRewind contexts.
|
||||
//! @return value in const base type form
|
||||
const BASE_TYPE& GetPrevious() const;
|
||||
|
||||
//! Base type retriever.
|
||||
//! @return value in base type form
|
||||
BASE_TYPE& Modify();
|
||||
|
||||
@@ -66,6 +66,12 @@ namespace Multiplayer
|
||||
return GetValueForTime(GetCurrentTimeForProperty());
|
||||
}
|
||||
|
||||
template <typename BASE_TYPE, AZStd::size_t REWIND_SIZE>
|
||||
inline const BASE_TYPE& RewindableObject<BASE_TYPE, REWIND_SIZE>::GetPrevious() const
|
||||
{
|
||||
return GetValueForTime(GetCurrentTimeForProperty() - HostFrameId(1));
|
||||
}
|
||||
|
||||
template <typename BASE_TYPE, AZStd::size_t REWIND_SIZE>
|
||||
inline BASE_TYPE& RewindableObject<BASE_TYPE, REWIND_SIZE>::Modify()
|
||||
{
|
||||
|
||||
@@ -155,9 +155,12 @@ namespace Multiplayer
|
||||
// Discard move input events, client may be speed hacking
|
||||
if (m_clientBankedTime < sv_MaxBankTimeWindowSec)
|
||||
{
|
||||
// Client blends from previous frame to target so here we subtract blend factor to get to that state
|
||||
const float blendFactor = AZStd::min(AZStd::max(0.f, input.GetHostBlendFactor()), 1.f);
|
||||
const AZ::TimeMs blendMs = AZ::TimeMs(static_cast<float>(static_cast<AZ::TimeMs>(cl_InputRateMs)) * (1.f - blendFactor));
|
||||
m_clientBankedTime = AZStd::min(m_clientBankedTime + clientInputRateSec, (double)sv_MaxBankTimeWindowSec); // clamp to boundary
|
||||
{
|
||||
ScopedAlterTime scopedTime(input.GetHostFrameId(), input.GetHostTimeMs(), invokingConnection->GetConnectionId());
|
||||
ScopedAlterTime scopedTime(input.GetHostFrameId(), input.GetHostTimeMs() - blendMs, input.GetHostBlendFactor(), invokingConnection->GetConnectionId());
|
||||
GetNetBindComponent()->ProcessInput(input, static_cast<float>(clientInputRateSec));
|
||||
}
|
||||
|
||||
@@ -311,7 +314,7 @@ namespace Multiplayer
|
||||
++ModifyLastInputId();
|
||||
input.SetClientInputId(GetLastInputId());
|
||||
|
||||
ScopedAlterTime scopedTime(input.GetHostFrameId(), input.GetHostTimeMs(), invokingConnection->GetConnectionId());
|
||||
ScopedAlterTime scopedTime(input.GetHostFrameId(), input.GetHostTimeMs(), input.GetHostBlendFactor(), invokingConnection->GetConnectionId());
|
||||
GetNetBindComponent()->ProcessInput(input, clientInputRateSec);
|
||||
|
||||
AZLOG
|
||||
@@ -391,7 +394,7 @@ namespace Multiplayer
|
||||
{
|
||||
// Reprocess the input for this frame
|
||||
NetworkInput& input = m_inputHistory[replayIndex];
|
||||
ScopedAlterTime scopedTime(input.GetHostFrameId(), input.GetHostTimeMs(), invokingConnection->GetConnectionId());
|
||||
ScopedAlterTime scopedTime(input.GetHostFrameId(), input.GetHostTimeMs(), input.GetHostBlendFactor(), invokingConnection->GetConnectionId());
|
||||
GetNetBindComponent()->ProcessInput(input, clientInputRateSec);
|
||||
|
||||
AZLOG
|
||||
@@ -499,6 +502,7 @@ namespace Multiplayer
|
||||
input.SetClientInputId(m_clientInputId);
|
||||
input.SetHostFrameId(networkTime->GetHostFrameId());
|
||||
input.SetHostTimeMs(multiplayer->GetCurrentHostTimeMs());
|
||||
input.SetHostBlendFactor(multiplayer->GetCurrentBlendFactor());
|
||||
|
||||
// Allow components to form the input for this frame
|
||||
GetNetBindComponent()->CreateInput(input, inputRate);
|
||||
@@ -573,7 +577,7 @@ namespace Multiplayer
|
||||
|
||||
NetworkInput& input = m_lastInputReceived[0];
|
||||
{
|
||||
ScopedAlterTime scopedTime(input.GetHostFrameId(), input.GetHostTimeMs(), AzNetworking::InvalidConnectionId);
|
||||
ScopedAlterTime scopedTime(input.GetHostFrameId(), input.GetHostTimeMs(), DefaultBlendFactor, AzNetworking::InvalidConnectionId);
|
||||
GetNetBindComponent()->ProcessInput(input, inputRate);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,18 +61,21 @@ namespace Multiplayer
|
||||
{
|
||||
m_previousTransform.SetRotation(m_targetTransform.GetRotation());
|
||||
m_targetTransform.SetRotation(rotation);
|
||||
UpdateTargetHostFrameId();
|
||||
}
|
||||
|
||||
void NetworkTransformComponent::OnTranslationChangedEvent(const AZ::Vector3& translation)
|
||||
{
|
||||
m_previousTransform.SetTranslation(m_targetTransform.GetTranslation());
|
||||
m_targetTransform.SetTranslation(translation);
|
||||
UpdateTargetHostFrameId();
|
||||
}
|
||||
|
||||
void NetworkTransformComponent::OnScaleChangedEvent(float scale)
|
||||
{
|
||||
m_previousTransform.SetUniformScale(m_targetTransform.GetUniformScale());
|
||||
m_targetTransform.SetUniformScale(scale);
|
||||
UpdateTargetHostFrameId();
|
||||
}
|
||||
|
||||
void NetworkTransformComponent::OnResetCountChangedEvent()
|
||||
@@ -83,14 +86,31 @@ namespace Multiplayer
|
||||
m_previousTransform = m_targetTransform;
|
||||
}
|
||||
|
||||
void NetworkTransformComponent::UpdateTargetHostFrameId()
|
||||
{
|
||||
HostFrameId currentHostFrameId = Multiplayer::GetNetworkTime()->GetHostFrameId();
|
||||
if (currentHostFrameId > m_targetHostFrameId)
|
||||
{
|
||||
m_targetHostFrameId = currentHostFrameId;
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkTransformComponent::OnPreRender([[maybe_unused]] float deltaTime, float blendFactor)
|
||||
{
|
||||
if (!HasController())
|
||||
{
|
||||
AZ::Transform blendTransform;
|
||||
blendTransform.SetRotation(m_previousTransform.GetRotation().Slerp(m_targetTransform.GetRotation(), blendFactor));
|
||||
blendTransform.SetTranslation(m_previousTransform.GetTranslation().Lerp(m_targetTransform.GetTranslation(), blendFactor));
|
||||
blendTransform.SetUniformScale(AZ::Lerp(m_previousTransform.GetUniformScale(), m_targetTransform.GetUniformScale(), blendFactor));
|
||||
if (Multiplayer::GetNetworkTime() && Multiplayer::GetNetworkTime()->GetHostFrameId() > m_targetHostFrameId)
|
||||
{
|
||||
m_previousTransform = m_targetTransform;
|
||||
blendTransform = m_targetTransform;
|
||||
}
|
||||
else
|
||||
{
|
||||
blendTransform.SetRotation(m_previousTransform.GetRotation().Slerp(m_targetTransform.GetRotation(), blendFactor));
|
||||
blendTransform.SetTranslation(m_previousTransform.GetTranslation().Lerp(m_targetTransform.GetTranslation(), blendFactor));
|
||||
blendTransform.SetUniformScale(AZ::Lerp(m_previousTransform.GetUniformScale(), m_targetTransform.GetUniformScale(), blendFactor));
|
||||
}
|
||||
|
||||
if (!GetTransformComponent()->GetWorldTM().IsClose(blendTransform))
|
||||
{
|
||||
|
||||
@@ -809,6 +809,11 @@ namespace Multiplayer
|
||||
}
|
||||
}
|
||||
|
||||
float MultiplayerSystemComponent::GetCurrentBlendFactor() const
|
||||
{
|
||||
return m_renderBlendFactor;
|
||||
}
|
||||
|
||||
INetworkTime* MultiplayerSystemComponent::GetNetworkTime()
|
||||
{
|
||||
return &m_networkTime;
|
||||
@@ -856,12 +861,12 @@ namespace Multiplayer
|
||||
{
|
||||
m_tickFactor += deltaTime / serverRateSeconds;
|
||||
// Linear close to the origin, but asymptote at y = 1
|
||||
const float renderBlendFactor = AZStd::clamp(1.0f - (std::pow(cl_renderTickBlendBase, m_tickFactor)), 0.0f, 1.0f);
|
||||
m_renderBlendFactor = AZStd::clamp(1.0f - (std::pow(cl_renderTickBlendBase, m_tickFactor)), 0.0f, 1.0f);
|
||||
AZLOG
|
||||
(
|
||||
NET_Blending,
|
||||
"Computed blend factor of %0.3f using a tick factor of %0.3f, a frametime of %0.3f and a serverTickRate of %0.3f",
|
||||
renderBlendFactor,
|
||||
m_renderBlendFactor,
|
||||
m_tickFactor,
|
||||
deltaTime,
|
||||
serverRateSeconds
|
||||
@@ -908,7 +913,7 @@ namespace Multiplayer
|
||||
|
||||
for (NetBindComponent* netBindComponent : gatheredEntities)
|
||||
{
|
||||
netBindComponent->NotifyPreRender(deltaTime, renderBlendFactor);
|
||||
netBindComponent->NotifyPreRender(deltaTime, m_renderBlendFactor);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -920,7 +925,7 @@ namespace Multiplayer
|
||||
NetBindComponent* netBindComponent = entity->FindComponent<NetBindComponent>();
|
||||
if (netBindComponent != nullptr)
|
||||
{
|
||||
netBindComponent->NotifyPreRender(deltaTime, renderBlendFactor);
|
||||
netBindComponent->NotifyPreRender(deltaTime, m_renderBlendFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ namespace Multiplayer
|
||||
void Terminate(AzNetworking::DisconnectReason reason) override;
|
||||
void SendReadyForEntityUpdates(bool readyForEntityUpdates) override;
|
||||
AZ::TimeMs GetCurrentHostTimeMs() const override;
|
||||
float GetCurrentBlendFactor() const override;
|
||||
INetworkTime* GetNetworkTime() override;
|
||||
INetworkEntityManager* GetNetworkEntityManager() override;
|
||||
void SetFilterEntityManager(IFilterEntityManager* entityFilter) override;
|
||||
@@ -155,6 +156,7 @@ namespace Multiplayer
|
||||
HostFrameId m_lastReplicatedHostFrameId = HostFrameId(0);
|
||||
|
||||
double m_serverSendAccumulator = 0.0;
|
||||
float m_renderBlendFactor = 0.0f;
|
||||
float m_tickFactor = 0.0f;
|
||||
|
||||
#if !defined(AZ_RELEASE_BUILD)
|
||||
|
||||
@@ -76,6 +76,16 @@ namespace Multiplayer
|
||||
return m_hostTimeMs;
|
||||
}
|
||||
|
||||
void NetworkInput::SetHostBlendFactor(float hostBlendFactor)
|
||||
{
|
||||
m_hostBlendFactor = hostBlendFactor;
|
||||
}
|
||||
|
||||
float NetworkInput::GetHostBlendFactor() const
|
||||
{
|
||||
return m_hostBlendFactor;
|
||||
}
|
||||
|
||||
void NetworkInput::AttachNetBindComponent(NetBindComponent* netBindComponent)
|
||||
{
|
||||
m_wasAttached = true;
|
||||
@@ -91,7 +101,8 @@ namespace Multiplayer
|
||||
{
|
||||
if (!serializer.Serialize(m_inputId, "InputId")
|
||||
|| !serializer.Serialize(m_hostTimeMs, "HostTimeMs")
|
||||
|| !serializer.Serialize(m_hostFrameId, "HostFrameId"))
|
||||
|| !serializer.Serialize(m_hostFrameId, "HostFrameId")
|
||||
|| !serializer.Serialize(m_hostBlendFactor, "HostBlendFactor"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -164,6 +175,7 @@ namespace Multiplayer
|
||||
m_inputId = rhs.m_inputId;
|
||||
m_hostFrameId = rhs.m_hostFrameId;
|
||||
m_hostTimeMs = rhs.m_hostTimeMs;
|
||||
m_hostBlendFactor = rhs.m_hostBlendFactor;
|
||||
m_componentInputs.resize(rhs.m_componentInputs.size());
|
||||
for (int32_t i = 0; i < rhs.m_componentInputs.size(); ++i)
|
||||
{
|
||||
|
||||
@@ -55,6 +55,11 @@ namespace Multiplayer
|
||||
return m_hostTimeMs;
|
||||
}
|
||||
|
||||
float NetworkTime::GetHostBlendFactor() const
|
||||
{
|
||||
return m_hostBlendFactor;
|
||||
}
|
||||
|
||||
AzNetworking::ConnectionId NetworkTime::GetRewindingConnectionId() const
|
||||
{
|
||||
return m_rewindingConnectionId;
|
||||
@@ -72,6 +77,11 @@ namespace Multiplayer
|
||||
m_rewindingConnectionId = rewindConnectionId;
|
||||
}
|
||||
|
||||
void NetworkTime::AlterBlendFactor(float blendFactor)
|
||||
{
|
||||
m_hostBlendFactor = blendFactor;
|
||||
}
|
||||
|
||||
void NetworkTime::SyncEntitiesToRewindState(const AZ::Aabb& rewindVolume)
|
||||
{
|
||||
// Since the vis system doesn't support rewound queries, first query with an expanded volume to catch any fast moving entities
|
||||
@@ -95,6 +105,7 @@ namespace Multiplayer
|
||||
|
||||
if (networkTransform != nullptr)
|
||||
{
|
||||
// We're not presently factoring in interpolated position here
|
||||
const AZ::Vector3 rewindCenter = networkTransform->GetTranslation(); // Get the rewound position
|
||||
const AZ::Vector3 rewindOffset = rewindCenter - currentCenter; // Compute offset between rewound and current positions
|
||||
const AZ::Aabb rewoundAabb = currentBounds.GetTranslated(rewindOffset); // Apply offset to the entity aabb
|
||||
|
||||
@@ -30,9 +30,11 @@ namespace Multiplayer
|
||||
HostFrameId GetUnalteredHostFrameId() const override;
|
||||
void IncrementHostFrameId() override;
|
||||
AZ::TimeMs GetHostTimeMs() const override;
|
||||
float GetHostBlendFactor() const override;
|
||||
AzNetworking::ConnectionId GetRewindingConnectionId() const override;
|
||||
HostFrameId GetHostFrameIdForRewindingConnection(AzNetworking::ConnectionId rewindConnectionId) const override;
|
||||
void AlterTime(HostFrameId frameId, AZ::TimeMs timeMs, AzNetworking::ConnectionId rewindConnectionId) override;
|
||||
void AlterBlendFactor(float blendFactor) override;
|
||||
void SyncEntitiesToRewindState(const AZ::Aabb& rewindVolume) override;
|
||||
void ClearRewoundEntities() override;
|
||||
//! @}
|
||||
@@ -44,6 +46,7 @@ namespace Multiplayer
|
||||
HostFrameId m_hostFrameId = HostFrameId{ 0 };
|
||||
HostFrameId m_unalteredFrameId = HostFrameId{ 0 };
|
||||
AZ::TimeMs m_hostTimeMs = AZ::TimeMs{ 0 };
|
||||
float m_hostBlendFactor = DefaultBlendFactor;
|
||||
AzNetworking::ConnectionId m_rewindingConnectionId = AzNetworking::InvalidConnectionId;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace UnitTest
|
||||
// Test rewind for all pushed values and overall size
|
||||
for (uint32_t idx = 0; idx < RewindableContainerSize; ++idx)
|
||||
{
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(idx), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(idx), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
EXPECT_EQ(idx + 1, test.size());
|
||||
EXPECT_EQ(idx, test.back());
|
||||
}
|
||||
@@ -70,9 +70,9 @@ namespace UnitTest
|
||||
EXPECT_TRUE(test.empty());
|
||||
|
||||
// Test rewind for pop_back and clear
|
||||
Multiplayer::ScopedAlterTime pop_time(static_cast<Multiplayer::HostFrameId>(RewindableContainerSize), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime pop_time(static_cast<Multiplayer::HostFrameId>(RewindableContainerSize), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
EXPECT_EQ(RewindableContainerSize - 1, test.size());
|
||||
Multiplayer::ScopedAlterTime clear_time(static_cast<Multiplayer::HostFrameId>(RewindableContainerSize + 1), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime clear_time(static_cast<Multiplayer::HostFrameId>(RewindableContainerSize + 1), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
EXPECT_EQ(0, test.size());
|
||||
|
||||
// Test copy_values and resize_no_construct
|
||||
@@ -100,7 +100,7 @@ namespace UnitTest
|
||||
// Test rewind for all values and overall size
|
||||
for (uint32_t idx = 1; idx <= RewindableContainerSize; ++idx)
|
||||
{
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(idx), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(idx), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
for (uint32_t testIdx = 0; testIdx < RewindableContainerSize; ++testIdx)
|
||||
{
|
||||
if (testIdx < idx)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace UnitTest
|
||||
|
||||
for (uint32_t i = 0; i < 16; ++i)
|
||||
{
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(i), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(i), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
EXPECT_EQ(i, test);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace UnitTest
|
||||
|
||||
for (uint32_t i = 16; i < 48; ++i)
|
||||
{
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(i), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(i), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
EXPECT_EQ(i, test);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace UnitTest
|
||||
|
||||
{
|
||||
// Note that we didn't actually set any value for time rewindableBufferFrames, so we're testing fetching a value past the last time set
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(RewindableBufferFrames), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(RewindableBufferFrames), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
EXPECT_EQ(RewindableBufferFrames - 1, test);
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ namespace UnitTest
|
||||
|
||||
for (uint32_t i = 0; i < RewindableBufferFrames; ++i)
|
||||
{
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(i), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(i), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
const Object& value = test;
|
||||
EXPECT_EQ(value.value, i);
|
||||
}
|
||||
@@ -102,19 +102,19 @@ namespace UnitTest
|
||||
TEST_F(RewindableObjectTests, TestBackfillOnLargeTimestep)
|
||||
{
|
||||
Multiplayer::RewindableObject<uint32_t, RewindableBufferFrames> test(0);
|
||||
Multiplayer::ScopedAlterTime time1(static_cast<Multiplayer::HostFrameId>(0), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime time1(static_cast<Multiplayer::HostFrameId>(0), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
test = 1;
|
||||
|
||||
Multiplayer::ScopedAlterTime time2(static_cast<Multiplayer::HostFrameId>(31), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime time2(static_cast<Multiplayer::HostFrameId>(31), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
test = 2;
|
||||
|
||||
for (uint32_t i = 0; i < 31; ++i)
|
||||
{
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(i), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(i), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
EXPECT_EQ(1, test);
|
||||
}
|
||||
|
||||
Multiplayer::ScopedAlterTime time3(static_cast<Multiplayer::HostFrameId>(31), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime time3(static_cast<Multiplayer::HostFrameId>(31), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
EXPECT_EQ(2, test);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace UnitTest
|
||||
|
||||
for (uint32_t i = 0; i < 1000; ++i)
|
||||
{
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(1000 - i), AZ::TimeMs{ 0 }, AzNetworking::InvalidConnectionId);
|
||||
Multiplayer::ScopedAlterTime time(static_cast<Multiplayer::HostFrameId>(1000 - i), AZ::TimeMs{ 0 }, 1.f, AzNetworking::InvalidConnectionId);
|
||||
EXPECT_EQ(1000, test);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user