Refactor engine to support double-precision vectors
This commit is contained in:
@@ -79,9 +79,9 @@ bool ParticleEmitterGraphCPU::Load(ReadStream* stream, bool loadMeta)
|
||||
*(type*)(_defaultParticleData.Get() + attr.Offset) = AttributesDefaults[i].getter; \
|
||||
break
|
||||
SETUP_ATTR(float, Float, AsFloat);
|
||||
SETUP_ATTR(Vector2, Vector2, AsVector2());
|
||||
SETUP_ATTR(Vector3, Vector3, AsVector3());
|
||||
SETUP_ATTR(Vector4, Vector4, AsVector4());
|
||||
SETUP_ATTR(Float2, Float2, AsFloat2());
|
||||
SETUP_ATTR(Float3, Float3, AsFloat3());
|
||||
SETUP_ATTR(Float4, Float4, AsFloat4());
|
||||
SETUP_ATTR(int32, Int, AsInt);
|
||||
SETUP_ATTR(uint32, Uint, AsUint);
|
||||
#undef SETUP_ATTR
|
||||
@@ -124,7 +124,7 @@ void ParticleEmitterGraphCPUExecutor::Init(ParticleEmitter* emitter, ParticleEff
|
||||
{
|
||||
auto& context = Context.Get();
|
||||
context.GraphStack.Clear();
|
||||
context.GraphStack.Push((Graph*)&_graph);
|
||||
context.GraphStack.Push(&_graph);
|
||||
context.Data = &data;
|
||||
context.Emitter = emitter;
|
||||
context.Effect = effect;
|
||||
@@ -153,10 +153,10 @@ bool ParticleEmitterGraphCPUExecutor::ComputeBounds(ParticleEmitter* emitter, Pa
|
||||
// Build sphere bounds out of all living particles positions
|
||||
byte* positionPtr = bufferPtr + layout->Attributes[_graph._attrPosition].Offset;
|
||||
#if 0
|
||||
BoundingSphere sphere(*((Vector3*)positionPtr), 0.0f);
|
||||
BoundingSphere sphere(*((Float3*)positionPtr), 0.0f);
|
||||
for (int32 particleIndex = 0; particleIndex < count; particleIndex++)
|
||||
{
|
||||
BoundingSphere::Merge(sphere, *((Vector3*)positionPtr), &sphere);
|
||||
BoundingSphere::Merge(sphere, *((Float3*)positionPtr), &sphere);
|
||||
positionPtr += stride;
|
||||
}
|
||||
#endif
|
||||
@@ -167,7 +167,7 @@ bool ParticleEmitterGraphCPUExecutor::ComputeBounds(ParticleEmitter* emitter, Pa
|
||||
Vector3 center = Vector3::Zero;
|
||||
for (int32 i = 0; i < count; i++)
|
||||
{
|
||||
Vector3::Add(*((Vector3*)positionPtr), center, ¢er);
|
||||
Vector3::Add(*((Float3*)positionPtr), center, ¢er);
|
||||
positionPtr += stride;
|
||||
}
|
||||
center /= static_cast<float>(count);
|
||||
@@ -178,7 +178,7 @@ bool ParticleEmitterGraphCPUExecutor::ComputeBounds(ParticleEmitter* emitter, Pa
|
||||
for (int32 i = 0; i < count; i++)
|
||||
{
|
||||
// We are doing a relative distance comparison to find the maximum distance from the center of our sphere
|
||||
const float distance = Vector3::DistanceSquared(center, *(Vector3*)positionPtr);
|
||||
const float distance = Float3::DistanceSquared(center, *(Float3*)positionPtr);
|
||||
positionPtr += stride;
|
||||
|
||||
if (distance > radius)
|
||||
@@ -197,7 +197,7 @@ bool ParticleEmitterGraphCPUExecutor::ComputeBounds(ParticleEmitter* emitter, Pa
|
||||
BoundingBox box = BoundingBox::Empty;
|
||||
for (int32 particleIndex = 0; particleIndex < count; particleIndex++)
|
||||
{
|
||||
Vector3 position = *(Vector3*)positionPtr;
|
||||
Float3 position = *(Float3*)positionPtr;
|
||||
#if ENABLE_ASSERTION
|
||||
if (!position.IsNanOrInfinity())
|
||||
#endif
|
||||
@@ -281,11 +281,11 @@ bool ParticleEmitterGraphCPUExecutor::ComputeBounds(ParticleEmitter* emitter, Pa
|
||||
if (_graph._attrScale != -1)
|
||||
{
|
||||
// Find the maximum local bounds of the particle model
|
||||
Vector3 maxScale = Vector3::Zero;
|
||||
Float3 maxScale = Float3::Zero;
|
||||
byte* scale = bufferPtr + layout->Attributes[_graph._attrScale].Offset;
|
||||
for (int32 i = 0; i < count; i++)
|
||||
{
|
||||
Vector3::Max(*((Vector3*)scale), maxScale, maxScale);
|
||||
Float3::Max(*((Float3*)scale), maxScale, maxScale);
|
||||
scale += stride;
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ void ParticleEmitterGraphCPUExecutor::Draw(ParticleEmitter* emitter, ParticleEff
|
||||
lightData.MinRoughness = 0.04f;
|
||||
lightData.ShadowsDistance = 2000.0f;
|
||||
lightData.ShadowsStrength = 1.0f;
|
||||
lightData.Direction = Vector3::Forward;
|
||||
lightData.Direction = Float3::Forward;
|
||||
lightData.ShadowsFadeDistance = 50.0f;
|
||||
lightData.ShadowsNormalOffsetScale = 10.0f;
|
||||
lightData.ShadowsDepthBias = 0.5f;
|
||||
@@ -409,13 +409,13 @@ void ParticleEmitterGraphCPUExecutor::Draw(ParticleEmitter* emitter, ParticleEff
|
||||
const float radius = (float)GetValue(module->GetBox(1), 3);
|
||||
const float fallOffExponent = (float)GetValue(module->GetBox(2), 4);
|
||||
|
||||
lightData.Position = *(Vector3*)positionPtr;
|
||||
lightData.Color = Vector3(color) * color.W;
|
||||
lightData.Position = *(Float3*)positionPtr;
|
||||
lightData.Color = Float3(color) * color.W;
|
||||
lightData.Radius = radius;
|
||||
lightData.FallOffExponent = fallOffExponent;
|
||||
|
||||
if (emitter->SimulationSpace == ParticlesSimulationSpace::Local)
|
||||
Vector3::Transform(lightData.Position, transform, lightData.Position);
|
||||
Float3::Transform(lightData.Position, transform, lightData.Position);
|
||||
|
||||
renderContext.List->PointLights.Add(lightData);
|
||||
|
||||
@@ -470,7 +470,7 @@ void ParticleEmitterGraphCPUExecutor::Update(ParticleEmitter* emitter, ParticleE
|
||||
byte* positionPtr = cpu.Buffer.Get() + data.Buffer->Layout->Attributes[_graph._attrPosition].Offset;
|
||||
for (int32 particleIndex = 0; particleIndex < cpu.Count; particleIndex++)
|
||||
{
|
||||
Vector3 pos = *((Vector3*)positionPtr);
|
||||
Float3 pos = *((Float3*)positionPtr);
|
||||
ASSERT(!pos.IsNanOrInfinity());
|
||||
positionPtr += data.Buffer->Stride;
|
||||
}
|
||||
@@ -485,7 +485,7 @@ void ParticleEmitterGraphCPUExecutor::Update(ParticleEmitter* emitter, ParticleE
|
||||
byte* velocityPtr = cpu.Buffer.Get() + data.Buffer->Layout->Attributes[_graph._attrVelocity].Offset;
|
||||
for (int32 particleIndex = 0; particleIndex < cpu.Count; particleIndex++)
|
||||
{
|
||||
*((Vector3*)positionPtr) += *((Vector3*)velocityPtr) * dt;
|
||||
*((Float3*)positionPtr) += *((Float3*)velocityPtr) * dt;
|
||||
positionPtr += data.Buffer->Stride;
|
||||
velocityPtr += data.Buffer->Stride;
|
||||
}
|
||||
@@ -499,7 +499,7 @@ void ParticleEmitterGraphCPUExecutor::Update(ParticleEmitter* emitter, ParticleE
|
||||
byte* angularVelocityPtr = cpu.Buffer.Get() + data.Buffer->Layout->Attributes[_graph._attrAngularVelocity].Offset;
|
||||
for (int32 particleIndex = 0; particleIndex < cpu.Count; particleIndex++)
|
||||
{
|
||||
*((Vector3*)rotationPtr) += *((Vector3*)angularVelocityPtr) * dt;
|
||||
*((Float3*)rotationPtr) += *((Float3*)angularVelocityPtr) * dt;
|
||||
rotationPtr += data.Buffer->Stride;
|
||||
angularVelocityPtr += data.Buffer->Stride;
|
||||
}
|
||||
@@ -619,5 +619,5 @@ VisjectExecutor::Value ParticleEmitterGraphCPUExecutor::eatBox(Node* caller, Box
|
||||
VisjectExecutor::Graph* ParticleEmitterGraphCPUExecutor::GetCurrentGraph() const
|
||||
{
|
||||
auto& context = Context.Get();
|
||||
return context.GraphStack.Peek();
|
||||
return (Graph*)context.GraphStack.Peek();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user