|
This Modifier allows you to store the the current status of modifier-stack.
Basically you can collapse the modifier-stack while keeping the history of the stack.
If you choose to save the cached data in the scene file, it will make file size bigger.
But, if the stack requires heavy calculation, this modifier will make scene loading a lot faster.
So, you cache the current modifier-stack, disable all modiers below, and save the cache with the max-file,
this makes demanding mcg-modifiers load at lightspeed.
It also could be used for replacing the current mesh in the modifier-stack.
If you cache a object with this modifier and paste it as an instanced modifier onto other object,
that object will get the mesh from the modifier which is chaching.
| |
|
For Developers:
When disabling all Modifiers below, any Parameter-change in such Modifiers will not trigger an update.
You might want that for your Procedural Object(s) too.
To make this work, you need to check if a Cache-Modifier is somewhere in the Modifier-Stack,
and if it is enabled. and if it is actually caching anything, then do nothing in your Object.
Sample Code:
#define CacheMod_CLASS_ID Class_ID(0x70305809, 0x63c127e3)
//-----------------------------------------------
class CheckCacheMod : public GeomPipelineEnumProc
{
public:
CheckCacheMod() : bCacheActive(false) {}
PipeEnumResult proc(ReferenceTarget* object, IDerivedObject* derObj, int index);
bool bCacheActive;
protected:
CheckCacheMod(CheckCacheMod& /*rhs*/) {}; // disallowed
CheckCacheMod& operator=(const CheckCacheMod& /*rhs*/) {} // disallowed
};
//-----------------------------------------------
PipeEnumResult CheckCacheMod::proc(ReferenceTarget* object, IDerivedObject* derObj, int index)
{
UNUSED_PARAM(index);
if(nullptr != derObj)
{
bCacheActive = false;
Modifier* pMod = dynamic_cast<Modifier*>(object);
if(nullptr != pMod)
{
if(pMod->ClassID() == CacheMod_CLASS_ID) // modifier is a ChacheModifier ?
{
if(pMod->IsEnabled()) // is it enabled ?
{
// cachemod is caching, if A_PLUGIN1-flag is set
if(pMod->TestAFlag(A_PLUGIN1))
{
bCacheActive = true;
return PIPE_ENUM_STOP;
}
}
}
}
}
return PIPE_ENUM_CONTINUE;
}
// check if a CacheModifier is caching
// param: inode, the node of your procedural Object
//-----------------------------------------------
bool AwesomeObject::IsCacheModActive()
{
ULONG nodeHandle = 0;
NotifyDependents(FOREVER, (PartID)&nodeHandle, REFMSG_GET_NODE_HANDLE);
INode* inode = GetCOREInterface()->GetINodeByHandle(nodeHandle);
if(nullptr != inode)
{
CheckCacheMod pipeEnumProc;
EnumGeomPipeline(&pipeEnumProc, inode->GetObjectRef());
return pipeEnumProc.bCacheActive;
}
return false;
}
then do the check in your Object's ObjectValidity()
//-----------------------------------------------
Interval AwesomeObject::ObjectValidity(TimeValue t)
{
if(IsCacheModActive())
return FOREVER;
// ... more code
}
|
|