Merge pull request #2315 from aws-lumberyard-dev/MultiplayerWeapons
Multiplayer weapons
This commit is contained in:
@@ -16,6 +16,8 @@ UserSettings.xml
|
||||
FrameCapture/**
|
||||
.DS_Store
|
||||
user*.cfg
|
||||
client*.cfg
|
||||
server*.cfg
|
||||
.mayaSwatches/
|
||||
_savebackup/
|
||||
#Output folder for test results when running Automated Tests
|
||||
|
||||
@@ -303,4 +303,22 @@ namespace AzNetworking
|
||||
return serializer.IsValid();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct SerializeObjectHelper<AZ::Transform>
|
||||
{
|
||||
static bool SerializeObject(ISerializer& serializer, AZ::Transform& value)
|
||||
{
|
||||
AZ::Vector3 translation = value.GetTranslation();
|
||||
AZ::Quaternion rotation = value.GetRotation();
|
||||
float uniformScale = value.GetUniformScale();
|
||||
serializer.Serialize(translation, "Translation");
|
||||
serializer.Serialize(rotation, "Rotation");
|
||||
serializer.Serialize(uniformScale, "Scale");
|
||||
value.SetTranslation(translation);
|
||||
value.SetRotation(rotation);
|
||||
value.SetUniformScale(uniformScale);
|
||||
return serializer.IsValid();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,9 +11,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
|
||||
{
|
||||
|
||||
@@ -8,22 +8,22 @@
|
||||
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
|
||||
{% if Property.attrib['Container'] == 'Array' %}
|
||||
{% if Property.attrib['IsRewindable']|booleanTrue %}
|
||||
const RewindableArray<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}> &Get{{ PropertyName }}Array() const;
|
||||
const RewindableArray<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& Get{{ PropertyName }}Array() const;
|
||||
{% else %}
|
||||
const AZStd::array<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}> &Get{{ PropertyName }}Array() const;
|
||||
const AZStd::array<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& Get{{ PropertyName }}Array() const;
|
||||
{% endif %}
|
||||
const {{ Property.attrib['Type'] }} &Get{{ PropertyName }}(int32_t index) const;
|
||||
const {{ Property.attrib['Type'] }}& Get{{ PropertyName }}(int32_t index) const;
|
||||
{% if Property.attrib['GenerateEventBindings']|booleanTrue %}
|
||||
void {{ PropertyName }}AddEvent(AZ::Event<int32_t, {{ Property.attrib['Type'] }}>::Handler& handler);
|
||||
{% endif %}
|
||||
{% elif Property.attrib['Container'] == 'Vector' %}
|
||||
{% if Property.attrib['IsRewindable']|booleanTrue %}
|
||||
const RewindableFixedVector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}> &Get{{ PropertyName }}Vector() const;
|
||||
const RewindableFixedVector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& Get{{ PropertyName }}Vector() const;
|
||||
{% else %}
|
||||
const AZStd::fixed_vector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}> &Get{{ PropertyName }}Vector() const;
|
||||
const AZStd::fixed_vector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& Get{{ PropertyName }}Vector() const;
|
||||
{% endif %}
|
||||
const {{ Property.attrib['Type'] }} &Get{{ PropertyName }}(int32_t index) const;
|
||||
const {{ Property.attrib['Type'] }} &{{ PropertyName }}GetBack() const;
|
||||
const {{ Property.attrib['Type'] }}& Get{{ PropertyName }}(int32_t index) const;
|
||||
const {{ Property.attrib['Type'] }}& {{ PropertyName }}GetBack() const;
|
||||
uint32_t {{ PropertyName }}GetSize() const;
|
||||
{% if Property.attrib['GenerateEventBindings']|booleanTrue %}
|
||||
void {{ PropertyName }}AddEvent(AZ::Event<int32_t, {{ Property.attrib['Type'] }}>::Handler& handler);
|
||||
@@ -63,7 +63,7 @@ void Set{{ PropertyName }}(const {{ Property.attrib['Type'] }}& value);
|
||||
{% macro DeclareNetworkPropertyGetters(Component, ReplicateFrom, ReplicateTo, IsProtected) %}
|
||||
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, ReplicateFrom, ReplicateTo) %}
|
||||
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
|
||||
{% if Property.attrib['IsPublic'] | booleanTrue != IsProtected %}
|
||||
{% if Property.attrib['IsPublic']|booleanTrue != IsProtected %}
|
||||
//! {{ PropertyName }} Accessors
|
||||
//! {{ Property.attrib['Description'] }}.
|
||||
{{ DeclareNetworkPropertyGetter(Property) }}
|
||||
@@ -105,7 +105,7 @@ const {{ Property.attrib['Type'] }}& Get{{ PropertyName }}() const;
|
||||
{% macro DeclareNetworkPropertyAccessors(Component, ReplicateFrom, ReplicateTo, IsProtected) %}
|
||||
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, ReplicateFrom, ReplicateTo) %}
|
||||
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
|
||||
{% if Property.attrib['IsPublic'] | booleanTrue != IsProtected %}
|
||||
{% if Property.attrib['IsPublic']|booleanTrue != IsProtected %}
|
||||
//! {{ PropertyName }} Accessors
|
||||
//! {{ Property.attrib['Description'] }}.
|
||||
{{ DeclareNetworkPropertyGetter(Property) -}}
|
||||
|
||||
@@ -507,7 +507,7 @@ case {{ UpperFirst(Component.attrib['Name']) }}Internal::RemoteProcedure::{{ Upp
|
||||
{% endif %}
|
||||
}
|
||||
{% else %}
|
||||
Handle{{ UpperFirst(Property.attrib['Name']) }}({{ ', '.join(rpcParamList) }});
|
||||
Handle{{ UpperFirst(Property.attrib['Name']) }}(invokingConnection, {{ ', '.join(rpcParamList) }});
|
||||
{% endif %}
|
||||
}
|
||||
else if (paramsSerialized)
|
||||
@@ -712,11 +712,7 @@ void {{ ClassName }}::NotifyChanges{{ AutoComponentMacros.GetNetPropertiesSetNam
|
||||
{% macro DefineArchetypePropertyGet(Property, ClassType, ClassName, Prefix = '') %}
|
||||
{% if ClassType == '' or Property.attrib['ExportTo'] == ClassType or Property.attrib['ExportTo'] == "Common" %}
|
||||
{% if Property.attrib['Container'] == 'Array' %}
|
||||
{% if Property.attrib['IsRewindable']|booleanTrue %}
|
||||
const RewindableArray<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Array() const
|
||||
{% else %}
|
||||
const AZStd::array<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Array() const
|
||||
{% endif %}
|
||||
{
|
||||
return {{ Prefix }}m_{{ LowerFirst(Property.attrib['Name']) }};
|
||||
}
|
||||
@@ -727,11 +723,7 @@ const {{ Property.attrib['Type'] }}& {{ ClassName }}::Get{{ UpperFirst(Property.
|
||||
}
|
||||
|
||||
{% elif Property.attrib['Container'] == 'Vector' %}
|
||||
{% if Property.attrib['IsRewindable']|booleanTrue %}
|
||||
const RewindableFixedVector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Vector() const
|
||||
{% else %}
|
||||
const AZStd::fixed_vector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Vector() const
|
||||
{% endif %}
|
||||
{
|
||||
return {{ Prefix }}m_{{ LowerFirst(Property.attrib['Name']) }};
|
||||
}
|
||||
|
||||
@@ -18,9 +18,4 @@
|
||||
<NetworkProperty Type="uint8_t" Name="resetCount" Init="0" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="false" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" ExposeToScript="false" GenerateEventBindings="true" />
|
||||
<NetworkProperty Type="NetEntityId" Name="parentEntityId" Init="InvalidNetEntityId" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" ExposeToScript="false" GenerateEventBindings="true" />
|
||||
<NetworkProperty Type="int32_t" Name="parentAttachmentBoneId" Init="-1" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" ExposeToScript="false" GenerateEventBindings="true" />
|
||||
|
||||
<!--
|
||||
<ArchetypeProperty Type="bool" Name="snapToGround" Init="false" ExposeToEditor="true" />
|
||||
<ArchetypeProperty Type="bool" Name="useGroundNormal" Init="false" ExposeToEditor="true" />
|
||||
-->
|
||||
</Component>
|
||||
|
||||
@@ -91,7 +91,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -849,12 +849,10 @@ namespace Multiplayer
|
||||
|
||||
void MultiplayerSystemComponent::TickVisibleNetworkEntities(float deltaTime, float serverRateSeconds)
|
||||
{
|
||||
const float targetAdjustBlend = AZStd::clamp(deltaTime / serverRateSeconds, 0.0f, 1.0f);
|
||||
m_renderBlendFactor += targetAdjustBlend;
|
||||
|
||||
// Linear close to the origin, but asymptote at y = 1
|
||||
const float adjustedBlendFactor = 1.0f - (std::pow(0.2f, m_renderBlendFactor));
|
||||
AZLOG(NET_Blending, "Computed blend factor of %f", adjustedBlendFactor);
|
||||
const float targetAdjustBlend = AZStd::clamp(deltaTime / serverRateSeconds, 0.0f, 1.0f);
|
||||
m_renderBlendFactor = 1.0f - (std::pow(0.2f, m_renderBlendFactor + targetAdjustBlend));
|
||||
AZLOG(NET_Blending, "Computed blend factor of %0.2f using a frametime of %0.2f and a serverTickRate of %0.2f", m_renderBlendFactor, deltaTime, serverRateSeconds);
|
||||
|
||||
if (Camera::ActiveCameraRequestBus::HasHandlers())
|
||||
{
|
||||
@@ -897,7 +895,7 @@ namespace Multiplayer
|
||||
|
||||
for (NetBindComponent* netBindComponent : gatheredEntities)
|
||||
{
|
||||
netBindComponent->NotifyPreRender(deltaTime, adjustedBlendFactor);
|
||||
netBindComponent->NotifyPreRender(deltaTime, m_renderBlendFactor);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -909,7 +907,7 @@ namespace Multiplayer
|
||||
NetBindComponent* netBindComponent = entity->FindComponent<NetBindComponent>();
|
||||
if (netBindComponent != nullptr)
|
||||
{
|
||||
netBindComponent->NotifyPreRender(deltaTime, adjustedBlendFactor);
|
||||
netBindComponent->NotifyPreRender(deltaTime, m_renderBlendFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user