Intervals

An Interval is a class that represents a length of time. The most common use is to describe a range of time over which an item is said to be 'valid' with regards within the Cache System. This type of interval is referred to as a validity interval.

The validity interval describes the range of time over which the cache accurately reflects the state of the item. When comparing a given time to see if the cache is up to date, if the time is inside the interval, the cache is valid at that time. If it is outside the interval, the cache is invalid.

3ds Max object and modifier plug-ins are responsible for maintaining, updating, and reporting their validity intervals.

Plug-ins must provide 3ds Max with information about when they are changing and when they are not. Below are some examples of methods which plug-in objects or modifiers call or implement that return or modify intervals.

Retrieving Interval Values

The GetValue() method of IParamBlock has several parameters, one of which is a C++ reference to an Interval. This method is frequently used by developers to 'whittle' down an interval. When a parameter of a parameter block is animated, for any given time there is an interval over which the parameter is constant. If the parameter is constantly changing the interval is instantaneous. If the parameter does not change for a certain period the interval will be longer. If the parameter never changes the interval will be FOREVER. By passing an interval to the GetValue() method of the parameter block you ask the parameter block to 'intersect' the interval passed in with the interval of the parameter. Intersecting two intervals means returning a new interval whose start value is the greater of the two, and whose end value is smaller of the two. In this way, the resulting interval represents a combined period of constancy for the two intervals.

This technique is used frequently to compute a validity interval for an object. The developer starts an interval off as FOREVER, then intersects this interval with each of its animated parameters (by calling GetValue()). GetValue() 'whittles' down the interval with each call. When all the parameters have been intersected, the result is the overall validity interval of an object at a specific time.

Example

Consider the example shown in the diagram below. A validity interval is computed at time 40 for an object with two animated parameters, Radius, and Segments. The interval is computed by first intersecting an initial interval of FOREVER with the Radius parameter. The Radius interval is from 20 to 100. The result of this intersection is the interval from 20 to 100. This interval is intersected with the Segment parameter interval (from 10 to 50). The result of this intersection is an interval from 20 to 50. Thus the validity interval of the object at time 40 is from 20 to 50.

ObjectValidity() - This method, implemented by the plug-in, returns the validity interval of the procedural object around the time passed. This method is computed by the object by starting an interval at FOREVER, and intersecting this interval with the intervals of each of its animated parameters. In this way, an interval is whittled down as it is intersected with each of the parameters. The resulting interval represents a period of constancy about the TimeValue passed. The interval represents how far before the TimeValue and how far after it the object is constant.

LocalValidity() - This method returns the validity interval of the modifier itself around the time passed. In general, this would be the intersection of the validity intervals of all controllers that the modifier uses to control its parameters, so if a modifier was not animated, this interval would be FOREVER.

As an object flows up the pipeline, the validity interval of each modifier is intersected into the object state's validity interval. When the object gets to the end of the pipeline, its validity interval reflects the intersection of all the elements in the pipeline.

GetValidity() - The SimpleMod class calls this method to retrieve the validity interval of the modifier. The modifier provides this interval by starting an interval at FOREVER and intersecting each parameter of the modifier with the interval. SimpleMod then intersects the validity intervals of its own controllers with the returned interval in its implementation of LocalValidity().

UpdateValidity() - A modifier calls the UpdateValidity() method of an object. When a modifier is applied to an object, it needs to include its own validity interval. Frequently this is called by the modifier in its ModifyObject() method.

SetChannelValidity() - This method is called to specify a validity interval for a certain channel of the pipeline.