diff --git a/Assets/Editor/Icons/PhysX/Move.svg b/Assets/Editor/Icons/PhysX/Move.svg
deleted file mode 100644
index e9019bf226..0000000000
--- a/Assets/Editor/Icons/PhysX/Move.svg
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
diff --git a/Assets/Editor/Icons/PhysX/Rotate.svg b/Assets/Editor/Icons/PhysX/Rotate.svg
deleted file mode 100644
index 79bfb77540..0000000000
--- a/Assets/Editor/Icons/PhysX/Rotate.svg
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
\ No newline at end of file
diff --git a/Assets/Editor/Icons/PhysX/Scale.svg b/Assets/Editor/Icons/PhysX/Scale.svg
deleted file mode 100644
index f4879b89f6..0000000000
--- a/Assets/Editor/Icons/PhysX/Scale.svg
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
\ No newline at end of file
diff --git a/Assets/Editor/Icons/WhiteBox/Move.svg b/Assets/Editor/Icons/WhiteBox/Move.svg
deleted file mode 100644
index e9019bf226..0000000000
--- a/Assets/Editor/Icons/WhiteBox/Move.svg
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
diff --git a/Assets/Editor/Icons/WhiteBox/Rotate.svg b/Assets/Editor/Icons/WhiteBox/Rotate.svg
deleted file mode 100644
index 79bfb77540..0000000000
--- a/Assets/Editor/Icons/WhiteBox/Rotate.svg
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
\ No newline at end of file
diff --git a/Assets/Editor/Icons/WhiteBox/Scale.svg b/Assets/Editor/Icons/WhiteBox/Scale.svg
deleted file mode 100644
index f4879b89f6..0000000000
--- a/Assets/Editor/Icons/WhiteBox/Scale.svg
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
\ No newline at end of file
diff --git a/AutomatedTesting/CMakeLists.txt b/AutomatedTesting/CMakeLists.txt
index e239ba7674..9a870b1279 100644
--- a/AutomatedTesting/CMakeLists.txt
+++ b/AutomatedTesting/CMakeLists.txt
@@ -10,7 +10,7 @@
#
if(NOT PROJECT_NAME)
- cmake_minimum_required(VERSION 3.19)
+ cmake_minimum_required(VERSION 3.20)
project(AutomatedTesting
LANGUAGES C CXX
VERSION 1.0.0.0
diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py
index 173d658b3c..3f94a23696 100644
--- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py
+++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py
@@ -49,7 +49,7 @@ class TestViewMenuOptions(EditorTestHelper):
view_menu_options = [
("Center on Selection",),
("Show Quick Access Bar",),
- ("Viewport", "Wireframe"),
+ ("Viewport", "Configure Layout"),
("Viewport", "Go to Position"),
("Viewport", "Center on Selection"),
("Viewport", "Go to Location"),
diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_Menus.py b/AutomatedTesting/Gem/PythonTests/editor/test_Menus.py
index 2b3fdcbdf3..26231e33d7 100644
--- a/AutomatedTesting/Gem/PythonTests/editor/test_Menus.py
+++ b/AutomatedTesting/Gem/PythonTests/editor/test_Menus.py
@@ -89,7 +89,7 @@ class TestMenus(object):
expected_lines = [
"Center on Selection Action triggered",
"Show Quick Access Bar Action triggered",
- "Wireframe Action triggered",
+ "Configure Layout Action triggered",
"Go to Position Action triggered",
"Center on Selection Action triggered",
"Go to Location Action triggered",
diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py
index 90027be2d7..73800a54be 100755
--- a/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py
+++ b/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py
@@ -56,6 +56,7 @@ def C18243584_Joints_HingeSoftLimitsConstrained():
"""
import os
import sys
+ import math
import ImportPathHelper as imports
@@ -93,22 +94,51 @@ def C18243584_Joints_HingeSoftLimitsConstrained():
Report.info_vector3(lead.position, "lead initial position:")
Report.info_vector3(follower.position, "follower initial position:")
leadInitialPosition = lead.position
- followerInitialPosition = follower.position
-
- # 4) Wait for several seconds
- general.idle_wait(4.0) # wait for lead and follower to move
-
+
+ # 4) Wait for the follower to move above the lead or Timeout
+ normalizedStartPos = JointsHelper.getRelativeVector(lead.position, follower.position)
+ normalizedStartPos = normalizedStartPos.GetNormalizedSafe()
+
+ class WaitCondition:
+ TARGET_ANGLE = math.radians(45)
+ TARGET_MAX_ANGLE = math.radians(180)
+
+ angleAchieved = 0.0
+ followerMovedAbove45Deg = False #this is expected to be true to pass the test
+ followerMovedAbove180Deg = True #this is expected to be false to pass the test
+
+ def checkConditionMet(self):
+ #calculate the current follower-lead vector
+ normalVec = JointsHelper.getRelativeVector(lead.position, follower.position)
+ normalVec = normalVec.GetNormalizedSafe()
+ #dot product + acos to get the angle
+ currentAngle = math.acos(normalizedStartPos.Dot(normalVec))
+ #if the angle is now less then last time, it is no longer rising, so end the test.
+ if currentAngle < self.angleAchieved:
+ return True
+
+ self.angleAchieved = currentAngle
+ self.followerMovedAbove45Deg = currentAngle > self.TARGET_ANGLE
+ self.followerMovedAbove180Deg = currentAngle > self.TARGET_MAX_ANGLE
+ return False
+
+ def isFollowerPositionCorrect(self):
+ return self.followerMovedAbove45Deg and not self.followerMovedAbove180Deg
+
+ waitCondition = WaitCondition()
+
+ MAX_WAIT_TIME = 5.0 #seconds
+ conditionMet = helper.wait_for_condition(lambda: waitCondition.checkConditionMet(), MAX_WAIT_TIME)
+
# 5) Check to see if lead and follower behaved as expected
- Report.info_vector3(lead.position, "lead position after 1 second:")
- Report.info_vector3(follower.position, "follower position after 1 second:")
+ Report.info_vector3(lead.position, "lead position after test:")
+ Report.info_vector3(follower.position, "follower position after test:")
leadPositionDelta = lead.position.Subtract(leadInitialPosition)
leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON)
Report.critical_result(Tests.check_lead_position, leadRemainedStill)
- followerMovedInXOnly = ((follower.position.x > leadInitialPosition.x) > FLOAT_EPSILON and
- (follower.position.z - leadInitialPosition.z) > FLOAT_EPSILON)
- Report.critical_result(Tests.check_follower_position, followerMovedInXOnly)
+ Report.critical_result(Tests.check_follower_position, conditionMet and waitCondition.isFollowerPositionCorrect())
# 6) Exit Game Mode
helper.exit_game_mode(Tests.exit_game_mode)
diff --git a/AutomatedTesting/Levels/Physics/C18243584_Joints_HingeSoftLimitsConstrained/C18243584_Joints_HingeSoftLimitsConstrained.ly b/AutomatedTesting/Levels/Physics/C18243584_Joints_HingeSoftLimitsConstrained/C18243584_Joints_HingeSoftLimitsConstrained.ly
index 585ca394f1..2307843887 100644
--- a/AutomatedTesting/Levels/Physics/C18243584_Joints_HingeSoftLimitsConstrained/C18243584_Joints_HingeSoftLimitsConstrained.ly
+++ b/AutomatedTesting/Levels/Physics/C18243584_Joints_HingeSoftLimitsConstrained/C18243584_Joints_HingeSoftLimitsConstrained.ly
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:16f592487e8973abcf6b696aee6e430924c22daac0d6bb781c9e76153cd932f7
-size 8885
+oid sha256:352a64f523b3246000393309fa7f14955fe554e0b792a4177349f0f2db8a2b62
+size 5901
diff --git a/AutomatedTesting/Levels/Physics/C18243586_Joints_HingeLeadFollowerCollide/C18243586_Joints_HingeLeadFollowerCollide.ly b/AutomatedTesting/Levels/Physics/C18243586_Joints_HingeLeadFollowerCollide/C18243586_Joints_HingeLeadFollowerCollide.ly
index d5675c2542..83ba9e3831 100644
--- a/AutomatedTesting/Levels/Physics/C18243586_Joints_HingeLeadFollowerCollide/C18243586_Joints_HingeLeadFollowerCollide.ly
+++ b/AutomatedTesting/Levels/Physics/C18243586_Joints_HingeLeadFollowerCollide/C18243586_Joints_HingeLeadFollowerCollide.ly
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:4d5c38cf9b97ae28c391916e6637aebf767d5ac009df61e730396fe8b116f3e5
-size 6913
+oid sha256:31bd1feb92c3bb8a5c5df4638927a9a80e879329965732c4c32f673c236a8b0a
+size 6021
diff --git a/AutomatedTesting/Levels/Physics/C18243589_Joints_BallSoftLimitsConstrained/C18243589_Joints_BallSoftLimitsConstrained.ly b/AutomatedTesting/Levels/Physics/C18243589_Joints_BallSoftLimitsConstrained/C18243589_Joints_BallSoftLimitsConstrained.ly
index 6091c9e137..ecd4b61cb0 100644
--- a/AutomatedTesting/Levels/Physics/C18243589_Joints_BallSoftLimitsConstrained/C18243589_Joints_BallSoftLimitsConstrained.ly
+++ b/AutomatedTesting/Levels/Physics/C18243589_Joints_BallSoftLimitsConstrained/C18243589_Joints_BallSoftLimitsConstrained.ly
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:a6f26f1c1c037fa0b848ac9b3d9a76e476b4853d770f1a77c01714286733b567
-size 6921
+oid sha256:063779c1e80ce22319cb82ff0d7635d3dcbb043b789c3830cc405ffa36d3c0ef
+size 5876
diff --git a/AutomatedTesting/Levels/Physics/C18243591_Joints_BallLeadFollowerCollide/C18243591_Joints_BallLeadFollowerCollide.ly b/AutomatedTesting/Levels/Physics/C18243591_Joints_BallLeadFollowerCollide/C18243591_Joints_BallLeadFollowerCollide.ly
index e50ffc9dff..3991492730 100644
--- a/AutomatedTesting/Levels/Physics/C18243591_Joints_BallLeadFollowerCollide/C18243591_Joints_BallLeadFollowerCollide.ly
+++ b/AutomatedTesting/Levels/Physics/C18243591_Joints_BallLeadFollowerCollide/C18243591_Joints_BallLeadFollowerCollide.ly
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:4ffd3c4ee04fa8a414995c39c7ca79246e3d9b0ceee1ad1b85d61a5298f71495
-size 6940
+oid sha256:5bd3a952841aa924a4869c74fad7ed397667a87948270f0ce35f314e6cf2e14a
+size 5927
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6ca9aeacb8..4a12e0c50a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,17 +9,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
-# Cmake version 3.19 is the minimum version needed for all of Open 3D Engine's supported platforms
-cmake_minimum_required(VERSION 3.19)
-
-# CMP0111 introduced in 3.19 has a bug that produces the policy to warn every time there is an
-# INTERFACE IMPORTED library. We use this type of libraries for handling 3rdParty. The rest of
-# the documentation states that INTERFACE IMPORTED libraries do not require to set locations, but
-# the policy still warns about it. Issue: https://gitlab.kitware.com/cmake/cmake/-/issues/21470
-# The issue was fixed in 3.19.1 so we just disable the policy for 3.19
-if(CMAKE_VERSION VERSION_EQUAL 3.19)
- cmake_policy(SET CMP0111 OLD)
-endif()
+# Cmake version 3.20 is the minimum version needed for all of Open 3D Engine's supported platforms
+cmake_minimum_required(VERSION 3.20)
include(cmake/LySet.cmake)
include(cmake/Version.cmake)
@@ -114,24 +105,25 @@ endforeach()
# Post-processing
################################################################################
# The following steps have to be done after all targets are registered:
-# Defer generation of the StaticModules.inl file which is needed to create the AZ::Module derived class in monolithic
-# builds until after all the targets are known
-ly_delayed_generate_static_modules_inl()
# 1. Add any dependencies registered via ly_enable_gems
ly_enable_gems_delayed()
-# 2. generate a settings registry .setreg file for all ly_add_project_dependencies() and ly_add_target_dependencies() calls
+# 2. Defer generation of the StaticModules.inl file which is needed to create the AZ::Module derived class in monolithic
+# builds until after all the targets are known and all the gems are enabled
+ly_delayed_generate_static_modules_inl()
+
+# 3. generate a settings registry .setreg file for all ly_add_project_dependencies() and ly_add_target_dependencies() calls
# to provide applications with the filenames of gem modules to load
# This must be done before ly_delayed_target_link_libraries() as that inserts BUILD_DEPENDENCIES as MANUALLY_ADDED_DEPENDENCIES
# if the build dependency is a MODULE_LIBRARY. That would cause a false load dependency to be generated
ly_delayed_generate_settings_registry()
-# 3. link targets where the dependency was yet not declared, we need to have the declaration so we do different
+# 4. link targets where the dependency was yet not declared, we need to have the declaration so we do different
# linking logic depending on the type of target
ly_delayed_target_link_libraries()
-# 4. generate a registry file for unit testing for platforms that support unit testing
+# 5. generate a registry file for unit testing for platforms that support unit testing
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
ly_delayed_generate_unit_test_module_registry()
endif()
diff --git a/Code/CryEngine/CryCommon/MTPseudoRandom.cpp b/Code/CryEngine/CryCommon/MTPseudoRandom.cpp
deleted file mode 100644
index 0796d92f66..0000000000
--- a/Code/CryEngine/CryCommon/MTPseudoRandom.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-// Original file Copyright Crytek GMBH or its affiliates, used under license.
-
-// Description : Marsenne Twister PRNG. See MT.h for more info.
-
-#include "MTPseudoRandom.h"
-// non-inline function definitions and static member definitions cannot
-// reside in header file because of the risk of multiple declarations
-
-void CMTRand_int32::gen_state() // generate new m_nState vector
-{
- for (int i = 0; i < (n - m); ++i)
- {
- m_nState[i] = m_nState[i + m] ^ twiddle(m_nState[i], m_nState[i + 1]);
- }
- for (int i = n - m; i < (n - 1); ++i)
- {
- m_nState[i] = m_nState[i + m - n] ^ twiddle(m_nState[i], m_nState[i + 1]);
- }
- m_nState[n - 1] = m_nState[m - 1] ^ twiddle(m_nState[n - 1], m_nState[0]);
- p = 0; // reset position
-}
-
-void CMTRand_int32::seed(uint32 s) // init by 32 bit seed
-{ //if (s == 0)
- //m_nRandom = 1;
- for (int i = 0; i < n; ++i)
- {
- m_nState[i] = 0x0UL;
- }
- m_nState[0] = s;
- for (int i = 1; i < n; ++i)
- {
- m_nState[i] = 1812433253UL * (m_nState[i - 1] ^ (m_nState[i - 1] >> 30)) + i;
- // see Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier
- // in the previous versions, MSBs of the seed affect only MSBs of the array m_nState
- // 2002/01/09 modified by Makoto Matsumoto
- }
- p = n; // force gen_state() to be called for next random number
-}
-
-void CMTRand_int32::seed(const uint32* array, int size) // init by array
-{
- seed(19650218UL);
- int i = 1, j = 0;
- for (int k = ((n > size) ? n : size); k; --k)
- {
- m_nState[i] = (m_nState[i] ^ ((m_nState[i - 1] ^ (m_nState[i - 1] >> 30)) * 1664525UL))
- + array[j] + j; // non linear
- ++j;
- j %= size;
- if ((++i) == n)
- {
- m_nState[0] = m_nState[n - 1];
- i = 1;
- }
- }
- for (int k = n - 1; k; --k)
- {
- PREFAST_SUPPRESS_WARNING(6385) PREFAST_SUPPRESS_WARNING(6386) m_nState[i] = (m_nState[i] ^ ((m_nState[i - 1] ^ (m_nState[i - 1] >> 30)) * 1566083941UL)) - i;
- if ((++i) == n)
- {
- m_nState[0] = m_nState[n - 1];
- i = 1;
- }
- }
- m_nState[0] = 0x80000000UL; // MSB is 1; assuring non-zero initial array
- p = n; // force gen_state() to be called for next random number
-}
diff --git a/Code/CryEngine/CryCommon/MTPseudoRandom.h b/Code/CryEngine/CryCommon/MTPseudoRandom.h
deleted file mode 100644
index 40075cf167..0000000000
--- a/Code/CryEngine/CryCommon/MTPseudoRandom.h
+++ /dev/null
@@ -1,166 +0,0 @@
-// mtrand.h
-// C++ include file for MT19937, with initialization improved 2002/1/26.
-// Coded by Takuji Nishimura and Makoto Matsumoto.
-// Ported to C++ by Jasper Bedaux 2003/1/1 (see http://www.bedaux.net/mtrand/).
-// The generators returning floating point numbers are based on
-// a version by Isaku Wada, 2002/01/09
-// Static shared data converted to per-instance, 2008-11-13 by JSP.
-//
-// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-// 1. Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// 3. The names of its contributors may not be used to endorse or promote
-// products derived from this software without specific prior written
-// permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Any feedback is very welcome.
-// http://www.math.keio.ac.jp/matumoto/emt.html
-// email: matumoto@math.keio.ac.jp
-//
-// Feedback about the C++ port should be sent to Jasper Bedaux,
-// see http://www.bedaux.net/mtrand/ for e-mail address and info.
-
-//-------------------------------------------------------------------------
-// History:
-// - 28:7:2005: File created and minor changes by Marco Corbetta
-//
-//*************************************************************************/
-// Modifications copyright Amazon.com, Inc. or its affiliates
-
-#ifndef CRYINCLUDE_CRYCOMMON_MTPSEUDORANDOM_H
-#define CRYINCLUDE_CRYCOMMON_MTPSEUDORANDOM_H
-#pragma once
-
-#include
-
-//////////////////////////////////////////////////////////////////////////
-class CMTRand_int32
-{
- // Mersenne Twister random number generator
-
-public:
- // default constructor
- CMTRand_int32() { seed(5489UL); }
- // constructor with 32 bit int as seed
- CMTRand_int32(uint32 seed_value) { seed(seed_value); }
- // constructor with array of 32 bit integers as seed
- CMTRand_int32(const uint32* array, int size) { seed(array, size); }
- // seeds with 32 bit integer
- void seed(uint32 seed_value);
- // seeds with array
- void seed(const uint32*, int size);
- // overloaded operator() to make this a generator (functor)
- //uint32 operator()() { return rand_int32(); }
-
- ~CMTRand_int32() {}
-
- // Functions with PascalCase names were added for
- // interchangeability with CRndGen (see LCGRandom.h).
-
- void Seed(uint32 seed_value)
- {
- seed(seed_value);
- }
-
- uint32 GenerateUint32()
- {
- return rand_int32();
- }
-
- uint64 GenerateUint64()
- {
- const uint32 a = GenerateUint32();
- const uint32 b = GenerateUint32();
- return ((uint64)b << 32) | (uint64)a;
- }
-
- float GenerateFloat()
- {
- return (float)GenerateUint32() * (1.0f / 4294967295.0f);
- }
-
- // Ranged function returns random value within the *inclusive* range
- // between minValue and maxValue.
- // Any orderings work correctly: minValue <= maxValue and
- // minValue >= minValue.
- template
- T GetRandom(const T minValue, const T maxValue)
- {
- return CryRandom_Internal::BoundedRandom::Get(*this, minValue, maxValue);
- }
-
- // Vector (Vec2, Vec3, Vec4) ranged function returns vector with
- // every component within the *inclusive* ranges between minValue.component
- // and maxValue.component.
- // All orderings work correctly: minValue.component <= maxValue.component and
- // minValue.component >= maxValue.component.
- template
- T GetRandomComponentwise(const T& minValue, const T& maxValue)
- {
- return CryRandom_Internal::BoundedRandomComponentwise::Get(*this, minValue, maxValue);
- }
-
- // The function returns a random unit vector (Vec2, Vec3, Vec4).
- template
- T GetRandomUnitVector()
- {
- return CryRandom_Internal::GetRandomUnitVector(*this);
- }
-
-protected: // used by derived classes, otherwise not accessible; use the ()-operator
- // generates 32 bit random int
- uint32 rand_int32()
- {
- if (p >= n) gen_state(); // new m_nState vector needed
- // gen_state() is split off to be non-inline, because it is only called once
- // in every 624 calls and otherwise irand() would become too big to get inlined
- uint32 x = m_nState[p++];
- x ^= (x >> 11);
- x ^= (x << 7) & 0x9D2C5680UL;
- x ^= (x << 15) & 0xEFC60000UL;
- return x ^ (x >> 18);
- }
-
-private:
- static const int n = 624, m = 397; // compile time constants
-
- // the variables below are static (no duplicates can exist)
- uint32 m_nState[n+1]; // m_nState vector array
- int p; // position in m_nState array
- // private functions used to generate the pseudo random numbers
- uint32 twiddle(uint32 u, uint32 v)
- {
- return (((u & 0x80000000UL) | (v & 0x7FFFFFFFUL)) >> 1)
- ^ ((v & 1UL) ? 0x9908B0DFUL : 0x0UL);
- }
- void gen_state(); // generate new m_nState
- // make copy constructor and assignment operator unavailable, they don't make sense
- CMTRand_int32(const CMTRand_int32&); // copy constructor not defined
- void operator=(const CMTRand_int32&); // assignment operator not defined
-};
-
-
-#endif // CRYINCLUDE_CRYCOMMON_MTPSEUDORANDOM_H
diff --git a/Code/CryEngine/CryCommon/Random.h b/Code/CryEngine/CryCommon/Random.h
index 0f0a9f0e89..6de9136113 100644
--- a/Code/CryEngine/CryCommon/Random.h
+++ b/Code/CryEngine/CryCommon/Random.h
@@ -17,7 +17,6 @@
#include "BaseTypes.h"
#include "LCGRandom.h"
-#include "MTPseudoRandom.h"
namespace CryRandom_Internal
{
diff --git a/Code/CryEngine/CryCommon/crycommon_files.cmake b/Code/CryEngine/CryCommon/crycommon_files.cmake
index 660cf20276..567bbefca7 100644
--- a/Code/CryEngine/CryCommon/crycommon_files.cmake
+++ b/Code/CryEngine/CryCommon/crycommon_files.cmake
@@ -69,7 +69,6 @@ set(FILES
CryRandomInternal.h
Random.h
LCGRandom.h
- MTPseudoRandom.cpp
CryTypeInfo.cpp
BaseTypes.h
CompileTimeAssert.h
@@ -102,7 +101,6 @@ set(FILES
LegacyAllocator.h
MetaUtils.h
MiniQueue.h
- MTPseudoRandom.h
MultiThread.h
MultiThread_Containers.h
NullAudioSystem.h
diff --git a/Code/CryEngine/CrySystem/LevelSystem/LevelSystem.cpp b/Code/CryEngine/CrySystem/LevelSystem/LevelSystem.cpp
index aa5d638831..708835c0cc 100644
--- a/Code/CryEngine/CrySystem/LevelSystem/LevelSystem.cpp
+++ b/Code/CryEngine/CrySystem/LevelSystem/LevelSystem.cpp
@@ -321,7 +321,7 @@ void CLevelSystem::ScanFolder(const char* subfolder, bool modFolder)
{
if (AZ::StringFunc::Equal(handle.m_filename.data(), LevelPakName))
{
- // level folder contain pak files like 'level.pak'
+ // level folder contain pak files like 'level.pak'
// which we only want to load during level loading.
continue;
}
@@ -352,7 +352,7 @@ void CLevelSystem::ScanFolder(const char* subfolder, bool modFolder)
PopulateLevels(search, folder, pPak, modFolder, false);
// Load levels outside of the bundles to maintain backward compatibility.
PopulateLevels(search, folder, pPak, modFolder, true);
-
+
}
void CLevelSystem::PopulateLevels(
@@ -974,7 +974,7 @@ void CLevelSystem::UnloadLevel()
m_lastLevelName.clear();
SAFE_RELEASE(m_pCurrentLevel);
-
+
// Force Lua garbage collection (may no longer be needed now the legacy renderer has been removed).
// Normally the GC step is triggered at the end of this method (by the ESYSTEM_EVENT_LEVEL_POST_UNLOAD event).
EBUS_EVENT(AZ::ScriptSystemRequestBus, GarbageCollect);
diff --git a/Code/Framework/AzAutoGen/CMakeLists.txt b/Code/Framework/AzAutoGen/CMakeLists.txt
index 925e7aed29..4c79f268fe 100644
--- a/Code/Framework/AzAutoGen/CMakeLists.txt
+++ b/Code/Framework/AzAutoGen/CMakeLists.txt
@@ -9,8 +9,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
-cmake_minimum_required(VERSION 3.0)
-
ly_add_target(
NAME AzAutoGen HEADERONLY
NAMESPACE AZ
diff --git a/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathCommon_simd.inl b/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathCommon_simd.inl
index 770a8fa104..d06372256d 100644
--- a/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathCommon_simd.inl
+++ b/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathCommon_simd.inl
@@ -292,8 +292,13 @@ namespace AZ
const typename VecType::FloatType cmp2 = VecType::AndNot(cmp0, cmp1);
// -1/x
+ // this step is calculated for all values of x, but only used if x > Sqrt(2) + 1
+ // in order to avoid a division by zero, detect if xabs is zero here and replace it with an arbitrary value
+ // if xabs does equal zero, the value here doesn't matter because the result will be thrown away
+ typename VecType::FloatType xabsSafe =
+ VecType::Add(xabs, VecType::And(VecType::CmpEq(xabs, VecType::ZeroFloat()), FastLoadConstant(Simd::g_vec1111)));
const typename VecType::FloatType y0 = VecType::And(cmp0, FastLoadConstant(Simd::g_HalfPi));
- typename VecType::FloatType x0 = VecType::Div(FastLoadConstant(Simd::g_vec1111), xabs);
+ typename VecType::FloatType x0 = VecType::Div(FastLoadConstant(Simd::g_vec1111), xabsSafe);
x0 = VecType::Xor(x0, VecType::CastToFloat(FastLoadConstant(Simd::g_negateMask)));
const typename VecType::FloatType y1 = VecType::And(cmp2, FastLoadConstant(Simd::g_QuarterPi));
@@ -368,8 +373,12 @@ namespace AZ
typename VecType::FloatType offset = VecType::And(x_lt_0, offset1);
+ // the result of this part of the computation is thrown away if x equals 0,
+ // but if x does equal 0, it will cause a division by zero
+ // so replace zero by an arbitrary value here in that case
+ typename VecType::FloatType xSafe = VecType::Add(x, VecType::And(x_eq_0, FastLoadConstant(Simd::g_vec1111)));
const typename VecType::FloatType atan_mask = VecType::Not(VecType::Or(x_eq_0, y_eq_0));
- const typename VecType::FloatType atan_arg = VecType::Div(y, x);
+ const typename VecType::FloatType atan_arg = VecType::Div(y, xSafe);
typename VecType::FloatType atan_result = VecType::Atan(atan_arg);
atan_result = VecType::Add(atan_result, offset);
atan_result = VecType::AndNot(pio2_mask, atan_result);
diff --git a/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec2_sse.inl b/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec2_sse.inl
index 8f35af258c..63e2dca8fd 100644
--- a/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec2_sse.inl
+++ b/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec2_sse.inl
@@ -471,6 +471,7 @@ namespace AZ
AZ_MATH_INLINE Vec2::FloatType Vec2::Reciprocal(FloatArgType value)
{
+ value = Sse::ReplaceFourth(Sse::ReplaceThird(value, 1.0f), 1.0f);
return Sse::Reciprocal(value);
}
@@ -513,6 +514,7 @@ namespace AZ
AZ_MATH_INLINE Vec2::FloatType Vec2::SqrtInv(FloatArgType value)
{
+ value = Sse::ReplaceFourth(Sse::ReplaceThird(value, 1.0f), 1.0f);
return Sse::SqrtInv(value);
}
diff --git a/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec3_sse.inl b/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec3_sse.inl
index 78a0d5db66..75ee2ab7c5 100644
--- a/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec3_sse.inl
+++ b/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec3_sse.inl
@@ -507,6 +507,7 @@ namespace AZ
AZ_MATH_INLINE Vec3::FloatType Vec3::Reciprocal(FloatArgType value)
{
+ value = Sse::ReplaceFourth(value, 1.0f);
return Sse::Reciprocal(value);
}
@@ -549,6 +550,7 @@ namespace AZ
AZ_MATH_INLINE Vec3::FloatType Vec3::SqrtInv(FloatArgType value)
{
+ value = Sse::ReplaceFourth(value, 1.0f);
return Sse::SqrtInv(value);
}
diff --git a/Code/Framework/AzCore/AzCore/Utils/Utils.cpp b/Code/Framework/AzCore/AzCore/Utils/Utils.cpp
index 7025b3977e..e3647ec2cb 100644
--- a/Code/Framework/AzCore/AzCore/Utils/Utils.cpp
+++ b/Code/Framework/AzCore/AzCore/Utils/Utils.cpp
@@ -175,4 +175,11 @@ namespace AZ::Utils
path /= ".o3de";
return path.Native();
}
+
+ AZ::IO::FixedMaxPathString GetO3deLogsDirectory()
+ {
+ AZ::IO::FixedMaxPath path = GetO3deManifestDirectory();
+ path /= "Logs";
+ return path.Native();
+ }
}
diff --git a/Code/Framework/AzCore/AzCore/Utils/Utils.h b/Code/Framework/AzCore/AzCore/Utils/Utils.h
index d082a3ebe0..8fb6f05742 100644
--- a/Code/Framework/AzCore/AzCore/Utils/Utils.h
+++ b/Code/Framework/AzCore/AzCore/Utils/Utils.h
@@ -97,6 +97,9 @@ namespace AZ
//! Retrieves the full path where the manifest file lives, i.e. "/.o3de/o3de_manifest.json"
AZ::IO::FixedMaxPathString GetEngineManifestPath();
+ //! Retrieves the full directory to the O3DE logs directory, i.e. "/.o3de/Logs"
+ AZ::IO::FixedMaxPathString GetO3deLogsDirectory();
+
//! Retrieves the App root path to use on the current platform
//! If the optional is not engaged the AppRootPath should be calculated based
//! on the location of the bootstrap.cfg file
diff --git a/Code/Framework/AzCore/AzCore/std/math.h b/Code/Framework/AzCore/AzCore/std/math.h
index f5e2ac7ea7..fe2469eb41 100644
--- a/Code/Framework/AzCore/AzCore/std/math.h
+++ b/Code/Framework/AzCore/AzCore/std/math.h
@@ -26,6 +26,7 @@ namespace AZStd
using std::exp2;
using std::floor;
using std::fmod;
+ using std::pow;
using std::round;
using std::sin;
using std::sqrt;
diff --git a/Code/Framework/AzCore/Tests/Components.cpp b/Code/Framework/AzCore/Tests/Components.cpp
index 7801f69375..9d9bd46d3d 100644
--- a/Code/Framework/AzCore/Tests/Components.cpp
+++ b/Code/Framework/AzCore/Tests/Components.cpp
@@ -1555,7 +1555,9 @@ namespace UnitTest
}
}
- TEST_F(Components, EntityIdGeneration)
+ // Temporary disabled. This will be re-enabled in the short term upon completion of SPEC-7384 and
+ // fixed in the long term upon completion of SPEC-4849
+ TEST_F(Components, DISABLED_EntityIdGeneration)
{
// Generate 1 million ids across 100 threads, and ensure that none collide
AZStd::concurrent_unordered_set entityIds;
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsJoint.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsJoint.cpp
new file mode 100644
index 0000000000..c654038ead
--- /dev/null
+++ b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsJoint.cpp
@@ -0,0 +1,36 @@
+/*
+* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
+* its licensors.
+*
+* For complete copyright and license terms please see the LICENSE at the root of this
+* distribution (the "License"). All use of this software is governed by the License,
+* or, if provided, by the license below or the license accompanying this file. Do not
+* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+*/
+
+#include
+
+#include
+#include
+
+#include
+#include
+
+namespace AzPhysics
+{
+ AZ_CLASS_ALLOCATOR_IMPL(Joint, AZ::SystemAllocator, 0);
+
+ void Joint::Reflect(AZ::ReflectContext* context)
+ {
+ if (auto* serializeContext = azdynamic_cast(context))
+ {
+ serializeContext->Class()
+ ->Version(1)
+ ->Field("SceneOwner", &Joint::m_sceneOwner)
+ ->Field("JointHandle", &Joint::m_jointHandle)
+ ;
+ }
+ }
+}
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsJoint.h b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsJoint.h
new file mode 100644
index 0000000000..a73a9e5cd4
--- /dev/null
+++ b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsJoint.h
@@ -0,0 +1,143 @@
+/*
+* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
+* its licensors.
+*
+* For complete copyright and license terms please see the LICENSE at the root of this
+* distribution (the "License"). All use of this software is governed by the License,
+* or, if provided, by the license below or the license accompanying this file. Do not
+* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+*/
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace AZ
+{
+ class ReflectContext;
+}
+
+namespace AzPhysics
+{
+ struct JointConfiguration;
+
+ //! Base class for all Joints in Physics.
+ struct Joint
+ {
+ AZ_CLASS_ALLOCATOR_DECL;
+ AZ_RTTI(AzPhysics::Joint, "{1EEC9382-3434-4866-9B18-E93F151A6F59}");
+ static void Reflect(AZ::ReflectContext* context);
+
+ virtual ~Joint() = default;
+
+ //! The current Scene the joint is contained.
+ SceneHandle m_sceneOwner = AzPhysics::InvalidSceneHandle;
+
+ //! The handle to this joint.
+ JointHandle m_jointHandle = AzPhysics::InvalidJointHandle;
+
+ //! Helper functions for setting user data.
+ //! @param userData Can be a pointer to any type as internally will be cast to a void*. Object lifetime not managed by the Joint.
+ template
+ void SetUserData(T* userData)
+ {
+ m_customUserData = static_cast(userData);
+ }
+ //! Helper functions for getting the set user data.
+ //! @return Will return a void* to the user data set.
+ void* GetUserData()
+ {
+ return m_customUserData;
+ }
+
+ virtual AZ::Crc32 GetNativeType() const = 0;
+ virtual void* GetNativePointer() const = 0;
+
+ virtual AzPhysics::SimulatedBodyHandle GetParentBodyHandle() const = 0;
+ virtual AzPhysics::SimulatedBodyHandle GetChildBodyHandle() const = 0;
+
+ virtual void SetParentBody(AzPhysics::SimulatedBodyHandle parentBody) = 0;
+ virtual void SetChildBody(AzPhysics::SimulatedBodyHandle childBody) = 0;
+
+ virtual void GenerateJointLimitVisualizationData(
+ [[ maybe_unused ]] float scale,
+ [[ maybe_unused ]] AZ::u32 angularSubdivisions,
+ [[ maybe_unused ]] AZ::u32 radialSubdivisions,
+ [[ maybe_unused ]] AZStd::vector& vertexBufferOut,
+ [[ maybe_unused ]] AZStd::vector& indexBufferOut,
+ [[ maybe_unused ]] AZStd::vector& lineBufferOut,
+ [[ maybe_unused ]] AZStd::vector& lineValidityBufferOut) { }
+
+ private:
+ void* m_customUserData = nullptr;
+ };
+
+ //! Alias for a list of non owning weak pointers to Joint objects.
+ using JointList = AZStd::vector;
+
+ //! Interface to access Joint utilities and helper functions
+ class JointHelpersInterface
+ {
+ public:
+ AZ_RTTI(AzPhysics::JointHelpersInterface, "{A511C64D-C8A5-4E8F-9C69-8DC5EFAD0C4C}");
+
+ JointHelpersInterface() = default;
+ virtual ~JointHelpersInterface() = default;
+ AZ_DISABLE_COPY_MOVE(JointHelpersInterface);
+
+ //! Returns a list of supported Joint types
+ virtual const AZStd::vector GetSupportedJointTypeIds() const = 0;
+
+ //! Returns a TypeID if the request joint type is supported.
+ //! If the Physics backend supports this joint type JointHelpersInterface::GetSupportedJointTypeId will return a AZ::TypeId.
+ virtual AZStd::optional GetSupportedJointTypeId(JointType typeEnum) const = 0;
+
+ //! Computes parameters such as joint limit local rotations to give the desired initial joint limit orientation.
+ //! @param jointLimitTypeId The type ID used to identify the particular kind of joint limit configuration to be created.
+ //! @param parentWorldRotation The rotation in world space of the parent world body associated with the joint.
+ //! @param childWorldRotation The rotation in world space of the child world body associated with the joint.
+ //! @param axis Axis used to define the centre for limiting angular degrees of freedom.
+ //! @param exampleLocalRotations A vector (which may be empty) containing example valid rotations in the local space
+ //! of the child world body relative to the parent world body, which may optionally be used to help estimate the extents
+ //! of the joint limit.
+ virtual AZStd::unique_ptr ComputeInitialJointLimitConfiguration(
+ const AZ::TypeId& jointLimitTypeId,
+ const AZ::Quaternion& parentWorldRotation,
+ const AZ::Quaternion& childWorldRotation,
+ const AZ::Vector3& axis,
+ const AZStd::vector& exampleLocalRotations) = 0;
+
+ /// Generates joint limit visualization data in appropriate format to pass to DebugDisplayRequests draw functions.
+ /// @param configuration The joint configuration to generate visualization data for.
+ /// @param parentRotation The rotation of the joint's parent body (in the same frame as childRotation).
+ /// @param childRotation The rotation of the joint's child body (in the same frame as parentRotation).
+ /// @param scale Scale factor for the output display data.
+ /// @param angularSubdivisions Level of detail in the angular direction (may be clamped in the implementation).
+ /// @param radialSubdivisions Level of detail in the radial direction (may be clamped in the implementation).
+ /// @param[out] vertexBufferOut Used with indexBufferOut to define triangles to be displayed.
+ /// @param[out] indexBufferOut Used with vertexBufferOut to define triangles to be displayed.
+ /// @param[out] lineBufferOut Used to define lines to be displayed.
+ /// @param[out] lineValidityBufferOut Whether each line in the line buffer is part of a valid or violated limit.
+ virtual void GenerateJointLimitVisualizationData(
+ const JointConfiguration& configuration,
+ const AZ::Quaternion& parentRotation,
+ const AZ::Quaternion& childRotation,
+ float scale,
+ AZ::u32 angularSubdivisions,
+ AZ::u32 radialSubdivisions,
+ AZStd::vector& vertexBufferOut,
+ AZStd::vector& indexBufferOut,
+ AZStd::vector& lineBufferOut,
+ AZStd::vector& lineValidityBufferOut) = 0;
+ };
+}
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsTypes.h b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsTypes.h
index b2b5fd1511..42aee35c2c 100644
--- a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsTypes.h
+++ b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsTypes.h
@@ -51,8 +51,10 @@ namespace AzPhysics
using SceneIndex = AZ::s8;
using SimulatedBodyIndex = AZ::s32;
+ using JointIndex = AZ::s32;
static_assert(std::is_signed::value
- && std::is_signed::value, "SceneIndex and SimulatedBodyIndex must be signed integers.");
+ && std::is_signed::value
+ && std::is_signed::value, "SceneIndex, SimulatedBodyIndex and JointIndex must be signed integers.");
//! A handle to a Scene within the physics simulation.
@@ -69,12 +71,27 @@ namespace AzPhysics
static constexpr SimulatedBodyHandle InvalidSimulatedBodyHandle = { AZ::Crc32(), -1 };
using SimulatedBodyHandleList = AZStd::vector;
+ //! A handle to a Joint within a physics scene.
+ //! A JointHandle is a tuple of a Crc of the scene's name and the index in the Joint list.
+ using JointHandle = AZStd::tuple;
+ static constexpr JointHandle InvalidJointHandle = { AZ::Crc32(), -1 };
+
//! Helper used for pairing the ShapeConfiguration and ColliderConfiguration together which is used when creating a Simulated Body.
using ShapeColliderPair = AZStd::pair<
AZStd::shared_ptr,
AZStd::shared_ptr>;
using ShapeColliderPairList = AZStd::vector;
+ //! Joint types are used to request for AZ::TypeId with the JointHelpersInterface::GetSupportedJointTypeId.
+ //! If the Physics backend supports this joint type JointHelpersInterface::GetSupportedJointTypeId will return a AZ::TypeId.
+ enum class JointType
+ {
+ D6Joint,
+ FixedJoint,
+ BallJoint,
+ HingeJoint
+ };
+
//! Flags used to specifying which properties of a body to compute.
enum class MassComputeFlags : AZ::u8
{
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Configuration/JointConfiguration.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Configuration/JointConfiguration.cpp
new file mode 100644
index 0000000000..aa58136944
--- /dev/null
+++ b/Code/Framework/AzFramework/AzFramework/Physics/Configuration/JointConfiguration.cpp
@@ -0,0 +1,37 @@
+/*
+* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
+* its licensors.
+*
+* For complete copyright and license terms please see the LICENSE at the root of this
+* distribution (the "License"). All use of this software is governed by the License,
+* or, if provided, by the license below or the license accompanying this file. Do not
+* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+*/
+
+#include
+
+#include
+#include
+
+namespace AzPhysics
+{
+ AZ_CLASS_ALLOCATOR_IMPL(JointConfiguration, AZ::SystemAllocator, 0);
+
+ void JointConfiguration::Reflect(AZ::ReflectContext* context)
+ {
+ if (auto* serializeContext = azrtti_cast(context))
+ {
+ serializeContext->Class()
+ ->Version(1)
+ ->Field("Name", &JointConfiguration::m_debugName)
+ ->Field("ParentLocalRotation", &JointConfiguration::m_parentLocalRotation)
+ ->Field("ParentLocalPosition", &JointConfiguration::m_parentLocalPosition)
+ ->Field("ChildLocalRotation", &JointConfiguration::m_childLocalRotation)
+ ->Field("ChildLocalPosition", &JointConfiguration::m_childLocalPosition)
+ ->Field("StartSimulationEnabled", &JointConfiguration::m_startSimulationEnabled)
+ ;
+ }
+ }
+}
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Configuration/JointConfiguration.h b/Code/Framework/AzFramework/AzFramework/Physics/Configuration/JointConfiguration.h
new file mode 100644
index 0000000000..8ebe1199a8
--- /dev/null
+++ b/Code/Framework/AzFramework/AzFramework/Physics/Configuration/JointConfiguration.h
@@ -0,0 +1,51 @@
+/*
+* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
+* its licensors.
+*
+* For complete copyright and license terms please see the LICENSE at the root of this
+* distribution (the "License"). All use of this software is governed by the License,
+* or, if provided, by the license below or the license accompanying this file. Do not
+* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+*/
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace AZ
+{
+ class ReflectContext;
+}
+
+namespace AzPhysics
+{
+ //! Base Class of all Physics Joints that will be simulated.
+ struct JointConfiguration
+ {
+ AZ_CLASS_ALLOCATOR_DECL;
+ AZ_RTTI(AzPhysics::JointConfiguration, "{DF91D39A-4901-48C4-9159-93FD2ACA5252}");
+ static void Reflect(AZ::ReflectContext* context);
+
+ JointConfiguration() = default;
+ virtual ~JointConfiguration() = default;
+
+ // Entity/object association.
+ void* m_customUserData = nullptr;
+
+ // Basic initial settings.
+ AZ::Quaternion m_parentLocalRotation = AZ::Quaternion::CreateIdentity(); ///< Parent joint frame relative to parent body.
+ AZ::Vector3 m_parentLocalPosition = AZ::Vector3::CreateZero(); ///< Joint position relative to parent body.
+ AZ::Quaternion m_childLocalRotation = AZ::Quaternion::CreateIdentity(); ///< Child joint frame relative to child body.
+ AZ::Vector3 m_childLocalPosition = AZ::Vector3::CreateZero(); ///< Joint position relative to child body.
+ bool m_startSimulationEnabled = true;
+
+ // For debugging/tracking purposes only.
+ AZStd::string m_debugName;
+ };
+}
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Joint.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Joint.cpp
deleted file mode 100644
index 965583c113..0000000000
--- a/Code/Framework/AzFramework/AzFramework/Physics/Joint.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-
-#include
-#include
-#include
-#include
-
-namespace Physics
-{
- const char* JointLimitConfiguration::GetTypeName()
- {
- return "Base Joint";
- }
-
- void JointLimitConfiguration::Reflect(AZ::ReflectContext* context)
- {
- if (auto serializeContext = azrtti_cast(context))
- {
- serializeContext->Class()
- ->Version(1)
- ->Field("ParentLocalRotation", &JointLimitConfiguration::m_parentLocalRotation)
- ->Field("ParentLocalPosition", &JointLimitConfiguration::m_parentLocalPosition)
- ->Field("ChildLocalRotation", &JointLimitConfiguration::m_childLocalRotation)
- ->Field("ChildLocalPosition", &JointLimitConfiguration::m_childLocalPosition)
- ;
-
- AZ::EditContext* editContext = serializeContext->GetEditContext();
- if (editContext)
- {
- editContext->Class(
- "Joint Configuration", "")
- ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
- ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
- ->DataElement(AZ::Edit::UIHandlers::Default, &JointLimitConfiguration::m_parentLocalRotation,
- "Parent local rotation", "The rotation of the parent joint frame relative to the parent body")
- ->DataElement(AZ::Edit::UIHandlers::Default, &JointLimitConfiguration::m_parentLocalPosition,
- "Parent local position", "The position of the joint in the frame of the parent body")
- ->DataElement(AZ::Edit::UIHandlers::Default, &JointLimitConfiguration::m_childLocalRotation,
- "Child local rotation", "The rotation of the child joint frame relative to the child body")
- ->DataElement(AZ::Edit::UIHandlers::Default, &JointLimitConfiguration::m_childLocalPosition,
- "Child local position", "The position of the joint in the frame of the child body")
- ;
- }
- }
- }
-} // namespace Physics
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Joint.h b/Code/Framework/AzFramework/AzFramework/Physics/Joint.h
deleted file mode 100644
index d78ce74611..0000000000
--- a/Code/Framework/AzFramework/AzFramework/Physics/Joint.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-* its licensors.
-*
-* For complete copyright and license terms please see the LICENSE at the root of this
-* distribution (the "License"). All use of this software is governed by the License,
-* or, if provided, by the license below or the license accompanying this file. Do not
-* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*
-*/
-
-#pragma once
-
-#include
-#include
-
-namespace AzPhysics
-{
- struct SimulatedBody;
-}
-
-namespace Physics
-{
- class JointLimitConfiguration
- {
- public:
- AZ_CLASS_ALLOCATOR(JointLimitConfiguration, AZ::SystemAllocator, 0);
- AZ_RTTI(JointLimitConfiguration, "{C9B70C4D-22D7-45AB-9B0A-30A4ED5E42DB}");
- static void Reflect(AZ::ReflectContext* context);
-
- JointLimitConfiguration() = default;
- JointLimitConfiguration(const JointLimitConfiguration&) = default;
- virtual ~JointLimitConfiguration() = default;
-
- virtual const char* GetTypeName();
-
- AZ::Quaternion m_parentLocalRotation = AZ::Quaternion::CreateIdentity(); ///< Parent joint frame relative to parent body.
- AZ::Vector3 m_parentLocalPosition = AZ::Vector3::CreateZero(); ///< Joint position relative to parent body.
- AZ::Quaternion m_childLocalRotation = AZ::Quaternion::CreateIdentity(); ///< Child joint frame relative to child body.
- AZ::Vector3 m_childLocalPosition = AZ::Vector3::CreateZero(); ///< Joint position relative to child body.
- };
-
- class Joint
- {
- public:
- AZ_CLASS_ALLOCATOR(Joint, AZ::SystemAllocator, 0);
- AZ_RTTI(Joint, "{405F517C-E986-4ACB-9606-D5D080DDE987}");
-
- virtual AzPhysics::SimulatedBody* GetParentBody() const = 0;
- virtual AzPhysics::SimulatedBody* GetChildBody() const = 0;
- virtual void SetParentBody(AzPhysics::SimulatedBody* parentBody) = 0;
- virtual void SetChildBody(AzPhysics::SimulatedBody* childBody) = 0;
- virtual const AZStd::string& GetName() const = 0;
- virtual void SetName(const AZStd::string& name) = 0;
- virtual const AZ::Crc32 GetNativeType() const = 0;
- virtual void* GetNativePointer() = 0;
- /// Generates joint limit visualization data in appropriate format to pass to DebugDisplayRequests draw functions.
- /// @param scale Scale factor for the output display data.
- /// @param angularSubdivisions Level of detail in the angular direction (may be clamped in the implementation).
- /// @param radialSubdivisions Level of detail in the radial direction (may be clamped in the implementation).
- /// @param[out] vertexBufferOut Used with indexBufferOut to define triangles to be displayed.
- /// @param[out] indexBufferOut Used with vertexBufferOut to define triangles to be displayed.
- /// @param[out] lineBufferOut Used to define lines to be displayed.
- /// @param[out] lineValidityBufferOut Whether each line in the line buffer is part of a valid or violated limit.
- virtual void GenerateJointLimitVisualizationData(
- float scale,
- AZ::u32 angularSubdivisions,
- AZ::u32 radialSubdivisions,
- AZStd::vector& vertexBufferOut,
- AZStd::vector& indexBufferOut,
- AZStd::vector& lineBufferOut,
- AZStd::vector& lineValidityBufferOut) = 0;
- };
-} // namespace Physics
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/PhysicsScene.h b/Code/Framework/AzFramework/AzFramework/Physics/PhysicsScene.h
index 58e53b0b0d..c93278e7bf 100644
--- a/Code/Framework/AzFramework/AzFramework/Physics/PhysicsScene.h
+++ b/Code/Framework/AzFramework/AzFramework/Physics/PhysicsScene.h
@@ -16,6 +16,8 @@
#include
#include
#include
+#include
+#include
#include
namespace AzPhysics
@@ -103,6 +105,26 @@ namespace AzPhysics
virtual void EnableSimulationOfBody(SceneHandle sceneHandle, SimulatedBodyHandle bodyHandle) = 0;
virtual void DisableSimulationOfBody(SceneHandle sceneHandle, SimulatedBodyHandle bodyHandle) = 0;
+ //! Add a joint to the Scene.
+ //! @param sceneHandle A handle to the scene to add / remove the joint.
+ //! @param jointConfig The config of the joint.
+ //! @param parentBody The parent body of the joint.
+ //! @param childBody The child body of the joint
+ //! @return Returns a handle to the created joint. Will return AzPhyiscs::InvalidJointHandle if it fails.
+ virtual JointHandle AddJoint(SceneHandle sceneHandle, const JointConfiguration* jointConfig,
+ SimulatedBodyHandle parentBody, SimulatedBodyHandle childBody) = 0;
+
+ //! Get the Raw pointer to the requested joint.
+ //! @param sceneHandle A handle to the scene to get the simulated bodies from.
+ //! @param jointHandle A handle to the joint to retrieve the raw pointer.
+ //! @return A raw pointer to the Joint body. If the either handle is invalid this will return null.
+ virtual Joint* GetJointFromHandle(SceneHandle sceneHandle, JointHandle jointHandle) = 0;
+
+ //! Remove a joint from the Scene.
+ //! @param sceneHandle A handle to the scene to add / remove the joint.
+ //! @param jointHandle A handle to the joint being removed.
+ virtual void RemoveJoint(SceneHandle sceneHandle, JointHandle jointHandle) = 0;
+
//! Make a blocking query into the scene.
//! @param sceneHandle A handle to the scene to make the scene query with.
//! @param request The request to make. Should be one of RayCastRequest || ShapeCastRequest || OverlapRequest
@@ -299,6 +321,23 @@ namespace AzPhysics
virtual void EnableSimulationOfBody(SimulatedBodyHandle bodyHandle) = 0;
virtual void DisableSimulationOfBody(SimulatedBodyHandle bodyHandle) = 0;
+ //! Add a joint to the Scene.
+ //! @param jointConfig The config of the joint.
+ //! @param parentBody The parent body of the joint.
+ //! @param childBody The child body of the joint
+ //! @return Returns a handle to the created joint. Will return AzPhyiscs::InvalidJointHandle if it fails.
+ virtual JointHandle AddJoint(const JointConfiguration* jointConfig,
+ SimulatedBodyHandle parentBody, SimulatedBodyHandle childBody) = 0;
+
+ //! Get the Raw pointer to the requested joint.
+ //! @param jointHandle A handle to the joint to retrieve the raw pointer.
+ //! @return A raw pointer to the Joint body. If the either handle is invalid this will return null.
+ virtual Joint* GetJointFromHandle(JointHandle jointHandle) = 0;
+
+ //! Remove a joint from the Scene.
+ //! @param jointHandle A handle to the joint being removed.
+ virtual void RemoveJoint(JointHandle jointHandle) = 0;
+
//! Make a blocking query into the scene.
//! @param request The request to make. Should be one of RayCastRequest || ShapeCastRequest || OverlapRequest
//! @return Returns a structure that contains a list of Hits. Depending on flags set in the request, this may only contain 1 result.
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Ragdoll.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Ragdoll.cpp
index f634360445..f4b88fe087 100644
--- a/Code/Framework/AzFramework/AzFramework/Physics/Ragdoll.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Physics/Ragdoll.cpp
@@ -36,8 +36,8 @@ namespace Physics
if (serializeContext)
{
serializeContext->Class()
- ->Version(4, &ClassConverters::RagdollNodeConfigConverter)
- ->Field("JointLimit", &RagdollNodeConfiguration::m_jointLimit)
+ ->Version(5, &ClassConverters::RagdollNodeConfigConverter)
+ ->Field("JointConfig", &RagdollNodeConfiguration::m_jointConfig)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Ragdoll.h b/Code/Framework/AzFramework/AzFramework/Physics/Ragdoll.h
index 97c841e8f8..5dcc93c9da 100644
--- a/Code/Framework/AzFramework/AzFramework/Physics/Ragdoll.h
+++ b/Code/Framework/AzFramework/AzFramework/Physics/Ragdoll.h
@@ -17,10 +17,11 @@
#include
#include
#include
-#include
#include
+#include
#include
#include
+#include
namespace Physics
{
@@ -37,7 +38,7 @@ namespace Physics
RagdollNodeConfiguration();
RagdollNodeConfiguration(const RagdollNodeConfiguration& settings) = default;
- AZStd::shared_ptr m_jointLimit;
+ AZStd::shared_ptr m_jointConfig;
};
class RagdollConfiguration
@@ -73,7 +74,7 @@ namespace Physics
virtual AzPhysics::RigidBody& GetRigidBody() = 0;
virtual ~RagdollNode() = default;
- virtual const AZStd::shared_ptr& GetJoint() const = 0;
+ virtual AzPhysics::Joint* GetJoint() = 0;
virtual bool IsSimulating() const = 0;
};
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/SystemBus.h b/Code/Framework/AzFramework/AzFramework/Physics/SystemBus.h
index 8cdd0e0cf0..73e9e4197a 100644
--- a/Code/Framework/AzFramework/AzFramework/Physics/SystemBus.h
+++ b/Code/Framework/AzFramework/AzFramework/Physics/SystemBus.h
@@ -26,23 +26,15 @@ namespace AZ
namespace AzPhysics
{
struct SimulatedBody;
- struct RigidBodyConfiguration;
- struct RigidBody;
}
namespace Physics
{
- class WorldBody;
class Shape;
class Material;
- class MaterialSelection;
class MaterialConfiguration;
class ColliderConfiguration;
class ShapeConfiguration;
- class JointLimitConfiguration;
- class Joint;
- class CharacterConfiguration;
- class Character;
/// Represents a debug vertex (position & color).
struct DebugDrawVertex
@@ -148,51 +140,6 @@ namespace Physics
/// @param nativeMeshObject Pointer to the mesh object.
virtual void ReleaseNativeMeshObject(void* nativeMeshObject) = 0;
- //////////////////////////////////////////////////////////////////////////
- //// Joints
-
- virtual AZStd::vector GetSupportedJointTypes() = 0;
- virtual AZStd::shared_ptr CreateJointLimitConfiguration(AZ::TypeId jointType) = 0;
- virtual AZStd::shared_ptr CreateJoint(const AZStd::shared_ptr& configuration,
- AzPhysics::SimulatedBody* parentBody, AzPhysics::SimulatedBody* childBody) = 0;
- /// Generates joint limit visualization data in appropriate format to pass to DebugDisplayRequests draw functions.
- /// @param configuration The joint configuration to generate visualization data for.
- /// @param parentRotation The rotation of the joint's parent body (in the same frame as childRotation).
- /// @param childRotation The rotation of the joint's child body (in the same frame as parentRotation).
- /// @param scale Scale factor for the output display data.
- /// @param angularSubdivisions Level of detail in the angular direction (may be clamped in the implementation).
- /// @param radialSubdivisions Level of detail in the radial direction (may be clamped in the implementation).
- /// @param[out] vertexBufferOut Used with indexBufferOut to define triangles to be displayed.
- /// @param[out] indexBufferOut Used with vertexBufferOut to define triangles to be displayed.
- /// @param[out] lineBufferOut Used to define lines to be displayed.
- /// @param[out] lineValidityBufferOut Whether each line in the line buffer is part of a valid or violated limit.
- virtual void GenerateJointLimitVisualizationData(
- const JointLimitConfiguration& configuration,
- const AZ::Quaternion& parentRotation,
- const AZ::Quaternion& childRotation,
- float scale,
- AZ::u32 angularSubdivisions,
- AZ::u32 radialSubdivisions,
- AZStd::vector& vertexBufferOut,
- AZStd::vector& indexBufferOut,
- AZStd::vector& lineBufferOut,
- AZStd::vector& lineValidityBufferOut) = 0;
-
- /// Computes parameters such as joint limit local rotations to give the desired initial joint limit orientation.
- /// @param jointLimitTypeId The type ID used to identify the particular kind of joint limit configuration to be created.
- /// @param parentWorldRotation The rotation in world space of the parent world body associated with the joint.
- /// @param childWorldRotation The rotation in world space of the child world body associated with the joint.
- /// @param axis Axis used to define the centre for limiting angular degrees of freedom.
- /// @param exampleLocalRotations A vector (which may be empty) containing example valid rotations in the local space
- /// of the child world body relative to the parent world body, which may optionally be used to help estimate the extents
- /// of the joint limit.
- virtual AZStd::unique_ptr ComputeInitialJointLimitConfiguration(
- const AZ::TypeId& jointLimitTypeId,
- const AZ::Quaternion& parentWorldRotation,
- const AZ::Quaternion& childWorldRotation,
- const AZ::Vector3& axis,
- const AZStd::vector& exampleLocalRotations) = 0;
-
//////////////////////////////////////////////////////////////////////////
//// Cooking
diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Utils.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Utils.cpp
index 17c09bb6ce..695fe1dcf5 100644
--- a/Code/Framework/AzFramework/AzFramework/Physics/Utils.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Physics/Utils.cpp
@@ -34,6 +34,7 @@
#include
#include
#include
+#include
namespace Physics
{
@@ -121,9 +122,9 @@ namespace Physics
DefaultMaterialConfiguration::Reflect(context);
MaterialLibraryAsset::Reflect(context);
MaterialInfoReflectionWrapper::Reflect(context);
- JointLimitConfiguration::Reflect(context);
AzPhysics::SimulatedBodyConfiguration::Reflect(context);
AzPhysics::RigidBodyConfiguration::Reflect(context);
+ AzPhysics::JointConfiguration::Reflect(context);
RagdollNodeConfiguration::Reflect(context);
RagdollConfiguration::Reflect(context);
CharacterColliderNodeConfiguration::Reflect(context);
@@ -131,6 +132,7 @@ namespace Physics
AnimationConfiguration::Reflect(context);
CharacterConfiguration::Reflect(context);
AzPhysics::SimulatedBody::Reflect(context);
+ AzPhysics::Joint::Reflect(context);
ReflectSimulatedBodyComponentRequestsBus(context);
CollisionFilteringRequests::Reflect(context);
AzPhysics::SceneQuery::ReflectSceneQueryObjects(context);
diff --git a/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp b/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp
index 4f8da821c1..d80094a071 100644
--- a/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp
+++ b/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp
@@ -693,11 +693,11 @@ namespace AzFramework
// set the __index so we can read values in case we change the script
// after we export the component
lua_pushliteral(lua, "__index");
- lua_pushcclosure(lua, &Internal::Properties__Index, 1);
+ lua_pushcclosure(lua, &Internal::Properties__Index, 0);
lua_rawset(lua, -3);
lua_pushliteral(lua, "__newindex");
- lua_pushcclosure(lua, &Internal::Properties__NewIndex, 1);
+ lua_pushcclosure(lua, &Internal::Properties__NewIndex, 0);
lua_rawset(lua, -3);
}
lua_pop(lua, 1); // pop the properties table (or the nil value)
@@ -900,11 +900,11 @@ namespace AzFramework
// Ensure that this instance of Properties table has the proper __index and __newIndex metamethods.
lua_newtable(lua); // This new table will become the Properties instance metatable. Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {}
lua_pushliteral(lua, "__index"); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {} __index
- lua_pushcclosure(lua, &Internal::Properties__Index, 1); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {} __index function
+ lua_pushcclosure(lua, &Internal::Properties__Index, 0); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {} __index function
lua_rawset(lua, -3); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {__index=Internal::Properties__Index}
lua_pushliteral(lua, "__newindex");
- lua_pushcclosure(lua, &Internal::Properties__NewIndex, 1);
+ lua_pushcclosure(lua, &Internal::Properties__NewIndex, 0);
lua_rawset(lua, -3); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {__index=Internal::Properties__Index __newindex=Internal::Properties__NewIndex}
lua_setmetatable(lua, -2); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {Meta{__index=Internal::Properties__Index __newindex=Internal::Properties__NewIndex} }
diff --git a/Code/Framework/AzFramework/AzFramework/azframework_files.cmake b/Code/Framework/AzFramework/AzFramework/azframework_files.cmake
index 13dff43f68..2a5d251400 100644
--- a/Code/Framework/AzFramework/AzFramework/azframework_files.cmake
+++ b/Code/Framework/AzFramework/AzFramework/azframework_files.cmake
@@ -204,6 +204,8 @@ set(FILES
Physics/Collision/CollisionLayers.cpp
Physics/Collision/CollisionGroups.h
Physics/Collision/CollisionGroups.cpp
+ Physics/Common/PhysicsJoint.h
+ Physics/Common/PhysicsJoint.cpp
Physics/Common/PhysicsSceneQueries.h
Physics/Common/PhysicsSceneQueries.cpp
Physics/Common/PhysicsEvents.h
@@ -215,6 +217,8 @@ set(FILES
Physics/Common/PhysicsSimulatedBodyEvents.cpp
Physics/Common/PhysicsTypes.h
Physics/Components/SimulatedBodyComponentBus.h
+ Physics/Configuration/JointConfiguration.h
+ Physics/Configuration/JointConfiguration.cpp
Physics/Configuration/CollisionConfiguration.h
Physics/Configuration/CollisionConfiguration.cpp
Physics/Configuration/RigidBodyConfiguration.h
@@ -259,8 +263,6 @@ set(FILES
Physics/Ragdoll.h
Physics/Utils.h
Physics/Utils.cpp
- Physics/Joint.h
- Physics/Joint.cpp
Physics/ClassConverters.cpp
Physics/ClassConverters.h
Physics/MaterialBus.h
diff --git a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkTestHelpers.h b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkTestHelpers.h
index b61956bdf9..d0107bb317 100644
--- a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkTestHelpers.h
+++ b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkTestHelpers.h
@@ -13,6 +13,7 @@
#pragma once
#include
+#include
#include
#include
#include
diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp
index 0f58f06420..47c0e66ff0 100644
--- a/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp
+++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp
@@ -493,6 +493,29 @@ namespace AzQtComponents
}
}
break;
+ case CE_MenuItem:
+ {
+ const QMenu* menu = qobject_cast(widget);
+ QAction* action = menu->activeAction();
+ if (action)
+ {
+ QMenu* subMenu = action->menu();
+ if (subMenu)
+ {
+ QVariant noHover = subMenu->property("noHover");
+ if (noHover.isValid() && noHover.toBool())
+ {
+ // First draw as standard to get the correct hover background for the complete control.
+ QProxyStyle::drawControl(element, option, painter, widget);
+ // Now draw the icon as non-hovered so control behaves as designed.
+ QStyleOptionMenuItem myOpt = *qstyleoption_cast(option);
+ myOpt.state &= ~QStyle::State_Selected;
+ return QProxyStyle::drawControl(element, &myOpt, painter, widget);
+ }
+ }
+ }
+ }
+ break;
}
return QProxyStyle::drawControl(element, option, painter, widget);
diff --git a/Assets/Editor/Icons/WhiteBox/RestoreMode.svg b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/toolbar/RestoreMode.svg
similarity index 100%
rename from Assets/Editor/Icons/WhiteBox/RestoreMode.svg
rename to Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/toolbar/RestoreMode.svg
diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/toolbar/Translate.svg b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/toolbar/Rotate.svg
similarity index 100%
rename from Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/toolbar/Translate.svg
rename to Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/toolbar/Rotate.svg
diff --git a/Assets/Editor/Icons/WhiteBox/SketchMode.svg b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/toolbar/SketchMode.svg
similarity index 100%
rename from Assets/Editor/Icons/WhiteBox/SketchMode.svg
rename to Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/toolbar/SketchMode.svg
diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc b/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc
index 7070bd372b..d6cd99b1d9 100644
--- a/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc
+++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc
@@ -370,6 +370,7 @@
img/UI20/toolbar/Redo.svgimg/UI20/toolbar/remove_link.svgimg/UI20/toolbar/Reset_physics_state.svg
+ img/UI20/toolbar/RestoreMode.svgimg/UI20/toolbar/Save.svgimg/UI20/toolbar/Scale.svgimg/UI20/toolbar/Select.svg
@@ -377,9 +378,10 @@
img/UI20/toolbar/Select_terrain.svgimg/UI20/toolbar/Simulate_Physics.svgimg/UI20/toolbar/Simulate_Physics_on_selected_objects.svg
+ img/UI20/toolbar/SketchMode.svgimg/UI20/toolbar/Terrain.svgimg/UI20/toolbar/Terrain_Texture.svg
- img/UI20/toolbar/Translate.svg
+ img/UI20/toolbar/Rotate.svgimg/UI20/toolbar/undo.svgimg/UI20/toolbar/Unlocked.svgimg/UI20/toolbar/Vertex_snapping.svg
diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Images/Notifications/link.svg b/Code/Framework/AzQtComponents/AzQtComponents/Images/Notifications/link.svg
index dfd21d157f..6f5608c092 100644
--- a/Code/Framework/AzQtComponents/AzQtComponents/Images/Notifications/link.svg
+++ b/Code/Framework/AzQtComponents/AzQtComponents/Images/Notifications/link.svg
@@ -1,4 +1,4 @@
diff --git a/Code/Framework/AzTest/CMakeLists.txt b/Code/Framework/AzTest/CMakeLists.txt
index fe5ec2d0ff..d7b8813639 100644
--- a/Code/Framework/AzTest/CMakeLists.txt
+++ b/Code/Framework/AzTest/CMakeLists.txt
@@ -8,25 +8,27 @@
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
-
-ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/AzTest/Platform/${PAL_PLATFORM_NAME})
-ly_add_target(
- NAME AzTest STATIC
- NAMESPACE AZ
- FILES_CMAKE
- AzTest/aztest_files.cmake
- ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
- INCLUDE_DIRECTORIES
- PUBLIC
- .
- ${pal_dir}
- BUILD_DEPENDENCIES
- PUBLIC
- 3rdParty::googletest::GMock
- 3rdParty::googletest::GTest
- 3rdParty::GoogleBenchmark
- AZ::AzCore
- PLATFORM_INCLUDE_FILES
+if(NOT LY_MONOLITHIC_GAME)
+ ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/AzTest/Platform/${PAL_PLATFORM_NAME})
+
+ ly_add_target(
+ NAME AzTest STATIC
+ NAMESPACE AZ
+ FILES_CMAKE
+ AzTest/aztest_files.cmake
+ ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
+ INCLUDE_DIRECTORIES
+ PUBLIC
+ .
+ ${pal_dir}
+ BUILD_DEPENDENCIES
+ PUBLIC
+ 3rdParty::googletest::GMock
+ 3rdParty::googletest::GTest
+ 3rdParty::GoogleBenchmark
+ AZ::AzCore
+ PLATFORM_INCLUDE_FILES
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
-)
+ )
+endif()
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp
index 9c60b6cd35..adb4ae66c4 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp
@@ -12,6 +12,7 @@
#include
#include
#include
+#include
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option")
#include
@@ -22,6 +23,9 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option")
#include
AZ_POP_DISABLE_WARNING
+AZ_CVAR(
+ bool, ed_useNewAssetBrowserTableView, false, nullptr, AZ::ConsoleFunctorFlags::Null,
+ "Use the new AssetBrowser TableView for searching assets.");
namespace AzToolsFramework
{
namespace AssetBrowser
@@ -31,7 +35,11 @@ namespace AzToolsFramework
AssetBrowserFilterModel::AssetBrowserFilterModel(QObject* parent)
: QSortFilterProxyModel(parent)
{
- m_showColumn.insert(AssetBrowserModel::m_column);
+ m_showColumn.insert(aznumeric_cast(AssetBrowserEntry::Column::DisplayName));
+ if (ed_useNewAssetBrowserTableView)
+ {
+ m_showColumn.insert(aznumeric_cast(AssetBrowserEntry::Column::Path));
+ }
m_collator.setNumericMode(true);
AssetBrowserComponentNotificationBus::Handler::BusConnect();
}
@@ -128,28 +136,58 @@ namespace AzToolsFramework
auto compFilter = qobject_cast >(m_filter);
if (compFilter)
{
- auto& subFilters = compFilter->GetSubFilters();
- auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool
+ const auto& subFilters = compFilter->GetSubFilters();
+
+ const auto compositeFilterIterator = AZStd::find_if(subFilters.cbegin(), subFilters.cend(), [subFilters](FilterConstType filter) -> bool
{
- auto assetTypeFilter = qobject_cast >(filter);
+ const auto assetTypeFilter = qobject_cast >(filter);
return !assetTypeFilter.isNull();
});
- if (it != subFilters.end())
+
+ if (compositeFilterIterator != subFilters.end())
{
- m_assetTypeFilter = qobject_cast >(*it);
+ m_assetTypeFilter = qobject_cast >(*compositeFilterIterator);
}
- it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool
+
+ const auto compStringFilterIter = AZStd::find_if(subFilters.cbegin(), subFilters.cend(), [](FilterConstType filter) -> bool
{
- auto stringFilter = qobject_cast >(filter);
- return !stringFilter.isNull();
+ //The real StringFilter is really a CompositeFilter with just one StringFilter in its subfilter list
+ //To know if it is actually a StringFilter we have to get that subfilter and check if it is a Stringfilter.
+ const auto stringCompositeFilter = qobject_cast >(filter);
+ bool isStringFilter = false;
+ if (stringCompositeFilter)
+ {
+ const auto& stringSubfilters = stringCompositeFilter->GetSubFilters();
+ auto canBeCasted = [](FilterConstType filt) -> bool
+ {
+ auto strFilter = qobject_cast>(filt);
+ return !strFilter.isNull();
+ };
+ const auto stringSubfliterConstIter = AZStd::find_if(stringSubfilters.cbegin(), stringSubfilters.cend(), canBeCasted);
+
+ //A Composite StringFilter will only have just one subfilter and nothing more.
+ if (stringSubfliterConstIter != stringSubfilters.end() && stringSubfilters.size() == 1)
+ {
+ isStringFilter = true;
+ }
+ }
+
+ return isStringFilter;
});
- if (it != subFilters.end())
+ if (compStringFilterIter != subFilters.end())
{
- m_stringFilter = qobject_cast >(*it);
+ const auto compStringFilter = qobject_cast>(*compStringFilterIter);
+
+ if (!compStringFilter->GetSubFilters().isEmpty() && compStringFilter->GetSubFilters()[0])
+ {
+ m_stringFilter = qobject_cast>(compStringFilter->GetSubFilters()[0]);
+ }
}
+
}
invalidateFilter();
Q_EMIT filterChanged();
+ emit stringFilterPopulated(!m_stringFilter.isNull());
}
void AssetBrowserFilterModel::filterUpdatedSlot()
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h
index f9423b2534..5d22791699 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h
@@ -45,15 +45,15 @@ namespace AzToolsFramework
//asset type filtering
void SetFilter(FilterConstType filter);
void FilterUpdatedSlotImmediate();
-
+ const FilterConstType& GetFilter() const { return m_filter; }
//////////////////////////////////////////////////////////////////////////
// AssetBrowserComponentNotificationBus
//////////////////////////////////////////////////////////////////////////
void OnAssetBrowserComponentReady() override;
Q_SIGNALS:
+ void stringFilterPopulated(bool);
void filterChanged();
-
//////////////////////////////////////////////////////////////////////////
//QSortFilterProxyModel
protected:
@@ -68,7 +68,7 @@ namespace AzToolsFramework
protected:
//set for filtering columns
//if the column is in the set the column is not filtered and is shown
- AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)> m_showColumn;
+ AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)> m_showColumn;
bool m_alreadyRecomputingFilters = false;
//asset source name match filter
FilterConstType m_filter;
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp
index d7c0164435..c0f78baccb 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp
@@ -27,8 +27,6 @@ namespace AzToolsFramework
{
namespace AssetBrowser
{
- const int AssetBrowserModel::m_column = static_cast(AssetBrowserEntry::Column::DisplayName);
-
AssetBrowserModel::AssetBrowserModel(QObject* parent)
: QAbstractItemModel(parent)
, m_rootEntry(nullptr)
@@ -143,8 +141,9 @@ namespace AzToolsFramework
if (parent.isValid())
{
- if ((parent.column() != static_cast(AssetBrowserEntry::Column::DisplayName)) &&
- (parent.column() != static_cast(AssetBrowserEntry::Column::Name)))
+ if ((parent.column() != aznumeric_cast(AssetBrowserEntry::Column::DisplayName)) &&
+ (parent.column() != aznumeric_cast(AssetBrowserEntry::Column::Name)) &&
+ (parent.column() != aznumeric_cast(AssetBrowserEntry::Column::Path)))
{
return 0;
}
@@ -164,7 +163,7 @@ namespace AzToolsFramework
int AssetBrowserModel::columnCount(const QModelIndex& /*parent*/) const
{
- return static_cast(AssetBrowserEntry::Column::Count);
+ return aznumeric_cast(AssetBrowserEntry::Column::Count);
}
QVariant AssetBrowserModel::data(const QModelIndex& index, int role) const
@@ -393,7 +392,7 @@ namespace AzToolsFramework
}
int row = entry->row();
- index = createIndex(row, m_column, entry);
+ index = createIndex(row, aznumeric_cast(AssetBrowserEntry::Column::DisplayName), entry);
return true;
}
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.h
index 9e60c44dae..3c4cae5588 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.h
@@ -91,8 +91,6 @@ namespace AzToolsFramework
static void SourceIndexesToAssetIds(const QModelIndexList& indexes, AZStd::vector& assetIds);
static void SourceIndexesToAssetDatabaseEntries(const QModelIndexList& indexes, AZStd::vector& entries);
- const static int m_column;
-
private:
AZStd::shared_ptr m_rootEntry;
bool m_loaded;
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp
new file mode 100644
index 0000000000..d22486d481
--- /dev/null
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp
@@ -0,0 +1,136 @@
+/*
+ * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
+ * its licensors.
+ *
+ * For complete copyright and license terms please see the LICENSE at the root of this
+ * distribution (the "License"). All use of this software is governed by the License,
+ * or, if provided, by the license below or the license accompanying this file. Do not
+ * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ */
+#include
+#include
+#include
+
+namespace AzToolsFramework
+{
+ namespace AssetBrowser
+ {
+ AssetBrowserTableModel::AssetBrowserTableModel(QObject* parent /* = nullptr */)
+ : QSortFilterProxyModel(parent)
+ {
+ setDynamicSortFilter(false);
+ }
+
+ void AssetBrowserTableModel::setSourceModel(QAbstractItemModel* sourceModel)
+ {
+ m_filterModel = qobject_cast(sourceModel);
+ AZ_Assert(
+ m_filterModel,
+ "Error in AssetBrowserTableModel initialization, class expects source model to be an AssetBrowserFilterModel.");
+ QSortFilterProxyModel::setSourceModel(sourceModel);
+ }
+
+ QModelIndex AssetBrowserTableModel::mapToSource(const QModelIndex& proxyIndex) const
+ {
+ Q_ASSERT(!proxyIndex.isValid() || proxyIndex.model() == this);
+ if (!proxyIndex.isValid())
+ {
+ return QModelIndex();
+ }
+ return m_indexMap[proxyIndex.row()];
+ }
+
+ QVariant AssetBrowserTableModel::headerData(int section, Qt::Orientation orientation, int role) const
+ {
+ if (role == Qt::DisplayRole && orientation == Qt::Horizontal)
+ {
+ return tr(AssetBrowserEntry::m_columnNames[section]);
+ }
+ return QSortFilterProxyModel::headerData(section, orientation, role);
+ }
+
+ QVariant AssetBrowserTableModel::data(const QModelIndex& index, int role) const
+ {
+ auto sourceIndex = mapToSource(index);
+ if (!sourceIndex.isValid())
+ {
+ return QVariant();
+ }
+
+ AssetBrowserEntry* entry = GetAssetEntry(sourceIndex);
+ if (entry == nullptr)
+ {
+ AZ_Assert(false, "AssetBrowserTableModel - QModelIndex does not reference an AssetEntry. Source model is not valid.");
+ return QVariant();
+ }
+
+ return sourceIndex.data(role);
+ }
+
+ QModelIndex AssetBrowserTableModel::index(int row, int column, const QModelIndex& parent) const
+ {
+ return parent.isValid() ? QModelIndex() : createIndex(row, column, m_indexMap[row].internalPointer());
+ }
+
+ int AssetBrowserTableModel::rowCount(const QModelIndex& parent) const
+ {
+ return !parent.isValid() ? m_indexMap.size() : 0;
+ }
+
+ int AssetBrowserTableModel::BuildTableModelMap(
+ const QAbstractItemModel* model, const QModelIndex& parent /*= QModelIndex()*/, int row /*= 0*/)
+ {
+ int rows = model ? model->rowCount(parent) : 0;
+ for (int i = 0; i < rows; ++i)
+ {
+ QModelIndex index = model->index(i, 0, parent);
+ AssetBrowserEntry* entry = GetAssetEntry(m_filterModel->mapToSource(index));
+ //We only wanna see the source assets.
+ if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source)
+ {
+ beginInsertRows(parent, row, row);
+ m_indexMap[row] = index;
+ endInsertRows();
+
+ Q_EMIT dataChanged(index, index);
+ ++row;
+ }
+
+ if (model->hasChildren(index))
+ {
+ row = BuildTableModelMap(model, index, row);
+ }
+ }
+ return row;
+ }
+
+ AssetBrowserEntry* AssetBrowserTableModel::GetAssetEntry(QModelIndex index) const
+ {
+ if (index.isValid())
+ {
+ return static_cast(index.internalPointer());
+ }
+ else
+ {
+ AZ_Error("AssetBrowser", false, "Invalid Source Index provided to GetAssetEntry.");
+ return nullptr;
+ }
+ }
+
+ void AssetBrowserTableModel::UpdateTableModelMaps()
+ {
+ emit layoutAboutToBeChanged();
+ if (!m_indexMap.isEmpty())
+ {
+ beginRemoveRows(m_indexMap.first(), m_indexMap.first().row(), m_indexMap.last().row());
+ m_indexMap.clear();
+ endRemoveRows();
+ }
+ BuildTableModelMap(sourceModel());
+ emit layoutChanged();
+ }
+ } // namespace AssetBrowser
+} // namespace AzToolsFramework
+#include "AssetBrowser/moc_AssetBrowserTableModel.cpp"
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h
new file mode 100644
index 0000000000..e438bf6271
--- /dev/null
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h
@@ -0,0 +1,59 @@
+/*
+ * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
+ * its licensors.
+ *
+ * For complete copyright and license terms please see the LICENSE at the root of this
+ * distribution (the "License"). All use of this software is governed by the License,
+ * or, if provided, by the license below or the license accompanying this file. Do not
+ * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ */
+#pragma once
+
+#if !defined(Q_MOC_RUN)
+#include
+#include
+#include
+#endif
+
+namespace AzToolsFramework
+{
+ namespace AssetBrowser
+ {
+ class AssetBrowserFilterModel;
+ class AssetBrowserEntry;
+
+ class AssetBrowserTableModel
+ : public QSortFilterProxyModel
+ {
+ Q_OBJECT
+
+ public:
+ AZ_CLASS_ALLOCATOR(AssetBrowserTableModel, AZ::SystemAllocator, 0);
+ explicit AssetBrowserTableModel(QObject* parent = nullptr);
+ ////////////////////////////////////////////////////////////////////
+ // QSortFilterProxyModel
+ void setSourceModel(QAbstractItemModel* sourceModel) override;
+ QModelIndex mapToSource(const QModelIndex& proxyIndex) const override;
+ QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
+
+ public Q_SLOTS:
+ void UpdateTableModelMaps();
+
+ protected:
+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */) const override;
+ ////////////////////////////////////////////////////////////////////
+
+ private:
+ AssetBrowserEntry* GetAssetEntry(QModelIndex index) const;
+ int BuildTableModelMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0);
+
+ private:
+ QPointer m_filterModel;
+ QMap m_indexMap;
+ };
+ } // namespace AssetBrowser
+} // namespace AzToolsFramework
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.cpp
index abd1f91bf5..8ee8f44137 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.cpp
@@ -46,6 +46,7 @@ namespace AzToolsFramework
const char* AssetBrowserEntry::m_columnNames[] =
{
"Name",
+ "Path",
"Source ID",
"Fingerprint",
"Guid",
@@ -128,6 +129,8 @@ namespace AzToolsFramework
return QString::fromUtf8(m_name.c_str());
case Column::DisplayName:
return m_displayName;
+ case Column::Path:
+ return m_displayPath;
default:
return QVariant();
}
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.h
index 6f0eceeeea..ac5470a136 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.h
@@ -68,6 +68,7 @@ namespace AzToolsFramework
enum class Column
{
Name,
+ Path,
SourceID,
Fingerprint,
Guid,
@@ -135,6 +136,7 @@ namespace AzToolsFramework
protected:
AZStd::string m_name;
QString m_displayName;
+ QString m_displayPath;
AZStd::string m_relativePath;
AZStd::string m_fullPath;
AZStd::vector m_children;
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/FolderAssetBrowserEntry.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/FolderAssetBrowserEntry.cpp
index 88b26ad5ee..0312edbc51 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/FolderAssetBrowserEntry.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/FolderAssetBrowserEntry.cpp
@@ -43,6 +43,7 @@ namespace AzToolsFramework
void FolderAssetBrowserEntry::UpdateChildPaths(AssetBrowserEntry* child) const
{
child->m_relativePath = m_relativePath + AZ_CORRECT_DATABASE_SEPARATOR + child->m_name;
+ child->m_displayPath = QString::fromUtf8(child->m_relativePath.c_str());
child->m_fullPath = m_fullPath + AZ_CORRECT_DATABASE_SEPARATOR + child->m_name;
AssetBrowserEntry::UpdateChildPaths(child);
}
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp
index bd5ba48d8d..e626f31b62 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp
@@ -286,6 +286,9 @@ namespace AzToolsFramework
product->m_assetType = productWithUuidDatabaseEntry.second.m_assetType;
product->m_assetType.ToString(product->m_assetTypeString);
AZ::Data::AssetCatalogRequestBus::BroadcastResult(product->m_relativePath, &AZ::Data::AssetCatalogRequests::GetAssetPathById, assetId);
+ QString displayPath = QString::fromUtf8(product->m_relativePath.c_str());
+ displayPath.remove(QString(AZ_CORRECT_DATABASE_SEPARATOR + QString::fromUtf8(product->m_name.c_str())));
+ product->m_displayPath = displayPath;
EntryCache::GetInstance()->m_productAssetIdMap[assetId] = product;
if (needsAdd)
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp
new file mode 100644
index 0000000000..894bbd8700
--- /dev/null
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp
@@ -0,0 +1,178 @@
+/*
+ * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
+ * its licensors.
+ *
+ * For complete copyright and license terms please see the LICENSE at the root of this
+ * distribution (the "License"). All use of this software is governed by the License,
+ * or, if provided, by the license below or the license accompanying this file. Do not
+ * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ */
+
+#include
+
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+AZ_PUSH_DISABLE_WARNING(
+ 4244 4251 4800, "-Wunknown-warning-option") // conversion from 'int' to 'float', possible loss of data, needs to have dll-interface to
+ // be used by clients of class 'QFlags::Int': forcing value to bool
+ // 'true' or 'false' (performance warning)
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+AZ_POP_DISABLE_WARNING
+namespace AzToolsFramework
+{
+ namespace AssetBrowser
+ {
+ AssetBrowserTableView::AssetBrowserTableView(QWidget* parent)
+ : QTableView(parent)
+ , m_delegate(new EntryDelegate(this))
+ {
+ setSortingEnabled(true);
+ setItemDelegate(m_delegate);
+ verticalHeader()->hide();
+ setContextMenuPolicy(Qt::CustomContextMenu);
+
+ setMouseTracking(true);
+ setSortingEnabled(false);
+ setSelectionMode(QAbstractItemView::SingleSelection);
+
+ connect(this, &QTableView::customContextMenuRequested, this, &AssetBrowserTableView::OnContextMenu);
+
+ AssetBrowserViewRequestBus::Handler::BusConnect();
+ AssetBrowserComponentNotificationBus::Handler::BusConnect();
+ }
+
+ AssetBrowserTableView::~AssetBrowserTableView()
+ {
+ AssetBrowserViewRequestBus::Handler::BusDisconnect();
+ AssetBrowserComponentNotificationBus::Handler::BusDisconnect();
+ }
+
+ void AssetBrowserTableView::setModel(QAbstractItemModel* model)
+ {
+ m_tableModel = qobject_cast(model);
+ AZ_Assert(m_tableModel, "Expecting AssetBrowserTableModel");
+ m_sourceFilterModel = qobject_cast(m_tableModel->sourceModel());
+ QTableView::setModel(model);
+ connect(m_tableModel, &AssetBrowserTableModel::layoutChanged, this, &AssetBrowserTableView::layoutChangedSlot);
+
+ horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch);
+ horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeMode::Stretch);
+ }
+
+ void AssetBrowserTableView::SetName(const QString& name)
+ {
+ m_name = name;
+ bool isAssetBrowserComponentReady = false;
+ AssetBrowserComponentRequestBus::BroadcastResult(isAssetBrowserComponentReady, &AssetBrowserComponentRequests::AreEntriesReady);
+ if (isAssetBrowserComponentReady)
+ {
+ OnAssetBrowserComponentReady();
+ }
+ }
+
+ AZStd::vector AssetBrowserTableView::GetSelectedAssets() const
+ {
+ QModelIndexList sourceIndexes;
+ for (const auto& index : selectedIndexes())
+ {
+ if (index.column() == 0)
+ {
+ sourceIndexes.push_back(m_sourceFilterModel->mapToSource(m_tableModel->mapToSource(index)));
+ }
+ }
+
+ AZStd::vector entries;
+ AssetBrowserModel::SourceIndexesToAssetDatabaseEntries(sourceIndexes, entries);
+ return entries;
+ }
+
+ void AssetBrowserTableView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
+ {
+ QTableView::selectionChanged(selected, deselected);
+ Q_EMIT selectionChangedSignal(selected, deselected);
+ }
+
+ void AssetBrowserTableView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end)
+ {
+ // if selected entry is being removed, clear selection so not to select (and attempt to preview) other entries potentially
+ // marked for deletion
+ if (selectionModel() && selectionModel()->selectedIndexes().size() == 1)
+ {
+ QModelIndex selectedIndex = selectionModel()->selectedIndexes().first();
+ QModelIndex parentSelectedIndex = selectedIndex.parent();
+ if (parentSelectedIndex == parent && selectedIndex.row() >= start && selectedIndex.row() <= end)
+ {
+ selectionModel()->clear();
+ }
+ }
+ QTableView::rowsAboutToBeRemoved(parent, start, end);
+ }
+
+ void AssetBrowserTableView::layoutChangedSlot(
+ [[maybe_unused]] const QList& parents, [[maybe_unused]] QAbstractItemModel::LayoutChangeHint hint)
+ {
+ scrollToTop();
+ }
+
+ void AssetBrowserTableView::SelectProduct([[maybe_unused]] AZ::Data::AssetId assetID)
+ {
+ }
+
+ void AssetBrowserTableView::SelectFileAtPath([[maybe_unused]] const AZStd::string& assetPath)
+ {
+ }
+
+ void AssetBrowserTableView::ClearFilter()
+ {
+ emit ClearStringFilter();
+ emit ClearTypeFilter();
+ m_sourceFilterModel->FilterUpdatedSlotImmediate();
+ }
+
+ void AssetBrowserTableView::Update()
+ {
+ update();
+ }
+
+ void AssetBrowserTableView::OnAssetBrowserComponentReady()
+ {
+ }
+
+ void AssetBrowserTableView::OnContextMenu([[maybe_unused]] const QPoint& point)
+ {
+ const auto& selectedAssets = GetSelectedAssets();
+ if (selectedAssets.size() != 1)
+ {
+ return;
+ }
+
+ QMenu menu(this);
+ AssetBrowserInteractionNotificationBus::Broadcast(
+ &AssetBrowserInteractionNotificationBus::Events::AddContextMenuActions, this, &menu, selectedAssets);
+ if (!menu.isEmpty())
+ {
+ menu.exec(QCursor::pos());
+ }
+ }
+ } // namespace AssetBrowser
+} // namespace AzToolsFramework
+#include "AssetBrowser/Views/moc_AssetBrowserTableView.cpp"
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h
new file mode 100644
index 0000000000..15bc95f13c
--- /dev/null
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h
@@ -0,0 +1,84 @@
+/*
+ * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
+ * its licensors.
+ *
+ * For complete copyright and license terms please see the LICENSE at the root of this
+ * distribution (the "License"). All use of this software is governed by the License,
+ * or, if provided, by the license below or the license accompanying this file. Do not
+ * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ */
+#pragma once
+#if !defined(Q_MOC_RUN)
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#endif
+
+namespace AzToolsFramework
+{
+ namespace AssetBrowser
+ {
+ class AssetBrowserEntry;
+ class AssetBrowserTableModel;
+ class AssetBrowserFilterModel;
+ class EntryDelegate;
+
+ class AssetBrowserTableView //! Table view that displays the asset browser entries in a list.
+ : public QTableView
+ , public AssetBrowserViewRequestBus::Handler
+ , public AssetBrowserComponentNotificationBus::Handler
+ {
+ Q_OBJECT
+ public:
+ explicit AssetBrowserTableView(QWidget* parent = nullptr);
+ ~AssetBrowserTableView() override;
+
+ void setModel(QAbstractItemModel *model) override;
+ void SetName(const QString& name);
+
+ AZStd::vector GetSelectedAssets() const;
+
+ //////////////////////////////////////////////////////////////////////////
+ // AssetBrowserViewRequestBus
+ virtual void SelectProduct(AZ::Data::AssetId assetID) override;
+ virtual void SelectFileAtPath(const AZStd::string& assetPath) override;
+ virtual void ClearFilter() override;
+ virtual void Update() override;
+
+ //////////////////////////////////////////////////////////////////////////
+ // AssetBrowserComponentNotificationBus
+ void OnAssetBrowserComponentReady() override;
+ //////////////////////////////////////////////////////////////////////////
+
+
+ Q_SIGNALS:
+ void selectionChangedSignal(const QItemSelection& selected, const QItemSelection& deselected);
+ void ClearStringFilter();
+ void ClearTypeFilter();
+
+ protected Q_SLOTS:
+ void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override;
+ void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
+ void layoutChangedSlot(const QList &parents = QList(),
+ QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint);
+
+ private:
+ QString m_name;
+ QPointer m_tableModel = nullptr;
+ QPointer m_sourceFilterModel = nullptr;
+ EntryDelegate* m_delegate = nullptr;
+
+ private Q_SLOTS:
+ void OnContextMenu(const QPoint& point);
+ };
+ } // namespace AssetBrowser
+} // namespace AzToolsFramework
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp
index 6cd60b0015..026343c2a4 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp
@@ -53,6 +53,7 @@ namespace AzToolsFramework
setSortingEnabled(true);
setItemDelegate(m_delegate);
header()->hide();
+
setContextMenuPolicy(Qt::CustomContextMenu);
setMouseTracking(true);
@@ -99,8 +100,9 @@ namespace AzToolsFramework
AZStd::vector AssetBrowserTreeView::GetSelectedAssets() const
{
+ const QModelIndexList& selectedIndexes = selectionModel()->selectedRows();
QModelIndexList sourceIndexes;
- for (const auto& index : selectedIndexes())
+ for (const auto& index : selectedIndexes)
{
sourceIndexes.push_back(m_assetBrowserSortFilterProxyModel->mapToSource(index));
}
@@ -172,6 +174,7 @@ namespace AzToolsFramework
void AssetBrowserTreeView::OnAssetBrowserComponentReady()
{
+ hideColumn(aznumeric_cast(AssetBrowserEntry::Column::Path));
if (!m_name.isEmpty())
{
auto crc = AZ::Crc32(m_name.toUtf8().data());
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp
index e8abaebd6f..d0ac05020d 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp
@@ -74,34 +74,34 @@ namespace AzToolsFramework
QPoint iconTopLeft(remainingRect.x(), remainingRect.y() + (remainingRect.height() / 2) - (m_iconSize / 2));
auto sourceEntry = azrtti_cast(entry);
-
- int thumbX = DrawThumbnail(painter, iconTopLeft, iconSize, entry->GetThumbnailKey());
-
QPalette actualPalette(option.palette);
-
- if (sourceEntry)
+ if (index.column() == aznumeric_cast(AssetBrowserEntry::Column::Name))
{
- if (m_showSourceControl)
+ int thumbX = DrawThumbnail(painter, iconTopLeft, iconSize, entry->GetThumbnailKey());
+ if (sourceEntry)
{
- DrawThumbnail(painter, iconTopLeft, iconSize, sourceEntry->GetSourceControlThumbnailKey());
+ if (m_showSourceControl)
+ {
+ DrawThumbnail(painter, iconTopLeft, iconSize, sourceEntry->GetSourceControlThumbnailKey());
+ }
+ // sources with no children should be greyed out.
+ if (sourceEntry->GetChildCount() == 0)
+ {
+ isEnabled = false; // draw in disabled style.
+ actualPalette.setCurrentColorGroup(QPalette::Disabled);
+ }
}
- // sources with no children should be greyed out.
- if (sourceEntry->GetChildCount() == 0)
- {
- isEnabled = false; // draw in disabled style.
- actualPalette.setCurrentColorGroup(QPalette::Disabled);
- }
- }
- remainingRect.adjust(thumbX, 0, 0, 0); // bump it to the right by the size of the thumbnail
- remainingRect.adjust(ENTRY_SPACING_LEFT_PIXELS, 0, 0, 0); // bump it to the right by the spacing.
+ remainingRect.adjust(thumbX, 0, 0, 0); // bump it to the right by the size of the thumbnail
+ remainingRect.adjust(ENTRY_SPACING_LEFT_PIXELS, 0, 0, 0); // bump it to the right by the spacing.
+ }
+ QString displayString = index.column() == aznumeric_cast(AssetBrowserEntry::Column::Name)
+ ? qvariant_cast(entry->data(aznumeric_cast(AssetBrowserEntry::Column::Name)))
+ : qvariant_cast(entry->data(aznumeric_cast(AssetBrowserEntry::Column::Path)));
- style->drawItemText(painter,
- remainingRect,
- option.displayAlignment,
- actualPalette,
- isEnabled,
- entry->GetDisplayName(),
+ style->drawItemText(
+ painter, remainingRect, option.displayAlignment, actualPalette, isEnabled,
+ displayString,
isSelected ? QPalette::HighlightedText : QPalette::Text);
}
}
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp
index fa7d5f6e9b..336b56653b 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp
@@ -159,12 +159,23 @@ namespace AzToolsFramework
void PrefabEditorEntityOwnershipService::GetNonPrefabEntities(EntityList& entities)
{
- m_rootInstance->GetEntities(entities, false);
+ m_rootInstance->GetEntities(
+ [&entities](const AZStd::unique_ptr& entity)
+ {
+ entities.emplace_back(entity.get());
+ return true;
+ });
}
bool PrefabEditorEntityOwnershipService::GetAllEntities(EntityList& entities)
{
- m_rootInstance->GetEntities(entities, true);
+ m_rootInstance->GetAllEntitiesInHierarchy(
+ [&entities](const AZStd::unique_ptr& entity)
+ {
+ entities.emplace_back(entity.get());
+ return true;
+ });
+
return true;
}
@@ -252,13 +263,20 @@ namespace AzToolsFramework
}
AZStd::string out;
- if (m_loaderInterface->SaveTemplateToString(m_rootInstance->GetTemplateId(), out))
+
+ if (!m_loaderInterface->SaveTemplateToString(m_rootInstance->GetTemplateId(), out))
{
- const size_t bytesToWrite = out.size();
- const size_t bytesWritten = stream.Write(bytesToWrite, out.data());
- return bytesWritten == bytesToWrite;
+ return false;
}
- return false;
+
+ const size_t bytesToWrite = out.size();
+ const size_t bytesWritten = stream.Write(bytesToWrite, out.data());
+ if(bytesWritten != bytesToWrite)
+ {
+ return false;
+ }
+ m_prefabSystemComponent->SetTemplateDirtyFlag(templateId, false);
+ return true;
}
void PrefabEditorEntityOwnershipService::CreateNewLevelPrefab(AZStd::string_view filename, const AZStd::string& templateFilename)
@@ -544,7 +562,7 @@ namespace AzToolsFramework
return;
}
- m_rootInstance->GetNestedEntities([this](AZStd::unique_ptr& entity)
+ m_rootInstance->GetAllEntitiesInHierarchy([this](AZStd::unique_ptr& entity)
{
AZ_Assert(entity, "Invalid entity found in root instance while starting play in editor.");
if (entity->GetState() == AZ::Entity::State::Active)
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/ManipulatorSnapping.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/ManipulatorSnapping.cpp
index 427bb9e9d1..27d8f7e5a3 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/ManipulatorSnapping.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/ManipulatorSnapping.cpp
@@ -14,6 +14,7 @@
#include
#include
+#include
#include
#include
#include
@@ -95,16 +96,34 @@ namespace AzToolsFramework
return axis * snapAdjustment.m_nextSnapDistance;
}
+ AZ::Vector3 CalculateSnappedOffset(
+ const AZ::Vector3& unsnappedPosition, const AZ::Vector3* snapAxes, const size_t snapAxesCount, const float size)
+ {
+ return AZStd::accumulate(
+ snapAxes, snapAxes + snapAxesCount, AZ::Vector3::CreateZero(),
+ [&unsnappedPosition, size](AZ::Vector3 acc, const AZ::Vector3& snapAxis)
+ {
+ acc += CalculateSnappedOffset(unsnappedPosition, snapAxis, size);
+ return acc;
+ });
+ }
+
+ AZ::Vector3 CalculateSnappedPosition(
+ const AZ::Vector3& unsnappedPosition, const AZ::Vector3* snapAxes, const size_t snapAxesCount, const float size)
+ {
+ return unsnappedPosition + CalculateSnappedOffset(unsnappedPosition, snapAxes, snapAxesCount, size);
+ }
+
AZ::Vector3 CalculateSnappedTerrainPosition(
- const AZ::Vector3& worldSurfacePosition, const AZ::Transform& worldFromLocal, const int viewportId, const float gridSize)
+ const AZ::Vector3& worldSurfacePosition, const AZ::Transform& worldFromLocal, const int viewportId, const float size)
{
const AZ::Transform localFromWorld = worldFromLocal.GetInverse();
const AZ::Vector3 localSurfacePosition = localFromWorld.TransformPoint(worldSurfacePosition);
// snap in xy plane
AZ::Vector3 localSnappedSurfacePosition = localSurfacePosition +
- CalculateSnappedOffset(localSurfacePosition, AZ::Vector3::CreateAxisX(), gridSize) +
- CalculateSnappedOffset(localSurfacePosition, AZ::Vector3::CreateAxisY(), gridSize);
+ CalculateSnappedOffset(localSurfacePosition, AZ::Vector3::CreateAxisX(), size) +
+ CalculateSnappedOffset(localSurfacePosition, AZ::Vector3::CreateAxisY(), size);
// find terrain height at xy snapped location
float terrainHeight = 0.0f;
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/ManipulatorSnapping.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/ManipulatorSnapping.h
index f2fa104d4c..9024625fae 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/ManipulatorSnapping.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/ManipulatorSnapping.h
@@ -12,6 +12,7 @@
#pragma once
+#include
#include
#include
@@ -58,10 +59,18 @@ namespace AzToolsFramework
//! @note A movement of more than half size (in either direction) will cause a snap by size.
AZ::Vector3 CalculateSnappedAmount(const AZ::Vector3& unsnappedPosition, const AZ::Vector3& axis, float size);
+ //! Overload of CalculateSnappedOffset taking multiple axes.
+ AZ::Vector3 CalculateSnappedOffset(
+ const AZ::Vector3& unsnappedPosition, const AZ::Vector3* snapAxes, size_t snapAxesCount, float size);
+
+ //! Return the final snapped position according to size (unsnappedPosition + CalculateSnappedOffset).
+ AZ::Vector3 CalculateSnappedPosition(
+ const AZ::Vector3& unsnappedPosition, const AZ::Vector3* snapAxes, size_t snapAxesCount, float size);
+
//! For a given point on the terrain, calculate the closest xy position snapped to the grid
//! (z position is aligned to terrain height, not snapped to z grid)
AZ::Vector3 CalculateSnappedTerrainPosition(
- const AZ::Vector3& worldSurfacePosition, const AZ::Transform& worldFromLocal, int viewportId, float gridSize);
+ const AZ::Vector3& worldSurfacePosition, const AZ::Transform& worldFromLocal, int viewportId, float size);
//! Wrapper for grid snapping and grid size bus calls.
GridSnapParameters GridSnapSettings(int viewportId);
@@ -84,8 +93,8 @@ namespace AzToolsFramework
//! @param exponent Precision to use when rounding.
inline float Round(const float value, const float exponent)
{
- const float precision = std::pow(10.0f, exponent);
- return roundf(value * precision) / precision;
+ const float precision = AZStd::pow(10.0f, exponent);
+ return AZStd::round(value * precision) / precision;
}
//! Round to 3 significant digits (3 digits common usage).
@@ -116,7 +125,7 @@ namespace AzToolsFramework
//! when dealing with values far from the origin.
inline AZ::Vector3 NonUniformScaleReciprocal(const AZ::Vector3& nonUniformScale)
{
- AZ::Vector3 scaleReciprocal = nonUniformScale.GetReciprocal();
+ const AZ::Vector3 scaleReciprocal = nonUniformScale.GetReciprocal();
return AZ::Vector3(Round3(scaleReciprocal.GetX()), Round3(scaleReciprocal.GetY()), Round3(scaleReciprocal.GetZ()));
}
} // namespace AzToolsFramework
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp
index 83a76aeb01..e5179f4229 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp
@@ -373,17 +373,25 @@ namespace AzToolsFramework
}
}
- void Instance::GetConstNestedEntities(const AZStd::function& callback)
+ bool Instance::GetEntities_Impl(const AZStd::function&)>& callback)
{
- GetConstEntities(callback);
-
- for (const auto& [instanceAlias, instance] : m_nestedInstances)
+ for (auto& [entityAlias, entity] : m_entities)
{
- instance->GetConstNestedEntities(callback);
+ if (!entity)
+ {
+ continue;
+ }
+
+ if (!callback(entity))
+ {
+ return false;
+ }
}
+
+ return true;
}
- void Instance::GetConstEntities(const AZStd::function& callback)
+ bool Instance::GetConstEntities_Impl(const AZStd::function& callback) const
{
for (const auto& [entityAlias, entity] : m_entities)
{
@@ -394,65 +402,91 @@ namespace AzToolsFramework
if (!callback(*entity))
{
- break;
+ return false;
}
}
+
+ return true;
}
- void Instance::GetNestedEntities(const AZStd::function&)>& callback)
+ bool Instance::GetAllEntitiesInHierarchy_Impl(const AZStd::function&)>& callback)
{
- GetEntities(callback);
-
- for (auto& [instanceAlias, instance] : m_nestedInstances)
+ if (HasContainerEntity())
{
- instance->GetNestedEntities(callback);
+ if (!callback(m_containerEntity))
+ {
+ return false;
+ }
}
- }
- void Instance::GetNestedInstances(const AZStd::function&)>& callback)
- {
- for (auto& [instanceAlias, instance] : m_nestedInstances)
+ if (!GetEntities_Impl(callback))
{
- callback(instance);
+ return false;
}
- }
- void Instance::GetEntities(const AZStd::function&)>& callback)
- {
- for (auto& [entityAlias, entity] : m_entities)
+ for (auto& [instanceAlias, instance] : m_nestedInstances)
{
- if (!callback(entity))
+ if (!instance->GetAllEntitiesInHierarchy_Impl(callback))
{
- break;
+ return false;
}
}
+
+ return true;
}
- void Instance::GetEntities(EntityList& entities, bool includeNestedEntities)
+ bool Instance::GetAllEntitiesInHierarchyConst_Impl(const AZStd::function& callback) const
{
- // Non-recursive traversal of instances
- AZStd::vector instancesToTraverse = { this };
- while (!instancesToTraverse.empty())
+ if (HasContainerEntity())
{
- Instance* currentInstance = instancesToTraverse.back();
- instancesToTraverse.pop_back();
- if (includeNestedEntities)
+ if (!callback(*m_containerEntity))
{
- instancesToTraverse.reserve(instancesToTraverse.size() + currentInstance->m_nestedInstances.size());
- for (const auto& instanceByAlias : currentInstance->m_nestedInstances)
- {
- instancesToTraverse.push_back(instanceByAlias.second.get());
- }
+ return false;
}
+ }
- // Size increases by 1 for each instance because we have to count the container entity also.
- entities.reserve(entities.size() + currentInstance->m_entities.size() + 1);
- entities.push_back(m_containerEntity.get());
- for (const auto& entityByAlias : currentInstance->m_entities)
+ if (!GetConstEntities_Impl(callback))
+ {
+ return false;
+ }
+
+ for (const auto& [instanceAlias, instance] : m_nestedInstances)
+ {
+ if (!instance->GetAllEntitiesInHierarchyConst_Impl(callback))
{
- entities.push_back(entityByAlias.second.get());
+ return false;
}
}
+
+ return true;
+ }
+
+ void Instance::GetEntities(const AZStd::function&)>& callback)
+ {
+ GetEntities_Impl(callback);
+ }
+
+ void Instance::GetConstEntities(const AZStd::function& callback) const
+ {
+ GetConstEntities_Impl(callback);
+ }
+
+ void Instance::GetAllEntitiesInHierarchy(const AZStd::function&)>& callback)
+ {
+ GetAllEntitiesInHierarchy_Impl(callback);
+ }
+
+ void Instance::GetAllEntitiesInHierarchyConst(const AZStd::function& callback) const
+ {
+ GetAllEntitiesInHierarchyConst_Impl(callback);
+ }
+
+ void Instance::GetNestedInstances(const AZStd::function&)>& callback)
+ {
+ for (auto& [instanceAlias, instance] : m_nestedInstances)
+ {
+ callback(instance);
+ }
}
EntityAliasOptionalReference Instance::GetEntityAlias(const AZ::EntityId& id)
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h
index 5f36ac10dc..9d3ae31796 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h
@@ -121,10 +121,10 @@ namespace AzToolsFramework
/**
* Gets the entities in the Instance DOM. Can recursively trace all nested instances.
*/
- void GetConstNestedEntities(const AZStd::function& callback);
- void GetConstEntities(const AZStd::function& callback);
- void GetNestedEntities(const AZStd::function&)>& callback);
void GetEntities(const AZStd::function&)>& callback);
+ void GetConstEntities(const AZStd::function& callback) const;
+ void GetAllEntitiesInHierarchy(const AZStd::function&)>& callback);
+ void GetAllEntitiesInHierarchyConst(const AZStd::function& callback) const;
void GetNestedInstances(const AZStd::function&)>& callback);
/**
@@ -184,12 +184,6 @@ namespace AzToolsFramework
static InstanceAlias GenerateInstanceAlias();
- protected:
- /**
- * Gets the entities owned by this instance
- */
- void GetEntities(EntityList& entities, bool includeNestedEntities = false);
-
private:
static constexpr const char s_aliasPathSeparator = '/';
@@ -197,6 +191,11 @@ namespace AzToolsFramework
void RemoveEntities(const AZStd::function&)>& filter);
+ bool GetEntities_Impl(const AZStd::function&)>& callback);
+ bool GetConstEntities_Impl(const AZStd::function& callback) const;
+ bool GetAllEntitiesInHierarchy_Impl(const AZStd::function&)>& callback);
+ bool GetAllEntitiesInHierarchyConst_Impl(const AZStd::function& callback) const;
+
bool RegisterEntity(const AZ::EntityId& entityId, const EntityAlias& entityAlias);
AZStd::unique_ptr DetachEntity(const EntityAlias& entityAlias);
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/EditorInfoRemover.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/EditorInfoRemover.cpp
index 6480ac37d7..cc04fe24c1 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/EditorInfoRemover.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/EditorInfoRemover.cpp
@@ -62,25 +62,16 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
}
}
- AZStd::vector