merging dev because AR failed for mysterious reasons

Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com>
This commit is contained in:
antonmic
2021-12-02 09:47:08 -08:00
108 changed files with 4344 additions and 680 deletions
@@ -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)
@@ -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)
@@ -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)
@@ -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'
]
}
@@ -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',
@@ -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
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,12 @@
0,0,0,0,0,0
0,0,0,0,0,0
0,0,0,0,0,0
0,0,0,0,0,0
0,0,0,0,0,0
0,0,0,0,0,0
0,0,0,0,0,0
0,0,0,0,0,0
0,0,0,0,0,0
0,0,0,0,0,0
0,0,0,0,0,0
0,0,0,0,0,0
@@ -53,7 +53,6 @@ static void OptimizedSetParent(QWidget* widget, QWidget* parent)
namespace AzQtComponents
{
static const FancyDockingDropZoneConstants g_FancyDockingConstants;
// Constant for the threshold in pixels for snapping to edges while dragging for docking
static const int g_snapThresholdInPixels = 15;
@@ -155,7 +154,7 @@ namespace AzQtComponents
// Timer for updating our hovered drop zone opacity
QObject::connect(m_dropZoneHoverFadeInTimer, &QTimer::timeout, this, &FancyDocking::onDropZoneHoverFadeInUpdate);
m_dropZoneHoverFadeInTimer->setInterval(g_FancyDockingConstants.dropZoneHoverFadeUpdateIntervalMS);
m_dropZoneHoverFadeInTimer->setInterval(FancyDockingDropZoneConstants::dropZoneHoverFadeUpdateIntervalMS);
QIcon dragIcon = QIcon(QStringLiteral(":/Cursors/Grabbing.svg"));
m_dragCursor = QCursor(dragIcon.pixmap(16), 5, 2);
}
@@ -333,13 +332,13 @@ namespace AzQtComponents
*/
void FancyDocking::onDropZoneHoverFadeInUpdate()
{
const qreal dropZoneHoverOpacity = g_FancyDockingConstants.dropZoneHoverFadeIncrement + m_dropZoneState.dropZoneHoverOpacity();
const qreal dropZoneHoverOpacity = FancyDockingDropZoneConstants::dropZoneHoverFadeIncrement + m_dropZoneState.dropZoneHoverOpacity();
// Once we've reached the full drop zone opacity, cut it off in case we
// went over and stop the timer
if (dropZoneHoverOpacity >= g_FancyDockingConstants.dropZoneOpacity)
if (dropZoneHoverOpacity >= FancyDockingDropZoneConstants::dropZoneOpacity)
{
m_dropZoneState.setDropZoneHoverOpacity(g_FancyDockingConstants.dropZoneOpacity);
m_dropZoneState.setDropZoneHoverOpacity(FancyDockingDropZoneConstants::dropZoneOpacity);
m_dropZoneHoverFadeInTimer->stop();
}
else
@@ -792,12 +791,12 @@ namespace AzQtComponents
QPoint mainWindowTopLeft = multiscreenMapFromGlobal(mainWindow->mapToGlobal(mainWindowRect.topLeft()));
QPoint mainWindowTopRight = multiscreenMapFromGlobal(mainWindow->mapToGlobal(mainWindowRect.topRight()));
QPoint mainWindowBottomLeft = multiscreenMapFromGlobal(mainWindow->mapToGlobal(mainWindowRect.bottomLeft()));
QSize absoluteLeftRightSize(g_FancyDockingConstants.absoluteDropZoneSizeInPixels, mainWindowRect.height());
QSize absoluteLeftRightSize(FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels, mainWindowRect.height());
QRect absoluteLeftDropZone(mainWindowTopLeft, absoluteLeftRightSize);
QRect absoluteRightDropZone(mainWindowTopRight - QPoint(g_FancyDockingConstants.absoluteDropZoneSizeInPixels, 0), absoluteLeftRightSize);
QSize absoluteTopBottomSize(mainWindowRect.width(), g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
QRect absoluteRightDropZone(mainWindowTopRight - QPoint(FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels, 0), absoluteLeftRightSize);
QSize absoluteTopBottomSize(mainWindowRect.width(), FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
QRect absoluteTopDropZone(mainWindowTopLeft, absoluteTopBottomSize);
QRect absoluteBottomDropZone(mainWindowBottomLeft - QPoint(0, g_FancyDockingConstants.absoluteDropZoneSizeInPixels), absoluteTopBottomSize);
QRect absoluteBottomDropZone(mainWindowBottomLeft - QPoint(0, FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels), absoluteTopBottomSize);
// If the drop target is a main window, then we will only show the absolute
// drop zone if the cursor is in that zone already
@@ -986,16 +985,16 @@ namespace AzQtComponents
switch (m_dropZoneState.absoluteDropZoneArea())
{
case Qt::LeftDockWidgetArea:
dockRect.setX(dockRect.x() + g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
dockRect.setX(dockRect.x() + FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
break;
case Qt::RightDockWidgetArea:
dockRect.setWidth(dockRect.width() - g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
dockRect.setWidth(dockRect.width() - FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
break;
case Qt::TopDockWidgetArea:
dockRect.setY(dockRect.y() + g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
dockRect.setY(dockRect.y() + FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
break;
case Qt::BottomDockWidgetArea:
dockRect.setHeight(dockRect.height() - g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
dockRect.setHeight(dockRect.height() - FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
break;
}
@@ -1034,15 +1033,15 @@ namespace AzQtComponents
// Set the drop zone width/height to the default, but if the dock widget
// width and/or height is below the threshold, then switch to scaling them
// down accordingly
int dropZoneWidth = g_FancyDockingConstants.dropZoneSizeInPixels;
if (dockWidth < g_FancyDockingConstants.minDockSizeBeforeDropZoneScalingInPixels)
int dropZoneWidth = FancyDockingDropZoneConstants::dropZoneSizeInPixels;
if (dockWidth < FancyDockingDropZoneConstants::minDockSizeBeforeDropZoneScalingInPixels)
{
dropZoneWidth = aznumeric_cast<int>(dockWidth * g_FancyDockingConstants.dropZoneScaleFactor);
dropZoneWidth = aznumeric_cast<int>(dockWidth * FancyDockingDropZoneConstants::dropZoneScaleFactor);
}
int dropZoneHeight = g_FancyDockingConstants.dropZoneSizeInPixels;
if (dockHeight < g_FancyDockingConstants.minDockSizeBeforeDropZoneScalingInPixels)
int dropZoneHeight = FancyDockingDropZoneConstants::dropZoneSizeInPixels;
if (dockHeight < FancyDockingDropZoneConstants::minDockSizeBeforeDropZoneScalingInPixels)
{
dropZoneHeight = aznumeric_cast<int>(dockHeight * g_FancyDockingConstants.dropZoneScaleFactor);
dropZoneHeight = aznumeric_cast<int>(dockHeight * FancyDockingDropZoneConstants::dropZoneScaleFactor);
}
// Calculate the inner corners to be used when constructing the drop zone polygons
@@ -1078,7 +1077,7 @@ namespace AzQtComponents
int innerDropZoneWidth = m_dropZoneState.innerDropZoneRect().width();
int innerDropZoneHeight = m_dropZoneState.innerDropZoneRect().height();
int centerDropZoneDiameter = (innerDropZoneWidth < innerDropZoneHeight) ? innerDropZoneWidth : innerDropZoneHeight;
centerDropZoneDiameter = aznumeric_cast<int>(centerDropZoneDiameter * g_FancyDockingConstants.centerTabDropZoneScale);
centerDropZoneDiameter = aznumeric_cast<int>(centerDropZoneDiameter * FancyDockingDropZoneConstants::centerTabDropZoneScale);
// Setup our center tab drop zone
const QSize centerDropZoneSize(centerDropZoneDiameter, centerDropZoneDiameter);
@@ -1986,7 +1985,7 @@ namespace AzQtComponents
// hasn't faded in all the way yet, then ignore the drop zone area
// which will make the widget floating
bool modifiedKeyPressed = FancyDockingDropZoneWidget::CheckModifierKey();
if (modifiedKeyPressed || m_dropZoneState.dropZoneHoverOpacity() != g_FancyDockingConstants.dropZoneOpacity)
if (modifiedKeyPressed || m_dropZoneState.dropZoneHoverOpacity() != FancyDockingDropZoneConstants::dropZoneOpacity)
{
area = Qt::NoDockWidgetArea;
}
@@ -3026,7 +3025,7 @@ namespace AzQtComponents
{
bool modifiedKeyPressed = FancyDockingDropZoneWidget::CheckModifierKey();
m_ghostWidget->setWindowOpacity(modifiedKeyPressed ? 1.0f : g_FancyDockingConstants.draggingDockWidgetOpacity);
m_ghostWidget->setWindowOpacity(modifiedKeyPressed ? 1.0f : FancyDockingDropZoneConstants::draggingDockWidgetOpacity);
m_ghostWidget->setPixmap(m_state.dockWidgetScreenGrab.screenGrab, m_state.placeholder(), m_state.placeholderScreen());
}
}
@@ -19,26 +19,6 @@
namespace AzQtComponents
{
static const FancyDockingDropZoneConstants g_Constants;
FancyDockingDropZoneConstants::FancyDockingDropZoneConstants()
{
draggingDockWidgetOpacity = 0.6;
dropZoneOpacity = 0.4;
dropZoneSizeInPixels = 40;
minDockSizeBeforeDropZoneScalingInPixels = dropZoneSizeInPixels * 3;
dropZoneScaleFactor = 0.25;
centerTabDropZoneScale = 0.5;
centerTabIconScale = 0.5;
dropZoneColor = QColor(155, 155, 155);
dropZoneBorderColor = Qt::black;
dropZoneBorderInPixels = 1;
absoluteDropZoneSizeInPixels = 25;
dockingTargetDelayMS = 110;
dropZoneHoverFadeUpdateIntervalMS = 20;
dropZoneHoverFadeIncrement = dropZoneOpacity / (dockingTargetDelayMS / dropZoneHoverFadeUpdateIntervalMS);
centerDropZoneIconPath = QString(":/stylesheet/img/UI20/docking/tabs_icon.svg");
}
FancyDockingDropZoneWidget::FancyDockingDropZoneWidget(QMainWindow* mainWindow, QWidget* coordinatesRelativeTo, QScreen* screen, FancyDockingDropZoneState* dropZoneState)
// NOTE: this will not work with multiple monitors if this widget has a parent. The floating drop zone
@@ -154,7 +134,7 @@ namespace AzQtComponents
// Draw all of the normal drop zones if they exist (if a dock widget is hovered over)
painter.setPen(Qt::NoPen);
painter.setOpacity(g_Constants.dropZoneOpacity);
painter.setOpacity(FancyDockingDropZoneConstants::dropZoneOpacity);
auto dropZones = m_dropZoneState->dropZones();
for (auto it = dropZones.cbegin(); it != dropZones.cend(); ++it)
{
@@ -189,7 +169,7 @@ namespace AzQtComponents
// Otherwise, set the normal color
else
{
painter.setBrush(g_Constants.dropZoneColor);
painter.setBrush(FancyDockingDropZoneConstants::dropZoneColor);
}
// negate the window position to offset everything by that much
@@ -214,8 +194,8 @@ namespace AzQtComponents
// Scale the tabs icon based on the drop zone size and our specified offset
// Doing this through QIcon to make sure that SVG is rendered already in desired resolution
const QSize& dropZoneSize = dropZoneRect.size();
const QSize requestedIconSize = dropZoneSize * g_Constants.centerTabIconScale;
const QIcon dropZoneIcon = QIcon(g_Constants.centerDropZoneIconPath);
const QSize requestedIconSize = dropZoneSize * FancyDockingDropZoneConstants::centerTabIconScale;
const QIcon dropZoneIcon = QIcon(FancyDockingDropZoneConstants::centerDropZoneIconPath);
const QPixmap dropZonePixmap = dropZoneIcon.pixmap(requestedIconSize);
const QSize receivedIconSize = dropZoneIcon.actualSize(requestedIconSize);
@@ -264,7 +244,7 @@ namespace AzQtComponents
}
else
{
painter.setBrush(g_Constants.dropZoneColor);
painter.setBrush(FancyDockingDropZoneConstants::dropZoneColor);
}
painter.drawRect(absoluteDropZoneRect);
@@ -313,8 +293,8 @@ namespace AzQtComponents
const QPoint innerBottomRight = innerDropZoneRect.bottomRight();
// Draw the lines using the appropriate pen
QPen dropZoneBorderPen(g_Constants.dropZoneBorderColor);
dropZoneBorderPen.setWidth(g_Constants.dropZoneBorderInPixels);
QPen dropZoneBorderPen(FancyDockingDropZoneConstants::dropZoneBorderColor);
dropZoneBorderPen.setWidth(FancyDockingDropZoneConstants::dropZoneBorderInPixels);
painter.setPen(dropZoneBorderPen);
painter.setOpacity(1);
painter.drawLine(topLeft, innerTopLeft);
@@ -28,63 +28,58 @@ class QPainter;
namespace AzQtComponents
{
struct AZ_QT_COMPONENTS_API FancyDockingDropZoneConstants
namespace FancyDockingDropZoneConstants
{
// Constant for the opacity of the screen grab for the dock widget being dragged
qreal draggingDockWidgetOpacity;
static constexpr qreal draggingDockWidgetOpacity = 0.6;
// Constant for the opacity of the normal drop zones
qreal dropZoneOpacity;
static constexpr qreal dropZoneOpacity = 0.4;
// Constant for the default drop zone size (in pixels)
int dropZoneSizeInPixels;
static constexpr int dropZoneSizeInPixels = 40;
// Constant for the dock width/height size (in pixels) before we need to start
// scaling down the drop zone sizes, or else they will overlap with the center
// tab icon or each other
int minDockSizeBeforeDropZoneScalingInPixels;
static constexpr int minDockSizeBeforeDropZoneScalingInPixels = dropZoneSizeInPixels * 3;
// Constant for the factor by which we must scale down the drop zone sizes once
// the dock width/height size is too small
qreal dropZoneScaleFactor;
static constexpr qreal dropZoneScaleFactor = 0.25;
// Constant for the percentage to scale down the inner drop zone rectangle for the center tab drop zone
qreal centerTabDropZoneScale;
static constexpr qreal centerTabDropZoneScale = 0.5;
// Constant for the percentage to scale down the center tab drop zone for the center tab icon
qreal centerTabIconScale;
static constexpr qreal centerTabIconScale = 0.5;
// Constant for the drop zone hotspot default color
QColor dropZoneColor;
static const QColor dropZoneColor = QColor(155, 155, 155);
// Constant for the drop zone border color
QColor dropZoneBorderColor;
static const QColor dropZoneBorderColor = Qt::black;
// Constant for the border width in pixels separating the drop zones
int dropZoneBorderInPixels;
static constexpr int dropZoneBorderInPixels = 1;
// Constant for the border width in pixels separating the drop zones
int absoluteDropZoneSizeInPixels;
static constexpr int absoluteDropZoneSizeInPixels = 25;
// Constant for the delay (in milliseconds) before a drop zone becomes active
// once it is hovered over
int dockingTargetDelayMS;
static constexpr int dockingTargetDelayMS = 110;
// Constant for the rate at which we will update (fade in) the drop zone opacity
// when hovered over (in milliseconds)
int dropZoneHoverFadeUpdateIntervalMS;
static constexpr int dropZoneHoverFadeUpdateIntervalMS = 20;
// Constant for the incremental opacity increase for the hovered drop zone
// that will fade in to the full drop zone opacity in the desired time
qreal dropZoneHoverFadeIncrement;
static constexpr qreal dropZoneHoverFadeIncrement = dropZoneOpacity / (dockingTargetDelayMS / dropZoneHoverFadeUpdateIntervalMS);
// Constant for the path to the center drop zone tabs icon
QString centerDropZoneIconPath;
FancyDockingDropZoneConstants();
FancyDockingDropZoneConstants(const FancyDockingDropZoneConstants&) = delete;
FancyDockingDropZoneConstants& operator=(const FancyDockingDropZoneConstants&) = delete;
static const QString centerDropZoneIconPath = QStringLiteral(":/stylesheet/img/UI20/docking/tabs_icon.svg");
};
class FancyDockingDropZoneState
@@ -323,7 +323,7 @@ namespace AzQtComponents
saturation *= 2.0 - lightness;
}
double value = (lightness + saturation) / 2.0;
saturation = (2.0 * saturation) / (lightness + saturation);
saturation = qFuzzyIsNull(lightness + saturation) ? 0 : (2.0 * saturation) / (lightness + saturation);
m_hsv.saturation = AZ::GetClamp(saturation, 0.0, 1.0);
m_hsv.value = AZ::GetClamp(value, 0.0, 12.5);
@@ -341,11 +341,12 @@ namespace AzQtComponents
double saturation = m_hsv.saturation * m_hsv.value;
if (lightness <= 1.0)
{
saturation /= lightness;
saturation = (qFuzzyIsNull(lightness)) ? 0.0 : saturation / lightness;
}
else
{
saturation /= 2.0 - lightness;
double two_minus_lightness = 2.0 - lightness;
saturation = (qFuzzyIsNull(two_minus_lightness)) ? 0.0 : saturation / two_minus_lightness;
}
lightness /= 2.0;
@@ -164,11 +164,7 @@ namespace
}
}
#if AZ_TRAIT_DISABLE_FAILED_ZERO_COLOR_CONVERSION_TEST
TEST(AzQtComponents, DISABLED_ColorConversionsTestAllZeros)
#else
TEST(AzQtComponents, ColorConversionsTestAllZeros)
#endif // AZ_TRAIT_DISABLE_FAILED_ZERO_COLOR_CONVERSION_TEST
{
TestConversions({ 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 });
}
@@ -18,7 +18,7 @@
#define AZ_TRAIT_DISABLE_FAILED_ATOM_RPI_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_ZERO_COLOR_CONVERSION_TEST true
#define AZ_TRAIT_DISABLE_FAILED_FRAMEPROFILER_TEST true
#define AZ_TRAIT_DISABLE_FAILED_FRAMEWORK_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_GRADIENT_SIGNAL_TESTS true
@@ -521,21 +521,18 @@ namespace AzToolsFramework
nestedInstanceLink.has_value(),
"A valid link was not found for one of the instances provided as input for the CreatePrefab operation.");
PrefabDomReference nestedInstanceLinkDom = nestedInstanceLink->get().GetLinkDom();
AZ_Assert(
nestedInstanceLinkDom.has_value(),
"A valid DOM was not found for the link corresponding to one of the instances provided as input for the "
"CreatePrefab operation.");
PrefabDomValueReference nestedInstanceLinkPatches =
PrefabDomUtils::FindPrefabDomValue(nestedInstanceLinkDom->get(), PrefabDomUtils::PatchesName);
AZ_Assert(
nestedInstanceLinkPatches.has_value(),
"A valid DOM for patches was not found for the link corresponding to one of the instances provided as input for the "
"CreatePrefab operation.");
PrefabDom patchesCopyForUndoSupport;
patchesCopyForUndoSupport.CopyFrom(nestedInstanceLinkPatches->get(), patchesCopyForUndoSupport.GetAllocator());
PrefabDomReference nestedInstanceLinkDom = nestedInstanceLink->get().GetLinkDom();
if (nestedInstanceLinkDom.has_value())
{
PrefabDomValueReference nestedInstanceLinkPatches =
PrefabDomUtils::FindPrefabDomValue(nestedInstanceLinkDom->get(), PrefabDomUtils::PatchesName);
if (nestedInstanceLinkPatches.has_value())
{
patchesCopyForUndoSupport.CopyFrom(nestedInstanceLinkPatches->get(), patchesCopyForUndoSupport.GetAllocator());
}
}
PrefabUndoHelpers::RemoveLink(
sourceInstance->GetTemplateId(), targetTemplateId, sourceInstance->GetInstanceAlias(), sourceInstance->GetLinkId(),
AZStd::move(patchesCopyForUndoSupport), undoBatch);
@@ -0,0 +1,150 @@
/*
* 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 <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
#include <Prefab/PrefabTestComponent.h>
#include <Prefab/PrefabTestDomUtils.h>
#include <Prefab/PrefabTestFixture.h>
namespace UnitTest
{
using PrefabDeleteTest = PrefabTestFixture;
TEST_F(PrefabDeleteTest, DeleteEntitiesInInstance_DeleteSingleEntitySucceeds)
{
PrefabEntityResult createEntityResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
// Verify that a valid entity is created.
AZ::EntityId testEntityId = createEntityResult.GetValue();
ASSERT_TRUE(testEntityId.IsValid());
AZ::Entity* testEntity = AzToolsFramework::GetEntityById(testEntityId);
ASSERT_TRUE(testEntity != nullptr);
m_prefabPublicInterface->DeleteEntitiesInInstance(AzToolsFramework::EntityIdList{ testEntityId });
// Verify that entity can't be found after deletion.
testEntity = AzToolsFramework::GetEntityById(testEntityId);
EXPECT_TRUE(testEntity == nullptr);
}
TEST_F(PrefabDeleteTest, DeleteEntitiesInInstance_DeleteSinglePrefabSucceeds)
{
PrefabEntityResult createEntityResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
// Verify that a valid entity is created.
AZ::EntityId createdEntityId = createEntityResult.GetValue();
ASSERT_TRUE(createdEntityId.IsValid());
AZ::Entity* createdEntity = AzToolsFramework::GetEntityById(createdEntityId);
ASSERT_TRUE(createdEntity != nullptr);
// Rather than hardcode a path, use a path from settings registry since that will work on all platforms.
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
AZ::IO::FixedMaxPath path;
registry->Get(path.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
CreatePrefabResult createPrefabResult =
m_prefabPublicInterface->CreatePrefabInMemory(AzToolsFramework::EntityIdList{ createdEntityId }, path);
AZ::EntityId createdPrefabContainerId = createPrefabResult.GetValue();
ASSERT_TRUE(createdPrefabContainerId.IsValid());
AZ::Entity* prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
ASSERT_TRUE(prefabContainerEntity != nullptr);
// Verify that the prefab container entity and the entity within are deleted.
m_prefabPublicInterface->DeleteEntitiesInInstance(AzToolsFramework::EntityIdList{ createdPrefabContainerId });
prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
EXPECT_TRUE(prefabContainerEntity == nullptr);
createdEntity = AzToolsFramework::GetEntityById(createdEntityId);
EXPECT_TRUE(createdEntity == nullptr);
}
TEST_F(PrefabDeleteTest, DeleteEntitiesAndAllDescendantsInInstance_DeletingEntityDeletesChildEntityToo)
{
PrefabEntityResult parentEntityCreationResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
// Verify that valid parent entity is created.
AZ::EntityId parentEntityId = parentEntityCreationResult.GetValue();
ASSERT_TRUE(parentEntityId.IsValid());
AZ::Entity* parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
ASSERT_TRUE(parentEntity != nullptr);
// Verify that valid child entity is created.
PrefabEntityResult childEntityCreationResult = m_prefabPublicInterface->CreateEntity(parentEntityId, AZ::Vector3());
AZ::EntityId childEntityId = childEntityCreationResult.GetValue();
ASSERT_TRUE(childEntityId.IsValid());
AZ::Entity* childEntity = AzToolsFramework::GetEntityById(childEntityId);
ASSERT_TRUE(childEntity != nullptr);
// PrefabTestFixture won't add required editor components by default. Hence we add them here.
AddRequiredEditorComponents(childEntity);
AddRequiredEditorComponents(parentEntity);
// Parent the child entity under the parent entity.
AZ::TransformBus::Event(childEntityId, &AZ::TransformBus::Events::SetParent, parentEntityId);
// Delete parent entity and its children.
m_prefabPublicInterface->DeleteEntitiesAndAllDescendantsInInstance(AzToolsFramework::EntityIdList{ parentEntityId });
// Verify that both the parent and child entities are deleted.
parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
EXPECT_TRUE(parentEntity == nullptr);
childEntity = AzToolsFramework::GetEntityById(childEntityId);
EXPECT_TRUE(childEntity == nullptr);
}
TEST_F(PrefabDeleteTest, DeleteEntitiesAndAllDescendantsInInstance_DeletingEntityDeletesChildPrefabToo)
{
PrefabEntityResult entityToBePutUnderPrefabResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
// Verify that a valid entity is created that will be put in a prefab later.
AZ::EntityId entityToBePutUnderPrefabId = entityToBePutUnderPrefabResult.GetValue();
ASSERT_TRUE(entityToBePutUnderPrefabId.IsValid());
AZ::Entity* entityToBePutUnderPrefab = AzToolsFramework::GetEntityById(entityToBePutUnderPrefabId);
ASSERT_TRUE(entityToBePutUnderPrefab != nullptr);
// Verify that a valid parent entity is created.
PrefabEntityResult parentEntityCreationResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
AZ::EntityId parentEntityId = parentEntityCreationResult.GetValue();
ASSERT_TRUE(parentEntityId.IsValid());
AZ::Entity* parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
ASSERT_TRUE(parentEntity != nullptr);
// Rather than hardcode a path, use a path from settings registry since that will work on all platforms.
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
AZ::IO::FixedMaxPath path;
registry->Get(path.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
CreatePrefabResult createPrefabResult =
m_prefabPublicInterface->CreatePrefabInMemory(AzToolsFramework::EntityIdList{ entityToBePutUnderPrefabId }, path);
// Verify that a valid prefab container entity is created.
AZ::EntityId createdPrefabContainerId = createPrefabResult.GetValue();
ASSERT_TRUE(createdPrefabContainerId.IsValid());
AZ::Entity* prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
ASSERT_TRUE(prefabContainerEntity != nullptr);
// PrefabTestFixture won't add required editor components by default. Hence we add them here.
AddRequiredEditorComponents(parentEntity);
AddRequiredEditorComponents(prefabContainerEntity);
// Parent the prefab under the parent entity.
AZ::TransformBus::Event(createdPrefabContainerId, &AZ::TransformBus::Events::SetParent, parentEntityId);
// Delete the parent entity.
m_prefabPublicInterface->DeleteEntitiesAndAllDescendantsInInstance(AzToolsFramework::EntityIdList{ parentEntityId });
// Validate that the parent and the prefab under it and the entity inside the prefab are all deleted.
parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
ASSERT_TRUE(parentEntity == nullptr);
entityToBePutUnderPrefab = AzToolsFramework::GetEntityById(entityToBePutUnderPrefabId);
ASSERT_TRUE(entityToBePutUnderPrefab == nullptr);
prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
EXPECT_TRUE(prefabContainerEntity == nullptr);
}
} // namespace UnitTest
@@ -57,6 +57,11 @@ namespace UnitTest
return AZStd::make_unique<PrefabTestToolsApplication>("PrefabTestApplication");
}
void PrefabTestFixture::PropagateAllTemplateChanges()
{
m_prefabSystemComponent->OnSystemTick();
}
AZ::Entity* PrefabTestFixture::CreateEntity(const char* entityName, const bool shouldActivate)
{
// Circumvent the EntityContext system and generate a new entity with a transformcomponent
@@ -125,4 +130,13 @@ namespace UnitTest
EXPECT_EQ(entityInInstance->GetState(), AZ::Entity::State::Active);
}
}
void PrefabTestFixture::AddRequiredEditorComponents(AZ::Entity* entity)
{
ASSERT_TRUE(entity != nullptr);
entity->Deactivate();
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
&AzToolsFramework::EditorEntityContextRequests::AddRequiredComponents, *entity);
entity->Activate();
}
}
@@ -52,6 +52,8 @@ namespace UnitTest
AZStd::unique_ptr<ToolsTestApplication> CreateTestApplication() override;
void PropagateAllTemplateChanges();
AZ::Entity* CreateEntity(const char* entityName, const bool shouldActivate = true);
void CompareInstances(const Instance& instanceA, const Instance& instanceB, bool shouldCompareLinkIds = true,
@@ -62,6 +64,8 @@ namespace UnitTest
//! Validates that all entities within a prefab instance are in 'Active' state.
void ValidateInstanceEntitiesActive(Instance& instance);
void AddRequiredEditorComponents(AZ::Entity* entity);
PrefabSystemComponent* m_prefabSystemComponent = nullptr;
PrefabLoaderInterface* m_prefabLoaderInterface = nullptr;
PrefabPublicInterface* m_prefabPublicInterface = nullptr;
@@ -128,7 +128,7 @@ namespace UnitTest
void ProcessDeferredUpdates()
{
// Force a prefab propagation for updates that are deferred to the next tick.
m_prefabSystemComponent->OnSystemTick();
PropagateAllTemplateChanges();
// Ensure the model process its entity update queue
m_model->ProcessEntityUpdates();
@@ -69,6 +69,7 @@ set(FILES
Prefab/PrefabFocus/PrefabFocusTests.cpp
Prefab/MockPrefabFileIOActionValidator.cpp
Prefab/MockPrefabFileIOActionValidator.h
Prefab/PrefabDeleteTests.cpp
Prefab/PrefabDuplicateTests.cpp
Prefab/PrefabEntityAliasTests.cpp
Prefab/PrefabInstanceToTemplatePropagatorTests.cpp
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "",
"propertyLayoutVersion": 3,
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"metallic": {
"useTexture": false
@@ -18,4 +18,4 @@
"useTexture": false
}
}
}
}
@@ -1,11 +1,11 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"textureMap": "Materials/Presets/MacBeth/00_illuminant_sRGB.tif"
"textureMap": "00_illuminant_sRGB.tif"
}
}
}
}
@@ -1,18 +1,18 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.17143511772155763,
0.17143511772155762,
0.08227664977312088,
0.056122682988643649,
0.056122682988643646,
1.0
],
"textureMap": "Materials/Presets/MacBeth/01_dark_skin_sRGB.tif",
"textureMap": "01_dark_skin_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\01_dark_skin.material",
"propertyLayoutVersion": 3,
"parentMaterial": "01_dark_skin.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,8 +11,8 @@
0.21953155100345612,
1.0
],
"textureMap": "Materials/Presets/MacBeth/02_light_skin_sRGB.tif",
"textureMap": "02_light_skin_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\02_light_skin.material",
"propertyLayoutVersion": 3,
"parentMaterial": "02_light_skin.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,18 +1,18 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.10946822166442871,
0.19806210696697236,
0.33716335892677309,
0.19806210696697235,
0.33716335892677307,
1.0
],
"textureMap": "Materials/Presets/MacBeth/03_blue_sky_sRGB.tif",
"textureMap": "03_blue_sky_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\03_blue_sky.material",
"propertyLayoutVersion": 3,
"parentMaterial": "03_blue_sky.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,16 +1,16 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.10223544389009476,
0.14996567368507386,
0.052857253700494769,
0.14996567368507385,
0.052857253700494766,
1.0
]
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\04_foliage.material",
"propertyLayoutVersion": 3,
"parentMaterial": "04_foliage.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,7 +11,7 @@
1.0,
1.0
],
"textureMap": "Materials/Presets/MacBeth/04_foliage_sRGB.tif"
"textureMap": "04_foliage_sRGB.tif"
}
}
}
}
@@ -1,16 +1,16 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.2232242375612259,
0.21953155100345612,
0.43414968252182009,
0.43414968252182007,
1.0
]
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\05_blue_flower.material",
"propertyLayoutVersion": 3,
"parentMaterial": "05_blue_flower.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,7 +11,7 @@
1.0,
1.0
],
"textureMap": "Materials/Presets/MacBeth/05_blue_flower_sRGB.tif"
"textureMap": "05_blue_flower_sRGB.tif"
}
}
}
}
@@ -1,18 +1,18 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.12477302551269531,
0.5209887623786926,
0.40723279118537905,
0.40723279118537903,
1.0
],
"textureMap": "Materials/Presets/MacBeth/06_bluish_green_sRGB.tif",
"textureMap": "06_bluish_green_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\06_bluish_green.material",
"propertyLayoutVersion": 3,
"parentMaterial": "06_bluish_green.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,16 +1,16 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.7156938910484314,
0.19806210696697236,
0.026245517656207086,
0.19806210696697235,
0.026245517656207085,
1.0
]
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\07_orange.material",
"propertyLayoutVersion": 3,
"parentMaterial": "07_orange.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,7 +11,7 @@
1.0,
1.0
],
"textureMap": "Materials/Presets/MacBeth/07_orange_sRGB.tif"
"textureMap": "07_orange_sRGB.tif"
}
}
}
}
@@ -1,18 +1,18 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.06480506807565689,
0.10702677816152573,
0.39157700538635256,
0.39157700538635254,
1.0
],
"textureMap": "Materials/Presets/MacBeth/08_purplish_blue_sRGB.tif",
"textureMap": "08_purplish_blue_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\08_purplish_blue.material",
"propertyLayoutVersion": 3,
"parentMaterial": "08_purplish_blue.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,8 +11,8 @@
0.12213321030139923,
1.0
],
"textureMap": "Materials/Presets/MacBeth/09_moderate_red_sRGB.tif",
"textureMap": "09_moderate_red_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\09_moderate_red.material",
"propertyLayoutVersion": 3,
"parentMaterial": "09_moderate_red.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,18 +1,18 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.10461585223674774,
0.043732356280088428,
0.043732356280088425,
0.1412680298089981,
1.0
],
"textureMap": "Materials/Presets/MacBeth/10_purple_sRGB.tif",
"textureMap": "10_purple_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\10_purple.material",
"propertyLayoutVersion": 3,
"parentMaterial": "10_purple.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,8 +11,8 @@
0.0481727309525013,
1.0
],
"textureMap": "Materials/Presets/MacBeth/11_yellow_green_sRGB.tif",
"textureMap": "11_yellow_green_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\11_yellow_green.material",
"propertyLayoutVersion": 3,
"parentMaterial": "11_yellow_green.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,18 +1,18 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.7835355401039124,
0.35640496015548708,
0.35640496015548706,
0.02217135950922966,
1.0
],
"textureMap": "Materials/Presets/MacBeth/12_orange_yellow_sRGB.tif",
"textureMap": "12_orange_yellow_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\12_orange_yellow.material",
"propertyLayoutVersion": 3,
"parentMaterial": "12_orange_yellow.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,18 +1,18 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.024155031889677049,
0.024155031889677048,
0.0481727309525013,
0.29176774621009829,
0.29176774621009827,
1.0
],
"textureMap": "Materials/Presets/MacBeth/13_blue_sRGB.tif",
"textureMap": "13_blue_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\13_blue.material",
"propertyLayoutVersion": 3,
"parentMaterial": "13_blue.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,8 +11,8 @@
0.06480506807565689,
1.0
],
"textureMap": "Materials/Presets/MacBeth/14_green_sRGB.tif",
"textureMap": "14_green_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\14_green.material",
"propertyLayoutVersion": 3,
"parentMaterial": "14_green.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,18 +1,18 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.43414968252182009,
0.029556725174188615,
0.43414968252182007,
0.029556725174188614,
0.03955138474702835,
1.0
],
"textureMap": "Materials/Presets/MacBeth/15_red_sRGB.tif",
"textureMap": "15_red_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\15_red.material",
"propertyLayoutVersion": 3,
"parentMaterial": "15_red.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,8 +11,8 @@
0.00802624598145485,
1.0
],
"textureMap": "Materials/Presets/MacBeth/16_yellow_sRGB.tif",
"textureMap": "16_yellow_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\16_yellow.material",
"propertyLayoutVersion": 3,
"parentMaterial": "16_yellow.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,8 +11,8 @@
0.30498206615448,
1.0
],
"textureMap": "Materials/Presets/MacBeth/17_magenta_sRGB.tif",
"textureMap": "17_magenta_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\17_magenta.material",
"propertyLayoutVersion": 3,
"parentMaterial": "17_magenta.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,18 +1,18 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.0,
0.24620431661605836,
0.24620431661605835,
0.3813229501247406,
1.0
],
"textureMap": "Materials/Presets/MacBeth/18_cyan_sRGB.tif",
"textureMap": "18_cyan_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\18_cyan.material",
"propertyLayoutVersion": 3,
"parentMaterial": "18_cyan.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,8 +11,8 @@
0.8713664412498474,
1.0
],
"textureMap": "Materials/Presets/MacBeth/19_white_9-5_0-05D_sRGB.tif",
"textureMap": "19_white_9-5_0-05D_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\19_white_9-5_0-05D.material",
"propertyLayoutVersion": 3,
"parentMaterial": "19_white_9-5_0-05D.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,8 +11,8 @@
0.5840848684310913,
1.0
],
"textureMap": "Materials/Presets/MacBeth/20_neutral_8-0_0-23D_sRGB.tif",
"textureMap": "20_neutral_8-0_0-23D_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\20_neutral_8-0_0-23D.material",
"propertyLayoutVersion": 3,
"parentMaterial": "20_neutral_8-0_0-23D.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,18 +1,18 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.3515373468399048,
0.35640496015548708,
0.35640496015548708,
0.35640496015548706,
0.35640496015548706,
1.0
],
"textureMap": "Materials/Presets/MacBeth/21_neutral_6-5_0-44D_sRGB.tif",
"textureMap": "21_neutral_6-5_0-44D_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\21_neutral_6-5_0-44D.material",
"propertyLayoutVersion": 3,
"parentMaterial": "21_neutral_6-5_0-44D.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,18 +1,18 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
0.18782329559326173,
0.18782329559326172,
0.191195547580719,
0.191195547580719,
1.0
],
"textureMap": "Materials/Presets/MacBeth/22_neutral_5-0_0-70D_sRGB.tif",
"textureMap": "22_neutral_5-0_0-70D_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\22_neutral_5-0_0-70D.material",
"propertyLayoutVersion": 3,
"parentMaterial": "22_neutral_5-0_0-70D.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,8 +11,8 @@
0.09083695709705353,
1.0
],
"textureMap": "Materials/Presets/MacBeth/23_neutral_3-5_1-05D_sRGB.tif",
"textureMap": "23_neutral_3-5_1-05D_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\23_neutral_3-5_1-05D.material",
"propertyLayoutVersion": 3,
"parentMaterial": "23_neutral_3-5_1-05D.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -11,8 +11,8 @@
0.0318913571536541,
1.0
],
"textureMap": "Materials/Presets/MacBeth/24_black_2-0_1-50D_sRGB.tif",
"textureMap": "24_black_2-0_1-50D_sRGB.tif",
"useTexture": false
}
}
}
}
@@ -1,8 +1,8 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\24_black_2-0_1-50D.material",
"propertyLayoutVersion": 3,
"parentMaterial": "24_black_2-0_1-50D.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"color": [
@@ -14,4 +14,4 @@
"useTexture": true
}
}
}
}
@@ -1,11 +1,11 @@
{
"description": "",
"materialType": "Materials\\Types\\StandardPBR.materialtype",
"parentMaterial": "Materials\\Presets\\MacBeth\\00_illuminant.material",
"propertyLayoutVersion": 3,
"parentMaterial": "00_illuminant.material",
"materialType": "../../Types/StandardPBR.materialtype",
"materialTypeVersion": 4,
"properties": {
"baseColor": {
"textureMap": "Materials/Presets/MacBeth/ColorChecker_sRGB_from_Lab_16bit_AfterNov2014.tif"
"textureMap": "ColorChecker_sRGB_from_Lab_16bit_AfterNov2014.tif"
}
}
}
}
@@ -41,97 +41,3 @@ bool IsInsideOfImageSize(
return IsInsideOfImageSize(coord, inputImageSize) &&
IsInsideOfImageSize(coord, outputImageSize);
}
//! This returns filtered value of "source" with weights in "filterTable" in 1 direction.
//! @param coord the center coordinate (in Texture2DArray) of the filtered area.
//! the xy coordinate is in pixel, and z is array slice index.
//! @param source image resource which is used as the source of the filtering.
//! Note that it contains entire of the shadowmap atlas, not a single shadowmap.
//! @param direction either (1,0) or (0,1).
//! If (1,0), the filtering direction is horizontal,
//! and if (0,1), it is vertical.
//! @param sourceMin the minimum (left/top most) index of the shadowmap.
//! @param sourceMax the maximum (right/bottom most) index of the shadowmap.
//! @param filterTable the weight table for this table.
//! Since the weight table of a Gaussian filter is left-right symmetry,
//! the right half is omitted in this filterTable.
//! @param filterOffset the offset of the filtering parameter in filterTable.
//! @param filterCount the element count of filtering parameter in filterTable.
//! For example, the weight table has size 11 in the original meaning
//! of Gaussian filter, filterCount == 6 by omitting the right half.
float FilteredFloat(
uint3 coord,
Texture2DArray<float> source,
int2 direction,
int sourceMin,
int sourceMax,
Buffer<float> filterTable,
uint filterOffset,
uint filterCount)
{
if (filterCount == 0)
{
return 0.; // if no filtering info, early return.
}
const int centerIndex = (int)dot(coord.xy, direction);
float result = 0.;
int index = 0;
// This function summarizes the values stored in "source"
// from minIndex to maxIndex with weight in "filterTable".
// In the case that some point in [minIndex, maxIndex] go outside of
// the shadowmap (indicated by sourceMin and sourceMax),
// the edge value of the shadowmap is used.
// 1. littler index side (left/up side)
const int minIndex = centerIndex - ((int)filterCount - 1);
// 1-1. outside of shadowmap (littler)
// Assuming outside values are equal to the edge value,
// it first summarize the weights for outside of shadowmap
// then multiply it by the edge value.
float weight = 0.; // summation of weights of outside of shadowmap
for (index = minIndex; index < sourceMin; ++index)
{
weight += filterTable[filterOffset + index - minIndex];
}
int2 edgeOffset = direction * (sourceMin - centerIndex);
int3 edgeCoord = coord + int3(edgeOffset, 0);
result += weight * source[edgeCoord];
// 1-2. inside of shadowmap (littler)
for (index = max(sourceMin, minIndex); index < centerIndex; ++index)
{
const int2 offset = direction * (index - centerIndex);
result += filterTable[filterOffset + index - minIndex] *
source[coord + int3(offset, 0)];
}
// 2. greater index side (right/down side)
const int maxIndex = centerIndex + ((int)filterCount - 1);
// 2-1. outside of shadowmap (greater)
// This is similar to 1-1 above.
weight = 0.; // summation of weights of outside of shadowmap
for (index = maxIndex; index > sourceMax; --index)
{
weight += filterTable[filterOffset + maxIndex - index];
}
edgeOffset = direction * (sourceMax - centerIndex);
edgeCoord = coord + int3(edgeOffset, 0);
result += weight * source[edgeCoord];
// 2-2. inside of shadowmap (greater)
for (index = min(sourceMax, maxIndex); index > centerIndex; --index)
{
const int2 offset = direction * (index - centerIndex);
result += filterTable[filterOffset + maxIndex - index] *
source[coord + int3(offset, 0)];
}
// 3. center
result += filterTable[filterOffset + filterCount - 1] * source[coord];
return result;
}
@@ -23,6 +23,16 @@ float3 TransmissionKernel(float t, float3 s)
return 0.25 * (1.0 / exp(exponent) + 3.0 / exp(exponent / 3.0));
}
float ThinObjectFalloff(const float3 surfaceNormal, const float3 dirToLight)
{
const float ndl = saturate(dot(-surfaceNormal, dirToLight));
// ndl works decently well but it can produce a harsh discontinuity in the area just before
// the shadow starts appearing on objects like cylinder and tubes.
// Smoothing out ndl does a decent enough job of removing this artifact.
return smoothstep(0, 1, ndl * ndl);
}
float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight, float shadowRatio)
{
float3 result = float3(0.0, 0.0, 0.0);
@@ -53,8 +63,10 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI
float litRatio = 1.0 - shadowRatio;
if (litRatio)
{
result = TransmissionKernel(surface.transmission.thickness * transmissionParams.w, rcp(transmissionParams.xyz)) *
saturate(dot(-surface.normal, dirToLight)) * lightIntensity * litRatio;
const float thickness = surface.transmission.thickness * transmissionParams.w;
const float3 invScattering = rcp(transmissionParams.xyz);
const float falloff = ThinObjectFalloff(surface.normal, dirToLight);
result = TransmissionKernel(thickness, invScattering) * falloff * lightIntensity * litRatio;
}
break;
@@ -50,6 +50,20 @@ int UnpackPointLightShadowIndex(const ViewSrg::PointLight light, const int face)
return (light.m_shadowIndices[index] >> shiftAmount) & 0xFFFF;
}
uint ComputeShadowIndex(const ViewSrg::PointLight light, const Surface surface)
{
// shadow map size and bias are the same across all shadowmaps used by a specific point light, so just grab the first one
const uint lightIndex0 = UnpackPointLightShadowIndex(light, 0);
const float shadowmapSize = ViewSrg::m_projectedFilterParams[lightIndex0].m_shadowmapSize;
// Note that the normal bias offset could potentially move the shadowed position from one map to another map inside the same point light shadow.
const float normalBias = ViewSrg::m_projectedShadows[lightIndex0].m_normalShadowBias;
const float3 biasedPosition = surface.position + ComputeNormalShadowOffset(normalBias, surface.vertexNormal, shadowmapSize);
const int shadowCubemapFace = GetPointLightShadowCubemapFace(biasedPosition, light.m_position);
return UnpackPointLightShadowIndex(light, shadowCubemapFace);
}
void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingData lightingData)
{
float3 posToLight = light.m_position - surface.position;
@@ -74,10 +88,8 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD
float backShadowRatio = 0.0;
if (o_enableShadows)
{
const int shadowCubemapFace = GetPointLightShadowCubemapFace(surface.position, light.m_position);
const int shadowIndex = UnpackPointLightShadowIndex(light, shadowCubemapFace);
const float3 lightDir = normalize(light.m_position - surface.position);
const uint shadowIndex = ComputeShadowIndex(light, surface);
litRatio *= ProjectedShadow::GetVisibility(
shadowIndex,
light.m_position,
@@ -0,0 +1,24 @@
/*
* 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
*
*/
#pragma once
float SampleESM(const Texture2DArray<float> shadowMap, const SamplerState samp, const float3 uv, const float zReceiver, const float esmExponent)
{
const float mipmaplevel = 0;
const float occluder = shadowMap.SampleLevel(samp,uv, mipmaplevel).r;
const float lit = exp((occluder - zReceiver) * esmExponent);
return lit;
}
float PCFFallbackForESM(const Texture2DArray<float> shadowMap, const float3 uv, const float zReceiver, const float esmExponent)
{
const float result = SampleESM(shadowMap, PassSrg::LinearSampler, uv, zReceiver, esmExponent);
return saturate(result);
}
@@ -15,6 +15,7 @@
#include "BicubicPcfFilters.azsli"
#include "Shadow.azsli"
#include "NormalOffsetShadows.azsli"
#include "ESM.azsli"
// ProjectedShadow calculates shadowed area projected from a light.
class ProjectedShadow
@@ -190,13 +191,11 @@ float ProjectedShadow::GetVisibilityEsm()
const float depth = PerspectiveDepthToLinear(
m_shadowPosition.z - m_bias,
coefficients);
const float occluder = shadowmap.SampleLevel(
PassSrg::LinearSampler,
float3(atlasPosition.xy * invAtlasSize, atlasPosition.z),
/*LOD=*/0).r;
const float3 uv = float3(atlasPosition.xy * invAtlasSize, atlasPosition.z);
const float esmExponent = ViewSrg::m_projectedShadows[m_shadowIndex].m_esmExponent;
const float ratio = SampleESM(shadowmap, PassSrg::LinearSampler, uv, depth, esmExponent);
const float exponent = -ViewSrg::m_projectedShadows[m_shadowIndex].m_esmExponent * (depth - occluder);
const float ratio = exp(exponent);
// pow() mitigates light bleeding to shadows from near shadow casters.
return saturate( pow(ratio, 8) );
}
@@ -229,21 +228,18 @@ float ProjectedShadow::GetVisibilityEsmPcf()
return 1.;
}
const float3 atlasPosition = GetAtlasPosition(m_shadowPosition.xy);
const float3 uv = float3(atlasPosition.xy * invAtlasSize, atlasPosition.z);
const float depth = PerspectiveDepthToLinear(
m_shadowPosition.z - m_bias,
coefficients);
const float occluder = shadowmap.SampleLevel(
PassSrg::LinearSampler,
float3(atlasPosition.xy * invAtlasSize, atlasPosition.z),
/*LOD=*/0).r;
const float exponent = -ViewSrg::m_projectedShadows[m_shadowIndex].m_esmExponent * (depth - occluder);
float ratio = exp(exponent);
const float esmExponent = ViewSrg::m_projectedShadows[m_shadowIndex].m_esmExponent;
float ratio = SampleESM(shadowmap, PassSrg::LinearSampler, uv, depth, esmExponent);
static const float pcfFallbackThreshold = 1.04;
if (ratio > pcfFallbackThreshold)
{
ratio = GetVisibilityPcf();
ratio = PCFFallbackForESM(shadowmap, uv, depth, esmExponent);
}
else
{
@@ -273,7 +273,7 @@ namespace EMotionFX
{
AZ::Vector3 boneCenter = nodeTransform.GetTranslation() + 0.5f * boneDirection;
float sumDistanceFromAxisSq = 0.0f;
float boneLengthSqReciprocal = 1.0f / boneDirection.GetLengthSq();
float boneLengthSqReciprocal = 1.0f / (boneLength * boneLength);
for (int i = 0; i < numMeshPoints; i++)
{
meshPoints[i] -= boneCenter;
@@ -299,7 +299,7 @@ namespace EMotionFX
{
Physics::CapsuleShapeConfiguration* capsule = static_cast<Physics::CapsuleShapeConfiguration*>(collider.second.get());
capsule->m_height = boneDirection.GetLength();
if (AZ::IsClose(localBoneDirection.GetLength(), 1.0f))
if (!localBoneDirection.IsZero())
{
collider.first->m_rotation = AZ::Quaternion::CreateShortestArc(AZ::Vector3::CreateAxisZ(), localBoneDirection.GetNormalized());
}
@@ -309,7 +309,7 @@ namespace EMotionFX
}
else if (colliderType == azrtti_typeid<Physics::BoxShapeConfiguration>())
{
if (AZ::IsClose(localBoneDirection.GetLength(), 1.0f))
if (!localBoneDirection.IsZero())
{
collider.first->m_rotation = AZ::Quaternion::CreateShortestArc(AZ::Vector3::CreateAxisZ(), localBoneDirection.GetNormalized());
}
@@ -933,6 +933,7 @@ namespace EMStudio
// save the current settings and disable rendering
m_renderOptions.SetLastUsedLayout(layout->GetName());
SaveRenderOptions();
ClearViewWidgets();
VisibilityChanged(false);
@@ -1138,6 +1138,12 @@ namespace EMStudio
for (size_t motionSetId = 0; motionSetId < numMotionSets; motionSetId++)
{
EMotionFX::MotionSet* motionSet2 = EMotionFX::GetMotionManager().GetMotionSet(motionSetId);
if (motionSet2->GetIsOwnedByRuntime())
{
continue;
}
if (motionSet2->FindMotionEntryById(motionEntry->GetId()))
{
numMotionSetContainsMotion++;
@@ -1148,12 +1154,6 @@ namespace EMStudio
}
}
// If motion exists in multiple motion sets, then it should not be removed from motions window.
if (removeMotion && numMotionSetContainsMotion > 1)
{
continue;
}
// check the reference counter if only one reference registered
// two is needed because the remove motion command has to be called to have the undo/redo possible
// without it the motion list is also not updated because the remove motion callback is not called
@@ -1170,6 +1170,12 @@ namespace EMStudio
}
motionIdsToRemoveString += motionEntry->GetId();
// If motion exists in multiple motion sets, then it should not be removed from motions window.
if (removeMotion && numMotionSetContainsMotion > 1)
{
continue;
}
// Check if the motion is not valid, that means the motion is not loaded.
if (removeMotion && motionEntry->GetMotion())
{
@@ -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(),
@@ -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,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/";
};
}
@@ -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)
@@ -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
@@ -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
)
@@ -27,8 +27,6 @@ AnchorPresetsWidget::AnchorPresetsWidget(int defaultPresetIndex,
, m_presetIndex(defaultPresetIndex)
, m_buttons(AnchorPresets::PresetIndexCount, nullptr)
{
setFixedSize(UICANVASEDITOR_ANCHOR_WIDGET_FIXED_SIZE, UICANVASEDITOR_ANCHOR_WIDGET_FIXED_SIZE);
// The layout.
QGridLayout* grid = new QGridLayout(this);
grid->setContentsMargins(0, 0, 0, 0);
@@ -38,6 +36,7 @@ AnchorPresetsWidget::AnchorPresetsWidget(int defaultPresetIndex,
{
for (int presetIndex = 0; presetIndex < AnchorPresets::PresetIndexCount; ++presetIndex)
{
QLayout* boxLayout = new QVBoxLayout();
PresetButton* button = new PresetButton(UICANVASEDITOR_ANCHOR_ICON_PATH_DEFAULT(presetIndex),
UICANVASEDITOR_ANCHOR_ICON_PATH_HOVER(presetIndex),
UICANVASEDITOR_ANCHOR_ICON_PATH_SELECTED(presetIndex),
@@ -50,8 +49,9 @@ AnchorPresetsWidget::AnchorPresetsWidget(int defaultPresetIndex,
presetChanger(presetIndex);
},
this);
grid->addWidget(button, (presetIndex / 4), (presetIndex % 4));
boxLayout->addWidget(button);
boxLayout->setContentsMargins(2, 2, 2, 2);
grid->addItem(boxLayout, (presetIndex / 4), (presetIndex % 4));
m_buttons[ presetIndex ] = button;
}
@@ -49,7 +49,7 @@ PropertiesWidget::PropertiesWidget(EditorWindow* editorWindow,
m_refreshTimer.setSingleShot(true);
}
setMinimumWidth(250);
setMinimumWidth(330);
ToolsApplicationEvents::Bus::Handler::BusConnect();
}
+1
View File
@@ -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

Some files were not shown because too many files have changed in this diff Show More