Desync debug work

Signed-off-by: kberg-amzn <karlberg@amazon.com>
This commit is contained in:
kberg-amzn
2021-07-19 12:03:57 -07:00
parent 68d2536b3b
commit 23a4835e48
2 changed files with 16 additions and 9 deletions
@@ -10,9 +10,9 @@
namespace AzNetworking
{
// This gives us a hash sensitivity of around 1/128th of a unit, and will detect errors within a range of -16,777,216 to +16,777,216
static const int32_t FloatHashMinValue = (INT_MIN >> 7);
static const int32_t FloatHashMaxValue = (INT_MAX >> 7);
// This gives us a hash sensitivity of around 1/512th of a unit, and will detect errors within a range of -4,194,304 to +4,194,304
static const int32_t FloatHashMinValue = (INT_MIN >> 9);
static const int32_t FloatHashMaxValue = (INT_MAX >> 9);
AZ::HashValue32 HashSerializer::GetHash() const
{
@@ -92,11 +92,14 @@ namespace AzNetworking
// This hashing serializer is used to detect desyncs between the predicted and authoritative state of all predictive values
// If either of these asserts triggers, it means desyncs *will not* be detected for the value being serialized
// You should consider using a quantized float for the failing value, or potentially adjust the min/max quantized values
AZ_Assert(value > FloatHashMinValue, "Out of range float value passed to hashing serializer, this will clamp the float value");
AZ_Assert(value < FloatHashMaxValue, "Out of range float value passed to hashing serializer, this will clamp the float value");
QuantizedValues<1, 4, FloatHashMinValue, FloatHashMaxValue> quantizedValue(value);
const int32_t hashableValue = quantizedValue.GetQuantizedIntegralValues()[0];
m_hash = AZ::TypeHash64(hashableValue, m_hash);
//AZ_Assert(value > FloatHashMinValue, "Out of range float value passed to hashing serializer, this will clamp the float value");
//AZ_Assert(value < FloatHashMaxValue, "Out of range float value passed to hashing serializer, this will clamp the float value");
//QuantizedValues<1, 4, FloatHashMinValue, FloatHashMaxValue> quantizedValue(value);
//const int32_t hashableValue = quantizedValue.GetQuantizedIntegralValues()[0];
//m_hash = AZ::TypeHash64(hashableValue, m_hash);
//return true;
m_hash = AZ::TypeHash64(value, m_hash);
return true;
}
@@ -90,7 +90,11 @@ namespace Multiplayer
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));
GetTransformComponent()->SetWorldTM(blendTransform);
if (!GetTransformComponent()->GetWorldTM().IsClose(blendTransform))
{
GetTransformComponent()->SetWorldTM(blendTransform);
}
}
}