Implement LockedWrapper.GetAnimationQueues
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace LuprexCommonTypes {
|
namespace CommonTypes {
|
||||||
// Array of tangible IDs.
|
// Array of tangible IDs.
|
||||||
using IdArray = TArray<int64>;
|
using IdArray = TArray<int64>;
|
||||||
|
|
||||||
// View of Array of tangible IDs.
|
// View of Array of tangible IDs.
|
||||||
using IdView = TArrayView<const int64>;
|
using IdView = TArrayView<const int64>;
|
||||||
|
|
||||||
|
// Array of std::string_view
|
||||||
|
using StringViewVec = TArray<std::string_view>;
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
#include "DebugPrint.h"
|
#include "DebugPrint.h"
|
||||||
#include "lpx-drvutil.hpp"
|
#include "lpx-drvutil.hpp"
|
||||||
|
|
||||||
|
using namespace CommonTypes;
|
||||||
|
|
||||||
void FLockedWrapper::InitWrapper() {
|
void FLockedWrapper::InitWrapper() {
|
||||||
if (Lockable.Wrapper.play_initialize != nullptr) {
|
if (Lockable.Wrapper.play_initialize != nullptr) {
|
||||||
// Already initialized.
|
// Already initialized.
|
||||||
@@ -38,9 +40,37 @@ int64 FLockedWrapper::GetActor() {
|
|||||||
return Lockable.Wrapper.get_actor_id(Get());
|
return Lockable.Wrapper.get_actor_id(Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
FLockedWrapper::IdView FLockedWrapper::GetNear(int64 id, double rx, double ry, double rz) {
|
IdView FLockedWrapper::GetNear(int64 id, double rx, double ry, double rz) {
|
||||||
uint32 size;
|
uint32 size;
|
||||||
int64* data;
|
int64* data;
|
||||||
Lockable.Wrapper.get_tangibles_near(Get(), id, rx, ry, rz, &size, &data);
|
Lockable.Wrapper.get_tangibles_near(Get(), id, rx, ry, rz, &size, &data);
|
||||||
return IdView(data, size);
|
return IdView(data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringViewVec FLockedWrapper::GetAnimationQueues(IdView ids) {
|
||||||
|
// How many animation queues are we fetching?
|
||||||
|
int num = ids.Num();
|
||||||
|
|
||||||
|
// Enlarge the static buffers if necessary.
|
||||||
|
// Add a little extra space so we don't have to enlarge
|
||||||
|
// the buffers every time we get a new tangible.
|
||||||
|
if (num > Lockable.AQLenBuffer.Num()) {
|
||||||
|
Lockable.AQLenBuffer.SetNum(num + 1000);
|
||||||
|
Lockable.AQStrBuffer.SetNum(num + 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get pointers to the static buffers.
|
||||||
|
uint32* LenBuf = Lockable.AQLenBuffer.GetData();
|
||||||
|
const char** StrBuf = Lockable.AQStrBuffer.GetData();
|
||||||
|
|
||||||
|
// Get the animation queues into the static buffers.
|
||||||
|
Lockable.Wrapper.get_animation_queues(Get(), num, ids.GetData(), LenBuf, StrBuf);
|
||||||
|
|
||||||
|
// Transfer data from static buffers into an array of string_view
|
||||||
|
StringViewVec result;
|
||||||
|
result.SetNum(num);
|
||||||
|
for (int i = 0; i < num; i++) {
|
||||||
|
result[i] = std::string_view(StrBuf[i], LenBuf[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -15,6 +15,14 @@ class FLockableWrapper {
|
|||||||
private:
|
private:
|
||||||
FCriticalSection Mutex;
|
FCriticalSection Mutex;
|
||||||
EngineWrapper Wrapper;
|
EngineWrapper Wrapper;
|
||||||
|
|
||||||
|
// Temporary buffers. These are only used
|
||||||
|
// inside wrapper methods. There's nothing
|
||||||
|
// persistent in these.
|
||||||
|
//
|
||||||
|
TArray<uint32> AQLenBuffer;
|
||||||
|
TArray<const char*> AQStrBuffer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend class FLockedWrapper;
|
friend class FLockedWrapper;
|
||||||
};
|
};
|
||||||
@@ -25,8 +33,9 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Import these types into our Namespace.
|
// Import these types into our Namespace.
|
||||||
using IdArray = LuprexCommonTypes::IdArray;
|
using IdArray = CommonTypes::IdArray;
|
||||||
using IdView = LuprexCommonTypes::IdView;
|
using IdView = CommonTypes::IdView;
|
||||||
|
using StringViewVec = CommonTypes::StringViewVec;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// The constructor of the FLockedWrapper claims the mutex.
|
// The constructor of the FLockedWrapper claims the mutex.
|
||||||
@@ -74,4 +83,11 @@ public:
|
|||||||
// in the TangibleManager, for example).
|
// in the TangibleManager, for example).
|
||||||
//
|
//
|
||||||
IdView GetNear(int64 id, double rx, double ry, double rz);
|
IdView GetNear(int64 id, double rx, double ry, double rz);
|
||||||
|
|
||||||
|
// Get animation queues.
|
||||||
|
//
|
||||||
|
// The array returned by this is valid until the
|
||||||
|
// next time you call this.
|
||||||
|
//
|
||||||
|
StringViewVec GetAnimationQueues(IdView ids);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ struct INTEGRATION_API FTangibleManager
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
// Import these types into our Namespace.
|
// Import these types into our Namespace.
|
||||||
using IdArray = LuprexCommonTypes::IdArray;
|
using IdArray = CommonTypes::IdArray;
|
||||||
using IdView = LuprexCommonTypes::IdView;
|
using IdView = CommonTypes::IdView;
|
||||||
|
|
||||||
// A pointer to the UWorld.
|
// A pointer to the UWorld.
|
||||||
UWorld* World;
|
UWorld* World;
|
||||||
|
|||||||
Reference in New Issue
Block a user