Merge branch 'development' into cmake/SPEC-2513_w4244

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

# Conflicts:
#	Code/Framework/Crcfix/crcfix.cpp
monroegm-disable-blank-issue-2
Esteban Papp 4 years ago
commit 1e136a02b0

@ -7,10 +7,14 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
# fmt:off
class Tests():
create_new_entity = ("Entity: 'CreateNewEntity' passed", "Entity: 'CreateNewEntity' failed")
create_prefab = ("Prefab: 'CreatePrefab' passed", "Prefab: 'CreatePrefab' failed")
instantiate_prefab = ("Prefab: 'InstantiatePrefab' passed", "Prefab: 'InstantiatePrefab' failed")
new_prefab_position = ("Prefab: new prefab's position is at the expected position", "Prefab: new prefab's position is *not* at the expected position")
create_new_entity = ("'CreateNewEntity' passed", "'CreateNewEntity' failed")
create_prefab = ("'CreatePrefab' passed", "'CreatePrefab' failed")
instantiate_prefab = ("'InstantiatePrefab' passed", "'InstantiatePrefab' failed")
has_one_child = ("instantiated prefab contains only one child as expected", "instantiated prefab does *not* contain only one child as expected")
instantiated_prefab_position = ("instantiated prefab's position is at the expected position", "instantiated prefab's position is *not* at the expected position")
delete_prefab = ("'DeleteEntitiesAndAllDescendantsInInstance' passed", "'DeleteEntitiesAndAllDescendantsInInstance' failed")
instantiated_prefab_removed = ("instantiated prefab's container entity has been removed", "instantiated prefab's container entity has *not* been removed")
instantiated_child_removed = ("instantiated prefab's child entity has been removed", "instantiated prefab's child entity has *not* been removed")
# fmt:on
def PrefabLevel_BasicWorkflow():
@ -18,6 +22,7 @@ def PrefabLevel_BasicWorkflow():
This test will help verify if the following functions related to Prefab work as expected:
- CreatePrefab
- InstantiatePrefab
- DeleteEntitiesAndAllDescendantsInInstance
"""
import os
@ -35,31 +40,68 @@ def PrefabLevel_BasicWorkflow():
from azlmbr.math import Vector3
import azlmbr.legacy.general as general
EXPECTED_NEW_PREFAB_POSITION = Vector3(10.00, 20.0, 30.0)
NEW_PREFAB_NAME = "new_prefab"
NEW_PREFAB_FILE_NAME = NEW_PREFAB_NAME + ".prefab"
NEW_PREFAB_FILE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), NEW_PREFAB_FILE_NAME)
INSTANTIATED_PREFAB_POSITION = Vector3(10.00, 20.0, 30.0)
INSTANTIATED_PREFAB_NAME = "instantiated_prefab"
INSTANTIATED_CHILD_ENTITY_NAME = "child_1"
TEST_LEVEL_FOLDER = "Prefab"
TEST_LEVEL_NAME = "Base"
def find_entity_by_name(entity_name):
searchFilter = entity.SearchFilter()
searchFilter.names = [entity_name]
entityIds = entity.SearchBus(bus.Broadcast, 'SearchEntities', searchFilter)
if entityIds and entityIds[0].IsValid():
return entityIds[0]
return None
def print_error_if_failed(prefab_operation_result):
if not prefab_operation_result.IsSuccess():
Report.info(f'Error message: {prefab_operation_result.GetError()}')
# Open the test level
helper.init_idle()
helper.open_level("Prefab", "Base")
helper.open_level(TEST_LEVEL_FOLDER, TEST_LEVEL_NAME)
# Create a new Entity at the root level
new_entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', EntityId())
Report.result(Tests.create_new_entity, new_entity_id.IsValid())
# Checks for prefab creation passed or not
new_prefab_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'new_prefab.prefab')
create_prefab_result = prefab.PrefabPublicRequestBus(bus.Broadcast, 'CreatePrefabInMemory', [new_entity_id], new_prefab_file_path)
Report.result(Tests.create_prefab, create_prefab_result)
create_prefab_result = prefab.PrefabPublicRequestBus(bus.Broadcast, 'CreatePrefabInMemory', [new_entity_id], NEW_PREFAB_FILE_PATH)
Report.result(Tests.create_prefab, create_prefab_result.IsSuccess())
print_error_if_failed(create_prefab_result)
# Checks for prefab instantiation passed or not
container_entity_id = prefab.PrefabPublicRequestBus(bus.Broadcast, 'InstantiatePrefab', new_prefab_file_path, EntityId(), EXPECTED_NEW_PREFAB_POSITION)
Report.result(Tests.instantiate_prefab, container_entity_id.IsValid())
instantiate_prefab_result = prefab.PrefabPublicRequestBus(bus.Broadcast, 'InstantiatePrefab', NEW_PREFAB_FILE_PATH, EntityId(), INSTANTIATED_PREFAB_POSITION)
Report.result(Tests.instantiate_prefab, instantiate_prefab_result.IsSuccess() and instantiate_prefab_result.GetValue().IsValid())
print_error_if_failed(instantiate_prefab_result)
container_entity_id = instantiate_prefab_result.GetValue()
editor.EditorEntityAPIBus(bus.Event, 'SetName', container_entity_id, INSTANTIATED_PREFAB_NAME)
children_entity_ids = editor.EditorEntityInfoRequestBus(bus.Event, 'GetChildren', container_entity_id)
Report.result(Tests.has_one_child, len(children_entity_ids) is 1)
child_entity_id = children_entity_ids[0]
editor.EditorEntityAPIBus(bus.Event, 'SetName', child_entity_id, INSTANTIATED_CHILD_ENTITY_NAME)
# Checks if the new prefab is at the correct position and if it fails, it will provide the expected postion and the actual postion of the entity in the Editor log
new_prefab_position = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", container_entity_id)
is_at_position = new_prefab_position.IsClose(EXPECTED_NEW_PREFAB_POSITION)
Report.result(Tests.new_prefab_position, is_at_position)
actual_prefab_position = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", container_entity_id)
is_at_position = actual_prefab_position.IsClose(INSTANTIATED_PREFAB_POSITION)
Report.result(Tests.instantiated_prefab_position, is_at_position)
if not is_at_position:
Report.info(f'Expected position: {EXPECTED_NEW_PREFAB_POSITION.ToString()}, actual position: {new_prefab_position.ToString()}')
Report.info(f'Expected position: {INSTANTIATED_PREFAB_POSITION.ToString()}, actual position: {actual_prefab_position.ToString()}')
# Checks for prefab deletion passed or not
delete_prefab_result = prefab.PrefabPublicRequestBus(bus.Broadcast, 'DeleteEntitiesAndAllDescendantsInInstance', [container_entity_id])
Report.result(Tests.delete_prefab, delete_prefab_result.IsSuccess())
print_error_if_failed(delete_prefab_result)
Report.result(Tests.instantiated_prefab_removed, find_entity_by_name(INSTANTIATED_PREFAB_NAME) is None)
Report.result(Tests.instantiated_child_removed, find_entity_by_name(INSTANTIATED_CHILD_ENTITY_NAME) is None)
if __name__ == "__main__":
from editor_python_test_tools.utils import Report

@ -32,9 +32,6 @@
#include <AzToolsFramework/API/EditorLevelNotificationBus.h>
#include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h>
// CryCommon
#include <CryCommon/IAudioSystem.h>
// Editor
#include "Settings.h"
@ -60,6 +57,7 @@
#include <Atom/RPI.Public/ViewportContextBus.h>
// LmbrCentral
#include <LmbrCentral/Audio/AudioSystemComponentBus.h>
#include <LmbrCentral/Rendering/EditorLightComponentBus.h> // for LmbrCentral::EditorLightComponentRequestBus
//#define PROFILE_LOADING_WITH_VTUNE
@ -269,20 +267,7 @@ void CCryEditDoc::DeleteContents()
CErrorReportDialog::Clear();
// Unload level specific audio binary data.
Audio::SAudioManagerRequestData<Audio::eAMRT_UNLOAD_AFCM_DATA_BY_SCOPE> oAMData(Audio::eADS_LEVEL_SPECIFIC);
Audio::SAudioRequest oAudioRequestData;
oAudioRequestData.nFlags = (Audio::eARF_PRIORITY_HIGH | Audio::eARF_EXECUTE_BLOCKING);
oAudioRequestData.pData = &oAMData;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
// Now unload level specific audio config data.
Audio::SAudioManagerRequestData<Audio::eAMRT_CLEAR_CONTROLS_DATA> oAMData2(Audio::eADS_LEVEL_SPECIFIC);
oAudioRequestData.pData = &oAMData2;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
Audio::SAudioManagerRequestData<Audio::eAMRT_CLEAR_PRELOADS_DATA> oAMData3(Audio::eADS_LEVEL_SPECIFIC);
oAudioRequestData.pData = &oAMData3;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
LmbrCentral::AudioSystemComponentRequestBus::Broadcast(&LmbrCentral::AudioSystemComponentRequestBus::Events::LevelUnloadAudio);
GetIEditor()->Notify(eNotify_OnSceneClosed);
CrySystemEventBus::Broadcast(&CrySystemEventBus::Events::OnCryEditorSceneClosed);
@ -413,32 +398,11 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
#ifdef PROFILE_LOADING_WITH_VTUNE
VTResume();
#endif
// Parse level specific config data.
const char* controlsPath = nullptr;
Audio::AudioSystemRequestBus::BroadcastResult(controlsPath, &Audio::AudioSystemRequestBus::Events::GetControlsPath);
QString sAudioLevelPath(controlsPath);
sAudioLevelPath += "levels/";
AZStd::string const sLevelNameOnly = PathUtil::GetFileName(fileName.toUtf8().data());
sAudioLevelPath += sLevelNameOnly.c_str();
QByteArray path = sAudioLevelPath.toUtf8();
Audio::SAudioManagerRequestData<Audio::eAMRT_PARSE_CONTROLS_DATA> oAMData(path, Audio::eADS_LEVEL_SPECIFIC);
Audio::SAudioRequest oAudioRequestData;
oAudioRequestData.nFlags = (Audio::eARF_PRIORITY_HIGH | Audio::eARF_EXECUTE_BLOCKING); // Needs to be blocking so data is available for next preloading request!
oAudioRequestData.pData = &oAMData;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
Audio::SAudioManagerRequestData<Audio::eAMRT_PARSE_PRELOADS_DATA> oAMData2(path, Audio::eADS_LEVEL_SPECIFIC);
oAudioRequestData.pData = &oAMData2;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
Audio::TAudioPreloadRequestID nPreloadRequestID = INVALID_AUDIO_PRELOAD_REQUEST_ID;
Audio::AudioSystemRequestBus::BroadcastResult(nPreloadRequestID, &Audio::AudioSystemRequestBus::Events::GetAudioPreloadRequestID, sLevelNameOnly.c_str());
if (nPreloadRequestID != INVALID_AUDIO_PRELOAD_REQUEST_ID)
{
Audio::SAudioManagerRequestData<Audio::eAMRT_PRELOAD_SINGLE_REQUEST> oAMData3(nPreloadRequestID);
oAudioRequestData.pData = &oAMData3;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
}
// Load level-specific audio data.
AZStd::string levelFileName{ fileName.toUtf8().constData() };
AZStd::to_lower(levelFileName.begin(), levelFileName.end());
LmbrCentral::AudioSystemComponentRequestBus::Broadcast(
&LmbrCentral::AudioSystemComponentRequestBus::Events::LevelLoadAudio, AZStd::string_view{ levelFileName });
{
CAutoLogTime logtime("Game Engine level load");

@ -77,7 +77,7 @@ namespace UnitTest
class ViewportManipulatorControllerFixture : public AllocatorsTestFixture
{
public:
static const AzFramework::ViewportId TestViewportId = AzFramework::ViewportId(0);
static const AzFramework::ViewportId TestViewportId;
void SetUp() override
{
@ -108,6 +108,8 @@ namespace UnitTest
AZStd::unique_ptr<AzToolsFramework::QtEventToAzInputMapper> m_inputChannelMapper;
};
const AzFramework::ViewportId ViewportManipulatorControllerFixture::TestViewportId = AzFramework::ViewportId(0);
TEST_F(ViewportManipulatorControllerFixture, An_event_is_not_propagated_to_the_viewport_when_a_manipulator_handles_it_first)
{
// forward input events to our controller list

@ -97,6 +97,7 @@ AZ_POP_DISABLE_WARNING
#include "ActionManager.h"
#include <ImGuiBus.h>
#include <LmbrCentral/Audio/AudioSystemComponentBus.h>
using namespace AZ;
using namespace AzQtComponents;
@ -1474,25 +1475,22 @@ int MainWindow::ViewPaneVersion() const
void MainWindow::OnStopAllSounds()
{
Audio::SAudioRequest oStopAllSoundsRequest;
Audio::SAudioManagerRequestData<Audio::eAMRT_STOP_ALL_SOUNDS> oStopAllSoundsRequestData;
oStopAllSoundsRequest.pData = &oStopAllSoundsRequestData;
CryLogAlways("<Audio> Executed \"Stop All Sounds\" command.");
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequest, oStopAllSoundsRequest);
LmbrCentral::AudioSystemComponentRequestBus::Broadcast(&LmbrCentral::AudioSystemComponentRequestBus::Events::GlobalStopAllSounds);
}
void MainWindow::OnRefreshAudioSystem()
{
QString sLevelName = GetIEditor()->GetGameEngine()->GetLevelName();
AZStd::string levelName;
AzToolsFramework::EditorRequestBus::BroadcastResult(levelName, &AzToolsFramework::EditorRequestBus::Events::GetLevelName);
AZStd::to_lower(levelName.begin(), levelName.end());
if (QString::compare(sLevelName, "Untitled", Qt::CaseInsensitive) == 0)
if (levelName == "untitled")
{
// Rather pass nullptr to indicate that no level is loaded!
sLevelName = QString();
levelName.clear();
}
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::RefreshAudioSystem, sLevelName.toUtf8().data());
LmbrCentral::AudioSystemComponentRequestBus::Broadcast(
&LmbrCentral::AudioSystemComponentRequestBus::Events::GlobalRefreshAudio, AZStd::string_view{ levelName });
}
void MainWindow::SaveLayout()

@ -43,6 +43,8 @@
#include <AzCore/Casting/numeric_cast.h>
#include <AzToolsFramework/Viewport/ViewportMessages.h>
#include <LmbrCentral/Audio/AudioSystemComponentBus.h>
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include "ui_ViewportTitleDlg.h"
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
@ -119,17 +121,20 @@ CViewportTitleDlg::CViewportTitleDlg(QWidget* pParent)
LoadCustomPresets("AspectRatioPresets", "AspectRatioPreset", m_customAspectRatioPresets);
LoadCustomPresets("ResPresets", "ResPreset", m_customResPresets);
// audio request setup
m_oMuteAudioRequest.pData = &m_oMuteAudioRequestData;
m_oUnmuteAudioRequest.pData = &m_oUnmuteAudioRequestData;
SetupCameraDropdownMenu();
SetupResolutionDropdownMenu();
SetupViewportInformationMenu();
SetupHelpersButton();
SetupOverflowMenu();
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequest, gSettings.bMuteAudio ? m_oMuteAudioRequest : m_oUnmuteAudioRequest);
if (gSettings.bMuteAudio)
{
LmbrCentral::AudioSystemComponentRequestBus::Broadcast(&LmbrCentral::AudioSystemComponentRequestBus::Events::GlobalMuteAudio);
}
else
{
LmbrCentral::AudioSystemComponentRequestBus::Broadcast(&LmbrCentral::AudioSystemComponentRequestBus::Events::GlobalUnmuteAudio);
}
connect(this, &CViewportTitleDlg::ActionTriggered, MainWindow::instance()->GetActionManager(), &ActionManager::ActionTriggered);
@ -877,24 +882,32 @@ void CViewportTitleDlg::OnBnClickedGotoPosition()
void CViewportTitleDlg::OnBnClickedMuteAudio()
{
gSettings.bMuteAudio = !gSettings.bMuteAudio;
Audio::AudioSystemRequestBus::Broadcast(
&Audio::AudioSystemRequestBus::Events::PushRequest, gSettings.bMuteAudio ? m_oMuteAudioRequest : m_oUnmuteAudioRequest);
if (gSettings.bMuteAudio)
{
LmbrCentral::AudioSystemComponentRequestBus::Broadcast(&LmbrCentral::AudioSystemComponentRequestBus::Events::GlobalMuteAudio);
}
else
{
LmbrCentral::AudioSystemComponentRequestBus::Broadcast(&LmbrCentral::AudioSystemComponentRequestBus::Events::GlobalUnmuteAudio);
}
UpdateMuteActionText();
}
void CViewportTitleDlg::UpdateMuteActionText()
{
if (!Audio::AudioSystemRequestBus::HasHandlers())
bool audioSystemConnected = false;
LmbrCentral::AudioSystemComponentRequestBus::BroadcastResult(
audioSystemConnected, &LmbrCentral::AudioSystemComponentRequestBus::Events::IsAudioSystemInitialized);
if (audioSystemConnected)
{
m_audioMuteAction->setEnabled(false);
m_audioMuteAction->setText(tr("Mute Audio: Enable Audio Gem"));
m_audioMuteAction->setEnabled(true);
m_audioMuteAction->setText(gSettings.bMuteAudio ? tr("Un-mute Audio") : tr("Mute Audio"));
}
else
{
m_audioMuteAction->setEnabled(true);
m_audioMuteAction->setText(gSettings.bMuteAudio ? tr("Un-mute Audio") : tr("Mute Audio"));
m_audioMuteAction->setEnabled(false);
m_audioMuteAction->setText(tr("Mute Audio: Enable Audio Gem"));
}
}

@ -14,8 +14,6 @@
#if !defined(Q_MOC_RUN)
#include <AzCore/Component/Component.h>
#include <IAudioSystem.h>
#include <functional>
#include <QSharedPointer>
#include <QWidgetAction>
@ -178,12 +176,6 @@ protected:
QWidgetAction* m_gridSizeActionWidget = nullptr;
QWidgetAction* m_angleSizeActionWidget = nullptr;
Audio::SAudioRequest m_oMuteAudioRequest;
Audio::SAudioManagerRequestData<Audio::eAMRT_MUTE_ALL> m_oMuteAudioRequestData;
Audio::SAudioRequest m_oUnmuteAudioRequest;
Audio::SAudioManagerRequestData<Audio::eAMRT_UNMUTE_ALL> m_oUnmuteAudioRequestData;
QScopedPointer<Ui::ViewportTitleDlg> m_ui;
};

@ -366,7 +366,7 @@ bool SpinBoxWatcher::filterSpinBoxEvents(QAbstractSpinBox* spinBox, QEvent* even
{
// To prevent the event being turned into a focus event, be sure to install an
// AzQtComponents::GlobalEventFilter on your QApplication instance.
event->ignore();
event->accept();
return true;
}

@ -15,6 +15,7 @@
#include <AzToolsFramework/Prefab/Instance/InstanceEntityMapperInterface.h>
#include <AzToolsFramework/Prefab/PrefabLoaderInterface.h>
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
#include <Prefab/PrefabDomUtils.h>
namespace AzToolsFramework
{
@ -81,6 +82,15 @@ namespace AzToolsFramework
result.Combine(resultInstances);
}
PrefabDomUtils::LinkIdMetadata* subPathLinkId = context.GetMetadata().Find<PrefabDomUtils::LinkIdMetadata>();
if (subPathLinkId)
{
AZ::ScopedContextPath subPathSource(context, "m_linkId");
result = ContinueStoringToJsonObjectField(
outputValue, "LinkId", &(instance->m_linkId), &InvalidLinkId, azrtti_typeid<decltype(instance->m_linkId)>(), context);
}
return context.Report(result,
result.GetProcessing() == JSR::Processing::Completed ? "Successfully stored Instance information for Prefab." :
"Failed to store Instance information for Prefab.");

@ -88,6 +88,11 @@ namespace AzToolsFramework
settings.m_keepDefaults = true;
}
if ((flags & StoreFlags::StoreLinkIds) != StoreFlags::None)
{
settings.m_metadata.Create<LinkIdMetadata>();
}
AZStd::string scratchBuffer;
auto issueReportingCallback = [&scratchBuffer]
(AZStd::string_view message, AZ::JsonSerializationResult::ResultCode result,

@ -45,7 +45,11 @@ namespace AzToolsFramework
//! By default an instance will be stored with default values. In cases where we want to store less json without defaults
//! such as saving to disk, this flag will control that behavior.
StripDefaultValues = 1 << 0
StripDefaultValues = 1 << 0,
//! We do not save linkIds to file. However when loading a level we want to temporarily save
//! linkIds to instance dom so any nested prefabs will have linkIds correctly set.
StoreLinkIds = 1 << 1
};
AZ_DEFINE_ENUM_BITWISE_OPERATORS(StoreFlags);
@ -150,6 +154,14 @@ namespace AzToolsFramework
[[maybe_unused]] const AZStd::string_view printMessage,
[[maybe_unused]] const AzToolsFramework::Prefab::PrefabDomValue& prefabDomValue);
//! An empty struct for passing to JsonSerializerSettings.m_metadata that is consumed by InstanceSerializer::Store.
//! If present in metadata, linkIds will be stored to instance dom.
struct LinkIdMetadata
{
AZ_RTTI(LinkIdMetadata, "{8FF7D299-14E3-41D4-90C5-393A240FAE7C}");
virtual ~LinkIdMetadata() {}
};
} // namespace PrefabDomUtils
} // namespace Prefab
} // namespace AzToolsFramework

@ -300,7 +300,7 @@ namespace AzToolsFramework
}
PrefabDom storedPrefabDom(&loadedTemplateDom->get().GetAllocator());
if (!PrefabDomUtils::StoreInstanceInPrefabDom(loadedPrefabInstance, storedPrefabDom))
if (!PrefabDomUtils::StoreInstanceInPrefabDom(loadedPrefabInstance, storedPrefabDom, PrefabDomUtils::StoreFlags::StoreLinkIds))
{
return false;
}

@ -61,7 +61,7 @@ namespace AzToolsFramework
m_prefabUndoCache.Destroy();
}
PrefabOperationResult PrefabPublicHandler::CreatePrefabInMemory(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath)
PrefabOperationResult PrefabPublicHandler::CreatePrefabInMemory(const EntityIdList& entityIds, AZ::IO::PathView filePath)
{
EntityList inputEntityList, topLevelEntities;
AZ::EntityId commonRootEntityId;
@ -264,7 +264,7 @@ namespace AzToolsFramework
return AZ::Success();
}
PrefabOperationResult PrefabPublicHandler::CreatePrefabInDisk(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath)
PrefabOperationResult PrefabPublicHandler::CreatePrefabInDisk(const EntityIdList& entityIds, AZ::IO::PathView filePath)
{
auto result = CreatePrefabInMemory(entityIds, filePath);
if (result.IsSuccess())

@ -43,9 +43,9 @@ namespace AzToolsFramework
// PrefabPublicInterface...
PrefabOperationResult CreatePrefabInDisk(
const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath) override;
const EntityIdList& entityIds, AZ::IO::PathView filePath) override;
PrefabOperationResult CreatePrefabInMemory(
const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath) override;
const EntityIdList& entityIds, AZ::IO::PathView filePath) override;
InstantiatePrefabResult InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position) override;
PrefabOperationResult SavePrefab(AZ::IO::Path filePath) override;
PrefabEntityResult CreateEntity(AZ::EntityId parentId, const AZ::Vector3& position) override;

@ -47,7 +47,7 @@ namespace AzToolsFramework
* @return An outcome object; on failure, it comes with an error message detailing the cause of the error.
*/
virtual PrefabOperationResult CreatePrefabInDisk(
const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath) = 0;
const EntityIdList& entityIds, AZ::IO::PathView filePath) = 0;
/**
* Create a prefab out of the entities provided, at the path provided, and keep it in memory.
@ -57,7 +57,7 @@ namespace AzToolsFramework
* @return An outcome object; on failure, it comes with an error message detailing the cause of the error.
*/
virtual PrefabOperationResult CreatePrefabInMemory(
const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath) = 0;
const EntityIdList& entityIds, AZ::IO::PathView filePath) = 0;
/**
* Instantiate a prefab from a prefab file.

@ -11,13 +11,20 @@
#include <AzCore/Component/EntityId.h>
#include <AzCore/EBus/EBus.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/Outcome/Outcome.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/string/string_view.h>
namespace AzToolsFramework
{
using EntityIdList = AZStd::vector<AZ::EntityId>;
namespace Prefab
{
using PrefabOperationResult = AZ::Outcome<void, AZStd::string>;
using InstantiatePrefabResult = AZ::Outcome<AZ::EntityId, AZStd::string>;
/**
* The primary purpose of this bus is to facilitate writing automated tests for prefabs.
* It calls PrefabPublicInterface internally to talk to the prefab system.
@ -40,14 +47,25 @@ namespace AzToolsFramework
/**
* Create a prefab out of the entities provided, at the path provided, and keep it in memory.
* Automatically detects descendants of entities, and discerns between entities and child instances.
* Return whether the creation succeeded or not.
*/
virtual bool CreatePrefabInMemory(
const AZStd::vector<AZ::EntityId>& entityIds, AZStd::string_view filePath) = 0;
virtual PrefabOperationResult CreatePrefabInMemory(
const EntityIdList& entityIds, AZStd::string_view filePath) = 0;
/**
* Instantiate a prefab from a prefab file.
* Return the container entity id of the prefab instantiated if instantiation succeeded.
*/
virtual InstantiatePrefabResult InstantiatePrefab(
AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position) = 0;
/**
* Deletes all entities and their descendants from the owning instance. Bails if the entities don't
* all belong to the same instance.
* Return whether the deletion succeeded or not.
*/
virtual AZ::EntityId InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position) = 0;
virtual PrefabOperationResult DeleteEntitiesAndAllDescendantsInInstance(const EntityIdList& entityIds) = 0;
};
using PrefabPublicRequestBus = AZ::EBus<PrefabPublicRequests>;

@ -25,6 +25,7 @@ namespace AzToolsFramework
->Attribute(AZ::Script::Attributes::Module, "prefab")
->Event("CreatePrefabInMemory", &PrefabPublicRequests::CreatePrefabInMemory)
->Event("InstantiatePrefab", &PrefabPublicRequests::InstantiatePrefab)
->Event("DeleteEntitiesAndAllDescendantsInInstance", &PrefabPublicRequests::DeleteEntitiesAndAllDescendantsInInstance)
;
}
}
@ -44,36 +45,20 @@ namespace AzToolsFramework
m_prefabPublicInterface = nullptr;
}
bool PrefabPublicRequestHandler::CreatePrefabInMemory(const AZStd::vector<AZ::EntityId>& entityIds, AZStd::string_view filePath)
PrefabOperationResult PrefabPublicRequestHandler::CreatePrefabInMemory(const EntityIdList& entityIds, AZStd::string_view filePath)
{
auto createPrefabOutcome = m_prefabPublicInterface->CreatePrefabInMemory(entityIds, filePath);
if (!createPrefabOutcome.IsSuccess())
{
AZ_Error("CreatePrefabInMemory", false,
"Failed to create Prefab on file path '%.*s'. Error message: %s.",
AZ_STRING_ARG(filePath),
createPrefabOutcome.GetError().c_str());
return false;
}
return true;
return m_prefabPublicInterface->CreatePrefabInMemory(entityIds, filePath);
}
AZ::EntityId PrefabPublicRequestHandler::InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position)
InstantiatePrefabResult PrefabPublicRequestHandler::InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position)
{
auto instantiatePrefabOutcome = m_prefabPublicInterface->InstantiatePrefab(filePath, parent, position);
if (!instantiatePrefabOutcome.IsSuccess())
{
AZ_Error("InstantiatePrefab", false,
"Failed to instantiate Prefab on file path '%.*s'. Error message: %s.",
AZ_STRING_ARG(filePath),
instantiatePrefabOutcome.GetError().c_str());
return AZ::EntityId();
}
return m_prefabPublicInterface->InstantiatePrefab(filePath, parent, position);
}
return instantiatePrefabOutcome.GetValue();
PrefabOperationResult PrefabPublicRequestHandler::DeleteEntitiesAndAllDescendantsInInstance(const EntityIdList& entityIds)
{
return m_prefabPublicInterface->DeleteEntitiesAndAllDescendantsInInstance(entityIds);
}
} // namespace Prefab
} // namespace AzToolsFramework

@ -31,8 +31,9 @@ namespace AzToolsFramework
void Connect();
void Disconnect();
bool CreatePrefabInMemory(const AZStd::vector<AZ::EntityId>& entityIds, AZStd::string_view filePath) override;
AZ::EntityId InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position) override;
PrefabOperationResult CreatePrefabInMemory(const EntityIdList& entityIds, AZStd::string_view filePath) override;
InstantiatePrefabResult InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, const AZ::Vector3& position) override;
PrefabOperationResult DeleteEntitiesAndAllDescendantsInInstance(const EntityIdList& entityIds) override;
private:
PrefabPublicInterface* m_prefabPublicInterface = nullptr;

@ -15,6 +15,5 @@ add_subdirectory(AzTest)
add_subdirectory(AzToolsFramework)
add_subdirectory(AzManipulatorTestFramework)
add_subdirectory(AzNetworking)
add_subdirectory(Crcfix)
add_subdirectory(GFxFramework)
add_subdirectory(GridMate)

@ -1,32 +0,0 @@
#
# 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
#
#
if (NOT PAL_TRAIT_BUILD_HOST_TOOLS)
return()
endif()
include(Platform/${PAL_PLATFORM_NAME}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
if (NOT PAL_TRAIT_BUILD_CRCFIX)
return()
endif()
ly_add_target(
NAME Crcfix EXECUTABLE
NAMESPACE AZ
FILES_CMAKE
crcfix_files.cmake
BUILD_DEPENDENCIES
PRIVATE
AZ::AzCore
)
ly_add_source_properties(
SOURCES crcfix.cpp
PROPERTY COMPILE_DEFINITIONS
VALUES _CRT_SECURE_NO_WARNINGS
)

@ -1,9 +0,0 @@
#
# 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
#
#
set(PAL_TRAIT_BUILD_CRCFIX FALSE)

@ -1,9 +0,0 @@
#
# 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
#
#
set(PAL_TRAIT_BUILD_CRCFIX FALSE)

@ -1,9 +0,0 @@
#
# 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
#
#
set(PAL_TRAIT_BUILD_CRCFIX TRUE)

@ -1,538 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/PlatformIncl.h>
#include <AzCore/Math/Crc.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Memory/AllocationRecords.h>
#include <AzCore/std/chrono/chrono.h>
#include <AzCore/std/string/conversions.h>
#include <AzCore/Utils/Utils.h>
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <sys/stat.h>
int g_totalFixTimeMs = 0;
int g_longestFixTimeMs = 0;
class Filename
{
wchar_t fullpath[MAX_PATH];
wchar_t drive[_MAX_DRIVE];
wchar_t dir[_MAX_DIR];
wchar_t fname[_MAX_FNAME];
wchar_t ext[_MAX_EXT];
public:
Filename()
{
fullpath[0] = drive[0] = dir[0] = fname[0] = ext[0] = 0;
}
Filename(const AZStd::wstring& filename)
{
_wsplitpath(filename.c_str(), drive, dir, fname, ext);
wcscpy(fullpath, filename.c_str());
}
void SetExt(const wchar_t* pExt) { wcscpy(ext, pExt); _wmakepath(fullpath, drive, dir, fname, pExt); }
const wchar_t* GetFullPath() const { return fullpath; }
bool Exists() const { return _waccess(fullpath, 0) == 0; }
bool IsReadOnly() const { return _waccess(fullpath, 6) == -1; }
bool SetReadOnly() const { return _wchmod(fullpath, _S_IREAD) == 0; }
bool SetWritable() const { return _wchmod(fullpath, _S_IREAD | _S_IWRITE) == 0; }
bool Delete() const { return _wremove(fullpath) == 0; }
bool Rename(const wchar_t* fn2) const{ return MoveFileEx(fullpath, fn2, MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING) == 0; }
bool Copy(const wchar_t* dest) const { return ::CopyFile(fullpath, dest, FALSE) == TRUE; }
};
class CRCfix
{
int lastchar;
int linenum;
public:
void SkipToEOL(FILE* infile);
char* GetToken(FILE* infile, FILE* outfile);
void GetPreviousCRC(char* token, FILE* infile);
int Fix(Filename srce);
};
void FixFiles(const AZStd::wstring& dir, const AZStd::wstring& files, FILETIME* pLastRun, bool verbose, int& nFound, int& nProcessed, int& nFixed, int& nFailed)
{
CRCfix fixer;
WIN32_FIND_DATA wfd;
HANDLE hFind;
hFind = FindFirstFile((dir + files).c_str(), &wfd);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
{
if (verbose)
{
AZ_TracePrintf("CrcFix", "\tProcessing %ls ...", wfd.cFileName);
}
nFound++;
int n = 0;
if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0 && (!pLastRun || CompareFileTime(pLastRun, &wfd.ftLastWriteTime) <= 0))
{
n = fixer.Fix(Filename(dir + L"\\" + wfd.cFileName));
nProcessed++;
}
if (n < 0)
{
nFailed++;
if (verbose)
{
AZ_TracePrintf("CrcFix", "Failed\n");
}
}
else
{
if (verbose)
{
AZ_TracePrintf("CrcFix", n > 0 ? "Done\n" : (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) != 0 ? "ReadOnly\n" : "Unchanged\n");
}
nFixed += n;
}
}
} while (FindNextFile(hFind, &wfd));
}
FindClose(hFind);
}
void FixDirectories(const AZStd::wstring& dirs, const AZStd::wstring& files, FILETIME* pLastRun, bool verbose, int& nFound, int& nProcessed, int& nFixed, int& nFailed)
{
if (verbose)
{
AZ_TracePrintf("CrcFix", "Processing %ls ...\n", dirs.c_str());
}
// do files
FixFiles(dirs, files, pLastRun, verbose, nFound, nProcessed, nFixed, nFailed);
// do folders
WIN32_FIND_DATA wfd;
HANDLE hFind;
hFind = FindFirstFile((dirs + L"\\*").c_str(), &wfd);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
{
if (wfd.cFileName[0] == '.')
{
continue;
}
FixDirectories(AZStd::wstring(dirs + L"\\" + wfd.cFileName), files, pLastRun, verbose, nFound, nProcessed, nFixed, nFailed);
}
} while (FindNextFile(hFind, &wfd));
}
FindClose(hFind);
}
int main(int argc, char* argv[])
{
AZStd::chrono::system_clock::time_point startTime = AZStd::chrono::system_clock::now();
AZ::SystemAllocator::Descriptor desc;
//desc.m_stackRecordLevels = 15;
AZ::AllocatorInstance<AZ::SystemAllocator>::Create(desc);
//if (AZ::AllocatorInstance<AZ::SystemAllocator>::Get().GetRecords()) {
// AZ::AllocatorInstance<AZ::SystemAllocator>::Get().GetRecords()->SetMode(AZ::Debug::AllocationRecords::RECORD_FULL);
//}
{
if (argc < 2)
{
AZ_TracePrintf("CrcFix", "Usage:\n crcfix [-v(erbose)] [-log:logfile] {path[\\*][\\*.*]}\n");
AZ_TracePrintf("CrcFix", "\n Ex:\n crcfix -v -log:timestamp.log src\\*\\*.cpp src\\*\\*.h ..\\scripts\\*.*\n\n");
}
char root[MAX_PATH];
AZ::Utils::GetExecutableDirectory(root, MAX_PATH);
AZStd::vector<AZStd::wstring> entries;
AZStd::wstring logfilename;
FILETIME lastRun;
FILETIME* pLastRun = NULL;
bool verbose = false;
for (int iArg = 1; iArg < argc; ++iArg)
{
const char* pArg = argv[iArg];
if (!pArg)
{
continue;
}
AZStd::wstring pArgW;
AZStd::to_wstring(pArgW, pArg);
if (_strnicmp(pArg, "-log:", 5) == 0)
{
logfilename.assign(pArgW.begin() + 5, pArgW.end());
HANDLE hFile = CreateFile(logfilename.data(), 0, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
pLastRun = &lastRun;
GetFileTime(hFile, NULL, NULL, pLastRun);
CloseHandle(hFile);
}
}
else if (_stricmp(pArg, "-v") == 0)
{
verbose = true;
}
else
{
entries.emplace_back(AZStd::move(pArgW));
}
}
// for each entry from the command line...
int nFound = 0;
int nProcessed = 0;
int nFixed = 0;
int nFailed = 0;
for (AZStd::vector<AZStd::wstring>::const_iterator iEntry = entries.begin(); iEntry != entries.end(); ++iEntry)
{
AZStd::wstring entry = (iEntry->at(0) == L'\\' || iEntry->find(L":") != iEntry->npos) ? *iEntry : AZStd::wstring(root) + L"\\" + *iEntry;
AZStd::wstring::size_type split = entry.find(L"*\\");
bool doSubdirs = split != entry.npos;
if (doSubdirs)
{
FixDirectories(entry.substr(0, split), entry.substr(split + 1), pLastRun, verbose, nFound, nProcessed, nFixed, nFailed);
}
else
{
split = entry.rfind(L"\\");
if (split == entry.npos)
{
split = 0;
}
FixFiles(entry.substr(0, split), entry.substr(split), pLastRun, verbose, nFound, nProcessed, nFixed, nFailed);
}
}
// update timestamp
if (!logfilename.empty())
{
HANDLE hFile = CreateFile(logfilename.data(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
GetSystemTimeAsFileTime(&lastRun);
SetFileTime(hFile, NULL, NULL, &lastRun);
char log[1024];
DWORD oCount;
sprintf(log, "Batches processed: %zu\n\tFiles found: %d\n\tFiles processed: %d\n\tFiles fixed: %d\n\tFiles failed: %d\n", entries.size(), nFound, nProcessed, nFixed, nFailed);
WriteFile(hFile, log, static_cast<DWORD>(strlen(log)), &oCount, NULL);
AZStd::chrono::system_clock::time_point endTime = AZStd::chrono::system_clock::now();
sprintf(log, "Total running time: %.2f secs.\n\tTotal processing time: %.2f secs.\n\tLongest processing time: %.2f secs.\n", (float)AZStd::chrono::milliseconds(endTime - startTime).count() / 1000.f, (float)g_totalFixTimeMs / 1000.f, (float)g_longestFixTimeMs / 1000.f);
WriteFile(hFile, log, static_cast<DWORD>(strlen(log)), &oCount, NULL);
CloseHandle(hFile);
}
}
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
return 0;
}
//-----------------------------------------------------------------------------
// CRCfix
//-----------------------------------------------------------------------------
void CRCfix::SkipToEOL(FILE* infile)
{
int c;
for (c = lastchar; c != EOF && c != '\n'; c = fgetc(infile))
{
;
}
lastchar = fgetc(infile);
linenum++;
}
//-----------------------------------------------------------------------------
char* CRCfix::GetToken(FILE* infile, FILE* outfile)
{
static char token[512];
bool commentline = false;
bool commentblock = false;
bool doublequote = false;
bool singlequote = false;
int i = 0;
int c;
if (lastchar == EOF)
{
return NULL;
}
for (c = lastchar; c != EOF; c = fgetc(infile))
{
if (!commentline && !commentblock && !doublequote && !singlequote)
{
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '#' || c == '_')
{
token[i++] = static_cast<char>(c);
continue;
}
else
{
if (i)
{
lastchar = c;
token[i] = 0;
i = 0;
return token;
}
}
}
if (commentline)
{
if (c == '\n')
{
commentline = false;
}
}
else if (commentblock)
{
while (c == '*')
{
c = fgetc(infile);
if (c == '/')
{
commentblock = false;
}
fputc('*', outfile);
}
}
if (!commentline && !commentblock)
{
if (c == '"' && !singlequote)
{
doublequote = !doublequote;
}
else if (c == '\'' && !doublequote)
{
singlequote = !singlequote;
}
else if (!singlequote && !doublequote)
{
if (c == '/')
{
c = fgetc(infile);
if (c == '/')
{
commentline = true;
}
else if (c == '*')
{
commentblock = true;
}
if (c == '\'')
{
singlequote = true;
}
else if (c == '"')
{
doublequote = true;
}
fputc('/', outfile);
}
}
else if (c == '\\')
{
fputc(c, outfile);
c = fgetc(infile);
}
}
fputc(c, outfile);
if (c == '\n')
{
linenum++;
}
}
lastchar = c;
token[i] = 0;
return i ? token : NULL;
}
//-----------------------------------------------------------------------------
void CRCfix::GetPreviousCRC(char* token, FILE* infile)
{
int c;
while ((c = fgetc(infile)) != ')')
{
*token++ = static_cast<char>(c);
}
*token = 0;
}
//-----------------------------------------------------------------------------
int CRCfix::Fix(Filename srce)
{
AZStd::chrono::system_clock::time_point startTime = AZStd::chrono::system_clock::now();
bool changed = false;
Filename dest(srce);
dest.SetExt(L"xxx");
linenum = 0;
FILE* infile = _wfopen(srce.GetFullPath(), L"r");
FILE* outfile = _wfopen(dest.GetFullPath(), L"w");
if (!infile || !outfile)
{
if (infile)
{
fclose(infile);
infile = nullptr;
}
if (outfile)
{
fclose(outfile);
outfile = nullptr;
}
int dt = static_cast<int>(AZStd::chrono::milliseconds(AZStd::chrono::system_clock::now() - startTime).count());
g_totalFixTimeMs += dt;
if (dt > g_longestFixTimeMs)
{
g_longestFixTimeMs = dt;
}
return -1;
}
lastchar = fgetc(infile);
while (char* token = GetToken(infile, outfile))
{
bool got = false;
if (strcmp(token, "AZ_CRC") == 0 && lastchar == '(')
{
size_t i = strlen(token);
token[i++] = static_cast<char>(lastchar);
int c = fgetc(infile);
if (c == '"')
{
size_t j = i + 1;
do
{
token[i++] = static_cast<char>(c);
c = fgetc(infile);
} while (c != '"');
token[i++] = static_cast<char>(c);
c = fgetc(infile);
int oldcrc = 0, newcrc;
if (c == ',')
{
GetPreviousCRC(token + i, infile);
sscanf(token + i, "%i", &oldcrc);
c = ')';
}
if (c == ')')
{
token[i] = 0;
c = fgetc(infile);
got = true;
newcrc = AZ::Crc32(token + j, i - j - 1, true);
fprintf(outfile, "%s, 0x%08x)", token, newcrc);
if (newcrc != oldcrc)
{
changed = true;
}
}
}
lastchar = c;
token[i] = 0;
}
if (!got)
{
fwrite(token, 1, strlen(token), outfile);
}
}
fclose(infile);
fclose(outfile);
if (changed)
{
Filename backup(srce);
backup.SetExt(L"crcfix_old");
if (backup.Exists())
{
backup.SetWritable();
[[maybe_unused]] bool deleted = backup.Delete();
AZ_Assert(deleted, "failed to delete");
}
if (!srce.Copy(backup.GetFullPath()))
{
AZ_TracePrintf("CrcFix", "Failed to copy %ls to %ls\n", srce, backup);
int dt = static_cast<int>(AZStd::chrono::milliseconds(AZStd::chrono::system_clock::now() - startTime).count());
g_totalFixTimeMs += dt;
if (dt > g_longestFixTimeMs)
{
g_longestFixTimeMs = dt;
}
return -1;
}
if (!dest.Rename(srce.GetFullPath()))
{
AZ_TracePrintf("CrcFix", "Failed to rename %ls to %ls\n", dest, srce);
int dt = static_cast<int>(AZStd::chrono::milliseconds(AZStd::chrono::system_clock::now() - startTime).count());
g_totalFixTimeMs += dt;
if (dt > g_longestFixTimeMs)
{
g_longestFixTimeMs = dt;
}
return -1;
}
if (!backup.Delete())
{
AZ_TracePrintf("CrcFix", "Failed to delete %ls\n", backup);
}
}
else
{
dest.Delete();
}
int dt = static_cast<int>(AZStd::chrono::milliseconds(AZStd::chrono::system_clock::now() - startTime).count());
g_totalFixTimeMs += dt;
if (dt > g_longestFixTimeMs)
{
g_longestFixTimeMs = dt;
}
return changed ? 1 : 0;
}
//-----------------------------------------------------------------------------

@ -1,11 +0,0 @@
#
# 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
#
#
set(FILES crcfix_files.cmake
crcfix.cpp
)

@ -246,7 +246,6 @@ struct IView
virtual void SetScale(const float scale) = 0;
virtual void SetZoomedScale(const float scale) = 0;
virtual void SetActive(const bool bActive) = 0;
virtual void UpdateAudioListener(const Matrix34& rMatrix) = 0;
};
struct IViewSystemListener
@ -295,8 +294,6 @@ struct IViewSystem
virtual bool IsPlayingCutScene() const = 0;
virtual void UpdateSoundListeners() = 0;
virtual void SetDeferredViewSystemUpdate(bool const bDeferred) = 0;
virtual bool UseDeferredViewSystemUpdate() const = 0;
virtual void SetControlAudioListeners(bool const bActive) = 0;

@ -11,7 +11,6 @@
#include "CrySystem_precompiled.h"
#include "LevelSystem.h"
#include <IAudioSystem.h>
#include "IMovieSystem.h"
#include <ILocalizationManager.h>
#include "CryPath.h"
@ -630,41 +629,6 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName)
pSpamDelay->Set(0.0f);
}
// Parse level specific config data.
AZStd::string const sLevelNameOnly(PathUtil::GetFileName(levelName));
if (!sLevelNameOnly.empty())
{
const char* controlsPath = nullptr;
Audio::AudioSystemRequestBus::BroadcastResult(controlsPath, &Audio::AudioSystemRequestBus::Events::GetControlsPath);
if (controlsPath)
{
AZStd::string sAudioLevelPath(controlsPath);
sAudioLevelPath.append("levels/");
sAudioLevelPath += sLevelNameOnly;
Audio::SAudioManagerRequestData<Audio::eAMRT_PARSE_CONTROLS_DATA> oAMData(sAudioLevelPath.c_str(), Audio::eADS_LEVEL_SPECIFIC);
Audio::SAudioRequest oAudioRequestData;
oAudioRequestData.nFlags = (Audio::eARF_PRIORITY_HIGH | Audio::eARF_EXECUTE_BLOCKING); // Needs to be blocking so data is available for next preloading request!
oAudioRequestData.pData = &oAMData;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
Audio::SAudioManagerRequestData<Audio::eAMRT_PARSE_PRELOADS_DATA> oAMData2(sAudioLevelPath.c_str(), Audio::eADS_LEVEL_SPECIFIC);
oAudioRequestData.pData = &oAMData2;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
Audio::TAudioPreloadRequestID nPreloadRequestID = INVALID_AUDIO_PRELOAD_REQUEST_ID;
Audio::AudioSystemRequestBus::BroadcastResult(nPreloadRequestID, &Audio::AudioSystemRequestBus::Events::GetAudioPreloadRequestID, sLevelNameOnly.c_str());
if (nPreloadRequestID != INVALID_AUDIO_PRELOAD_REQUEST_ID)
{
Audio::SAudioManagerRequestData<Audio::eAMRT_PRELOAD_SINGLE_REQUEST> requestData(nPreloadRequestID, true);
oAudioRequestData.pData = &requestData;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
}
}
}
{
AZStd::string missionXml("Mission_");
missionXml += pLevelInfo->m_defaultGameTypeName;
@ -926,22 +890,6 @@ void CLevelSystem::UnloadLevel()
gEnv->pMovieSystem->RemoveAllSequences();
}
// Unload level specific audio binary data.
Audio::SAudioManagerRequestData<Audio::eAMRT_UNLOAD_AFCM_DATA_BY_SCOPE> oAMData(Audio::eADS_LEVEL_SPECIFIC);
Audio::SAudioRequest oAudioRequestData;
oAudioRequestData.nFlags = (Audio::eARF_PRIORITY_HIGH | Audio::eARF_EXECUTE_BLOCKING);
oAudioRequestData.pData = &oAMData;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
// Now unload level specific audio config data.
Audio::SAudioManagerRequestData<Audio::eAMRT_CLEAR_CONTROLS_DATA> oAMData2(Audio::eADS_LEVEL_SPECIFIC);
oAudioRequestData.pData = &oAMData2;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
Audio::SAudioManagerRequestData<Audio::eAMRT_CLEAR_PRELOADS_DATA> oAMData3(Audio::eADS_LEVEL_SPECIFIC);
oAudioRequestData.pData = &oAMData3;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
OnUnloadComplete(m_lastLevelName.c_str());
// -- kenzo: this will close all pack files for this level

@ -8,7 +8,6 @@
#include "CrySystem_precompiled.h"
#include "SpawnableLevelSystem.h"
#include <IAudioSystem.h>
#include "IMovieSystem.h"
#include <LoadScreenBus.h>
@ -280,47 +279,6 @@ namespace LegacyLevelSystem
pSpamDelay->Set(0.0f);
}
// Parse level specific config data.
AZStd::string const sLevelNameOnly(PathUtil::GetFileName(levelName));
if (!sLevelNameOnly.empty())
{
const char* controlsPath = nullptr;
Audio::AudioSystemRequestBus::BroadcastResult(controlsPath, &Audio::AudioSystemRequestBus::Events::GetControlsPath);
if (controlsPath)
{
AZStd::string sAudioLevelPath(controlsPath);
sAudioLevelPath.append("levels/");
sAudioLevelPath += sLevelNameOnly;
Audio::SAudioManagerRequestData<Audio::eAMRT_PARSE_CONTROLS_DATA> oAMData(
sAudioLevelPath.c_str(), Audio::eADS_LEVEL_SPECIFIC);
Audio::SAudioRequest oAudioRequestData;
oAudioRequestData.nFlags =
(Audio::eARF_PRIORITY_HIGH |
Audio::eARF_EXECUTE_BLOCKING); // Needs to be blocking so data is available for next preloading request!
oAudioRequestData.pData = &oAMData;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
Audio::SAudioManagerRequestData<Audio::eAMRT_PARSE_PRELOADS_DATA> oAMData2(
sAudioLevelPath.c_str(), Audio::eADS_LEVEL_SPECIFIC);
oAudioRequestData.pData = &oAMData2;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
Audio::TAudioPreloadRequestID nPreloadRequestID = INVALID_AUDIO_PRELOAD_REQUEST_ID;
Audio::AudioSystemRequestBus::BroadcastResult(
nPreloadRequestID, &Audio::AudioSystemRequestBus::Events::GetAudioPreloadRequestID, sLevelNameOnly.c_str());
if (nPreloadRequestID != INVALID_AUDIO_PRELOAD_REQUEST_ID)
{
Audio::SAudioManagerRequestData<Audio::eAMRT_PRELOAD_SINGLE_REQUEST> requestData(nPreloadRequestID, true);
oAudioRequestData.pData = &requestData;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
}
}
}
AZ::Data::Asset<AzFramework::Spawnable> rootSpawnable(
rootSpawnableAssetId, azrtti_typeid<AzFramework::Spawnable>(), levelName);
@ -565,22 +523,6 @@ namespace LegacyLevelSystem
gEnv->pMovieSystem->RemoveAllSequences();
}
// Unload level specific audio binary data.
Audio::SAudioManagerRequestData<Audio::eAMRT_UNLOAD_AFCM_DATA_BY_SCOPE> oAMData(Audio::eADS_LEVEL_SPECIFIC);
Audio::SAudioRequest oAudioRequestData;
oAudioRequestData.nFlags = (Audio::eARF_PRIORITY_HIGH | Audio::eARF_EXECUTE_BLOCKING);
oAudioRequestData.pData = &oAMData;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
// Now unload level specific audio config data.
Audio::SAudioManagerRequestData<Audio::eAMRT_CLEAR_CONTROLS_DATA> oAMData2(Audio::eADS_LEVEL_SPECIFIC);
oAudioRequestData.pData = &oAMData2;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
Audio::SAudioManagerRequestData<Audio::eAMRT_CLEAR_PRELOADS_DATA> oAMData3(Audio::eADS_LEVEL_SPECIFIC);
oAudioRequestData.pData = &oAMData3;
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
OnUnloadComplete(m_lastLevelName.c_str());
AzFramework::RootSpawnableInterface::Get()->ReleaseRootSpawnable();

@ -892,24 +892,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode)
return false;
}
//////////////////////////////////////////////////////////////////////
//update sound system Part 1 if in Editor / in Game Mode Viewsystem updates the Listeners
if (!m_env.IsEditorGameMode())
{
if ((updateFlags & ESYSUPDATE_EDITOR) != 0 && !bNoUpdate && nPauseMode != 1)
{
// updating the Listener Position in a first separate step.
// Updating all views here is a bit of a workaround, since we need
// to ensure that sound listeners owned by inactive views are also
// marked as inactive. Ideally that should happen when exiting game mode.
if (GetIViewSystem())
{
FRAME_PROFILER("SysUpdate:UpdateSoundListeners", this, PROFILE_SYSTEM);
GetIViewSystem()->UpdateSoundListeners();
}
}
}
// Use UI timer for CryMovie, because it should not be affected by pausing game time
const float fMovieFrameTime = m_Time.GetFrameTime(ITimer::ETIMER_UI);

@ -115,12 +115,6 @@ void DebugCamera::Update()
m_view = Matrix33(Ang3(DEG2RAD(m_cameraPitch), 0.0f, DEG2RAD(m_cameraYaw)));
UpdatePosition(m_moveInput);
// update the listener of the active view
if (IView* view = gEnv->pSystem->GetIViewSystem()->GetActiveView())
{
view->UpdateAudioListener(Matrix34(m_view, m_position));
}
}
///////////////////////////////////////////////////////////////////////////////

@ -553,11 +553,6 @@ void CView::PostSerialize()
{
}
//////////////////////////////////////////////////////////////////////////
void CView::UpdateAudioListener([[maybe_unused]] Matrix34 const& rMatrix)
{
}
//////////////////////////////////////////////////////////////////////////
void CView::SetActive([[maybe_unused]] bool const bActive)
{

@ -110,7 +110,6 @@ public:
void PostSerialize() override;
CCamera& GetCamera() override { return m_camera; }
const CCamera& GetCamera() const override { return m_camera; }
void UpdateAudioListener(const Matrix34& rMatrix) override;
void GetMemoryUsage(ICrySizer* s) const;

@ -200,11 +200,6 @@ void CViewSystem::Update(float frameTime)
if (bIsActive)
{
CCamera& rCamera = pView->GetCamera();
if (!s_debugCamera || !s_debugCamera->IsEnabled())
{
pView->UpdateAudioListener(rCamera.GetMatrix());
}
if (const SViewParams* currentParams = pView->GetCurrentParams())
{
SViewParams copyCurrentParams = *currentParams;
@ -554,12 +549,6 @@ void CViewSystem::SetOverrideCameraRotation(bool bOverride, Quat rotation)
m_overridenCameraRotation = rotation;
}
//////////////////////////////////////////////////////////////////////////
void CViewSystem::UpdateSoundListeners()
{
AZ_ErrorOnce("CryLegacy", false, "CryLegacy view system no longer available (CViewSystem::UpdateSoundListeners)");
}
//////////////////////////////////////////////////////////////////
void CViewSystem::OnLoadingStart([[maybe_unused]] const char* levelName)
{

@ -65,8 +65,6 @@ public:
{
return m_cutsceneCount > 0;
}
virtual void UpdateSoundListeners();
virtual void SetDeferredViewSystemUpdate(bool const bDeferred){ m_useDeferredViewSystemUpdate = bDeferred; }
virtual bool UseDeferredViewSystemUpdate() const { return m_useDeferredViewSystemUpdate; }
virtual void SetControlAudioListeners(bool const bActive);

@ -9,6 +9,15 @@
#include "DebugOutput.h"
#include <AzCore/std/optional.h>
#include <AzCore/IO/SystemFile.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/Views/PairIterator.h>
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphDownwardsIterator.h>
#include <SceneAPI/SceneCore/DataTypes/IGraphObject.h>
#include <SceneAPI/SceneCore/Events/ExportProductList.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
namespace AZ::SceneAPI::Utilities
{
void DebugOutput::Write(const char* name, const char* data)
@ -118,4 +127,63 @@ namespace AZ::SceneAPI::Utilities
{
return m_output;
}
void WriteAndLog(AZ::IO::SystemFile& dbgFile, const char* strToWrite)
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::LogWindow, "%s", strToWrite);
dbgFile.Write(strToWrite, strlen(strToWrite));
dbgFile.Write("\n", strlen("\n"));
}
void DebugOutput::BuildDebugSceneGraph(const char* outputFolder, AZ::SceneAPI::Events::ExportProductList& productList, const AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene>& scene, AZStd::string productName)
{
const int debugSceneGraphVersion = 1;
AZStd::string debugSceneFile;
AzFramework::StringFunc::Path::ConstructFull(outputFolder, productName.c_str(), debugSceneFile);
AZ_TracePrintf(AZ::SceneAPI::Utilities::LogWindow, "outputFolder %s, name %s.\n", outputFolder, productName.c_str());
AZ::IO::SystemFile dbgFile;
if (dbgFile.Open(debugSceneFile.c_str(), AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY))
{
WriteAndLog(dbgFile, AZStd::string::format("ProductName: %s", productName.c_str()).c_str());
WriteAndLog(dbgFile, AZStd::string::format("debugSceneGraphVersion: %d", debugSceneGraphVersion).c_str());
WriteAndLog(dbgFile, scene->GetName().c_str());
const AZ::SceneAPI::Containers::SceneGraph& sceneGraph = scene->GetGraph();
auto names = sceneGraph.GetNameStorage();
auto content = sceneGraph.GetContentStorage();
auto pairView = AZ::SceneAPI::Containers::Views::MakePairView(names, content);
auto view = AZ::SceneAPI::Containers::Views::MakeSceneGraphDownwardsView<
AZ::SceneAPI::Containers::Views::BreadthFirst>(
sceneGraph, sceneGraph.GetRoot(), pairView.cbegin(), true);
for (auto&& viewIt : view)
{
if (viewIt.second == nullptr)
{
continue;
}
AZ::SceneAPI::DataTypes::IGraphObject* graphObject = const_cast<AZ::SceneAPI::DataTypes::IGraphObject*>(viewIt.second.get());
WriteAndLog(dbgFile, AZStd::string::format("Node Name: %s", viewIt.first.GetName()).c_str());
WriteAndLog(dbgFile, AZStd::string::format("Node Path: %s", viewIt.first.GetPath()).c_str());
WriteAndLog(dbgFile, AZStd::string::format("Node Type: %s", graphObject->RTTI_GetTypeName()).c_str());
AZ::SceneAPI::Utilities::DebugOutput debugOutput;
viewIt.second->GetDebugOutput(debugOutput);
if (!debugOutput.GetOutput().empty())
{
WriteAndLog(dbgFile, debugOutput.GetOutput().c_str());
}
}
dbgFile.Close();
static const AZ::Data::AssetType dbgSceneGraphAssetType("{07F289D1-4DC7-4C40-94B4-0A53BBCB9F0B}");
productList.AddProduct(productName, AZ::Uuid::CreateName(productName.c_str()), dbgSceneGraphAssetType,
AZStd::nullopt, AZStd::nullopt);
}
}
}

@ -16,6 +16,22 @@
#include <AzCore/std/optional.h>
#include <cinttypes>
namespace AZ
{
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace Events
{
struct ExportProduct;
class ExportProductList;
}
}
}
namespace AZ::SceneAPI::Utilities
{
class DebugOutput
@ -42,6 +58,8 @@ namespace AZ::SceneAPI::Utilities
SCENE_CORE_API const AZStd::string& GetOutput() const;
SCENE_CORE_API static void BuildDebugSceneGraph(const char* outputFolder, AZ::SceneAPI::Events::ExportProductList& productList, const AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene>& scene, AZStd::string productName);
protected:
AZStd::string m_output;
};

@ -40,29 +40,35 @@ namespace AtomToolsFramework
const AZStd::any& AtomToolsDocument::GetPropertyValue([[maybe_unused]] const AZ::Name& propertyFullName) const
{
AZ_UNUSED(propertyFullName);
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
return m_invalidValue;
}
const AtomToolsFramework::DynamicProperty& AtomToolsDocument::GetProperty([[maybe_unused]] const AZ::Name& propertyFullName) const
{
AZ_UNUSED(propertyFullName);
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
return m_invalidProperty;
}
bool AtomToolsDocument::IsPropertyGroupVisible([[maybe_unused]] const AZ::Name& propertyGroupFullName) const
{
AZ_UNUSED(propertyGroupFullName);
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
return false;
}
void AtomToolsDocument::SetPropertyValue([[maybe_unused]] const AZ::Name& propertyFullName, [[maybe_unused]] const AZStd::any& value)
{
AZ_UNUSED(propertyFullName);
AZ_UNUSED(value);
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
}
bool AtomToolsDocument::Open([[maybe_unused]] AZStd::string_view loadPath)
{
AZ_UNUSED(loadPath);
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
return false;
}
@ -81,6 +87,7 @@ namespace AtomToolsFramework
bool AtomToolsDocument::SaveAsCopy([[maybe_unused]] AZStd::string_view savePath)
{
AZ_UNUSED(savePath);
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
return false;
}
@ -88,6 +95,7 @@ namespace AtomToolsFramework
bool AtomToolsDocument::SaveAsChild([[maybe_unused]] AZStd::string_view savePath)
{
AZ_UNUSED(savePath);
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
return false;
}

@ -15,7 +15,10 @@
#include <LmbrCentral/Audio/AudioTriggerComponentBus.h>
#include <AzCore/IO/Path/Path.h>
#include <IAudioSystem.h>
#include <ISystem.h>
using namespace Audio;
@ -68,11 +71,16 @@ namespace LmbrCentral
{
behaviorContext->EBus<AudioSystemComponentRequestBus>("AudioSystemComponentRequestBus")
->Event("GlobalStopAllSounds", &AudioSystemComponentRequestBus::Events::GlobalStopAllSounds)
->Event("GlobalMuteAudio", &AudioSystemComponentRequestBus::Events::GlobalMuteAudio)
->Event("GlobalUnmuteAudio", &AudioSystemComponentRequestBus::Events::GlobalUnmuteAudio)
->Event("GlobalRefreshAudio", &AudioSystemComponentRequestBus::Events::GlobalRefreshAudio)
->Event("GlobalExecuteAudioTrigger", &AudioSystemComponentRequestBus::Events::GlobalExecuteAudioTrigger)
->Event("GlobalKillAudioTrigger", &AudioSystemComponentRequestBus::Events::GlobalKillAudioTrigger)
->Event("GlobalSetAudioRtpc", &AudioSystemComponentRequestBus::Events::GlobalSetAudioRtpc)
->Event("GlobalResetAudioRtpcs", &AudioSystemComponentRequestBus::Events::GlobalResetAudioRtpcs)
->Event("GlobalSetAudioSwitchState", &AudioSystemComponentRequestBus::Events::GlobalSetAudioSwitchState)
->Event("LevelLoadAudio", &AudioSystemComponentRequestBus::Events::LevelLoadAudio)
->Event("LevelUnloadAudio", &AudioSystemComponentRequestBus::Events::LevelUnloadAudio)
;
behaviorContext->EBus<AudioSystemComponentNotificationBus>("Audio System Component Notifications", "AudioSystemComponentNotificationBus")
@ -114,6 +122,12 @@ namespace LmbrCentral
CrySystemEventBus::Handler::BusDisconnect();
}
////////////////////////////////////////////////////////////////////////
bool AudioSystemComponent::IsAudioSystemInitialized()
{
return Audio::AudioSystemRequestBus::HasHandlers();
}
////////////////////////////////////////////////////////////////////////
void AudioSystemComponent::GlobalStopAllSounds()
{
@ -124,6 +138,32 @@ namespace LmbrCentral
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequest, request);
}
////////////////////////////////////////////////////////////////////////
void AudioSystemComponent::GlobalMuteAudio()
{
SAudioRequest request;
SAudioManagerRequestData<eAMRT_MUTE_ALL> requestData;
request.pData = &requestData;
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequest, request);
}
////////////////////////////////////////////////////////////////////////
void AudioSystemComponent::GlobalUnmuteAudio()
{
SAudioRequest request;
SAudioManagerRequestData<eAMRT_UNMUTE_ALL> requestData;
request.pData = &requestData;
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequest, request);
}
////////////////////////////////////////////////////////////////////////
void AudioSystemComponent::GlobalRefreshAudio(AZStd::string_view levelName)
{
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::RefreshAudioSystem, levelName.data());
}
////////////////////////////////////////////////////////////////////////
void AudioSystemComponent::GlobalExecuteAudioTrigger(const char* triggerName, AZ::EntityId callbackOwnerEntityId)
{
@ -231,33 +271,105 @@ namespace LmbrCentral
}
////////////////////////////////////////////////////////////////////////
void AudioSystemComponent::OnCrySystemInitialized(ISystem&, const SSystemInitParams&)
void AudioSystemComponent::LevelLoadAudio(AZStd::string_view levelName)
{
const char* controlsPath = nullptr;
AudioSystemRequestBus::BroadcastResult(controlsPath, &AudioSystemRequestBus::Events::GetControlsPath);
if (!controlsPath)
{
return;
}
AZ::IO::FixedMaxPath levelControlsPath{ controlsPath };
levelControlsPath /= "levels";
levelControlsPath /= levelName;
SAudioRequest request;
SAudioManagerRequestData<eAMRT_PARSE_CONTROLS_DATA> requestData(levelControlsPath.Native().data(), eADS_LEVEL_SPECIFIC);
request.nFlags = (eARF_PRIORITY_HIGH | eARF_EXECUTE_BLOCKING);
request.pData = &requestData;
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequestBlocking, request);
SAudioManagerRequestData<eAMRT_PARSE_PRELOADS_DATA> requestData2(levelControlsPath.Native().data(), eADS_LEVEL_SPECIFIC);
request.pData = &requestData2;
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequestBlocking, request);
TAudioPreloadRequestID preloadRequestId = INVALID_AUDIO_PRELOAD_REQUEST_ID;
AudioSystemRequestBus::BroadcastResult(
preloadRequestId, &AudioSystemRequestBus::Events::GetAudioPreloadRequestID, levelName.data());
if (preloadRequestId != INVALID_AUDIO_PRELOAD_REQUEST_ID)
{
SAudioManagerRequestData<eAMRT_PRELOAD_SINGLE_REQUEST> requestData3(preloadRequestId);
request.pData = &requestData3;
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequestBlocking, request);
}
}
////////////////////////////////////////////////////////////////////////
void AudioSystemComponent::LevelUnloadAudio()
{
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::AddRequestListener,
SAudioRequest request;
// Unload level-specific banks...
SAudioManagerRequestData<eAMRT_UNLOAD_AFCM_DATA_BY_SCOPE> requestData(eADS_LEVEL_SPECIFIC);
request.nFlags = (eARF_PRIORITY_HIGH | eARF_EXECUTE_BLOCKING);
request.pData = &requestData;
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequestBlocking, request);
// Now unload level-specific audio config data (controls then preloads)...
SAudioManagerRequestData<eAMRT_CLEAR_CONTROLS_DATA> requestData2(eADS_LEVEL_SPECIFIC);
request.pData = &requestData2;
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequestBlocking, request);
SAudioManagerRequestData<eAMRT_CLEAR_PRELOADS_DATA> requestData3(eADS_LEVEL_SPECIFIC);
request.pData = &requestData3;
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequestBlocking, request);
}
////////////////////////////////////////////////////////////////////////
void AudioSystemComponent::OnCrySystemInitialized(ISystem& system, const SSystemInitParams&)
{
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::AddRequestListener,
&AudioSystemComponent::OnAudioEvent,
this,
Audio::eART_AUDIO_CALLBACK_MANAGER_REQUEST,
Audio::eACMRT_REPORT_FINISHED_TRIGGER_INSTANCE
eART_AUDIO_CALLBACK_MANAGER_REQUEST,
eACMRT_REPORT_FINISHED_TRIGGER_INSTANCE
);
system.GetILevelSystem()->AddListener(this);
}
////////////////////////////////////////////////////////////////////////
void AudioSystemComponent::OnCrySystemShutdown(ISystem&)
void AudioSystemComponent::OnCrySystemShutdown(ISystem& system)
{
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::RemoveRequestListener,
AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::RemoveRequestListener,
&AudioSystemComponent::OnAudioEvent,
this
);
system.GetILevelSystem()->RemoveListener(this);
}
////////////////////////////////////////////////////////////////////////
void AudioSystemComponent::OnLoadingStart(const char* levelName)
{
LevelLoadAudio(AZStd::string_view{ levelName });
}
////////////////////////////////////////////////////////////////////////
void AudioSystemComponent::OnUnloadComplete([[maybe_unused]] const char* levelName)
{
LevelUnloadAudio();
}
////////////////////////////////////////////////////////////////////////
// static
void AudioSystemComponent::OnAudioEvent(const Audio::SAudioRequestInfo* const requestInfo)
void AudioSystemComponent::OnAudioEvent(const SAudioRequestInfo* const requestInfo)
{
if (requestInfo->eAudioRequestType == Audio::eART_AUDIO_CALLBACK_MANAGER_REQUEST)
if (requestInfo->eAudioRequestType == eART_AUDIO_CALLBACK_MANAGER_REQUEST)
{
const auto notificationType = static_cast<Audio::EAudioCallbackManagerRequestType>(requestInfo->nSpecificAudioRequest);
if (notificationType == Audio::eACMRT_REPORT_FINISHED_TRIGGER_INSTANCE && requestInfo->eResult == Audio::eARR_SUCCESS)
const auto notificationType = static_cast<EAudioCallbackManagerRequestType>(requestInfo->nSpecificAudioRequest);
if (notificationType == eACMRT_REPORT_FINISHED_TRIGGER_INSTANCE && requestInfo->eResult == eARR_SUCCESS)
{
AZ::EntityId callbackOwnerEntityId(reinterpret_cast<AZ::u64>(requestInfo->pUserData));
AudioTriggerComponentNotificationBus::Event(callbackOwnerEntityId, &AudioTriggerComponentNotificationBus::Events::OnTriggerFinished, requestInfo->nAudioControlID);

@ -14,6 +14,7 @@
#include <CrySystemBus.h>
#include <IAudioInterfacesCommonData.h>
#include <ILevelSystem.h>
namespace LmbrCentral
{
@ -26,6 +27,7 @@ namespace LmbrCentral
: public AZ::Component
, protected AudioSystemComponentRequestBus::Handler
, public CrySystemEventBus::Handler
, public ILevelSystemListener
{
public:
AZ_COMPONENT(AudioSystemComponent, "{666E28D2-FC99-4D41-861D-3758C5070653}");
@ -49,18 +51,29 @@ namespace LmbrCentral
////////////////////////////////////////////////////////////////////////
// AudioSystemComponentRequestBus::Handler interface implementation
bool IsAudioSystemInitialized() override;
void GlobalStopAllSounds() override;
void GlobalMuteAudio() override;
void GlobalUnmuteAudio() override;
void GlobalRefreshAudio(AZStd::string_view levelName) override;
void GlobalExecuteAudioTrigger(const char* triggerName, AZ::EntityId callbackOwnerEntityId) override;
void GlobalKillAudioTrigger(const char* triggerName, AZ::EntityId callbackOwnerEntityId) override;
void GlobalSetAudioRtpc(const char* rtpcName, float value) override;
void GlobalResetAudioRtpcs() override;
void GlobalSetAudioSwitchState(const char* switchName, const char* stateName) override;
void LevelLoadAudio(AZStd::string_view levelName) override;
void LevelUnloadAudio() override;
////////////////////////////////////////////////////////////////////////
// CrySystemEventBus::Handler interface implementation
void OnCrySystemInitialized(ISystem&, const SSystemInitParams&) override;
void OnCrySystemShutdown(ISystem&) override;
////////////////////////////////////////////////////////////////////////
// ILevelSystemListener interface implementation
void OnLoadingStart(const char* levelName) override;
void OnUnloadComplete(const char* levelName) override;
private:
static void OnAudioEvent(const Audio::SAudioRequestInfo* const);
};

@ -28,12 +28,23 @@ namespace LmbrCentral
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
virtual bool IsAudioSystemInitialized()
{
return false;
}
virtual void GlobalStopAllSounds() = 0;
virtual void GlobalMuteAudio() = 0;
virtual void GlobalUnmuteAudio() = 0;
virtual void GlobalRefreshAudio(AZStd::string_view levelName) = 0;
virtual void GlobalExecuteAudioTrigger(const char* triggerName, AZ::EntityId callbackOwnerEntityId) = 0;
virtual void GlobalKillAudioTrigger(const char* triggerName, AZ::EntityId callbackOwnerEntityId) = 0;
virtual void GlobalSetAudioRtpc(const char* rtpcName, float value) = 0;
virtual void GlobalResetAudioRtpcs() = 0;
virtual void GlobalSetAudioSwitchState(const char* switchName, const char* stateName) = 0;
virtual void LevelLoadAudio(AZStd::string_view levelName) = 0;
virtual void LevelUnloadAudio() = 0;
};
using AudioSystemComponentRequestBus = AZ::EBus<AudioSystemComponentRequests>;

@ -16,7 +16,6 @@
#include "PNoise3.h"
#include "AnimSequence.h"
#include <IAudioSystem.h>
#include <Cry_Camera.h>
#include <AzCore/Serialization/SerializeContext.h>

@ -10,9 +10,7 @@
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/SystemFile.h>
#include <AzCore/Serialization/Utils.h>
#include <SceneAPI/SceneCore/Containers/Views/PairIterator.h>
#include <SceneAPI/SceneCore/DataTypes/IGraphObject.h>
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphDownwardsIterator.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/containers/set.h>
#include <AzFramework/Application/Application.h>
@ -306,7 +304,10 @@ namespace SceneBuilder
if (itr != request.m_jobDescription.m_jobParameters.end() && itr->second == "true")
{
BuildDebugSceneGraph(outputFolder.c_str(), productList, scene);
AZStd::string productName;
AzFramework::StringFunc::Path::GetFullFileName(scene->GetSourceFilename().c_str(), productName);
AzFramework::StringFunc::Path::ReplaceExtension(productName, "dbgsg");
AZ::SceneAPI::Utilities::DebugOutput::BuildDebugSceneGraph(outputFolder.c_str(), productList, scene, productName);
}
AZ_TracePrintf(Utilities::LogWindow, "Collecting and registering products.\n");
@ -371,66 +372,4 @@ namespace SceneBuilder
return id;
}
void WriteAndLog(AZ::IO::SystemFile& dbgFile, const char* strToWrite)
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::LogWindow, "%s", strToWrite);
dbgFile.Write(strToWrite, strlen(strToWrite));
dbgFile.Write("\n", strlen("\n"));
}
void SceneBuilderWorker::BuildDebugSceneGraph(const char* outputFolder, AZ::SceneAPI::Events::ExportProductList& productList, const AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene>& scene) const
{
const int debugSceneGraphVersion = 1;
AZStd::string productName, debugSceneFile;
AzFramework::StringFunc::Path::GetFullFileName(scene->GetSourceFilename().c_str(), productName);
AzFramework::StringFunc::Path::ReplaceExtension(productName, "dbgsg");
AzFramework::StringFunc::Path::ConstructFull(outputFolder, productName.c_str(), debugSceneFile);
AZ_TracePrintf(AZ::SceneAPI::Utilities::LogWindow, "outputFolder %s, name %s.\n", outputFolder, productName.c_str());
AZ::IO::SystemFile dbgFile;
if (dbgFile.Open(debugSceneFile.c_str(), AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY))
{
WriteAndLog(dbgFile, AZStd::string::format("ProductName: %s", productName.c_str()).c_str());
WriteAndLog(dbgFile, AZStd::string::format("debugSceneGraphVersion: %d", debugSceneGraphVersion).c_str());
WriteAndLog(dbgFile, scene->GetName().c_str());
const AZ::SceneAPI::Containers::SceneGraph& sceneGraph = scene->GetGraph();
auto names = sceneGraph.GetNameStorage();
auto content = sceneGraph.GetContentStorage();
auto pairView = AZ::SceneAPI::Containers::Views::MakePairView(names, content);
auto view = AZ::SceneAPI::Containers::Views::MakeSceneGraphDownwardsView<
AZ::SceneAPI::Containers::Views::BreadthFirst>(
sceneGraph, sceneGraph.GetRoot(), pairView.cbegin(), true);
for (auto&& viewIt : view)
{
if (viewIt.second == nullptr)
{
continue;
}
AZ::SceneAPI::DataTypes::IGraphObject* graphObject = const_cast<AZ::SceneAPI::DataTypes::IGraphObject*>(viewIt.second.get());
WriteAndLog(dbgFile, AZStd::string::format("Node Name: %s", viewIt.first.GetName()).c_str());
WriteAndLog(dbgFile, AZStd::string::format("Node Path: %s", viewIt.first.GetPath()).c_str());
WriteAndLog(dbgFile, AZStd::string::format("Node Type: %s", graphObject->RTTI_GetTypeName()).c_str());
AZ::SceneAPI::Utilities::DebugOutput debugOutput;
viewIt.second->GetDebugOutput(debugOutput);
if (!debugOutput.GetOutput().empty())
{
WriteAndLog(dbgFile, debugOutput.GetOutput().c_str());
}
}
dbgFile.Close();
static const AZ::Data::AssetType dbgSceneGraphAssetType("{07F289D1-4DC7-4C40-94B4-0A53BBCB9F0B}");
productList.AddProduct(productName, AZ::Uuid::CreateName(productName.c_str()), dbgSceneGraphAssetType,
AZStd::nullopt, AZStd::nullopt);
}
}
} // namespace SceneBuilder

@ -55,9 +55,6 @@ namespace SceneBuilder
void PopulateProductDependencies(const AZ::SceneAPI::Events::ExportProduct& exportProduct, const char* watchFolder, AssetBuilderSDK::JobProduct& jobProduct) const;
protected:
void BuildDebugSceneGraph(const char* outputFolder, AZ::SceneAPI::Events::ExportProductList& productList, const AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene>& scene) const;
bool LoadScene(AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene>& result,
const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response);

@ -32,7 +32,7 @@ ly_associate_package(PACKAGE_NAME DirectXShaderCompilerDxc-1.6.2104-o3de-rev2-ma
ly_associate_package(PACKAGE_NAME SPIRVCross-2021.04.29-rev1-mac TARGETS SPIRVCross PACKAGE_HASH 78c6376ed2fd195b9b1f5fb2b56e5267a32c3aa21fb399e905308de470eb4515)
ly_associate_package(PACKAGE_NAME freetype-2.10.4.14-mac-ios TARGETS freetype PACKAGE_HASH 67b4f57aed92082d3fd7c16aa244a7d908d90122c296b0a63f73e0a0b8761977)
ly_associate_package(PACKAGE_NAME tiff-4.2.0.15-mac-ios TARGETS tiff PACKAGE_HASH a23ae1f8991a29f8e5df09d6d5b00d7768a740f90752cef465558c1768343709)
ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.7.167-rev3-mac TARGETS AWSNativeSDK PACKAGE_HASH 21920372e90355407578b45ac19580df1463a39a25a867bcd0ffd8b385c8254a)
ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.7.167-rev4-mac TARGETS AWSNativeSDK PACKAGE_HASH 89e1651cde6b4e6bd80cdb96ed6b624accad9f9688ff38bfca226777f4fcb678)
ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev6-mac TARGETS Lua PACKAGE_HASH b9079fd35634774c9269028447562c6b712dbc83b9c64975c095fd423ff04c08)
ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev3-mac TARGETS PhysX PACKAGE_HASH 5e092a11d5c0a50c4dd99bb681a04b566a4f6f29aa08443d9bffc8dc12c27c8e)
ly_associate_package(PACKAGE_NAME etc2comp-9cd0f9cae0-rev1-mac TARGETS etc2comp PACKAGE_HASH 1966ab101c89db7ecf30984917e0a48c0d02ee0e4d65b798743842b9469c0818)

@ -634,6 +634,40 @@ try {
pipelineParameters.add(booleanParam(defaultValue: true, description: '', name: platform.key))
}
}
// Add additional Jenkins parameters
pipelineConfig.platforms.each { platform ->
platformEnv = platform.value.PIPELINE_ENV
pipelineJenkinsParameters = platformEnv['PIPELINE_JENKINS_PARAMETERS'] ?: [:]
jenkinsParametersToAdd = pipelineJenkinsParameters[pipelineName] ?: [:]
jenkinsParametersToAdd.each{ jenkinsParameter ->
defaultValue = jenkinsParameter['default_value']
// Use last run's value as default value so we can save values in different Jenkins environment
if (jenkinsParameter['use_last_run_value']?.toBoolean()) {
defaultValue = params."${jenkinsParameter['parameter_name']}" ?: jenkinsParameter['default_value']
}
switch (jenkinsParameter['parameter_type']) {
case 'string':
pipelineParameters.add(stringParam(defaultValue: defaultValue,
description: jenkinsParameter['description'],
name: jenkinsParameter['parameter_name']
))
break
case 'boolean':
pipelineParameters.add(booleanParam(defaultValue: defaultValue,
description: jenkinsParameter['description'],
name: jenkinsParameter['parameter_name']
))
break
case 'password':
pipelineParameters.add(password(defaultValue: defaultValue,
description: jenkinsParameter['description'],
name: jenkinsParameter['parameter_name']
))
break
}
}
}
pipelineProperties.add(parameters(pipelineParameters))
properties(pipelineProperties)

@ -376,5 +376,10 @@
"install_profile_vs2019",
"project_engineinstall_profile_vs2019"
]
},
"awsi_deployment": {
"TAGS": ["awsi-deployment"],
"COMMAND": "deploy_cdk_applications.cmd",
"PARAMETERS": {}
}
}

@ -16,5 +16,37 @@
"nightly-clean": {
"CLEAN_WORKSPACE": true
}
},
"PIPELINE_JENKINS_PARAMETERS": {
"awsi-deployment": [
{
"parameter_name": "O3DE_AWS_PROJECT_NAME",
"parameter_type": "string",
"default_value": "",
"use_last_run_value": true,
"description": ""
},
{
"parameter_name": "O3DE_AWS_DEPLOY_REGION",
"parameter_type": "string",
"default_value": "",
"use_last_run_value": true,
"description": ""
},
{
"parameter_name": "ASSUME_ROLE_ARN",
"parameter_type": "string",
"default_value": "",
"use_last_run_value": true,
"description": ""
},
{
"parameter_name": "COMMIT_ID",
"parameter_type": "string",
"default_value": "",
"use_last_run_value": true,
"description": ""
}
]
}
}
Loading…
Cancel
Save