Mantis#1543. Thank you kindly, Jonc for a patch that:
Implements terrain bake from Region/Estate dialog and respects estate settings during terraforming0.6.0-stable
parent
1d91613679
commit
838ffd7792
|
@ -420,7 +420,7 @@ namespace OpenSim.Framework
|
|||
case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT:
|
||||
float floatResult;
|
||||
if (
|
||||
float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo,
|
||||
float.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo,
|
||||
out floatResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
|
@ -431,7 +431,7 @@ namespace OpenSim.Framework
|
|||
case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE:
|
||||
double doubleResult;
|
||||
if (
|
||||
Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo,
|
||||
Double.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo,
|
||||
out doubleResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
|
|
|
@ -773,9 +773,9 @@ namespace OpenSim.Framework
|
|||
configMember.addConfigurationOption("sun_hour", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, String.Empty, "0",
|
||||
true);
|
||||
configMember.addConfigurationOption("terrain_raise_limit", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
|
||||
String.Empty, "0", true);
|
||||
String.Empty, "4.0", true); //4 is the LL default
|
||||
configMember.addConfigurationOption("terrain_lower_limit", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
|
||||
String.Empty, "0", true);
|
||||
String.Empty, "-4.0", true); //-4.0 is the LL default
|
||||
configMember.addConfigurationOption("use_fixed_sun", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, String.Empty,
|
||||
"false", true);
|
||||
configMember.addConfigurationOption("price_per_meter", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
|
||||
|
|
|
@ -633,6 +633,7 @@ namespace OpenSim.Framework
|
|||
public delegate void SetEstateTerrainTextureHeights(IClientAPI remoteClient, int corner, float lowVal, float highVal);
|
||||
public delegate void CommitEstateTerrainTextureRequest(IClientAPI remoteClient);
|
||||
public delegate void SetRegionTerrainSettings(float waterHeight, float terrainRaiseLimit, float terrainLowerLimit, bool fixedSun, float sunHour);
|
||||
public delegate void BakeTerrain(IClientAPI remoteClient );
|
||||
public delegate void EstateRestartSimRequest(IClientAPI remoteClient, int secondsTilReboot);
|
||||
public delegate void EstateChangeCovenantRequest(IClientAPI remoteClient, LLUUID newCovenantID);
|
||||
public delegate void UpdateEstateAccessDeltaRequest(IClientAPI remote_client, LLUUID invoice, int estateAccessType, LLUUID user);
|
||||
|
@ -693,6 +694,7 @@ namespace OpenSim.Framework
|
|||
event RezObject OnRezObject;
|
||||
[Obsolete("LLClientView Specific - Replace with more suitable arguments.")]
|
||||
event ModifyTerrain OnModifyTerrain;
|
||||
event BakeTerrain OnBakeTerrain;
|
||||
[Obsolete("LLClientView Specific.")]
|
||||
event SetAppearance OnSetAppearance;
|
||||
[Obsolete("LLClientView Specific - Replace and rename OnAvatarUpdate. Difference from SetAppearance?")]
|
||||
|
|
|
@ -159,6 +159,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
private RezObject handlerRezObject = null; //OnRezObject;
|
||||
private GenericCall4 handlerDeRezObject = null; //OnDeRezObject;
|
||||
private ModifyTerrain handlerModifyTerrain = null;
|
||||
private BakeTerrain handlerBakeTerrain = null;
|
||||
private Action<IClientAPI> handlerRegionHandShakeReply = null; //OnRegionHandShakeReply;
|
||||
private GenericCall2 handlerRequestWearables = null; //OnRequestWearables;
|
||||
private Action<IClientAPI> handlerRequestAvatarsData = null; //OnRequestAvatarsData;
|
||||
|
@ -893,6 +894,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
|
||||
public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
|
||||
public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
|
||||
public event BakeTerrain OnBakeTerrain;
|
||||
public event EstateRestartSimRequest OnEstateRestartSimRequest;
|
||||
public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
|
||||
public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
|
||||
|
@ -5846,6 +5848,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
handlerLandStatRequest(0, 0, 0, "", this);
|
||||
}
|
||||
break;
|
||||
case "terrain":
|
||||
if (((Scene)m_scene).ExternalChecks.ExternalChecksCanIssueEstateCommand(this.AgentId))
|
||||
{
|
||||
handlerBakeTerrain = OnBakeTerrain;
|
||||
if (handlerBakeTerrain != null)
|
||||
{
|
||||
handlerBakeTerrain(this);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket.ToString());
|
||||
break;
|
||||
|
|
|
@ -281,6 +281,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
|
|||
public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
|
||||
public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
|
||||
public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
|
||||
public event BakeTerrain OnBakeTerrain;
|
||||
public event EstateRestartSimRequest OnEstateRestartSimRequest;
|
||||
public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
|
||||
public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
|
||||
|
@ -776,5 +777,6 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
|
|||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -419,12 +419,27 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
|
|||
private void EventManager_OnNewClient(IClientAPI client)
|
||||
{
|
||||
client.OnModifyTerrain += client_OnModifyTerrain;
|
||||
client.OnBakeTerrain += client_OnBakeTerrain;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if the terrain has been modified since last check
|
||||
/// but won't attempt to limit those changes to the limits specified in the estate settings
|
||||
/// currently invoked by the command line operations in the region server only
|
||||
/// </summary>
|
||||
private void CheckForTerrainUpdates()
|
||||
{
|
||||
CheckForTerrainUpdates(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if the terrain has been modified since last check
|
||||
/// if the call is asked to respect the estate settings for terrain_raise_limit and
|
||||
/// terrain_lower_limit, it will clamp terrain updates between these values
|
||||
/// currently invoked by client_OnModifyTerrain only and not the Commander interfaces
|
||||
/// <param name="respectEstateSettings">should height map deltas be limited to the estate settings limits</param>
|
||||
/// </summary>
|
||||
private void CheckForTerrainUpdates(bool respectEstateSettings)
|
||||
{
|
||||
bool shouldTaint = false;
|
||||
float[] serialised = m_channel.GetFloatsSerialised();
|
||||
|
@ -436,6 +451,14 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
|
|||
{
|
||||
if (m_channel.Tainted(x, y))
|
||||
{
|
||||
// if we should respect the estate settings then
|
||||
// fixup and height deltas that don't respect them
|
||||
if (respectEstateSettings && LimitChannelChanges(x, y))
|
||||
{
|
||||
// this has been vetoed, so update
|
||||
// what we are going to send to the client
|
||||
serialised = m_channel.GetFloatsSerialised();
|
||||
}
|
||||
SendToClients(serialised, x, y);
|
||||
shouldTaint = true;
|
||||
}
|
||||
|
@ -447,6 +470,46 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see height deltas in the tainted terrain patch at xStart ,yStart
|
||||
/// are all within the current estate limits
|
||||
/// <returns>true if changes were limited, false otherwise</returns>
|
||||
/// </summary>
|
||||
private bool LimitChannelChanges(int xStart, int yStart)
|
||||
{
|
||||
bool changesLimited = false;
|
||||
double minDelta = m_scene.RegionInfo.EstateSettings.terrainLowerLimit;
|
||||
double maxDelta = m_scene.RegionInfo.EstateSettings.terrainRaiseLimit;
|
||||
|
||||
// loop through the height map for this patch and compare it against
|
||||
// the revert map
|
||||
for (int x = xStart; x < xStart + Constants.TerrainPatchSize; x++)
|
||||
{
|
||||
for (int y = yStart; y < yStart + Constants.TerrainPatchSize; y++)
|
||||
{
|
||||
|
||||
double requestedHeight = m_channel[x, y];
|
||||
double bakedHeight = m_revert[x, y];
|
||||
double requestedDelta = requestedHeight - bakedHeight;
|
||||
|
||||
if (requestedDelta > maxDelta )
|
||||
{
|
||||
m_channel[x, y] = bakedHeight + maxDelta;
|
||||
changesLimited = true;
|
||||
}
|
||||
else if (requestedDelta < minDelta)
|
||||
{
|
||||
m_channel[x, y] = bakedHeight + minDelta; //as lower is a -ve delta
|
||||
changesLimited = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return changesLimited;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sends a copy of the current terrain to the scenes clients
|
||||
/// </summary>
|
||||
|
@ -472,7 +535,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
|
|||
m_painteffects[(StandardTerrainEffects) action].PaintEffect(
|
||||
m_channel, west, south, size, seconds);
|
||||
|
||||
CheckForTerrainUpdates();
|
||||
CheckForTerrainUpdates(true); //revert changes outside estate limits
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -505,7 +568,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
|
|||
m_floodeffects[(StandardTerrainEffects) action].FloodEffect(
|
||||
m_channel, fillArea, size);
|
||||
|
||||
CheckForTerrainUpdates();
|
||||
CheckForTerrainUpdates(true); //revert changes outside estate limits
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -515,6 +578,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
|
|||
}
|
||||
}
|
||||
|
||||
private void client_OnBakeTerrain(IClientAPI remoteClient)
|
||||
{
|
||||
// Not a good permissions check (see client_OnModifyTerrain above), need to check the entire area.
|
||||
// for now check a point in the centre of the region
|
||||
|
||||
if (m_scene.ExternalChecks.ExternalChecksCanTerraformLand(remoteClient.AgentId, new LLVector3(127, 127, 0)))
|
||||
{
|
||||
InterfaceBakeTerrain(null); //bake terrain does not use the passed in parameter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Console Commands
|
||||
|
||||
private void InterfaceLoadFile(Object[] args)
|
||||
|
|
|
@ -57,6 +57,7 @@ namespace OpenSim.Region.Examples.SimpleModule
|
|||
public event TextureRequest OnRequestTexture;
|
||||
public event RezObject OnRezObject;
|
||||
public event ModifyTerrain OnModifyTerrain;
|
||||
public event BakeTerrain OnBakeTerrain;
|
||||
public event SetAppearance OnSetAppearance;
|
||||
public event AvatarNowWearing OnAvatarNowWearing;
|
||||
public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
|
||||
|
|
Loading…
Reference in New Issue