Merge pull request #5532 from aws-lumberyard-dev/optimization/unused_files
Optimization: remove unused files
This commit is contained in:
@@ -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
|
||||
*
|
||||
*/
|
||||
#define AZCORE_BUILD_NUMBER 368
|
||||
#define AZCORE_BUILD_DATE "Thu 10/10/2013"
|
||||
#define AZCORE_BUILD_TIME "19:42:16.96"
|
||||
#define AZCORE_SOURCE_CHANGELIST 2992189
|
||||
@@ -1,197 +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
|
||||
*
|
||||
*/
|
||||
#ifndef AZCORE_JOBS_JOBEXECUTOR_H
|
||||
#define AZCORE_JOBS_JOBEXECUTOR_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
#include <AzCore/Jobs/JobFunction.h>
|
||||
#include <AzCore/std/parallel/condition_variable.h>
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
/**
|
||||
* Helper for porting legacy jobs that allows Starting and Waiting for multiple jobs asynchronously
|
||||
*/
|
||||
class LegacyJobExecutor final
|
||||
{
|
||||
public:
|
||||
LegacyJobExecutor() = default;
|
||||
|
||||
LegacyJobExecutor(const LegacyJobExecutor&) = delete;
|
||||
|
||||
~LegacyJobExecutor()
|
||||
{
|
||||
WaitForCompletion();
|
||||
}
|
||||
|
||||
template <class Function>
|
||||
inline void StartJob(const Function& processFunction, JobContext* context = nullptr)
|
||||
{
|
||||
Job * job = aznew JobFunctionExecutorHelper<Function>(processFunction, *this, context);
|
||||
StartJobInternal(job);
|
||||
}
|
||||
|
||||
// SetPostJob - This API exists to support backwards compatibility and is not a recommended pattern to be copied.
|
||||
// Instead, create AZ::Jobs with appropriate dependencies on each other
|
||||
template <class Function>
|
||||
inline void SetPostJob(LegacyJobExecutor& postJobExecutor, const Function& processFunction, JobContext* context = nullptr)
|
||||
{
|
||||
AZStd::unique_ptr<JobExecutorHelper> postJob(aznew JobFunctionExecutorHelper<Function>(processFunction, postJobExecutor, context)); // Allocate outside the lock
|
||||
{
|
||||
LockGuard lockGuard(m_conditionLock);
|
||||
|
||||
AZ_Assert(!m_postJob, "Post already set");
|
||||
AZ_Assert(!m_running, "LegacyJobExecutor::SetPostJob() must be called before starting any jobs");
|
||||
m_postJob = std::move(postJob);
|
||||
// Note: m_jobCount is not incremented until we push the post job
|
||||
}
|
||||
}
|
||||
|
||||
inline void ClearPostJob()
|
||||
{
|
||||
LockGuard lockGuard(m_conditionLock);
|
||||
m_postJob.reset();
|
||||
}
|
||||
|
||||
inline void Reset()
|
||||
{
|
||||
AZ_Assert(!IsRunning(), "LegacyJobExecutor::Reset() called while jobs in flight");
|
||||
}
|
||||
|
||||
inline void WaitForCompletion()
|
||||
{
|
||||
AZStd::unique_lock<decltype(m_conditionLock)> uniqueLock(m_conditionLock);
|
||||
|
||||
while (m_running)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AzCore);
|
||||
m_completionCondition.wait(uniqueLock, [this] { return !this->m_running; });
|
||||
}
|
||||
}
|
||||
|
||||
// Push a logical fence that will cause WaitForCompletion to wait until PopCompletionFence is called and all jobs are complete. Analogue to the legacy API SJobState::SetStarted()
|
||||
// Note: this does NOT fence execution of jobs in relation to each other
|
||||
inline void PushCompletionFence()
|
||||
{
|
||||
IncJobCount();
|
||||
}
|
||||
|
||||
// Pop a logical completion fence. Analogue to the legacy API SJobState::SetStopped()
|
||||
inline void PopCompletionFence()
|
||||
{
|
||||
JobCompleteUpdate();
|
||||
}
|
||||
|
||||
// Are there presently jobs in-flight (queued or running)?
|
||||
inline bool IsRunning()
|
||||
{
|
||||
return m_running;
|
||||
}
|
||||
|
||||
private:
|
||||
void JobCompleteUpdate()
|
||||
{
|
||||
AZ_Assert(m_jobCount, "Invalid LegacyJobExecutor::m_jobCount.");
|
||||
if (--m_jobCount == 0) // note: m_jobCount is atomic, so only the last completing job will take the count to zero
|
||||
{
|
||||
JobExecutorHelper* postJob = nullptr;
|
||||
{
|
||||
// All state transitions to and from running must be serialized through the condition lock
|
||||
LockGuard lockGuard(m_conditionLock);
|
||||
|
||||
// Test count again as another job may have started before we got the lock
|
||||
if (!m_jobCount)
|
||||
{
|
||||
m_running = false;
|
||||
postJob = m_postJob.release();
|
||||
m_completionCondition.notify_all();
|
||||
}
|
||||
}
|
||||
|
||||
// outside the lock (this pointer is no longer valid)...
|
||||
if (postJob)
|
||||
{
|
||||
postJob->StartOnExecutor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StartJobInternal(Job * job)
|
||||
{
|
||||
IncJobCount();
|
||||
job->Start();
|
||||
}
|
||||
|
||||
void IncJobCount()
|
||||
{
|
||||
if (m_jobCount++ == 0)
|
||||
{
|
||||
// All state transitions to and from running must be serialized through the condition lock (Even though m_running is atomic)
|
||||
LockGuard lockGuard(m_conditionLock);
|
||||
m_running = true;
|
||||
}
|
||||
}
|
||||
|
||||
class JobExecutorHelper
|
||||
{
|
||||
public:
|
||||
virtual ~JobExecutorHelper() = default;
|
||||
virtual void StartOnExecutor() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Private Job type that notifies the owning LegacyJobExecutor of completion
|
||||
*/
|
||||
template<class Function>
|
||||
class JobFunctionExecutorHelper : public JobFunction<Function>, public JobExecutorHelper
|
||||
{
|
||||
using Base = JobFunction<Function>;
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(JobFunctionExecutorHelper, ThreadPoolAllocator, 0)
|
||||
|
||||
JobFunctionExecutorHelper(typename JobFunction<Function>::FunctionCRef processFunction, LegacyJobExecutor& executor, JobContext* context)
|
||||
: JobFunction<Function>(processFunction, true /* isAutoDelete */, context)
|
||||
, m_executor(executor)
|
||||
{
|
||||
}
|
||||
|
||||
void StartOnExecutor() override
|
||||
{
|
||||
m_executor.StartJobInternal(this);
|
||||
}
|
||||
|
||||
void Process() override
|
||||
{
|
||||
Base::Process();
|
||||
|
||||
m_executor.JobCompleteUpdate();
|
||||
}
|
||||
|
||||
private:
|
||||
LegacyJobExecutor& m_executor;
|
||||
};
|
||||
|
||||
template<class Function>
|
||||
friend class JobFunctionExecutorHelper; // For JobCompleteUpdate, StartJobInternal
|
||||
|
||||
using Lock = AZStd::mutex;
|
||||
using LockGuard = AZStd::lock_guard<Lock>;
|
||||
|
||||
AZStd::condition_variable m_completionCondition;
|
||||
Lock m_conditionLock;
|
||||
AZStd::unique_ptr<JobExecutorHelper> m_postJob;
|
||||
|
||||
AZStd::atomic_uint m_jobCount{0};
|
||||
AZStd::atomic_bool m_running{false};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -7,22 +7,8 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/Memory/OSAllocator.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/std/parallel/containers/concurrent_fixed_unordered_set.h>
|
||||
|
||||
#include <AzCore/Memory/AllocatorManager.h>
|
||||
|
||||
AZ::AllocatorStorage::LazyAllocatorRef::~LazyAllocatorRef()
|
||||
{
|
||||
m_destructor(*m_allocator);
|
||||
}
|
||||
|
||||
void AZ::AllocatorStorage::LazyAllocatorRef::Init(size_t size, size_t alignment, CreationFn creationFn, DestructionFn destructionFn)
|
||||
{
|
||||
m_allocator = AZ::AllocatorManager::CreateLazyAllocator(size, alignment, creationFn);
|
||||
m_destructor = destructionFn;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// New overloads
|
||||
|
||||
@@ -521,19 +521,6 @@ namespace AZ
|
||||
{
|
||||
namespace AllocatorStorage
|
||||
{
|
||||
/// A private structure to create heap-storage for an allocator that won't expire until other static module members are destructed.
|
||||
struct LazyAllocatorRef
|
||||
{
|
||||
using CreationFn = IAllocator*(*)(void*);
|
||||
using DestructionFn = void(*)(IAllocator&);
|
||||
|
||||
~LazyAllocatorRef();
|
||||
void Init(size_t size, size_t alignment, CreationFn creationFn, DestructionFn destructionFn);
|
||||
|
||||
IAllocator* m_allocator = nullptr;
|
||||
DestructionFn m_destructor = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* A base class for all storage policies. This exists to provide access to private IAllocator methods via template friends.
|
||||
*/
|
||||
@@ -640,87 +627,6 @@ namespace AZ
|
||||
|
||||
template<class Allocator>
|
||||
EnvironmentVariable<Allocator> EnvironmentStoragePolicy<Allocator>::s_allocator;
|
||||
|
||||
/**
|
||||
* ModuleStoragePolicy stores the allocator in a static variable that is local to the module using it.
|
||||
* This forces separate instances of the allocator to exist in each module, and permits lazy instantiation.
|
||||
* We only tolerate this for some special allocators, primarily to maintain backwards compatibility with CryEngine,
|
||||
* since it still allocates outside of code in the data section.
|
||||
*
|
||||
* It has two ways of storing its allocator: either on the heap, which is the preferred way, since it guarantees
|
||||
* the memory for the allocator won't be deallocated (such as in a DLL) before anyone that's using it. If disabled
|
||||
* the allocator is stored in a static variable, which should only be used where this isn't a problem a shut-down
|
||||
* time, such as on a console.
|
||||
*/
|
||||
template<class Allocator, bool StoreAllocatorOnHeap>
|
||||
struct ModuleStoragePolicyBase;
|
||||
|
||||
template<class Allocator>
|
||||
struct ModuleStoragePolicyBase<Allocator, false>: public StoragePolicyBase<Allocator>
|
||||
{
|
||||
protected:
|
||||
// Use a static instance to store the allocator. This is not recommended when the order of shut-down with the module matters, as the allocator could have its memory destroyed
|
||||
// before the users of it are destroyed. The primary use case for this is allocators that need to support the CRT, as they cannot allocate from the heap.
|
||||
static Allocator& GetModuleAllocatorInstance()
|
||||
{
|
||||
static Allocator* s_allocator = nullptr;
|
||||
static typename AZStd::aligned_storage<sizeof(Allocator), AZStd::alignment_of<Allocator>::value>::type s_storage;
|
||||
|
||||
if (!s_allocator)
|
||||
{
|
||||
s_allocator = new (&s_storage) Allocator;
|
||||
StoragePolicyBase<Allocator>::Create(*s_allocator, typename Allocator::Descriptor(), true);
|
||||
}
|
||||
|
||||
return *s_allocator;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Allocator>
|
||||
struct ModuleStoragePolicyBase<Allocator, true> : public StoragePolicyBase<Allocator>
|
||||
{
|
||||
protected:
|
||||
// Store-on-heap implementation uses the LazyAllocatorRef to create and destroy an allocator using heap-space so there isn't a problem with destruction order within the module.
|
||||
static Allocator& GetModuleAllocatorInstance()
|
||||
{
|
||||
static LazyAllocatorRef s_allocator;
|
||||
|
||||
if (!s_allocator.m_allocator)
|
||||
{
|
||||
s_allocator.Init(sizeof(Allocator), AZStd::alignment_of<Allocator>::value, [](void* mem) -> IAllocator* { return new (mem) Allocator; }, &StoragePolicyBase<Allocator>::Destroy);
|
||||
StoragePolicyBase<Allocator>::Create(*static_cast<Allocator*>(s_allocator.m_allocator), typename Allocator::Descriptor(), true);
|
||||
}
|
||||
|
||||
return *static_cast<Allocator*>(s_allocator.m_allocator);
|
||||
}
|
||||
};
|
||||
|
||||
template<class Allocator, bool StoreAllocatorOnHeap = true>
|
||||
class ModuleStoragePolicy : public ModuleStoragePolicyBase<Allocator, StoreAllocatorOnHeap>
|
||||
{
|
||||
public:
|
||||
using Base = ModuleStoragePolicyBase<Allocator, StoreAllocatorOnHeap>;
|
||||
|
||||
static IAllocator& GetAllocator()
|
||||
{
|
||||
return Base::GetModuleAllocatorInstance();
|
||||
}
|
||||
|
||||
static void Create(const typename Allocator::Descriptor& desc = typename Allocator::Descriptor())
|
||||
{
|
||||
StoragePolicyBase<Allocator>::Create(Base::GetModuleAllocatorInstance(), desc, true);
|
||||
}
|
||||
|
||||
static void Destroy()
|
||||
{
|
||||
StoragePolicyBase<Allocator>::Destroy(Base::GetModuleAllocatorInstance());
|
||||
}
|
||||
|
||||
static bool IsReady()
|
||||
{
|
||||
return Base::GetModuleAllocatorInstance().IsReady();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace Internal
|
||||
|
||||
@@ -1,49 +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 "TimeDataStatisticsManager.h"
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Statistics
|
||||
{
|
||||
void TimeDataStatisticsManager::PushTimeDataSample(const char * registerName, const AZ::Debug::ProfilerRegister::TimeData& timeData)
|
||||
{
|
||||
const AZStd::string statName(registerName);
|
||||
NamedRunningStatistic* statistic = GetStatistic(statName);
|
||||
if (!statistic)
|
||||
{
|
||||
const AZStd::string units("us");
|
||||
AddStatistic(statName, statName, units, false);
|
||||
AZ::Debug::ProfilerRegister::TimeData zeroTimeData;
|
||||
memset(&zeroTimeData, 0, sizeof(AZ::Debug::ProfilerRegister::TimeData));
|
||||
m_previousTimeData[statName] = zeroTimeData;
|
||||
statistic = GetStatistic(statName);
|
||||
AZ_Assert(statistic != nullptr, "Fatal error adding a new statistic object");
|
||||
}
|
||||
|
||||
const AZ::u64 accumulatedTime = timeData.m_time;
|
||||
const AZ::s64 totalNumCalls = timeData.m_calls;
|
||||
const AZ::u64 previousAccumulatedTime = m_previousTimeData[statName].m_time;
|
||||
const AZ::s64 previousTotalNumCalls = m_previousTimeData[statName].m_calls;
|
||||
const AZ::u64 deltaTime = accumulatedTime - previousAccumulatedTime;
|
||||
const AZ::s64 deltaCalls = totalNumCalls - previousTotalNumCalls;
|
||||
|
||||
if (deltaCalls == 0)
|
||||
{
|
||||
//This is the same old data. Let's skip it
|
||||
return;
|
||||
}
|
||||
|
||||
double newSample = static_cast<double>(deltaTime) / deltaCalls;
|
||||
|
||||
statistic->PushSample(newSample);
|
||||
m_previousTimeData[statName] = timeData;
|
||||
}
|
||||
} //namespace Statistics
|
||||
} //namespace AZ
|
||||
@@ -1,51 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
#include <AzCore/Statistics/StatisticsManager.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Statistics
|
||||
{
|
||||
/**
|
||||
* @brief Specialization useful for data generated with AZ::Debug::FrameProfileComponent
|
||||
*
|
||||
* Timer based data collection using AZ_PROFILE_TIMER(...), available in
|
||||
* AzCore/Debug/Profiler.h can be collected when using AZ::Debug::FrameProfilerComponent
|
||||
* and AZ::Debug::FrameProfilerBus. The method PushTimeDataSample(...) is a convenience
|
||||
* to convert those Timer registers into a RunningStatistic.
|
||||
*
|
||||
*
|
||||
*/
|
||||
class TimeDataStatisticsManager : public StatisticsManager<>
|
||||
{
|
||||
public:
|
||||
TimeDataStatisticsManager() = default;
|
||||
virtual ~TimeDataStatisticsManager() = default;
|
||||
|
||||
/**
|
||||
* @brief Adds one sample data to a specific running stat by name.
|
||||
*
|
||||
* This method is specialized to work with ProfilerRegister::TimeData that can be intercepted
|
||||
* during AZ::Debug::FrameProfilerBus::OnFrameProfilerData().
|
||||
* For each @param registerName a new RunningStat object is created if it doesn't exist.
|
||||
*
|
||||
* Adds the TimeData as one sample for its RunningStatistic.
|
||||
*/
|
||||
void PushTimeDataSample(const char * registerName, const AZ::Debug::ProfilerRegister::TimeData& timeData);
|
||||
|
||||
protected:
|
||||
///We store here the previous value from the previous timer frame data.
|
||||
///This is necessary because AZ_PROFILER_TIMER is cumulative
|
||||
///and we need the time spent for each call.
|
||||
AZStd::unordered_map<AZStd::string, AZ::Debug::ProfilerRegister::TimeData> m_previousTimeData;
|
||||
};
|
||||
} //namespace Statistics
|
||||
} //namespace AZ
|
||||
@@ -240,7 +240,6 @@ set(FILES
|
||||
Jobs/JobManagerComponent.cpp
|
||||
Jobs/JobManagerComponent.h
|
||||
Jobs/JobManagerDesc.h
|
||||
Jobs/LegacyJobExecutor.h
|
||||
Jobs/MultipleDependentJob.h
|
||||
Jobs/task_group.h
|
||||
Math/Aabb.cpp
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <AzCore/Jobs/JobCompletion.h>
|
||||
#include <AzCore/Jobs/JobCompletionSpin.h>
|
||||
#include <AzCore/Jobs/JobFunction.h>
|
||||
#include <AzCore/Jobs/LegacyJobExecutor.h>
|
||||
#include <AzCore/Jobs/JobManager.h>
|
||||
#include <AzCore/Jobs/task_group.h>
|
||||
#include <AzCore/Jobs/Algorithms.h>
|
||||
@@ -1398,103 +1397,6 @@ namespace UnitTest
|
||||
run();
|
||||
}
|
||||
|
||||
using JobLegacyJobExecutorIsRunning = DefaultJobManagerSetupFixture;
|
||||
TEST_F(JobLegacyJobExecutorIsRunning, Test)
|
||||
{
|
||||
// Note: Legacy JobExecutor exists as an adapter to Legacy CryEngine jobs.
|
||||
// When writing new jobs instead favor direct use of the AZ::Job type family
|
||||
AZ::LegacyJobExecutor jobExecutor;
|
||||
EXPECT_FALSE(jobExecutor.IsRunning());
|
||||
|
||||
// Completion fences and IsRunning()
|
||||
{
|
||||
jobExecutor.PushCompletionFence();
|
||||
EXPECT_TRUE(jobExecutor.IsRunning());
|
||||
jobExecutor.PopCompletionFence();
|
||||
EXPECT_FALSE(jobExecutor.IsRunning());
|
||||
}
|
||||
|
||||
AZStd::atomic_bool jobExecuted{ false };
|
||||
AZStd::binary_semaphore jobSemaphore;
|
||||
|
||||
jobExecutor.StartJob([&jobSemaphore, &jobExecuted]
|
||||
{
|
||||
// Wait until the test thread releases
|
||||
jobExecuted = true;
|
||||
jobSemaphore.acquire();
|
||||
}
|
||||
);
|
||||
EXPECT_TRUE(jobExecutor.IsRunning());
|
||||
|
||||
// Allow the job to complete
|
||||
jobSemaphore.release();
|
||||
|
||||
// Wait for completion
|
||||
jobExecutor.WaitForCompletion();
|
||||
EXPECT_FALSE(jobExecutor.IsRunning());
|
||||
EXPECT_TRUE(jobExecuted);
|
||||
}
|
||||
|
||||
using JobLegacyJobExecutorWaitForCompletion = DefaultJobManagerSetupFixture;
|
||||
TEST_F(JobLegacyJobExecutorWaitForCompletion, Test)
|
||||
{
|
||||
// Note: Legacy JobExecutor exists as an adapter to Legacy CryEngine jobs.
|
||||
// When writing new jobs instead favor direct use of the AZ::Job type family
|
||||
AZ::LegacyJobExecutor jobExecutor;
|
||||
|
||||
// Semaphores used to park job threads until released
|
||||
const AZ::u32 numParkJobs = AZ::JobContext::GetGlobalContext()->GetJobManager().GetNumWorkerThreads();
|
||||
AZStd::vector<AZStd::binary_semaphore> jobSemaphores(numParkJobs);
|
||||
|
||||
// Data destination for workers
|
||||
const AZ::u32 workJobCount = numParkJobs * 2;
|
||||
AZStd::vector<AZ::u32> jobData(workJobCount, 0);
|
||||
|
||||
// Touch completion multiple times as a test of correctly transitioning in and out of the all jobs completed state
|
||||
AZ::u32 NumCompletionCycles = 5;
|
||||
for (AZ::u32 completionItrIdx = 0; completionItrIdx < NumCompletionCycles; ++completionItrIdx)
|
||||
{
|
||||
// Intentionally park every job thread
|
||||
for (auto& jobSemaphore : jobSemaphores)
|
||||
{
|
||||
jobExecutor.StartJob([&jobSemaphore]
|
||||
{
|
||||
jobSemaphore.acquire();
|
||||
}
|
||||
);
|
||||
}
|
||||
EXPECT_TRUE(jobExecutor.IsRunning());
|
||||
|
||||
// Kick off verifiable "work" jobs
|
||||
for (AZ::u32 i = 0; i < workJobCount; ++i)
|
||||
{
|
||||
jobExecutor.StartJob([i, &jobData]
|
||||
{
|
||||
jobData[i] = i + 1;
|
||||
}
|
||||
);
|
||||
}
|
||||
EXPECT_TRUE(jobExecutor.IsRunning());
|
||||
|
||||
// Now released our parked job threads
|
||||
for (auto& jobSemaphore : jobSemaphores)
|
||||
{
|
||||
jobSemaphore.release();
|
||||
}
|
||||
|
||||
// And wait for all jobs to finish
|
||||
jobExecutor.WaitForCompletion();
|
||||
EXPECT_FALSE(jobExecutor.IsRunning());
|
||||
|
||||
// Verify our workers ran and clear data
|
||||
for (size_t i = 0; i < workJobCount; ++i)
|
||||
{
|
||||
EXPECT_EQ(jobData[i], i + 1);
|
||||
jobData[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class JobCompletionCompleteNotScheduled
|
||||
: public DefaultJobManagerSetupFixture
|
||||
{
|
||||
|
||||
@@ -1,24 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
#include <AzFramework/Asset/SimpleAsset.h>
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
class CfgFileAsset
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(CfgFileAsset, "{117A80A5-206B-4D85-9445-33B446D94C35}")
|
||||
static const char* GetFileFilter()
|
||||
{
|
||||
return "*.cfg";
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,68 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class Transform;
|
||||
class Matrix3x3;
|
||||
class Vector3;
|
||||
}
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
//! The debug camera allows the user control over the view through mouse + keyboard and/or
|
||||
//! controller while the game still uses the view camera for everything else. This can for
|
||||
//! instance be used to debug occlusion culling as all occlusion calculates will be done
|
||||
//! from the view camera, so the debug camera makes it possible to check if hidden objects
|
||||
//! are correctly culled.
|
||||
//! This class can be useful to validate a hypothetical camera-based look-ahead asset streaming system.
|
||||
//! The developer can update the camera location using this EBus, without requiring to move the viewport camera.
|
||||
class DebugCameraInterface
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
enum class Mode
|
||||
{
|
||||
FreeFloating, //< Controls move the debug camera through the world.
|
||||
Fixed, //< The debug camera stays in the position it was navigated to and control is handed back to the game.
|
||||
Disabled, //< Debug camera is disabled.
|
||||
|
||||
Unknown
|
||||
};
|
||||
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
|
||||
//! Sets the debug camera in free floating, fixed or disabled mode.
|
||||
virtual void SetMode(Mode mode) = 0;
|
||||
//! Returns the current mode the debug camera is in.
|
||||
virtual Mode GetMode() const = 0;
|
||||
|
||||
//! Retrieves the world position of the debug camera. This is the same position that can be retrieved
|
||||
//! from GetTransform.
|
||||
virtual void GetPosition(AZ::Vector3& result) const = 0;
|
||||
//! Retrieves the view orientation of the debub camera. This is the same orientation that can be retrieved
|
||||
//! from GetTransform.
|
||||
virtual void GetView(AZ::Matrix3x3& result) const = 0;
|
||||
//! Get the world transform for the debug camera.
|
||||
virtual void GetTransform(AZ::Transform& result) const = 0;
|
||||
};
|
||||
using DebugCameraBus = AZ::EBus<DebugCameraInterface>;
|
||||
|
||||
//! The debug camera sends out notifications about some changes. This interface provides access to these.
|
||||
class DebugCameraEventsInterface
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
//! Called when the debug camera moves, usually due to user interaction.
|
||||
virtual void DebugCameraMoved(const AZ::Transform& world) {}
|
||||
};
|
||||
using DebugCameraEventsBus = AZ::EBus<DebugCameraEventsInterface>;
|
||||
} // namespace AzFramework
|
||||
@@ -1,13 +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 <AzFramework/Entity/PrefabEntityOwnershipService.h>
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
}
|
||||
@@ -59,7 +59,6 @@ set(FILES
|
||||
Asset/AssetSeedList.h
|
||||
Asset/AssetSystemComponent.cpp
|
||||
Asset/AssetSystemComponent.h
|
||||
Asset/CfgFileAsset.h
|
||||
Asset/GenericAssetHandler.h
|
||||
Asset/AssetBundleManifest.cpp
|
||||
Asset/AssetBundleManifest.h
|
||||
@@ -78,8 +77,6 @@ set(FILES
|
||||
Asset/Benchmark/BenchmarkSettingsAsset.h
|
||||
CommandLine/CommandLine.h
|
||||
CommandLine/CommandRegistrationBus.h
|
||||
Debug/DebugCameraBus.h
|
||||
feature_options.cmake
|
||||
Viewport/ViewportBus.h
|
||||
Viewport/ViewportBus.cpp
|
||||
Viewport/ViewportColors.h
|
||||
@@ -124,7 +121,6 @@ set(FILES
|
||||
Entity/SliceGameEntityOwnershipService.cpp
|
||||
Entity/SliceGameEntityOwnershipServiceBus.h
|
||||
Entity/PrefabEntityOwnershipService.h
|
||||
Entity/PrefabEntityOwnershipService.cpp
|
||||
Components/ComponentAdapter.h
|
||||
Components/ComponentAdapter.inl
|
||||
Components/ComponentAdapterHelpers.h
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "SvgLabelPage.h"
|
||||
#include "TableViewPage.h"
|
||||
#include "TabWidgetPage.h"
|
||||
#include "TitleBarPage.h"
|
||||
#include "ToggleSwitchPage.h"
|
||||
#include "ToolBarPage.h"
|
||||
#include "TreeViewPage.h"
|
||||
@@ -101,7 +100,6 @@ ComponentDemoWidget::ComponentDemoWidget(QWidget* parent)
|
||||
|
||||
// Pages hidden in 1.25 release - unused components, still need work before being made public, or not interesting for external devs
|
||||
//sortedPages.insert("AssetBrowserFolder", new AssetBrowserFolderPage(this));
|
||||
//sortedPages.insert("Titlebar", new TitleBarPage(this));
|
||||
|
||||
for (const auto& title : sortedPages.keys())
|
||||
{
|
||||
|
||||
@@ -1,74 +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 "TitleBarPage.h"
|
||||
#include <AzQtComponents/Gallery/ui_TitleBarPage.h>
|
||||
|
||||
TitleBarPage::TitleBarPage(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::TitleBarPage)
|
||||
{
|
||||
using namespace AzQtComponents;
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->activeSimpleTitleBar->setDrawSimple(true);
|
||||
ui->activeSimpleButtonsTitleBar->setDrawSimple(true);
|
||||
ui->inactiveSimpleTitleBar->setDrawSimple(true);
|
||||
ui->inactiveSimpleButtonsTitleBar->setDrawSimple(true);
|
||||
|
||||
ui->activeTearTitleBar->setTearEnabled(true);
|
||||
ui->activeTearButtonsTitleBar->setTearEnabled(true);
|
||||
ui->inactiveTearTitleBar->setTearEnabled(true);
|
||||
ui->inactiveTearButtonsTitleBar->setTearEnabled(true);
|
||||
|
||||
ui->inactiveTitleBar->setForceInactive(true);
|
||||
ui->inactiveButtonsTitleBar->setForceInactive(true);
|
||||
ui->inactiveSimpleTitleBar->setForceInactive(true);
|
||||
ui->inactiveSimpleButtonsTitleBar->setForceInactive(true);
|
||||
ui->inactiveTearTitleBar->setForceInactive(true);
|
||||
ui->inactiveTearButtonsTitleBar->setForceInactive(true);
|
||||
|
||||
ui->activeButtonsTitleBar->setButtons(
|
||||
{ DockBarButton::DividerButton, DockBarButton::MinimizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::MaximizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::CloseButton});
|
||||
ui->activeSimpleButtonsTitleBar->setButtons(
|
||||
{ DockBarButton::DividerButton, DockBarButton::MinimizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::MaximizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::CloseButton});
|
||||
ui->activeTearButtonsTitleBar->setButtons(
|
||||
{ DockBarButton::DividerButton, DockBarButton::MinimizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::MaximizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::CloseButton});
|
||||
ui->inactiveButtonsTitleBar->setButtons(
|
||||
{ DockBarButton::DividerButton, DockBarButton::MinimizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::MaximizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::CloseButton});
|
||||
ui->inactiveSimpleButtonsTitleBar->setButtons(
|
||||
{ DockBarButton::DividerButton, DockBarButton::MinimizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::MaximizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::CloseButton});
|
||||
ui->inactiveTearButtonsTitleBar->setButtons(
|
||||
{ DockBarButton::DividerButton, DockBarButton::MinimizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::MaximizeButton,
|
||||
DockBarButton::DividerButton, DockBarButton::CloseButton});
|
||||
|
||||
QString exampleText = R"(
|
||||
<pre>
|
||||
</pre>
|
||||
)";
|
||||
|
||||
ui->exampleText->setHtml(exampleText);
|
||||
}
|
||||
|
||||
TitleBarPage::~TitleBarPage()
|
||||
{
|
||||
}
|
||||
|
||||
#include "Gallery/moc_TitleBarPage.cpp"
|
||||
@@ -1,29 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QWidget>
|
||||
#include <QScopedPointer>
|
||||
#endif
|
||||
|
||||
namespace Ui {
|
||||
class TitleBarPage;
|
||||
}
|
||||
|
||||
class TitleBarPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TitleBarPage(QWidget* parent = nullptr);
|
||||
~TitleBarPage() override;
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::TitleBarPage> ui;
|
||||
};
|
||||
@@ -1,162 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TitleBarPage</class>
|
||||
<widget class="QWidget" name="TitleBarPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>827</width>
|
||||
<height>716</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="exampleText">
|
||||
<property name="undoRedoEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="normalLabel">
|
||||
<property name="text">
|
||||
<string>Normal</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="simpleLabel">
|
||||
<property name="text">
|
||||
<string>Simple</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="tearLabel">
|
||||
<property name="text">
|
||||
<string>Tear</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="activeLabel">
|
||||
<property name="text">
|
||||
<string>Active</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="inactiveLabel">
|
||||
<property name="text">
|
||||
<string>Inactive</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="AzQtComponents::TitleBar" name="activeTitleBar" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="AzQtComponents::TitleBar" name="activeSimpleTitleBar" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="AzQtComponents::TitleBar" name="activeTearTitleBar" native="true"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="AzQtComponents::TitleBar" name="activeButtonsTitleBar" native="true"/>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="AzQtComponents::TitleBar" name="activeSimpleButtonsTitleBar" native="true"/>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="AzQtComponents::TitleBar" name="activeTearButtonsTitleBar" native="true"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="AzQtComponents::TitleBar" name="inactiveTitleBar" native="true"/>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="AzQtComponents::TitleBar" name="inactiveSimpleTitleBar" native="true"/>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="AzQtComponents::TitleBar" name="inactiveTearTitleBar" native="true"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="AzQtComponents::TitleBar" name="inactiveButtonsTitleBar" native="true"/>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="AzQtComponents::TitleBar" name="inactiveSimpleButtonsTitleBar" native="true"/>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="AzQtComponents::TitleBar" name="inactiveTearButtonsTitleBar" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AzQtComponents::TitleBar</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>AzQtComponents/Components/Titlebar.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -106,9 +106,6 @@ set(FILES
|
||||
Gallery/TabWidgetPage.ui
|
||||
Gallery/TabWidgetPage.cpp
|
||||
Gallery/TabWidgetPage.h
|
||||
Gallery/TitleBarPage.ui
|
||||
Gallery/TitleBarPage.cpp
|
||||
Gallery/TitleBarPage.h
|
||||
Gallery/ToggleSwitchPage.ui
|
||||
Gallery/ToggleSwitchPage.cpp
|
||||
Gallery/ToggleSwitchPage.h
|
||||
|
||||
@@ -1,43 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Math/Vector2.h>
|
||||
|
||||
class CVegetationMap;
|
||||
struct CVegetationInstance;
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace EditorVegetation
|
||||
{
|
||||
/**
|
||||
* Bus used to talk to VegetationMap across the application
|
||||
*/
|
||||
class EditorVegetationRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
using Bus = AZ::EBus<EditorVegetationRequests>;
|
||||
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
typedef CVegetationMap* BusIdType;
|
||||
|
||||
virtual ~EditorVegetationRequests() {}
|
||||
|
||||
virtual AZStd::vector<CVegetationInstance*> GetObjectInstances(const AZ::Vector2& min, const AZ::Vector2& max) = 0;
|
||||
virtual void DeleteObjectInstance(CVegetationInstance* instance) = 0;
|
||||
};
|
||||
|
||||
using EditorVegetationRequestsBus = AZ::EBus<EditorVegetationRequests>;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +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 "NullArchiveComponent.h"
|
||||
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
|
||||
void NullArchiveComponent::Activate()
|
||||
{
|
||||
ArchiveCommandsBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void NullArchiveComponent::Deactivate()
|
||||
{
|
||||
ArchiveCommandsBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
std::future<bool> DefaultFuture()
|
||||
{
|
||||
std::promise<bool> p;
|
||||
p.set_value(false);
|
||||
return p.get_future();
|
||||
}
|
||||
|
||||
std::future<bool> NullArchiveComponent::CreateArchive(
|
||||
const AZStd::string& /*archivePath*/,
|
||||
const AZStd::string& /*dirToArchive*/)
|
||||
{
|
||||
return DefaultFuture();
|
||||
}
|
||||
|
||||
std::future<bool> NullArchiveComponent::ExtractArchive(
|
||||
const AZStd::string& /*archivePath*/,
|
||||
const AZStd::string& /*destinationPath*/)
|
||||
{
|
||||
return DefaultFuture();
|
||||
}
|
||||
|
||||
std::future<bool> NullArchiveComponent::ExtractFile(
|
||||
const AZStd::string& /*archivePath*/,
|
||||
const AZStd::string& /*fileInArchive*/,
|
||||
const AZStd::string& /*destinationPath*/)
|
||||
{
|
||||
return DefaultFuture();
|
||||
}
|
||||
|
||||
bool NullArchiveComponent::ListFilesInArchive(const AZStd::string& /*archivePath*/, AZStd::vector<AZStd::string>& /*outFileEntries*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::future<bool> NullArchiveComponent::AddFileToArchive(
|
||||
const AZStd::string& /*archivePath*/,
|
||||
const AZStd::string& /*fileToAdd*/,
|
||||
const AZStd::string& /*pathInArchive*/)
|
||||
{
|
||||
return DefaultFuture();
|
||||
}
|
||||
|
||||
std::future<bool> NullArchiveComponent::AddFilesToArchive(
|
||||
const AZStd::string& /*archivePath*/,
|
||||
const AZStd::string& /*workingDirectory*/,
|
||||
const AZStd::string& /*listFilePath*/)
|
||||
{
|
||||
return DefaultFuture();
|
||||
}
|
||||
|
||||
void NullArchiveComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
|
||||
if (serialize)
|
||||
{
|
||||
serialize->Class<NullArchiveComponent, AZ::Component>()
|
||||
;
|
||||
}
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
@@ -1,62 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzToolsFramework/Archive/ArchiveAPI.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
class NullArchiveComponent
|
||||
: public AZ::Component
|
||||
, private ArchiveCommandsBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(NullArchiveComponent, "{D665B6B1-5FF4-4203-B19F-BBDB82587129}")
|
||||
|
||||
NullArchiveComponent() = default;
|
||||
~NullArchiveComponent() override = default;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AZ::Component overrides
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
private:
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ArchiveCommandsBus::Handler overrides
|
||||
[[nodiscard]] std::future<bool> CreateArchive(
|
||||
const AZStd::string& archivePath,
|
||||
const AZStd::string& dirToArchive) override;
|
||||
|
||||
[[nodiscard]] std::future<bool> ExtractArchive(
|
||||
const AZStd::string& archivePath,
|
||||
const AZStd::string& destinationPath) override;
|
||||
|
||||
[[nodiscard]] std::future<bool> ExtractFile(
|
||||
const AZStd::string& archivePath,
|
||||
const AZStd::string& fileInArchive,
|
||||
const AZStd::string& destinationPath) override;
|
||||
|
||||
bool ListFilesInArchive(const AZStd::string& archivePath, AZStd::vector<AZStd::string>& outFileEntries) override;
|
||||
|
||||
[[nodiscard]] std::future<bool> AddFileToArchive(
|
||||
const AZStd::string& archivePath,
|
||||
const AZStd::string& workingDirectory,
|
||||
const AZStd::string& fileToAdd) override;
|
||||
|
||||
[[nodiscard]] std::future<bool> AddFilesToArchive(
|
||||
const AZStd::string& archivePath,
|
||||
const AZStd::string& workingDirectory,
|
||||
const AZStd::string& listFilePath) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
@@ -286,5 +286,3 @@ namespace AzToolsFramework
|
||||
|
||||
} // namespace AssetBrowser
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.inl>
|
||||
|
||||
@@ -1,41 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/std/function/function_fwd.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
#include <QImage>
|
||||
|
||||
class QImage;
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace AssetBrowser
|
||||
{
|
||||
class AssetBrowserModel;
|
||||
|
||||
//! Sends requests to output preview image for texture assets. Used for internal only!
|
||||
class AssetBrowserTexturePreviewRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
|
||||
// Only a single handler is allowed
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
|
||||
//! Request to get a preview image for texture product
|
||||
//@return whether the output image is valid or not
|
||||
virtual bool GetProductTexturePreview(const char* /*fullProductFileName*/, QImage& /*previewImage*/, AZStd::string& /*productInfo*/, AZStd::string& /*productAlphaInfo*/) { return false; }
|
||||
};
|
||||
|
||||
using AssetBrowserTexturePreviewRequestsBus = AZ::EBus<AssetBrowserTexturePreviewRequests>;
|
||||
} // namespace AssetBrowser
|
||||
} // namespace AzToolsFramework
|
||||
-186
@@ -1,186 +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 "SortFilterProxyModel.hxx"
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace AssetBrowser
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//SortFilterProxyModel
|
||||
SortFilterProxyModel::SortFilterProxyModel(QObject* parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
, m_assetMatchFiltersOperator(AzToolsFramework::FilterOperatorType::And)
|
||||
{
|
||||
//uncomment any column you want to see in the view
|
||||
m_showColumn.insert(AssetBrowserEntry::Column::Name);
|
||||
//m_showColumn.insert( Entry::Column_SourceID );
|
||||
//m_showColumn.insert( Entry::Column_FingerprintValue );
|
||||
//m_showColumn.insert( Entry::Colbumn_Guid );
|
||||
//m_showColumn.insert( Entry::Column_ScanFolderID );
|
||||
//m_showColumn.insert( Entry::Column_ProductID );
|
||||
//m_showColumn.insert( Entry::Column_JobID );
|
||||
//m_showColumn.insert( Entry::Column_JobKey );
|
||||
//m_showColumn.insert( Entry::Column_SubID );
|
||||
//m_showColumn.insert( Entry::Column_AssetType );
|
||||
//m_showColumn.insert( Entry::Column_Platform );
|
||||
//m_showColumn.insert( Entry::Column_ClassID );
|
||||
}
|
||||
|
||||
void SortFilterProxyModel::OnSearchCriteriaChanged(QStringList& criteriaList, AzToolsFramework::FilterOperatorType filterOperator)
|
||||
{
|
||||
removeAllAssetMatchFilters();
|
||||
setAssetMatchFilterOperator(filterOperator);
|
||||
|
||||
for (QString criteria : criteriaList)
|
||||
{
|
||||
auto parts = criteria.split(": ", QString::SkipEmptyParts);
|
||||
addAssetMatchFilter(parts.last().toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
void SortFilterProxyModel::addAssetTypeFilter(AZ::Data::AssetType assetType)
|
||||
{
|
||||
m_assetTypeFilters.push_back(assetType);
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void SortFilterProxyModel::addAssetPathFilter(const char* assetPathFilter)
|
||||
{
|
||||
m_assetPathFilters.push_back(assetPathFilter);
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void SortFilterProxyModel::removeAllAssetPathFilters()
|
||||
{
|
||||
m_assetPathFilters.clear();
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void SortFilterProxyModel::setAssetMatchSubDirFilter(bool val)
|
||||
{
|
||||
m_includeSubdir = val;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void SortFilterProxyModel::removeAllAssetMatchFilters()
|
||||
{
|
||||
m_assetMatchFilters.clear();
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void SortFilterProxyModel::addAssetMatchFilter(const char* assetMatchFilter)
|
||||
{
|
||||
m_assetMatchFilters.push_back(assetMatchFilter);
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void SortFilterProxyModel::setAssetMatchFilterOperator(AzToolsFramework::FilterOperatorType type)
|
||||
{
|
||||
m_assetMatchFiltersOperator = type;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
bool SortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
{
|
||||
//get the source idx, if invalid early out
|
||||
QModelIndex idx = sourceModel()->index(source_row, 0, source_parent);
|
||||
if (!idx.isValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//the entry is the internal pointer of the index
|
||||
auto entry = static_cast<AssetBrowserEntry*>(idx.internalPointer());
|
||||
|
||||
if (!entry->isValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//we only want to see assets that have at least one child product that has a valid assetType
|
||||
if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source)
|
||||
{
|
||||
//we have a asset with at least one valid child product assetType
|
||||
//we only want to see assets that have at least one child product that matches the assetType filter
|
||||
if (!m_assetTypeFilters.empty())
|
||||
{
|
||||
for (int i = 0; i < entry->GetChildCount(); ++i)
|
||||
{
|
||||
auto product = static_cast<ProductAssetBrowserEntry*>(entry->GetChild(i));
|
||||
if (product->isValid())
|
||||
{
|
||||
if (AZStd::find(m_assetTypeFilters.begin(), m_assetTypeFilters.end(), product->GetAssetType()) == m_assetTypeFilters.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//we only want to see assets that match all the match filters
|
||||
if (!m_assetMatchFilters.empty())
|
||||
{
|
||||
if (m_assetMatchFiltersOperator == AzToolsFramework::FilterOperatorType::And)
|
||||
{
|
||||
for (const auto& item : m_assetMatchFilters)
|
||||
{
|
||||
if (!entry->Match(item.c_str()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_assetMatchFiltersOperator == AzToolsFramework::FilterOperatorType::Or)
|
||||
{
|
||||
for (const auto& item : m_assetMatchFilters)
|
||||
{
|
||||
if (entry->Match(item.c_str()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SortFilterProxyModel::filterAcceptsColumn(int source_column, const QModelIndex& source_parent) const
|
||||
{
|
||||
(void)source_parent;
|
||||
|
||||
//if the column is in the set we want to show it
|
||||
return m_showColumn.find(static_cast<AssetBrowserEntry::Column>(source_column)) != m_showColumn.end();
|
||||
}
|
||||
|
||||
bool SortFilterProxyModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const
|
||||
{
|
||||
if (source_left.column() == source_right.column())
|
||||
{
|
||||
QVariant leftData = sourceModel()->data(source_left);
|
||||
QVariant rightData = sourceModel()->data(source_right);
|
||||
if ((leftData.type() == QVariant::String) &&
|
||||
(rightData.type() == QVariant::String))
|
||||
{
|
||||
QString leftString = leftData.toString();
|
||||
QString rightString = rightData.toString();
|
||||
return QString::compare(leftString, rightString, Qt::CaseInsensitive) > 0;
|
||||
}
|
||||
}
|
||||
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
} // namespace AssetBrowser
|
||||
} // namespace AzToolsFramework// namespace AssetBrowser
|
||||
|
||||
#include <AssetBrowser/moc_SortFilterProxyModel.cpp>
|
||||
-124
@@ -1,124 +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/Asset/AssetTypeInfoBus.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Thumbnails/ProductThumbnail.h>
|
||||
#include <QPixmap>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace AssetBrowser
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ProductThumbnailKey
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
ProductThumbnailKey::ProductThumbnailKey(const AZ::Data::AssetId& assetId)
|
||||
: ThumbnailKey()
|
||||
, m_assetId(assetId)
|
||||
{
|
||||
AZ::Data::AssetInfo info;
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(info, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, m_assetId);
|
||||
m_assetType = info.m_assetType;
|
||||
}
|
||||
|
||||
const AZ::Data::AssetId& ProductThumbnailKey::GetAssetId() const { return m_assetId; }
|
||||
|
||||
const AZ::Data::AssetType& ProductThumbnailKey::GetAssetType() const { return m_assetType; }
|
||||
|
||||
size_t ProductThumbnailKey::GetHash() const
|
||||
{
|
||||
return m_assetType.GetHash();
|
||||
}
|
||||
|
||||
bool ProductThumbnailKey::Equals(const ThumbnailKey* other) const
|
||||
{
|
||||
if (!ThumbnailKey::Equals(other))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// products displayed in Asset Browser have icons based on asset type, so multiple different products with same asset type will have same thumbnail
|
||||
return m_assetId == azrtti_cast<const ProductThumbnailKey*>(other)->GetAssetId();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ProductThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static const char* DEFAULT_PRODUCT_ICON_PATH = "Editor/Icons/AssetBrowser/DefaultProduct_16.svg";
|
||||
|
||||
ProductThumbnail::ProductThumbnail(Thumbnailer::SharedThumbnailKey key, int thumbnailSize)
|
||||
: Thumbnail(key, thumbnailSize)
|
||||
{}
|
||||
|
||||
void ProductThumbnail::LoadThread()
|
||||
{
|
||||
auto productKey = azrtti_cast<const ProductThumbnailKey*>(m_key.data());
|
||||
AZ_Assert(productKey, "Incorrect key type, excpected ProductThumbnailKey");
|
||||
|
||||
QString iconPath;
|
||||
AZ::AssetTypeInfoBus::EventResult(iconPath, productKey->GetAssetType(), &AZ::AssetTypeInfo::GetBrowserIcon);
|
||||
if (!iconPath.isEmpty())
|
||||
{
|
||||
// is it an embedded resource or absolute path?
|
||||
bool isUsablePath = (iconPath.startsWith(":") || (!AzFramework::StringFunc::Path::IsRelative(iconPath.toUtf8().constData())));
|
||||
|
||||
if (!isUsablePath)
|
||||
{
|
||||
// getting here means it needs resolution. Can we find the real path of the file? This also searches in gems for sources.
|
||||
bool foundIt = false;
|
||||
AZStd::string watchFolder;
|
||||
AZ::Data::AssetInfo assetInfo;
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(foundIt, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath, iconPath.toUtf8().constData(), assetInfo, watchFolder);
|
||||
|
||||
if (foundIt)
|
||||
{
|
||||
// the absolute path is join(watchfolder, relativepath); // since its relative to the watch folder.
|
||||
AZStd::string finalPath;
|
||||
AzFramework::StringFunc::Path::Join(watchFolder.c_str(), assetInfo.m_relativePath.c_str(), finalPath);
|
||||
iconPath = QString::fromUtf8(finalPath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no pixmap specified - use default.
|
||||
iconPath = QString::fromUtf8(DEFAULT_PRODUCT_ICON_PATH);
|
||||
}
|
||||
|
||||
m_icon = QIcon(iconPath);
|
||||
|
||||
if (m_icon.isNull())
|
||||
{
|
||||
m_state = State::Failed;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ProductThumbnailCache
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
ProductThumbnailCache::ProductThumbnailCache()
|
||||
: ThumbnailCache<ProductThumbnail>() {}
|
||||
|
||||
ProductThumbnailCache::~ProductThumbnailCache() = default;
|
||||
|
||||
const char* ProductThumbnailCache::GetProviderName() const
|
||||
{
|
||||
return ProviderName;
|
||||
}
|
||||
|
||||
bool ProductThumbnailCache::IsSupportedThumbnail(Thumbnailer::SharedThumbnailKey key) const
|
||||
{
|
||||
return azrtti_istypeof<const ProductThumbnailKey*>(key.data());
|
||||
}
|
||||
|
||||
} // namespace AssetBrowser
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#include "AssetBrowser/Thumbnails/moc_AssetBrowserProductThumbnail.cpp"
|
||||
-1
@@ -14,7 +14,6 @@
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzToolsFramework/SQLite/SQLiteConnection.h>
|
||||
#include <AzToolsFramework/API/AssetDatabaseBus.h>
|
||||
#include <AzToolsFramework/Debug/TraceContext.h>
|
||||
#include <AzToolsFramework/SQLite/SQLiteQuery.h>
|
||||
#include <AzToolsFramework/SQLite/SQLiteBoundColumnSet.h>
|
||||
#include <cinttypes>
|
||||
|
||||
@@ -1,88 +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 0
|
||||
|
||||
#include "EntityTransformCommand.h"
|
||||
#include <HexEdFramework/FrameworkCore/SelectionMessages.h>
|
||||
#include <HexEd/WorldEditor/ToolsComponents/TransformComponentBus.h>
|
||||
#include <AzToolsFramework/Undo/UndoCacheInterface.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
TransformCommand::TransformCommand(const AZ::u64& contextId, const AZStd::string& friendlyName, const EntityList& captureEntities)
|
||||
: UndoSystem::URSequencePoint(friendlyName)
|
||||
, m_contextId(contextId)
|
||||
{
|
||||
for (auto it = captureEntities.begin(); it != captureEntities.end(); ++it)
|
||||
{
|
||||
SRT current;
|
||||
EBUS_EVENT_ID_RESULT(current, *it, TransformComponentMessages::Bus, GetLocalSRT);
|
||||
m_priorTransforms[*it] = current;
|
||||
m_nextTransforms[*it] = current;
|
||||
}
|
||||
|
||||
m_undoCacheInterface = AZ::Interface<UndoSystem::UndoCacheInterface>::Get();
|
||||
AZ_Assert(m_undoCacheInterface, "Could not get UndoCacheInterface on TransformCommand construction.");
|
||||
}
|
||||
|
||||
void TransformCommand::Post()
|
||||
{
|
||||
// add to undo stack
|
||||
UndoSystem::UndoStack* undoStack = NULL;
|
||||
EBUS_EVENT_ID_RESULT(undoStack, m_contextId, SelectionMessages::Bus, GetUndoStack);
|
||||
|
||||
if (undoStack)
|
||||
{
|
||||
undoStack->Post(this);
|
||||
}
|
||||
|
||||
for (auto it = m_priorTransforms.begin(); it != m_priorTransforms.end(); ++it)
|
||||
{
|
||||
m_undoCacheInterface->UpdateCache(it->first);
|
||||
}
|
||||
}
|
||||
|
||||
void TransformCommand::Undo()
|
||||
{
|
||||
for (auto it = m_priorTransforms.begin(); it != m_priorTransforms.end(); ++it)
|
||||
{
|
||||
EBUS_EVENT_ID(it->first, TransformComponentMessages::Bus, SetLocalSRT, it->second);
|
||||
m_undoCacheInterface->UpdateCache(it->first);
|
||||
}
|
||||
}
|
||||
|
||||
void TransformCommand::Redo()
|
||||
{
|
||||
for (auto it = m_nextTransforms.begin(); it != m_nextTransforms.end(); ++it)
|
||||
{
|
||||
EBUS_EVENT_ID(it->first, TransformComponentMessages::Bus, SetLocalSRT, it->second);
|
||||
m_undoCacheInterface->UpdateCache(it->first);
|
||||
}
|
||||
}
|
||||
|
||||
void TransformCommand::CaptureNewTransform(const AZ::EntityId entityId)
|
||||
{
|
||||
AZ_Assert(m_priorTransforms.find(entityId) != m_priorTransforms.end(), "You can't add new transforms during an operation");
|
||||
AZ_Assert(m_nextTransforms.find(entityId) != m_nextTransforms.end(), "You can't add new transforms during an operation");
|
||||
|
||||
SRT current;
|
||||
EBUS_EVENT_ID_RESULT(current, entityId, TransformComponentMessages::Bus, GetLocalSRT);
|
||||
m_nextTransforms[entityId] = current;
|
||||
}
|
||||
|
||||
void TransformCommand::RevertToPriorTransform(const AZ::EntityId entityId)
|
||||
{
|
||||
AZ_Assert(m_priorTransforms.find(entityId) != m_priorTransforms.end(), "No such entity!");
|
||||
|
||||
m_nextTransforms[entityId] = m_priorTransforms[entityId];
|
||||
EBUS_EVENT_ID(entityId, TransformComponentMessages::Bus, SetLocalSRT, m_priorTransforms[entityId]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,66 +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
|
||||
*
|
||||
*/
|
||||
#ifndef TRANSFORM_COMMAND_H
|
||||
#define TRANSFORM_COMMAND_H
|
||||
|
||||
#if 0
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
#include <AzCore/Component/ComponentBus.h>
|
||||
#include <HexEdFramework/FrameworkCore/UndoSystem.h>
|
||||
#include <HexEd/WorldEditor/ToolsComponents/TransformComponentBus.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace UndoSystem
|
||||
{
|
||||
class UndoCacheInterface;
|
||||
}
|
||||
|
||||
typedef AZStd::vector<AZ::EntityId> EntityList;
|
||||
|
||||
// transform command specializes undo to just care about the transform of an entity instead of the entire thing, for performance.
|
||||
class TransformCommand
|
||||
: public UndoSystem::URSequencePoint
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(TransformCommand, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(TransformCommand);
|
||||
|
||||
TransformCommand(const AZ::u64& contextId, const AZStd::string& friendlyName, const EditorFramework::EntityList& captureEntities);
|
||||
virtual ~TransformCommand() {}
|
||||
|
||||
// the default will work for selections with out an undo stack(maybe move the undo stack here too
|
||||
void CaptureNewTransform(const AZ::EntityId entityId);
|
||||
void RevertToPriorTransform(const AZ::EntityId entityID);
|
||||
|
||||
virtual void Undo();
|
||||
virtual void Redo();
|
||||
|
||||
virtual void Post();
|
||||
|
||||
protected:
|
||||
AZ::u64 m_contextId;
|
||||
|
||||
typedef AZStd::unordered_map<AZ::EntityId, Components::SRT> CapturedTransforms;
|
||||
|
||||
CapturedTransforms m_priorTransforms;
|
||||
CapturedTransforms m_nextTransforms;
|
||||
|
||||
private:
|
||||
UndoCacheInterface* m_undoCacheInterface;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // disabled
|
||||
|
||||
#endif
|
||||
@@ -1,47 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
#include <AzFramework/Application/Application.h>
|
||||
#include <AzToolsFramework/Undo/UndoSystem.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
/**
|
||||
* AzToolsFramework URSequencePoint wrapper around legacy IUndoObject
|
||||
* Allows using IUndoObject with AzToolsFramework undo system
|
||||
*/
|
||||
template<typename UndoObjectType>
|
||||
class LegacyCommand
|
||||
: public AzToolsFramework::UndoSystem::URSequencePoint
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(LegacyCommand<UndoObjectType>, "{9ED33CB6-04D0-4924-A121-D8C27DC09066}", AzToolsFramework::UndoSystem::URSequencePoint);
|
||||
AZ_CLASS_ALLOCATOR(LegacyCommand<UndoObjectType>, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit LegacyCommand(const AZStd::string& friendlyName, AZStd::unique_ptr<UndoObjectType>&& legacyUndo)
|
||||
: AzToolsFramework::UndoSystem::URSequencePoint(friendlyName)
|
||||
{
|
||||
m_legacyUndo = AZStd::move(legacyUndo);
|
||||
}
|
||||
virtual ~LegacyCommand() = default;
|
||||
|
||||
void Undo() override { m_legacyUndo->Undo(); }
|
||||
void Redo() override { m_legacyUndo->Redo(); }
|
||||
|
||||
bool Changed() const override { return true; }
|
||||
|
||||
protected:
|
||||
AZStd::unique_ptr<UndoObjectType> m_legacyUndo;
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
-149
@@ -1,149 +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 <AzToolsFramework/Debug/TraceContext.h>
|
||||
#include <AzToolsFramework/Debug/TraceContextBufferedFormatter.h>
|
||||
|
||||
#ifdef AZ_ENABLE_TRACE_CONTEXT
|
||||
|
||||
#include <AzCore/Math/Uuid.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzToolsFramework/Debug/TraceContextStackInterface.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#endif // AZ_ENABLE_TRACE_CONTEXT
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
|
||||
#ifdef AZ_ENABLE_TRACE_CONTEXT
|
||||
|
||||
int TraceContextBufferedFormatter::Print(char* buffer, size_t bufferSize, const TraceContextStackInterface& stack, bool printUuids, size_t startIndex)
|
||||
{
|
||||
if (bufferSize == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Make sure there's always a terminator, even if nothing has been written.
|
||||
buffer[0] = 0;
|
||||
|
||||
size_t stackSize = stack.GetStackCount();
|
||||
for (size_t i = startIndex; i < stackSize; ++i)
|
||||
{
|
||||
int written = 0;
|
||||
switch (stack.GetType(i))
|
||||
{
|
||||
case TraceContextStackInterface::ContentType::StringType:
|
||||
written = azsnprintf(buffer, bufferSize, "%s=%s\n", stack.GetKey(i), stack.GetStringValue(i));
|
||||
break;
|
||||
case TraceContextStackInterface::ContentType::BoolType:
|
||||
written = azsnprintf(buffer, bufferSize, "%s=%c\n", stack.GetKey(i), (stack.GetBoolValue(i) ? '1' : '0'));
|
||||
break;
|
||||
case TraceContextStackInterface::ContentType::IntType:
|
||||
written = azsnprintf(buffer, bufferSize, "%s=%" PRIi64 "\n", stack.GetKey(i), stack.GetIntValue(i));
|
||||
break;
|
||||
case TraceContextStackInterface::ContentType::UintType:
|
||||
written = azsnprintf(buffer, bufferSize, "%s=%" PRIu64 "\n", stack.GetKey(i), stack.GetUIntValue(i));
|
||||
break;
|
||||
case TraceContextStackInterface::ContentType::FloatType:
|
||||
written = azsnprintf(buffer, bufferSize, "%s=%f\n", stack.GetKey(i), stack.GetFloatValue(i));
|
||||
break;
|
||||
case TraceContextStackInterface::ContentType::DoubleType:
|
||||
written = azsnprintf(buffer, bufferSize, "%s=%f\n", stack.GetKey(i), stack.GetDoubleValue(i));
|
||||
break;
|
||||
case TraceContextStackInterface::ContentType::UuidType:
|
||||
if (printUuids)
|
||||
{
|
||||
written = azsnprintf(buffer, bufferSize, "%s=", stack.GetKey(i));
|
||||
if (written > 0)
|
||||
{
|
||||
int uuidWritten = PrintUuid(buffer + written, bufferSize - written, stack.GetUuidValue(i));
|
||||
written = (uuidWritten < 0 ? -1 : (written + uuidWritten));
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
case TraceContextStackInterface::ContentType::Undefined:
|
||||
written = azsnprintf(buffer, bufferSize, "<UNDEFINED>\n");
|
||||
break;
|
||||
default:
|
||||
written = azsnprintf(buffer, bufferSize, "<UNKNOWN>\n");
|
||||
break;
|
||||
}
|
||||
|
||||
// If successful azsnprintf will return the number of characters that were
|
||||
// written, so move the buffer forward and reduce the available space.
|
||||
// Otherwise see if there's anything written that needs to be recovered
|
||||
// or to simply move to the next entry upon re-entry.
|
||||
if (written > 0)
|
||||
{
|
||||
buffer += written;
|
||||
bufferSize -= written;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the startIndex is the same as the current index, this is the first
|
||||
// entry to be written. It means this is the largest the buffer will
|
||||
// ever get, so leave whatever has been written in place. Do however
|
||||
// add a newline.
|
||||
if (startIndex == i)
|
||||
{
|
||||
if (bufferSize >= 2)
|
||||
{
|
||||
buffer[bufferSize - 2] = '\n';
|
||||
buffer[bufferSize - 1] = 0;
|
||||
}
|
||||
return aznumeric_caster(i + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bufferSize > 0)
|
||||
{
|
||||
// Remove whatever part has been written as it's not complete.
|
||||
*buffer = 0;
|
||||
}
|
||||
}
|
||||
return aznumeric_caster(i);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int TraceContextBufferedFormatter::PrintUuid(char* buffer, size_t bufferSize, const AZ::Uuid& uuid)
|
||||
{
|
||||
int written = uuid.ToString(buffer, aznumeric_caster(bufferSize), false);
|
||||
if (written > 0)
|
||||
{
|
||||
if (bufferSize > written)
|
||||
{
|
||||
buffer[written - 1] = '\n';
|
||||
buffer[written] = 0;
|
||||
return written + 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else // AZ_ENABLE_TRACE_CONTEXT
|
||||
|
||||
int TraceContextBufferedFormatter::Print(char* /*buffer*/, size_t /*bufferSize*/,
|
||||
const TraceContextStackInterface& /*stack*/, bool /*printUuids*/, size_t /*startIndex*/)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif // AZ_ENABLE_TRACE_CONTEXT
|
||||
} // Debug
|
||||
} // AzToolsFramework
|
||||
-66
@@ -1,66 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/base.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
struct Uuid;
|
||||
}
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
class TraceContextStackInterface;
|
||||
|
||||
// TraceContexBufferedFormatter takes a trace context stack and prints it to the given buffer.
|
||||
// It's aimed to be used with small to micro sized character buffers. (At least 50-100
|
||||
// characters is advised.) If the entire context couldn't be written to the buffer, Build
|
||||
// can be called repeatedly with the returned index to continue printing the buffer. If a
|
||||
// single context entry doesn't fit in the buffer, TraceContexBufferedFormatter will attempt
|
||||
// to write as much data as can be fitted in the buffer.
|
||||
//
|
||||
// Typical usage looks like:
|
||||
// TraceContextSingleStackHandler stackHandler;
|
||||
// ...
|
||||
// TraceContexBufferedFormatter buffered;
|
||||
// char buffer[64];
|
||||
// int index = 0;
|
||||
// do
|
||||
// {
|
||||
// index = buffered.Build(buffer, stackHandler.GetStack(), true, index);
|
||||
// Print(buffer);
|
||||
// } while (index >= 0);
|
||||
//
|
||||
// Example output:
|
||||
// String=text
|
||||
// Integer=42
|
||||
// Float=3.141500
|
||||
// Uuid=E2C7EEFA-B1CA-465F-A4BC-30514F76B7B5
|
||||
|
||||
class TraceContextBufferedFormatter
|
||||
{
|
||||
public:
|
||||
// Prints the trace context to the given buffer, tags.
|
||||
// If printUuids is true, the uuid of objects and tags is printed as well.
|
||||
// Use startIndex to continue from a specific entry.
|
||||
// Returns the index of the next entry to be written or -1 if no entries are left.
|
||||
static int Print(char* buffer, size_t bufferSize, const TraceContextStackInterface& stack, bool printUuids, size_t startIndex = 0);
|
||||
|
||||
template<size_t size>
|
||||
static inline int Print(char(&buffer)[size], const TraceContextStackInterface& stack, bool printUuids, size_t startIndex = 0);
|
||||
|
||||
private:
|
||||
static int PrintUuid(char* buffer, size_t bufferSize, const AZ::Uuid& uuid);
|
||||
};
|
||||
} // Debug
|
||||
} // AzToolsFramework
|
||||
|
||||
#include <AzToolsFramework/Debug/TraceContextBufferedFormatter.inl>
|
||||
-19
@@ -1,19 +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
|
||||
*
|
||||
*/
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
template<size_t size>
|
||||
inline int TraceContextBufferedFormatter::Print(char(&buffer)[size], const TraceContextStackInterface& stack, bool printUuids, size_t startIndex)
|
||||
{
|
||||
return Print(buffer, size, stack, printUuids, startIndex);
|
||||
}
|
||||
} // Debug
|
||||
} // AzToolsFramework
|
||||
@@ -1,48 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
class QWidget;
|
||||
class QPainter;
|
||||
class QStyleOptionViewItem;
|
||||
class QAbstractItemModel;
|
||||
class QModelIndex;
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Thumbnailer
|
||||
{
|
||||
//! Thumbnail delegate can be used as within item views to draw thumbnails
|
||||
class ThumbnailDelegate
|
||||
: public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ThumbnailDelegate(QWidget* parent = nullptr);
|
||||
~ThumbnailDelegate() override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// QStyledItemDelegate
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
void setEditorData(QWidget* editor, const QModelIndex& index) const override;
|
||||
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
|
||||
//! Set location where thumbnails are searched
|
||||
void SetThumbnailContext(const char* thumbnailContext);
|
||||
|
||||
private:
|
||||
AZStd::string m_thumbnailContext;
|
||||
};
|
||||
} // namespace Thumbnailer
|
||||
} // namespace AzToolsFramework
|
||||
@@ -22,7 +22,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
namespace Thumbnailer
|
||||
{
|
||||
//! A widget used to display thumbnail. To display thumbnails within item views, use ThumbnailDelegate
|
||||
//! A widget used to display thumbnail
|
||||
class ThumbnailWidget
|
||||
: public QWidget
|
||||
{
|
||||
|
||||
-7
@@ -1,7 +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
|
||||
*
|
||||
*/
|
||||
-53
@@ -1,53 +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 "ComponentPaletteModelFilter.hxx"
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
|
||||
ComponentPaletteModelFilter::ComponentPaletteModelFilter(QObject* parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool ComponentPaletteModelFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
if (!index.isValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!filterRegExp().isValid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
auto componentClass = reinterpret_cast<const AZ::SerializeContext::ClassData*>(sourceModel()->data(index, Qt::ItemDataRole::UserRole + 1).toULongLong());
|
||||
if (componentClass)
|
||||
{
|
||||
const QString componentName = sourceModel()->data(index, Qt::DisplayRole).toString();
|
||||
return componentName.contains(filterRegExp());
|
||||
}
|
||||
|
||||
const int childRowCount = sourceModel()->rowCount(index);
|
||||
for (int childRow = 0; childRow < childRowCount; ++childRow)
|
||||
{
|
||||
if (filterAcceptsRow(childRow, index))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#include "UI/ComponentPalette/moc_ComponentPaletteModelFilter.cpp"
|
||||
-29
@@ -1,29 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QSortFilterProxyModel>
|
||||
#endif
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
class ComponentPaletteModelFilter : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ComponentPaletteModelFilter(QObject* parent = nullptr);
|
||||
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
|
||||
protected:
|
||||
QRegExp m_filterRegExp;
|
||||
};
|
||||
}
|
||||
-67
@@ -1,67 +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 "UIFrameworkAPI.h"
|
||||
#include <AzCore/Math/Uuid.h>
|
||||
#include <AzCore/std/delegate/delegate.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
# include <QtGui/qpa/qplatformnativeinterface.h>
|
||||
#endif
|
||||
|
||||
#include <AzToolsFramework/UI/UICore/OverwritePromptDialog.hxx>
|
||||
|
||||
#include <QWindow>
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace
|
||||
{
|
||||
// an aggregator utility which essentially provides the operation of returning the last result of an ebus event
|
||||
// which returned something which returns a non-false value (like for example if its a pointer, then the last non-null value)
|
||||
template<class T>
|
||||
struct EBusLastNonNullResult
|
||||
{
|
||||
T value;
|
||||
EBusLastNonNullResult() { value = NULL; }
|
||||
AZ_FORCE_INLINE void operator=(const T& rhs)
|
||||
{
|
||||
if (rhs)
|
||||
{
|
||||
value = rhs;
|
||||
}
|
||||
}
|
||||
AZ_FORCE_INLINE T& operator->() { return value; }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct EBusAnyTrueResult
|
||||
{
|
||||
T value;
|
||||
AZ_FORCE_INLINE void operator=(const T& rhs) { value = rhs || value; }
|
||||
AZ_FORCE_INLINE T& operator->() { return value; }
|
||||
};
|
||||
}
|
||||
|
||||
bool GetOverwritePromptResult(QWidget* pParentWidget, const char* assetNameToOvewrite)
|
||||
{
|
||||
OverwritePromptDialog dlg(pParentWidget);
|
||||
if (assetNameToOvewrite)
|
||||
{
|
||||
dlg.UpdateLabel(QString::fromUtf8(assetNameToOvewrite));
|
||||
}
|
||||
|
||||
if (!dlg.exec() == QDialog::Accepted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return dlg.m_result;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +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 "DHQSlider.hxx"
|
||||
#include "PropertyQTConstants.h"
|
||||
#include <QtWidgets/QAbstractSpinBox>
|
||||
AZ_PUSH_DISABLE_WARNING(4244 4251, "-Wunknown-warning-option") // 4244: conversion from 'int' to 'float', possible loss of data
|
||||
// 4251: 'QInputEvent::modState': class 'QFlags<Qt::KeyboardModifier>' needs to have dll-interface to be used by clients of class 'QInputEvent'
|
||||
#include <QWheelEvent>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
void DHQSlider::wheelEvent(QWheelEvent* e)
|
||||
{
|
||||
if (hasFocus())
|
||||
{
|
||||
QSlider::wheelEvent(e);
|
||||
}
|
||||
else
|
||||
{
|
||||
e->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeSliderPropertyWidgets(QSlider* slider, QAbstractSpinBox* spinbox)
|
||||
{
|
||||
if (slider == nullptr || spinbox == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// A 2:1 ratio between spinbox and slider gives the slider more room,
|
||||
// but leaves some space for the spin box to expand.
|
||||
const int spinBoxStretch = 1;
|
||||
const int sliderStretch = 2;
|
||||
|
||||
QSizePolicy sizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||
sizePolicy.setHorizontalStretch(spinBoxStretch);
|
||||
spinbox->setSizePolicy(sizePolicy);
|
||||
spinbox->setMinimumWidth(PropertyQTConstant_MinimumWidth);
|
||||
spinbox->setFixedHeight(PropertyQTConstant_DefaultHeight);
|
||||
spinbox->setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
sizePolicy.setHorizontalStretch(sliderStretch);
|
||||
slider->setSizePolicy(sizePolicy);
|
||||
slider->setMinimumWidth(PropertyQTConstant_MinimumWidth);
|
||||
slider->setFixedHeight(PropertyQTConstant_DefaultHeight);
|
||||
slider->setFocusPolicy(Qt::StrongFocus);
|
||||
slider->setFocusProxy(spinbox);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AZ_Q_SLIDER_HXX
|
||||
#define AZ_Q_SLIDER_HXX
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <QtWidgets/QSlider>
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
class QAbstractSpinBox;
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
class DHQSlider
|
||||
: public QSlider
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(DHQSlider, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit DHQSlider(QWidget* parent = 0)
|
||||
: QSlider(parent) {}
|
||||
|
||||
DHQSlider(Qt::Orientation orientation, QWidget* parent = 0)
|
||||
: QSlider(orientation, parent) {}
|
||||
|
||||
void wheelEvent(QWheelEvent* e);
|
||||
};
|
||||
|
||||
// Share widget initialization code between double and int based slider properties.
|
||||
void InitializeSliderPropertyWidgets(QSlider*, QAbstractSpinBox*);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzToolsFramework/Debug/TraceContext.h>
|
||||
#include <AzCore/PlatformDef.h>
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // 4251: 'QRawFont::d': class 'QExplicitlySharedDataPointer<QRawFontPrivate>' needs to have dll-interface to be used by clients of class 'QRawFont'
|
||||
// 4800: 'QTextEngine *const ': forcing value to bool 'true' or 'false' (performance warning)
|
||||
#include <QTextBlock>
|
||||
|
||||
+1
-2
@@ -18,8 +18,7 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option")
|
||||
#include <QPainter>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
#include <QtWidgets/QToolButton>
|
||||
|
||||
#include "../UICore/ColorPickerDelegate.hxx"
|
||||
#include <QtGui/QRegExpValidator>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
|
||||
-1
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
#include <cmath>
|
||||
#include "PropertyDoubleSliderCtrl.hxx"
|
||||
#include "DHQSlider.hxx"
|
||||
#include "PropertyQTConstants.h"
|
||||
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: 'QLayoutItem::align': class 'QFlags<Qt::AlignmentFlag>' needs to have dll-interface to be used by clients of class 'QLayoutItem'
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
|
||||
-346
@@ -1,346 +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
|
||||
*
|
||||
*/
|
||||
#ifndef PROPERTYEDITOR_UITYPES_H
|
||||
#define PROPERTYEDITOR_UITYPES_H
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include "PropertyEditor/EditorClassReflectionTest.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace PropertySystem
|
||||
{
|
||||
typedef AZStd::function < void(const AZStd::string& FieldName, AZStd::vector<AZStd::string>& dEnumNames) >
|
||||
EnumNamesCallback;
|
||||
|
||||
class EditorUIInfo_Enum
|
||||
: public EditorUIInfo
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_Enum, EditorUIInfo);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_Enum, AZ::SystemAllocator, 0);
|
||||
|
||||
EnumNamesCallback m_enumNamesCallBack;
|
||||
|
||||
EditorUIInfo_Enum(EnumNamesCallback enumNamesCallBack, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo(inFlags)
|
||||
, m_enumNamesCallBack(enumNamesCallBack)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_EnumComboBox
|
||||
: public EditorUIInfo_Enum
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_EnumComboBox, EditorUIInfo_Enum);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_EnumComboBox, AZ::SystemAllocator, 0);
|
||||
|
||||
EditorUIInfo_EnumComboBox(EnumNamesCallback enumNamesCallBack, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo_Enum(enumNamesCallBack, inFlags)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
typedef AZStd::function < void(const AZStd::string& FieldName, AZStd::vector<AZStd::string>& dEnumNames) >
|
||||
ChoiceNamesCallback;
|
||||
|
||||
class EditorUIInfo_Choice
|
||||
: public EditorUIInfo
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_Choice, EditorUIInfo);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_Choice, AZ::SystemAllocator, 0);
|
||||
|
||||
ChoiceNamesCallback m_choiceNamesCallBack;
|
||||
|
||||
EditorUIInfo_Choice(ChoiceNamesCallback choiceNamesCallBack, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo(inFlags)
|
||||
, m_choiceNamesCallBack(choiceNamesCallBack)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_ChoiceComboBox
|
||||
: public EditorUIInfo_Choice
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_ChoiceComboBox, EditorUIInfo_Choice);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_ChoiceComboBox, AZ::SystemAllocator, 0);
|
||||
|
||||
EditorUIInfo_ChoiceComboBox(ChoiceNamesCallback choiceNamesCallBack, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo_Choice(choiceNamesCallBack, inFlags)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_Bool
|
||||
: public EditorUIInfo
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_Bool, EditorUIInfo);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_Bool, AZ::SystemAllocator, 0);
|
||||
|
||||
EditorUIInfo_Bool(AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo(inFlags)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_BoolComboBox
|
||||
: public EditorUIInfo_Bool
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_BoolComboBox, EditorUIInfo_Bool);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_BoolComboBox, AZ::SystemAllocator, 0);
|
||||
|
||||
EditorUIInfo_BoolComboBox(AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo_Bool(inFlags)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_BoolDialogBox
|
||||
: public EditorUIInfo_Bool
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_BoolDialogBox, EditorUIInfo_Bool);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_BoolDialogBox, AZ::SystemAllocator, 0);
|
||||
|
||||
EditorUIInfo_BoolDialogBox(AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo_Bool(inFlags)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class EditorUIInfo_Int
|
||||
: public EditorUIInfo
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_Int, EditorUIInfo);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_Int, AZ::SystemAllocator, 0);
|
||||
|
||||
int m_minVal;
|
||||
int m_maxVal;
|
||||
|
||||
EditorUIInfo_Int(int minVal = INT_MIN, int maxVal = INT_MAX, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo(inFlags)
|
||||
, m_minVal(minVal)
|
||||
, m_maxVal(maxVal)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_IntSpinBox
|
||||
: public EditorUIInfo_Int
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_IntSpinBox, EditorUIInfo_Int);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_IntSpinBox, AZ::SystemAllocator, 0);
|
||||
|
||||
EditorUIInfo_IntSpinBox(int minVal = INT_MIN, int maxVal = INT_MAX, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo_Int(minVal, maxVal, inFlags)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_IntSlider
|
||||
: public EditorUIInfo_Int
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_IntSlider, EditorUIInfo_Int);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_IntSlider, AZ::SystemAllocator, 0);
|
||||
|
||||
int m_step;
|
||||
|
||||
EditorUIInfo_IntSlider(int step = 1, int minVal = INT_MIN, int maxVal = INT_MAX, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo_Int(minVal, maxVal, inFlags)
|
||||
, m_step(step)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_Float
|
||||
: public EditorUIInfo
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_Float, EditorUIInfo);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_Float, AZ::SystemAllocator, 0);
|
||||
|
||||
float m_minVal;
|
||||
float m_maxVal;
|
||||
|
||||
EditorUIInfo_Float(float minVal = std::numeric_limits<float>::min(), float maxVal = std::numeric_limits<float>::max(), AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo(inFlags)
|
||||
, m_minVal(minVal)
|
||||
, m_maxVal(maxVal)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_FloatSpinBox
|
||||
: public EditorUIInfo_Float
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_FloatSpinBox, EditorUIInfo_Float);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_FloatSpinBox, AZ::SystemAllocator, 0);
|
||||
|
||||
EditorUIInfo_FloatSpinBox(float minVal = std::numeric_limits<float>::min(), float maxVal = std::numeric_limits<float>::max(), AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo_Float(minVal, maxVal, inFlags)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_FloatSlider
|
||||
: public EditorUIInfo_Float
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_FloatSlider, EditorUIInfo_Float);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_FloatSlider, AZ::SystemAllocator, 0);
|
||||
|
||||
float m_step;
|
||||
|
||||
EditorUIInfo_FloatSlider(float step = 1.f, float minVal = std::numeric_limits<float>::min(), float maxVal = std::numeric_limits<float>::max(), AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo_Float(minVal, maxVal, inFlags)
|
||||
, m_step(step)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_Double
|
||||
: public EditorUIInfo
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_Double, EditorUIInfo);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_Double, AZ::SystemAllocator, 0);
|
||||
|
||||
double m_minVal;
|
||||
double m_maxVal;
|
||||
|
||||
EditorUIInfo_Double(double minVal = DBL_MIN, double maxVal = DBL_MAX, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo(inFlags)
|
||||
, m_minVal(minVal)
|
||||
, m_maxVal(maxVal)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_DoubleSpinBox
|
||||
: public EditorUIInfo_Double
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_DoubleSpinBox, EditorUIInfo_Double);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_DoubleSpinBox, AZ::SystemAllocator, 0);
|
||||
|
||||
EditorUIInfo_DoubleSpinBox(double minVal = DBL_MIN, double maxVal = DBL_MAX, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo_Double(minVal, maxVal, inFlags)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_DoubleSlider
|
||||
: public EditorUIInfo_Double
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_DoubleSlider, EditorUIInfo_Double);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_DoubleSlider, AZ::SystemAllocator, 0);
|
||||
|
||||
double m_step;
|
||||
|
||||
EditorUIInfo_DoubleSlider(double step = 1.0, double minVal = DBL_MIN, double maxVal = DBL_MAX, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo_Double(minVal, maxVal, inFlags)
|
||||
, m_step(step)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_String
|
||||
: public EditorUIInfo
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_String, EditorUIInfo);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_String, AZ::SystemAllocator, 0);
|
||||
|
||||
int m_maxChars;
|
||||
|
||||
EditorUIInfo_String(int maxchars = -1, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo(inFlags)
|
||||
, m_maxChars(maxchars)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class EditorUIInfo_StringLineEdit
|
||||
: public EditorUIInfo_String
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_StringLineEdit, EditorUIInfo_String);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_StringLineEdit, AZ::SystemAllocator, 0);
|
||||
|
||||
EditorUIInfo_StringLineEdit(int maxchars = -1, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo_String(maxchars, inFlags)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
typedef AZStd::function<AZStd::string(int /*Index*/, int /*purpose*/)> DropListInfoCallback;
|
||||
|
||||
class EditorUIInfo_DropdownList
|
||||
: public EditorUIInfo
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_DropdownList, EditorUIInfo);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_DropdownList, AZ::SystemAllocator, 0);
|
||||
EditorUIInfo_DropdownList(DropListInfoCallback info, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo(inFlags)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// this function, if you supply it, will be called by the UI and other system to determine whether or not to show
|
||||
// your property at all. This allows you to make properties which only show up when certain other properties are set.
|
||||
typedef AZStd::function < bool(const AZStd::string& /*property name*/, void* /* propertyOwner */, const EditorDataContext::ToolsComponentInfo* /* component info */) >
|
||||
GroupDisplayBooleanFunction;
|
||||
|
||||
// a group is special in that it has children and uses a function to determine what to write for the group and whether to show the group
|
||||
class EditorUIInfo_Group
|
||||
: public EditorUIInfo
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_Group, EditorUIInfo);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_Group, AZ::SystemAllocator, 0);
|
||||
EditorUIInfo_Group(GroupDisplayBooleanFunction displayBoolFn = 0, AZ::u32 inFlags = 0)
|
||||
: EditorUIInfo(inFlags)
|
||||
, m_displayBoolFn(displayBoolFn)
|
||||
{
|
||||
}
|
||||
GroupDisplayBooleanFunction m_displayBoolFn;
|
||||
};
|
||||
|
||||
class EditorUIInfo_Class
|
||||
: public EditorUIInfo
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorUIInfo_Class, EditorUIInfo);
|
||||
AZ_CLASS_ALLOCATOR(EditorUIInfo_Class, AZ::SystemAllocator, 0);
|
||||
|
||||
AZ::Uuid m_classID;
|
||||
|
||||
EditorUIInfo_Class(const AZ::Uuid& classID = AZ::Uuid::CreateNull())
|
||||
: m_classID(classID)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#endif
|
||||
-1
@@ -6,7 +6,6 @@
|
||||
*
|
||||
*/
|
||||
#include "PropertyIntSliderCtrl.hxx"
|
||||
#include "DHQSlider.hxx"
|
||||
#include "PropertyQTConstants.h"
|
||||
#include <AzQtComponents/Components/Widgets/SpinBox.h>
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzToolsFramework/Debug/TraceContext.h>
|
||||
#include <AzCore/PlatformDef.h>
|
||||
|
||||
// 4251: 'QRawFont::d': class 'QExplicitlySharedDataPointer<QRawFontPrivate>' needs to have dll-interface to be used by clients of class
|
||||
// 'QRawFont' 4800: 'QTextEngine *const ': forcing value to bool 'true' or 'false' (performance warning)
|
||||
|
||||
@@ -1,55 +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 "AZAutoSizingScrollArea.hxx"
|
||||
|
||||
#include <qscrollbar.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
|
||||
AZAutoSizingScrollArea::AZAutoSizingScrollArea(QWidget* parent)
|
||||
: QScrollArea(parent)
|
||||
{
|
||||
}
|
||||
|
||||
// this code was copied from the regular implementation of the same function in QScrollArea, but converted
|
||||
// the private calls to public calls and removed the cache.
|
||||
QSize AZAutoSizingScrollArea::sizeHint() const
|
||||
{
|
||||
int initialSize = 2 * frameWidth();
|
||||
QSize sizeHint(initialSize, initialSize);
|
||||
|
||||
if (widget())
|
||||
{
|
||||
sizeHint += this->widgetResizable() ? widget()->sizeHint() : widget()->size();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we don't have a widget, we want to reserve some space visually for ourselves.
|
||||
int fontHeight = fontMetrics().height();
|
||||
sizeHint += QSize(2 * fontHeight, 2 * fontHeight);
|
||||
}
|
||||
|
||||
if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOn)
|
||||
{
|
||||
sizeHint.setWidth(sizeHint.width() + verticalScrollBar()->sizeHint().width());
|
||||
}
|
||||
|
||||
if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOn)
|
||||
{
|
||||
sizeHint.setHeight(sizeHint.height() + horizontalScrollBar()->sizeHint().height());
|
||||
}
|
||||
|
||||
return sizeHint;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "UI/UICore/moc_AZAutoSizingScrollArea.cpp"
|
||||
@@ -1,41 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AZAUTOSIZINGSCROLLAREA_HXX
|
||||
#define AZAUTOSIZINGSCROLLAREA_HXX
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QScrollArea>
|
||||
#endif
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
// This fixes a bug in QScrollArea which makes it so that you can dynamically add and remove elements from inside it, and the scroll
|
||||
// area will take up as much room as it needs to, to prevent the need for scroll bars. Scroll bars will still appear if there is not enough
|
||||
// room, but the view will scale up to eat all available room before that happens.
|
||||
|
||||
// QScrollArea was supposed to do this, but it appears to cache the size of its embedded widget on startup, and never clears that cache.
|
||||
class AZAutoSizingScrollArea
|
||||
: public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(AZAutoSizingScrollArea, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit AZAutoSizingScrollArea(QWidget* parent = 0);
|
||||
|
||||
QSize sizeHint() const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,75 +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 <QtCore/QAbstractItemModel>
|
||||
#include "ColorPickerDelegate.hxx"
|
||||
|
||||
#include <AzQtComponents/Components/Widgets/ColorPicker.h>
|
||||
#include <AzQtComponents/Utilities/Conversions.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
ColorPickerDelegate::ColorPickerDelegate(QObject* pParent)
|
||||
: QStyledItemDelegate(pParent)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget* ColorPickerDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
(void)index;
|
||||
(void)option;
|
||||
AzQtComponents::ColorPicker* ptrDialog = new AzQtComponents::ColorPicker(AzQtComponents::ColorPicker::Configuration::RGB,
|
||||
tr("Select Color"), parent);
|
||||
ptrDialog->setWindowFlags(Qt::Tool);
|
||||
return ptrDialog;
|
||||
}
|
||||
|
||||
void ColorPickerDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
|
||||
{
|
||||
AzQtComponents::ColorPicker* colorEditor = qobject_cast<AzQtComponents::ColorPicker*>(editor);
|
||||
|
||||
if (!editor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QVariant colorResult = index.data(COLOR_PICKER_ROLE);
|
||||
if (colorResult == QVariant())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QColor pickedColor = qvariant_cast<QColor>(colorResult);
|
||||
colorEditor->setCurrentColor(AzQtComponents::fromQColor(pickedColor));
|
||||
}
|
||||
|
||||
void ColorPickerDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
|
||||
{
|
||||
AzQtComponents::ColorPicker* colorEditor = qobject_cast<AzQtComponents::ColorPicker*>(editor);
|
||||
|
||||
if (!editor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QVariant colorVariant = AzQtComponents::toQColor(colorEditor->currentColor());
|
||||
model->setData(index, colorVariant, COLOR_PICKER_ROLE);
|
||||
}
|
||||
|
||||
void ColorPickerDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
(void)index;
|
||||
QRect pickerpos = option.rect;
|
||||
|
||||
pickerpos.setTopLeft(editor->parentWidget()->mapToGlobal(pickerpos.topLeft()));
|
||||
pickerpos.adjust(64, 0, 0, 0);
|
||||
editor->setGeometry(pickerpos);
|
||||
}
|
||||
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#include "UI/UICore/moc_ColorPickerDelegate.cpp"
|
||||
@@ -1,41 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef COLOR_PICKER_DELEGATE_HXX
|
||||
#define COLOR_PICKER_DELEGATE_HXX
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <QtWidgets/QStyledItemDelegate>
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
/**
|
||||
* A delegate which handles the double clicking to pop open a color picker dialog, as long as the role is COLOR_PICKER_ROLE.
|
||||
* To use it, just add a setData() and a data() function to your model which returns a QColor (or accepts one) whenever the COLOR_PICKER_ROLE is queried.
|
||||
**/
|
||||
class ColorPickerDelegate
|
||||
: public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
static const int COLOR_PICKER_ROLE = Qt::UserRole + 1;
|
||||
|
||||
AZ_CLASS_ALLOCATOR(ColorPickerDelegate, AZ::SystemAllocator, 0);
|
||||
ColorPickerDelegate(QObject* pParent);
|
||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
|
||||
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
|
||||
virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#endif //COLOR_PICKER_DELEGATE_HXX
|
||||
@@ -38,7 +38,6 @@ set(FILES
|
||||
API/EditorLevelNotificationBus.h
|
||||
API/ViewportEditorModeTrackerNotificationBus.h
|
||||
API/ViewportEditorModeTrackerNotificationBus.cpp
|
||||
API/EditorVegetationRequestsBus.h
|
||||
API/EditorPythonConsoleBus.h
|
||||
API/EditorPythonRunnerRequestsBus.h
|
||||
API/EditorPythonScriptNotificationsBus.h
|
||||
@@ -106,9 +105,6 @@ set(FILES
|
||||
Debug/TraceContextSingleStackHandler.cpp
|
||||
Debug/TraceContextMultiStackHandler.h
|
||||
Debug/TraceContextMultiStackHandler.cpp
|
||||
Debug/TraceContextBufferedFormatter.cpp
|
||||
Debug/TraceContextBufferedFormatter.inl
|
||||
Debug/TraceContextBufferedFormatter.h
|
||||
Debug/TraceContextLogFormatter.cpp
|
||||
Debug/TraceContextLogFormatter.h
|
||||
Component/EditorComponentAPIBus.h
|
||||
@@ -360,8 +356,6 @@ set(FILES
|
||||
UI/ComponentPalette/ComponentPaletteWidget.cpp
|
||||
UI/ComponentPalette/ComponentPaletteModel.hxx
|
||||
UI/ComponentPalette/ComponentPaletteModel.cpp
|
||||
UI/ComponentPalette/ComponentPaletteModelFilter.hxx
|
||||
UI/ComponentPalette/ComponentPaletteModelFilter.cpp
|
||||
UI/ComponentPalette/ComponentPaletteUtil.hxx
|
||||
UI/ComponentPalette/ComponentPaletteUtil.cpp
|
||||
UI/Layer/NameConflictWarning.hxx
|
||||
@@ -374,8 +368,6 @@ set(FILES
|
||||
UI/PropertyEditor/QtWidgetLimits.h
|
||||
UI/PropertyEditor/DHQComboBox.hxx
|
||||
UI/PropertyEditor/DHQComboBox.cpp
|
||||
UI/PropertyEditor/DHQSlider.hxx
|
||||
UI/PropertyEditor/DHQSlider.cpp
|
||||
UI/PropertyEditor/EntityIdQLabel.hxx
|
||||
UI/PropertyEditor/EntityIdQLabel.cpp
|
||||
UI/PropertyEditor/EntityIdQLineEdit.h
|
||||
@@ -406,7 +398,6 @@ set(FILES
|
||||
UI/PropertyEditor/PropertyDoubleSliderCtrl.cpp
|
||||
UI/PropertyEditor/PropertyDoubleSpinCtrl.hxx
|
||||
UI/PropertyEditor/PropertyDoubleSpinCtrl.cpp
|
||||
UI/PropertyEditor/PropertyEditor_UITypes.h
|
||||
UI/PropertyEditor/PropertyEditorAPI.h
|
||||
UI/PropertyEditor/PropertyEditorApi.cpp
|
||||
UI/PropertyEditor/PropertyEditorAPI_Internals.h
|
||||
@@ -453,10 +444,6 @@ set(FILES
|
||||
UI/Slice/SliceRelationshipWidget.hxx
|
||||
UI/UICore/AspectRatioAwarePixmapWidget.hxx
|
||||
UI/UICore/AspectRatioAwarePixmapWidget.cpp
|
||||
UI/UICore/AZAutoSizingScrollArea.hxx
|
||||
UI/UICore/AZAutoSizingScrollArea.cpp
|
||||
UI/UICore/ColorPickerDelegate.hxx
|
||||
UI/UICore/ColorPickerDelegate.cpp
|
||||
UI/UICore/ClickableLabel.hxx
|
||||
UI/UICore/ClickableLabel.cpp
|
||||
UI/UICore/IconButton.hxx
|
||||
@@ -484,11 +471,8 @@ set(FILES
|
||||
Commands/EntityStateCommand.h
|
||||
Commands/SelectionCommand.cpp
|
||||
Commands/SelectionCommand.h
|
||||
Commands/EntityTransformCommand.cpp
|
||||
Commands/EntityTransformCommand.h
|
||||
Commands/PreemptiveUndoCache.cpp
|
||||
Commands/PreemptiveUndoCache.h
|
||||
Commands/LegacyCommand.h
|
||||
Commands/BaseSliceCommand.cpp
|
||||
Commands/BaseSliceCommand.h
|
||||
Commands/SliceDetachEntityCommand.cpp
|
||||
@@ -645,8 +629,6 @@ set(FILES
|
||||
AssetBrowser/Previewer/PreviewerFrame.h
|
||||
Archive/ArchiveComponent.h
|
||||
Archive/ArchiveComponent.cpp
|
||||
Archive/NullArchiveComponent.h
|
||||
Archive/NullArchiveComponent.cpp
|
||||
Archive/ArchiveAPI.h
|
||||
UI/PropertyEditor/Model/AssetCompleterModel.h
|
||||
UI/PropertyEditor/Model/AssetCompleterModel.cpp
|
||||
|
||||
@@ -1,34 +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
|
||||
UI/LegacyFramework/MainWindowSavedState.h
|
||||
UI/LegacyFramework/MainWindowSavedState.cpp
|
||||
UI/LegacyFramework/UIFramework.hxx
|
||||
UI/LegacyFramework/UIFramework.cpp
|
||||
UI/LegacyFramework/UIFrameworkAPI.h
|
||||
UI/LegacyFramework/UIFrameworkAPI.cpp
|
||||
UI/LegacyFramework/UIFrameworkPreferences.cpp
|
||||
UI/LegacyFramework/Resources/sharedResources.qrc
|
||||
UI/LegacyFramework/Core/EditorContextBus.h
|
||||
UI/LegacyFramework/Core/EditorFrameworkAPI.h
|
||||
UI/LegacyFramework/Core/EditorFrameworkAPI.cpp
|
||||
UI/LegacyFramework/Core/EditorFrameworkApplication.h
|
||||
UI/LegacyFramework/Core/EditorFrameworkApplication.cpp
|
||||
UI/LegacyFramework/Core/IPCComponent.h
|
||||
UI/LegacyFramework/Core/IPCComponent.cpp
|
||||
UI/LegacyFramework/CustomMenus/CustomMenusAPI.h
|
||||
UI/LegacyFramework/CustomMenus/CustomMenusComponent.cpp
|
||||
UI/UICore/OverwritePromptDialog.hxx
|
||||
UI/UICore/OverwritePromptDialog.cpp
|
||||
UI/UICore/OverwritePromptDialog.ui
|
||||
UI/UICore/SaveChangesDialog.hxx
|
||||
UI/UICore/SaveChangesDialog.cpp
|
||||
UI/UICore/SaveChangesDialog.ui
|
||||
ToolsFileUtils/ToolsFileUtils_win.cpp
|
||||
)
|
||||
@@ -12,7 +12,6 @@ set(FILES
|
||||
UI/LegacyFramework/UIFramework.hxx
|
||||
UI/LegacyFramework/UIFramework.cpp
|
||||
UI/LegacyFramework/UIFrameworkAPI.h
|
||||
UI/LegacyFramework/UIFrameworkAPI.cpp
|
||||
UI/LegacyFramework/UIFrameworkPreferences.cpp
|
||||
UI/LegacyFramework/Resources/sharedResources.qrc
|
||||
UI/LegacyFramework/Core/EditorContextBus.h
|
||||
|
||||
@@ -1,165 +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
|
||||
*
|
||||
*/
|
||||
// overrides all new and delete and forwards them to the AZ allocator system
|
||||
// for tracking purposes.
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/Memory/allocatorbase.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
|
||||
void* operator new(std::size_t size, const AZ::Internal::AllocatorDummy*)
|
||||
{
|
||||
if (!AZ::AllocatorInstance<AZ::SystemAllocator>::IsReady())
|
||||
{
|
||||
AZ_Warning("MEMORY", false, "Memory is being allocated at static startup!");
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
return AZ::AllocatorInstance<AZ::SystemAllocator>::Get().Allocate(size, AZCORE_GLOBAL_NEW_ALIGNMENT, 0, "global operator aznew", 0, 0);
|
||||
}
|
||||
void* operator new[](std::size_t size, const AZ::Internal::AllocatorDummy*)
|
||||
{
|
||||
if (!AZ::AllocatorInstance<AZ::SystemAllocator>::IsReady())
|
||||
{
|
||||
AZ_Warning("MEMORY", false, "Memory is being allocated at static startup!");
|
||||
return malloc(size);
|
||||
}
|
||||
return AZ::AllocatorInstance<AZ::SystemAllocator>::Get().Allocate(size, AZCORE_GLOBAL_NEW_ALIGNMENT, 0, "global operator aznew[]", 0, 0);
|
||||
}
|
||||
void* operator new(std::size_t size, const char* fileName, int lineNum, const char* name, const AZ::Internal::AllocatorDummy*)
|
||||
{
|
||||
if (!AZ::AllocatorInstance<AZ::SystemAllocator>::IsReady())
|
||||
{
|
||||
AZ_Warning("MEMORY", false, "Memory is being allocated at static startup!");
|
||||
return malloc(size);
|
||||
}
|
||||
return AZ::AllocatorInstance<AZ::SystemAllocator>::Get().Allocate(size, AZCORE_GLOBAL_NEW_ALIGNMENT, 0, name ? name : "global operator aznew", fileName, lineNum);
|
||||
}
|
||||
void* operator new[](std::size_t size, const char* fileName, int lineNum, const char* name, const AZ::Internal::AllocatorDummy*)
|
||||
{
|
||||
if (!AZ::AllocatorInstance<AZ::SystemAllocator>::IsReady())
|
||||
{
|
||||
AZ_Warning("MEMORY", false, "Memory is being allocated at static startup!");
|
||||
return malloc(size);
|
||||
}
|
||||
return AZ::AllocatorInstance<AZ::SystemAllocator>::Get().Allocate(size, AZCORE_GLOBAL_NEW_ALIGNMENT, 0, name ? name : "global operator aznew[]", fileName, lineNum);
|
||||
}
|
||||
|
||||
void* operator new(std::size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
{
|
||||
size = 1;
|
||||
}
|
||||
|
||||
if (!AZ::AllocatorInstance<AZ::SystemAllocator>::IsReady())
|
||||
{
|
||||
AZ_Warning("MEMORY", false, "Memory is being allocated at static startup!");
|
||||
return malloc(size);
|
||||
}
|
||||
return AZ::AllocatorInstance<AZ::SystemAllocator>::Get().Allocate(size, AZCORE_GLOBAL_NEW_ALIGNMENT, 0, "global operator new", 0, 0);
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
void* operator new[](std::size_t size)
|
||||
//-----------------------------------
|
||||
{
|
||||
if (size == 0)
|
||||
{
|
||||
size = 1;
|
||||
}
|
||||
|
||||
if (!AZ::AllocatorInstance<AZ::SystemAllocator>::IsReady())
|
||||
{
|
||||
AZ_Warning("MEMORY", false, "Memory is being allocated at static startup!");
|
||||
return _aligned_malloc(size, AZCORE_GLOBAL_NEW_ALIGNMENT);
|
||||
}
|
||||
|
||||
return AZ::AllocatorInstance<AZ::SystemAllocator>::Get().Allocate(size, AZCORE_GLOBAL_NEW_ALIGNMENT, 0, "global operator new[]", 0, 0);
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
void* operator new(std::size_t size, std::nothrow_t const&)
|
||||
//-----------------------------------
|
||||
{
|
||||
return operator new(size);
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
void* operator new[](std::size_t size, std::nothrow_t const&)
|
||||
//-----------------------------------
|
||||
{
|
||||
return operator new[](size);
|
||||
}
|
||||
|
||||
// these deletes have to be created to match the new()
|
||||
// and will only happen during exception handling when allocation fails.
|
||||
void operator delete(void* ptr, const AZ::Internal::AllocatorDummy*)
|
||||
{
|
||||
if (ptr == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Get().DeAllocate(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void* ptr, const AZ::Internal::AllocatorDummy*)
|
||||
{
|
||||
if (ptr == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Get().DeAllocate(ptr);
|
||||
}
|
||||
|
||||
void operator delete(void* ptr, const char* fileName, int lineNum, const char* name, const AZ::Internal::AllocatorDummy*)
|
||||
{
|
||||
(void)fileName;
|
||||
(void)lineNum;
|
||||
(void)name;
|
||||
if (ptr == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Get().DeAllocate(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void* ptr, const char* fileName, int lineNum, const char* name, const AZ::Internal::AllocatorDummy*)
|
||||
{
|
||||
(void)fileName;
|
||||
(void)lineNum;
|
||||
(void)name;
|
||||
if (ptr == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Get().DeAllocate(ptr);
|
||||
}
|
||||
|
||||
void operator delete(void* ptr)
|
||||
{
|
||||
if (ptr == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Get().DeAllocate(ptr);
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
void operator delete[](void* ptr)
|
||||
//-----------------------------------
|
||||
{
|
||||
if (ptr == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Get().DeAllocate(ptr);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*
|
||||
*/
|
||||
#define GM_BUILD_NUMBER 263
|
||||
#define GM_BUILD_DATE "Fri 10/11/2013"
|
||||
#define GM_BUILD_TIME "11:42:40.81"
|
||||
#define GM_SOURCE_CHANGELIST 2992328
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
#include <GridMate/Carrier/Carrier.h>
|
||||
#include <GridMate/Carrier/Compressor.h>
|
||||
#include <GridMate/Carrier/Cripter.h>
|
||||
#include <GridMate/Carrier/DefaultHandshake.h>
|
||||
#include <GridMate/Carrier/DefaultTrafficControl.h>
|
||||
#include <GridMate/Carrier/Simulator.h>
|
||||
|
||||
@@ -1,25 +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
|
||||
*
|
||||
*/
|
||||
#ifndef GM_CRIPTER_INTERFACE_H
|
||||
#define GM_CRIPTER_INTERFACE_H
|
||||
|
||||
#include <GridMate/Types.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
/**
|
||||
* Traffic control interface
|
||||
*/
|
||||
class Cripter
|
||||
{
|
||||
public:
|
||||
};
|
||||
}
|
||||
|
||||
#endif // GM_CRIPTER_INTERFACE_H
|
||||
|
||||
@@ -1,23 +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
|
||||
*
|
||||
*/
|
||||
#ifndef GM_CONTAINERS_SET_H
|
||||
#define GM_CONTAINERS_SET_H
|
||||
|
||||
#include <GridMate/Memory.h>
|
||||
#include <AzCore/std/containers/set.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
template<class Key, class Compare = AZStd::less<Key>, class Allocator = SysContAlloc>
|
||||
using set = AZStd::set<Key, Compare, Allocator>;
|
||||
|
||||
template<class Key, class Compare = AZStd::less<Key>, class Allocator = SysContAlloc>
|
||||
using multiset = AZStd::multiset<Key, Compare, Allocator>;
|
||||
}
|
||||
|
||||
#endif // GM_CONTAINERS_SET_H
|
||||
@@ -1,20 +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
|
||||
*
|
||||
*/
|
||||
#ifndef GM_CONTAINERS_SLIST_H
|
||||
#define GM_CONTAINERS_SLIST_H
|
||||
|
||||
#include <GridMate/Memory.h>
|
||||
#include <AzCore/std/containers/forward_list.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
template<class T, class Allocator = SysContAlloc>
|
||||
using forward_list = AZStd::forward_list<T, Allocator>;
|
||||
}
|
||||
|
||||
#endif // GM_CONTAINERS_SLIST_H
|
||||
@@ -1,31 +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
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* \mainpage
|
||||
* Welcome to the GridMate network library.
|
||||
*
|
||||
* Check the latest \ref ReleaseNotes "release notes" for this version of GridMate.
|
||||
*
|
||||
* You can start learning by looking at the \ref Library "Library overview".
|
||||
*
|
||||
* Or if you can't wait, jump to the \ref GMExamples "code examples" to see how GridMate is used.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \page Library Library Overview
|
||||
*
|
||||
* \subpage Fundamentals "Fundamental Concepts"
|
||||
*
|
||||
* \ref GMExamples "Code examples"
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \namespace GridMate
|
||||
* \brief The main namespace for the GridMate library.
|
||||
*/
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <GridMate/GridMate.h>
|
||||
#include <GridMate/GridMateService.h>
|
||||
#include <GridMate/GridMateEventsBus.h>
|
||||
#include <GridMate/Version.h>
|
||||
|
||||
AZ_DEFINE_BUDGET(GridMate);
|
||||
|
||||
|
||||
@@ -1,93 +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
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* Provides EBus definitions for getting the utility thread tick
|
||||
*/
|
||||
#ifndef ONLINE_UTILITY_THREAD_H
|
||||
#define ONLINE_UTILITY_THREAD_H
|
||||
|
||||
#include <GridMate/EBus.h>
|
||||
#include <AzCore/std/parallel/mutex.h>
|
||||
|
||||
/**
|
||||
* IMPORTANT NOTE TO SERVICES THAT USE THE UTILITY THREAD:
|
||||
* The online service will start ticking the utility thread at construction
|
||||
* time, but you have have to let it know when you need to be ticked. This
|
||||
* is done two ways: first, send the NotifyOfNewWork event to the
|
||||
* OnlineUtilityThreadCommandBus; second, return whether you still have
|
||||
* work to do in OnlineUtilityThreadNotificationBus's event
|
||||
* IsThereUtilityThreadWork. There, however, caveats the service
|
||||
* must be aware of.
|
||||
* - For those that derive from OnlineUtilityNotificationBus::Handler,
|
||||
* do your BusConnect and BusDisConnect calls in your Init and Shutdown
|
||||
* calls, instead of at construction and destruction time. You shouldn't
|
||||
* be trying to use this utility thread outside of the time between these
|
||||
* calls to your service anyway, so this shouldn't cause any amount of
|
||||
* headache to conform to.
|
||||
* - When you call BusConnect and BusDiscconect, the online manager may
|
||||
* already be ticking that event - you may or may not receive your first
|
||||
* and/or last tick events the way you might expect, so be careful about
|
||||
* how you do you initialization and shutdown procedures.
|
||||
* - Your Init call should do as little work as possible. Set yourself up for
|
||||
* being ready to do actual initialization the first time you receive the
|
||||
* OnUtilityThreadTick event instead of doing it all in Init and blocking
|
||||
* the main thread.
|
||||
* - Your Shutdown call should abort any pending operations, including ones
|
||||
* it's already in the middle of.
|
||||
* - In your OnUtilityThreadTick event response, make sure you haven't already
|
||||
* been told to shut down. This is because the Shutdown call may have been
|
||||
* made soon after the OnUtilityThreadTick event was fired, and other
|
||||
* services took up a fair amount of time before the event got to you (with
|
||||
* the Shutdown call to your service being made between event-firing and
|
||||
* when the event reached you).
|
||||
* - Be VERY careful about Shutdown getting called before you finish
|
||||
* initializing in the utility thread (or even get a change to)! If you
|
||||
* use this utility thread, be sure to test whether you can shutdown
|
||||
* immediately after being initialized without breaking anything.
|
||||
*/
|
||||
namespace GridMate
|
||||
{
|
||||
//-------------------------------------------------------------------------
|
||||
// For ticking services that need a separate thread (outbound)
|
||||
// - BusConnect to OnlineUtilityThreadNotificationBus::Handler to receive OnUtilityThreadTick
|
||||
// - Return whether you have work left to do in IsThereWork
|
||||
//-------------------------------------------------------------------------
|
||||
class OnlineUtilityThreadNotifications
|
||||
: public GridMateEBusTraits
|
||||
{
|
||||
public:
|
||||
virtual ~OnlineUtilityThreadNotifications() {}
|
||||
|
||||
// Called on each iteration of the online manager's utility thread loop
|
||||
virtual void OnUtilityThreadTick() = 0;
|
||||
|
||||
// Return whether there's work left to do here to keep the thread from doing busy waiting
|
||||
virtual bool IsThereUtilityThreadWork() = 0;
|
||||
};
|
||||
typedef AZ::EBus<OnlineUtilityThreadNotifications> OnlineUtilityThreadNotificationBus;
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// For services that need a separate thread (inbound)
|
||||
// - Fire the NotifyOfNewWork event to notify the thread that you have a new
|
||||
// request you'd like to take care of
|
||||
//-------------------------------------------------------------------------
|
||||
class OnlineUtilityThreadCommands
|
||||
: public GridMateEBusTraits
|
||||
{
|
||||
public:
|
||||
virtual ~OnlineUtilityThreadCommands() {}
|
||||
|
||||
virtual void NotifyOfNewWork() = 0;
|
||||
};
|
||||
typedef AZ::EBus<OnlineUtilityThreadCommands> OnlineUtilityThreadCommandBus;
|
||||
//-------------------------------------------------------------------------
|
||||
} // namespace GridMate
|
||||
|
||||
#endif // ONLINE_UTILITY_THREAD_H
|
||||
@@ -1,114 +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
|
||||
*
|
||||
*/
|
||||
#ifndef GM_USER_SERVICE_TYPES_H
|
||||
#define GM_USER_SERVICE_TYPES_H
|
||||
|
||||
#include <GridMate/Types.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
/**
|
||||
* User signin state
|
||||
*/
|
||||
enum OLSSigninState
|
||||
{
|
||||
OLS_SigninUnknown,
|
||||
OLS_NotSignedIn, // There is no user signed in
|
||||
OLS_SignedInOffline, // User signed in without online capabilities
|
||||
OLS_SignedInOnline, // User signed in with online capabilities
|
||||
OLS_SigningOut, // User is in the process of signing out
|
||||
};
|
||||
|
||||
/**
|
||||
* service network state
|
||||
*/
|
||||
enum OLSOnlineState
|
||||
{
|
||||
OLS_OnlineUnknown,
|
||||
OLS_NoNetwork, // No NIC or network is unplugged
|
||||
OLS_Offline, // No online access
|
||||
OLS_Online, // Has online access
|
||||
};
|
||||
|
||||
/**
|
||||
* Supported privilege types
|
||||
*/
|
||||
enum OLSUserPrivilege
|
||||
{
|
||||
OLS_UserPrivilegeMP,
|
||||
OLS_UserPrivilegeRecordDVR,
|
||||
OLS_UserPrivilegePurchaseContent,
|
||||
OLS_UserPrivilegeVoiceChat,
|
||||
OLS_UserPrivilegeLeaderboards
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for platform dependent player id.
|
||||
*/
|
||||
struct PlayerId
|
||||
{
|
||||
PlayerId(ServiceType serviceType)
|
||||
: m_serviceType(serviceType) {}
|
||||
virtual ~PlayerId() {}
|
||||
|
||||
// Compare 2 PlayerId IDs
|
||||
virtual bool Compare(const PlayerId& userId) const = 0;
|
||||
|
||||
// Returns a printable string representation of the id.
|
||||
virtual gridmate_string ToString() const = 0;
|
||||
|
||||
ServiceType GetType() const { return m_serviceType; }
|
||||
|
||||
protected:
|
||||
ServiceType m_serviceType;
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface class for a local player/member.
|
||||
*/
|
||||
class ILocalMember
|
||||
{
|
||||
public:
|
||||
virtual ~ILocalMember() {}
|
||||
// SignIn
|
||||
virtual OLSSigninState GetSigninState() const = 0;
|
||||
|
||||
virtual const PlayerId* GetPlayerId() const = 0;
|
||||
|
||||
// Pad number / info ???
|
||||
virtual unsigned int GetControllerIndex() const = 0;
|
||||
virtual const char* GetName() const = 0;
|
||||
virtual bool IsGuest() const = 0;
|
||||
|
||||
// Friends List
|
||||
virtual void RefreshFriends() = 0;
|
||||
virtual bool IsFriendsListRefreshing() const = 0;
|
||||
virtual unsigned int GetFriendsCount() const = 0;
|
||||
virtual const char* GetFriendName(unsigned int idx) const = 0;
|
||||
virtual const PlayerId* GetFriendPlayerId(unsigned int idx) const = 0;
|
||||
virtual OLSSigninState GetFriendSigninState(unsigned int idx) const = 0;
|
||||
virtual bool IsFriendPlayingTitle(unsigned int idx) const = 0;
|
||||
virtual const char* GetFriendPresenceDetails(unsigned int idx) const = 0;
|
||||
virtual bool IsFriendsWith(const PlayerId* playerId) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generic invite structure
|
||||
* pPlatformSpecific contains the native structure used by each platform
|
||||
*/
|
||||
struct InviteInfo
|
||||
{
|
||||
InviteInfo()
|
||||
: m_localMember(nullptr) {}
|
||||
|
||||
ILocalMember* m_localMember;
|
||||
};
|
||||
} // namespace GridMate
|
||||
|
||||
#endif // GM_USER_SERVICE_TYPES_H
|
||||
#pragma once
|
||||
@@ -1,257 +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
|
||||
*
|
||||
*/
|
||||
#ifndef GM_DELTACOMPRESSED_DATASET_H
|
||||
#define GM_DELTACOMPRESSED_DATASET_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <GridMate/Serialize/DataMarshal.h>
|
||||
#include <GridMate/Replica/DataSet.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
namespace Helper
|
||||
{
|
||||
template<AZ::u32 DeltaRange>
|
||||
AZ::u8 GetQuantized(float value)
|
||||
{
|
||||
/*
|
||||
* Quantizing into a single byte, thus 255 values.
|
||||
* [-DeltaRange V +DeltaRange]
|
||||
* [0 Q 255]
|
||||
* Given V, solve for Q.
|
||||
*/
|
||||
const float quantized = (value + DeltaRange) * 255.f / (2.f * DeltaRange);
|
||||
const int clamped = AZ::GetClamp(static_cast<int>(quantized), 0, 255);
|
||||
return static_cast<AZ::u8>(clamped);
|
||||
}
|
||||
|
||||
template<AZ::u32 DeltaRange>
|
||||
float GetUnquantized(AZ::u8 quantized)
|
||||
{
|
||||
/*
|
||||
* Unquantizing from a single byte, out of 255 values.
|
||||
* [0 Q 255]
|
||||
* [-DeltaRange V +DeltaRange]
|
||||
* Given Q, solve for V.
|
||||
*/
|
||||
return 2 * DeltaRange * quantized / 255.f - DeltaRange;
|
||||
}
|
||||
|
||||
template<typename FieldType>
|
||||
struct DeltaHelper;
|
||||
|
||||
/**
|
||||
* \brief Works for integer and floating points numbers
|
||||
*/
|
||||
template<typename FieldType>
|
||||
struct DeltaHelper
|
||||
{
|
||||
static bool IsWithinDelta(const FieldType& base, const FieldType& another, AZ::u32 deltaRange)
|
||||
{
|
||||
return abs(base - another) < deltaRange;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Specialization for AZ::Vector3
|
||||
*/
|
||||
template<>
|
||||
struct DeltaHelper<AZ::Vector3>
|
||||
{
|
||||
static bool IsWithinDelta(const AZ::Vector3& base, const AZ::Vector3& another, AZ::u32 deltaRange)
|
||||
{
|
||||
const AZ::Vector3 absDiff = (base - another).GetAbs();
|
||||
return absDiff.GetX() < deltaRange && absDiff.GetY() < deltaRange && absDiff.GetZ() < deltaRange;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Packing a value into a single byte within +/- @DeltaRange
|
||||
*/
|
||||
template<AZ::u32 DeltaRange, typename FieldType>
|
||||
class DeltaMarshaller;
|
||||
|
||||
// float specialization
|
||||
template<AZ::u32 DeltaRange>
|
||||
class DeltaMarshaller<DeltaRange, float>
|
||||
{
|
||||
public:
|
||||
void Marshal(WriteBuffer& wb, const float &value)
|
||||
{
|
||||
wb.Write(Helper::GetQuantized<DeltaRange>(value));
|
||||
}
|
||||
|
||||
void Unmarshal(float& value, ReadBuffer &rb)
|
||||
{
|
||||
AZ::u8 delta;
|
||||
rb.Read(delta);
|
||||
value = Helper::GetUnquantized<DeltaRange>(delta);
|
||||
}
|
||||
};
|
||||
|
||||
// AZ::Vector3 specialization
|
||||
template<AZ::u32 DeltaRange>
|
||||
class DeltaMarshaller<DeltaRange, AZ::Vector3>
|
||||
{
|
||||
public:
|
||||
void Marshal(WriteBuffer& wb, const AZ::Vector3& value)
|
||||
{
|
||||
wb.Write(Helper::GetQuantized<DeltaRange>(value.GetX()));
|
||||
wb.Write(Helper::GetQuantized<DeltaRange>(value.GetY()));
|
||||
wb.Write(Helper::GetQuantized<DeltaRange>(value.GetZ()));
|
||||
}
|
||||
|
||||
void Unmarshal(AZ::Vector3& value, ReadBuffer& rb)
|
||||
{
|
||||
AZ::u8 delta[3];
|
||||
rb.Read(delta[0]);
|
||||
rb.Read(delta[1]);
|
||||
rb.Read(delta[2]);
|
||||
|
||||
value = AZ::Vector3(Helper::GetUnquantized<DeltaRange>(delta[0]), Helper::GetUnquantized<DeltaRange>(delta[1]), Helper::GetUnquantized<DeltaRange>(delta[2]));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Delta compressed DataSet, stateless and cacheless. Stateless - because it does not keep per-player state of any kind.
|
||||
* Cacheless - because it does not keep a history of its values.
|
||||
* This approach requires only one extra copy of a field, because the field is split into two portions: absolute and relative portions.
|
||||
* The value is always the sum of two portions. We leverage existing DataSets to omit sending the larger absolute value, thus achieving compression.
|
||||
*
|
||||
* \tparam FieldType
|
||||
* \tparam DeltaRange
|
||||
* \tparam MarshalerType
|
||||
* \tparam DeltaMarshalerType
|
||||
*/
|
||||
template<typename FieldType, AZ::u32 DeltaRange, typename MarshalerType = Marshaler<FieldType>, typename DeltaMarshalerType = DeltaMarshaller<DeltaRange, FieldType>>
|
||||
class DeltaCompressedDataSet
|
||||
{
|
||||
public:
|
||||
virtual ~DeltaCompressedDataSet() = default;
|
||||
|
||||
template<class C, void (C::* FuncPtr)(const FieldType&, const TimeContext&)>
|
||||
class BindInterface;
|
||||
|
||||
/**
|
||||
Constructs a DataSet.
|
||||
**/
|
||||
explicit DeltaCompressedDataSet(const char* debugName, const FieldType& value = FieldType())
|
||||
: m_absolutePortion(debugName, value)
|
||||
, m_relativePortion(debugName)
|
||||
{
|
||||
static_assert(DeltaRange > 0, "Delta range cannot be zero!");
|
||||
|
||||
// We need to intercept changes to our two DataSets, in order to calculate the combined value and report back to Replica Chunk on our time.
|
||||
m_absolutePortion.SetDispatchOverride([this](const TimeContext& tc) {OnAbsolutePortionChanged(tc); });
|
||||
m_relativePortion.SetDispatchOverride([this](const TimeContext& tc) {OnRelativePortionChanged(tc); });
|
||||
}
|
||||
|
||||
/**
|
||||
Modify the DataSet. Call this on the Primary node to change the data,
|
||||
which will be propagated to all proxies.
|
||||
**/
|
||||
void Set(const FieldType& v)
|
||||
{
|
||||
m_combinedValue = v;
|
||||
|
||||
if (Helper::DeltaHelper<FieldType>::IsWithinDelta(m_absolutePortion.Get(), v, DeltaRange))
|
||||
{
|
||||
// within bounds, so only the relative portion needs to be updated
|
||||
m_relativePortion.Set(v - m_absolutePortion.Get());
|
||||
}
|
||||
else
|
||||
{
|
||||
// relative out of range, reset absolute
|
||||
m_absolutePortion.Set(v);
|
||||
m_relativePortion.Set(static_cast<FieldType>(0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the current value of the DataSet.
|
||||
**/
|
||||
const FieldType& Get() const
|
||||
{
|
||||
return m_combinedValue;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void OnAbsolutePortionChanged(const TimeContext& /*tc*/)
|
||||
{
|
||||
m_combinedValue = m_absolutePortion.Get() + m_relativePortion.Get();
|
||||
}
|
||||
|
||||
virtual void OnRelativePortionChanged(const TimeContext& /*tc*/)
|
||||
{
|
||||
m_combinedValue = m_absolutePortion.Get() + m_relativePortion.Get();
|
||||
}
|
||||
|
||||
private:
|
||||
DataSet<FieldType, MarshalerType> m_absolutePortion;
|
||||
DataSet<FieldType, DeltaMarshalerType> m_relativePortion;
|
||||
FieldType m_combinedValue; // the latest value on either primary or proxy
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Declares a DeltaCompressedDataSet with an event handler that is called when the value is changed.
|
||||
Use BindInterface<Class, FuncPtr> to dispatch to a method on the ReplicaChunk's
|
||||
ReplicaChunkInterface event handler instance.
|
||||
**/
|
||||
template<typename FieldType, AZ::u32 DeltaRange, typename MarshalerType, typename DeltaMarshalerType>
|
||||
template<class C, void (C::* FuncPtr)(const FieldType&, const TimeContext&)>
|
||||
class DeltaCompressedDataSet<FieldType, DeltaRange, MarshalerType, DeltaMarshalerType>::BindInterface
|
||||
: public DeltaCompressedDataSet<FieldType, DeltaRange, MarshalerType, DeltaMarshalerType>
|
||||
{
|
||||
public:
|
||||
explicit BindInterface(const char* debugName) : DeltaCompressedDataSet(debugName) { }
|
||||
|
||||
protected:
|
||||
void OnAbsolutePortionChanged(const GridMate::TimeContext& tc) override
|
||||
{
|
||||
DeltaCompressedDataSet::OnAbsolutePortionChanged(tc);
|
||||
|
||||
m_lastUpdateTime = m_absolutePortion.GetLastUpdateTime();
|
||||
if (m_relativePortion.GetLastUpdateTime() < m_lastUpdateTime)
|
||||
{
|
||||
// relative portion wasn't updated, so its callback won't be invoked this tick, therefore we need to dispatch change event now
|
||||
DispatchChangedEvent(tc);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRelativePortionChanged(const GridMate::TimeContext& tc) override
|
||||
{
|
||||
DeltaCompressedDataSet::OnRelativePortionChanged(tc);
|
||||
|
||||
m_lastUpdateTime = m_relativePortion.GetLastUpdateTime();
|
||||
// Assuming that relative portion DataSet is dispatched after absolute portion by construction in DeltaCompressedDataSet
|
||||
DispatchChangedEvent(tc);
|
||||
}
|
||||
|
||||
void DispatchChangedEvent(const TimeContext& tc)
|
||||
{
|
||||
AZ_Assert(m_relativePortion.GetReplicaChunkBase(), "DataSets should be attached to replica chunks!");
|
||||
|
||||
if (C* c = static_cast<C*>(m_relativePortion.GetReplicaChunkBase()->GetHandler()))
|
||||
{
|
||||
const TimeContext changeTime{ m_lastUpdateTime, m_lastUpdateTime - (tc.m_realTime - tc.m_localTime) };
|
||||
(*c.*FuncPtr)(Get(), changeTime);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
AZ::u32 m_lastUpdateTime = 0; // the latest update time among m_absolutePortion and m_relativePortion
|
||||
};
|
||||
//-----------------------------------------------------------------------------
|
||||
} // namespace GridMate
|
||||
|
||||
#endif // GM_DELTACOMPRESSED_DATASET_H
|
||||
@@ -1,421 +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 <GridMate/Replica/Interest/BitmaskInterestHandler.h>
|
||||
|
||||
#include <GridMate/Replica/Interpolators.h>
|
||||
#include <GridMate/Replica/Replica.h>
|
||||
#include <GridMate/Replica/ReplicaFunctions.h>
|
||||
#include <GridMate/Replica/ReplicaMgr.h>
|
||||
|
||||
#include <GridMate/Replica/Interest/InterestManager.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
|
||||
void BitmaskInterestChunk::OnReplicaActivate(const ReplicaContext& rc)
|
||||
{
|
||||
m_interestHandler = static_cast<BitmaskInterestHandler*>(rc.m_rm->GetUserContext(AZ_CRC("BitmaskInterestHandler", 0x5bf5d75b)));
|
||||
AZ_Warning("GridMate", m_interestHandler != nullptr, "No bitmask interest handler in the user context");
|
||||
if (m_interestHandler)
|
||||
{
|
||||
m_interestHandler->OnNewRulesChunk(this, rc.m_peer);
|
||||
}
|
||||
}
|
||||
|
||||
void BitmaskInterestChunk::OnReplicaDeactivate(const ReplicaContext& rc)
|
||||
{
|
||||
if (m_interestHandler)
|
||||
{
|
||||
// even if rc.m_peer is null, we still need to call OnDeleteRulesChunk so that the interest handler can clear m_rulesReplica
|
||||
m_interestHandler->OnDeleteRulesChunk(this, rc.m_peer);
|
||||
}
|
||||
}
|
||||
|
||||
bool BitmaskInterestChunk::AddRuleFn(RuleNetworkId netId, InterestBitmask bits, const RpcContext& ctx)
|
||||
{
|
||||
if (IsProxy())
|
||||
{
|
||||
auto rulePtr = m_interestHandler->CreateRule(ctx.m_sourcePeer);
|
||||
rulePtr->Set(bits);
|
||||
m_rules.insert(AZStd::make_pair(netId, rulePtr));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BitmaskInterestChunk::RemoveRuleFn(RuleNetworkId netId, const RpcContext&)
|
||||
{
|
||||
if (IsProxy())
|
||||
{
|
||||
m_rules.erase(netId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BitmaskInterestChunk::UpdateRuleFn(RuleNetworkId netId, InterestBitmask bits, const RpcContext&)
|
||||
{
|
||||
if (IsProxy())
|
||||
{
|
||||
auto it = m_rules.find(netId);
|
||||
if (it != m_rules.end())
|
||||
{
|
||||
it->second->Set(bits);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BitmaskInterestChunk::AddRuleForPeerFn(RuleNetworkId netId, PeerId peerId, InterestBitmask bitmask, const RpcContext&)
|
||||
{
|
||||
BitmaskInterestChunk::Ptr peerChunk = m_interestHandler->FindRulesChunkByPeerId(peerId);
|
||||
if (peerChunk)
|
||||
{
|
||||
auto it = peerChunk->m_rules.find(netId);
|
||||
if (it == peerChunk->m_rules.end())
|
||||
{
|
||||
auto rulePtr = m_interestHandler->CreateRule(peerId);
|
||||
peerChunk->m_rules.insert(AZStd::make_pair(netId, rulePtr));
|
||||
rulePtr->Set(bitmask);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
* BitmaskInterest
|
||||
*/
|
||||
BitmaskInterest::BitmaskInterest(BitmaskInterestHandler* handler)
|
||||
: m_handler(handler)
|
||||
, m_bits(0)
|
||||
{
|
||||
AZ_Assert(m_handler, "Invalid interest handler");
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
* BitmaskInterestRule
|
||||
*/
|
||||
void BitmaskInterestRule::Set(InterestBitmask newBitmask)
|
||||
{
|
||||
m_bits = newBitmask;
|
||||
m_handler->UpdateRule(this);
|
||||
}
|
||||
|
||||
void BitmaskInterestRule::Destroy()
|
||||
{
|
||||
m_handler->DestroyRule(this);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
* BitmaskInterestAttribute
|
||||
*/
|
||||
void BitmaskInterestAttribute::Set(InterestBitmask newBitmask)
|
||||
{
|
||||
m_bits = newBitmask;
|
||||
m_handler->UpdateAttribute(this);
|
||||
}
|
||||
|
||||
void BitmaskInterestAttribute::Destroy()
|
||||
{
|
||||
m_handler->DestroyAttribute(this);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
* BitmaskInterestHandler
|
||||
*/
|
||||
BitmaskInterestHandler::BitmaskInterestHandler()
|
||||
: m_im(nullptr)
|
||||
, m_rm(nullptr)
|
||||
, m_lastRuleNetId(0)
|
||||
, m_rulesReplica(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
BitmaskInterestRule::Ptr BitmaskInterestHandler::CreateRule(PeerId peerId)
|
||||
{
|
||||
BitmaskInterestRule* rulePtr = aznew BitmaskInterestRule(this, peerId, GetNewRuleNetId());
|
||||
m_rules.insert(rulePtr);
|
||||
|
||||
if (peerId == m_rm->GetLocalPeerId() && m_rulesReplica)
|
||||
{
|
||||
m_rulesReplica->AddRuleRpc(rulePtr->GetNetworkId(), rulePtr->Get());
|
||||
m_localRules.insert(rulePtr);
|
||||
}
|
||||
|
||||
return rulePtr;
|
||||
}
|
||||
|
||||
void BitmaskInterestHandler::FreeRule(BitmaskInterestRule* rule)
|
||||
{
|
||||
//TODO: should be pool-allocated
|
||||
m_rules.erase(rule);
|
||||
delete rule;
|
||||
}
|
||||
|
||||
void BitmaskInterestHandler::DestroyRule(BitmaskInterestRule* rule)
|
||||
{
|
||||
if (m_rm && rule->GetPeerId() == m_rm->GetLocalPeerId() && m_rulesReplica)
|
||||
{
|
||||
m_rulesReplica->RemoveRuleRpc(rule->GetNetworkId());
|
||||
}
|
||||
|
||||
rule->m_bits = 0;
|
||||
m_dirtyRules.insert(rule);
|
||||
m_localRules.erase(rule);
|
||||
}
|
||||
|
||||
void BitmaskInterestHandler::UpdateRule(BitmaskInterestRule* rule)
|
||||
{
|
||||
if (m_rm && m_rulesReplica && rule->GetPeerId() == m_rm->GetLocalPeerId())
|
||||
{
|
||||
m_rulesReplica->UpdateRuleRpc(rule->GetNetworkId(), rule->Get());
|
||||
}
|
||||
|
||||
m_dirtyRules.insert(rule);
|
||||
}
|
||||
|
||||
BitmaskInterestAttribute::Ptr BitmaskInterestHandler::CreateAttribute(ReplicaId replicaId)
|
||||
{
|
||||
auto ptr = aznew BitmaskInterestAttribute(this, replicaId);
|
||||
m_attrs.insert(ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void BitmaskInterestHandler::FreeAttribute(BitmaskInterestAttribute* attrib)
|
||||
{
|
||||
//TODO: should be pool-allocated
|
||||
m_attrs.erase(attrib);
|
||||
delete attrib;
|
||||
}
|
||||
|
||||
void BitmaskInterestHandler::DestroyAttribute(BitmaskInterestAttribute* attrib)
|
||||
{
|
||||
attrib->m_bits = 0;
|
||||
m_dirtyAttributes.insert(attrib);
|
||||
}
|
||||
|
||||
void BitmaskInterestHandler::UpdateAttribute(BitmaskInterestAttribute* attrib)
|
||||
{
|
||||
m_dirtyAttributes.insert(attrib);
|
||||
}
|
||||
|
||||
void BitmaskInterestHandler::OnNewRulesChunk(BitmaskInterestChunk::Ptr chunk, ReplicaPeer* peer)
|
||||
{
|
||||
if (chunk != m_rulesReplica) // non-local
|
||||
{
|
||||
m_peerChunks.insert(AZStd::make_pair(peer->GetId(), chunk));
|
||||
|
||||
for (auto& rule : m_localRules)
|
||||
{
|
||||
chunk->AddRuleForPeerRpc(rule->GetNetworkId(), rule->GetPeerId(), rule->Get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BitmaskInterestHandler::OnDeleteRulesChunk(BitmaskInterestChunk::Ptr chunk, ReplicaPeer* peer)
|
||||
{
|
||||
AZ_UNUSED(chunk);
|
||||
m_rulesReplica = nullptr;
|
||||
|
||||
if (peer)
|
||||
{
|
||||
m_peerChunks.erase(peer->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
RuleNetworkId BitmaskInterestHandler::GetNewRuleNetId()
|
||||
{
|
||||
++m_lastRuleNetId;
|
||||
if (m_rulesReplica)
|
||||
{
|
||||
return m_rulesReplica->GetReplicaId() | (static_cast<AZ::u64>(m_lastRuleNetId) << 32);
|
||||
}
|
||||
|
||||
return (static_cast<AZ::u64>(m_lastRuleNetId) << 32);
|
||||
}
|
||||
|
||||
BitmaskInterestChunk::Ptr BitmaskInterestHandler::FindRulesChunkByPeerId(PeerId peerId)
|
||||
{
|
||||
auto it = m_peerChunks.find(peerId);
|
||||
if (it == m_peerChunks.end())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
const InterestMatchResult& BitmaskInterestHandler::GetLastResult()
|
||||
{
|
||||
return m_resultCache;
|
||||
}
|
||||
|
||||
void BitmaskInterestHandler::Update()
|
||||
{
|
||||
m_resultCache.clear();
|
||||
|
||||
for (BitmaskInterestRule* rule : m_dirtyRules)
|
||||
{
|
||||
InterestBitmask j = 1;
|
||||
for (size_t i = 0; i < k_numGroups; ++i, j <<= 1)
|
||||
{
|
||||
auto ruleIt = m_ruleGroups[i].find(rule);
|
||||
bool isMatch = !!(rule->m_bits & j);
|
||||
if (isMatch && ruleIt == m_ruleGroups[i].end())
|
||||
{
|
||||
m_ruleGroups[i].insert(rule);
|
||||
|
||||
// recalculate all the attributes in this bucket
|
||||
for (BitmaskInterestAttribute* attr : m_attrGroups[i])
|
||||
{
|
||||
m_dirtyAttributes.insert(attr);
|
||||
}
|
||||
}
|
||||
else if (!isMatch && ruleIt != m_ruleGroups[i].end())
|
||||
{
|
||||
m_ruleGroups[i].erase(ruleIt);
|
||||
|
||||
// recalculate all the attributes in this bucket
|
||||
for (BitmaskInterestAttribute* attr : m_attrGroups[i])
|
||||
{
|
||||
m_dirtyAttributes.insert(attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rule->IsDeleted())
|
||||
{
|
||||
FreeRule(rule);
|
||||
}
|
||||
}
|
||||
|
||||
m_dirtyRules.clear();
|
||||
|
||||
for (BitmaskInterestAttribute* attr : m_dirtyAttributes)
|
||||
{
|
||||
InterestBitmask j = 1;
|
||||
for (size_t i = 0; i < k_numGroups; ++i, j <<= 1)
|
||||
{
|
||||
auto attrIt = m_attrGroups[i].find(attr);
|
||||
bool isMatch = !!(attr->m_bits & j);
|
||||
if (isMatch && attrIt == m_attrGroups[i].end())
|
||||
{
|
||||
m_attrGroups[i].insert(attr);
|
||||
}
|
||||
else if (!isMatch && attrIt != m_attrGroups[i].end())
|
||||
{
|
||||
m_attrGroups[i].erase(attrIt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (BitmaskInterestAttribute* attr : m_dirtyAttributes)
|
||||
{
|
||||
auto repIt = m_resultCache.insert(attr->GetReplicaId());
|
||||
|
||||
InterestBitmask j = 1;
|
||||
for (size_t i = 0; i < k_numGroups; ++i, j <<= 1)
|
||||
{
|
||||
if (!!(attr->m_bits & j))
|
||||
{
|
||||
for (BitmaskInterestRule* rule : m_ruleGroups[i])
|
||||
{
|
||||
repIt.first->second.insert(rule->GetPeerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (attr->IsDeleted())
|
||||
{
|
||||
FreeAttribute(attr);
|
||||
}
|
||||
}
|
||||
|
||||
m_dirtyAttributes.clear();
|
||||
}
|
||||
|
||||
void BitmaskInterestHandler::OnRulesHandlerRegistered(InterestManager* manager)
|
||||
{
|
||||
AZ_Assert(m_im == nullptr, "Handler is already registered with manager %p (%p)\n", m_im, manager);
|
||||
AZ_Assert(m_rulesReplica == nullptr, "Rules replica is already created\n");
|
||||
AZ_TracePrintf("GridMate", "Bitmask interest handler is registered\n");
|
||||
m_im = manager;
|
||||
m_rm = m_im->GetReplicaManager();
|
||||
m_rm->RegisterUserContext(AZ_CRC("BitmaskInterestHandler", 0x5bf5d75b), this);
|
||||
|
||||
auto replica = Replica::CreateReplica("BitmaskInterestHandlerRules");
|
||||
m_rulesReplica = CreateAndAttachReplicaChunk<BitmaskInterestChunk>(replica);
|
||||
m_rm->AddPrimary(replica);
|
||||
}
|
||||
|
||||
void BitmaskInterestHandler::OnRulesHandlerUnregistered(InterestManager* manager)
|
||||
{
|
||||
(void)manager;
|
||||
|
||||
AZ_Assert(m_im == manager, "Handler was not registered with manager %p (%p)\n", manager, m_im);
|
||||
AZ_TracePrintf("GridMate", "Bitmask interest handler is unregistered\n");
|
||||
|
||||
if (m_rulesReplica)
|
||||
{
|
||||
m_rulesReplica->m_rules.clear();
|
||||
m_rulesReplica->m_interestHandler = nullptr;
|
||||
}
|
||||
|
||||
for (auto& chunk : m_peerChunks)
|
||||
{
|
||||
chunk.second->m_rules.clear();
|
||||
chunk.second->m_interestHandler = nullptr;
|
||||
}
|
||||
|
||||
m_rulesReplica = nullptr;
|
||||
m_im = nullptr;
|
||||
m_rm->UnregisterUserContext(AZ_CRC("BitmaskInterestHandler", 0x5bf5d75b));
|
||||
m_rm = nullptr;
|
||||
|
||||
m_peerChunks.clear();
|
||||
m_localRules.clear();
|
||||
|
||||
for (auto& a : m_attrs)
|
||||
{
|
||||
delete a;
|
||||
}
|
||||
|
||||
for (auto& r : m_rules)
|
||||
{
|
||||
delete r;
|
||||
}
|
||||
|
||||
m_dirtyAttributes.clear();
|
||||
m_dirtyRules.clear();
|
||||
|
||||
for (auto& group : m_attrGroups)
|
||||
{
|
||||
group.clear();
|
||||
}
|
||||
|
||||
for (auto& group : m_ruleGroups)
|
||||
{
|
||||
group.clear();
|
||||
}
|
||||
|
||||
m_resultCache.clear();
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
@@ -1,237 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GM_REPLICA_BITMASKINTERESTHANDLER_H
|
||||
#define GM_REPLICA_BITMASKINTERESTHANDLER_H
|
||||
|
||||
#include <GridMate/Replica/RemoteProcedureCall.h>
|
||||
#include <GridMate/Replica/ReplicaChunk.h>
|
||||
#include <GridMate/Replica/Interest/RulesHandler.h>
|
||||
#include <GridMate/Serialize/UtilityMarshal.h>
|
||||
|
||||
#include <GridMate/Containers/vector.h>
|
||||
#include <GridMate/Containers/unordered_set.h>
|
||||
#include <AzCore/std/containers/array.h>
|
||||
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
class BitmaskInterestHandler;
|
||||
using InterestBitmask = AZ::u32;
|
||||
|
||||
/*
|
||||
* Base interest
|
||||
*/
|
||||
class BitmaskInterest
|
||||
{
|
||||
friend class BitmaskInterestHandler;
|
||||
|
||||
public:
|
||||
InterestBitmask Get() const { return m_bits; }
|
||||
|
||||
protected:
|
||||
explicit BitmaskInterest(BitmaskInterestHandler* handler);
|
||||
|
||||
BitmaskInterestHandler* m_handler;
|
||||
InterestBitmask m_bits;
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
* Bitmask rule
|
||||
*/
|
||||
class BitmaskInterestRule
|
||||
: public InterestRule
|
||||
, public BitmaskInterest
|
||||
{
|
||||
friend class BitmaskInterestHandler;
|
||||
|
||||
public:
|
||||
using Ptr = AZStd::intrusive_ptr<BitmaskInterestRule>;
|
||||
|
||||
GM_CLASS_ALLOCATOR(BitmaskInterestRule);
|
||||
|
||||
void Set(InterestBitmask newBitmask);
|
||||
|
||||
private:
|
||||
|
||||
// Intrusive ptr
|
||||
template<class T>
|
||||
friend struct AZStd::IntrusivePtrCountPolicy;
|
||||
unsigned int m_refCount = 0;
|
||||
AZ_FORCE_INLINE void add_ref() { ++m_refCount; }
|
||||
AZ_FORCE_INLINE void release() { --m_refCount; if (!m_refCount) Destroy(); }
|
||||
AZ_FORCE_INLINE bool IsDeleted() const { return m_refCount == 0; }
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BitmaskInterestRule(BitmaskInterestHandler* handler, PeerId peerId, RuleNetworkId netId)
|
||||
: InterestRule(peerId, netId)
|
||||
, BitmaskInterest(handler)
|
||||
{}
|
||||
|
||||
void Destroy();
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
* Bitmask attribute
|
||||
*/
|
||||
class BitmaskInterestAttribute
|
||||
: public InterestAttribute
|
||||
, public BitmaskInterest
|
||||
{
|
||||
friend class BitmaskInterestHandler;
|
||||
template<class T> friend class InterestPtr;
|
||||
|
||||
public:
|
||||
using Ptr = AZStd::intrusive_ptr<BitmaskInterestAttribute>;
|
||||
|
||||
GM_CLASS_ALLOCATOR(BitmaskInterestAttribute);
|
||||
|
||||
void Set(InterestBitmask newBitmask);
|
||||
|
||||
private:
|
||||
|
||||
// Intrusive ptr
|
||||
template<class T>
|
||||
friend struct AZStd::IntrusivePtrCountPolicy;
|
||||
unsigned int m_refCount = 0;
|
||||
AZ_FORCE_INLINE void add_ref() { ++m_refCount; }
|
||||
AZ_FORCE_INLINE void release() { Destroy(); }
|
||||
AZ_FORCE_INLINE bool IsDeleted() const { return m_refCount == 0; }
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BitmaskInterestAttribute(BitmaskInterestHandler* handler, ReplicaId repId)
|
||||
: InterestAttribute(repId)
|
||||
, BitmaskInterest(handler)
|
||||
{}
|
||||
|
||||
void Destroy();
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class BitmaskInterestChunk
|
||||
: public ReplicaChunk
|
||||
{
|
||||
public:
|
||||
GM_CLASS_ALLOCATOR(BitmaskInterestChunk);
|
||||
|
||||
BitmaskInterestChunk()
|
||||
: AddRuleRpc("AddRule")
|
||||
, RemoveRuleRpc("RemoveRule")
|
||||
, UpdateRuleRpc("UpdateRule")
|
||||
, AddRuleForPeerRpc("AddRuleForPeerRpc")
|
||||
, m_interestHandler(nullptr)
|
||||
{}
|
||||
|
||||
typedef AZStd::intrusive_ptr<BitmaskInterestChunk> Ptr;
|
||||
bool IsReplicaMigratable() override { return false; }
|
||||
bool IsBroadcast() override { return true; }
|
||||
static const char* GetChunkName() { return "BitmaskInterestChunk"; }
|
||||
|
||||
void OnReplicaActivate(const ReplicaContext& rc) override;
|
||||
void OnReplicaDeactivate(const ReplicaContext& rc) override;
|
||||
|
||||
bool AddRuleFn(RuleNetworkId netId, InterestBitmask bits, const RpcContext& ctx);
|
||||
bool RemoveRuleFn(RuleNetworkId netId, const RpcContext&);
|
||||
bool UpdateRuleFn(RuleNetworkId netId, InterestBitmask bits, const RpcContext&);
|
||||
bool AddRuleForPeerFn(RuleNetworkId netId, PeerId peerId, InterestBitmask bitmask, const RpcContext&);
|
||||
|
||||
Rpc<RpcArg<RuleNetworkId>, RpcArg<InterestBitmask>>::BindInterface<BitmaskInterestChunk, &BitmaskInterestChunk::AddRuleFn> AddRuleRpc;
|
||||
Rpc<RpcArg<RuleNetworkId>>::BindInterface<BitmaskInterestChunk, &BitmaskInterestChunk::RemoveRuleFn> RemoveRuleRpc;
|
||||
Rpc<RpcArg<RuleNetworkId>, RpcArg<InterestBitmask>>::BindInterface<BitmaskInterestChunk, &BitmaskInterestChunk::UpdateRuleFn> UpdateRuleRpc;
|
||||
|
||||
Rpc<RpcArg<RuleNetworkId>, RpcArg<PeerId>, RpcArg<InterestBitmask>>::BindInterface<BitmaskInterestChunk, &BitmaskInterestChunk::AddRuleForPeerFn> AddRuleForPeerRpc;
|
||||
|
||||
unordered_map<RuleNetworkId, BitmaskInterestRule::Ptr> m_rules;
|
||||
BitmaskInterestHandler* m_interestHandler;
|
||||
};
|
||||
|
||||
/*
|
||||
* Rules handler
|
||||
*/
|
||||
class BitmaskInterestHandler
|
||||
: public BaseRulesHandler
|
||||
{
|
||||
friend class BitmaskInterestRule;
|
||||
friend class BitmaskInterestAttribute;
|
||||
friend class BitmaskInterestChunk;
|
||||
|
||||
public:
|
||||
|
||||
GM_CLASS_ALLOCATOR(BitmaskInterestHandler);
|
||||
|
||||
BitmaskInterestHandler();
|
||||
|
||||
// Creates new bitmask rule and binds it to the peer
|
||||
BitmaskInterestRule::Ptr CreateRule(PeerId peerId);
|
||||
|
||||
// Creates new bitmask attribute and binds it to the replica
|
||||
BitmaskInterestAttribute::Ptr CreateAttribute(ReplicaId replicaId);
|
||||
|
||||
// Calculates rules and attributes matches
|
||||
void Update() override;
|
||||
|
||||
// Returns last recalculated results
|
||||
const InterestMatchResult& GetLastResult() override;
|
||||
|
||||
InterestManager* GetManager() override { return m_im; }
|
||||
private:
|
||||
|
||||
// BaseRulesHandler
|
||||
void OnRulesHandlerRegistered(InterestManager* manager) override;
|
||||
void OnRulesHandlerUnregistered(InterestManager* manager) override;
|
||||
|
||||
void DestroyRule(BitmaskInterestRule* rule);
|
||||
void FreeRule(BitmaskInterestRule* rule);
|
||||
void UpdateRule(BitmaskInterestRule* rule);
|
||||
|
||||
void DestroyAttribute(BitmaskInterestAttribute* attrib);
|
||||
void FreeAttribute(BitmaskInterestAttribute* attrib);
|
||||
void UpdateAttribute(BitmaskInterestAttribute* attrib);
|
||||
|
||||
|
||||
void OnNewRulesChunk(BitmaskInterestChunk::Ptr chunk, ReplicaPeer* peer);
|
||||
void OnDeleteRulesChunk(BitmaskInterestChunk::Ptr chunk, ReplicaPeer* peer);
|
||||
|
||||
RuleNetworkId GetNewRuleNetId();
|
||||
|
||||
BitmaskInterestChunk::Ptr FindRulesChunkByPeerId(PeerId peerId);
|
||||
|
||||
typedef unordered_set<BitmaskInterestAttribute*> AttributeSet;
|
||||
typedef unordered_set<BitmaskInterestRule*> RuleSet;
|
||||
static const size_t k_numGroups = sizeof(InterestBitmask) * CHAR_BIT;
|
||||
|
||||
InterestManager* m_im;
|
||||
ReplicaManager* m_rm;
|
||||
|
||||
AZ::u32 m_lastRuleNetId;
|
||||
|
||||
unordered_map<PeerId, BitmaskInterestChunk::Ptr> m_peerChunks;
|
||||
|
||||
RuleSet m_localRules;
|
||||
|
||||
AttributeSet m_dirtyAttributes;
|
||||
RuleSet m_dirtyRules;
|
||||
|
||||
AZStd::array<AttributeSet, k_numGroups> m_attrGroups;
|
||||
AZStd::array<RuleSet, k_numGroups> m_ruleGroups;
|
||||
|
||||
InterestMatchResult m_resultCache;
|
||||
|
||||
BitmaskInterestChunk* m_rulesReplica;
|
||||
|
||||
AttributeSet m_attrs;
|
||||
RuleSet m_rules;
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,132 +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
|
||||
*
|
||||
*/
|
||||
#ifndef GM_REPLICA_INTERESTDEFS_H
|
||||
#define GM_REPLICA_INTERESTDEFS_H
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <GridMate/Replica/ReplicaCommon.h>
|
||||
#include <GridMate/Containers/vector.h>
|
||||
#include <GridMate/Containers/unordered_set.h>
|
||||
#include <GridMate/Containers/unordered_map.h>
|
||||
#include <AzCore/std/sort.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
/**
|
||||
* Bitmask used internally in InterestManager to check which handler is responsible for a given interest match
|
||||
*/
|
||||
using InterestHandlerSlot = AZ::u32;
|
||||
|
||||
/**
|
||||
* Rule identifier (unique within the session)
|
||||
*/
|
||||
using RuleNetworkId = AZ::u64;
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using InterestPeerSet = unordered_set<PeerId>;
|
||||
|
||||
/**
|
||||
* InterestMatchResult: a structure to gather new matches from handlers.
|
||||
* Passed to handler within matching context when handler's Match method is invoked.
|
||||
* User must fill the structure with changes that handler recalculated.
|
||||
*
|
||||
* Specifically, the changes should have all the replicas that had their list of associated peers modified.
|
||||
* Each entry replica - new full list of associated peers.
|
||||
*/
|
||||
class InterestMatchResult : public unordered_map<ReplicaId, InterestPeerSet>
|
||||
{
|
||||
public:
|
||||
using unordered_map::unordered_map;
|
||||
|
||||
/*
|
||||
* An expensive debug trace helper, prints sorted mapping between replica id's and associated peers.
|
||||
*/
|
||||
void PrintMatchResult(const char* name) const;
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Base class for interest rules
|
||||
*/
|
||||
class InterestRule
|
||||
{
|
||||
public:
|
||||
explicit InterestRule(PeerId peerId, RuleNetworkId netId)
|
||||
: m_peerId(peerId)
|
||||
, m_netId(netId)
|
||||
{}
|
||||
|
||||
PeerId GetPeerId() const { return m_peerId; }
|
||||
RuleNetworkId GetNetworkId() const { return m_netId; }
|
||||
|
||||
protected:
|
||||
PeerId m_peerId; ///< the peer this rule is bound to
|
||||
RuleNetworkId m_netId; ///< network id
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Base class for interest attributes
|
||||
*/
|
||||
class InterestAttribute
|
||||
{
|
||||
public:
|
||||
explicit InterestAttribute(ReplicaId replicaId)
|
||||
: m_replicaId(replicaId)
|
||||
{}
|
||||
|
||||
ReplicaId GetReplicaId() const { return m_replicaId; }
|
||||
|
||||
protected:
|
||||
ReplicaId m_replicaId; ///< Replica id this attribute is bound to
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AZ_DEBUG_BUILD)
|
||||
AZ_INLINE void InterestMatchResult::PrintMatchResult(const char*) const {}
|
||||
#else
|
||||
AZ_INLINE void InterestMatchResult::PrintMatchResult(const char* name) const
|
||||
{
|
||||
if (size() == 0)
|
||||
{
|
||||
AZ_TracePrintf("GridMate", "InterestMatchResult %s empty \n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
AZStd::vector<value_type> sorted;
|
||||
for (auto& r : *this)
|
||||
{
|
||||
sorted.push_back(r);
|
||||
}
|
||||
|
||||
auto sortByReplicaId = [](const value_type& one, const value_type& another)
|
||||
{
|
||||
return one.first < another.first;
|
||||
};
|
||||
AZStd::sort(sorted.begin(), sorted.end(), sortByReplicaId);
|
||||
|
||||
AZ_TracePrintf("GridMate", "InterestMatchResult %s \n", name);
|
||||
for (auto& match : sorted)
|
||||
{
|
||||
auto repId = match.first;
|
||||
AZ_TracePrintf("GridMate", "\t\t\t for repId %d ", repId);
|
||||
|
||||
// unsorted list of peers
|
||||
for (auto& peerId : match.second)
|
||||
{
|
||||
AZ_TracePrintf("", "peer %d", peerId);
|
||||
}
|
||||
|
||||
AZ_TracePrintf("", "\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // GridMate
|
||||
|
||||
#endif // GM_REPLICA_INTERESTDEFS_H
|
||||
@@ -1,53 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GM_REPLICA_INTERESTEVENTS_H
|
||||
#define GM_REPLICA_INTERESTEVENTS_H
|
||||
|
||||
#if defined(GM_INTEREST_MANAGER)
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <GridMate/Replica/ReplicaCommon.h>
|
||||
|
||||
#include <GridMate/containers/unordered_set.h>
|
||||
#include <GridMate/containers/unordered_map.h>
|
||||
#include <GridMate/EBus.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
/**
|
||||
* EBus for interest manager's events.
|
||||
* Notifies subscribers about new interest matches and new mismatches happened.
|
||||
*/
|
||||
class InterestManagerEvents
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
typedef AZStd::recursive_mutex MutexType;
|
||||
typedef void* BusIdType;
|
||||
typedef SysContAlloc AllocatorType;
|
||||
|
||||
virtual ~InterestManagerEvents() {}
|
||||
|
||||
/**
|
||||
* Called when new pair of replica and peer matched their interest
|
||||
*/
|
||||
virtual void OnInterestMatched(ReplicaId replicaId, PeerId peerId) { (void) replicaId; (void) peerId; }
|
||||
|
||||
/**
|
||||
* Called when pair of replica and peer mismatched interest (only called if the pair was previously matching)
|
||||
*/
|
||||
virtual void OnInterestUnmatched(ReplicaId replicaId, PeerId peerId) { (void) replicaId; (void) peerId; }
|
||||
};
|
||||
|
||||
typedef AZ::EBus<InterestManagerEvents> InterestManagerEventsBus;
|
||||
}
|
||||
|
||||
#endif // GM_INTEREST_MANAGER
|
||||
#endif
|
||||
@@ -1,243 +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 <GridMate/Replica/Interest/InterestManager.h>
|
||||
#include <GridMate/Replica/Interest/RulesHandler.h>
|
||||
#include <GridMate/Replica/Interest/InterestQueryResult.h>
|
||||
|
||||
#include <GridMate/Replica/ReplicaMgr.h>
|
||||
|
||||
#include <AzCore/std/containers/array.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
static const unsigned k_maxHandlers = sizeof(GridMate::InterestHandlerSlot) * CHAR_BIT;
|
||||
|
||||
/**
|
||||
* Hashing utils
|
||||
*/
|
||||
struct ReplicaHashByPeer
|
||||
{
|
||||
AZ_FORCE_INLINE AZStd::size_t operator()(const ReplicaTarget* t) const
|
||||
{
|
||||
static_assert(sizeof(AZStd::size_t) >= sizeof(ReplicaPeer*), "Types sizes mismatch");
|
||||
return reinterpret_cast<AZStd::size_t>(t->GetPeer());
|
||||
}
|
||||
};
|
||||
|
||||
struct ReplicaEqualToByPeer
|
||||
{
|
||||
AZ_FORCE_INLINE bool operator()(const ReplicaTarget* left, const ReplicaTarget* right) const
|
||||
{
|
||||
return left->GetPeer() == right->GetPeer();
|
||||
}
|
||||
};
|
||||
|
||||
struct ReplicaHashByPeerId
|
||||
{
|
||||
AZ_FORCE_INLINE AZStd::size_t operator()(PeerId peerId) const
|
||||
{
|
||||
static_assert(sizeof(AZStd::size_t) >= sizeof(PeerId), "Types sizes mismatch");
|
||||
return static_cast<AZStd::size_t>(peerId);
|
||||
}
|
||||
};
|
||||
|
||||
struct ReplicaEqualToByPeerId
|
||||
{
|
||||
AZ_FORCE_INLINE bool operator()(PeerId peerId, const ReplicaTarget* right) const
|
||||
{
|
||||
return peerId == right->GetPeer()->GetId();
|
||||
}
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* InterestManager
|
||||
*/
|
||||
InterestManager::InterestManager()
|
||||
: m_rm(nullptr)
|
||||
, m_freeSlots(~0u)
|
||||
{
|
||||
}
|
||||
|
||||
void InterestManager::Init(const InterestManagerDesc& desc)
|
||||
{
|
||||
m_rm = desc.m_rm;
|
||||
AZ_Assert(m_rm, "Invalid replica manager");
|
||||
}
|
||||
|
||||
bool InterestManager::IsReady() const
|
||||
{
|
||||
return m_rm != nullptr;
|
||||
}
|
||||
|
||||
InterestManager::~InterestManager()
|
||||
{
|
||||
while (!m_handlers.empty())
|
||||
{
|
||||
m_handlers.back()->OnRulesHandlerUnregistered(this);
|
||||
m_handlers.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
void InterestManager::RegisterHandler(BaseRulesHandler* handler)
|
||||
{
|
||||
AZ_Assert(handler, "Invalid rules handler");
|
||||
|
||||
for (BaseRulesHandler* h : m_handlers)
|
||||
{
|
||||
if (h == handler)
|
||||
{
|
||||
AZ_TracePrintf("GridMate", "Rules handler %p is already registered", handler);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
InterestHandlerSlot slot = GetNewSlot();
|
||||
if (!slot)
|
||||
{
|
||||
AZ_TracePrintf("GridMate", "Too many rules handlers, max=%u\n", k_maxHandlers);
|
||||
return;
|
||||
}
|
||||
|
||||
handler->m_slot = slot;
|
||||
m_handlers.push_back(handler);
|
||||
handler->OnRulesHandlerRegistered(this);
|
||||
}
|
||||
|
||||
void InterestManager::UnregisterHandler(BaseRulesHandler* handler)
|
||||
{
|
||||
AZ_Assert(handler, "Invalid rules handler");
|
||||
|
||||
for (auto it = m_handlers.begin(); it != m_handlers.end(); ++it)
|
||||
{
|
||||
if (*it == handler)
|
||||
{
|
||||
handler->OnRulesHandlerUnregistered(this);
|
||||
m_handlers.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AZ_Assert(false, "Handler was not registered");
|
||||
}
|
||||
|
||||
void InterestManager::Update()
|
||||
{
|
||||
// Updating all handlers
|
||||
for (BaseRulesHandler* handler : m_handlers)
|
||||
{
|
||||
handler->Update();
|
||||
}
|
||||
|
||||
// merging results from every handler
|
||||
for (BaseRulesHandler* handler : m_handlers)
|
||||
{
|
||||
const InterestMatchResult& result = handler->GetLastResult();
|
||||
|
||||
for (auto& match : result)
|
||||
{
|
||||
ReplicaPtr replica = m_rm->FindReplica(match.first);
|
||||
if (!replica) // replica was destroyed: ignoring this match
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
unordered_set<ReplicaTarget*, ReplicaHashByPeer, ReplicaEqualToByPeer> targets;
|
||||
|
||||
for (ReplicaTarget& targetObj : replica->m_targets)
|
||||
{
|
||||
targets.insert(&targetObj);
|
||||
if (!match.second.count(targetObj.GetPeer()->GetId()))
|
||||
{
|
||||
targetObj.m_slotMask &= ~handler->m_slot;
|
||||
if (!targetObj.m_slotMask)
|
||||
{
|
||||
targetObj.m_flags |= ReplicaTarget::TargetRemoved;
|
||||
m_rm->OnReplicaChanged(replica);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const PeerId& peerId : match.second)
|
||||
{
|
||||
ReplicaTarget* rt = nullptr;
|
||||
|
||||
auto it = targets.find_as(peerId, ReplicaHashByPeerId(), ReplicaEqualToByPeerId());
|
||||
if (it == targets.end())
|
||||
{
|
||||
ReplicaPeer* peer = m_rm->FindPeer(peerId);
|
||||
|
||||
if (!ShouldForward(replica.get(), peer))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
rt = ReplicaTarget::AddReplicaTarget(peer, replica.get());
|
||||
rt->SetNew(true);
|
||||
m_rm->OnReplicaChanged(replica);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt = *it;
|
||||
}
|
||||
|
||||
rt->m_slotMask |= handler->m_slot;
|
||||
rt->m_flags &= ~ReplicaTarget::TargetRemoved;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool InterestManager::ShouldForward(Replica* replica, ReplicaPeer* peer) const
|
||||
{
|
||||
if (!peer) // invalid peer
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (replica->IsPrimary()) // own the replica?
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_rm->GetLocalPeerId() == peer->GetId() || peer->GetId() == replica->m_upstreamHop->GetId()) // forwarding to local peer or to owner?
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_rm->IsSyncHost() && !(replica->m_upstreamHop->GetMode() == Mode_Peer && peer->GetMode() == Mode_Peer)) // we are host and replica' owner and target are not connected
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
InterestHandlerSlot InterestManager::GetNewSlot()
|
||||
{
|
||||
InterestHandlerSlot s = m_freeSlots;
|
||||
for (unsigned i = 0; s && i < k_maxHandlers; ++i, s >>= 1)
|
||||
{
|
||||
if (s & 1)
|
||||
{
|
||||
InterestHandlerSlot slot = (1 << i);
|
||||
m_freeSlots &= ~slot;
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void InterestManager::FreeSlot(InterestHandlerSlot slot)
|
||||
{
|
||||
m_freeSlots |= slot;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
@@ -1,91 +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
|
||||
*
|
||||
*/
|
||||
#ifndef GM_REPLICA_INTERESTMANAGER_H
|
||||
#define GM_REPLICA_INTERESTMANAGER_H
|
||||
|
||||
#include <GridMate/Containers/list.h>
|
||||
|
||||
#include <GridMate/Replica/Interest/InterestDefs.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
class BaseRulesHandler;
|
||||
|
||||
/**
|
||||
* Interest manager initialization parameters
|
||||
*/
|
||||
struct InterestManagerDesc
|
||||
{
|
||||
ReplicaManager* m_rm; ///< Replica manager instance
|
||||
|
||||
InterestManagerDesc()
|
||||
: m_rm(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* InterestManager: responsible for matching of replicas and peers pairs based on rules and attribute provided.
|
||||
* InterestManager allows registration of up to 32 custom rules handler. Each rules handler is responsible of matching attributes
|
||||
* and rules that user provides. InterestManager is responsible for merging results of matching from every registered handler and
|
||||
* maintaining valid forwarding targets cache on every Replica.
|
||||
*/
|
||||
class InterestManager
|
||||
{
|
||||
public:
|
||||
|
||||
GM_CLASS_ALLOCATOR(InterestManager);
|
||||
|
||||
InterestManager();
|
||||
~InterestManager();
|
||||
|
||||
/**
|
||||
* Initialize manager with a descriptor
|
||||
*/
|
||||
void Init(const InterestManagerDesc& desc);
|
||||
|
||||
/**
|
||||
* Returns true if InterestManager is initialized and is ready to use
|
||||
*/
|
||||
bool IsReady() const;
|
||||
|
||||
/**
|
||||
* Register new handler with a given type and instance
|
||||
*/
|
||||
void RegisterHandler(BaseRulesHandler* handler);
|
||||
|
||||
/**
|
||||
* Unregister handler
|
||||
*/
|
||||
void UnregisterHandler(BaseRulesHandler* handler);
|
||||
|
||||
/**
|
||||
* Call to update current replica->peers cache
|
||||
*/
|
||||
void Update();
|
||||
|
||||
/**
|
||||
* Returns replica manager IM is bount to
|
||||
*/
|
||||
ReplicaManager* GetReplicaManager() { return m_rm; }
|
||||
private:
|
||||
InterestManager(const InterestManager&) = delete;
|
||||
InterestManager& operator=(const InterestManager&) = delete;
|
||||
|
||||
InterestHandlerSlot GetNewSlot();
|
||||
void FreeSlot(InterestHandlerSlot slot);
|
||||
bool ShouldForward(Replica* replica, ReplicaPeer* peer) const;
|
||||
|
||||
ReplicaManager* m_rm;
|
||||
vector<BaseRulesHandler*> m_handlers;
|
||||
InterestHandlerSlot m_freeSlots;
|
||||
};
|
||||
} // namespace GridMate
|
||||
|
||||
#endif // GM_REPLICA_INTERESTMANAGER_H
|
||||
@@ -1,25 +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 <GridMate/Replica/Interest/InterestQueryResult.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
InterestQueryResult::InterestQueryResult()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
InterestQueryResult::PeerList& InterestQueryResult::Insert(ReplicaId repId)
|
||||
{
|
||||
auto it = m_matches.insert_key(repId);
|
||||
return it.first->second;
|
||||
}
|
||||
} // namespace GridMate
|
||||
|
||||
*/
|
||||
@@ -1,25 +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
|
||||
*
|
||||
*/
|
||||
#ifndef GM_REPLICA_INTERESTQUERYRESULT_H
|
||||
#define GM_REPLICA_INTERESTQUERYRESULT_H
|
||||
/*
|
||||
#include <AzCore/base.h>
|
||||
|
||||
#include <GridMate/containers/vector.h>
|
||||
#include <GridMate/containers/unordered_map.h>
|
||||
#include <GridMate/Replica/Interest/InterestDefs.h>
|
||||
#include <GridMate/Replica/ReplicaCommon.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
|
||||
using InterestPeerList = vector<PeerId>;
|
||||
using InterestQueryResult = unordered_map<ReplicaId, InterestPeerList>;
|
||||
} // GridMate
|
||||
*/
|
||||
#endif // GM_REPLICA_INTERESTQUERYRESULT_H
|
||||
@@ -1,65 +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
|
||||
*
|
||||
*/
|
||||
#ifndef GM_REPLICA_RULES_HANDLER_H
|
||||
#define GM_REPLICA_RULES_HANDLER_H
|
||||
|
||||
#include <GridMate/Replica/ReplicaCommon.h>
|
||||
|
||||
#include <GridMate/Replica/Interest/InterestDefs.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
class InterestManager;
|
||||
|
||||
/**
|
||||
* BaseRulesHandler: base handler class
|
||||
* RulesHandler's job is to provide InterestManager with matching pairs of attributes and rules.
|
||||
*/
|
||||
class BaseRulesHandler
|
||||
{
|
||||
public:
|
||||
BaseRulesHandler()
|
||||
: m_slot(0)
|
||||
{}
|
||||
|
||||
virtual ~BaseRulesHandler() { };
|
||||
|
||||
/**
|
||||
* Ticked by interest manager to retrieve new matches or mismatches of interests
|
||||
*/
|
||||
virtual void Update() = 0;
|
||||
|
||||
/**
|
||||
* Returns result of a previous update
|
||||
* This only returns changes that happened on the previous tick not the whole world state
|
||||
*/
|
||||
virtual const InterestMatchResult& GetLastResult() = 0;
|
||||
|
||||
/**
|
||||
* Called by InterestManager when the given handler instance is registered
|
||||
*/
|
||||
virtual void OnRulesHandlerRegistered(InterestManager* manager) = 0;
|
||||
|
||||
/**
|
||||
* Called by InterestManager when the given handler is unregistered
|
||||
*/
|
||||
virtual void OnRulesHandlerUnregistered(InterestManager* manager) = 0;
|
||||
|
||||
/**
|
||||
* Returns interest mananger this handler is bound to, or nullptr if it's unbound
|
||||
*/
|
||||
virtual InterestManager* GetManager() = 0;
|
||||
|
||||
private:
|
||||
friend class InterestManager;
|
||||
|
||||
InterestHandlerSlot m_slot;
|
||||
};
|
||||
} // namespace GridMate
|
||||
|
||||
#endif // GM_REPLICA_RULES_HANDLER_H
|
||||
@@ -29,8 +29,7 @@ namespace GridMate
|
||||
|
||||
class ReplicaStatus;
|
||||
class ReplicaTask;
|
||||
class InterestManager;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Replica
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -55,7 +54,6 @@ namespace GridMate
|
||||
|
||||
friend class ReplicaMarshalNewTask;
|
||||
|
||||
friend class InterestManager;
|
||||
friend class ReplicaTarget;
|
||||
|
||||
enum Flags
|
||||
|
||||
@@ -1,98 +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 (GM_FUNCTION_NUM_ARGS == 0)
|
||||
#define GM_FUNCTION_TEMPLATE_PARMS
|
||||
#define GM_FUNCTION_ARGS
|
||||
#define GM_FUNCTION_ARGS_CONCAT
|
||||
#define GM_FUNCTION_FORWARD
|
||||
#define GM_FUNCTION_FORWARD_CONCAT
|
||||
#elif (GM_FUNCTION_NUM_ARGS == 1)
|
||||
#define GM_FUNCTION_TEMPLATE_PARMS , typename T0
|
||||
#define GM_FUNCTION_ARGS T0 && t0
|
||||
#define GM_FUNCTION_ARGS_CONCAT , GM_FUNCTION_ARGS
|
||||
#define GM_FUNCTION_FORWARD AZStd::forward<T0>(t0)
|
||||
#define GM_FUNCTION_FORWARD_CONCAT , GM_FUNCTION_FORWARD
|
||||
#elif (GM_FUNCTION_NUM_ARGS == 2)
|
||||
#define GM_FUNCTION_TEMPLATE_PARMS , typename T0, typename T1
|
||||
#define GM_FUNCTION_ARGS T0 && t0, T1 && t1
|
||||
#define GM_FUNCTION_ARGS_CONCAT , GM_FUNCTION_ARGS
|
||||
#define GM_FUNCTION_FORWARD AZStd::forward<T0>(t0), AZStd::forward<T1>(t1)
|
||||
#define GM_FUNCTION_FORWARD_CONCAT , GM_FUNCTION_FORWARD
|
||||
#elif (GM_FUNCTION_NUM_ARGS == 3)
|
||||
#define GM_FUNCTION_TEMPLATE_PARMS , typename T0, typename T1, typename T2
|
||||
#define GM_FUNCTION_ARGS T0 && t0, T1 && t1, T2 && t2
|
||||
#define GM_FUNCTION_ARGS_CONCAT , GM_FUNCTION_ARGS
|
||||
#define GM_FUNCTION_FORWARD AZStd::forward<T0>(t0), AZStd::forward<T1>(t1), AZStd::forward<T2>(t2)
|
||||
#define GM_FUNCTION_FORWARD_CONCAT , GM_FUNCTION_FORWARD
|
||||
#elif (GM_FUNCTION_NUM_ARGS == 4)
|
||||
#define GM_FUNCTION_TEMPLATE_PARMS , typename T0, typename T1, typename T2, typename T3
|
||||
#define GM_FUNCTION_ARGS T0 && t0, T1 && t1, T2 && t2, T3 && t3
|
||||
#define GM_FUNCTION_ARGS_CONCAT , GM_FUNCTION_ARGS
|
||||
#define GM_FUNCTION_FORWARD AZStd::forward<T0>(t0), AZStd::forward<T1>(t1), AZStd::forward<T2>(t2), AZStd::forward<T3>(t3)
|
||||
#define GM_FUNCTION_FORWARD_CONCAT , GM_FUNCTION_FORWARD
|
||||
#elif (GM_FUNCTION_NUM_ARGS == 5)
|
||||
#define GM_FUNCTION_TEMPLATE_PARMS , typename T0, typename T1, typename T2, typename T3, typename T4
|
||||
#define GM_FUNCTION_ARGS T0 && t0, T1 && t1, T2 && t2, T3 && t3, T4 && t4
|
||||
#define GM_FUNCTION_ARGS_CONCAT , GM_FUNCTION_ARGS
|
||||
#define GM_FUNCTION_FORWARD AZStd::forward<T0>(t0), AZStd::forward<T1>(t1), AZStd::forward<T2>(t2), AZStd::forward<T3>(t3), AZStd::forward<T4>(t4)
|
||||
#define GM_FUNCTION_FORWARD_CONCAT , GM_FUNCTION_FORWARD
|
||||
#else
|
||||
#error Unsupported argument count
|
||||
#endif
|
||||
|
||||
/**
|
||||
Create a ReplicaChunk that isn't attached to a Replica. To attach it to a replica,
|
||||
call replica->AttachReplicaChunk(chunk).
|
||||
**/
|
||||
template<class ChunkType GM_FUNCTION_TEMPLATE_PARMS>
|
||||
ChunkType* CreateReplicaChunk(GM_FUNCTION_ARGS)
|
||||
{
|
||||
static_assert(AZStd::is_base_of<ReplicaChunkBase, ChunkType>::value, "Class must inherit from ReplicaChunk");
|
||||
|
||||
ReplicaChunkDescriptor* descriptor = ReplicaChunkDescriptorTable::Get().FindReplicaChunkDescriptor(ReplicaChunkClassId(ChunkType::GetChunkName()));
|
||||
AZ_Assert(descriptor, "Cannot find replica chunk descriptor for %s. Did you remember to register the chunk type?", ChunkType::GetChunkName());
|
||||
ReplicaChunkDescriptorTable::Get().BeginConstructReplicaChunk(descriptor);
|
||||
ChunkType* chunk = aznew ChunkType(GM_FUNCTION_FORWARD);
|
||||
ReplicaChunkDescriptorTable::Get().EndConstructReplicaChunk();
|
||||
chunk->Init(descriptor);
|
||||
|
||||
return chunk;
|
||||
}
|
||||
|
||||
/**
|
||||
Create a ReplicaChunk that is automatically attached to the replica.
|
||||
**/
|
||||
template<class ChunkType GM_FUNCTION_TEMPLATE_PARMS>
|
||||
ChunkType* CreateAndAttachReplicaChunk(const ReplicaPtr& replica GM_FUNCTION_ARGS_CONCAT)
|
||||
{
|
||||
return CreateAndAttachReplicaChunk<ChunkType>(replica.get() GM_FUNCTION_FORWARD_CONCAT);
|
||||
}
|
||||
|
||||
/**
|
||||
Create a ReplicaChunk that is automatically attached to the replica.
|
||||
**/
|
||||
template<class ChunkType GM_FUNCTION_TEMPLATE_PARMS>
|
||||
ChunkType* CreateAndAttachReplicaChunk(Replica* replica GM_FUNCTION_ARGS_CONCAT)
|
||||
{
|
||||
// Chunks cannot be attached while active
|
||||
if (replica->IsActive())
|
||||
{
|
||||
AZ_Warning("GridMate", false, "Cannot attach chunk %s while replica is active", ChunkType::GetChunkName());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ChunkType* chunk = CreateReplicaChunk<ChunkType>(GM_FUNCTION_FORWARD);
|
||||
replica->AttachReplicaChunk(chunk);
|
||||
return chunk;
|
||||
}
|
||||
|
||||
#undef GM_FUNCTION_TEMPLATE_PARMS
|
||||
#undef GM_FUNCTION_ARGS
|
||||
#undef GM_FUNCTION_ARGS_CONCAT
|
||||
#undef GM_FUNCTION_FORWARD
|
||||
#undef GM_FUNCTION_FORWARD_CONCAT
|
||||
@@ -329,7 +329,6 @@ namespace GridMate
|
||||
friend class ReplicaUpdateTaskBase;
|
||||
friend class ReplicaDestroyPeerTask;
|
||||
friend class SendLimitProcessPolicy;
|
||||
friend class InterestManager;
|
||||
|
||||
typedef unordered_map<int, void*> UserContextMapType;
|
||||
typedef unordered_map<ReplicaId, ReplicaPtr> ReplicaMap;
|
||||
|
||||
@@ -46,8 +46,6 @@ namespace GridMate
|
||||
*/
|
||||
class ReplicaTarget
|
||||
{
|
||||
friend class InterestManager;
|
||||
|
||||
public:
|
||||
static ReplicaTarget* AddReplicaTarget(ReplicaPeer* peer, Replica* replica);
|
||||
|
||||
|
||||
@@ -1,20 +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
|
||||
*
|
||||
*/
|
||||
#ifndef GRIDMATE_VERSION_H
|
||||
#define GRIDMATE_VERSION_H 1
|
||||
|
||||
// buildversion.h is updated automatically when we release an SDK.
|
||||
// It contians the folling defines (with example numbers)
|
||||
// #define GM_BUILD_NUMBER 18
|
||||
// #define GM_BUILD_DATE "Tue 06/09/2009"
|
||||
// #define GM_BUILD_TIME "14:10:34.72"
|
||||
#include <GridMate/BuildInfo.h>
|
||||
|
||||
#define GM_BUILD_VERSION 001 // Hundreds is a major version, tens in a minor. For instance 155 is 1.55.
|
||||
|
||||
#endif // GRIDMATE_VERSION_H
|
||||
@@ -7,9 +7,7 @@
|
||||
#
|
||||
|
||||
set(FILES
|
||||
BuildInfo.h
|
||||
EBus.h
|
||||
Docs.h
|
||||
GridMate.cpp
|
||||
GridMate.h
|
||||
GridMateEventsBus.h
|
||||
@@ -17,11 +15,9 @@ set(FILES
|
||||
MathUtils.h
|
||||
Memory.h
|
||||
Types.h
|
||||
Version.h
|
||||
Carrier/Carrier.cpp
|
||||
Carrier/Carrier.h
|
||||
Carrier/Compressor.h
|
||||
Carrier/Cripter.h
|
||||
Carrier/DefaultHandshake.cpp
|
||||
Carrier/DefaultHandshake.h
|
||||
Carrier/DefaultSimulator.cpp
|
||||
@@ -40,15 +36,10 @@ set(FILES
|
||||
Carrier/Utils.h
|
||||
Containers/list.h
|
||||
Containers/queue.h
|
||||
Containers/set.h
|
||||
Containers/slist.h
|
||||
Containers/unordered_map.h
|
||||
Containers/unordered_set.h
|
||||
Containers/vector.h
|
||||
Online/OnlineUtilityThread.h
|
||||
Online/UserServiceTypes.h
|
||||
Replica/BasicHostChunkDescriptor.h
|
||||
Replica/DeltaCompressedDataSet.h
|
||||
Replica/DataSet.cpp
|
||||
Replica/DataSet.h
|
||||
Replica/Interpolators.h
|
||||
@@ -66,7 +57,6 @@ set(FILES
|
||||
Replica/ReplicaCommon.h
|
||||
Replica/ReplicaDefs.h
|
||||
Replica/ReplicaFunctions.h
|
||||
Replica/ReplicaFunctions.inl
|
||||
Replica/ReplicaInline.inl
|
||||
Replica/ReplicaMgr.cpp
|
||||
Replica/ReplicaMgr.h
|
||||
@@ -88,13 +78,6 @@ set(FILES
|
||||
Replica/Tasks/ReplicaProcessPolicy.cpp
|
||||
Replica/Tasks/ReplicaProcessPolicy.h
|
||||
Replica/Tasks/ReplicaPriorityPolicy.h
|
||||
Replica/Interest/BitmaskInterestHandler.cpp
|
||||
Replica/Interest/BitmaskInterestHandler.h
|
||||
Replica/Interest/InterestDefs.h
|
||||
Replica/Interest/InterestManager.cpp
|
||||
Replica/Interest/InterestManager.h
|
||||
Replica/Interest/InterestQueryResult.h
|
||||
Replica/Interest/RulesHandler.h
|
||||
Serialize/Buffer.cpp
|
||||
Serialize/Buffer.h
|
||||
Serialize/PackedSize.h
|
||||
|
||||
Reference in New Issue
Block a user