Integrating github/staging through commit ab87ed9
This commit is contained in:
@@ -54,7 +54,6 @@ namespace SurfaceData
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<SurfaceDataColliderConfig>()
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Category, "Vegetation")
|
||||
->Attribute(AZ::Script::Attributes::Module, "surface_data")
|
||||
@@ -101,7 +100,6 @@ namespace SurfaceData
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<SurfaceDataColliderComponent>()
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Category, "Vegetation")
|
||||
->Attribute(AZ::Script::Attributes::Module, "surface_data")
|
||||
|
||||
@@ -1,303 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensor's.
|
||||
*
|
||||
* 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 "SurfaceData_precompiled.h"
|
||||
#include "SurfaceDataMeshComponent.h"
|
||||
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <LmbrCentral/Rendering/MeshAsset.h>
|
||||
|
||||
#include <SurfaceData/SurfaceDataSystemRequestBus.h>
|
||||
#include <SurfaceData/Utility/SurfaceDataUtility.h>
|
||||
|
||||
#include <Cry_Matrix34.h>
|
||||
#include <Cry_GeoIntersect.h>
|
||||
#include <Cry_Geo.h>
|
||||
#include <IStatObj.h>
|
||||
#include <MathConversion.h>
|
||||
|
||||
namespace SurfaceData
|
||||
{
|
||||
void SurfaceDataMeshConfig::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
|
||||
if (serialize)
|
||||
{
|
||||
serialize->Class<SurfaceDataMeshConfig, AZ::ComponentConfig>()
|
||||
->Version(0)
|
||||
->Field("SurfaceTags", &SurfaceDataMeshConfig::m_tags)
|
||||
;
|
||||
|
||||
AZ::EditContext* edit = serialize->GetEditContext();
|
||||
if (edit)
|
||||
{
|
||||
edit->Class<SurfaceDataMeshConfig>(
|
||||
"Mesh Surface Tag Emitter", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->DataElement(0, &SurfaceDataMeshConfig::m_tags, "Generated Tags", "")
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services)
|
||||
{
|
||||
services.push_back(AZ_CRC("SurfaceDataProviderService", 0xfe9fb95e));
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services)
|
||||
{
|
||||
services.push_back(AZ_CRC("SurfaceDataProviderService", 0xfe9fb95e));
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services)
|
||||
{
|
||||
services.push_back(AZ_CRC("MeshService", 0x71d8a455));
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
SurfaceDataMeshConfig::Reflect(context);
|
||||
|
||||
AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
|
||||
if (serialize)
|
||||
{
|
||||
serialize->Class<SurfaceDataMeshComponent, AZ::Component>()
|
||||
->Version(0)
|
||||
->Field("Configuration", &SurfaceDataMeshComponent::m_configuration)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
SurfaceDataMeshComponent::SurfaceDataMeshComponent(const SurfaceDataMeshConfig& configuration)
|
||||
: m_configuration(configuration)
|
||||
{
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::Activate()
|
||||
{
|
||||
AZ::TransformNotificationBus::Handler::BusConnect(GetEntityId());
|
||||
LmbrCentral::MeshComponentNotificationBus::Handler::BusConnect(GetEntityId());
|
||||
|
||||
m_providerHandle = InvalidSurfaceDataRegistryHandle;
|
||||
m_refresh = false;
|
||||
|
||||
// Update the cached mesh data and bounds, then register the surface data provider
|
||||
UpdateMeshData();
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::Deactivate()
|
||||
{
|
||||
if (m_providerHandle != InvalidSurfaceDataRegistryHandle)
|
||||
{
|
||||
SurfaceDataSystemRequestBus::Broadcast(&SurfaceDataSystemRequestBus::Events::UnregisterSurfaceDataProvider, m_providerHandle);
|
||||
m_providerHandle = InvalidSurfaceDataRegistryHandle;
|
||||
}
|
||||
|
||||
SurfaceDataProviderRequestBus::Handler::BusDisconnect();
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
AZ::TransformNotificationBus::Handler::BusDisconnect();
|
||||
LmbrCentral::MeshComponentNotificationBus::Handler::BusDisconnect();
|
||||
m_refresh = false;
|
||||
|
||||
// Clear the cached mesh data
|
||||
{
|
||||
AZStd::lock_guard<decltype(m_cacheMutex)> lock(m_cacheMutex);
|
||||
m_meshAssetData = {};
|
||||
m_meshBounds = AZ::Aabb::CreateNull();
|
||||
m_meshWorldTM = AZ::Transform::CreateIdentity();
|
||||
m_meshWorldTMInverse = AZ::Transform::CreateIdentity();
|
||||
}
|
||||
}
|
||||
|
||||
bool SurfaceDataMeshComponent::ReadInConfig(const AZ::ComponentConfig* baseConfig)
|
||||
{
|
||||
if (auto config = azrtti_cast<const SurfaceDataMeshConfig*>(baseConfig))
|
||||
{
|
||||
m_configuration = *config;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SurfaceDataMeshComponent::WriteOutConfig(AZ::ComponentConfig* outBaseConfig) const
|
||||
{
|
||||
if (auto config = azrtti_cast<SurfaceDataMeshConfig*>(outBaseConfig))
|
||||
{
|
||||
*config = m_configuration;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SurfaceDataMeshComponent::DoRayTrace(const AZ::Vector3& inPosition, AZ::Vector3& outPosition, AZ::Vector3& outNormal) const
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Entity);
|
||||
|
||||
AZStd::lock_guard<decltype(m_cacheMutex)> lock(m_cacheMutex);
|
||||
|
||||
// test AABB as first pass to claim the point
|
||||
const AZ::Vector3 testPosition = AZ::Vector3(
|
||||
inPosition.GetX(),
|
||||
inPosition.GetY(),
|
||||
(m_meshBounds.GetMax().GetZ() + m_meshBounds.GetMin().GetZ()) * 0.5f);
|
||||
|
||||
if (!m_meshBounds.Contains(testPosition))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
LmbrCentral::MeshAsset* mesh = m_meshAssetData.GetAs<LmbrCentral::MeshAsset>();
|
||||
if (!mesh)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const AZ::Vector3 rayOrigin = AZ::Vector3(inPosition.GetX(), inPosition.GetY(), m_meshBounds.GetMax().GetZ() + s_rayAABBHeightPadding);
|
||||
const AZ::Vector3 rayDirection = -AZ::Vector3::CreateAxisZ();
|
||||
return GetMeshRayIntersection(*mesh, m_meshWorldTM, m_meshWorldTMInverse, rayOrigin, rayDirection, outPosition, outNormal);
|
||||
}
|
||||
|
||||
|
||||
void SurfaceDataMeshComponent::GetSurfacePoints(const AZ::Vector3& inPosition, SurfacePointList& surfacePointList) const
|
||||
{
|
||||
AZ::Vector3 hitPosition;
|
||||
AZ::Vector3 hitNormal;
|
||||
if (DoRayTrace(inPosition, hitPosition, hitNormal))
|
||||
{
|
||||
SurfacePoint point;
|
||||
point.m_entityId = GetEntityId();
|
||||
point.m_position = hitPosition;
|
||||
point.m_normal = hitNormal;
|
||||
AddMaxValueForMasks(point.m_masks, m_configuration.m_tags, 1.0f);
|
||||
surfacePointList.push_back(point);
|
||||
}
|
||||
}
|
||||
|
||||
AZ::Aabb SurfaceDataMeshComponent::GetSurfaceAabb() const
|
||||
{
|
||||
return m_meshBounds;
|
||||
}
|
||||
|
||||
SurfaceTagVector SurfaceDataMeshComponent::GetSurfaceTags() const
|
||||
{
|
||||
return m_configuration.m_tags;
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::OnCompositionChanged()
|
||||
{
|
||||
if (!m_refresh)
|
||||
{
|
||||
m_refresh = true;
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
}
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::OnMeshDestroyed()
|
||||
{
|
||||
OnCompositionChanged();
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::OnMeshCreated(const AZ::Data::Asset<AZ::Data::AssetData>& asset)
|
||||
{
|
||||
(void)asset;
|
||||
OnCompositionChanged();
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::OnBoundsReset()
|
||||
{
|
||||
OnCompositionChanged();
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::OnTransformChanged(const AZ::Transform & local, const AZ::Transform & world)
|
||||
{
|
||||
(void)local;
|
||||
(void)world;
|
||||
OnCompositionChanged();
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/)
|
||||
{
|
||||
if (m_refresh)
|
||||
{
|
||||
UpdateMeshData();
|
||||
m_refresh = false;
|
||||
}
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void SurfaceDataMeshComponent::UpdateMeshData()
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Entity);
|
||||
|
||||
bool meshValidBeforeUpdate = false;
|
||||
bool meshValidAfterUpdate = false;
|
||||
|
||||
{
|
||||
AZStd::lock_guard<decltype(m_cacheMutex)> lock(m_cacheMutex);
|
||||
|
||||
meshValidBeforeUpdate = (m_meshAssetData.GetAs<LmbrCentral::MeshAsset>() != nullptr) && (m_meshBounds.IsValid());
|
||||
|
||||
m_meshAssetData = {};
|
||||
LmbrCentral::MeshComponentRequestBus::EventResult(m_meshAssetData, GetEntityId(), &LmbrCentral::MeshComponentRequestBus::Events::GetMeshAsset);
|
||||
|
||||
m_meshBounds = AZ::Aabb::CreateNull();
|
||||
LmbrCentral::MeshComponentRequestBus::EventResult(m_meshBounds, GetEntityId(), &LmbrCentral::MeshComponentRequestBus::Events::GetWorldBounds);
|
||||
|
||||
m_meshWorldTM = AZ::Transform::CreateIdentity();
|
||||
AZ::TransformBus::EventResult(m_meshWorldTM, GetEntityId(), &AZ::TransformBus::Events::GetWorldTM);
|
||||
m_meshWorldTMInverse = m_meshWorldTM.GetInverse();
|
||||
|
||||
meshValidAfterUpdate = (m_meshAssetData.GetAs<LmbrCentral::MeshAsset>() != nullptr) && (m_meshBounds.IsValid());
|
||||
}
|
||||
|
||||
SurfaceDataRegistryEntry registryEntry;
|
||||
registryEntry.m_entityId = GetEntityId();
|
||||
registryEntry.m_bounds = GetSurfaceAabb();
|
||||
registryEntry.m_tags = GetSurfaceTags();
|
||||
|
||||
if (!meshValidBeforeUpdate && !meshValidAfterUpdate)
|
||||
{
|
||||
// We didn't have a valid mesh asset before or after running this, so do nothing.
|
||||
}
|
||||
else if (!meshValidBeforeUpdate && meshValidAfterUpdate)
|
||||
{
|
||||
// Our mesh has become valid, so register as a provider and save off the provider handle
|
||||
AZ_Assert((m_providerHandle == InvalidSurfaceDataRegistryHandle), "Surface data handle is initialized before our mesh became active");
|
||||
AZ_Assert(m_meshBounds.IsValid(), "Mesh Geometry isn't correctly initialized.");
|
||||
SurfaceDataSystemRequestBus::BroadcastResult(m_providerHandle, &SurfaceDataSystemRequestBus::Events::RegisterSurfaceDataProvider, registryEntry);
|
||||
|
||||
// Start listening for surface data events
|
||||
AZ_Assert((m_providerHandle != InvalidSurfaceDataRegistryHandle), "Invalid surface data handle");
|
||||
SurfaceDataProviderRequestBus::Handler::BusConnect(m_providerHandle);
|
||||
}
|
||||
else if (meshValidBeforeUpdate && !meshValidAfterUpdate)
|
||||
{
|
||||
// Our mesh has stopped being valid, so unregister and stop listening for surface data events
|
||||
AZ_Assert((m_providerHandle != InvalidSurfaceDataRegistryHandle), "Invalid surface data handle");
|
||||
SurfaceDataSystemRequestBus::Broadcast(&SurfaceDataSystemRequestBus::Events::UnregisterSurfaceDataProvider, m_providerHandle);
|
||||
m_providerHandle = InvalidSurfaceDataRegistryHandle;
|
||||
|
||||
SurfaceDataProviderRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
else if (meshValidBeforeUpdate && meshValidAfterUpdate)
|
||||
{
|
||||
// Our mesh was valid before and after, it just changed in some way, so update our registry entry.
|
||||
AZ_Assert((m_providerHandle != InvalidSurfaceDataRegistryHandle), "Invalid surface data handle");
|
||||
SurfaceDataSystemRequestBus::Broadcast(&SurfaceDataSystemRequestBus::Events::UpdateSurfaceDataProvider, m_providerHandle, registryEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* 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/Asset/AssetCommon.h>
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
#include <LmbrCentral/Rendering/MeshComponentBus.h>
|
||||
#include <SurfaceData/SurfaceDataProviderRequestBus.h>
|
||||
#include <SurfaceData/SurfaceDataTypes.h>
|
||||
|
||||
namespace LmbrCentral
|
||||
{
|
||||
class MeshAsset;
|
||||
|
||||
template<typename, typename>
|
||||
class EditorWrappedComponentBase;
|
||||
}
|
||||
|
||||
namespace SurfaceData
|
||||
{
|
||||
constexpr float s_rayAABBHeightPadding = 0.1f;
|
||||
|
||||
class SurfaceDataMeshConfig
|
||||
: public AZ::ComponentConfig
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(SurfaceDataMeshConfig, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(SurfaceDataMeshConfig, "{764C602E-7CA8-4BCC-AB2D-3E46623B3A20}", AZ::ComponentConfig);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
SurfaceTagVector m_tags;
|
||||
};
|
||||
|
||||
class SurfaceDataMeshComponent
|
||||
: public AZ::Component
|
||||
, public AZ::TickBus::Handler
|
||||
, public AZ::TransformNotificationBus::Handler
|
||||
, public LmbrCentral::MeshComponentNotificationBus::Handler
|
||||
, public SurfaceDataProviderRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
template<typename, typename> friend class LmbrCentral::EditorWrappedComponentBase;
|
||||
AZ_COMPONENT(SurfaceDataMeshComponent, "{F8915F34-BE8B-40B4-B7E8-01EBF3DA1C95}");
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
SurfaceDataMeshComponent(const SurfaceDataMeshConfig& configuration);
|
||||
SurfaceDataMeshComponent() = default;
|
||||
~SurfaceDataMeshComponent() = default;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AZ::Component interface implementation
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
bool ReadInConfig(const AZ::ComponentConfig* baseConfig) override;
|
||||
bool WriteOutConfig(AZ::ComponentConfig* outBaseConfig) const override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// MeshComponentNotificationBus
|
||||
void OnMeshCreated(const AZ::Data::Asset<AZ::Data::AssetData>& asset) override;
|
||||
void OnMeshDestroyed() override;
|
||||
void OnBoundsReset() override;;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// TransformNotificationBus
|
||||
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// AZ::TickBus
|
||||
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// SurfaceDataProviderRequestBus
|
||||
void GetSurfacePoints(const AZ::Vector3& inPosition, SurfacePointList& surfacePointList) const override;
|
||||
|
||||
private:
|
||||
bool DoRayTrace(const AZ::Vector3& inPosition, AZ::Vector3& outPosition, AZ::Vector3& outNormal) const;
|
||||
void UpdateMeshData();
|
||||
void OnCompositionChanged();
|
||||
|
||||
AZ::Aabb GetSurfaceAabb() const;
|
||||
SurfaceTagVector GetSurfaceTags() const;
|
||||
|
||||
SurfaceDataMeshConfig m_configuration;
|
||||
|
||||
SurfaceDataRegistryHandle m_providerHandle = InvalidSurfaceDataRegistryHandle;
|
||||
|
||||
// cached data
|
||||
AZStd::atomic_bool m_refresh{ false };
|
||||
mutable AZStd::recursive_mutex m_cacheMutex;
|
||||
AZ::Data::Asset<AZ::Data::AssetData> m_meshAssetData;
|
||||
AZ::Transform m_meshWorldTM = AZ::Transform::CreateIdentity();
|
||||
AZ::Transform m_meshWorldTMInverse = AZ::Transform::CreateIdentity();
|
||||
AZ::Aabb m_meshBounds = AZ::Aabb::CreateNull();
|
||||
};
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* 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 "SurfaceData_precompiled.h"
|
||||
#include "EditorSurfaceDataMeshComponent.h"
|
||||
#include <AzCore/Serialization/Utils.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
#include <LmbrCentral/Dependency/DependencyNotificationBus.h>
|
||||
|
||||
namespace SurfaceData
|
||||
{
|
||||
void EditorSurfaceDataMeshComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
BaseClassType::ReflectSubClass<EditorSurfaceDataMeshComponent, BaseClassType>(context, 2, &LmbrCentral::EditorWrappedComponentBaseVersionConverter<typename BaseClassType::WrappedComponentType, typename BaseClassType::WrappedConfigType,2>);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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/Module/Module.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorVisibilityBus.h>
|
||||
#include <Components/SurfaceDataMeshComponent.h>
|
||||
#include <LmbrCentral/Component/EditorWrappedComponentBase.h>
|
||||
|
||||
namespace SurfaceData
|
||||
{
|
||||
class EditorSurfaceDataMeshComponent
|
||||
: public LmbrCentral::EditorWrappedComponentBase<SurfaceDataMeshComponent, SurfaceDataMeshConfig>
|
||||
{
|
||||
public:
|
||||
using BaseClassType = LmbrCentral::EditorWrappedComponentBase<SurfaceDataMeshComponent, SurfaceDataMeshConfig>;
|
||||
AZ_EDITOR_COMPONENT(EditorSurfaceDataMeshComponent, "{4D73E979-5463-4B75-AE46-70B1E52CBF43}", BaseClassType);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
static constexpr const char* const s_categoryName = "Surface Data";
|
||||
static constexpr const char* const s_componentName = "Mesh Surface Tag Emitter";
|
||||
static constexpr const char* const s_componentDescription = "Enables a static mesh to emit surface tags";
|
||||
static constexpr const char* const s_icon = "Editor/Icons/Components/SurfaceData.svg";
|
||||
static constexpr const char* const s_viewportIcon = "Editor/Icons/Components/Viewport/SurfaceData.png";
|
||||
static constexpr const char* const s_helpUrl = "https://docs.aws.amazon.com/console/lumberyard/surfacedata/mesh-surface-tag-emitter";
|
||||
};
|
||||
}
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <SurfaceDataSystemComponent.h>
|
||||
#include <Editor/EditorSurfaceDataSystemComponent.h>
|
||||
#include <Editor/EditorSurfaceDataColliderComponent.h>
|
||||
#include <Editor/EditorSurfaceDataMeshComponent.h>
|
||||
#include <Editor/EditorSurfaceDataShapeComponent.h>
|
||||
|
||||
namespace SurfaceData
|
||||
@@ -25,7 +24,6 @@ namespace SurfaceData
|
||||
m_descriptors.insert(m_descriptors.end(), {
|
||||
EditorSurfaceDataSystemComponent::CreateDescriptor(),
|
||||
EditorSurfaceDataColliderComponent::CreateDescriptor(),
|
||||
EditorSurfaceDataMeshComponent::CreateDescriptor(),
|
||||
EditorSurfaceDataShapeComponent::CreateDescriptor()
|
||||
});
|
||||
}
|
||||
@@ -38,4 +36,4 @@ namespace SurfaceData
|
||||
}
|
||||
}
|
||||
|
||||
AZ_DECLARE_MODULE_CLASS(Gem_SurfaceDataEditor, SurfaceData::SurfaceDataEditorModule)
|
||||
AZ_DECLARE_MODULE_CLASS(Gem_SurfaceDataEditor, SurfaceData::SurfaceDataEditorModule)
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <SurfaceDataModule.h>
|
||||
#include <SurfaceDataSystemComponent.h>
|
||||
#include <Components/SurfaceDataColliderComponent.h>
|
||||
#include <Components/SurfaceDataMeshComponent.h>
|
||||
#include <Components/SurfaceDataShapeComponent.h>
|
||||
#include <TerrainSurfaceDataSystemComponent.h>
|
||||
|
||||
@@ -26,7 +25,6 @@ namespace SurfaceData
|
||||
m_descriptors.insert(m_descriptors.end(), {
|
||||
SurfaceDataSystemComponent::CreateDescriptor(),
|
||||
SurfaceDataColliderComponent::CreateDescriptor(),
|
||||
SurfaceDataMeshComponent::CreateDescriptor(),
|
||||
SurfaceDataShapeComponent::CreateDescriptor(),
|
||||
TerrainSurfaceDataSystemComponent::CreateDescriptor(),
|
||||
});
|
||||
|
||||
@@ -52,7 +52,6 @@ namespace SurfaceData
|
||||
{
|
||||
behaviorContext->Class<SurfacePoint>()
|
||||
->Constructor()
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(AZ::Script::Attributes::Category, "Vegetation")
|
||||
->Attribute(AZ::Script::Attributes::Module, "surface_data")
|
||||
->Property("entityId", BehaviorValueProperty(&SurfacePoint::m_entityId))
|
||||
@@ -66,7 +65,6 @@ namespace SurfaceData
|
||||
;
|
||||
|
||||
behaviorContext->EBus<SurfaceDataSystemRequestBus>("SurfaceDataSystemRequestBus")
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(AZ::Script::Attributes::Category, "Vegetation")
|
||||
->Attribute(AZ::Script::Attributes::Module, "surface_data")
|
||||
->Event("GetSurfacePoints", &SurfaceDataSystemRequestBus::Events::GetSurfacePoints)
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 "SurfaceData_precompiled.h"
|
||||
#include <SurfaceData/Utility/SurfaceDataUtility.h>
|
||||
#include <Atom/RPI.Reflect/Model/ModelAssetCreator.h>
|
||||
|
||||
namespace SurfaceData
|
||||
{
|
||||
bool GetMeshRayIntersection(
|
||||
const AZ::RPI::ModelAsset& meshAsset, const AZ::Transform& meshTransform, const AZ::Transform& meshTransformInverse,
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDirection, AZ::Vector3& outPosition, AZ::Vector3& outNormal)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Entity);
|
||||
|
||||
// Transform everything into model space
|
||||
const AZ::Vector3 rayOriginLocal = meshTransformInverse.TransformPoint(rayOrigin);
|
||||
const AZ::Vector3 rayDirectionLocal = meshTransformInverse.TransformVector(rayDirection).GetNormalized();
|
||||
float distance = FLT_MAX;
|
||||
|
||||
AZ::Vector3 normalLocal;
|
||||
|
||||
if (meshAsset.LocalRayIntersectionAgainstModel(rayOriginLocal, rayDirectionLocal, distance, normalLocal))
|
||||
{
|
||||
// Transform everything back to world space
|
||||
outPosition = meshTransform.TransformPoint(rayOriginLocal + (rayDirectionLocal * distance));
|
||||
outNormal = meshTransform.TransformVector(normalLocal);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -82,7 +82,6 @@ namespace SurfaceData
|
||||
->Constructor()
|
||||
->Constructor<const AZStd::string&>()
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(AZ::Script::Attributes::Category, "Vegetation")
|
||||
->Attribute(AZ::Script::Attributes::Module, "surface_data")
|
||||
->Method("SetTag", &SurfaceTag::SetTag)
|
||||
|
||||
Reference in New Issue
Block a user