From bd5226aac56a6ffe8e05c028e775945e6f591606 Mon Sep 17 00:00:00 2001 From: kberg-amzn Date: Wed, 7 Jul 2021 10:41:44 -0700 Subject: [PATCH 01/33] Changes to fix rewindable attributes incorrectly used on read-only archetype data, fix some bad logic in the pre-render blending code, adding a serializer for AZ::Transform, and adding our client.cfg and server.cfg files to .gitignore Signed-off-by: kberg-amzn --- .gitignore | 2 ++ .../Serialization/AzContainerSerializers.h | 18 ++++++++++++++++++ .../Source/AutoGen/AutoComponent_Header.jinja | 18 +++++++++--------- .../Source/AutoGen/AutoComponent_Source.jinja | 10 +--------- ...NetworkTransformComponent.AutoComponent.xml | 5 ----- .../Code/Source/MultiplayerSystemComponent.cpp | 12 +++++------- 6 files changed, 35 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 664680c5bf..654b839155 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ UserSettings.xml FrameCapture/** .DS_Store user*.cfg +client*.cfg +server*.cfg .mayaSwatches/ _savebackup/ #Output folder for test results when running Automated Tests diff --git a/Code/Framework/AzNetworking/AzNetworking/Serialization/AzContainerSerializers.h b/Code/Framework/AzNetworking/AzNetworking/Serialization/AzContainerSerializers.h index 25b1543b1f..107d0068fb 100644 --- a/Code/Framework/AzNetworking/AzNetworking/Serialization/AzContainerSerializers.h +++ b/Code/Framework/AzNetworking/AzNetworking/Serialization/AzContainerSerializers.h @@ -302,4 +302,22 @@ namespace AzNetworking return serializer.IsValid(); } }; + + template <> + struct SerializeObjectHelper + { + 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(); + } + }; } diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja index 79fbb4a99e..4fe2f6291c 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja @@ -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::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::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) -}} diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja index c34c639cd9..f1c7098c19 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja @@ -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']) }}; } diff --git a/Gems/Multiplayer/Code/Source/AutoGen/NetworkTransformComponent.AutoComponent.xml b/Gems/Multiplayer/Code/Source/AutoGen/NetworkTransformComponent.AutoComponent.xml index 8abc874aa6..cec005cc26 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/NetworkTransformComponent.AutoComponent.xml +++ b/Gems/Multiplayer/Code/Source/AutoGen/NetworkTransformComponent.AutoComponent.xml @@ -18,9 +18,4 @@ - - diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index 012eca1e89..93f655af0c 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -847,12 +847,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()) { @@ -895,7 +893,7 @@ namespace Multiplayer for (NetBindComponent* netBindComponent : gatheredEntities) { - netBindComponent->NotifyPreRender(deltaTime, adjustedBlendFactor); + netBindComponent->NotifyPreRender(deltaTime, m_renderBlendFactor); } } else @@ -907,7 +905,7 @@ namespace Multiplayer NetBindComponent* netBindComponent = entity->FindComponent(); if (netBindComponent != nullptr) { - netBindComponent->NotifyPreRender(deltaTime, adjustedBlendFactor); + netBindComponent->NotifyPreRender(deltaTime, m_renderBlendFactor); } } } From 9c1d66f61fc0050d02698b4ec2d9eec881745aa4 Mon Sep 17 00:00:00 2001 From: greerdv Date: Thu, 15 Jul 2021 13:07:34 +0100 Subject: [PATCH 02/33] improve translations for physics types in Script Canvas Signed-off-by: greerdv --- .../Editor/Translation/scriptcanvas_en_us.ts | 447 +++++++++++++----- .../Physics/Common/PhysicsSceneQueries.cpp | 34 +- .../AzFramework/Physics/PhysicsSystem.cpp | 5 +- 3 files changed, 355 insertions(+), 131 deletions(-) diff --git a/Assets/Editor/Translation/scriptcanvas_en_us.ts b/Assets/Editor/Translation/scriptcanvas_en_us.ts index 5cafabaf60..f057ba2f30 100644 --- a/Assets/Editor/Translation/scriptcanvas_en_us.ts +++ b/Assets/Editor/Translation/scriptcanvas_en_us.ts @@ -42001,245 +42001,255 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro WORLD_RAYCASTMULTIPLELOCALSPACE_OUTPUT0_NAME Hits - - WORLD_OVERLAPSPHERE_NAME + + WORLD_OVERLAPSPHEREWITHGROUP_NAME Overlap Sphere - - WORLD_OVERLAPSPHERE_PARAM0_NAME + + WORLD_OVERLAPSPHEREWITHGROUP_PARAM0_NAME Position - - WORLD_OVERLAPSPHERE_PARAM1_NAME + + WORLD_OVERLAPSPHEREWITHGROUP_PARAM1_NAME Radius - - WORLD_OVERLAPSPHERE_PARAM2_NAME + + WORLD_OVERLAPSPHEREWITHGROUP_PARAM2_NAME Collision Group - - WORLD_OVERLAPSPHERE_PARAM3_NAME + + WORLD_OVERLAPSPHEREWITHGROUP_PARAM3_NAME Ignore - - WORLD_OVERLAPSPHERE_OUTPUT0_NAME + + WORLD_OVERLAPSPHEREWITHGROUP_OUTPUT0_NAME Is Overlapping - - WORLD_OVERLAPSPHERE_OUTPUT1_NAME + + WORLD_OVERLAPSPHEREWITHGROUP_OUTPUT1_NAME Overlaps - - WORLD_OVERLAPBOX_NAME + + WORLD_OVERLAPBOXWITHGROUP_NAME Overlap Box - - WORLD_OVERLAPBOX_PARAM0_NAME + + WORLD_OVERLAPBOXWITHGROUP_PARAM0_NAME Pose - - WORLD_OVERLAPBOX_PARAM1_NAME + + WORLD_OVERLAPBOXWITHGROUP_PARAM1_NAME Dimensions - - WORLD_OVERLAPBOX_PARAM2_NAME + + WORLD_OVERLAPBOXWITHGROUP_PARAM2_NAME Collision Group - - WORLD_OVERLAPBOX_PARAM3_NAME + + WORLD_OVERLAPBOXWITHGROUP_PARAM3_NAME Ignore - - WORLD_OVERLAPBOX_OUTPUT0_NAME + + WORLD_OVERLAPBOXWITHGROUP_OUTPUT0_NAME Is Overlapping - - WORLD_OVERLAPBOX_OUTPUT1_NAME + + WORLD_OVERLAPBOXWITHGROUP_OUTPUT1_NAME Overlaps - - WORLD_OVERLAPCAPSULE_NAME + + WORLD_OVERLAPCAPSULEWITHGROUP_NAME Overlap Capsule - - WORLD_OVERLAPCAPSULE_PARAM0_NAME + + WORLD_OVERLAPCAPSULEWITHGROUP_PARAM0_NAME Pose - - WORLD_OVERLAPCAPSULE_PARAM1_NAME + + WORLD_OVERLAPCAPSULEWITHGROUP_PARAM1_NAME Height - - WORLD_OVERLAPCAPSULE_PARAM2_NAME + + WORLD_OVERLAPCAPSULEWITHGROUP_PARAM2_NAME Radius - - WORLD_OVERLAPCAPSULE_PARAM3_NAME + + WORLD_OVERLAPCAPSULEWITHGROUP_PARAM3_NAME Collision Group - - WORLD_OVERLAPCAPSULE_PARAM4_NAME + + WORLD_OVERLAPCAPSULEWITHGROUP_PARAM4_NAME Ignore - - WORLD_OVERLAPCAPSULE_OUTPUT0_NAME + + WORLD_OVERLAPCAPSULEWITHGROUP_OUTPUT0_NAME Is Overlapping - - WORLD_OVERLAPCAPSULE_OUTPUT1_NAME + + WORLD_OVERLAPCAPSULEWITHGROUP_OUTPUT1_NAME Overlaps - - - - WORLD_SPHERECAST_NAME + + + WORLD_SPHERECASTWITHGROUP_NAME Sphere Cast - - WORLD_SPHERECAST_PARAM0_NAME + + WORLD_SPHERECASTWITHGROUP_PARAM0_NAME Distance - - WORLD_SPHERECAST_PARAM1_NAME + + WORLD_SPHERECASTWITHGROUP_PARAM1_NAME Start Pose - - WORLD_SPHERECAST_PARAM2_NAME + + WORLD_SPHERECASTWITHGROUP_PARAM2_NAME Direction - - WORLD_SPHERECAST_PARAM3_NAME + + WORLD_SPHERECASTWITHGROUP_PARAM3_NAME Radius - - WORLD_SPHERECAST_PARAM4_NAME + + WORLD_SPHERECASTWITHGROUP_PARAM4_NAME Collision Group - - WORLD_SPHERECAST_PARAM5_NAME + + WORLD_SPHERECASTWITHGROUP_PARAM5_NAME Ignore - - WORLD_SPHERECAST_OUTPUT0_NAME + + WORLD_SPHERECASTWITHGROUP_OUTPUT0_NAME Object Hit - - WORLD_SPHERECAST_OUTPUT1_NAME + + WORLD_SPHERECASTWITHGROUP_OUTPUT1_NAME Position - - WORLD_SPHERECAST_OUTPUT2_NAME + + WORLD_SPHERECASTWITHGROUP_OUTPUT2_NAME Normal - - WORLD_SPHERECAST_OUTPUT3_NAME + + WORLD_SPHERECASTWITHGROUP_OUTPUT3_NAME Distance - - WORLD_SPHERECAST_OUTPUT4_NAME + + WORLD_SPHERECASTWITHGROUP_OUTPUT4_NAME EntityId - - - WORLD_BOXCAST_NAME + + WORLD_BOXCASTWITHGROUP_NAME Box Cast - - WORLD_BOXCAST_PARAM0_NAME + + WORLD_BOXCASTWITHGROUP_PARAM0_NAME Distance - - WORLD_BOXCAST_PARAM1_NAME + + WORLD_BOXCASTWITHGROUP_PARAM1_NAME Start Pose - - WORLD_BOXCAST_PARAM2_NAME + + WORLD_BOXCASTWITHGROUP_PARAM2_NAME Direction - - WORLD_BOXCAST_PARAM3_NAME + + WORLD_BOXCASTWITHGROUP_PARAM3_NAME Dimensions - - WORLD_BOXCAST_PARAM4_NAME + + WORLD_BOXCASTWITHGROUP_PARAM4_NAME Collision Group - - WORLD_BOXCAST_PARAM5_NAME + + WORLD_BOXCASTWITHGROUP_PARAM5_NAME Ignore - - WORLD_BOXCAST_OUTPUT0_NAME + + WORLD_BOXCASTWITHGROUP_OUTPUT0_NAME Object Hit - - WORLD_BOXCAST_OUTPUT1_NAME + + WORLD_BOXCASTWITHGROUP_OUTPUT1_NAME Position - - WORLD_BOXCAST_OUTPUT2_NAME + + WORLD_BOXCASTWITHGROUP_OUTPUT2_NAME Normal - - WORLD_BOXCAST_OUTPUT3_NAME + + WORLD_BOXCASTWITHGROUP_OUTPUT3_NAME Distance - - WORLD_BOXCAST_OUTPUT4_NAME + + WORLD_BOXCASTWITHGROUP_OUTPUT4_NAME EntityId - - - WORLD_CAPSULECAST_NAME + + WORLD_CAPSULECASTWITHGROUP_NAME Capsule Cast - - WORLD_CAPSULECAST_PARAM0_NAME + + WORLD_CAPSULECASTWITHGROUP_PARAM0_NAME Distance - - WORLD_CAPSULECAST_PARAM1_NAME + + WORLD_CAPSULECASTWITHGROUP_PARAM1_NAME Start Pose - - WORLD_CAPSULECAST_PARAM2_NAME + + WORLD_CAPSULECASTWITHGROUP_PARAM2_NAME Direction - - WORLD_CAPSULECAST_PARAM3_NAME + + WORLD_CAPSULECASTWITHGROUP_PARAM3_NAME Height - - WORLD_CAPSULECAST_PARAM4_NAME + + WORLD_CAPSULECASTWITHGROUP_PARAM4_NAME Radius - - WORLD_CAPSULECAST_PARAM5_NAME + + WORLD_CAPSULECASTWITHGROUP_PARAM5_NAME Collision Group - - WORLD_CAPSULECAST_PARAM6_NAME + + WORLD_CAPSULECASTWITHGROUP_PARAM6_NAME Ignore - - WORLD_CAPSULECAST_OUTPUT0_NAME + + WORLD_CAPSULECASTWITHGROUP_OUTPUT0_NAME Object Hit - - WORLD_CAPSULECAST_OUTPUT1_NAME + + WORLD_CAPSULECASTWITHGROUP_OUTPUT1_NAME + WORLD_CAPSULECASTWITHGROUP_OUTPUT1_NAME Position - - WORLD_BOXCAST_OUTPUT2_NAME + + WORLD_CAPSULECASTWITHGROUP_OUTPUT2_NAME Normal - - WORLD_CAPSULECAST_OUTPUT3_NAME + + WORLD_CAPSULECASTWITHGROUP_OUTPUT3_NAME Distance - - WORLD_CAPSULECAST_OUTPUT4_NAME + + WORLD_CAPSULECASTWITHGROUP_OUTPUT4_NAME EntityId + + WORLD_RAYCASTLOCALSPACEWITHGROUP_NAME + Raycast (Local Space) + + + WORLD_RAYCASTMULTIPLELOCALSPACEWITHGROUP_NAME + Raycast Multiple (Local Space) + + + WORLD_RAYCASTWORLDSPACEWITHGROUP_NAME + Raycast (World Space) + EBus: CollisionFilteringBus @@ -42368,7 +42378,7 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro EBus: RigidBodyRequestBus RIGIDBODYREQUESTBUS_NAME - RigidBody + Rigid Body RIGIDBODYREQUESTBUS_TOOLTIP @@ -42413,6 +42423,23 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro RIGIDBODYREQUESTBUS_ISPHYSICSENABLED_OUTPUT0_TOOLTIP Indicates whether physics is enabled + + RIGIDBODYREQUESTBUS_ISGRAVITYENABLED_NAME + Class/Bus: RigidBodyRequestBus Event/Method: IsGravityEnabled + Is Gravity Enabled + + + RIGIDBODYREQUESTBUS_ISGRAVITYENABLED_TOOLTIP + Returns true if the rigid body has gravity enabled + + + RIGIDBODYREQUESTBUS_ISGRAVITYENABLED_OUTPUT0_NAME + Enabled + + + RIGIDBODYREQUESTBUS_ISGRAVITYENABLED_OUTPUT0_TOOLTIP + Indicates whether gravity is enabled + RIGIDBODYREQUESTBUS_GETCENTEROFMASSWORLD_NAME Class/Bus: RigidBodyRequestBus Event/Method: GetCenterOfMassWorld @@ -42915,7 +42942,50 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro RIGIDBODYREQUESTBUS_GETAABB_OUTPUT0_TOOLTIP The aabb of the rigid body - + + + Method: SceneQueries + + SCENEQUERIES_NAME + Scene Queries + + + SCENEQUERIES_CREATERAYCASTREQUEST_NAME + Create Raycast Request + + + SCENEQUERIES_CREATERAYCASTREQUEST_PARAM0_NAME + Start + + + SCENEQUERIES_CREATERAYCASTREQUEST_PARAM0_TOOLTIP + The position from which the raycast starts + + + SCENEQUERIES_CREATERAYCASTREQUEST_PARAM1_NAME + Direction + + + SCENEQUERIES_CREATERAYCASTREQUEST_PARAM1_TOOLTIP + The (normalized) direction in which to fire the raycast + + + SCENEQUERIES_CREATERAYCASTREQUEST_PARAM2_NAME + Distance + + + SCENEQUERIES_CREATERAYCASTREQUEST_PARAM2_TOOLTIP + The length of the raycast + + + SCENEQUERIES_CREATERAYCASTREQUEST_PARAM3_NAME + Collision Group + + + SCENEQUERIES_CREATERAYCASTREQUEST_PARAM3_TOOLTIP + Allows filtering of objects intersecting the raycast based on their collision layers + + Handler: TriggerNotificationBus @@ -43199,12 +43269,12 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro PHYSXCHARACTERCONTROLLERREQUESTBUS_NAME Character Controller (PhysX Specific) - - CHARACTERCONTROLLERREQUESTBUS_TOOLTIP + + PHYSXCHARACTERCONTROLLERREQUESTBUS_TOOLTIP PhysX Character Controller Request Bus - - CHARACTERCONTROLLERREQUESTBUS_CATEGORY + + PHYSXCHARACTERCONTROLLERREQUESTBUS_CATEGORY PhysX @@ -44616,6 +44686,96 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro + + EBus: SimulatedBodyComponentRequestBus + + SIMULATEDBODYCOMPONENTREQUESTBUS_NAME + Simulated Body + + + SIMULATEDBODYCOMPONENTREQUESTBUS_TOOLTIP + Simulated Body Component Request Bus + + + SIMULATEDBODYCOMPONENTREQUESTBUS_CATEGORY + PhysX + + + SIMULATEDBODYCOMPONENTREQUESTBUS_DISABLEPHYSICS_NAME + Disable Physics + + + SIMULATEDBODYCOMPONENTREQUESTBUS_ENABLEPHYSICS_NAME + Enable Physics + + + SIMULATEDBODYCOMPONENTREQUESTBUS_GETAABB_NAME + Get AABB + + + SIMULATEDBODYCOMPONENTREQUESTBUS_ISPHYSICSENABLED_NAME + Is Physics Enabled + + + SIMULATEDBODYCOMPONENTREQUESTBUS_RAYCAST_NAME + Raycast (Single Body) + + + SIMULATEDBODYCOMPONENTREQUESTBUS_RAYCAST_TOOLTIP + Perform a raycast against a single simulated body (not the whole scene) + + + SIMULATEDBODYCOMPONENTREQUESTBUS_RAYCAST_PARAM0_NAME + Raycast Request + + + + EBus: WindRequestsBus + + WINDREQUESTSBUS_NAME + Wind + + + WINDREQUESTSBUS_TOOLTIP + Wind Request Bus + + + WINDREQUESTSBUS_CATEGORY + PhysX + + + WINDREQUESTSBUS_GETGLOBALWIND_NAME + Get Global Wind + + + WINDREQUESTSBUS_GETGLOBALWIND_OUTPUT0_NAME + Wind Vector + + + WINDREQUESTSBUS_GETWINDATPOSITION_NAME + Get Wind At Position + + + WINDREQUESTSBUS_GETWINDATPOSITION_PARAM0_NAME + Position + + + WINDREQUESTSBUS_GETWINDATPOSITION_OUTPUT0_NAME + Wind Vector + + + WINDREQUESTSBUS_GETWINDINSIDEAABB_NAME + Get Wind Inside AABB + + + WINDREQUESTSBUS_GETWINDINSIDEAABB_PARAM0_NAME + AABB + + + WINDREQUESTSBUS_GETWINDINSIDEAABB_OUTPUT0_NAME + Wind Vector + + EBus: ChatPlayRequestBus @@ -62374,6 +62534,37 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro + + EBus: NonUniformScaleRequestBus + + NONUNIFORMSCALEREQUESTBUS_NAME + Non-uniform Scale + + + NONUNIFORMSCALEREQUESTBUS_TOOLTIP + Non-uniform Scale Request Bus + + + NONUNIFORMSCALEREQUESTBUS_CATEGORY + Entity + + + NONUNIFORMSCALEREQUESTBUS_GETSCALE_NAME + Get Scale + + + NONUNIFORMSCALEREQUESTBUS_GETSCALE_OUTPUT0_NAME + Non-uniform Scale + + + NONUNIFORMSCALEREQUESTBUS_SETSCALE_NAME + Set Scale + + + NONUNIFORMSCALEREQUESTBUS_SETSCALE_PARAM0_NAME + Non-uniform Scale + + EBus: TransformBus diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsSceneQueries.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsSceneQueries.cpp index 02597123db..bf5c191bef 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsSceneQueries.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsSceneQueries.cpp @@ -66,6 +66,17 @@ namespace AzPhysics } } + // class for exposing free functions to script + class SceneQueries + { + public: + AZ_TYPE_INFO(SceneQueries, "{4EFA3DA5-C0E3-4753-8C55-202228CA527E}"); + AZ_CLASS_ALLOCATOR(SceneQueries, AZ::SystemAllocator, 0); + + SceneQueries() = default; + ~SceneQueries() = default; + }; + /*static*/ void SceneQueryRequest::Reflect(AZ::ReflectContext* context) { if (auto* serializeContext = azdynamic_cast(context)) @@ -95,6 +106,7 @@ namespace AzPhysics ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Module, "physics") ->Attribute(AZ::Script::Attributes::Category, "PhysX") + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) ->Property("Collision", BehaviorValueProperty(&SceneQueryRequest::m_collisionGroup)) // Until enum class support for behavior context is done, expose this as an int ->Property("QueryType", [](const SceneQueryRequest& self) { return static_cast(self.m_queryType); }, @@ -133,11 +145,28 @@ namespace AzPhysics ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Module, "physics") ->Attribute(AZ::Script::Attributes::Category, "PhysX") + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) ->Property("Distance", BehaviorValueProperty(&RayCastRequest::m_distance)) ->Property("Start", BehaviorValueProperty(&RayCastRequest::m_start)) ->Property("Direction", BehaviorValueProperty(&RayCastRequest::m_direction)) ->Property("ReportMultipleHits", BehaviorValueProperty(&RayCastRequest::m_reportMultipleHits)) ; + + behaviorContext->Class("SceneQueries") + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Module, "physics") + ->Attribute(AZ::Script::Attributes::Category, "PhysX") + ->Method( + "CreateRayCastRequest", + [](const AZ::Vector3& start, const AZ::Vector3& direction, float distance, const AZStd::string& collisionGroup) + { + RayCastRequest request; + request.m_start = start; + request.m_direction = direction; + request.m_distance = distance; + request.m_collisionGroup = CollisionGroup(collisionGroup); + return request; + }); } } @@ -161,6 +190,7 @@ namespace AzPhysics ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Module, "physics") ->Attribute(AZ::Script::Attributes::Category, "PhysX") + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) ->Property("Distance", BehaviorValueProperty(&ShapeCastRequest::m_distance)) ->Property("Start", BehaviorValueProperty(&ShapeCastRequest::m_start)) ->Property("Direction", BehaviorValueProperty(&ShapeCastRequest::m_direction)) @@ -174,7 +204,6 @@ namespace AzPhysics return ShapeCastRequestHelpers::CreateSphereCastRequest( radius, startPose, direction, distance, queryType, collisionGroup, nullptr); }); - behaviorContext->Method( "CreateBoxCastRequest", [](const AZ::Vector3& boxDimensions, const AZ::Transform& startPose, const AZ::Vector3& direction, float distance, @@ -183,7 +212,6 @@ namespace AzPhysics return ShapeCastRequestHelpers::CreateBoxCastRequest( boxDimensions, startPose, direction, distance, queryType, collisionGroup, nullptr); }); - behaviorContext->Method( "CreateCapsuleCastRequest", [](float capsuleRadius, float capsuleHeight, const AZ::Transform& startPose, const AZ::Vector3& direction, float distance, @@ -266,6 +294,7 @@ namespace AzPhysics ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Module, "physics") ->Attribute(AZ::Script::Attributes::Category, "PhysX") + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) ->Property("Pose", BehaviorValueProperty(&OverlapRequest::m_pose)) ; @@ -348,6 +377,7 @@ namespace AzPhysics ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Module, "physics") ->Attribute(AZ::Script::Attributes::Category, "PhysX") + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) ->Property("Distance", BehaviorValueProperty(&SceneQueryHit::m_distance)) ->Property("Position", BehaviorValueProperty(&SceneQueryHit::m_position)) ->Property("Normal", BehaviorValueProperty(&SceneQueryHit::m_normal)) diff --git a/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp b/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp index 06f1802cc9..6299359b3f 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp @@ -50,7 +50,10 @@ namespace AzPhysics ->Method("GetOnPostsimulateEvent", getOnPostsimulateEvent) ->Attribute(AZ::Script::Attributes::AzEventDescription, postsimulateEventDescription) ->Method("GetSceneHandle", &SystemInterface::GetSceneHandle) - ->Method("GetScene", &SystemInterface::GetScene); + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + ->Method("GetScene", &SystemInterface::GetScene) + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + ; behaviorContext->Method( "GetPhysicsSystem", From 23a4835e4814640fe68dc8f310620e5f0c09a359 Mon Sep 17 00:00:00 2001 From: kberg-amzn Date: Mon, 19 Jul 2021 12:03:57 -0700 Subject: [PATCH 03/33] Desync debug work Signed-off-by: kberg-amzn --- .../Serialization/HashSerializer.cpp | 19 +++++++++++-------- .../Components/NetworkTransformComponent.cpp | 6 +++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Code/Framework/AzNetworking/AzNetworking/Serialization/HashSerializer.cpp b/Code/Framework/AzNetworking/AzNetworking/Serialization/HashSerializer.cpp index 187dfcdfd0..07cc5f3588 100644 --- a/Code/Framework/AzNetworking/AzNetworking/Serialization/HashSerializer.cpp +++ b/Code/Framework/AzNetworking/AzNetworking/Serialization/HashSerializer.cpp @@ -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; } diff --git a/Gems/Multiplayer/Code/Source/Components/NetworkTransformComponent.cpp b/Gems/Multiplayer/Code/Source/Components/NetworkTransformComponent.cpp index e956245724..142d66febb 100644 --- a/Gems/Multiplayer/Code/Source/Components/NetworkTransformComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Components/NetworkTransformComponent.cpp @@ -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); + } } } From 2b89d9d563d584d46e9a13f4898243557f21fa3f Mon Sep 17 00:00:00 2001 From: Benjamin Jillich Date: Tue, 20 Jul 2021 16:25:42 +0200 Subject: [PATCH 04/33] MikkT generator fills given tangent data rather than creating a new scene node Signed-off-by: Benjamin Jillich --- .../TangentGenerators/MikkTGenerator.cpp | 36 ++++--------------- .../TangentGenerators/MikkTGenerator.h | 14 ++++---- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/Gems/SceneProcessing/Code/Source/Generation/Components/TangentGenerator/TangentGenerators/MikkTGenerator.cpp b/Gems/SceneProcessing/Code/Source/Generation/Components/TangentGenerator/TangentGenerators/MikkTGenerator.cpp index a6191e3b36..3f736815e5 100644 --- a/Gems/SceneProcessing/Code/Source/Generation/Components/TangentGenerator/TangentGenerators/MikkTGenerator.cpp +++ b/Gems/SceneProcessing/Code/Source/Generation/Components/TangentGenerator/TangentGenerators/MikkTGenerator.cpp @@ -32,7 +32,6 @@ namespace AZ::TangentGeneration::Mesh::MikkT return customData->m_meshData->GetFaceCount(); } - int GetNumVerticesOfFace(const SMikkTSpaceContext* context, const int face) { AZ_UNUSED(context); @@ -40,7 +39,6 @@ namespace AZ::TangentGeneration::Mesh::MikkT return 3; } - void GetPosition(const SMikkTSpaceContext* context, float posOut[], const int face, const int vert) { MikktCustomData* customData = static_cast(context->m_pUserData); @@ -51,7 +49,6 @@ namespace AZ::TangentGeneration::Mesh::MikkT posOut[2] = pos.GetZ(); } - void GetNormal(const SMikkTSpaceContext* context, float normOut[], const int face, const int vert) { MikktCustomData* customData = static_cast(context->m_pUserData); @@ -62,7 +59,6 @@ namespace AZ::TangentGeneration::Mesh::MikkT normOut[2] = normal.GetZ(); } - void GetTexCoord(const SMikkTSpaceContext* context, float texOut[], const int face, const int vert) { MikktCustomData* customData = static_cast(context->m_pUserData); @@ -72,7 +68,6 @@ namespace AZ::TangentGeneration::Mesh::MikkT texOut[1] = uv.GetY(); } - // This function is used to return the tangent and signValue to the application. // tangent is a unit length vector. // For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level. @@ -91,7 +86,6 @@ namespace AZ::TangentGeneration::Mesh::MikkT customData->m_bitangentData->SetBitangent(vertexIndex, bitangent); } - // This function is used to return tangent space results to the application. // tangent and bitangent are unit length vectors and magS and magT are their // true magnitudes which can be used for relief mapping effects. @@ -111,27 +105,11 @@ namespace AZ::TangentGeneration::Mesh::MikkT customData->m_bitangentData->SetBitangent(vertexIndex, bitangentVec); } - - bool GenerateTangents(AZ::SceneAPI::Containers::SceneManifest& manifest, AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::SceneAPI::DataTypes::IMeshData* meshData, size_t uvSet) + bool GenerateTangents(const AZ::SceneAPI::DataTypes::IMeshData* meshData, + const AZ::SceneAPI::DataTypes::IMeshVertexUVData* uvData, + AZ::SceneAPI::DataTypes::IMeshVertexTangentData* outTangentData, + AZ::SceneAPI::DataTypes::IMeshVertexBitangentData* outBitangentData) { - // Create tangent and bitangent data sets and relate them to the given UV set. - AZ::SceneAPI::DataTypes::IMeshVertexUVData* uvData = AZ::SceneAPI::SceneData::TangentsRule::FindUVData(graph, nodeIndex, uvSet); - AZ::SceneAPI::DataTypes::IMeshVertexTangentData* tangentData = nullptr; - AZ::SceneAPI::DataTypes::IMeshVertexBitangentData* bitangentData = nullptr; - if (!uvData) - { - AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Cannot find UV data (set index=%d) to generate tangents and bitangents from in MikkT generator!\n", uvSet); - return false; - } - - if (!AZ::SceneGenerationComponents::TangentGenerateComponent::CreateTangentBitangentLayers(manifest, nodeIndex, meshData->GetVertexCount(), uvSet, AZ::SceneAPI::DataTypes::TangentSpace::MikkT, "MikkT", graph, &tangentData, &bitangentData)) - { - AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Failed to create tangents and bitangents data sets inside MikkT generator!\n"); - return false; - } - - //---------------------------------- - // Provide the MikkT interface. SMikkTSpaceInterface mikkInterface; mikkInterface.m_getNumFaces = GetNumFaces; @@ -146,8 +124,8 @@ namespace AZ::TangentGeneration::Mesh::MikkT MikktCustomData customData; customData.m_meshData = meshData; customData.m_uvData = uvData; - customData.m_tangentData = tangentData; - customData.m_bitangentData = bitangentData; + customData.m_tangentData = outTangentData; + customData.m_bitangentData = outBitangentData; // Generate the tangents. SMikkTSpaceContext mikkContext; @@ -155,7 +133,7 @@ namespace AZ::TangentGeneration::Mesh::MikkT mikkContext.m_pUserData = &customData; if (genTangSpaceDefault(&mikkContext) == 0) { - AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Failed to generate tangents and bitangents using MikkT, because MikkT reported failure!\n"); + AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Failed to generate tangents and bitangents using MikkT.\n"); return false; } diff --git a/Gems/SceneProcessing/Code/Source/Generation/Components/TangentGenerator/TangentGenerators/MikkTGenerator.h b/Gems/SceneProcessing/Code/Source/Generation/Components/TangentGenerator/TangentGenerators/MikkTGenerator.h index 98451d3c46..4b1d8ebd72 100644 --- a/Gems/SceneProcessing/Code/Source/Generation/Components/TangentGenerator/TangentGenerators/MikkTGenerator.h +++ b/Gems/SceneProcessing/Code/Source/Generation/Components/TangentGenerator/TangentGenerators/MikkTGenerator.h @@ -19,12 +19,14 @@ namespace AZ::TangentGeneration::Mesh::MikkT { struct MikktCustomData { - AZ::SceneAPI::DataTypes::IMeshData* m_meshData; - AZ::SceneAPI::DataTypes::IMeshVertexUVData* m_uvData; - AZ::SceneAPI::DataTypes::IMeshVertexTangentData* m_tangentData; - AZ::SceneAPI::DataTypes::IMeshVertexBitangentData* m_bitangentData; + const AZ::SceneAPI::DataTypes::IMeshData* m_meshData; + const AZ::SceneAPI::DataTypes::IMeshVertexUVData* m_uvData; + AZ::SceneAPI::DataTypes::IMeshVertexTangentData* m_tangentData; + AZ::SceneAPI::DataTypes::IMeshVertexBitangentData* m_bitangentData; }; - // The main generation method. - bool GenerateTangents(AZ::SceneAPI::Containers::SceneManifest& manifest, AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::SceneAPI::DataTypes::IMeshData* meshData, size_t uvSet); + bool GenerateTangents(const AZ::SceneAPI::DataTypes::IMeshData* meshData, + const AZ::SceneAPI::DataTypes::IMeshVertexUVData* uvData, + AZ::SceneAPI::DataTypes::IMeshVertexTangentData* outTangentData, + AZ::SceneAPI::DataTypes::IMeshVertexBitangentData* outBitangentData); } // namespace AZ::TangentGeneration::MikkT From 424ee5d5e8738a3aad19e897f8239110851da230 Mon Sep 17 00:00:00 2001 From: Benjamin Jillich Date: Tue, 20 Jul 2021 16:26:38 +0200 Subject: [PATCH 05/33] Removed emfx legacy tangent generation settings from tangents rule Signed-off-by: Benjamin Jillich --- .../SceneAPI/SceneData/Rules/TangentsRule.cpp | 117 +----------------- .../SceneAPI/SceneData/Rules/TangentsRule.h | 15 +-- 2 files changed, 3 insertions(+), 129 deletions(-) diff --git a/Code/Tools/SceneAPI/SceneData/Rules/TangentsRule.cpp b/Code/Tools/SceneAPI/SceneData/Rules/TangentsRule.cpp index 0bea5863bf..7b4be1dfdf 100644 --- a/Code/Tools/SceneAPI/SceneData/Rules/TangentsRule.cpp +++ b/Code/Tools/SceneAPI/SceneData/Rules/TangentsRule.cpp @@ -27,114 +27,14 @@ namespace AZ TangentsRule::TangentsRule() : DataTypes::IRule() , m_tangentSpace(AZ::SceneAPI::DataTypes::TangentSpace::MikkT) - , m_bitangentMethod(AZ::SceneAPI::DataTypes::BitangentMethod::Orthogonal) - , m_uvSetIndex(0) - , m_normalize(true) { } - AZ::SceneAPI::DataTypes::TangentSpace TangentsRule::GetTangentSpace() const { return m_tangentSpace; } - - AZ::SceneAPI::DataTypes::BitangentMethod TangentsRule::GetBitangentMethod() const - { - return m_bitangentMethod; - } - - - AZ::u64 TangentsRule::GetUVSetIndex() const - { - return m_uvSetIndex; - } - - - bool TangentsRule::GetNormalizeVectors() const - { - return m_normalize; - } - - - // Find UV data. - AZ::SceneAPI::DataTypes::IMeshVertexUVData* TangentsRule::FindUVData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 uvSet) - { - const auto nameContentView = AZ::SceneAPI::Containers::Views::MakePairView(graph.GetNameStorage(), graph.GetContentStorage()); - - AZ::u64 uvSetIndex = 0; - auto meshChildView = AZ::SceneAPI::Containers::Views::MakeSceneGraphChildView(graph, nodeIndex, nameContentView.begin(), true); - for (auto child = meshChildView.begin(); child != meshChildView.end(); ++child) - { - AZ::SceneAPI::DataTypes::IMeshVertexUVData* data = azrtti_cast(child->second.get()); - if (data) - { - if (uvSetIndex == uvSet) - { - return data; - } - uvSetIndex++; - } - } - - return nullptr; - } - - - // Find tangent data. - AZ::SceneAPI::DataTypes::IMeshVertexTangentData* TangentsRule::FindTangentData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 setIndex, AZ::SceneAPI::DataTypes::TangentSpace tangentSpace) - { - const auto nameContentView = AZ::SceneAPI::Containers::Views::MakePairView(graph.GetNameStorage(), graph.GetContentStorage()); - - auto meshChildView = AZ::SceneAPI::Containers::Views::MakeSceneGraphChildView(graph, nodeIndex, nameContentView.begin(), true); - for (auto child = meshChildView.begin(); child != meshChildView.end(); ++child) - { - AZ::SceneAPI::DataTypes::IMeshVertexTangentData* data = azrtti_cast(child->second.get()); - if (data) - { - if (setIndex == data->GetTangentSetIndex() && tangentSpace == data->GetTangentSpace()) - { - return data; - } - } - } - - return nullptr; - } - - - // Find bitangent data. - AZ::SceneAPI::DataTypes::IMeshVertexBitangentData* TangentsRule::FindBitangentData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 setIndex, AZ::SceneAPI::DataTypes::TangentSpace tangentSpace) - { - const auto nameContentView = AZ::SceneAPI::Containers::Views::MakePairView(graph.GetNameStorage(), graph.GetContentStorage()); - - auto meshChildView = AZ::SceneAPI::Containers::Views::MakeSceneGraphChildView(graph, nodeIndex, nameContentView.begin(), true); - for (auto child = meshChildView.begin(); child != meshChildView.end(); ++child) - { - AZ::SceneAPI::DataTypes::IMeshVertexBitangentData* data = azrtti_cast(child->second.get()); - if (data) - { - if (setIndex == data->GetBitangentSetIndex() && tangentSpace == data->GetTangentSpace()) - { - return data; - } - } - } - - return nullptr; - } - - AZ::Crc32 TangentsRule::GetNormalizeVisibility() const - { - return (m_tangentSpace == AZ::SceneAPI::DataTypes::TangentSpace::EMotionFX) ? AZ::Edit::PropertyVisibility::Hide : AZ::Edit::PropertyVisibility::Show; - } - - AZ::Crc32 TangentsRule::GetOrthogonalVisibility() const - { - return (m_tangentSpace == AZ::SceneAPI::DataTypes::TangentSpace::EMotionFX) ? AZ::Edit::PropertyVisibility::Hide : AZ::Edit::PropertyVisibility::Show; - } - void TangentsRule::Reflect(AZ::ReflectContext* context) { AZ::SerializeContext* serializeContext = azrtti_cast(context); @@ -143,11 +43,8 @@ namespace AZ return; } - serializeContext->Class()->Version(2) - ->Field("tangentSpace", &TangentsRule::m_tangentSpace) - ->Field("bitangentMethod", &TangentsRule::m_bitangentMethod) - ->Field("normalize", &TangentsRule::m_normalize) - ->Field("uvSetIndex", &TangentsRule::m_uvSetIndex); + serializeContext->Class()->Version(3) + ->Field("tangentSpace", &TangentsRule::m_tangentSpace); AZ::EditContext* editContext = serializeContext->GetEditContext(); if (editContext) @@ -159,17 +56,7 @@ namespace AZ ->DataElement(AZ::Edit::UIHandlers::ComboBox, &AZ::SceneAPI::SceneData::TangentsRule::m_tangentSpace, "Tangent space", "Specify the tangent space used for normal map baking. Choose 'From Fbx' to extract the tangents and bitangents directly from the Fbx file. When there is no tangents rule or the Fbx has no tangents stored inside it, the 'MikkT' option will be used with orthogonal tangents of unit length, so with the normalize option enabled, using the first UV set.") ->EnumAttribute(AZ::SceneAPI::DataTypes::TangentSpace::FromSourceScene, "From Source Scene") ->EnumAttribute(AZ::SceneAPI::DataTypes::TangentSpace::MikkT, "MikkT") - ->EnumAttribute(AZ::SceneAPI::DataTypes::TangentSpace::EMotionFX, "EMotion FX") ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree) - ->DataElement(AZ::Edit::UIHandlers::ComboBox, &AZ::SceneAPI::SceneData::TangentsRule::m_bitangentMethod, "Bitangents", "Set to 'use from tangent space' to use the bitangents generated by the algorithm used or inside the fbx file. This can result in non-orthogonal tangents. Set to 'orthogonal' to skip storing the bitangents and let the engine calculate the bitangents in a way it will be perpendicular to both the normal and tangent.") - ->EnumAttribute(AZ::SceneAPI::DataTypes::BitangentMethod::UseFromTangentSpace, "Use from tangent space") - ->EnumAttribute(AZ::SceneAPI::DataTypes::BitangentMethod::Orthogonal, "Orthogonal") - ->Attribute(AZ::Edit::Attributes::Visibility, &TangentsRule::GetOrthogonalVisibility) - ->DataElement(AZ::Edit::UIHandlers::Default, &TangentsRule::m_uvSetIndex, "Uv set", "The UV set index to generate the tangents from. A value of 0 means the first uv set, while 1 means the second uv set.") - ->Attribute(AZ::Edit::Attributes::Min, 0) - ->Attribute(AZ::Edit::Attributes::Max, 1) - ->DataElement(AZ::Edit::UIHandlers::Default, &TangentsRule::m_normalize, "Normalize", "Normalize the tangents and bitangents? When disabled the vectors might no be unit length, which can be useful for relief mapping.") - ->Attribute(AZ::Edit::Attributes::Visibility, &TangentsRule::GetNormalizeVisibility) ; } } diff --git a/Code/Tools/SceneAPI/SceneData/Rules/TangentsRule.h b/Code/Tools/SceneAPI/SceneData/Rules/TangentsRule.h index 28627cfe0c..b368fce88a 100644 --- a/Code/Tools/SceneAPI/SceneData/Rules/TangentsRule.h +++ b/Code/Tools/SceneAPI/SceneData/Rules/TangentsRule.h @@ -46,24 +46,11 @@ namespace AZ SCENE_DATA_API ~TangentsRule() override = default; SCENE_DATA_API AZ::SceneAPI::DataTypes::TangentSpace GetTangentSpace() const; - SCENE_DATA_API AZ::SceneAPI::DataTypes::BitangentMethod GetBitangentMethod() const; - SCENE_DATA_API AZ::u64 GetUVSetIndex() const; - SCENE_DATA_API bool GetNormalizeVectors() const; - - SCENE_DATA_API static AZ::SceneAPI::DataTypes::IMeshVertexUVData* FindUVData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 uvSet); - SCENE_DATA_API static AZ::SceneAPI::DataTypes::IMeshVertexTangentData* FindTangentData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 setIndex, AZ::SceneAPI::DataTypes::TangentSpace tangentSpace); - SCENE_DATA_API static AZ::SceneAPI::DataTypes::IMeshVertexBitangentData* FindBitangentData(AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::Containers::SceneGraph::NodeIndex& nodeIndex, AZ::u64 setIndex, AZ::SceneAPI::DataTypes::TangentSpace tangentSpace); static void Reflect(ReflectContext* context); protected: - AZ::Crc32 GetNormalizeVisibility() const; - AZ::Crc32 GetOrthogonalVisibility() const; - - AZ::SceneAPI::DataTypes::TangentSpace m_tangentSpace; /**< Specifies how to handle tangents. Either generate them, or import them. */ - AZ::SceneAPI::DataTypes::BitangentMethod m_bitangentMethod; /**< Grab the bitangents from the generator/source or use an orthogonal basis by always calculating them? */ - AZ::u64 m_uvSetIndex; /**< Generate the tangents from this UV set. */ - bool m_normalize; /**< Normalize the tangent and bitangents? */ + AZ::SceneAPI::DataTypes::TangentSpace m_tangentSpace; /**< Specifies how to handle tangents. Either generate them, or import them. */ }; } // SceneData } // SceneAPI From fe661bc159fbb8d6759286021e4f081fcca6b41a Mon Sep 17 00:00:00 2001 From: Benjamin Jillich Date: Tue, 20 Jul 2021 16:27:52 +0200 Subject: [PATCH 06/33] Register tangents rule for mesh groups, so users can add it to the scene settings Signed-off-by: Benjamin Jillich --- .../SceneCore/DataTypes/GraphData/IMeshVertexTangentData.h | 3 +-- .../SceneAPI/SceneData/GraphData/MeshVertexBitangentData.cpp | 1 - .../SceneAPI/SceneData/GraphData/MeshVertexTangentData.cpp | 1 - Code/Tools/SceneAPI/SceneData/ManifestMetaInfoHandler.cpp | 5 +++++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexTangentData.h b/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexTangentData.h index 3264bcf45d..ffeeedf9fe 100644 --- a/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexTangentData.h +++ b/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexTangentData.h @@ -25,8 +25,7 @@ namespace AZ enum class TangentSpace { FromSourceScene = 0, - MikkT = 1, - EMotionFX = 2 + MikkT = 1 }; enum class BitangentMethod diff --git a/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexBitangentData.cpp b/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexBitangentData.cpp index 183288a470..faa9bf457e 100644 --- a/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexBitangentData.cpp +++ b/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexBitangentData.cpp @@ -34,7 +34,6 @@ namespace AZ ->Method("GetBitangent", &MeshVertexBitangentData::GetBitangent) ->Method("GetBitangentSetIndex", &MeshVertexBitangentData::GetBitangentSetIndex) ->Method("GetTangentSpace", &MeshVertexBitangentData::GetTangentSpace) - ->Enum<(int)SceneAPI::DataTypes::TangentSpace::EMotionFX>("EMotionFX") ->Enum<(int)SceneAPI::DataTypes::TangentSpace::FromSourceScene>("FromSourceScene") ->Enum<(int)SceneAPI::DataTypes::TangentSpace::MikkT>("MikkT"); } diff --git a/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexTangentData.cpp b/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexTangentData.cpp index 41e8bd9f65..9f27f4eb44 100644 --- a/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexTangentData.cpp +++ b/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexTangentData.cpp @@ -34,7 +34,6 @@ namespace AZ ->Method("GetTangent", &MeshVertexTangentData::GetTangent) ->Method("GetTangentSetIndex", &MeshVertexTangentData::GetTangentSetIndex) ->Method("GetTangentSpace", &MeshVertexTangentData::GetTangentSpace) - ->Enum<(int)SceneAPI::DataTypes::TangentSpace::EMotionFX>("EMotionFX") ->Enum<(int)SceneAPI::DataTypes::TangentSpace::FromSourceScene>("FromSourceScene") ->Enum<(int)SceneAPI::DataTypes::TangentSpace::MikkT>("MikkT"); } diff --git a/Code/Tools/SceneAPI/SceneData/ManifestMetaInfoHandler.cpp b/Code/Tools/SceneAPI/SceneData/ManifestMetaInfoHandler.cpp index 760221983e..a135ec5073 100644 --- a/Code/Tools/SceneAPI/SceneData/ManifestMetaInfoHandler.cpp +++ b/Code/Tools/SceneAPI/SceneData/ManifestMetaInfoHandler.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -82,6 +83,10 @@ namespace AZ { modifiers.push_back(azrtti_typeid()); } + if (existingRules.find(SceneData::TangentsRule::TYPEINFO_Uuid()) == existingRules.end()) + { + modifiers.push_back(SceneData::TangentsRule::TYPEINFO_Uuid()); + } } else if (target.RTTI_IsTypeOf(DataTypes::ISkinGroup::TYPEINFO_Uuid())) { From b7cb9fa5e3b8a97ff4156a36866da81de4b4a4cb Mon Sep 17 00:00:00 2001 From: jckand-amzn Date: Tue, 20 Jul 2021 11:46:16 -0500 Subject: [PATCH 07/33] Re-configured some component properties to account for uniform scaling in PositionModifier tests Signed-off-by: jckand-amzn --- ...PositionModifier_AutoSnapToSurfaceWorks.py | 25 ++++--------------- .../dyn_veg/test_PositionModifier.py | 4 +-- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_AutoSnapToSurfaceWorks.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_AutoSnapToSurfaceWorks.py index fe33da550a..a55e88488c 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_AutoSnapToSurfaceWorks.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/PositionModifier_AutoSnapToSurfaceWorks.py @@ -82,22 +82,7 @@ class TestPositionModifierAutoSnapToSurface(EditorTestHelper): # 3) Create a spherical planting surface and a flat surface flat_entity = dynveg.create_surface_entity("Flat Surface", spawner_center_point, 32.0, 32.0, 1.0) - hill_entity = dynveg.create_mesh_surface_entity_with_slopes("Planting Surface", spawner_center_point, 5.0, 5.0, 5.0) - - # Disable/Re-enable Mesh component due to ATOM-14299 - general.idle_wait(1.0) - editor.EditorComponentAPIBus(bus.Broadcast, 'DisableComponents', [hill_entity.components[0]]) - is_enabled = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', hill_entity.components[0]) - if is_enabled: - print("Mesh component is still enabled") - else: - print("Mesh component was disabled") - editor.EditorComponentAPIBus(bus.Broadcast, 'EnableComponents', [hill_entity.components[0]]) - is_enabled = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', hill_entity.components[0]) - if is_enabled: - print("Mesh component is now enabled") - else: - print("Mesh component is still disabled") + hill_entity = dynveg.create_mesh_surface_entity_with_slopes("Planting Surface", spawner_center_point, 5.0) # Disable the Flat Surface Box Shape component, and temporarily ignore initial instance counts due to LYN-2245 editor.EditorComponentAPIBus(bus.Broadcast, 'DisableComponents', [flat_entity.components[0]]) @@ -117,14 +102,14 @@ class TestPositionModifierAutoSnapToSurface(EditorTestHelper): # Pin the Constant Gradient to the X axis of the spawner's Position Modifier component spawner_entity.get_set_test(3, 'Configuration|Position X|Gradient|Gradient Entity Id', gradient_entity.id) - # 6) Set the Position Modifier offset to 5 on the x-axis - spawner_entity.get_set_test(3, position_modifier_paths[0], 5) - spawner_entity.get_set_test(3, position_modifier_paths[1], 5) + # 6) Set the Position Modifier offset to 2.5 on the x-axis + spawner_entity.get_set_test(3, position_modifier_paths[0], 2.5) + spawner_entity.get_set_test(3, position_modifier_paths[1], 2.5) # 7) Validate instance count at the top of the sphere mesh and inside the sphere mesh while Auto Snap to Surface # is enabled top_point = math.Vector3(512.0, 512.0, 37.0) - inside_point = math.Vector3(512.0, 512.0, 33.0) + inside_point = math.Vector3(512.0, 512.0, 35.0) radius = 0.5 num_expected = 1 self.log(f"Checking for instances in a {radius * 2}m area at {top_point.ToString()}") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py index 0e211ba311..f990939320 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py @@ -58,7 +58,6 @@ class TestPositionModifier(object): @pytest.mark.test_case_id("C4874100") @pytest.mark.SUITE_sandbox @pytest.mark.dynveg_modifier - @pytest.mark.xfail # LYN-3275 def test_PositionModifier_AutoSnapToSurfaceWorks(self, request, editor, level, launcher_platform): expected_lines = [ @@ -75,5 +74,6 @@ class TestPositionModifier(object): editor, "PositionModifier_AutoSnapToSurfaceWorks.py", expected_lines, - cfg_args=[level] + cfg_args=[level], + null_renderer=False ) From 605c17072ee4f71582bebc281a1b2e686e57afb3 Mon Sep 17 00:00:00 2001 From: jckand-amzn Date: Tue, 20 Jul 2021 11:47:26 -0500 Subject: [PATCH 08/33] Updating test suite for Position Modifier test Signed-off-by: jckand-amzn --- .../PythonTests/largeworlds/dyn_veg/test_PositionModifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py index f990939320..85f89b0f12 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py @@ -56,7 +56,7 @@ class TestPositionModifier(object): ) @pytest.mark.test_case_id("C4874100") - @pytest.mark.SUITE_sandbox + @pytest.mark.SUITE_periodic @pytest.mark.dynveg_modifier def test_PositionModifier_AutoSnapToSurfaceWorks(self, request, editor, level, launcher_platform): From 4762867856090c7e3a8363d361849f727ba2fa73 Mon Sep 17 00:00:00 2001 From: hultonha Date: Tue, 20 Jul 2021 18:01:15 +0100 Subject: [PATCH 09/33] fix for focus being removed from main viewport widget when interacting with viewport ui elements Signed-off-by: hultonha --- Code/Editor/ShortcutDispatcher.cpp | 1 - .../ViewportUi/ButtonGroup.cpp | 7 +- .../ViewportUi/ViewportUiCluster.cpp | 42 ++++--- .../ViewportUi/ViewportUiCluster.h | 9 +- .../ViewportUi/ViewportUiDisplay.cpp | 115 +++++++----------- .../ViewportUi/ViewportUiDisplay.h | 36 +++--- .../ViewportUi/ViewportUiWidgetCallbacks.h | 2 +- 7 files changed, 95 insertions(+), 117 deletions(-) diff --git a/Code/Editor/ShortcutDispatcher.cpp b/Code/Editor/ShortcutDispatcher.cpp index df7b25eb55..50e309d955 100644 --- a/Code/Editor/ShortcutDispatcher.cpp +++ b/Code/Editor/ShortcutDispatcher.cpp @@ -346,7 +346,6 @@ bool ShortcutDispatcher::eventFilter(QObject* obj, QEvent* ev) case QEvent::Shortcut: return shortcutFilter(obj, static_cast(ev)); - break; case QEvent::MouseButtonPress: if (!s_lastFocus || !IsAContainerForB(qobject_cast(obj), s_lastFocus)) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/ButtonGroup.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/ButtonGroup.cpp index eb846ddde8..e933940d95 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/ButtonGroup.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/ButtonGroup.cpp @@ -45,11 +45,11 @@ namespace AzToolsFramework::ViewportUi::Internal if (name.empty()) { - m_buttons.insert({buttonId, AZStd::make_unique