From abb193ec9421f167286f5cd07ff8d2b1fe207749 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 22 Jan 2014 16:14:42 +0200 Subject: In UuidGatherer, gather materials referenced in the prim's TextureEntry Signed-off-by: dahlia --- OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 75a51b5..fe6cb84 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -161,7 +161,7 @@ namespace OpenSim.Region.Framework.Scenes { // Get the prim's default texture. This will be used for faces which don't have their own texture if (textureEntry.DefaultTexture != null) - assetUuids[textureEntry.DefaultTexture.TextureID] = (sbyte)AssetType.Texture; + GatherTextureEntryAssets(textureEntry.DefaultTexture, assetUuids); if (textureEntry.FaceTextures != null) { @@ -169,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) { if (texture != null) - assetUuids[texture.TextureID] = (sbyte)AssetType.Texture; + GatherTextureEntryAssets(texture, assetUuids); } } } @@ -233,6 +233,19 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Gather all the asset uuids found in one face of a Texture Entry. + /// + private void GatherTextureEntryAssets(Primitive.TextureEntryFace texture, IDictionary assetUuids) + { + assetUuids[texture.TextureID] = (sbyte)AssetType.Texture; + + if (texture.MaterialID != UUID.Zero) + { + GatherAssetUuids(texture.MaterialID, (sbyte)OpenSimAssetType.Material, assetUuids); + } + } + // /// // /// The callback made when we request the asset for an object from the asset service. // /// -- cgit v1.1 From a8e64cd59a7a296b7cae6fc0a66255a7f566e10d Mon Sep 17 00:00:00 2001 From: dahlia Date: Sat, 1 Feb 2014 04:09:20 -0800 Subject: Overload INPCModule.CreateNPC() to allow agentID to be specified. Note: this is intended for use in region modules and is not exposed to scripts. --- OpenSim/Region/Framework/Interfaces/INPCModule.cs | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index 9817cf7..d5dcddd 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs @@ -72,6 +72,32 @@ namespace OpenSim.Region.Framework.Interfaces AvatarAppearance appearance); /// + /// Create an NPC with a user-supplied agentID + /// + /// + /// + /// + /// + /// The desired agent ID + /// + /// + /// Make the NPC show up as an agent on LSL sensors. The default is + /// that they show up as the NPC type instead, but this is currently + /// an OpenSim-only extension. + /// + /// + /// + /// The avatar appearance to use for the new NPC. + /// + /// + /// The UUID of the ScenePresence created. UUID.Zero if there was a + /// failure. + /// + UUID CreateNPC(string firstname, string lastname, + Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene, + AvatarAppearance appearance); + + /// /// Check if the agent is an NPC. /// /// -- cgit v1.1 From 9c97fb8e127e91d48cf92eeed238cf80878e2286 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 2 Feb 2014 11:17:49 -0800 Subject: Implement terrain merging in TerrainChannel. Modify archiver to use terrain merging when loading oars. This makes displacement AND rotation properly work on terrain when loading oars. Especially useful when loading legacy region oars into large varregions. --- .../Region/Framework/Interfaces/ITerrainChannel.cs | 3 + .../Region/Framework/Interfaces/ITerrainModule.cs | 2 +- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 72 ++++++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs index 469bd31..f660b8d 100644 --- a/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs +++ b/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs @@ -26,6 +26,7 @@ */ using OpenSim.Framework; +using OpenMetaverse; namespace OpenSim.Region.Framework.Interfaces { @@ -56,5 +57,7 @@ namespace OpenSim.Region.Framework.Interfaces ITerrainChannel MakeCopy(); string SaveToXmlString(); void LoadFromXmlString(string data); + // Merge some terrain into this channel + void Merge(ITerrainChannel newTerrain, Vector3 displacement, float radianRotation, Vector2 rotationDisplacement); } } diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs index 189a30a..a6f5d98 100644 --- a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs @@ -51,7 +51,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// void LoadFromStream(string filename, Stream stream); - void LoadFromStream(string filename, Vector2 displacement, Stream stream); + void LoadFromStream(string filename, Vector3 displacement, float radianRotation, Vector2 rotationDisplacement, Stream stream); void LoadFromStream(string filename, System.Uri pathToTerrainHeightmap); /// /// Save a terrain to a stream. diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index b4b1823..24709dc 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -36,6 +36,8 @@ using OpenSim.Data; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; +using OpenMetaverse; + using log4net; namespace OpenSim.Region.Framework.Scenes @@ -212,6 +214,76 @@ namespace OpenSim.Region.Framework.Scenes sr.Close(); } + // ITerrainChannel.Merge + public void Merge(ITerrainChannel newTerrain, Vector3 displacement, float radianRotation, Vector2 rotationDisplacement) + { + for (int xx = 0; xx < newTerrain.Width; xx++) + { + for (int yy = 0; yy < newTerrain.Height; yy++) + { + int dispX = (int)displacement.X; + int dispY = (int)displacement.Y; + float newHeight = (float)newTerrain[xx, yy] + displacement.Z; + if (radianRotation == 0) + { + // If no rotation, place the new height in the specified location + dispX += xx; + dispY += yy; + if (dispX >= 0 && dispX < m_terrainData.SizeX && dispY >= 0 && dispY < m_terrainData.SizeY) + { + m_terrainData[dispX, dispY] = newHeight; + } + } + else + { + // If rotating, we have to smooth the result because the conversion + // to ints will mean heightmap entries will not get changed + // First compute the rotation location for the new height. + dispX += (int)(rotationDisplacement.X + + ((float)xx - rotationDisplacement.X) * Math.Cos(radianRotation) + - ((float)yy - rotationDisplacement.Y) * Math.Sin(radianRotation) ); + + dispY += (int)(rotationDisplacement.Y + + ((float)xx - rotationDisplacement.X) * Math.Sin(radianRotation) + + ((float)yy - rotationDisplacement.Y) * Math.Cos(radianRotation) ); + + if (dispX >= 0 && dispX < m_terrainData.SizeX && dispY >= 0 && dispY < m_terrainData.SizeY) + { + float oldHeight = m_terrainData[dispX, dispY]; + // Smooth the heights around this location if the old height is far from this one + for (int sxx = dispX - 2; sxx < dispX + 2; sxx++) + { + for (int syy = dispY - 2; syy < dispY + 2; syy++) + { + if (sxx >= 0 && sxx < m_terrainData.SizeX && syy >= 0 && syy < m_terrainData.SizeY) + { + if (sxx == dispX && syy == dispY) + { + // Set height for the exact rotated point + m_terrainData[dispX, dispY] = newHeight; + } + else + { + if (Math.Abs(m_terrainData[sxx, syy] - newHeight) > 1f) + { + // If the adjacent height is far off, force it to this height + m_terrainData[sxx, syy] = newHeight; + } + } + } + } + } + } + + if (dispX >= 0 && dispX < m_terrainData.SizeX && dispY >= 0 && dispY < m_terrainData.SizeY) + { + m_terrainData[dispX, dispY] = (float)newTerrain[xx, yy]; + } + } + } + } + } + #endregion public TerrainChannel Copy() -- cgit v1.1