5.8. Additional Methods

You may need to implement additional methods for certain element classes. Detailed information on matches() and copyMatchInfo() is presented in Section 5.9, “Special Considerations for Caching”. The push() and pop() methods are discussed in Section 5.10, “Pushing and Popping Elements”.

matches()

called to determine whether an element matches another element. This method is used to compare states for cache validity. copyMatchInfo() is used to create a copy of an element to be added to a cache.

push()

used in a few cases to set up a new element instance that is a copy of the one just below it in the stack. Elements that contain two or more pieces of data and elements that implement side effects (often for OpenGL rendering) need to implement a push() method. The default push() method does nothing, since most elements contain only one piece of data and the value is typically set immediately after a push. Subclasses of SoAccumulatedElement SoAccumulatedElement SoAccumulatedElement must define their own push() method to copy values from the next instance in the stack, since the new instance accumulates values on top of the old ones. Use theSoElement SoElement SoElement method getNextInStack().

pop()

the counterpart to push(). The default method does nothing. You need to implement a pop() method if your element has side effects. For the GL matrix elements, which call glPopMatrix() when they pop (see Section 5.10, “Pushing and Popping Elements”).