public bool ModifyTerrain(SimClient simClient, Packet packet) { ModifyLandPacket modify = (ModifyLandPacket)packet; switch (modify.ModifyBlock.Action) { case 1: // raise terrain if (modify.ParcelData.Length > 0) { 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) { 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; } return(true); }
/// <summary> /// Terraform (raise, lower, etc) an area or whole parcel of land /// </summary> /// <param name="simulator">Simulator land area is in.</param> /// <param name="localID">LocalID of parcel, or -1 if using bounding box</param> /// <param name="west">west border of area to modify</param> /// <param name="south">south border of area to modify</param> /// <param name="east">east border of area to modify</param> /// <param name="north">north border of area to modify</param> /// <param name="action">From Enum, Raise, Lower, Level, Smooth, Etc.</param> /// <param name="brushSize">Size of area to modify</param> /// <param name="seconds">How many meters + or - to lower, 1 = 1 meter</param> /// <param name="height">Height at which the terraform operation is acting at</param> public void Terraform(Simulator simulator, int localID, float west, float south, float east, float north, TerraformAction action, TerraformBrushSize brushSize, int seconds, float height) { ModifyLandPacket land = new ModifyLandPacket(); land.AgentData.AgentID = Client.Self.AgentID; land.AgentData.SessionID = Client.Self.SessionID; land.ModifyBlock.Action = (byte)action; land.ModifyBlock.BrushSize = (byte)brushSize; land.ModifyBlock.Seconds = seconds; land.ModifyBlock.Height = height; land.ParcelData = new ModifyLandPacket.ParcelDataBlock[1]; land.ParcelData[0] = new ModifyLandPacket.ParcelDataBlock(); land.ParcelData[0].LocalID = localID; land.ParcelData[0].West = west; land.ParcelData[0].South = south; land.ParcelData[0].East = east; land.ParcelData[0].North = north; Client.Network.SendPacket(land, simulator); }
private void ModifyLandHandler(Packet packet, LLAgent agent) { ModifyLandPacket modify = (ModifyLandPacket)packet; TerrainAction action = (TerrainAction)modify.ModifyBlock.Action; float height = modify.ModifyBlock.Height; float seconds = modify.ModifyBlock.Seconds; // TODO: Build a permission mask based on this agent's permission to edit the affected parcels bool[] allowMask = new bool[64 * 64]; for (int y = 0; y < 64; y++) { for (int x = 0; x < 64; x++) { allowMask[y * 64 + x] = true; } } // Build an edit mask that tracks all of the terrain blocks modified by this request bool[] editMask = new bool[16 * 16]; for (int i = 0; i < modify.ParcelData.Length; i++) { ModifyLandPacket.ParcelDataBlock block = modify.ParcelData[i]; int localID = block.LocalID; float north = block.North; float east = block.East; float south = block.South; float west = block.West; float size = (modify.ModifyBlockExtended.Length > i) ? modify.ModifyBlockExtended[i].BrushSize : modify.ModifyBlock.BrushSize; if (north == south && east == west) { // Terrain painting switch (action) { case TerrainAction.Raise: RaiseLowerSphere(allowMask, ref editMask, west, south, height, size, seconds); break; case TerrainAction.Flatten: FlattenSphere(allowMask, ref editMask, west, south, height, size, seconds); break; case TerrainAction.Lower: RaiseLowerSphere(allowMask, ref editMask, west, south, height, size, seconds * -1.0f); break; case TerrainAction.Noise: NoiseSphere(allowMask, ref editMask, west, south, height, size, seconds); break; case TerrainAction.Revert: RevertSphere(allowMask, ref editMask, west, south, height, size, seconds); break; case TerrainAction.Smooth: SmoothSphere(allowMask, ref editMask, west, south, height, size, seconds); break; default: m_log.Warn("Unhandled ModifyLand paint action " + action); break; } } else { // Terrain flooding switch (action) { case TerrainAction.Raise: case TerrainAction.Flatten: case TerrainAction.Lower: case TerrainAction.Noise: case TerrainAction.Revert: case TerrainAction.Smooth: default: m_log.Warn("Unhandled ModifyLand flood action " + action); break; } } } // Send updates out for any modified terrain blocks for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { if (editMask[y * 16 + x]) { m_scene.CreateInterestListEvent(new InterestListEvent( CreateTerrainEventID(x, y), TERRAIN, new Vector3(x * 16 + 8, y * 16 + 8, 0.0f), TERRAIN_SCALE, new int[] { x, y }) ); } } } }