aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs
blob: cf95f3fb2ed02bbac5a75ebbc4574ca12228a092 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Environment.Modules.Terrain;
using OpenSim.Region.Environment.Interfaces;

namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{
    class RaiseSphere : ITerrainPaintableEffect
    {
        #region ITerrainPaintableEffect Members

        public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength)
        {
            int x, y;
            for (x = 0; x < map.Width; x++)
            {
                // Skip everything unlikely to be affected
                if (Math.Abs(x - rx) > strength * 1.1)
                    continue;

                for (y = 0; y < map.Height; y++)
                {
                    // Skip everything unlikely to be affected
                    if (Math.Abs(y - ry) > strength * 1.1)
                        continue;

                    // Calculate a sphere and add it to the heighmap
                    double z = strength;
                    z *= z;
                    z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));

                    if (z > 0.0)
                        map[x, y] += z;
                }
            }
        }

        #endregion
    }
}