Merge pull request #5908 from aws-lumberyard-dev/terrain/sphrose/reference_shape
LYN-7693 Rename and move vegetation reference shape.
This commit is contained in:
@@ -393,7 +393,7 @@ class AtomComponentProperties:
|
||||
'name': 'PostFX Shape Weight Modifier',
|
||||
'requires': [AtomComponentProperties.postfx_layer()],
|
||||
'shapes': ['Axis Aligned Box Shape', 'Box Shape', 'Capsule Shape', 'Compound Shape', 'Cylinder Shape',
|
||||
'Disk Shape', 'Polygon Prism Shape', 'Quad Shape', 'Sphere Shape', 'Vegetation Reference Shape'],
|
||||
'Disk Shape', 'Polygon Prism Shape', 'Quad Shape', 'Sphere Shape', 'Shape Reference'],
|
||||
}
|
||||
return properties[property]
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ def Terrain_SupportsPhysics():
|
||||
|
||||
# 2) Create 2 test entities, one parent at 512.0, 512.0, 50.0 and one child at the default position and add the required components
|
||||
entity1_components_to_add = ["Axis Aligned Box Shape", "Terrain Layer Spawner", "Terrain Height Gradient List", "Terrain Physics Heightfield Collider", "PhysX Heightfield Collider"]
|
||||
entity2_components_to_add = ["Vegetation Reference Shape", "Gradient Transform Modifier", "FastNoise Gradient"]
|
||||
entity2_components_to_add = ["Shape Reference", "Gradient Transform Modifier", "FastNoise Gradient"]
|
||||
ball_components_to_add = ["Sphere Shape", "PhysX Collider", "PhysX Rigid Body"]
|
||||
terrain_spawner_entity = hydra.Entity("TestEntity1")
|
||||
terrain_spawner_entity.create_entity(azmath.Vector3(512.0, 512.0, 50.0), entity1_components_to_add)
|
||||
|
||||
+2
-2
@@ -78,7 +78,7 @@ def LayerSpawner_InheritBehaviorFlag():
|
||||
# Create Vegetation area and assign a valid asset
|
||||
veg_1 = hydra.Entity("veg_1")
|
||||
veg_1.create_entity(
|
||||
position, ["Vegetation Layer Spawner", "Vegetation Reference Shape", "Vegetation Asset List"]
|
||||
position, ["Vegetation Layer Spawner", "Shape Reference", "Vegetation Asset List"]
|
||||
)
|
||||
set_dynamic_slice_asset(veg_1, 2, os.path.join("Slices", "PinkFlower.dynamicslice"))
|
||||
veg_1.get_set_test(1, "Configuration|Shape Entity Id", blender_entity.id)
|
||||
@@ -86,7 +86,7 @@ def LayerSpawner_InheritBehaviorFlag():
|
||||
# Create second vegetation area and assign a valid asset
|
||||
veg_2 = hydra.Entity("veg_2")
|
||||
veg_2.create_entity(
|
||||
position, ["Vegetation Layer Spawner", "Vegetation Reference Shape", "Vegetation Asset List"]
|
||||
position, ["Vegetation Layer Spawner", "Shape Reference", "Vegetation Asset List"]
|
||||
)
|
||||
set_dynamic_slice_asset(veg_2, 2, os.path.join("Slices", "PurpleFlower.dynamicslice"))
|
||||
veg_2.get_set_test(1, "Configuration|Shape Entity Id", blender_entity.id)
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
def LayerSpawner_InstancesPlantInAllSupportedShapes():
|
||||
"""
|
||||
Summary:
|
||||
The level is loaded and vegetation area is created. Then the Vegetation Reference Shape
|
||||
The level is loaded and vegetation area is created. Then the Shape Reference
|
||||
component of vegetation area is pinned with entities of different shape components to check
|
||||
if the vegetation plants in different shaped areas.
|
||||
|
||||
@@ -67,7 +67,7 @@ def LayerSpawner_InstancesPlantInAllSupportedShapes():
|
||||
10.0, 10.0, 10.0,
|
||||
asset_path)
|
||||
vegetation.remove_component("Box Shape")
|
||||
vegetation.add_component("Vegetation Reference Shape")
|
||||
vegetation.add_component("Shape Reference")
|
||||
|
||||
# Create surface for planting on
|
||||
dynveg.create_surface_entity("Surface Entity", entity_position, 60.0, 60.0, 1.0)
|
||||
|
||||
+2
-2
@@ -96,7 +96,7 @@ def AreaNodes_DependentComponentsAdded():
|
||||
'SpawnerAreaNode': [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Asset List',
|
||||
'Vegetation Reference Shape'
|
||||
'Shape Reference'
|
||||
],
|
||||
'MeshBlockerAreaNode': [
|
||||
'Vegetation Layer Blocker (Mesh)',
|
||||
@@ -104,7 +104,7 @@ def AreaNodes_DependentComponentsAdded():
|
||||
],
|
||||
'BlockerAreaNode': [
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Reference Shape'
|
||||
'Shape Reference'
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ def Edit_DisabledNodeDuplication():
|
||||
nodes = {
|
||||
'SpawnerAreaNode': 'Vegetation Asset List',
|
||||
'MeshBlockerAreaNode': 'Mesh',
|
||||
'BlockerAreaNode': 'Vegetation Reference Shape',
|
||||
'BlockerAreaNode': 'Shape Reference',
|
||||
'FastNoiseGradientNode': 'Gradient Transform Modifier',
|
||||
'ImageGradientNode': 'Gradient Transform Modifier',
|
||||
'PerlinNoiseGradientNode': 'Gradient Transform Modifier',
|
||||
|
||||
+2
-2
@@ -104,7 +104,7 @@ def GradientNodes_DependentComponentsAdded():
|
||||
# we will be checking for
|
||||
commonComponents = [
|
||||
'Gradient Transform Modifier',
|
||||
'Vegetation Reference Shape'
|
||||
'Shape Reference'
|
||||
]
|
||||
componentNames = []
|
||||
for name in gradients:
|
||||
@@ -114,7 +114,7 @@ def GradientNodes_DependentComponentsAdded():
|
||||
|
||||
# Create nodes for the gradients that have additional required dependencies and check if
|
||||
# the Entity created by adding the node has the appropriate Component and required
|
||||
# Gradient Transform Modifier and Vegetation Reference Shape components added automatically to it
|
||||
# Gradient Transform Modifier and Shape Reference components added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
|
||||
@@ -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;
|
||||
@@ -201,15 +203,34 @@ namespace LandscapeCanvasEditor
|
||||
{
|
||||
using namespace AzToolsFramework;
|
||||
|
||||
static const QStringList preferredCategories = {
|
||||
"Vegetation",
|
||||
"Atom"
|
||||
};
|
||||
// A map of category names with preferred component names.
|
||||
// There may be multiple component names for a category, as long as they provide different services.
|
||||
const AZStd::map<QString, AZStd::vector<QString>> preferredComponentsByCategory = { { "Shape", { "Shape Reference" } } };
|
||||
|
||||
// Scan through the preferred categories to see whether any exist in the componentDataTable.
|
||||
for (const auto& preferredComponentPair : preferredComponentsByCategory)
|
||||
{
|
||||
auto candidateDataTablePair = componentDataTable.find(preferredComponentPair.first);
|
||||
if (candidateDataTablePair != componentDataTable.end())
|
||||
{
|
||||
// Now check all the preferred components for that category, and return the first one that exists in the candidate componentDataTable.
|
||||
for (const auto& preferredComponentName : preferredComponentPair.second)
|
||||
{
|
||||
const auto& candidateComponent = candidateDataTablePair->second.find(preferredComponentName);
|
||||
if (candidateComponent != candidateDataTablePair->second.end())
|
||||
{
|
||||
return candidateComponent->second->m_typeId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// There are a couple of cases where we prefer certain categories of Components
|
||||
// to be added over others (e.g. a Vegetation Shape Reference instead of actual LmbrCentral shapes),
|
||||
// to be added over others,
|
||||
// so if those there are components in those categories, then choose them first.
|
||||
// Otherwise, just pick the first one in the list.
|
||||
static const QStringList preferredCategories = { "Vegetation", "Atom" };
|
||||
|
||||
ComponentPaletteUtil::ComponentDataTable::const_iterator categoryIt;
|
||||
for (const auto& categoryName : preferredCategories)
|
||||
{
|
||||
@@ -1303,7 +1324,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 +1400,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 +1422,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;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.50342 4.36061L7.47747 3.44014L9.96968 4.56039V2.7935L7.50829 1.71887L5.50342 2.64301V4.36061ZM3.99316 3.33915L1.07861 4.6826L1.07869 8.5229H2.82607V5.609L3.99316 5.06481V3.33915ZM11.4799 5.23924L12.5798 5.73362V6.85533L14.0063 7.64563L14.2967 7.4947L14.2966 4.6826L11.4799 3.45286V5.23924ZM1.07879 13.913L1.07872 10.0332H2.82607V12.9237L4.01036 13.4951V15.3537L1.07879 13.913ZM5.52062 16.0958V14.2239L7.37105 15.1168L8.42342 14.6693L9.29688 14.8634V16.2093L7.37105 17.0052L5.52062 16.0958ZM9.7033 19.8356L9.70321 14.9536L11.4506 15.3419V18.8462L15.9956 21.0393L21.2043 18.8243V11.6561L19.0892 10.7054V8.93214L22.9211 10.6051L22.9213 18.0941V20.0656L15.9956 22.9277L9.7033 19.8356ZM4.16865 7.26396L9.85617 10.8214L5.52028 12.8232L17.9621 15.3933L17.991 7.02899L14.0482 8.82368L7.81896 5.62147L4.16865 7.26396Z" fill="#5A69A1"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 982 B |
@@ -0,0 +1,16 @@
|
||||
<svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.918 0C24.0953 0 24.9498 1.77847 24.9498 3.01865C24.9498 4.25884 24.9498 18.7816 24.9498 20.6421C24.9498 22.393 23.7213 23.9567 21.918 23.9567C20.1147 23.9567 5.64246 23.9567 3.80245 23.9567C2.37978 23.9567 0.993164 22.5148 0.993164 21.1587C0.993164 19.8026 0.993164 4.03533 0.993164 2.67255C0.993164 1.30978 2.35856 0 3.60272 0C4.84688 0 19.9533 0 21.918 0Z" fill="url(#paint0_linear_946_53402)"/>
|
||||
<mask id="mask0_946_53402" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="25" height="24">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.918 0C24.0953 0 24.9498 1.77847 24.9498 3.01865C24.9498 4.25884 24.9498 18.7816 24.9498 20.6421C24.9498 22.393 23.7213 23.9567 21.918 23.9567C20.1147 23.9567 5.64246 23.9567 3.80245 23.9567C2.37978 23.9567 0.993164 22.5148 0.993164 21.1587C0.993164 19.8026 0.993164 4.03533 0.993164 2.67255C0.993164 1.30978 2.35856 0 3.60272 0C4.84688 0 19.9533 0 21.918 0Z" fill="white"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_946_53402)">
|
||||
<rect x="0.993164" width="24" height="24" fill="#5A69A1"/>
|
||||
</g>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.50342 4.36061L8.47747 3.44014L10.9697 4.56039V2.7935L8.50829 1.71887L6.50342 2.64301V4.36061ZM4.99316 3.33915L2.07861 4.6826L2.07869 8.5229H3.82607V5.609L4.99316 5.06481V3.33915ZM12.4799 5.23924L13.5798 5.73362V6.85533L15.0063 7.64563L15.2967 7.4947L15.2966 4.6826L12.4799 3.45286V5.23924ZM2.07879 13.913L2.07872 10.0332H3.82607V12.9237L5.01036 13.4951V15.3537L2.07879 13.913ZM6.52062 16.0958V14.2239L8.37105 15.1168L9.42342 14.6693L10.2969 14.8634V16.2093L8.37105 17.0052L6.52062 16.0958ZM10.7033 19.8356L10.7032 14.9536L12.4506 15.3419V18.8462L16.9956 21.0393L22.2043 18.8243V11.6561L20.0892 10.7054V8.93214L23.9211 10.6051L23.9213 18.0941V20.0656L16.9956 22.9277L10.7033 19.8356ZM5.16865 7.26396L10.8562 10.8214L6.52028 12.8232L18.9621 15.3933L18.991 7.02899L15.0482 8.82368L8.81896 5.62147L5.16865 7.26396Z" fill="white"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_946_53402" x1="0.993164" y1="0" x2="0.993164" y2="23.9567" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#ADADAD" stop-opacity="0.01"/>
|
||||
<stop offset="1" stop-color="#9D9D9D"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
@@ -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;
|
||||
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>);
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -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 = "Shape Reference";
|
||||
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_icon = "Editor/Icons/Components/ShapeReference.svg";
|
||||
static constexpr const char* const s_viewportIcon = "Editor/Icons/Components/Viewport/ShapeReference.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", "")
|
||||
"Shape Reference", "")
|
||||
->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
|
||||
|
||||
@@ -87,6 +87,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
|
||||
|
||||
@@ -56,6 +56,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
|
||||
|
||||
@@ -24,5 +24,6 @@ set(FILES
|
||||
Tests/SpawnerComponentTest.cpp
|
||||
Tests/SplineComponentTests.cpp
|
||||
Tests/DiskShapeTest.cpp
|
||||
Tests/ReferenceShapeTests.cpp
|
||||
Source/LmbrCentral.cpp
|
||||
)
|
||||
|
||||
@@ -103,6 +103,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
AZ::AzTest
|
||||
AZ::AzFrameworkTestShared
|
||||
Gem::Vegetation.Static
|
||||
Gem::LmbrCentral.Mocks
|
||||
)
|
||||
ly_add_googletest(
|
||||
NAME Gem::Vegetation.Tests
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "VegetationTest.h"
|
||||
#include "VegetationMocks.h"
|
||||
|
||||
#include <LmbrCentral/Shape/MockShapes.h>
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <AzCore/Component/Entity.h>
|
||||
|
||||
@@ -312,74 +312,6 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
struct MockSurfaceHandler
|
||||
: public SurfaceData::SurfaceDataSystemRequestBus::Handler
|
||||
{
|
||||
|
||||
@@ -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