Notifications
Clear all

[Closed] SDK Comparing Modifier Settings

Hi, I was wondering if there was a way to compare two of the same modifier to see if it has the same settings. The only way I can think of atm is by writing a huge list of different modifiers and their params and checking that way. So I was hoping of a quicker way of checking this. Thanks.

4 Replies

We could probably use generic pb2 code (iterating side by side the pblocks using NumParams(), IndextoID and using GetParameterType, to make a switch to compare the values, according to the types).

this how I would approach it…

BOOL compareMods(Modifier* mod1, Modifier* mod2, TimeValue t)
 {
 	if(mod1->ClassID() != mod2->ClassID())
 		return FALSE;
 
 	for(int i = 0; i < mod1->NumRefs(); ++i)
 	{
 		RefTargetHandle ref = mod1->GetReference(i);
 		if(!ref) continue;
 
 		if(ref->SuperClassID() == PARAMETER_BLOCK_CLASS_ID) 
 		{
 			IParamBlock* pb1 = (IParamBlock*)ref;
 			IParamBlock* pb2 = (IParamBlock*)mod2->GetReference(i);
 			if(!pb2) continue;
 
 			for(int j = 0; j < pb1->NumParams(); ++j)
 			{
 				switch(pb1->GetParameterType(j))
 				{
 					case TYPE_FLOAT: if(pb1->GetFloat(j,t) != pb2->GetFloat(j,t)) return FALSE;
 					case TYPE_INT: if(pb1->GetInt(j,t) != pb2->GetInt(j,t)) return FALSE;
 					//....
 				}
 			}
 		}
 		else if(ref->SuperClassID() == PARAMETER_BLOCK2_CLASS_ID) 
 		{
 			IParamBlock2* pb1 = (IParamBlock2*)ref;
 			IParamBlock2* pb2 = (IParamBlock2*)mod2->GetReference(i);
 			if(!pb2) continue;
 
 			for(int j = 0; j < pb1->NumParams(); ++j)
 			{
 				switch(pb1->GetParameterType(j))
 				{
 					case TYPE_FLOAT: if(pb1->GetFloat(j,t) != pb2->GetFloat(j,t)) return FALSE;
 					case TYPE_INT: if(pb1->GetInt(j,t) != pb2->GetInt(j,t)) return FALSE;
 					//.... continue for all other types and TABS(compare counts and iterate)
 				}
 			}
 		}
 	}
 	return TRUE
 }

you may have to compare other references and subanims to

EDIT: disregard what I said, misread the title

Ahh that is perfect! Exactly what I needed Thank you !!