ModContext* FindModContext(INode* pNode, Modifier* mod) { IDerivedObject *derivObj; if( pNode->GetObjectRef()->SuperClassID() == GEN_DERIVOB_CLASS_ID ) derivObj = (IDerivedObject*)pNode->GetObjectRef(); else return NULL; int i=0, count=derivObj->NumModifiers(); for( i=0; i<count; i++ ) if( (derivObj->GetModifier(i)) == mod ) break; if( i==count ) return NULL; //the search failed return derivObj->GetModContext(i); }
PaintDefromModData *PaintDeformTest::GetPMD(INode *pNode) { ModContext *mc = NULL; Object* pObj = pNode->GetObjectRef(); if (!pObj) return NULL; while (pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID && mc == NULL) { IDerivedObject* pDerObj = (IDerivedObject *)(pObj); int Idx = 0; while (Idx < pDerObj->NumModifiers()) { // Get the modifier. Modifier* mod = pDerObj->GetModifier(Idx); if (mod->ClassID() == PAINTDEFORMTEST_CLASS_ID) { // is this the correct Physique Modifier based on index? PaintDeformTest *pmod = (PaintDeformTest*)mod; if (pmod == this) { mc = pDerObj->GetModContext(Idx); break; } } Idx++; } pObj = pDerObj->GetObjRef(); } if(!mc) return NULL; if ( !mc->localData ) return NULL; PaintDefromModData *bmd = (PaintDefromModData *) mc->localData; return bmd; }
// We want to survive a collapsed stack so we reapply ourselves here void EditFaceDataMod::NotifyPostCollapse(INode *node,Object *obj, IDerivedObject *derObj, int index) { if (mCollapsable) return; Object *bo = node->GetObjectRef(); IDerivedObject *derob = NULL; if(bo->SuperClassID() != GEN_DERIVOB_CLASS_ID) { derob = CreateDerivedObject(obj); node->SetObjectRef(derob); } else derob = (IDerivedObject*) bo; // Add ourselves to the top of the stack derob->AddModifier(this,NULL,derob->NumModifiers()); // Reinsert our local mod data ModContext* mc = derob->GetModContext(derob->NumModifiers()-1); mc->localData = mpModDataCollapseCache; mpModDataCollapseCache = NULL; // Reengage modification: mDisabled = false; }
//--------------------------------------------------------------- ISkinContextData *ControllerExporter::getISkinContextInterface(SkinController* skinController) { if (!skinController ) return 0; IDerivedObject* derivedObject = skinController->getDerivedObject(); if ( !derivedObject ) return 0; ModContext * modContext = derivedObject->GetModContext(skinController->getModifierIndex()); if ( !modContext ) return 0; LocalModData* localModData = modContext->localData; if ( !localModData ) return 0; return (BoneModData *)localModData; }
BOOL RecursePipeAndMatch(LocalPatchData *smd, Object *obj) { SClass_ID sc; IDerivedObject* dobj; Object *currentObject = obj; if ((sc = obj->SuperClassID()) == GEN_DERIVOB_CLASS_ID) { dobj = (IDerivedObject*)obj; while (sc == GEN_DERIVOB_CLASS_ID) { for (int j = 0; j < dobj->NumModifiers(); j++) { ModContext *mc = dobj->GetModContext(j); if (mc->localData == smd) { return TRUE; } } dobj = (IDerivedObject*)dobj->GetObjRef(); currentObject = (Object*) dobj; sc = dobj->SuperClassID(); } } int bct = currentObject->NumPipeBranches(FALSE); if (bct > 0) { for (int bi = 0; bi < bct; bi++) { Object* bobj = currentObject->GetPipeBranch(bi,FALSE); if (RecursePipeAndMatch(smd, bobj)) return TRUE; } } return FALSE; }