vault backup: 2024-10-30 19:11:55

This commit is contained in:
BlueRose 2024-10-30 19:11:55 +08:00
parent e16c781aaf
commit c8f78d712a
3 changed files with 129 additions and 10 deletions

View File

@ -1 +1 @@
{"582020846":{"582020846":{"currentFile":{"count":1,"lastUpdated":1727792069567}}},"根据bComputeExport分别使用RDG的ComputeShader与PixelShader输出DepthStencil。":{"根据bComputeExport分别使用RDG的ComputeShader与PixelShader输出DepthStencil。":{"currentFile":{"count":1,"lastUpdated":1727249472660}}},"MeshDraw":{"MeshDraw":{"internalLink":{"count":1,"lastUpdated":1727260163677}}},"实现了一个在屏幕空间宽度恒定的":{"实现了一个在屏幕空间宽度恒定的":{"currentFile":{"count":1,"lastUpdated":1728700795488}}},"TsDirectorCamManagerActor":{"TsDirectorCamManagerActor":{"currentFile":{"count":1,"lastUpdated":1729139925413}}},"Bloom":{"Bloom":{"currentFile":{"count":1,"lastUpdated":1729490733473}}},"FBloomFinalizeApplyConstantsCS":{"FBloomFinalizeApplyConstantsCS":{"currentFile":{"count":1,"lastUpdated":1729584275683}}},"解决NaiLin高跟":{"解决NaiLin高跟":{"currentFile":{"count":1,"lastUpdated":1729587089926}}},"优化项目举例,参与多个项目。":{"优化项目举例,参与多个项目。":{"currentFile":{"count":1,"lastUpdated":1729696025968}}},"制作各种编辑器工具":{"制作各种编辑器工具":{"currentFile":{"count":1,"lastUpdated":1729696038138}}}} {"582020846":{"582020846":{"currentFile":{"count":1,"lastUpdated":1727792069567}}},"实现了一个在屏幕空间宽度恒定的":{"实现了一个在屏幕空间宽度恒定的":{"currentFile":{"count":1,"lastUpdated":1728700795488}}},"TsDirectorCamManagerActor":{"TsDirectorCamManagerActor":{"currentFile":{"count":1,"lastUpdated":1729139925413}}},"Bloom":{"Bloom":{"currentFile":{"count":1,"lastUpdated":1729490733473}}},"FBloomFinalizeApplyConstantsCS":{"FBloomFinalizeApplyConstantsCS":{"currentFile":{"count":1,"lastUpdated":1729584275683}}},"解决NaiLin高跟":{"解决NaiLin高跟":{"currentFile":{"count":1,"lastUpdated":1729587089926}}},"优化项目举例,参与多个项目。":{"优化项目举例,参与多个项目。":{"currentFile":{"count":1,"lastUpdated":1729696025968}}},"制作各种编辑器工具":{"制作各种编辑器工具":{"currentFile":{"count":1,"lastUpdated":1729696038138}}},"RigidBodyIndex":{"RigidBodyIndex":{"currentFile":{"count":1,"lastUpdated":1730280351906}}}}

View File

@ -19,4 +19,5 @@
2. 2024心仪生日会 2. 2024心仪生日会
1. 添加心仪呆毛以及物理效果。 1. 添加心仪呆毛以及物理效果。
3. 解决新棚手柄输入反应慢的问题。 3. 解决新棚手柄输入反应慢的问题。
4. 解决 道具新投影仪播放节目会有拖影的问题。 4. 解决 道具新投影仪播放节目会有拖影的问题。
5. 解决 2套嘉然衣服无法接收到动捕数据的问题。

View File

@ -36,6 +36,16 @@ void AChingmuMocapReceiverActor::BeginPlay()
} }
``` ```
FChingmuThread::Run()中处理完[[#ST_MocapFrameData]]之后将几个演员动补数据存入FrameQueue之后。在Tick()出队之后数据存入AllHumanFrames/AllRigidBodyFrames。
- AllHumanFrames
- ID
- std::vector<ST_MocapFrameData*> Frames
- ID
- TimeStamp
- FrameIndex
- BonesWorldPos
- BonesLocalRot
```c++ ```c++
void AChingmuMocapReceiverActor::Tick(float DeltaTime) void AChingmuMocapReceiverActor::Tick(float DeltaTime)
@ -46,17 +56,17 @@ void AChingmuMocapReceiverActor::Tick(float DeltaTime)
{ {
Sender = GetMotionSender(); Sender = GetMotionSender();
} }
const auto CurTime = ULiveDirectorStatics::GetUnixTime(); const auto CurTime = ULiveDirectorStatics::GetUnixTime();//获取当前系统时间
if(UseThread) if(UseThread)
{ {
// 线程方式 // 线程方式
// 在数据队列中获取青瞳数据 // 在数据队列中获取青瞳数据
while (!FrameQueue.IsEmpty()) while (!FrameQueue.IsEmpty())//处理完所有
{ {
ST_MocapFrameData* Frame; ST_MocapFrameData* Frame;
if (FrameQueue.Dequeue(Frame)) if (FrameQueue.Dequeue(Frame))//出队
{ {
PutMocapDataIntoFrameList(Frame); PutMocapDataIntoFrameList(Frame);//将帧数数据塞入对应HuamnID/RigidBodyID的AllHumanFrames/AllRigidBodyFrames中。
} }
} }
} }
@ -76,19 +86,125 @@ void AChingmuMocapReceiverActor::Tick(float DeltaTime)
} }
``` ```
### 采样相关逻辑
- ***SampleByTimeStamp***()
```c++ ```c++
void AChingmuMocapReceiverActor::DoSample(TArray<MocapFrames*>& Frames) void AChingmuMocapReceiverActor::DoSample(TArray<MocapFrames*>& Frames)
{ {
for (auto i = 0; i < Frames.Num(); i++) for (auto i = 0; i < Frames.Num(); i++)
{ {
Frames[i]->CheckSize(CacheLimit); Frames[i]->CheckSize(CacheLimit);//判断当前帧数据是否超过指定长度240帧2~4秒数据移除超出长度的数据。
if (SampleByTimeStamp(Frames[i]->Frames)) if (SampleByTimeStamp(Frames[i]->Frames))//对数据进行插值当前插值数据存在SampledHumanData。
{ {
SendFrameToCharacter(); SendFrameToCharacter();//执行对应的TsChingmuMocapReceiverActor.ts中的逻辑主要是触发一个事件讲数据传递给TsMotionRetargetComponent.ts 或者 TsSceneLiveLinkPropActor.ts动捕道具
} }
} }
} }
class MocapFrames
{
public:
int ID;
std::vector<ST_MocapFrameData*> Frames = {};
public:
MocapFrames(): ID(0)
{
}
bool CheckSize(const int Limit)
{
if (Frames.size() > Limit)
{
const int DeletedCount = Frames.size() / 2;
for (auto i = 0; i < DeletedCount; i++)
{
auto Data = Frames[i];
if (Data)
{
delete Data;
}
Data = nullptr;
}
Frames.erase(Frames.cbegin(), Frames.cbegin() + DeletedCount);
return true;
}
return false;
}
};
``` ```
对数据进行插值,当前插值数据存在**SampledHumanData**。
```c++
bool AChingmuMocapReceiverActor::SampleByTimeStamp(std::vector<ST_MocapFrameData*>& DataList)
{
const int64 SampleTime = ULiveDirectorStatics::GetUnixTime() - UMotionUtils::BackSampleTime;//UMotionUtils::BackSampleTime = 100ms,采样100ms的数据。
int Previous = -1;
int Next = -1;
for (int Index = DataList.size() - 1; Index > 0; Index--)//从Last => First遍历所有数据确定插值的2个数据Index。
{
const ST_MocapFrameData* Data = DataList[Index];
if (Data == nullptr)
{
continue;
}
if (Data->TimeStamp - SampleTime > 0)
{
Next = Index;
}
else
{
Previous = Index;
break;
}
}
if (bShowSampleLog)
{
UE_LOG(LogTemp, Warning, TEXT("prev: %d, next: %d, total: %llu"), Previous, Next, DataList.size());
}
if (Previous != -1 && Next != -1)
{
const auto p = DataList[Previous];
const auto n = DataList[Next];
const float Factor = (n->TimeStamp - p->TimeStamp) > 0
? (1.0 * (SampleTime - p->TimeStamp) / (n->TimeStamp - p->TimeStamp))
: 1.0;
// Bone world pos cannot lerp like this
// It will cause bone length changes all the time
SampledHumanData->ID = p->ID;
SampledHumanData->TimeStamp = SampleTime;
SampledHumanData->FrameIndex = p->FrameIndex;
for (auto Index = 0; Index < 23; Index++)//对23个骨骼进行差值
{
SampledHumanData->BonesWorldPos[Index] = UKismetMathLibrary::VLerp(
p->BonesWorldPos[Index], n->BonesWorldPos[Index], Factor);
SampledHumanData->BonesLocalRot[Index] = UKismetMathLibrary::RLerp(p->BonesLocalRot[Index].Rotator(),
n->BonesLocalRot[Index].Rotator(),
Factor, true).Quaternion();
}
return true;
}
if (Previous != -1)//容错处理全都是Previous数据太旧直接清空。
{
SampledHumanData->CopyFrom(DataList[Previous]);
if(SampleTime - DataList[Previous]->TimeStamp > UMotionUtils::MotionTimeout)
{
// data is too old, clear the data list.
DataList.clear();
}
return true;
}
if (Next != -1)//没有Previous直接复制Next的数据。
{
SampledHumanData->CopyFrom(DataList[Next]);
return true;
}
return false;
}
```
### FChingmuThread ### FChingmuThread
用途为: 用途为:
- 获取当前系统时间。 - 获取当前系统时间。
@ -98,7 +214,7 @@ void AChingmuMocapReceiverActor::DoSample(TArray<MocapFrames*>& Frames)
- 根据当前时间与当前Frames从UChingMUComponent中将数据复制到[[#ST_MocapFrameData]]中。 - 根据当前时间与当前Frames从UChingMUComponent中将数据复制到[[#ST_MocapFrameData]]中。
- 将[[#ST_MocapFrameData]]转换成JSON后使用AMotionSenderActor::OnGetRawMocapData_NotInGameThread()发送。 - 将[[#ST_MocapFrameData]]转换成JSON后使用AMotionSenderActor::OnGetRawMocapData_NotInGameThread()发送。
- 将当前帧数据加入FrameQueue队列。 - 将当前帧数据加入FrameQueue队列。
- 线程睡眠0.001s。 - 线程睡眠0.001s。以此保证AChingmuMocapReceiverActor::Tick()中可以把数据都处理完。
```c++ ```c++
uint32 FChingmuThread::Run() uint32 FChingmuThread::Run()
@ -169,6 +285,8 @@ uint32 FChingmuThread::Run()
``` ```
## ST_MocapFrameData ## ST_MocapFrameData
- ST_MocapFrameData为动捕数据的原始帧数据。
```c++ ```c++
#define MOCAP_BONE_COUNT 23 #define MOCAP_BONE_COUNT 23