コード例 #1
0
        public void UpdateParticleMaterial(int index)
        {
            if (solver == null)
            {
                return;
            }

            UpdateParticleResolution(index);

            ObiEmitterMaterialFluid fluidMaterial = emitterMaterial as ObiEmitterMaterialFluid;

            int solverIndex = particleIndices[index];

            solver.restDensities[solverIndex]       = fluidMaterial != null ? fluidMaterial.restDensity : 0;
            solver.viscosities[solverIndex]         = fluidMaterial != null ? fluidMaterial.viscosity : 0;
            solver.surfaceTension[solverIndex]      = fluidMaterial != null ? fluidMaterial.surfaceTension : 0;
            solver.buoyancies[solverIndex]          = fluidMaterial != null ? fluidMaterial.buoyancy : -1;
            solver.atmosphericDrag[solverIndex]     = fluidMaterial != null ? fluidMaterial.atmosphericDrag : 0;
            solver.atmosphericPressure[solverIndex] = fluidMaterial != null ? fluidMaterial.atmosphericPressure : 0;
            solver.diffusion[solverIndex]           = fluidMaterial != null ? fluidMaterial.diffusion : 0;
            solver.userData[solverIndex]            = fluidMaterial != null ? fluidMaterial.diffusionData : Vector4.zero;

            Oni.ParticlePhase particlePhase = Oni.ParticlePhase.Fluid;
            if (emitterMaterial != null && !(emitterMaterial is ObiEmitterMaterialFluid))
            {
                particlePhase = 0;
            }

            solver.phases[solverIndex] = Oni.MakePhase(fluidPhase, (selfCollisions?Oni.ParticlePhase.SelfCollide:0) | particlePhase);
        }
コード例 #2
0
        public void UpdateParticleResolution(int index)
        {
            if (solver == null)
            {
                return;
            }

            ObiEmitterMaterialFluid fluidMaterial = emitterMaterial as ObiEmitterMaterialFluid;

            int solverIndex = particleIndices[index];

            float restDistance = (emitterMaterial != null) ? emitterMaterial.GetParticleSize(solver.parameters.mode) : 0.1f;
            float pmass        = (emitterMaterial != null) ? emitterMaterial.GetParticleMass(solver.parameters.mode) : 0.1f;

            if (emitterMaterial != null && !(emitterMaterial is ObiEmitterMaterialFluid))
            {
                float randomRadius = UnityEngine.Random.Range(0, restDistance / 100.0f * (emitterMaterial as ObiEmitterMaterialGranular).randomness);
                solver.principalRadii[solverIndex] = Vector3.one * Mathf.Max(0.001f + restDistance * 0.5f - randomRadius);
            }
            else
            {
                solver.principalRadii[solverIndex] = Vector3.one * restDistance * 0.5f;
            }

            solver.invRotationalMasses[solverIndex] = solver.invMasses[solverIndex] = 1 / pmass;
            solver.smoothingRadii[solverIndex]      = fluidMaterial != null?fluidMaterial.GetSmoothingRadius(solver.parameters.mode) : 1f / (10 * Mathf.Pow(1, 1 / (solver.parameters.mode == Oni.SolverParameters.Mode.Mode3D ? 3.0f : 2.0f)));
        }