Ejemplo n.º 1
0
        void PlaybackFrame(float time)
        {
            if (cache == null || cache.Duration == 0)
            {
                return;
            }

            // Get current frame from cache:
            cache.GetFrame(time, interpolate, ref frame);

            if (solver.AllocParticleCount < frame.indices.Count)
            {
                Debug.LogError("The ObiSolver doesn't have enough allocated particles to playback this cache.");
                Playing = false;
                return;
            }

            Matrix4x4 s2world = cache.localSpace ? solver.transform.localToWorldMatrix : Matrix4x4.identity;

            // Apply current frame:
            for (int i = 0; i < frame.indices.Count; ++i)
            {
                if (frame.indices[i] >= 0 && frame.indices[i] < solver.renderablePositions.Length)
                {
                    solver.renderablePositions[frame.indices[i]] = s2world.MultiplyPoint3x4(frame.positions[i]);
                }
            }

            Oni.SetParticlePositions(solver.OniSolver, solver.renderablePositions, solver.renderablePositions.Length, 0);
            solver.UpdateActiveParticles();
        }
Ejemplo n.º 2
0
        void PlaybackFrame(float time)
        {
            if (cache == null)
            {
                return;
            }

            // Get current frame from cache:
            ObiParticleCache.Frame frame = cache.GetFrame(time, interpolate);

            if (frame == null)
            {
                return;
            }

            if (solver.allocatedParticles.Count < frame.indices.Count)
            {
                Debug.LogError("The ObiSolver doesn't have enough allocated particles to playback this cache.");
                Playing = false;
                return;
            }

            // Set active particles:
            solver.activeParticles = new HashSet <int>(frame.indices);

            // Apply current frame:
            for (int i = 0; i < frame.indices.Count; ++i)
            {
                if (frame.indices[i] >= 0 && frame.indices[i] < solver.renderablePositions.Length)
                {
                    if (cache.localSpace)
                    {
                        solver.renderablePositions[frame.indices[i]] = solver.transform.TransformPoint(frame.positions[i]);
                    }
                    else
                    {
                        solver.renderablePositions[frame.indices[i]] = frame.positions[i];
                    }
                }
            }

            Oni.SetParticlePositions(solver.OniSolver, solver.renderablePositions, solver.renderablePositions.Length, 0);
            solver.UpdateActiveParticles();
        }