Merge branch 'particle-rotate-shape' of https://github.com/Tryibion/FlaxEngine into Tryibion-particle-rotate-shape

This commit is contained in:
Wojtek Figat
2025-01-27 11:35:26 +01:00
3 changed files with 75 additions and 0 deletions

View File

@@ -1150,6 +1150,48 @@ 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); \
Float4 v4 = Float4(v3); \
Quaternion q = Quaternion(v4); \
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() \

View File

@@ -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 = tryGetValue(node->GetBox(0), Value::InitForZero(VariantType::Quaternion)).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() \