Merging latest origin

This commit is contained in:
karlberg
2021-05-07 16:28:11 -07:00
141 changed files with 2843 additions and 1178 deletions
@@ -36,6 +36,8 @@ namespace AzFramework
void NonUniformScaleComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC_CE("NonUniformScaleService"));
incompatible.push_back(AZ_CRC_CE("DebugDrawObbService"));
incompatible.push_back(AZ_CRC_CE("DebugDrawService"));
incompatible.push_back(AZ_CRC_CE("EMotionFXActorService"));
@@ -19,44 +19,29 @@
namespace AzPhysics
{
struct SimulatedBody;
}
namespace Physics
{
//! Requests for generic physical world bodies
class WorldBodyRequests
//! Requests for physics simulated body components.
class SimulatedBodyComponentRequests
: public AZ::ComponentBus
{
public:
using MutexType = AZStd::recursive_mutex;
//! Enable physics for this body
//! Enable physics for this body.
virtual void EnablePhysics() = 0;
//! Disable physics for this body
//! Disable physics for this body.
virtual void DisablePhysics() = 0;
//! Retrieve whether physics is enabled for this body
//! Retrieve whether physics is enabled for this body.
virtual bool IsPhysicsEnabled() const = 0;
//! Retrieves the AABB(aligned-axis bounding box) for this body
//! Retrieves the AABB(aligned-axis bounding box) for this body.
virtual AZ::Aabb GetAabb() const = 0;
//! Retrieves current WorldBody* for this body. Note: Do not hold a reference to AzPhysics::SimulatedBody* as could be deleted
virtual AzPhysics::SimulatedBody* GetWorldBody() = 0;
//! Perform a single-object raycast against this body
//! Get the Simulated Body Handle for this body.
virtual AzPhysics::SimulatedBodyHandle GetSimulatedBodyHandle() const = 0;
//! Retrieves current WorldBody* for this body.
//! @note Do not hold a reference to AzPhysics::SimulatedBody* as it could be deleted or moved.
virtual AzPhysics::SimulatedBody* GetSimulatedBody() = 0;
//! Perform a single-object raycast against this body.
virtual AzPhysics::SceneQueryHit RayCast(const AzPhysics::RayCastRequest& request) = 0;
};
using WorldBodyRequestBus = AZ::EBus<WorldBodyRequests>;
//! Notifications for generic physical world bodies
class WorldBodyNotifications
: public AZ::ComponentBus
{
public:
//! Notification for physics enabled
virtual void OnPhysicsEnabled() = 0;
//! Notification for physics disabled
virtual void OnPhysicsDisabled() = 0;
};
using WorldBodyNotificationBus = AZ::EBus<WorldBodyNotifications>;
using SimulatedBodyComponentRequestsBus = AZ::EBus<SimulatedBodyComponentRequests>;
}
@@ -21,7 +21,7 @@
#include <AzFramework/Physics/ShapeConfiguration.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzFramework/Physics/CollisionBus.h>
#include <AzFramework/Physics/WorldBodyBus.h>
#include <AzFramework/Physics/Components/SimulatedBodyComponentBus.h>
#include <AzFramework/Physics/WindBus.h>
#include <AzFramework/Physics/PhysicsSystem.h>
#include <AzFramework/Physics/Collision/CollisionEvents.h>
@@ -39,19 +39,19 @@ namespace Physics
{
namespace ReflectionUtils
{
void ReflectWorldBodyBus(AZ::ReflectContext* context)
void ReflectSimulatedBodyComponentRequestsBus(AZ::ReflectContext* context)
{
if (auto* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<Physics::WorldBodyRequestBus>("WorldBodyRequestBus")
behaviorContext->EBus<AzPhysics::SimulatedBodyComponentRequestsBus>("SimulatedBodyComponentRequestBus")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "physics")
->Attribute(AZ::Script::Attributes::Category, "PhysX")
->Event("EnablePhysics", &WorldBodyRequests::EnablePhysics)
->Event("DisablePhysics", &WorldBodyRequests::DisablePhysics)
->Event("IsPhysicsEnabled", &WorldBodyRequests::IsPhysicsEnabled)
->Event("GetAabb", &WorldBodyRequests::GetAabb)
->Event("RayCast", &WorldBodyRequests::RayCast)
->Event("EnablePhysics", &AzPhysics::SimulatedBodyComponentRequests::EnablePhysics)
->Event("DisablePhysics", &AzPhysics::SimulatedBodyComponentRequests::DisablePhysics)
->Event("IsPhysicsEnabled", &AzPhysics::SimulatedBodyComponentRequests::IsPhysicsEnabled)
->Event("GetAabb", &AzPhysics::SimulatedBodyComponentRequests::GetAabb)
->Event("RayCast", &AzPhysics::SimulatedBodyComponentRequests::RayCast)
;
}
}
@@ -131,7 +131,7 @@ namespace Physics
AnimationConfiguration::Reflect(context);
CharacterConfiguration::Reflect(context);
AzPhysics::SimulatedBody::Reflect(context);
ReflectWorldBodyBus(context);
ReflectSimulatedBodyComponentRequestsBus(context);
CollisionFilteringRequests::Reflect(context);
AzPhysics::SceneQuery::ReflectSceneQueryObjects(context);
ReflectWindBus(context);
@@ -48,15 +48,21 @@ namespace AzFramework
};
//! The interface used by MultiViewportController to manage individual instances.
template <class TController>
class MultiViewportControllerInstanceInterface
{
public:
explicit MultiViewportControllerInstanceInterface(ViewportId viewport)
using ControllerType = TController;
MultiViewportControllerInstanceInterface(ViewportId viewport, ControllerType* controller)
: m_viewportId(viewport)
, m_controller(controller)
{
}
ViewportId GetViewportId() const { return m_viewportId; }
ControllerType* GetController() { return m_controller; }
const ControllerType* GetController() const { return m_controller; }
virtual bool HandleInputChannelEvent([[maybe_unused]]const ViewportControllerInputEvent& event) { return false; }
virtual void ResetInputChannels() {}
@@ -64,6 +70,7 @@ namespace AzFramework
private:
ViewportId m_viewportId;
ControllerType* m_controller;
};
} //namespace AzFramework
@@ -17,8 +17,8 @@ namespace AzFramework
MultiViewportController<TViewportControllerInstance, Priority>::~MultiViewportController()
{
static_assert(
AZStd::is_constructible<TViewportControllerInstance, ViewportId>::value,
"TViewportControllerInstance must implement a TViewportControllerInstance(ViewportId) constructor"
AZStd::is_same<TViewportControllerInstance, decltype(TViewportControllerInstance(0, nullptr))>::value,
"TViewportControllerInstance must implement a TViewportControllerInstance(ViewportId, ViewportController) constructor"
);
}
@@ -50,7 +50,7 @@ namespace AzFramework
template <class TViewportControllerInstance, ViewportControllerPriority Priority>
void MultiViewportController<TViewportControllerInstance, Priority>::RegisterViewportContext(ViewportId viewport)
{
m_instances[viewport] = AZStd::make_unique<TViewportControllerInstance>(viewport);
m_instances[viewport] = AZStd::make_unique<TViewportControllerInstance>(viewport, static_cast<typename TViewportControllerInstance::ControllerType*>(this));
}
template <class TViewportControllerInstance, ViewportControllerPriority Priority>
@@ -213,6 +213,12 @@ set(FILES
StreamingInstall/StreamingInstall.cpp
StreamingInstall/StreamingInstallRequests.h
StreamingInstall/StreamingInstallNotifications.h
Physics/Collision/CollisionEvents.h
Physics/Collision/CollisionEvents.cpp
Physics/Collision/CollisionLayers.h
Physics/Collision/CollisionLayers.cpp
Physics/Collision/CollisionGroups.h
Physics/Collision/CollisionGroups.cpp
Physics/Common/PhysicsSceneQueries.h
Physics/Common/PhysicsSceneQueries.cpp
Physics/Common/PhysicsEvents.h
@@ -223,12 +229,7 @@ set(FILES
Physics/Common/PhysicsSimulatedBodyEvents.h
Physics/Common/PhysicsSimulatedBodyEvents.cpp
Physics/Common/PhysicsTypes.h
Physics/Collision/CollisionEvents.h
Physics/Collision/CollisionEvents.cpp
Physics/Collision/CollisionLayers.h
Physics/Collision/CollisionLayers.cpp
Physics/Collision/CollisionGroups.h
Physics/Collision/CollisionGroups.cpp
Physics/Components/SimulatedBodyComponentBus.h
Physics/Configuration/CollisionConfiguration.h
Physics/Configuration/CollisionConfiguration.cpp
Physics/Configuration/RigidBodyConfiguration.h
@@ -265,7 +266,6 @@ set(FILES
Physics/ShapeConfiguration.h
Physics/ShapeConfiguration.cpp
Physics/SystemBus.h
Physics/WorldBodyBus.h
Physics/ColliderComponentBus.h
Physics/RagdollPhysicsBus.h
Physics/CharacterPhysicsDataBus.h
@@ -0,0 +1,78 @@
/*
* 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 : Utilities for iOS and Mac OS X. Needs to be separated
// due to conflict with the system headers.
#ifndef CRYINCLUDE_CRYSYSTEM_SYSTEMUTILSAPPLE_H
#define CRYINCLUDE_CRYSYSTEM_SYSTEMUTILSAPPLE_H
#pragma once
#include <sys/resource.h>
#include <sys/types.h>
#include <AzCore/std/string/string.h>
namespace SystemUtilsApple
{
// Get the path to the application's bundle.
// - Returns length of the string or 0 on failure.
size_t GetPathToApplicationBundle(char* buffer, size_t bufferLen);
// Get the path to the application's executable.
// - Returns length of the string or 0 on failure.
size_t GetPathToApplicationExecutable(char* buffer, size_t bufferLen);
// Get the path to the application's resources.
// - Returns length of the string or 0 on failure.
size_t GetPathToApplicationResources(char* buffer, size_t bufferLen);
// Get the path to the user domain's application support directory.
// - Returns length of the string or 0 on failure.
// - Used to store application generated content.
// - iOS: Not available through file sharing.
// - Persistent, backed up by iTunes.
size_t GetPathToUserApplicationSupportDirectory(char* buffer, size_t bufferLen);
// Get the path to the user domain's caches directory.
// - Returns length of the string or 0 on failure.
// - Used to store application generated content.
// - iOS: Not available through file sharing.
// - Temporary, not backed up by iTunes.
size_t GetPathToUserCachesDirectory(char* buffer, size_t bufferLen);
// Get the path to the user domain's document directory.
// - Returns length of the string or 0 on failure.
// - Used to store user generated content.
// - iOS: Available through file sharing.
// - Persistent, backed up by iTunes.
size_t GetPathToUserDocumentDirectory(char* buffer, size_t bufferLen);
// Get the path to the user domain's library directory.
// - Returns length of the string or 0 on failure.
// - Parent directory of app support and caches.
// - iOS: Not available through file sharing.
// - Persistent, backed up by iTunes.
size_t GetPathToUserLibraryDirectory(char* buffer, size_t bufferLen);
// Get the user's name.
// - Returns length of the string or 0 on failure.
size_t GetUserName(char* buffer, size_t bufferLen);
// Get the device's machine name
// - Returns string representing device identifier or empty string on failure
// - Unique for each model
AZStd::string GetMachineName();
}
#endif // CRYINCLUDE_CRYSYSTEM_SYSTEMUTILSAPPLE_H
@@ -0,0 +1,131 @@
/*
* 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.
#include "SystemUtilsApple.h"
#include <AzCore/base.h>
#include <AzCore/Debug/Trace.h>
#include <Foundation/Foundation.h>
#include <mach-o/dyld.h>
#include <pthread.h>
#include <sys/utsname.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace SystemUtilsApplePrivate
{
////////////////////////////////////////////////////////////////////////////////////////////////
// Performs a 'safe' string copy from 'NString* source' to 'char* buffer' of 'size_t bufferLen'.
// Returns the length of the string, or 0 if the buffer is not large enough to hold the source.
// Copying an empty or null string will return 0, and null-terminate the buffer if possible.
////////////////////////////////////////////////////////////////////////////////////////////////
size_t CopyNSStringToBuffer(NSString* source, char* buffer, const size_t bufferLen)
{
if (!buffer || !bufferLen)
{
return 0;
}
if (source)
{
const char* src = [source UTF8String];
const size_t srcLen = strlen(src);
if (srcLen < bufferLen - 1)
{
azstrncpy(buffer, bufferLen, src, srcLen);
buffer[srcLen] = '\0';
return srcLen;
}
}
// Could not copy the source to the destination buffer.
buffer[0] = '\0';
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////
// Get the path to the specified user domain directory.
// Returns length of the string or 0 on failure.
////////////////////////////////////////////////////////////////////////////////////////////////
size_t GetPathToUserDirectory(NSSearchPathDirectory dir, char* buffer, const size_t bufferLen)
{
NSArray* userDomainDirectoryPaths = NSSearchPathForDirectoriesInDomains(dir, NSUserDomainMask, YES);
if ([userDomainDirectoryPaths count] != 0)
{
NSString* userDomainDirectoryPath = static_cast<NSString*>([userDomainDirectoryPaths objectAtIndex:0]);
return CopyNSStringToBuffer(userDomainDirectoryPath, buffer, bufferLen);
}
return 0;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
size_t SystemUtilsApple::GetPathToApplicationBundle(char* buffer, const size_t bufferLen)
{
NSString* bundlePath = [[NSBundle mainBundle] bundlePath];
return SystemUtilsApplePrivate::CopyNSStringToBuffer(bundlePath, buffer, bufferLen);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
size_t SystemUtilsApple::GetPathToApplicationExecutable(char* buffer, const size_t bufferLen)
{
NSString* executablePath = [[NSBundle mainBundle] executablePath];
return SystemUtilsApplePrivate::CopyNSStringToBuffer(executablePath, buffer, bufferLen);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
size_t SystemUtilsApple::GetPathToApplicationResources(char* buffer, const size_t bufferLen)
{
NSString* resourcesPath = [[NSBundle mainBundle] resourcePath];
return SystemUtilsApplePrivate::CopyNSStringToBuffer(resourcesPath, buffer, bufferLen);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
size_t SystemUtilsApple::GetPathToUserApplicationSupportDirectory(char* buffer, const size_t bufferLen)
{
return SystemUtilsApplePrivate::GetPathToUserDirectory(NSApplicationSupportDirectory, buffer, bufferLen);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
size_t SystemUtilsApple::GetPathToUserCachesDirectory(char* buffer, const size_t bufferLen)
{
return SystemUtilsApplePrivate::GetPathToUserDirectory(NSCachesDirectory, buffer, bufferLen);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
size_t SystemUtilsApple::GetPathToUserDocumentDirectory(char* buffer, const size_t bufferLen)
{
return SystemUtilsApplePrivate::GetPathToUserDirectory(NSDocumentDirectory, buffer, bufferLen);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
size_t SystemUtilsApple::GetPathToUserLibraryDirectory(char* buffer, const size_t bufferLen)
{
return SystemUtilsApplePrivate::GetPathToUserDirectory(NSLibraryDirectory, buffer, bufferLen);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
size_t SystemUtilsApple::GetUserName(char* buffer, const size_t bufferLen)
{
return SystemUtilsApplePrivate::CopyNSStringToBuffer(NSUserName(), buffer, bufferLen);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
AZStd::string SystemUtilsApple::GetMachineName()
{
utsname systemInfo;
if (uname(&systemInfo) == -1)
{
return "";
}
return systemInfo.machine;
}
@@ -0,0 +1,16 @@
/*
* 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.
#pragma once
#include "../../../Common/Apple/AzFramework/Utils/SystemUtilsApple.h"
@@ -36,4 +36,6 @@ set(FILES
../Common/Unimplemented/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard_Unimplemented.cpp
AzFramework/Archive/ArchiveVars_Platform.h
AzFramework/Archive/ArchiveVars_Mac.h
../Common/Apple/AzFramework/Utils/SystemUtilsApple.h
../Common/Apple/AzFramework/Utils/SystemUtilsApple.mm
)
@@ -0,0 +1,15 @@
/*
* 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 "../../../Common/Apple/AzFramework/Utils/SystemUtilsApple.h"
@@ -36,5 +36,7 @@ set(FILES
AzFramework/Process/ProcessCommon.h
AzFramework/Process/ProcessWatcher_iOS.cpp
AzFramework/Process/ProcessCommunicator_iOS.cpp
../Common/Apple/AzFramework/Utils/SystemUtilsApple.h
../Common/Apple/AzFramework/Utils/SystemUtilsApple.mm
)