Merge remote-tracking branch 'origin/master' into 1.10
# Conflicts: # Source/Engine/Graphics/Materials/MaterialShader.h
This commit is contained in:
@@ -1150,6 +1150,47 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
// Not supported
|
||||
break;
|
||||
}
|
||||
// Rotate Position Shape
|
||||
case 216:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Rotate Position Shape");
|
||||
auto& positionAttr = context.Data->Buffer->Layout->Attributes[node->Attributes[0]];
|
||||
|
||||
byte* positionPtr = start + positionAttr.Offset;
|
||||
|
||||
auto quatBox = node->GetBox(0);
|
||||
|
||||
#define INPUTS_FETCH() \
|
||||
const Quaternion quat = (Quaternion)GetValue(quatBox, 2);
|
||||
#define LOGIC() \
|
||||
Quaternion nq = Quaternion::Invert(quat); \
|
||||
Float3 v3 = *((Float3*)positionPtr); \
|
||||
Quaternion q = Quaternion(v3.X, v3.Y, v3.Z, 0.0f); \
|
||||
Quaternion rq = quat * (q * nq); \
|
||||
*(Float3*)positionPtr = Float3(rq.X, rq.Y, rq.Z); \
|
||||
positionPtr += stride;
|
||||
|
||||
if (node->UsePerParticleDataResolve())
|
||||
{
|
||||
for (int32 particleIndex = particlesStart; particleIndex < particlesEnd; particleIndex++)
|
||||
{
|
||||
context.ParticleIndex = particleIndex;
|
||||
INPUTS_FETCH();
|
||||
LOGIC();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
INPUTS_FETCH();
|
||||
for (int32 particleIndex = particlesStart; particleIndex < particlesEnd; particleIndex++)
|
||||
{
|
||||
LOGIC();
|
||||
}
|
||||
}
|
||||
#undef INPUTS_FETCH
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
|
||||
// Helper macros for collision modules to share the code
|
||||
#define COLLISION_BEGIN() \
|
||||
|
||||
@@ -632,6 +632,20 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), position.Value, param.ShaderName, wsPos);
|
||||
break;
|
||||
}
|
||||
// Rotate position shape
|
||||
case 216:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
const Value quaternion = GetValue(node->GetBox(0), 2).Cast(VariantType::Quaternion);
|
||||
_writer.Write(
|
||||
TEXT(
|
||||
" {{\n"
|
||||
" // Rotate position shape\n"
|
||||
" {0} = QuatRotateVector({1}, {0});\n"
|
||||
" }}\n"
|
||||
), positionAttr.Value, quaternion.Value);
|
||||
break;
|
||||
}
|
||||
|
||||
// Helper macros for collision modules to share the code
|
||||
#define COLLISION_BEGIN() \
|
||||
|
||||
@@ -1069,7 +1069,6 @@ void UpdateGPU(RenderTask* task, GPUContext* context)
|
||||
ScopeLock lock(GpuUpdateListLocker);
|
||||
if (GpuUpdateList.IsEmpty())
|
||||
return;
|
||||
|
||||
PROFILE_GPU("GPU Particles");
|
||||
|
||||
for (ParticleEffect* effect : GpuUpdateList)
|
||||
@@ -1109,6 +1108,7 @@ void UpdateGPU(RenderTask* task, GPUContext* context)
|
||||
|
||||
ParticleBuffer* Particles::AcquireParticleBuffer(ParticleEmitter* emitter)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
ParticleBuffer* result = nullptr;
|
||||
ASSERT(emitter && emitter->IsLoaded());
|
||||
|
||||
@@ -1118,7 +1118,7 @@ ParticleBuffer* Particles::AcquireParticleBuffer(ParticleEmitter* emitter)
|
||||
const auto entries = Pool.TryGet(emitter);
|
||||
if (entries)
|
||||
{
|
||||
while (entries->HasItems())
|
||||
while (entries->HasItems() && !result)
|
||||
{
|
||||
// Reuse buffer
|
||||
result = entries->Last().Buffer;
|
||||
@@ -1129,11 +1129,6 @@ ParticleBuffer* Particles::AcquireParticleBuffer(ParticleEmitter* emitter)
|
||||
{
|
||||
Delete(result);
|
||||
result = nullptr;
|
||||
if (entries->IsEmpty())
|
||||
{
|
||||
Pool.Remove(emitter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1162,6 +1157,7 @@ ParticleBuffer* Particles::AcquireParticleBuffer(ParticleEmitter* emitter)
|
||||
|
||||
void Particles::RecycleParticleBuffer(ParticleBuffer* buffer)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
if (buffer->Emitter->EnablePooling && EnableParticleBufferPooling)
|
||||
{
|
||||
// Return to pool
|
||||
@@ -1182,6 +1178,7 @@ void Particles::RecycleParticleBuffer(ParticleBuffer* buffer)
|
||||
|
||||
void Particles::OnEmitterUnload(ParticleEmitter* emitter)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
PoolLocker.Lock();
|
||||
const auto entries = Pool.TryGet(emitter);
|
||||
if (entries)
|
||||
|
||||
Reference in New Issue
Block a user