本文整理汇总了C#中SolverData.GetFluid方法的典型用法代码示例。如果您正苦于以下问题:C# SolverData.GetFluid方法的具体用法?C# SolverData.GetFluid怎么用?C# SolverData.GetFluid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolverData
的用法示例。
在下文中一共展示了SolverData.GetFluid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnUpdatePlugin
protected override void OnUpdatePlugin(SolverData solverData, int particleIndex, int neighborIndex)
{
// Get fluid IDs
var particleFluid = solverData.GetFluid(particleIndex).GetFluidID();
var neighborFluid = solverData.GetFluid(neighborIndex).GetFluidID();
var particleIsA = particleFluid == m_FluidAID;
if ((m_MixingFluidsAreTheSame || particleFluid != neighborFluid) && // Fluids are not the same, unless A and B are the same
(particleIsA || particleFluid == m_FluidBID) && // First fluid is A or B
(neighborFluid == m_FluidAID || neighborFluid == m_FluidBID)) // Second fluid is A or B
{
var position = solverData.GetPosition(particleIndex);
var neighborPosition = solverData.GetPosition(neighborIndex);
// Make sure the particles are actually close
if ((position - neighborPosition).sqrMagnitude > m_MixingDistanceSq)
return;
var velocity = solverData.GetVelocity(particleIndex);
var invMass = 1.0f/solverData.GetMass(particleIndex);
var emitC = false;
// Despawn the current particle, unless Fluid C is null and the particle is from Fluid A
if (m_FluidCID != 0 || !particleIsA)
{
emitC = true;
solverData.SetLifetime(particleIndex, -1);
}
// Emit a particle. We don't emit from the neighbor position, that gets handled in the opposite pair
// We handle actual emission on the main thread.
if (m_FluidDID == 0 || particleIsA)
{
if (emitC)
{
// Set the system to Fluid C
m_ParticleSystems[particleIndex] = 1;
}
else
{
m_ParticleSystems[particleIndex] = 0;
}
}
else
{
// Set the system to Fluid D
m_ParticleSystems[particleIndex] = 2;
}
// Set emit position and velocity. These must be manually integrated since they won't be applied until after the solver has run.
// The below is a standard Euler explicit integrator.
var acceleration = m_Gravity + solverData.GetForce(particleIndex)*invMass;
for (var iter = 0; iter < m_TimeStep.solverIterations; ++iter)
{
var t = (m_TimeStep.dtIter)*acceleration;
// Ignore very large velocity changes
if (Vector3.Dot(t, t) > (FluvioSettings.kMaxSqrVelocityChange * m_SimulationScale))
{
t *= 0;
}
velocity += t;
}
m_EmitVelocities[particleIndex] = velocity;
m_EmitPositions[particleIndex] = position + velocity * m_TimeStep.deltaTime;
}
}