示例#1
0
void PandaDocument::rewind()
{
	m_animTimeVal = 0.0;
	m_animTime.setValue(0.0);
	for(auto object : m_objectsList->get())
		object->reset();
	setDirtyValue(this);
	m_signals->timeChanged.run();
}
示例#2
0
void TransformPlaneConstraint::init()
{
    addInput(&d_planes);
    addInput(&d_rotation);
    addInput(&d_translation);
    addInput(&d_scale);
    addOutput(&d_outPlanes);

    setDirtyValue();
}
示例#3
0
void PandaDocument::step()
{
	m_stepQueued = false;
	if (m_stepCanceled)	// The user clicked stop after a step has been queued
	{
		m_stepCanceled = false;
		return;
	}

	auto startTime = std::chrono::high_resolution_clock::now();
	panda::helper::UpdateLogger::getInstance()->startLog(this);

	setInStep(true);
	// Force the value of isInStep, because some objects will propagate dirtyValue during beginStep
	for(auto& object : m_objectsList->get())
		object->setInStep(true);

	updateDocumentData();

	setDirtyValue(this);
	updateIfDirty();

	setInStep(false);
	for(auto& object : m_objectsList->get())
		object->endStep();

	panda::helper::UpdateLogger::getInstance()->stopLog();

	m_signals->timeChanged.run();

	for (auto obj : m_dirtyObjects)
		m_signals->dirtyObject.run(obj);
	m_dirtyObjects.clear();

	m_signals->modified.run();

	if (m_animPlaying)	
	{
		m_stepQueued = true; // We want another step
		if (m_useTimer.getValue()) // Restart the timer taking into consideration the time it took to render this frame
		{
			auto endTime = std::chrono::high_resolution_clock::now();
			auto frameDuration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
			double delay = m_timestep.getValue() - frameDuration.count() / 1000.0 - 0.001; // How long do we wait until we start the next step ?
			TimedFunctions::cancelRun(m_animFunctionIndex); // Remove previous
			m_animFunctionIndex = TimedFunctions::delayRun(delay, [this]() { // Ask for the delayed execution of step()
				m_gui.executeByUI([this]() { step(); });  // But we want step() to be run on the GUI thread
			});
		}
		else
			m_gui.executeByUI([this]() { step(); }); // Run ASAP on the GUI thread
	}

	++m_iNbFrames;
	auto now = currentTime();
	float elapsedDur = static_cast<float>(toSeconds(now - m_fpsTime));
	if(m_animPlaying && elapsedDur > 1.0)
	{
		m_currentFPS = m_iNbFrames / elapsedDur;
		m_fpsTime = now;
		m_iNbFrames = 0;
	}
}
示例#4
0
void DDGNode::addInput(DDGNode* n)
{
    doAddInput(n);
    n->doAddOutput(this);
    setDirtyValue();
}
示例#5
0
	void beginStep()
	{
		PandaObject::beginStep();
		setDirtyValue(this);
	}