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/RadiusWeightModifier/EditorRadiusWeightModifierComponent.h>
#include <AtomLyIntegration/CommonFeatures/PostProcess/RadiusWeightModifier/RadiusWeightModifierComponentConstants.h>
namespace AZ
{
namespace Render
{
void EditorRadiusWeightModifierComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EditorRadiusWeightModifierComponent, BaseClass>()
->Version(1);
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<EditorRadiusWeightModifierComponent>(
"Radius 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<RadiusWeightModifierComponentController>("RadiusWeightModifierComponentController", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &RadiusWeightModifierComponentController::m_configuration, "Configuration", "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
;
editContext->Class<RadiusWeightModifierComponentConfig>("RadiusWeightModifierComponentConfig", "")
->DataElement(AZ::Edit::UIHandlers::Slider,
&RadiusWeightModifierComponentConfig::m_radius,
"Radius",
"Radius of PostFx Volume.")
->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<EditorRadiusWeightModifierComponent>()->RequestBus("PostFxWeightRequestBus");
behaviorContext->ConstantProperty("EditorRadiusWeightModifierComponentTypeId", BehaviorConstant(Uuid(EditorRadiusWeightModifierComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
}
}
EditorRadiusWeightModifierComponent::EditorRadiusWeightModifierComponent(const RadiusWeightModifierComponentConfig& config)
: BaseClass(config)
{
}
AZ::u32 EditorRadiusWeightModifierComponent::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/RadiusWeightModifier/RadiusWeightModifierComponent.h>
namespace AZ
{
namespace Render
{
class EditorRadiusWeightModifierComponent final
: public AzToolsFramework::Components::EditorComponentAdapter<RadiusWeightModifierComponentController, RadiusWeightModifierComponent, RadiusWeightModifierComponentConfig>
{
public:
using BaseClass = AzToolsFramework::Components::EditorComponentAdapter<RadiusWeightModifierComponentController, RadiusWeightModifierComponent, RadiusWeightModifierComponentConfig>;
AZ_EDITOR_COMPONENT(AZ::Render::EditorRadiusWeightModifierComponent, EditorRadiusWeightModifierComponentTypeId, BaseClass);
static void Reflect(AZ::ReflectContext* context);
EditorRadiusWeightModifierComponent() = default;
EditorRadiusWeightModifierComponent(const RadiusWeightModifierComponentConfig& 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/RadiusWeightModifier/RadiusWeightModifierComponent.h>
namespace AZ
{
namespace Render
{
RadiusWeightModifierComponent::RadiusWeightModifierComponent(const RadiusWeightModifierComponentConfig& config)
: BaseClass(config)
{
}
void RadiusWeightModifierComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<RadiusWeightModifierComponent, BaseClass>();
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<RadiusWeightModifierComponent>()->RequestBus("PostFxWeightRequestBus");
behaviorContext->ConstantProperty("RadiusWeightModifierComponentTypeId", BehaviorConstant(Uuid(RadiusWeightModifierComponentTypeId)))
->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/RadiusWeightModifier/RadiusWeightModifierComponentConstants.h>
#include <AtomLyIntegration/CommonFeatures/PostProcess/RadiusWeightModifier/RadiusWeightModifierComponentConfig.h>
#include <PostProcess/RadiusWeightModifier/RadiusWeightModifierComponentController.h>
namespace AZ
{
namespace Render
{
class RadiusWeightModifierComponent final
: public AzFramework::Components::ComponentAdapter<RadiusWeightModifierComponentController, RadiusWeightModifierComponentConfig>
{
public:
using BaseClass = AzFramework::Components::ComponentAdapter<RadiusWeightModifierComponentController, RadiusWeightModifierComponentConfig>;
AZ_COMPONENT(AZ::Render::RadiusWeightModifierComponent, "{8F0FC718-50E1-425E-A1E7-9C0425879CEB}", BaseClass);
RadiusWeightModifierComponent() = default;
RadiusWeightModifierComponent(const RadiusWeightModifierComponentConfig& 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/RadiusWeightModifier/RadiusWeightModifierComponentConfig.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
namespace AZ
{
namespace Render
{
void RadiusWeightModifierComponentConfig::Reflect(ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<RadiusWeightModifierComponentConfig, ComponentConfig>()
->Version(0)
->Field("Radius", &RadiusWeightModifierComponentConfig::m_radius)
;
}
}
}
}
@@ -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/RadiusWeightModifier/RadiusWeightModifierComponentController.h>
namespace AZ
{
namespace Render
{
void RadiusWeightModifierComponentController::Reflect(AZ::ReflectContext* context)
{
RadiusWeightModifierComponentConfig::Reflect(context);
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<RadiusWeightModifierComponentController>()
->Version(0)
->Field("Configuration", &RadiusWeightModifierComponentController::m_configuration);
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<PostFxWeightRequestBus>("PostFxWeightRequestBus");
}
}
void RadiusWeightModifierComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC_CE("PostFXWeightModifierService"));
}
void RadiusWeightModifierComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC_CE("PostFXWeightModifierService"));
}
void RadiusWeightModifierComponentController::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC_CE("PostFXLayerService"));
}
RadiusWeightModifierComponentController::RadiusWeightModifierComponentController(const RadiusWeightModifierComponentConfig& config)
: m_configuration(config)
{
}
void RadiusWeightModifierComponentController::Activate(EntityId entityId)
{
m_entityId = entityId;
PostFxWeightRequestBus::Handler::BusConnect(m_entityId);
}
void RadiusWeightModifierComponentController::Deactivate()
{
PostFxWeightRequestBus::Handler::BusDisconnect(m_entityId);
m_entityId.SetInvalid();
}
void RadiusWeightModifierComponentController::SetConfiguration(const RadiusWeightModifierComponentConfig& config)
{
m_configuration = config;
}
float RadiusWeightModifierComponentController::GetWeightAtPosition(const AZ::Vector3& influencerPosition) const
{
AZ::Vector3 postfxCenterPosition = AZ::Vector3::CreateZero();
AZ::TransformBus::EventResult(postfxCenterPosition, m_entityId, &AZ::TransformInterface::GetWorldTranslation);
float magnitude = postfxCenterPosition.GetDistance(influencerPosition);
return AZ::GetMax(0.0f, 1 - magnitude / m_configuration.m_radius);
}
}
}
@@ -0,0 +1,52 @@
/*
* 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/RadiusWeightModifier/RadiusWeightModifierComponentConfig.h>
#include <AtomLyIntegration/CommonFeatures/PostProcess/PostFxWeightRequestBus.h>
namespace AZ
{
namespace Render
{
class RadiusWeightModifierComponentController final
: public PostFxWeightRequestBus::Handler
{
public:
friend class EditorRadiusWeightModifierComponent;
AZ_TYPE_INFO(AZ::Render::RadiusWeightModifierComponentController, "{29565EC9-8DE1-46A5-B20C-328AA6ED23C6}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
RadiusWeightModifierComponentController() = default;
RadiusWeightModifierComponentController(const RadiusWeightModifierComponentConfig& config);
void Activate(EntityId entityId);
void Deactivate();
void SetConfiguration(const RadiusWeightModifierComponentConfig& config);
const RadiusWeightModifierComponentConfig& GetConfiguration() const { return m_configuration; }
virtual float GetWeightAtPosition(const AZ::Vector3& influencerPosition) const override;
private:
AZ_DISABLE_COPY(RadiusWeightModifierComponentController);
RadiusWeightModifierComponentConfig m_configuration;
EntityId m_entityId;
};
}
}