Exemple #1
0
    protected override void ApplyTopology(Matrix4x4 localToWorld, Matrix4x4 worldToLocal)
    {
        if (Radius == 0f)
        {
            Radius = extents.x;
        }
        TextureData topologydata = new TextureData(topologymap.Get());
        Vector3     v            = localToWorld.MultiplyPoint3x4(offset + new Vector3(0f - Radius, 0f, 0f - Radius));
        Vector3     v2           = localToWorld.MultiplyPoint3x4(offset + new Vector3(Radius, 0f, 0f - Radius));
        Vector3     v3           = localToWorld.MultiplyPoint3x4(offset + new Vector3(0f - Radius, 0f, Radius));
        Vector3     v4           = localToWorld.MultiplyPoint3x4(offset + new Vector3(Radius, 0f, Radius));

        TerrainMeta.TopologyMap.ForEachParallel(v, v2, v3, v4, delegate(int x, int z)
        {
            GenerateCliffTopology.Process(x, z);
            float normZ         = TerrainMeta.TopologyMap.Coordinate(z);
            float normX         = TerrainMeta.TopologyMap.Coordinate(x);
            Vector3 point       = new Vector3(TerrainMeta.DenormalizeX(normX), 0f, TerrainMeta.DenormalizeZ(normZ));
            Vector3 vector      = worldToLocal.MultiplyPoint3x4(point) - offset;
            int interpolatedInt = topologydata.GetInterpolatedInt((vector.x + extents.x) / size.x, (vector.z + extents.z) / size.z);
            if (ShouldTopology(interpolatedInt))
            {
                TerrainMeta.TopologyMap.AddTopology(x, z, interpolatedInt & (int)TopologyMask);
            }
        });
    }
    public override void Process(uint seed)
    {
        int[] topologyMap = TerrainMeta.TopologyMap.dst;
        int   num         = TerrainMeta.TopologyMap.res;

        Parallel.For(0, num, (int z) => {
            for (int i = 0; i < num; i++)
            {
                GenerateCliffTopology.Process(i, z, this.KeepExisting);
            }
        });
        ImageProcessing.Dilate2D(topologyMap, num, num, 4194306, 1, (int x, int y) => {
            if ((topologyMap[x * num + y] & 2) == 0)
            {
                topologyMap[x * num + y] |= 4194304;
            }
        });
    }
Exemple #3
0
    protected override void ApplyTopology(Matrix4x4 localToWorld, Matrix4x4 worldToLocal)
    {
        TextureData textureDatum = new TextureData(this.topologymap);
        Vector3     vector32     = localToWorld.MultiplyPoint3x4(this.offset + new Vector3(-this.extents.x, 0f, -this.extents.z));
        Vector3     vector33     = localToWorld.MultiplyPoint3x4(this.offset + new Vector3(this.extents.x, 0f, -this.extents.z));
        Vector3     vector34     = localToWorld.MultiplyPoint3x4(this.offset + new Vector3(-this.extents.x, 0f, this.extents.z));
        Vector3     vector35     = localToWorld.MultiplyPoint3x4(this.offset + new Vector3(this.extents.x, 0f, this.extents.z));

        TerrainMeta.TopologyMap.ForEachParallel(vector32, vector33, vector34, vector35, (int x, int z) => {
            GenerateCliffTopology.Process(x, z);
            float single        = TerrainMeta.TopologyMap.Coordinate(z);
            Vector3 vector3     = new Vector3(TerrainMeta.DenormalizeX(TerrainMeta.TopologyMap.Coordinate(x)), 0f, TerrainMeta.DenormalizeZ(single));
            Vector3 vector31    = worldToLocal.MultiplyPoint3x4(vector3) - this.offset;
            int interpolatedInt = textureDatum.GetInterpolatedInt((vector31.x + this.extents.x) / this.size.x, (vector31.z + this.extents.z) / this.size.z);
            if (base.ShouldTopology(interpolatedInt))
            {
                TerrainMeta.TopologyMap.AddTopology(x, z, interpolatedInt & (int)this.TopologyMask);
            }
        });
    }
    protected override void ApplyTopology(Matrix4x4 localToWorld, Matrix4x4 worldToLocal)
    {
        TextureData topologydata = new TextureData(this.topologymap);

        TerrainMeta.TopologyMap.ForEachParallel(((Matrix4x4) ref localToWorld).MultiplyPoint3x4(Vector3.op_Addition(this.offset, new Vector3((float)-this.extents.x, 0.0f, (float)-this.extents.z))), ((Matrix4x4) ref localToWorld).MultiplyPoint3x4(Vector3.op_Addition(this.offset, new Vector3((float)this.extents.x, 0.0f, (float)-this.extents.z))), ((Matrix4x4) ref localToWorld).MultiplyPoint3x4(Vector3.op_Addition(this.offset, new Vector3((float)-this.extents.x, 0.0f, (float)this.extents.z))), ((Matrix4x4) ref localToWorld).MultiplyPoint3x4(Vector3.op_Addition(this.offset, new Vector3((float)this.extents.x, 0.0f, (float)this.extents.z))), (Action <int, int>)((x, z) =>
        {
            GenerateCliffTopology.Process(x, z);
            float normZ = TerrainMeta.TopologyMap.Coordinate(z);
            float normX = TerrainMeta.TopologyMap.Coordinate(x);
            Vector3 vector3_1;
            ((Vector3) ref vector3_1).\u002Ector(TerrainMeta.DenormalizeX(normX), 0.0f, TerrainMeta.DenormalizeZ(normZ));
            Vector3 vector3_2   = Vector3.op_Subtraction(((Matrix4x4) ref worldToLocal).MultiplyPoint3x4(vector3_1), this.offset);
            int interpolatedInt = topologydata.GetInterpolatedInt((float)((vector3_2.x + this.extents.x) / this.size.x), (float)((vector3_2.z + this.extents.z) / this.size.z));
            if (!this.ShouldTopology(interpolatedInt))
            {
                return;
            }
            TerrainMeta.TopologyMap.AddTopology(x, z, interpolatedInt & this.TopologyMask);
        }));
    }
Exemple #5
0
    public override void Process(uint seed)
    {
        int[] map = TerrainMeta.TopologyMap.dst;
        int   res = TerrainMeta.TopologyMap.res;

        Parallel.For(0, res, (Action <int>)(z =>
        {
            for (int x = 0; x < res; ++x)
            {
                GenerateCliffTopology.Process(x, z, this.KeepExisting);
            }
        }));
        ImageProcessing.Dilate2D(map, res, res, 4194306, 1, (Action <int, int>)((x, y) =>
        {
            if ((map[x * res + y] & 2) != 0)
            {
                return;
            }
            map[x * res + y] |= 4194304;
        }));
    }