Merge branch 'development' into cmake/AddressSanitizer

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Code/Legacy/CryCommon/LegacyAllocator.h
This commit is contained in:
Esteban Papp
2021-08-19 11:44:28 -07:00
460 changed files with 4366 additions and 5622 deletions
@@ -11,6 +11,7 @@
#include <AzCore/Math/Crc.h>
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/Component/NonUniformScaleBus.h>
#include <AzCore/Debug/Profiler.h>
#include <AzCore/Memory/MemoryComponent.h>
#include <AzCore/Slice/SliceSystemComponent.h>
#include <AzCore/Jobs/JobManagerComponent.h>
@@ -540,7 +541,7 @@ namespace AzFramework
const AZStd::function<void()>& workForNewThread,
const char* newThreadName)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
AZStd::thread_desc newThreadDesc;
newThreadDesc.m_cpuId = AFFINITY_MASK_USERTHREADS;
@@ -548,7 +549,7 @@ namespace AzFramework
AZStd::binary_semaphore binarySemaphore;
AZStd::thread newThread([&workForNewThread, &binarySemaphore, &newThreadName]
{
AZ_PROFILE_SCOPE_DYNAMIC(AZ::Debug::ProfileCategory::AzFramework,
AZ_PROFILE_SCOPE(AzFramework,
"Application::PumpSystemEventLoopWhileDoingWorkInNewThread:ThreadWorker %s", newThreadName);
workForNewThread();
@@ -559,7 +560,7 @@ namespace AzFramework
PumpSystemEventLoopUntilEmpty();
}
{
AZ_PROFILE_SCOPE_STALL_DYNAMIC(AZ::Debug::ProfileCategory::AzFramework,
AZ_PROFILE_SCOPE(AzFramework,
"Application::PumpSystemEventLoopWhileDoingWorkInNewThread:WaitOnThread %s", newThreadName);
newThread.join();
}
@@ -571,10 +572,14 @@ namespace AzFramework
////////////////////////////////////////////////////////////////////////////
void Application::RunMainLoop()
{
uint32_t frameCounter = 0;
while (!m_exitMainLoopRequested)
{
PumpSystemEventLoopUntilEmpty();
AZ_PROFILE_SCOPE(AzCore, "Frame %i", frameCounter);
Tick();
++frameCounter;
}
}
@@ -13,6 +13,7 @@
#include <AzCore/Casting/numeric_cast.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Console/IConsole.h>
#include <AzCore/Debug/Profiler.h>
#include <AzCore/Interface/Interface.h>
#include <AzCore/IO/SystemFile.h>
#include <AzCore/IO/FileIO.h>
@@ -206,7 +207,7 @@ namespace AZ::IO::ArchiveInternal
//////////////////////////////////////////////////////////////////////////
size_t ArchiveInternal::CZipPseudoFile::FRead(void* pDest, size_t nSize, size_t nCount, [[maybe_unused]] AZ::IO::HandleType fileHandle)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzCore);
AZ_PROFILE_FUNCTION(AzCore);
if (!GetFile())
{
@@ -271,7 +272,7 @@ namespace AZ::IO::ArchiveInternal
//////////////////////////////////////////////////////////////////////////
void* ArchiveInternal::CZipPseudoFile::GetFileData(size_t& nFileSize, [[maybe_unused]] AZ::IO::HandleType fileHandle)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzCore);
AZ_PROFILE_FUNCTION(AzCore);
if (!GetFile())
{
@@ -685,7 +686,7 @@ namespace AZ::IO
//////////////////////////////////////////////////////////////////////////
AZ::IO::HandleType Archive::FOpen(AZStd::string_view pName, const char* szMode, uint32_t nInputFlags)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzCore);
AZ_PROFILE_FUNCTION(AzCore);
const size_t pathLen = pName.size();
if (pathLen == 0 || pathLen >= MaxPath)
@@ -693,7 +694,7 @@ namespace AZ::IO
return AZ::IO::InvalidHandle;
}
AZ_PROFILE_SCOPE_DYNAMIC(AZ::Debug::ProfileCategory::Game, "File: %.*s Archive: %p",
AZ_PROFILE_SCOPE(Game, "File: %.*s Archive: %p",
aznumeric_cast<int>(pName.size()), pName.data(), this);
SAutoCollectFileAccessTime accessTime(this);
@@ -716,7 +717,7 @@ namespace AZ::IO
}
const bool fileWritable = (nOSFlags & (AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeAppend | AZ::IO::OpenMode::ModeUpdate)) != AZ::IO::OpenMode::Invalid;
AZ_PROFILE_SCOPE_DYNAMIC(AZ::Debug::ProfileCategory::Game, "File: %s Archive: %p", szFullPath->c_str(), this);
AZ_PROFILE_SCOPE(Game, "File: %s Archive: %p", szFullPath->c_str(), this);
if (fileWritable)
{
// we need to open the file for writing, but we failed to do so.
@@ -1094,8 +1095,8 @@ namespace AZ::IO
//////////////////////////////////////////////////////////////////////////
size_t Archive::FReadRaw(void* pData, size_t nSize, size_t nCount, AZ::IO::HandleType fileHandle)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzCore);
AZ_PROFILE_SCOPE_DYNAMIC(AZ::Debug::ProfileCategory::Game, "Size: %d Archive: %p", nSize, this);
AZ_PROFILE_FUNCTION(AzCore);
AZ_PROFILE_SCOPE(Game, "Size: %d Archive: %p", nSize, this);
SAutoCollectFileAccessTime accessTime(this);
ArchiveInternal::CZipPseudoFile* pseudoFile = GetPseudoFile(fileHandle);
@@ -1112,7 +1113,7 @@ namespace AZ::IO
//////////////////////////////////////////////////////////////////////////
size_t Archive::FReadRawAll(void* pData, size_t nFileSize, AZ::IO::HandleType fileHandle)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzCore);
AZ_PROFILE_FUNCTION(AzCore);
SAutoCollectFileAccessTime accessTime(this);
ArchiveInternal::CZipPseudoFile* pseudoFile = GetPseudoFile(fileHandle);
@@ -1130,7 +1131,7 @@ namespace AZ::IO
//////////////////////////////////////////////////////////////////////////
void* Archive::FGetCachedFileData(AZ::IO::HandleType fileHandle, size_t& nFileSize)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzCore);
AZ_PROFILE_FUNCTION(AzCore);
SAutoCollectFileAccessTime accessTime(this);
ArchiveInternal::CZipPseudoFile* pseudoFile = GetPseudoFile(fileHandle);
@@ -167,7 +167,7 @@ namespace AzFramework
//=========================================================================
void EntityContext::HandleEntitiesAdded(const EntityList& entities)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
for (AZ::Entity* entity : entities)
{
@@ -184,7 +184,7 @@ namespace AzFramework
//=========================================================================
void EntityContext::HandleEntitiesRemoved(const EntityIdList& entityIds)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
for (AZ::EntityId id : entityIds)
{
@@ -155,7 +155,7 @@ namespace AzFramework
void SliceEntityOwnershipService::CreateRootSlice()
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
AZ_Assert(m_rootAsset && m_rootAsset.Get(), "Root slice asset has not been created yet.");
@@ -164,7 +164,7 @@ namespace AzFramework
void SliceEntityOwnershipService::CreateRootSlice(AZ::SliceAsset* rootSliceAsset)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
AZ_Assert(m_rootAsset && m_rootAsset.Get(), "Root slice asset has not been created yet.");
AZ::Entity* rootEntity = new AZ::Entity();
@@ -240,7 +240,7 @@ namespace AzFramework
bool SliceEntityOwnershipService::LoadFromStream(AZ::IO::GenericStream& stream, bool remapIds, EntityIdToEntityIdMap* idRemapTable, const AZ::ObjectStream::FilterDescriptor& filterDesc)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
AZ_Assert(m_rootAsset, "The entity ownership service has not been initialized.");
@@ -259,7 +259,7 @@ namespace AzFramework
bool SliceEntityOwnershipService::HandleRootEntityReloadedFromStream(AZ::Entity* rootEntity, bool remapIds,
AZ::SliceComponent::EntityIdToEntityIdMap* idRemapTable)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
if (!rootEntity)
{
@@ -385,7 +385,7 @@ namespace AzFramework
void SliceEntityOwnershipService::OnAssetReady(AZ::Data::Asset<AZ::Data::AssetData> readyAsset)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
AZ_ASSET_ATTACH_TO_SCOPE(readyAsset.Get());
AZ_Assert(readyAsset.GetAs<AZ::SliceAsset>(), "Asset is not a slice!");
@@ -472,7 +472,7 @@ namespace AzFramework
void SliceEntityOwnershipService::OnAssetReloaded(AZ::Data::Asset<AZ::Data::AssetData> asset)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
if (asset == m_rootAsset && asset.Get() != m_rootAsset.Get())
{
Reset();
@@ -548,7 +548,7 @@ namespace AzFramework
AZ::SliceComponent::SliceInstanceAddress SliceEntityOwnershipService::CloneSliceInstance(
AZ::SliceComponent::SliceInstanceAddress sourceInstance, AZ::SliceComponent::EntityIdToEntityIdMap& sourceToCloneEntityIdMap)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
AZ_Assert(sourceInstance.IsValid(), "Source slice instance is invalid.");
@@ -80,7 +80,7 @@ namespace AzFramework
{
using namespace AZ::IO;
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzCore);
AZ_PROFILE_FUNCTION(AzCore);
AZ_Assert(request, "PrepareRequest was provided a null request.");
if (AZStd::holds_alternative<FileRequest::ReadRequestData>(request->GetCommand()))
@@ -278,7 +278,7 @@ namespace AzFramework
{
using namespace AZ::IO;
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzCore);
AZ_PROFILE_FUNCTION(AzCore);
auto data = AZStd::get_if<FileRequest::ReadData>(&request->GetCommand());
AZ_Assert(data, "Request doing reading in the RemoteStorageDrive didn't contain read data.")
@@ -424,7 +424,7 @@ namespace AzFramework
{
using namespace AZ::IO;
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzCore);
AZ_PROFILE_FUNCTION(AzCore);
TIMED_AVERAGE_WINDOW_SCOPE(m_getFileMetaDataTimeAverage);
AZ::u64 fileSize = 0;
@@ -619,7 +619,7 @@ namespace AzFramework
//=========================================================================
void ScriptComponent::LoadScript()
{
AZ_PROFILE_SCOPE_DYNAMIC(AZ::Debug::ProfileCategory::Script, "Load: %s", m_script.GetHint().c_str());
AZ_PROFILE_SCOPE(Script, "Load: %s", m_script.GetHint().c_str());
// Load the script, find the base table, create the entity table
// find the Activate/Deactivate functions in the script and call them
@@ -634,7 +634,7 @@ namespace AzFramework
//=========================================================================
void ScriptComponent::UnloadScript()
{
AZ_PROFILE_SCOPE_DYNAMIC(AZ::Debug::ProfileCategory::Script, "Unload: %s", m_script.GetHint().c_str());
AZ_PROFILE_SCOPE(Script, "Unload: %s", m_script.GetHint().c_str());
DestroyEntityTable();
}
@@ -822,7 +822,7 @@ namespace AzFramework
lua_rawget(lua, baseStackIndex); // ScriptTable[OnActivate]
if (lua_isfunction(lua, -1))
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::Script, "OnActivate");
AZ_PROFILE_SCOPE(Script, "OnActivate");
lua_rawgeti(lua, LUA_REGISTRYINDEX, m_table); // push the entity table as the only argument
AZ::Internal::LuaSafeCall(lua, 1, 0); // Call OnActivate
}
@@ -856,7 +856,7 @@ namespace AzFramework
lua_rawget(lua, -2); // ScriptTable[OnDeactivte]
if (lua_isfunction(lua, -1))
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::Script, "OnDeactivate");
AZ_PROFILE_SCOPE(Script, "OnDeactivate");
lua_pushvalue(lua, -3); // push the entity table as the only argument
AZ::Internal::LuaSafeCall(lua, 1, 0); // Call OnDeactivate
@@ -625,7 +625,7 @@ namespace AzFramework
return;
}
AZ_PROFILE_TIMER("TargetManager");
AZ_PROFILE_SCOPE(AzFramework, "TargetManager::SendTmMessage");
AZStd::vector<char, AZ::OSStdAllocator> msgBuffer;
AZ::IO::ByteContainerStream<AZStd::vector<char, AZ::OSStdAllocator> > outMsg(&msgBuffer);
@@ -651,7 +651,7 @@ namespace AzFramework
void TargetManagementComponent::DispatchMessages(MsgSlotId id)
{
AZ_PROFILE_TIMER("TargetManager");
AZ_PROFILE_SCOPE(AzFramework, "TargetManager::DispatchMessages");
AZStd::lock_guard<AZStd::mutex> lock(m_inboxMutex);
size_t maxMsgsToProcess = m_inbox.size();
TmMsgQueue::iterator itMsg = m_inbox.begin();
@@ -684,7 +684,7 @@ namespace AzFramework
{
if (m_networkImpl->m_gridMate)
{
AZ_PROFILE_TIMER("TargetManager");
AZ_PROFILE_SCOPE(AzFramework, "TargetManager::Tick");
if (!m_networkImpl->m_session && !m_networkImpl->m_gridSearch)
{
if (AZStd::chrono::system_clock::now() > m_reconnectionTime)
@@ -694,7 +694,7 @@ namespace AzFramework
}
{
AZ_PROFILE_TIMER("TargetManager", "Tick Gridmate");
AZ_PROFILE_SCOPE(AzFramework, "TargetManager::Tick Gridmate");
m_networkImpl->m_gridMate->Update();
if (m_networkImpl->m_session && m_networkImpl->m_session->GetReplicaMgr())
{
@@ -707,7 +707,7 @@ namespace AzFramework
if (m_networkImpl->m_session)
{
AZ_PROFILE_TIMER("TargetManager", "Send/Receive TmMsgs");
AZ_PROFILE_SCOPE(AzFramework, "TargetManager::Tick Send/Receive TmMsgs");
// Receive
for (unsigned int i = 0; i < m_networkImpl->m_session->GetNumberOfMembers(); ++i)
@@ -8,12 +8,12 @@
#include "CameraInput.h"
#include <AzCore/Console/IConsole.h>
#include <AzCore/Math/MathUtils.h>
#include <AzCore/Math/Plane.h>
#include <AzCore/std/numeric.h>
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
#include <AzFramework/Windowing/WindowBus.h>
namespace AzFramework
{
@@ -26,6 +26,13 @@ namespace AzFramework
"The default height of the ground plane to do intersection tests against when orbiting");
AZ_CVAR(float, ed_cameraSystemMinOrbitDistance, 10.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(float, ed_cameraSystemMaxOrbitDistance, 50.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "");
AZ_CVAR(
bool,
ed_cameraSystemUseCursor,
true,
nullptr,
AZ::ConsoleFunctorFlags::Null,
"Should the camera use cursor absolute positions or motion deltas");
//! return -1.0f if inverted, 1.0f otherwise
constexpr static float Invert(const bool invert)
@@ -134,9 +141,13 @@ namespace AzFramework
bool CameraSystem::HandleEvents(const InputEvent& event)
{
if (const auto& horizonalMotion = AZStd::get_if<HorizontalMotionEvent>(&event))
if (const auto& cursor = AZStd::get_if<CursorEvent>(&event))
{
m_motionDelta.m_x = horizonalMotion->m_delta;
m_cursorState.SetCurrentPosition(cursor->m_position);
}
else if (const auto& horizontalMotion = AZStd::get_if<HorizontalMotionEvent>(&event))
{
m_motionDelta.m_x = horizontalMotion->m_delta;
}
else if (const auto& verticalMotion = AZStd::get_if<VerticalMotionEvent>(&event))
{
@@ -147,15 +158,18 @@ namespace AzFramework
m_scrollDelta = scroll->m_delta;
}
m_handlingEvents = m_cameras.HandleEvents(event, m_motionDelta, m_scrollDelta);
m_handlingEvents =
m_cameras.HandleEvents(event, ed_cameraSystemUseCursor ? m_cursorState.CursorDelta() : m_motionDelta, m_scrollDelta);
return m_handlingEvents;
}
Camera CameraSystem::StepCamera(const Camera& targetCamera, const float deltaTime)
{
const auto nextCamera = m_cameras.StepCamera(targetCamera, m_motionDelta, m_scrollDelta, deltaTime);
const auto nextCamera = m_cameras.StepCamera(
targetCamera, ed_cameraSystemUseCursor ? m_cursorState.CursorDelta() : m_motionDelta, m_scrollDelta, deltaTime);
m_cursorState.Update();
m_motionDelta = ScreenVector{ 0, 0 };
m_scrollDelta = 0.0f;
@@ -727,18 +741,36 @@ namespace AzFramework
Camera camera;
// note: the math for the lerp smoothing implementation for camera rotation and translation was inspired by this excellent
// article by Scott Lembcke: https://www.gamasutra.com/blogs/ScottLembcke/20180404/316046/Improved_Lerp_Smoothing.php
const float lookRate = AZStd::exp2(cameraProps.m_rotateSmoothnessFn());
const float lookT = AZStd::exp2(-lookRate * deltaTime);
camera.m_pitch = AZ::Lerp(targetCamera.m_pitch, currentCamera.m_pitch, lookT);
camera.m_yaw = AZ::Lerp(targetYaw, currentYaw, lookT);
const float moveRate = AZStd::exp2(cameraProps.m_translateSmoothnessFn());
const float moveT = AZStd::exp2(-moveRate * deltaTime);
camera.m_lookDist = AZ::Lerp(targetCamera.m_lookDist, currentCamera.m_lookDist, moveT);
camera.m_lookAt = targetCamera.m_lookAt.Lerp(currentCamera.m_lookAt, moveT);
if (cameraProps.m_rotateSmoothingEnabledFn())
{
const float lookRate = AZStd::exp2(cameraProps.m_rotateSmoothnessFn());
const float lookTime = AZStd::exp2(-lookRate * deltaTime);
camera.m_pitch = AZ::Lerp(targetCamera.m_pitch, currentCamera.m_pitch, lookTime);
camera.m_yaw = AZ::Lerp(targetYaw, currentYaw, lookTime);
}
else
{
camera.m_pitch = targetCamera.m_pitch;
camera.m_yaw = targetYaw;
}
if (cameraProps.m_translateSmoothingEnabledFn())
{
const float moveRate = AZStd::exp2(cameraProps.m_translateSmoothnessFn());
const float moveTime = AZStd::exp2(-moveRate * deltaTime);
camera.m_lookDist = AZ::Lerp(targetCamera.m_lookDist, currentCamera.m_lookDist, moveTime);
camera.m_lookAt = targetCamera.m_lookAt.Lerp(currentCamera.m_lookAt, moveTime);
}
else
{
camera.m_lookDist = targetCamera.m_lookDist;
camera.m_lookAt = targetCamera.m_lookAt;
}
return camera;
}
InputEvent BuildInputEvent(const InputChannel& inputChannel)
InputEvent BuildInputEvent(const InputChannel& inputChannel, const WindowSize& windowSize)
{
const auto& inputChannelId = inputChannel.GetInputChannelId();
const auto& inputDeviceId = inputChannel.GetInputDevice().GetInputDeviceId();
@@ -753,7 +785,16 @@ namespace AzFramework
// accept active mouse channel updates, inactive movement channels will just have a 0 delta
if (inputChannel.IsActive())
{
if (inputChannelId == InputDeviceMouse::Movement::X)
if (inputChannelId == InputDeviceMouse::SystemCursorPosition)
{
const auto* position = inputChannel.GetCustomData<AzFramework::InputChannel::PositionData2D>();
AZ_Assert(position, "Expected PositionData2D but found nullptr");
return CursorEvent{ ScreenPoint(
position->m_normalizedPosition.GetX() * windowSize.m_width,
position->m_normalizedPosition.GetY() * windowSize.m_height) };
}
else if (inputChannelId == InputDeviceMouse::Movement::X)
{
return HorizontalMotionEvent{ aznumeric_cast<int>(inputChannel.GetValue()) };
}
@@ -761,6 +802,7 @@ namespace AzFramework
{
return VerticalMotionEvent{ aznumeric_cast<int>(inputChannel.GetValue()) };
}
else if (inputChannelId == InputDeviceMouse::Movement::Z)
{
return ScrollEvent{ inputChannel.GetValue() };
@@ -8,17 +8,23 @@
#pragma once
#include <AzCore/Console/IConsole.h>
#include <AzCore/Math/Matrix3x3.h>
#include <AzCore/Math/Transform.h>
#include <AzCore/std/containers/variant.h>
#include <AzCore/std/optional.h>
#include <AzFramework/Input/Channels/InputChannel.h>
#include <AzFramework/Viewport/ClickDetector.h>
#include <AzFramework/Viewport/CursorState.h>
#include <AzFramework/Viewport/ScreenGeometry.h>
#include <AzFramework/Viewport/ViewportId.h>
namespace AzFramework
{
AZ_CVAR_EXTERNED(bool, ed_cameraSystemUseCursor);
struct WindowSize;
//! Returns Euler angles (pitch, roll, yaw) for the incoming orientation.
//! @note Order of rotation is Z, Y, X.
AZ::Vector3 EulerAngles(const AZ::Matrix3x3& orientation);
@@ -79,6 +85,11 @@ namespace AzFramework
using HorizontalMotionEvent = MotionEvent<struct HorizontalMotionTag>;
using VerticalMotionEvent = MotionEvent<struct VerticalMotionTag>;
struct CursorEvent
{
ScreenPoint m_position;
};
struct ScrollEvent
{
float m_delta;
@@ -93,7 +104,8 @@ namespace AzFramework
};
//! Represents a type-safe union of input events that are handled by the camera system.
using InputEvent = AZStd::variant<AZStd::monostate, HorizontalMotionEvent, VerticalMotionEvent, ScrollEvent, DiscreteInputEvent>;
using InputEvent =
AZStd::variant<AZStd::monostate, HorizontalMotionEvent, VerticalMotionEvent, CursorEvent, ScrollEvent, DiscreteInputEvent>;
//! Base class for all camera behaviors.
//! The core interface consists of:
@@ -219,10 +231,14 @@ namespace AzFramework
//! Properties to use to configure behavior across all types of camera.
struct CameraProps
{
AZStd::function<float()>
m_rotateSmoothnessFn; //!< Rotate smoothing value (useful approx range 3-6, higher values give sharper feel).
AZStd::function<float()>
m_translateSmoothnessFn; //!< Translate smoothing value (useful approx range 3-6, higher values give sharper feel).
//! Rotate smoothing value (useful approx range 3-6, higher values give sharper feel).
AZStd::function<float()> m_rotateSmoothnessFn;
//! Translate smoothing value (useful approx range 3-6, higher values give sharper feel).
AZStd::function<float()> m_translateSmoothnessFn;
//! Enable/disable rotation smoothing.
AZStd::function<bool()> m_rotateSmoothingEnabledFn;
//! Enable/disable translation smoothing.
AZStd::function<bool()> m_translateSmoothingEnabledFn;
};
//! An interpolation function to smoothly interpolate all camera properties from currentCamera to targetCamera.
@@ -262,12 +278,16 @@ namespace AzFramework
public:
bool HandleEvents(const InputEvent& event);
Camera StepCamera(const Camera& targetCamera, float deltaTime);
bool HandlingEvents() const { return m_handlingEvents; }
bool HandlingEvents() const
{
return m_handlingEvents;
}
Cameras m_cameras; //!< Represents a collection of camera inputs that together provide a camera controller.
private:
ScreenVector m_motionDelta; //!< The delta used for look/orbit/pan (rotation + translation) - two dimensional.
CursorState m_cursorState; //!< The current and previous position of the cursor (used to calculate movement delta).
float m_scrollDelta = 0.0f; //!< The delta used for dolly/movement (translation) - one dimensional.
bool m_handlingEvents = false; //!< Is the camera system currently handling events (events are consumed and not propagated).
};
@@ -548,5 +568,5 @@ namespace AzFramework
}
//! Map from a generic InputChannel event to a camera specific InputEvent.
InputEvent BuildInputEvent(const InputChannel& inputChannel);
InputEvent BuildInputEvent(const InputChannel& inputChannel, const WindowSize& windowSize);
} // namespace AzFramework
@@ -8,6 +8,7 @@
#include "EntityVisibilityBoundsUnionSystem.h"
#include <AzCore/Debug/Profiler.h>
#include <AzFramework/Visibility/BoundsBus.h>
#include <cstring>
@@ -42,7 +43,7 @@ namespace AzFramework
void EntityVisibilityBoundsUnionSystem::OnEntityActivated(AZ::Entity* entity)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
// ignore any entity that might activate which does not have a TransformComponent
if (entity->GetTransform() == nullptr)
@@ -68,7 +69,7 @@ namespace AzFramework
void EntityVisibilityBoundsUnionSystem::OnEntityDeactivated(AZ::Entity* entity)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
// ignore any entity that might deactivate which does not have a TransformComponent
if (entity->GetTransform() == nullptr)
@@ -89,7 +90,7 @@ namespace AzFramework
void EntityVisibilityBoundsUnionSystem::UpdateVisibilitySystem(AZ::Entity* entity, EntityVisibilityBoundsUnionInstance& instance)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
if (const auto& localEntityBoundsUnions = instance.m_localEntityBoundsUnion; localEntityBoundsUnions.IsValid())
{
@@ -136,7 +137,7 @@ namespace AzFramework
void EntityVisibilityBoundsUnionSystem::ProcessEntityBoundsUnionRequests()
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
// iterate over all entities whose bounds changed and recalculate them
for (const auto& entity : m_entityBoundsDirty)
@@ -155,7 +156,7 @@ namespace AzFramework
void EntityVisibilityBoundsUnionSystem::OnTransformUpdated(AZ::Entity* entity)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
// update the world transform of the visibility bounds union
if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entity);
@@ -34,7 +34,7 @@ namespace AzFramework
{
void EntityVisibilityQuery::UpdateVisibility(const AzFramework::CameraState& cameraState)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
AZ_PROFILE_FUNCTION(AzFramework);
auto* visSystem = AZ::Interface<AzFramework::IVisibilitySystem>::Get();
if (!visSystem)
+3 -9
View File
@@ -10,7 +10,6 @@
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME})
ly_get_list_relative_pal_filename(common_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/Common)
set(LY_STATISTICAL_PROFILING_ENABLED OFF CACHE BOOL "Enables statistical profiling when using AZ_PROFILE_SCOPE. If True, it takes effect only if RAD Telemetry is disabled.")
set(LY_TOUCHBENDING_LAYER_BIT 63 CACHE STRING "Use TouchBending as the collision layer. The TouchBending layer can be a number from 1 to 63 (Default=63).")
ly_add_target(
@@ -38,14 +37,6 @@ ly_add_target(
3rdParty::lz4
)
if(LY_STATISTICAL_PROFILING_ENABLED)
ly_add_source_properties(
SOURCES AzFramework/Debug/StatisticalProfilerProxy.h
PROPERTY COMPILE_DEFINITIONS
VALUES AZ_STATISTICAL_PROFILING_ENABLED
)
endif()
ly_add_source_properties(
SOURCES
AzFramework/Physics/Collision/CollisionGroups.cpp
@@ -70,6 +61,9 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
PRIVATE
AZ::AzCore
AZ::AzFramework
PUBLIC
AZ::AzTest
AZ::AzTestShared
)
if(PAL_TRAIT_BUILD_HOST_TOOLS)
@@ -59,10 +59,15 @@ namespace UnitTest
m_cameraSystem->m_cameras.AddCamera(m_firstPersonRotateCamera);
m_cameraSystem->m_cameras.AddCamera(m_firstPersonTranslateCamera);
m_cameraSystem->m_cameras.AddCamera(orbitCamera);
// these tests rely on using motion delta, not cursor positions (default is true)
AzFramework::ed_cameraSystemUseCursor = false;
}
void TearDown() override
{
AzFramework::ed_cameraSystemUseCursor = true;
m_firstPersonRotateCamera.reset();
m_firstPersonTranslateCamera.reset();
@@ -0,0 +1,41 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzFramework/Windowing/WindowBus.h>
#include <gmock/gmock.h>
namespace UnitTest
{
class MockWindowRequests : public AzFramework::WindowRequestBus::Handler
{
public:
void Connect(AzFramework::NativeWindowHandle handle)
{
AzFramework::WindowRequestBus::Handler::BusConnect(handle);
}
void Disconnect()
{
AzFramework::WindowRequestBus::Handler::BusDisconnect();
}
// AzFramework::WindowRequestBus overrides ...
MOCK_METHOD1(SetWindowTitle, void(const AZStd::string&));
MOCK_CONST_METHOD0(GetClientAreaSize, AzFramework::WindowSize());
MOCK_METHOD1(ResizeClientArea, void(AzFramework::WindowSize clientAreaSize));
MOCK_CONST_METHOD0(GetFullScreenState, bool());
MOCK_METHOD1(SetFullScreenState, void(bool));
MOCK_CONST_METHOD0(CanToggleFullScreenState, bool());
MOCK_METHOD0(ToggleFullScreenState, void());
MOCK_CONST_METHOD0(GetDpiScaleFactor, float());
MOCK_CONST_METHOD0(GetSyncInterval, uint32_t());
MOCK_CONST_METHOD0(GetDisplayRefreshRate, uint32_t());
};
} // namespace UnitTest
@@ -8,6 +8,7 @@
set(FILES
Mocks/MockSpawnableEntitiesInterface.h
Mocks/MockWindowRequests.h
Utils/Utils.h
Utils/Utils.cpp
FrameworkApplicationFixture.h