**BREAKING CHANGE** Changing the way terrain is stored and used internally.

This commit is contained in:
Adam Frisby
2007-04-06 18:48:23 +00:00
parent df4df07c39
commit fb0dffbf13
23 changed files with 299 additions and 76 deletions

View File

@@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
@@ -6,7 +6,8 @@
<ProjectGuid>{632E1BFD-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.RegionServer</AssemblyName>
@@ -15,9 +16,11 @@
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<AppDesignerFolder>
</AppDesignerFolder>
<RootNamespace>OpenSim.RegionServer</RootNamespace>
<StartupObject></StartupObject>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
@@ -28,7 +31,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
@@ -37,7 +41,8 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@@ -46,7 +51,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
@@ -55,26 +61,27 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<Reference Include="System">
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<Reference Include="System.Xml">
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<Reference Include="libsecondlife.dll">
<HintPath>..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Axiom.MathLib.dll" >
<Reference Include="Axiom.MathLib.dll">
<HintPath>..\bin\Axiom.MathLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Db4objects.Db4o.dll" >
<Reference Include="Db4objects.Db4o.dll">
<HintPath>..\bin\Db4objects.Db4o.dll</HintPath>
<Private>False</Private>
</Reference>
@@ -84,31 +91,35 @@
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
<Name>OpenSim.Framework.Console</Name>
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.GenericConfig\Xml\OpenSim.GenericConfig.Xml.csproj">
<Name>OpenSim.GenericConfig.Xml</Name>
<Project>{E88EF749-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj">
<Name>OpenSim.Physics.Manager</Name>
<Project>{8BE16150-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj">
<Project>{FFD5951C-4002-4ACA-9ADF-68852357B94A}</Project>
<Name>OpenSim.Terrain.BasicTerrain</Name>
</ProjectReference>
<ProjectReference Include="..\Servers\OpenSim.Servers.csproj">
<Name>OpenSim.Servers</Name>
<Project>{8BB20F0A-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
@@ -222,4 +233,4 @@
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>

View File

@@ -156,7 +156,7 @@ namespace OpenSim
m_console.WriteLine("Main.cs:Startup() - Starting up messaging system");
LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use
LocalWorld.PhysScene.SetTerrain(LocalWorld.LandMap);
LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.map);
//should be passing a IGenericConfig object to these so they can read the config data they want from it
GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);

View File

@@ -44,7 +44,7 @@ namespace OpenSim.world
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
ControllingClient = TheClient;
localid = 8880000 + (this.m_world._localNumber++);
Pos = new LLVector3(100.0f, 100.0f, m_world.LandMap[(int)Pos.Y * 256 + (int)Pos.X] + 1);
Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain.map[(int)Pos.X, (int)Pos.Y] + 1.0f);
visualParams = new byte[218];
for (int i = 0; i < 218; i++)
{
@@ -332,7 +332,7 @@ namespace OpenSim.world
public override void LandRenegerated()
{
Pos = new LLVector3(100.0f, 100.0f, this.m_world.LandMap[(int)Pos.Y * 256 + (int)Pos.X] + 50);
Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain.map[(int)Pos.X, (int)Pos.Y] + 50.0f);
}
}

View File

@@ -14,6 +14,7 @@ using OpenSim.Assets;
using OpenSim.world.scripting;
using OpenSim.RegionServer.world.scripting;
using OpenSim.RegionServer.world.scripting.Scripts;
using OpenSim.Terrain;
namespace OpenSim.world
{
@@ -23,8 +24,9 @@ namespace OpenSim.world
public Dictionary<libsecondlife.LLUUID, Entity> Entities;
public Dictionary<libsecondlife.LLUUID, Avatar> Avatars;
public Dictionary<libsecondlife.LLUUID, Primitive> Prims;
public float[] LandMap;
// public float[] LandMap;
public ScriptEngine Scripts;
public TerrainEngine Terrain; //TODO: Replace TerrainManager with this.
public uint _localNumber = 0;
private PhysicsScene phyScene;
private float timeStep = 0.1f;
@@ -189,13 +191,13 @@ namespace OpenSim.world
public void RegenerateTerrain()
{
HeightmapGenHills hills = new HeightmapGenHills();
this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
Terrain.hills();
lock (this.LockPhysicsEngine)
{
this.phyScene.SetTerrain(this.LandMap);
this.phyScene.SetTerrain(Terrain.map);
}
this.localStorage.SaveMap(this.LandMap);
this.localStorage.SaveMap(this.Terrain.map);
foreach (SimClient client in m_clientThreads.Values)
{
@@ -208,14 +210,14 @@ namespace OpenSim.world
}
}
public void RegenerateTerrain(float[] newMap)
public void RegenerateTerrain(float[,] newMap)
{
this.LandMap = newMap;
this.Terrain.map = newMap;
lock (this.LockPhysicsEngine)
{
this.phyScene.SetTerrain(this.LandMap);
this.phyScene.SetTerrain(this.Terrain.map);
}
this.localStorage.SaveMap(this.LandMap);
this.localStorage.SaveMap(this.Terrain.map);
foreach (SimClient client in m_clientThreads.Values)
{
@@ -234,9 +236,9 @@ namespace OpenSim.world
{
lock (this.LockPhysicsEngine)
{
this.phyScene.SetTerrain(this.LandMap);
this.phyScene.SetTerrain(this.Terrain.map);
}
this.localStorage.SaveMap(this.LandMap);
this.localStorage.SaveMap(this.Terrain.map);
foreach (SimClient client in m_clientThreads.Values)
{
@@ -249,7 +251,7 @@ namespace OpenSim.world
public void LoadWorldMap()
{
LandMap = this.localStorage.LoadWorld();
Terrain.map = this.localStorage.LoadWorld();
}
public void LoadPrimsFromStorage()
@@ -288,7 +290,7 @@ namespace OpenSim.world
patches[2] = x + 2 + y * 16;
patches[3] = x + 3 + y * 16;
Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches);
Packet layerpack = TerrainManager.CreateLandPacket(Terrain.map, patches);
RemoteClient.OutPacket(layerpack);
}
}
@@ -310,7 +312,7 @@ namespace OpenSim.world
//patches[2] = patchx + 2 + patchy * 16;
//patches[3] = patchx + 3 + patchy * 16;
Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches);
Packet layerpack = TerrainManager.CreateLandPacket(Terrain.map, patches);
RemoteClient.OutPacket(layerpack);
}

View File

@@ -24,34 +24,16 @@ namespace OpenSim.world
// raise terrain
if (modify.ParcelData.Length > 0)
{
int mody = (int)modify.ParcelData[0].North;
int modx = (int)modify.ParcelData[0].West;
lock (LandMap)
{
LandMap[(mody * 256) + modx - 1] += 0.05f;
LandMap[(mody * 256) + modx] += 0.1f;
LandMap[(mody * 256) + modx + 1] += 0.05f;
LandMap[((mody + 1) * 256) + modx] += 0.05f;
LandMap[((mody - 1) * 256) + modx] += 0.05f;
}
RegenerateTerrain(true, modx, mody);
Terrain.raise(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
}
break;
case 2:
//lower terrain
if (modify.ParcelData.Length > 0)
{
int mody = (int)modify.ParcelData[0].North;
int modx = (int)modify.ParcelData[0].West;
lock (LandMap)
{
LandMap[(mody * 256) + modx - 1] -= 0.05f;
LandMap[(mody * 256) + modx] -= 0.1f;
LandMap[(mody * 256) + modx + 1] -= 0.05f;
LandMap[((mody + 1) * 256) + modx] -= 0.05f;
LandMap[((mody - 1) * 256) + modx] -= 0.05f;
}
RegenerateTerrain(true, modx, mody);
Terrain.lower(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
}
break;
}