Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,84 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <PostProcess/ShapeWeightModifier/EditorShapeWeightModifierComponent.h>
#include <AtomLyIntegration/CommonFeatures/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentConstants.h>
namespace AZ
{
namespace Render
{
void EditorShapeWeightModifierComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EditorShapeWeightModifierComponent, BaseClass>()
->Version(1);
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<EditorShapeWeightModifierComponent>(
"PostFX Shape Weight Modifier", "Modifies PostFX override factor based on proximity of an influencer against this entity's bounding sphere")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute(Edit::Attributes::Category, "Atom")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/Component_Placeholder.svg")
->Attribute(AZ::Edit::Attributes::ViewportIcon, "editor/icons/components/viewport/component_placeholder.png")
->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->Attribute(Edit::Attributes::AutoExpand, true)
->Attribute(Edit::Attributes::HelpPageURL, "")
;
editContext->Class<ShapeWeightModifierComponentController>("ShapeWeightModifierComponentController", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &ShapeWeightModifierComponentController::m_configuration, "Configuration", "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
;
editContext->Class<ShapeWeightModifierComponentConfig>("ShapeWeightModifierComponentConfig", "")
->DataElement(AZ::Edit::UIHandlers::Slider,
&ShapeWeightModifierComponentConfig::m_falloffDistance,
"Fall-off Distance",
"Distance from the shape to smoothly transition the PostFX.")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, std::numeric_limits<float>::max())
->Attribute(AZ::Edit::Attributes::SoftMax, 100.0f);
;
}
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<EditorShapeWeightModifierComponent>()->RequestBus("PostFxWeightRequestBus");
behaviorContext->ConstantProperty("EditorShapeWeightModifierComponentTypeId", BehaviorConstant(Uuid(EditorShapeWeightModifierComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
}
}
EditorShapeWeightModifierComponent::EditorShapeWeightModifierComponent(const ShapeWeightModifierComponentConfig& config)
: BaseClass(config)
{
}
AZ::u32 EditorShapeWeightModifierComponent::OnConfigurationChanged()
{
return Edit::PropertyRefreshLevels::AttributesAndValues;
}
}
}
@@ -0,0 +1,37 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzToolsFramework/ToolsComponents/EditorComponentAdapter.h>
#include <PostProcess/ShapeWeightModifier/ShapeWeightModifierComponent.h>
namespace AZ
{
namespace Render
{
class EditorShapeWeightModifierComponent final
: public AzToolsFramework::Components::EditorComponentAdapter<ShapeWeightModifierComponentController, ShapeWeightModifierComponent, ShapeWeightModifierComponentConfig>
{
public:
using BaseClass = AzToolsFramework::Components::EditorComponentAdapter<ShapeWeightModifierComponentController, ShapeWeightModifierComponent, ShapeWeightModifierComponentConfig>;
AZ_EDITOR_COMPONENT(AZ::Render::EditorShapeWeightModifierComponent, EditorShapeWeightModifierComponentTypeId, BaseClass);
static void Reflect(AZ::ReflectContext* context);
EditorShapeWeightModifierComponent() = default;
EditorShapeWeightModifierComponent(const ShapeWeightModifierComponentConfig& config);
AZ::u32 OnConfigurationChanged() override;
};
}
}
@@ -0,0 +1,44 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <PostProcess/ShapeWeightModifier/ShapeWeightModifierComponent.h>
namespace AZ
{
namespace Render
{
ShapeWeightModifierComponent::ShapeWeightModifierComponent(const ShapeWeightModifierComponentConfig& config)
: BaseClass(config)
{
}
void ShapeWeightModifierComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<ShapeWeightModifierComponent, BaseClass>();
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<ShapeWeightModifierComponent>()->RequestBus("PostFxWeightRequestBus");
behaviorContext->ConstantProperty("ShapeWeightModifierComponentTypeId", BehaviorConstant(Uuid(ShapeWeightModifierComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common);
}
}
}
}
@@ -0,0 +1,38 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzFramework/Components/ComponentAdapter.h>
#include <AtomLyIntegration/CommonFeatures/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentConstants.h>
#include <AtomLyIntegration/CommonFeatures/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentConfig.h>
#include <PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentController.h>
namespace AZ
{
namespace Render
{
class ShapeWeightModifierComponent final
: public AzFramework::Components::ComponentAdapter<ShapeWeightModifierComponentController, ShapeWeightModifierComponentConfig>
{
public:
using BaseClass = AzFramework::Components::ComponentAdapter<ShapeWeightModifierComponentController, ShapeWeightModifierComponentConfig>;
AZ_COMPONENT(AZ::Render::ShapeWeightModifierComponent, "{0BB6438B-6DD1-4A09-927F-7757D39C940D}", BaseClass);
ShapeWeightModifierComponent() = default;
ShapeWeightModifierComponent(const ShapeWeightModifierComponentConfig& config);
static void Reflect(AZ::ReflectContext* context);
};
}
}
@@ -0,0 +1,34 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AtomLyIntegration/CommonFeatures/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentConfig.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
namespace AZ
{
namespace Render
{
void ShapeWeightModifierComponentConfig::Reflect(ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<ShapeWeightModifierComponentConfig, ComponentConfig>()
->Version(0)
->Field("FalloffDistance", &ShapeWeightModifierComponentConfig::m_falloffDistance)
;
}
}
}
}
@@ -0,0 +1,108 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentController.h>
#include <LmbrCentral/Shape/ShapeComponentBus.h>
namespace AZ
{
namespace Render
{
void ShapeWeightModifierComponentController::Reflect(AZ::ReflectContext* context)
{
ShapeWeightModifierComponentConfig::Reflect(context);
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<ShapeWeightModifierComponentController>()
->Version(0)
->Field("Configuration", &ShapeWeightModifierComponentController::m_configuration);
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
}
}
void ShapeWeightModifierComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC_CE("PostFXWeightModifierService"));
}
void ShapeWeightModifierComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC_CE("PostFXWeightModifierService"));
}
void ShapeWeightModifierComponentController::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC_CE("PostFXLayerService"));
required.push_back(AZ_CRC("ShapeService", 0xe86aa5fe));
}
ShapeWeightModifierComponentController::ShapeWeightModifierComponentController(const ShapeWeightModifierComponentConfig& config)
: m_configuration(config)
{
}
void ShapeWeightModifierComponentController::Activate(EntityId entityId)
{
m_entityId = entityId;
PostFxWeightRequestBus::Handler::BusConnect(m_entityId);
}
void ShapeWeightModifierComponentController::Deactivate()
{
PostFxWeightRequestBus::Handler::BusDisconnect(m_entityId);
m_entityId.SetInvalid();
}
void ShapeWeightModifierComponentController::SetConfiguration(const ShapeWeightModifierComponentConfig& config)
{
m_configuration = config;
}
// Implementation taken from GradientSignal Gem
float ShapeWeightModifierComponentController::GetWeightAtPosition(const AZ::Vector3& influencerPosition) const
{
float distance = 0.0f;
LmbrCentral::ShapeComponentRequestsBus::EventResult(distance, m_entityId, &LmbrCentral::ShapeComponentRequestsBus::Events::DistanceFromPoint, influencerPosition);
// In the special case of 0 falloff, make sure that all points inside the shape (0 distance) return
// 1.0, and all points outside the shape return 0.
if (m_configuration.m_falloffDistance == 0.0f)
{
return (distance > 0.0f) ? 0.0f : 1.0f;
}
// Since this is outer falloff, distance should give us values from 1.0 at the minimum distance
// to 0.0 at the maximum distance.
return GetRatio(m_configuration.m_falloffDistance, 0.0f, distance);
}
// Implementation taken from GradientSignal Gem
float ShapeWeightModifierComponentController::GetRatio(float maxRange, float minRange, float distance) const
{
// If our min/max range is equal, GetRatio() would end up dividing by infinity, so in this case
// make sure that everything below or equal to the min/max value is 0.0, and everything above it is 1.0.
if (maxRange == minRange)
{
return (distance <= minRange) ? 0.0f : 1.0f;
}
return AZ::GetClamp((distance - maxRange) / (minRange - maxRange), 0.0f, 1.0f);
}
}
}
@@ -0,0 +1,55 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TransformBus.h>
#include <AtomLyIntegration/CommonFeatures/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentConfig.h>
#include <AtomLyIntegration/CommonFeatures/PostProcess/PostFxWeightRequestBus.h>
namespace AZ
{
namespace Render
{
class ShapeWeightModifierComponentController final
: public PostFxWeightRequestBus::Handler
{
public:
friend class EditorShapeWeightModifierComponent;
AZ_TYPE_INFO(AZ::Render::ShapeWeightModifierComponentController, "{5EF82EB8-8A7F-4B6C-BD40-8BABA1ABE0E5}");
static void Reflect(AZ::ReflectContext* context);
ShapeWeightModifierComponentController() = default;
ShapeWeightModifierComponentController(const ShapeWeightModifierComponentConfig& config);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services);
void Activate(EntityId entityId);
void Deactivate();
void SetConfiguration(const ShapeWeightModifierComponentConfig& config);
const ShapeWeightModifierComponentConfig& GetConfiguration() const { return m_configuration; }
//! PostFxWeightRequestBus::Handler Override
virtual float GetWeightAtPosition(const AZ::Vector3& influencerPosition) const override;
private:
float GetRatio(float maxRange, float minRange, float distance) const;
AZ_DISABLE_COPY(ShapeWeightModifierComponentController);
ShapeWeightModifierComponentConfig m_configuration;
EntityId m_entityId;
};
}
}