Beispiel #1
0
void CSfxModel::SetFrame(float currentFrame)
{
	if (currentFrame == m_currentFrame
		|| currentFrame < 0.0f)
		return;

	if (currentFrame < m_currentFrame)
	{
		CPtrArray<Particle>* particles;
		int j;
		for (int i = 0; i < m_particles.GetSize(); i++)
		{
			particles = m_particles[i];
			if (particles)
			{
				for (j = 0; j < particles->GetSize(); j++)
					Delete(particles->GetAt(j));
				particles->RemoveAll();
			}
		}

		m_currentFrame = -0.5f;
	}

	while (currentFrame > m_currentFrame)
	{
		if (!_nextFrame())
			break;
	}

	if (m_currentFrame < 0.0f)
		m_currentFrame = 0.0f;
}
PacketStreamReader::FrameInfo PacketStreamReader::NextFrame(PacketStreamSourceId src, SyncTime *sync)
{
    Lock(); //we cannot use a scoped lock here, because we may not want to release the lock, depending on what we find.
    try
    {
        while (1)
        {
            auto fi = _nextFrame();
            if (!fi) {
                // Nothing left in stream
                Unlock();
                return fi;
            } else {
                // So we have accurate sequence numbers for frames.
                ++_next_packet_framenum[fi.src];

                if (_stream.seekable())
                {
                    if (!_index.has(fi.src, fi.sequence_num)) {
                        // If it's not in the index for some reason, add it.
                        _index.add(fi.src, fi.sequence_num, fi.frame_streampos);
                    } else if (_index.position(fi.src, fi.sequence_num) != fi.frame_streampos) {
                        PANGO_ENSURE(_index.position(fi.src, fi.sequence_num) == fi.packet_streampos);
                        static bool warned_already = false;
                        if(!warned_already) {
                            pango_print_warn("CAUTION: Old .pango files do not update frame_properties on seek.\n");
                            warned_already = true;
                        }
                    }
                }
                _stream.data_len(fi.size); //now we are positioned on packet data for n characters.
            }

            if (sync) {
                //if we are doing timesync, wait, even if it's not our packet.
                WaitForTimeSync(*sync, fi.time);
            }

            //if it's ours, return it and don't release lock
            if (fi.src == src) {
                return _stream.readFrameHeader(*this);
            }

            //otherwise skip it and get the next one.
            _stream.skip(fi.size);
        }
    }
    catch (std::exception &e) {
        // Since we are not using a scoped lock, we must catch and release.
        Unlock();
        throw e;
    }
    catch (...)  {
        // We will always release, even if we cannot identify the exception.
        Unlock();
        throw std::runtime_error("Caught an unknown exception");
    }
}
Beispiel #3
0
void CSfxModel::MoveFrame()
{
	if (!_nextFrame())
		m_currentFrame = -0.5f;
}