private void endBoneAssigns() {
//        if (mesh != sharedMesh && isUsingSharedVerts(geom)) {
//            return;
//        }

        if (!actuallyHasWeights) {
            // No weights were actually written (the tag didn't have any entries)
            // remove those buffers
            mesh.clearBuffer(Type.BoneIndex);
            mesh.clearBuffer(Type.BoneWeight);

            weightsFloatData = null;
            indicesData = null;

            return;
        }

        //int vertCount = mesh.getVertexCount();
        int maxWeightsPerVert = 0;
        weightsFloatData.rewind();
        for (int v = 0; v < vertCount; v++) {
            float w0 = weightsFloatData.get(),
                    w1 = weightsFloatData.get(),
                    w2 = weightsFloatData.get(),
                    w3 = weightsFloatData.get();

            if (w3 != 0) {
                maxWeightsPerVert = Math.max(maxWeightsPerVert, 4);
            } else if (w2 != 0) {
                maxWeightsPerVert = Math.max(maxWeightsPerVert, 3);
            } else if (w1 != 0) {
                maxWeightsPerVert = Math.max(maxWeightsPerVert, 2);
            } else if (w0 != 0) {
                maxWeightsPerVert = Math.max(maxWeightsPerVert, 1);
            }

            float sum = w0 + w1 + w2 + w3;
            if (sum != 1f) {
                weightsFloatData.position(weightsFloatData.position() - 4);
                // Compute new weights based on sum.
                float sumToB = sum == 0 ? 0 : 1f / sum;
                weightsFloatData.put(w0 * sumToB);
                weightsFloatData.put(w1 * sumToB);
                weightsFloatData.put(w2 * sumToB);
                weightsFloatData.put(w3 * sumToB);
            }
        }
        weightsFloatData.rewind();

        actuallyHasWeights = false;
        weightsFloatData = null;
        indicesData = null;

        mesh.setMaxNumWeights(maxWeightsPerVert);
    }
Normalizes weights if needed and finds largest amount of weights used for
all vertices in the buffer.
jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MeshLoader.java