private static void trimBoneWeights(IrVertex vertex) {
        if (vertex.boneWeightsIndices == null) {
            return;
        }
        
        IrBoneWeightIndex[] boneWeightsIndices = vertex.boneWeightsIndices;
        
        if (boneWeightsIndices.length <= 4) {
            return;
        }
        
        // Sort by weight
        boneWeightsIndices = Arrays.copyOf(boneWeightsIndices, boneWeightsIndices.length);
        Arrays.sort(boneWeightsIndices);
        
        // Trim to four weights at most
        boneWeightsIndices = Arrays.copyOf(boneWeightsIndices, 4);
        
        // Renormalize weights
        float sum = 0;
        
        for (int i = 0; i < boneWeightsIndices.length; i++) {
            sum += boneWeightsIndices[i].boneWeight;
        }
        
        if (sum != 1f) {
            float sumToB = sum == 0 ? 0 : 1f / sum;
            for (int i = 0; i < boneWeightsIndices.length; i++) {
                IrBoneWeightIndex original = boneWeightsIndices[i];
                boneWeightsIndices[i] = new IrBoneWeightIndex(original.boneIndex, original.boneWeight * sumToB);
            }
        }
        
        vertex.boneWeightsIndices = boneWeightsIndices;
    }
Removes low bone weights from mesh, leaving only 4 bone weights at max.

@param vertex the IrVertex to modify (not null)
jme3-plugins/src/main/java/com/jme3/scene/plugins/IrUtils.java