Пример #1
0
static bool IsDxMaterialEnabled(MtlBase * map)
{
	bool enabled = false;
	ICustAttribContainer * cont = map->GetCustAttribContainer();

	if(cont)
	{
		for(int i=0; i< cont->GetNumCustAttribs(); i++)
		{
			CustAttrib * ca = cont->GetCustAttrib(i);
			if(ca->GetInterface(VIEWPORT_SHADER_MANAGER_INTERFACE2)){

				IViewportShaderManager2 * vsm = (IViewportShaderManager2*)ca->GetInterface(VIEWPORT_SHADER_MANAGER_INTERFACE2);
				return vsm->IsDxStdMtlEnabled();
			}
		}
	}
	return enabled;
}
Пример #2
0
RefResult StdDualVSImp::NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate)
{
	switch (message) 
	{
		case REFMSG_TARGET_DELETED:
			{
				int i = FindNodeIndex((INode*)hTarget);
				assert(i >= 0);
				callb->DeleteRenderMeshCache(caches[i]->GetNode());
				delete caches[i];
				caches[i] = NULL;
				// NH 07|11|02 The cache is no longer dynamic - it will only grow but not shrink, 
				// so there could be null entries.  This was causing a problem in SetReference
//				caches.Delete(i,1);
//				caches.Shrink();
			}
			break;
		case REFMSG_NODE_MATERIAL_CHANGED:
			{
				int i = FindNodeIndex((INode*)hTarget);
				assert(i >= 0);
				DeleteReference(i);
			}
			break;
		case REFMSG_NODE_WSCACHE_UPDATED:
			{
				int i = FindNodeIndex((INode*)hTarget);
				//NH:06|11|02  I removed this, as in an undo situation the node reference may not be restored yet
				// as the viewport shader has not been initialised and thus not set the node.  In this case -1 is valid
//				assert(i >= 0);
				if(i >= 0)
					caches[i]->SetValid(false);
			}
			break;
		case REFMSG_SUBANIM_STRUCTURE_CHANGED:
		case REFMSG_REF_DELETED:
			{
				BOOL del = TRUE;

				int i = FindNodeIndex((INode*)hTarget);
				INode * n = (INode*)hTarget;
				Mtl * m = n->GetMtl();
				if(m)
				{
					// NH|06|11|02 check for the Viewport Manager - if the Effect is the same as the callback then keep it
					ICustAttribContainer *cont = m->GetCustAttribContainer();
					if (cont && cont->GetNumCustAttribs()) {
						IDXShaderManagerInterface *sm = GetDXShaderManager();
						if (!sm) 
						{
							break;
						}

						for (int kk = 0; kk < cont->GetNumCustAttribs(); kk++) {
							CustAttrib *ca = cont->GetCustAttrib(kk);
							IViewportShaderManager *manager = (IViewportShaderManager*)ca->GetInterface(VIEWPORT_SHADER_MANAGER_INTERFACE);
							if (manager) {

								ReferenceTarget *rt = manager->GetActiveEffect();
								if(rt == callb->GetRefTarg())
									del = FALSE;

							}
						}
					}
				}
				// Check, if there's still a reference path from the node to the MtlBase
				if(!DependsOn(hTarget,callb->GetRefTarg()) && del)
				{
					DeleteReference(i);
				}
				forceInvalid = true;
			}
	}
	return REF_SUCCEED;
}