code: private int[] makeVertexDeltas(float[] vertices, SortableVertex[] sortVertices, Grid grid) {
          int vc = sortVertices.length;
  
          // Vertex scaling factor
          float scale = 1.0f / vertexPrecision;
  
          float prevGridIndex = 0x7fffffff;
          int prevDeltaX = 0;
          int[] intVertices = new int[vc * CTM_POSITION_ELEMENT_COUNT];
          for (int i = 0; i < vc; ++i) {
              // Get grid box origin
              int gridIdx = sortVertices[i].gridIndex;
              float[] gridOrigin = gridIdxToPoint(grid, gridIdx);
  
              // Get old vertex coordinate index (before vertex sorting)
              int oldIdx = sortVertices[i].originalIndex;
  
              // Store delta to the grid box origin in the integer vertex array. For the
              // X axis (which is sorted) we also do the delta to the previous coordinate
              // in the box.
              int deltaX = (int) floor(scale * (vertices[oldIdx * 3] - gridOrigin[0]) + 0.5f);
              if (gridIdx == prevGridIndex) {
                  intVertices[i * 3] = deltaX - prevDeltaX;
              } else {
                  intVertices[i * 3] = deltaX;
              }
  
              intVertices[i * 3 + 1] = (int) floor(scale * (vertices[oldIdx * 3 + 1] - gridOrigin[1]) + 0.5f);
              intVertices[i * 3 + 2] = (int) floor(scale * (vertices[oldIdx * 3 + 2] - gridOrigin[2]) + 0.5f);
  
              prevGridIndex = gridIdx;
              prevDeltaX = deltaX;
          }
  
          return intVertices;
      }
docs: Calculate various forms of derivatives in order to reduce data entropy.
  
  @param vertices vertex data
  @param sortVertices sorted vertices
  @param grid gird definition
  @return encoded vertex data