Autodesk Mudbox 2013 SDK Documentation > Layers and Viewport Filters >

# Sculpt Layers

A sculpt layer (LayerMeshData) or 3D layer, is a collection of vertex deltas. For each stored entry, a 3D vector and an integer are stored. The 3D vector is the delta value of the vertex in the layer, and the stored integer is the index of the vertex. The elements are ordered by their vertex index.

The mesh always contains the current result of all the layers applied to the surface with their current weight. When an operation is completed with a layer (like change in the weight, delete or duplicate the layer) all the vertices in the layer are processed and the change caused by the operation is calculated and added into the mesh current position.

For example, if a layer weight is changed from 100% to 50%, the current change is the current delta stored in the layer multiplied by 0.5. This vector is then added to the current vertex position. Plug-ins and other operations don't have to care about layers unless they want to modify the delta vector stored in the layer. Sculpt operations modify the currently stored delta in the layer.

A layer contains only the needed amount of elements, so as the user sculpts, the layer array is extended with new data. When the user creates a layer it does not contain any data so it does not require any memory. When the brush touches a vertex for the first time, Mudbox searches in the current layer for the vertex data with binary search. If the vertex is found in the layer, its index is stored in a temporary array. Otherwise, a new element is appended to another temporary array with the index of the vertex and its new delta. The next time the stroke touches the vertex, a search is not needed since the index is already stored in the temporary array. When the stroke finished, the array containing the new vertex elements is sorted and merged with the existing layer array.