public void UpdateParticleMaterial(int index) { if (m_Solver == null) { return; } UpdateParticleResolution(index); ObiFluidEmitterBlueprint fluidMaterial = emitterBlueprint as ObiFluidEmitterBlueprint; int solverIndex = solverIndices[index]; m_Solver.restDensities[solverIndex] = fluidMaterial != null ? fluidMaterial.restDensity : 0; m_Solver.viscosities[solverIndex] = fluidMaterial != null ? fluidMaterial.viscosity : 0; m_Solver.vortConfinement[solverIndex] = fluidMaterial != null ? fluidMaterial.vorticity : 0; m_Solver.surfaceTension[solverIndex] = fluidMaterial != null ? fluidMaterial.surfaceTension : 0; m_Solver.buoyancies[solverIndex] = fluidMaterial != null ? fluidMaterial.buoyancy : -1; m_Solver.atmosphericDrag[solverIndex] = fluidMaterial != null ? fluidMaterial.atmosphericDrag : 0; m_Solver.atmosphericPressure[solverIndex] = fluidMaterial != null ? fluidMaterial.atmosphericPressure : 0; m_Solver.diffusion[solverIndex] = fluidMaterial != null ? fluidMaterial.diffusion : 0; m_Solver.userData[solverIndex] = fluidMaterial != null ? fluidMaterial.diffusionData : Vector4.zero; Oni.ParticleFlags particlePhase = Oni.ParticleFlags.Fluid; if (emitterBlueprint != null && fluidMaterial == null) { particlePhase = 0; } m_Solver.phases[solverIndex] = Oni.MakePhase(fluidPhase, Oni.ParticleFlags.SelfCollide | particlePhase); }
private int GetSimplexPhase(int simplexStart, int simplexSize, out Oni.ParticleFlags flags, ref bool restPositionsEnabled) { flags = 0; int group = 0; for (int j = 0; j < simplexSize; ++j) { int particleIndex = simplices[simplexStart + j]; flags |= ObiUtils.GetFlagsFromPhase(phases[particleIndex]); group = math.max(group, ObiUtils.GetGroupFromPhase(phases[particleIndex])); restPositionsEnabled |= restPositions[particleIndex].w > 0.5f; } return(group); }
public override void SetSelfCollisions(bool selfCollisions) { if (solver != null && isLoaded) { Oni.ParticleFlags particlePhase = Oni.ParticleFlags.Fluid; if (emitterBlueprint != null && !(emitterBlueprint is ObiFluidEmitterBlueprint)) { particlePhase = 0; } for (int i = 0; i < solverIndices.Length; i++) { m_Solver.phases[solverIndices[i]] = Oni.MakePhase(fluidPhase, (selfCollisions ? Oni.ParticleFlags.SelfCollide : 0) | particlePhase); } } }
public static int MakePhase(int group, Oni.ParticleFlags flags) { return((group & (int)Oni.ParticleFlags.GroupMask) | (int)flags); }