Beispiel #1
0
void ShVarModel::setRecursiveUniformValues(ShVarItem *item, const Uniform& u)
{
	if (!item)
		return;

	if (item->getFullName() == u.name()) {
		dbgPrint(DBGLVL_INFO, "found uniform: %s\n", u.name().toAscii().data());
		item->setData(DF_DEBUG_UNIFORM_VALUE, u.toString());
		emit dataChanged(ShVarModel::getIndex(item, 0),
				ShVarModel::getIndex(item, DF_LAST - 1));
	} else {
		for (int i = 0; i < item->childCount(); ++i) {
			setRecursiveUniformValues(item->child(i), u);
		}
	}
}
void UniformRegistry::setUniform(const Uniform & uniform, bool warnIfUnused, bool forced){
	entry_t * & entry = uniforms[uniform.getNameId()];

	if(entry==nullptr){ // new entry
		entry = new entry_t( uniform,warnIfUnused,getNewGlobalStep() );
		orderedList.push_front(entry);
		entry->positionInUpdateList=orderedList.begin();
	} // if an entry exists and appliance is forced or (uniform is valid and value has changed)
	else if( forced || (entry->valid && !(uniform==entry->uniform)) ){

		//! \note This warning should do no harm - otherwise remove it.
		if(entry->uniform.getType()!=uniform.getType() ){
			WARN("Type of Uniform changed; this may be a problem. "+entry->uniform.toString()+" -> "+uniform.toString());
		}
		// move entry to the front of the orderedList
		orderedList.erase(entry->positionInUpdateList);
		orderedList.push_front(entry);

		entry->reset(uniform,getNewGlobalStep(),warnIfUnused,orderedList.begin());
	}
	// else: if the value of an uniform has not changed or the uniform could not be set (= invalid), nothing needs to be done.
}