Example #1
0
    public bool CheckChange()
    {
        var chg = old_mapExtent != mapExtent ||
                  old_maxVertsPerMesh != maxVertsPerMesh ||
                  old_hmult != hmult ||
                  old_synthTex != synthTex ||
                  old_flatTris != flatTriangles ||
                  old_mappprov != mapprov ||
                  old_normmethod != normmethod ||
                  old_nodefak != nodefak ||
                  old_heightType != heightType ||
                  old_useElevationData != useElevationData;

        if (updcount == 0 || chg)
        {
            old_mapExtent        = mapExtent;
            old_flatTris         = flatTriangles;
            old_hmult            = hmult;
            old_useElevationData = useElevationData;
            old_mappprov         = mapprov;
            old_normmethod       = normmethod;
            old_nodefak          = nodefak;
            old_synthTex         = synthTex;
            old_maxVertsPerMesh  = maxVertsPerMesh;
            old_addMeshColliders = addMeshColliders;
            old_heightType       = heightType;
        }
        if (chg)
        {
            Debug.Log("Change " + heightType);
        }
        return(chg);
    }
Example #2
0
    public static void ZipUpNormals(MfWrap mfw1, MfWrap mfw2, NormalAvgMethod method)
    {
        //Debug.Log("Starting ZipUpNormalsOld - method:" + method);
        var sw = new StopWatch();

        if (method == NormalAvgMethod.DoNothing)
        {
            return;
        }

        if (mfw1.nHorzSecs != mfw2.nHorzSecs)
        {
            Debug.LogError("Can't zip up MfWrap normals if nHorzSecs are unequal");
            return;
        }
        var mf1    = mfw1.GetComponent <MeshFilter>();
        var mf2    = mfw2.GetComponent <MeshFilter>();
        var norms1 = mf1.mesh.normals;
        var norms2 = mf2.mesh.normals;
        var iz1    = mfw1.nVertSecs;
        var iz2    = 0;

        for (var ix = 0; ix <= mfw1.nHorzSecs; ix++)
        {
            var idx1 = mfw1.GetNormIndex(ix, iz1);
            var idx2 = mfw1.GetNormIndex(ix, iz2);
            var n1   = norms1[idx1];
            var n2   = norms2[idx2];
            var n3   = Vector3.up;
            switch (method)
            {
            case NormalAvgMethod.Norm1:
                n3 = n1;
                break;

            case NormalAvgMethod.Norm2:
                n3 = n2;
                break;

            case NormalAvgMethod.Avg:
                n3 = n1 + n2;
                break;

            case NormalAvgMethod.AlwaysUp:
                n3 = Vector3.up;
                break;

            case NormalAvgMethod.AlwaysUpLeft:
                n3 = new Vector3(1, 1, 0);
                break;

            case NormalAvgMethod.Zero:
                n3 = Vector3.zero;
                break;
            }
            n3           = n3.normalized;
            norms1[idx1] = n3;
            norms2[idx2] = n3;
        }
        mf1.mesh.normals = norms1;
        mf2.mesh.normals = norms2;
        sw.Stop();
        //Debug.Log("Did ZipUpNormals - method:" + method+" elap:"+sw.ElapSecs(5)+" secs");
    }