Channel Locking
 
 
 

Certain channels within an object can be locked instead of the whole object itself. For example, once a modifier is applied it may have the geometry channel cached (such as an array of vertices cached somewhere in the pipeline). When the system is evaluating this pipeline, if a certain channel it requires is cached, instead of evaluating the rest of the pipeline, it will use the cache. It will do a shallow copy of the cached channel into the object going down the pipeline. This is just copying the pointer to the cached channel into the object flowing down the pipeline. So essentially there are two TriObjects whose geometry channels are both pointing to the same array of vertices. This reduces the memory overhead required because instead of copying the whole array of vertices two meshes share the same memory. 3ds Max takes care of all of this, keeping track of who owns what so nothing is deleted twice or deleted when in use.

The channel lock methods below deal with this system. These methods are implemented and called by the system and not the plugin object. They simply manipulate a private data member inside the Object class.

If a channel is locked, this means that the object does not own the channel and it should not free it. If the channel is unlocked, this means the object does own it, and may free it. A channel that is locked should also not be modified. For example, if a channel that was cached upstream in the pipeline was modified, the cached version would not be correct anymore. The locking of the cached channel prevents this modification from happening.

The ChannelMask used in the above methods is an unsigned long. Each channel is represented by a bit.

Note: Developers must not get confused between channel numbers (TOPO_CHAN_NUM, GEOM_CHAN_NUM, etc.) and channel bits (TOPO_CHANNEL, GEOM_CHANNEL, etc.). Some methods refer to the channel by number and some by bit. Developers must not confuse these two as the compiler will not catch this as an error.