LYN-7693 Rename and move vegetation reference shape.
Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>
This commit is contained in:
@@ -104,6 +104,8 @@
|
||||
#include <Editor/Nodes/UI/GradientPreviewThumbnailItem.h>
|
||||
#include <EditorLandscapeCanvasComponent.h>
|
||||
|
||||
#include <LmbrCentral/Shape/ReferenceShapeComponentBus.h>
|
||||
|
||||
namespace LandscapeCanvasEditor
|
||||
{
|
||||
static const int NODE_OFFSET_X_PIXELS = 350;
|
||||
@@ -1303,7 +1305,7 @@ namespace LandscapeCanvasEditor
|
||||
}
|
||||
|
||||
// Special case for the Vegetation Area Placement Bounds, the slot actually represents a separate
|
||||
// Vegetation Reference Shape or actual Shape component on the same Entity
|
||||
// Reference Shape or actual Shape component on the same Entity
|
||||
AZ::Component* component = nullptr;
|
||||
auto targetBaseNode = static_cast<LandscapeCanvas::BaseNode*>(targetNode.get());
|
||||
if (targetBaseNode->GetBaseNodeType() == LandscapeCanvas::BaseNode::BaseNodeType::VegetationArea && targetSlot->GetName() == LandscapeCanvas::PLACEMENT_BOUNDS_SLOT_ID)
|
||||
@@ -1379,7 +1381,7 @@ namespace LandscapeCanvasEditor
|
||||
AzToolsFramework::EditorDisabledCompositionRequestBus::Event(targetEntityId, &AzToolsFramework::EditorDisabledCompositionRequests::GetDisabledComponents, disabledComponents);
|
||||
for (auto disabledComponent : disabledComponents)
|
||||
{
|
||||
if (disabledComponent->RTTI_GetType() == Vegetation::EditorReferenceShapeComponentTypeId)
|
||||
if (disabledComponent->RTTI_GetType() == LmbrCentral::EditorReferenceShapeComponentTypeId)
|
||||
{
|
||||
component = disabledComponent;
|
||||
|
||||
@@ -1401,7 +1403,7 @@ namespace LandscapeCanvasEditor
|
||||
// If 'component' is still null then that means there is no Reference Shape component on our Entity, so we need to add one
|
||||
if (!component)
|
||||
{
|
||||
AZ::ComponentId componentId = AddComponentTypeIdToEntity(targetEntityId, Vegetation::EditorReferenceShapeComponentTypeId);
|
||||
AZ::ComponentId componentId = AddComponentTypeIdToEntity(targetEntityId, LmbrCentral::EditorReferenceShapeComponentTypeId);
|
||||
|
||||
component = targetEntity->FindComponent(componentId);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "BaseAreaNode.h"
|
||||
#include <Editor/Core/GraphContext.h>
|
||||
|
||||
#include <LmbrCentral/Shape/ReferenceShapeComponentBus.h>
|
||||
|
||||
namespace LandscapeCanvas
|
||||
{
|
||||
void BaseAreaNode::Reflect(AZ::ReflectContext* context)
|
||||
@@ -61,7 +63,7 @@ namespace LandscapeCanvas
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AZ::Component* component = entity->FindComponent(Vegetation::EditorReferenceShapeComponentTypeId);
|
||||
AZ::Component* component = entity->FindComponent(LmbrCentral::EditorReferenceShapeComponentTypeId);
|
||||
if (component)
|
||||
{
|
||||
return component;
|
||||
|
||||
@@ -56,5 +56,73 @@ namespace UnitTest
|
||||
MOCK_METHOD1(GenerateRandomPointInside, AZ::Vector3(AZ::RandomDistributionType randomDistribution));
|
||||
MOCK_METHOD3(IntersectRay, bool(const AZ::Vector3& src, const AZ::Vector3& dir, float& distance));
|
||||
};
|
||||
|
||||
class MockShape : public LmbrCentral::ShapeComponentRequestsBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ::Entity m_entity;
|
||||
mutable int m_count = 0;
|
||||
|
||||
MockShape()
|
||||
{
|
||||
LmbrCentral::ShapeComponentRequestsBus::Handler::BusConnect(m_entity.GetId());
|
||||
}
|
||||
|
||||
~MockShape()
|
||||
{
|
||||
LmbrCentral::ShapeComponentRequestsBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
AZ::Crc32 GetShapeType() override
|
||||
{
|
||||
++m_count;
|
||||
return AZ_CRC("TestShape", 0x856ca50c);
|
||||
}
|
||||
|
||||
AZ::Aabb m_aabb = AZ::Aabb::CreateNull();
|
||||
AZ::Aabb GetEncompassingAabb() override
|
||||
{
|
||||
++m_count;
|
||||
return m_aabb;
|
||||
}
|
||||
|
||||
AZ::Transform m_localTransform = AZ::Transform::CreateIdentity();
|
||||
AZ::Aabb m_localBounds = AZ::Aabb::CreateNull();
|
||||
void GetTransformAndLocalBounds(AZ::Transform& transform, AZ::Aabb& bounds) override
|
||||
{
|
||||
++m_count;
|
||||
transform = m_localTransform;
|
||||
bounds = m_localBounds;
|
||||
}
|
||||
|
||||
bool m_pointInside = true;
|
||||
bool IsPointInside([[maybe_unused]] const AZ::Vector3& point) override
|
||||
{
|
||||
++m_count;
|
||||
return m_pointInside;
|
||||
}
|
||||
|
||||
float m_distanceSquaredFromPoint = 0.0f;
|
||||
float DistanceSquaredFromPoint([[maybe_unused]] const AZ::Vector3& point) override
|
||||
{
|
||||
++m_count;
|
||||
return m_distanceSquaredFromPoint;
|
||||
}
|
||||
|
||||
AZ::Vector3 m_randomPointInside = AZ::Vector3::CreateZero();
|
||||
AZ::Vector3 GenerateRandomPointInside([[maybe_unused]] AZ::RandomDistributionType randomDistribution) override
|
||||
{
|
||||
++m_count;
|
||||
return m_randomPointInside;
|
||||
}
|
||||
|
||||
bool m_intersectRay = false;
|
||||
bool IntersectRay(
|
||||
[[maybe_unused]] const AZ::Vector3& src, [[maybe_unused]] const AZ::Vector3& dir, [[maybe_unused]] float& distance) override
|
||||
{
|
||||
++m_count;
|
||||
return m_intersectRay;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
#include "Shape/CompoundShapeComponent.h"
|
||||
#include "Shape/SplineComponent.h"
|
||||
#include "Shape/PolygonPrismShapeComponent.h"
|
||||
#include "Shape/ReferenceShapeComponent.h"
|
||||
|
||||
namespace LmbrCentral
|
||||
{
|
||||
@@ -203,6 +204,7 @@ namespace LmbrCentral
|
||||
CapsuleShapeComponent::CreateDescriptor(),
|
||||
TubeShapeComponent::CreateDescriptor(),
|
||||
CompoundShapeComponent::CreateDescriptor(),
|
||||
ReferenceShapeComponent::CreateDescriptor(),
|
||||
SplineComponent::CreateDescriptor(),
|
||||
PolygonPrismShapeComponent::CreateDescriptor(),
|
||||
NavigationSystemComponent::CreateDescriptor(),
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "Shape/EditorSplineComponent.h"
|
||||
#include "Shape/EditorTubeShapeComponent.h"
|
||||
#include "Shape/EditorPolygonPrismShapeComponent.h"
|
||||
#include "Shape/EditorReferenceShapeComponent.h"
|
||||
#include "Editor/EditorCommentComponent.h"
|
||||
|
||||
#include "Shape/EditorCompoundShapeComponent.h"
|
||||
@@ -73,6 +74,7 @@ namespace LmbrCentral
|
||||
EditorCylinderShapeComponent::CreateDescriptor(),
|
||||
EditorCapsuleShapeComponent::CreateDescriptor(),
|
||||
EditorCompoundShapeComponent::CreateDescriptor(),
|
||||
EditorReferenceShapeComponent::CreateDescriptor(),
|
||||
EditorSplineComponent::CreateDescriptor(),
|
||||
EditorPolygonPrismShapeComponent::CreateDescriptor(),
|
||||
EditorCommentComponent::CreateDescriptor(),
|
||||
|
||||
+3
-2
@@ -10,11 +10,12 @@
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <LmbrCentral/Dependency/DependencyNotificationBus.h>
|
||||
#include<LmbrCentral/Component/EditorWrappedComponentBase.h>
|
||||
|
||||
namespace Vegetation
|
||||
namespace LmbrCentral
|
||||
{
|
||||
void EditorReferenceShapeComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
ReflectSubClass<EditorReferenceShapeComponent, BaseClassType>(context, 1, &EditorVegetationComponentBaseVersionConverter<typename BaseClassType::WrappedComponentType, typename BaseClassType::WrappedConfigType>);
|
||||
ReflectSubClass<EditorReferenceShapeComponent, BaseClassType>(context, 1, &EditorWrappedComponentBaseVersionConverter<typename BaseClassType::WrappedComponentType, typename BaseClassType::WrappedConfigType, 1>);
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -8,24 +8,24 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Components/ReferenceShapeComponent.h>
|
||||
#include <Vegetation/Editor/EditorVegetationComponentBase.h>
|
||||
#include<LmbrCentral/Component/EditorWrappedComponentBase.h>
|
||||
#include <Shape/ReferenceShapeComponent.h>
|
||||
|
||||
namespace Vegetation
|
||||
namespace LmbrCentral
|
||||
{
|
||||
class EditorReferenceShapeComponent
|
||||
: public EditorVegetationComponentBase<ReferenceShapeComponent, ReferenceShapeConfig>
|
||||
: public EditorWrappedComponentBase<ReferenceShapeComponent, ReferenceShapeConfig>
|
||||
{
|
||||
public:
|
||||
using BaseClassType = EditorVegetationComponentBase<ReferenceShapeComponent, ReferenceShapeConfig>;
|
||||
using BaseClassType = EditorWrappedComponentBase<ReferenceShapeComponent, ReferenceShapeConfig>;
|
||||
AZ_EDITOR_COMPONENT(EditorReferenceShapeComponent, EditorReferenceShapeComponentTypeId, BaseClassType);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
static constexpr const char* const s_categoryName = "Vegetation";
|
||||
static constexpr const char* const s_componentName = "Vegetation Reference Shape";
|
||||
static constexpr const char* const s_categoryName = "Shape";
|
||||
static constexpr const char* const s_componentName = "Reference Shape";
|
||||
static constexpr const char* const s_componentDescription = "Enables the entity to reference and reuse shape entities";
|
||||
static constexpr const char* const s_icon = "Editor/Icons/Components/Vegetation.svg";
|
||||
static constexpr const char* const s_viewportIcon = "Editor/Icons/Components/Viewport/Vegetation.svg";
|
||||
static constexpr const char* const s_viewportIcon = "Icons/Components/Viewport/Component_Placeholder.svg";
|
||||
static constexpr const char* const s_helpUrl = "https://o3de.org/docs/user-guide/components/reference/";
|
||||
};
|
||||
}
|
||||
+2
-2
@@ -11,7 +11,7 @@
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
namespace Vegetation
|
||||
namespace LmbrCentral
|
||||
{
|
||||
void ReferenceShapeConfig::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
@@ -27,7 +27,7 @@ namespace Vegetation
|
||||
if (edit)
|
||||
{
|
||||
edit->Class<ReferenceShapeConfig>(
|
||||
"Vegetation Reference Shape", "")
|
||||
"Reference Shape", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
+1
-4
@@ -12,16 +12,13 @@
|
||||
#include <AzCore/Component/EntityBus.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <LmbrCentral/Shape/ShapeComponentBus.h>
|
||||
#include <Vegetation/Ebuses/ReferenceShapeRequestBus.h>
|
||||
#include <LmbrCentral/Shape/ReferenceShapeComponentBus.h>
|
||||
|
||||
namespace LmbrCentral
|
||||
{
|
||||
template<typename, typename>
|
||||
class EditorWrappedComponentBase;
|
||||
}
|
||||
|
||||
namespace Vegetation
|
||||
{
|
||||
class ReferenceShapeConfig
|
||||
: public AZ::ComponentConfig
|
||||
{
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <AzCore/Component/ComponentApplication.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <AzCore/Math/Random.h>
|
||||
#include <AzCore/Memory/MemoryComponent.h>
|
||||
|
||||
#include <LmbrCentral/Shape/MockShapes.h>
|
||||
#include <Shape/ReferenceShapeComponent.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class ReferenceComponentTests
|
||||
: public AllocatorsFixture
|
||||
{
|
||||
protected:
|
||||
AZ::ComponentApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AZ::ComponentApplication::Descriptor appDesc;
|
||||
appDesc.m_memoryBlocksByteSize = 20 * 1024 * 1024;
|
||||
appDesc.m_recordingMode = AZ::Debug::AllocationRecords::RECORD_NO_RECORDS;
|
||||
appDesc.m_stackRecordLevels = 20;
|
||||
|
||||
m_app.Create(appDesc);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Destroy();
|
||||
}
|
||||
|
||||
template<typename Component, typename Configuration>
|
||||
AZStd::unique_ptr<AZ::Entity> CreateEntity(const Configuration& config, Component** ppComponent)
|
||||
{
|
||||
m_app.RegisterComponentDescriptor(Component::CreateDescriptor());
|
||||
|
||||
auto entity = AZStd::make_unique<AZ::Entity>();
|
||||
|
||||
if (ppComponent)
|
||||
{
|
||||
*ppComponent = entity->CreateComponent<Component>(config);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity->CreateComponent<Component>(config);
|
||||
}
|
||||
|
||||
entity->Init();
|
||||
EXPECT_EQ(AZ::Entity::State::Init, entity->GetState());
|
||||
|
||||
entity->Activate();
|
||||
EXPECT_EQ(AZ::Entity::State::Active, entity->GetState());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
template<typename ComponentA, typename ComponentB>
|
||||
bool IsComponentCompatible()
|
||||
{
|
||||
AZ::ComponentDescriptor::DependencyArrayType providedServicesA;
|
||||
ComponentA::GetProvidedServices(providedServicesA);
|
||||
|
||||
AZ::ComponentDescriptor::DependencyArrayType incompatibleServicesB;
|
||||
ComponentB::GetIncompatibleServices(incompatibleServicesB);
|
||||
|
||||
for (auto providedServiceA : providedServicesA)
|
||||
{
|
||||
for (auto incompatibleServiceB : incompatibleServicesB)
|
||||
{
|
||||
if (providedServiceA == incompatibleServiceB)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename ComponentA, typename ComponentB>
|
||||
bool AreComponentsCompatible()
|
||||
{
|
||||
return IsComponentCompatible<ComponentA, ComponentB>() && IsComponentCompatible<ComponentB, ComponentA>();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ReferenceComponentTests, VerifyCompatibility)
|
||||
{
|
||||
EXPECT_FALSE((AreComponentsCompatible<LmbrCentral::ReferenceShapeComponent, LmbrCentral::ReferenceShapeComponent>()));
|
||||
}
|
||||
|
||||
TEST_F(ReferenceComponentTests, ReferenceShapeComponent_WithValidReference)
|
||||
{
|
||||
UnitTest::MockShape testShape;
|
||||
|
||||
LmbrCentral::ReferenceShapeConfig config;
|
||||
config.m_shapeEntityId = testShape.m_entity.GetId();
|
||||
|
||||
LmbrCentral::ReferenceShapeComponent* component;
|
||||
auto entity = CreateEntity(config, &component);
|
||||
|
||||
AZ::RandomDistributionType randomDistribution = AZ::RandomDistributionType::Normal;
|
||||
AZ::Vector3 randPos = AZ::Vector3::CreateOne();
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
randPos, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GenerateRandomPointInside, randomDistribution);
|
||||
EXPECT_EQ(AZ::Vector3::CreateZero(), randPos);
|
||||
|
||||
testShape.m_aabb = AZ::Aabb::CreateFromPoint(AZ::Vector3(1.0f, 21.0f, 31.0f));
|
||||
AZ::Aabb resultAABB;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
resultAABB, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetEncompassingAabb);
|
||||
EXPECT_EQ(testShape.m_aabb, resultAABB);
|
||||
|
||||
AZ::Crc32 resultCRC = {};
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
resultCRC, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetShapeType);
|
||||
EXPECT_EQ(AZ_CRC("TestShape", 0x856ca50c), resultCRC);
|
||||
|
||||
testShape.m_localBounds = AZ::Aabb::CreateFromPoint(AZ::Vector3(1.0f, 21.0f, 31.0f));
|
||||
testShape.m_localTransform = AZ::Transform::CreateTranslation(testShape.m_localBounds.GetCenter());
|
||||
AZ::Transform resultTransform = AZ::Transform::CreateIdentity();
|
||||
AZ::Aabb resultBounds = AZ::Aabb::CreateNull();
|
||||
LmbrCentral::ShapeComponentRequestsBus::Event(
|
||||
entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetTransformAndLocalBounds, resultTransform, resultBounds);
|
||||
EXPECT_EQ(testShape.m_localTransform, resultTransform);
|
||||
EXPECT_EQ(testShape.m_localBounds, resultBounds);
|
||||
|
||||
testShape.m_pointInside = true;
|
||||
bool resultPointInside = false;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
resultPointInside, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::IsPointInside, AZ::Vector3::CreateZero());
|
||||
EXPECT_EQ(testShape.m_pointInside, resultPointInside);
|
||||
|
||||
testShape.m_distanceSquaredFromPoint = 456.0f;
|
||||
float resultdistanceSquaredFromPoint = 0;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
resultdistanceSquaredFromPoint, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::DistanceSquaredFromPoint,
|
||||
AZ::Vector3::CreateZero());
|
||||
EXPECT_EQ(testShape.m_distanceSquaredFromPoint, resultdistanceSquaredFromPoint);
|
||||
|
||||
testShape.m_intersectRay = false;
|
||||
bool resultIntersectRay = false;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
resultIntersectRay, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::IntersectRay, AZ::Vector3::CreateZero(),
|
||||
AZ::Vector3::CreateZero(), 0.0f);
|
||||
EXPECT_TRUE(testShape.m_intersectRay == resultIntersectRay);
|
||||
}
|
||||
|
||||
TEST_F(ReferenceComponentTests, ReferenceShapeComponent_WithInvalidReference)
|
||||
{
|
||||
LmbrCentral::ReferenceShapeConfig config;
|
||||
config.m_shapeEntityId = AZ::EntityId();
|
||||
|
||||
LmbrCentral::ReferenceShapeComponent* component;
|
||||
auto entity = CreateEntity(config, &component);
|
||||
|
||||
AZ::RandomDistributionType randomDistribution = AZ::RandomDistributionType::Normal;
|
||||
AZ::Vector3 randPos = AZ::Vector3::CreateOne();
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
randPos, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GenerateRandomPointInside, randomDistribution);
|
||||
EXPECT_EQ(randPos, AZ::Vector3::CreateZero());
|
||||
|
||||
AZ::Aabb resultAABB;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
resultAABB, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetEncompassingAabb);
|
||||
EXPECT_EQ(resultAABB, AZ::Aabb::CreateNull());
|
||||
|
||||
AZ::Crc32 resultCRC;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
resultCRC, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetShapeType);
|
||||
EXPECT_EQ(resultCRC, AZ::Crc32(AZ::u32(0)));
|
||||
|
||||
AZ::Transform resultTransform;
|
||||
AZ::Aabb resultBounds;
|
||||
LmbrCentral::ShapeComponentRequestsBus::Event(
|
||||
entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetTransformAndLocalBounds, resultTransform, resultBounds);
|
||||
EXPECT_EQ(resultTransform, AZ::Transform::CreateIdentity());
|
||||
EXPECT_EQ(resultBounds, AZ::Aabb::CreateNull());
|
||||
|
||||
bool resultPointInside = true;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
resultPointInside, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::IsPointInside, AZ::Vector3::CreateZero());
|
||||
EXPECT_EQ(resultPointInside, false);
|
||||
|
||||
float resultdistanceSquaredFromPoint = 0;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
resultdistanceSquaredFromPoint, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::DistanceSquaredFromPoint,
|
||||
AZ::Vector3::CreateZero());
|
||||
EXPECT_EQ(resultdistanceSquaredFromPoint, FLT_MAX);
|
||||
|
||||
bool resultIntersectRay = true;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(
|
||||
resultIntersectRay, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::IntersectRay, AZ::Vector3::CreateZero(),
|
||||
AZ::Vector3::CreateZero(), 0.0f);
|
||||
EXPECT_EQ(resultIntersectRay, false);
|
||||
}
|
||||
} // namespace UnitTest
|
||||
+4
-1
@@ -11,8 +11,11 @@
|
||||
#include <AzCore/Component/ComponentBus.h>
|
||||
#include <AzCore/Component/EntityId.h>
|
||||
|
||||
namespace Vegetation
|
||||
namespace LmbrCentral
|
||||
{
|
||||
// Type ID for Reference EditorReferenceShapeComponent
|
||||
static const char* EditorReferenceShapeComponentTypeId = "{21BC79CA-C2F4-428F-AF2E-B76E233D4254}";
|
||||
|
||||
class ReferenceShapeRequests
|
||||
: public AZ::ComponentBus
|
||||
{
|
||||
@@ -60,6 +60,8 @@ set(FILES
|
||||
Source/Shape/EditorCompoundShapeComponent.cpp
|
||||
Source/Shape/EditorQuadShapeComponent.h
|
||||
Source/Shape/EditorQuadShapeComponent.cpp
|
||||
Source/Shape/EditorReferenceShapeComponent.h
|
||||
Source/Shape/EditorReferenceShapeComponent.cpp
|
||||
Source/Shape/EditorSplineComponent.h
|
||||
Source/Shape/EditorSplineComponent.cpp
|
||||
Source/Shape/EditorSplineComponentMode.h
|
||||
|
||||
@@ -57,6 +57,7 @@ set(FILES
|
||||
include/LmbrCentral/Shape/SplineComponentBus.h
|
||||
include/LmbrCentral/Shape/PolygonPrismShapeComponentBus.h
|
||||
include/LmbrCentral/Shape/TubeShapeComponentBus.h
|
||||
include/LmbrCentral/Shape/ReferenceShapeComponentBus.h
|
||||
include/LmbrCentral/Shape/SplineAttribute.h
|
||||
include/LmbrCentral/Shape/SplineAttribute.inl
|
||||
include/LmbrCentral/Terrain/TerrainSystemRequestBus.h
|
||||
@@ -140,6 +141,8 @@ set(FILES
|
||||
Source/Shape/PolygonPrismShapeComponent.cpp
|
||||
Source/Shape/TubeShapeComponent.h
|
||||
Source/Shape/TubeShapeComponent.cpp
|
||||
Source/Shape/ReferenceShapeComponent.h
|
||||
Source/Shape/ReferenceShapeComponent.cpp
|
||||
Source/Shape/ShapeComponentConverters.h
|
||||
Source/Shape/ShapeComponentConverters.cpp
|
||||
Source/Shape/ShapeComponentConverters.inl
|
||||
|
||||
@@ -24,5 +24,6 @@ set(FILES
|
||||
Tests/SpawnerComponentTest.cpp
|
||||
Tests/SplineComponentTests.cpp
|
||||
Tests/DiskShapeTest.cpp
|
||||
Tests/ReferenceShapeTests.cpp
|
||||
Source/LmbrCentral.cpp
|
||||
)
|
||||
|
||||
@@ -35,7 +35,4 @@ namespace Vegetation
|
||||
|
||||
// Vegetation Area Selectors
|
||||
static const char* EditorDescriptorWeightSelectorComponentTypeId = "{0FB90550-149B-4E05-B22C-2753F6526E97}";
|
||||
|
||||
// Vegetation Reference Shape
|
||||
static const char* EditorReferenceShapeComponentTypeId = "{21BC79CA-C2F4-428F-AF2E-B76E233D4254}";
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <Editor/EditorLevelSettingsComponent.h>
|
||||
#include <Editor/EditorMeshBlockerComponent.h>
|
||||
#include <Editor/EditorPositionModifierComponent.h>
|
||||
#include <Editor/EditorReferenceShapeComponent.h>
|
||||
#include <Editor/EditorRotationModifierComponent.h>
|
||||
#include <Editor/EditorScaleModifierComponent.h>
|
||||
#include <Editor/EditorShapeIntersectionFilterComponent.h>
|
||||
@@ -50,7 +49,6 @@ namespace Vegetation
|
||||
EditorLevelSettingsComponent::CreateDescriptor(),
|
||||
EditorMeshBlockerComponent::CreateDescriptor(),
|
||||
EditorPositionModifierComponent::CreateDescriptor(),
|
||||
EditorReferenceShapeComponent::CreateDescriptor(),
|
||||
EditorRotationModifierComponent::CreateDescriptor(),
|
||||
EditorScaleModifierComponent::CreateDescriptor(),
|
||||
EditorShapeIntersectionFilterComponent::CreateDescriptor(),
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <Components/LevelSettingsComponent.h>
|
||||
#include <Components/MeshBlockerComponent.h>
|
||||
#include <Components/PositionModifierComponent.h>
|
||||
#include <Components/ReferenceShapeComponent.h>
|
||||
#include <Components/RotationModifierComponent.h>
|
||||
#include <Components/ScaleModifierComponent.h>
|
||||
#include <Components/ShapeIntersectionFilterComponent.h>
|
||||
@@ -52,7 +51,6 @@ namespace Vegetation
|
||||
LevelSettingsComponent::CreateDescriptor(),
|
||||
MeshBlockerComponent::CreateDescriptor(),
|
||||
PositionModifierComponent::CreateDescriptor(),
|
||||
ReferenceShapeComponent::CreateDescriptor(),
|
||||
RotationModifierComponent::CreateDescriptor(),
|
||||
ScaleModifierComponent::CreateDescriptor(),
|
||||
ShapeIntersectionFilterComponent::CreateDescriptor(),
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <Source/Components/LevelSettingsComponent.h>
|
||||
#include <Source/Components/MeshBlockerComponent.h>
|
||||
#include <Source/Components/PositionModifierComponent.h>
|
||||
#include <Source/Components/ReferenceShapeComponent.h>
|
||||
#include <Source/Components/RotationModifierComponent.h>
|
||||
#include <Source/Components/ScaleModifierComponent.h>
|
||||
#include <Source/Components/ShapeIntersectionFilterComponent.h>
|
||||
@@ -190,8 +189,6 @@ namespace UnitTest
|
||||
EXPECT_FALSE((AreComponentsCompatible<Vegetation::RotationModifierComponent, Vegetation::RotationModifierComponent>()));
|
||||
EXPECT_FALSE((AreComponentsCompatible<Vegetation::ScaleModifierComponent, Vegetation::ScaleModifierComponent>()));
|
||||
|
||||
EXPECT_FALSE((AreComponentsCompatible<Vegetation::ReferenceShapeComponent, Vegetation::ReferenceShapeComponent>()));
|
||||
|
||||
EXPECT_FALSE((AreComponentsCompatible<Vegetation::DescriptorListComponent, Vegetation::DescriptorListComponent>()));
|
||||
EXPECT_FALSE((AreComponentsCompatible<Vegetation::DescriptorListComponent, Vegetation::DescriptorListCombinerComponent>()));
|
||||
|
||||
@@ -231,7 +228,6 @@ namespace UnitTest
|
||||
CreateWith<Vegetation::LevelSettingsComponent, MockVegetationAreaServiceComponent>();
|
||||
CreateWith<Vegetation::MeshBlockerComponent, MockMeshServiceComponent>();
|
||||
CreateWith<Vegetation::PositionModifierComponent, MockVegetationAreaServiceComponent>();
|
||||
CreateWith<Vegetation::ReferenceShapeComponent, MockVegetationAreaServiceComponent>();
|
||||
CreateWith<Vegetation::RotationModifierComponent, MockVegetationAreaServiceComponent>();
|
||||
CreateWith<Vegetation::ScaleModifierComponent, MockVegetationAreaServiceComponent>();
|
||||
CreateWith<Vegetation::ShapeIntersectionFilterComponent, MockVegetationAreaServiceComponent>();
|
||||
@@ -287,94 +283,6 @@ namespace UnitTest
|
||||
EXPECT_EQ(defaultProcessTime, instConfig->m_maxInstanceProcessTimeMicroseconds);
|
||||
}
|
||||
|
||||
TEST_F(VegetationComponentTestsBasics, ReferenceShapeComponent_WithValidReference)
|
||||
{
|
||||
UnitTest::MockShape testShape;
|
||||
|
||||
Vegetation::ReferenceShapeConfig config;
|
||||
config.m_shapeEntityId = testShape.m_entity.GetId();
|
||||
|
||||
Vegetation::ReferenceShapeComponent* component;
|
||||
auto entity = CreateEntity(config, &component);
|
||||
|
||||
AZ::RandomDistributionType randomDistribution = AZ::RandomDistributionType::Normal;
|
||||
AZ::Vector3 randPos = AZ::Vector3::CreateOne();
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(randPos, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GenerateRandomPointInside, randomDistribution);
|
||||
EXPECT_EQ(AZ::Vector3::CreateZero(), randPos);
|
||||
|
||||
testShape.m_aabb = AZ::Aabb::CreateFromPoint(AZ::Vector3(1.0f, 21.0f, 31.0f));
|
||||
AZ::Aabb resultAABB;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(resultAABB, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetEncompassingAabb);
|
||||
EXPECT_EQ(testShape.m_aabb, resultAABB);
|
||||
|
||||
AZ::Crc32 resultCRC = {};
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(resultCRC, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetShapeType);
|
||||
EXPECT_EQ(AZ_CRC("TestShape", 0x856ca50c), resultCRC);
|
||||
|
||||
testShape.m_localBounds = AZ::Aabb::CreateFromPoint(AZ::Vector3(1.0f, 21.0f, 31.0f));
|
||||
testShape.m_localTransform = AZ::Transform::CreateTranslation(testShape.m_localBounds.GetCenter());
|
||||
AZ::Transform resultTransform = AZ::Transform::CreateIdentity();
|
||||
AZ::Aabb resultBounds = AZ::Aabb::CreateNull();
|
||||
LmbrCentral::ShapeComponentRequestsBus::Event(entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetTransformAndLocalBounds, resultTransform, resultBounds);
|
||||
EXPECT_EQ(testShape.m_localTransform, resultTransform);
|
||||
EXPECT_EQ(testShape.m_localBounds, resultBounds);
|
||||
|
||||
testShape.m_pointInside = true;
|
||||
bool resultPointInside = false;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(resultPointInside, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::IsPointInside, AZ::Vector3::CreateZero());
|
||||
EXPECT_EQ(testShape.m_pointInside, resultPointInside);
|
||||
|
||||
testShape.m_distanceSquaredFromPoint = 456.0f;
|
||||
float resultdistanceSquaredFromPoint = 0;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(resultdistanceSquaredFromPoint, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::DistanceSquaredFromPoint, AZ::Vector3::CreateZero());
|
||||
EXPECT_EQ(testShape.m_distanceSquaredFromPoint, resultdistanceSquaredFromPoint);
|
||||
|
||||
testShape.m_intersectRay = false;
|
||||
bool resultIntersectRay = false;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(resultIntersectRay, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::IntersectRay, AZ::Vector3::CreateZero(), AZ::Vector3::CreateZero(), 0.0f);
|
||||
EXPECT_TRUE(testShape.m_intersectRay == resultIntersectRay);
|
||||
}
|
||||
|
||||
TEST_F(VegetationComponentTestsBasics, ReferenceShapeComponent_WithInvalidReference)
|
||||
{
|
||||
Vegetation::ReferenceShapeConfig config;
|
||||
config.m_shapeEntityId = AZ::EntityId();
|
||||
|
||||
Vegetation::ReferenceShapeComponent* component;
|
||||
auto entity = CreateEntity(config, &component);
|
||||
|
||||
AZ::RandomDistributionType randomDistribution = AZ::RandomDistributionType::Normal;
|
||||
AZ::Vector3 randPos = AZ::Vector3::CreateOne();
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(randPos, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GenerateRandomPointInside, randomDistribution);
|
||||
EXPECT_EQ(randPos, AZ::Vector3::CreateZero());
|
||||
|
||||
AZ::Aabb resultAABB;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(resultAABB, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetEncompassingAabb);
|
||||
EXPECT_EQ(resultAABB, AZ::Aabb::CreateNull());
|
||||
|
||||
AZ::Crc32 resultCRC;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(resultCRC, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetShapeType);
|
||||
EXPECT_EQ(resultCRC, AZ::Crc32(AZ::u32(0)));
|
||||
|
||||
AZ::Transform resultTransform;
|
||||
AZ::Aabb resultBounds;
|
||||
LmbrCentral::ShapeComponentRequestsBus::Event(entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::GetTransformAndLocalBounds, resultTransform, resultBounds);
|
||||
EXPECT_EQ(resultTransform, AZ::Transform::CreateIdentity());
|
||||
EXPECT_EQ(resultBounds, AZ::Aabb::CreateNull());
|
||||
|
||||
bool resultPointInside = true;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(resultPointInside, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::IsPointInside, AZ::Vector3::CreateZero());
|
||||
EXPECT_EQ(resultPointInside, false);
|
||||
|
||||
float resultdistanceSquaredFromPoint = 0;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(resultdistanceSquaredFromPoint, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::DistanceSquaredFromPoint, AZ::Vector3::CreateZero());
|
||||
EXPECT_EQ(resultdistanceSquaredFromPoint, FLT_MAX);
|
||||
|
||||
bool resultIntersectRay = true;
|
||||
LmbrCentral::ShapeComponentRequestsBus::EventResult(resultIntersectRay, entity->GetId(), &LmbrCentral::ShapeComponentRequestsBus::Events::IntersectRay, AZ::Vector3::CreateZero(), AZ::Vector3::CreateZero(), 0.0f);
|
||||
EXPECT_EQ(resultIntersectRay, false);
|
||||
}
|
||||
|
||||
TEST_F(VegetationComponentTestsBasics, Components_HaveMinMaxRanges)
|
||||
{
|
||||
ValidateHasMinMaxRanges<Vegetation::AreaSystemConfig>();
|
||||
|
||||
@@ -36,8 +36,6 @@ set(FILES
|
||||
Source/Editor/EditorMeshBlockerComponent.h
|
||||
Source/Editor/EditorPositionModifierComponent.cpp
|
||||
Source/Editor/EditorPositionModifierComponent.h
|
||||
Source/Editor/EditorReferenceShapeComponent.cpp
|
||||
Source/Editor/EditorReferenceShapeComponent.h
|
||||
Source/Editor/EditorRotationModifierComponent.cpp
|
||||
Source/Editor/EditorRotationModifierComponent.h
|
||||
Source/Editor/EditorScaleModifierComponent.cpp
|
||||
|
||||
@@ -46,7 +46,6 @@ set(FILES
|
||||
Include/Vegetation/Ebuses/AreaBlenderRequestBus.h
|
||||
Include/Vegetation/Ebuses/BlockerRequestBus.h
|
||||
Include/Vegetation/Ebuses/DescriptorListCombinerRequestBus.h
|
||||
Include/Vegetation/Ebuses/ReferenceShapeRequestBus.h
|
||||
Include/Vegetation/Ebuses/MeshBlockerRequestBus.h
|
||||
Include/Vegetation/Ebuses/SpawnerRequestBus.h
|
||||
Include/Vegetation/Ebuses/DescriptorListRequestBus.h
|
||||
@@ -71,8 +70,6 @@ set(FILES
|
||||
Source/Components/MeshBlockerComponent.h
|
||||
Source/Components/PositionModifierComponent.cpp
|
||||
Source/Components/PositionModifierComponent.h
|
||||
Source/Components/ReferenceShapeComponent.cpp
|
||||
Source/Components/ReferenceShapeComponent.h
|
||||
Source/Components/RotationModifierComponent.cpp
|
||||
Source/Components/RotationModifierComponent.h
|
||||
Source/Components/ScaleModifierComponent.cpp
|
||||
|
||||
Reference in New Issue
Block a user