diff options
author | Robert Adams | 2014-02-02 11:17:49 -0800 |
---|---|---|
committer | Robert Adams | 2014-02-02 11:17:49 -0800 |
commit | 9c97fb8e127e91d48cf92eeed238cf80878e2286 (patch) | |
tree | a0d00a1707f45121137d210f18b8b9525cc3ab48 /OpenSim/Region/CoreModules/World/Archiver | |
parent | Overload INPCModule.CreateNPC() to allow agentID to be specified. Note: this ... (diff) | |
download | opensim-SC_OLD-9c97fb8e127e91d48cf92eeed238cf80878e2286.zip opensim-SC_OLD-9c97fb8e127e91d48cf92eeed238cf80878e2286.tar.gz opensim-SC_OLD-9c97fb8e127e91d48cf92eeed238cf80878e2286.tar.bz2 opensim-SC_OLD-9c97fb8e127e91d48cf92eeed238cf80878e2286.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 40 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs | 31 |
2 files changed, 49 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index f4807ad..6f68966 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
121 | protected Vector3 m_displacement = Vector3.Zero; | 121 | protected Vector3 m_displacement = Vector3.Zero; |
122 | 122 | ||
123 | /// <value> | 123 | /// <value> |
124 | /// Rotation to apply to the objects as they are loaded. | 124 | /// Rotation (in radians) to apply to the objects as they are loaded. |
125 | /// </value> | 125 | /// </value> |
126 | protected float m_rotation = 0f; | 126 | protected float m_rotation = 0f; |
127 | 127 | ||
@@ -184,7 +184,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
184 | m_displacement = options.ContainsKey("displacement") ? (Vector3)options["displacement"] : Vector3.Zero; | 184 | m_displacement = options.ContainsKey("displacement") ? (Vector3)options["displacement"] : Vector3.Zero; |
185 | m_rotation = options.ContainsKey("rotation") ? (float)options["rotation"] : 0f; | 185 | m_rotation = options.ContainsKey("rotation") ? (float)options["rotation"] : 0f; |
186 | m_rotationCenter = options.ContainsKey("rotationCenter") ? (Vector3)options["rotationCenter"] | 186 | m_rotationCenter = options.ContainsKey("rotationCenter") ? (Vector3)options["rotationCenter"] |
187 | : new Vector3(Constants.RegionSize / 2f, Constants.RegionSize / 2f, 0f); | 187 | : new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 0f); |
188 | 188 | ||
189 | // Zero can never be a valid user id | 189 | // Zero can never be a valid user id |
190 | m_validUserUuids[UUID.Zero] = false; | 190 | m_validUserUuids[UUID.Zero] = false; |
@@ -454,8 +454,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
454 | // Reload serialized prims | 454 | // Reload serialized prims |
455 | m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); | 455 | m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); |
456 | 456 | ||
457 | float angle = (float)(m_rotation / 180.0 * Math.PI); | 457 | OpenMetaverse.Quaternion rot = OpenMetaverse.Quaternion.CreateFromAxisAngle(0, 0, 1, m_rotation); |
458 | OpenMetaverse.Quaternion rot = OpenMetaverse.Quaternion.CreateFromAxisAngle(0, 0, 1, angle); | ||
459 | 458 | ||
460 | UUID oldTelehubUUID = scene.RegionInfo.RegionSettings.TelehubObject; | 459 | UUID oldTelehubUUID = scene.RegionInfo.RegionSettings.TelehubObject; |
461 | 460 | ||
@@ -483,16 +482,25 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
483 | // Happily this does not do much to the object since it hasn't been added to the scene yet | 482 | // Happily this does not do much to the object since it hasn't been added to the scene yet |
484 | if (sceneObject.AttachmentPoint == 0) | 483 | if (sceneObject.AttachmentPoint == 0) |
485 | { | 484 | { |
486 | if (angle != 0f) | 485 | if (m_displacement != Vector3.Zero || m_rotation != 0f) |
487 | { | 486 | { |
488 | sceneObject.RootPart.RotationOffset = rot * sceneObject.GroupRotation; | 487 | Vector3 pos = sceneObject.AbsolutePosition; |
489 | Vector3 offset = sceneObject.AbsolutePosition - m_rotationCenter; | 488 | if (m_rotation != 0f) |
490 | offset *= rot; | 489 | { |
491 | sceneObject.AbsolutePosition = m_rotationCenter + offset; | 490 | // Rotate the object |
492 | } | 491 | sceneObject.RootPart.RotationOffset = rot * sceneObject.GroupRotation; |
493 | if (m_displacement != Vector3.Zero) | 492 | // Get object position relative to rotation axis |
494 | { | 493 | Vector3 offset = pos - m_rotationCenter; |
495 | sceneObject.AbsolutePosition += m_displacement; | 494 | // Rotate the object position |
495 | offset *= rot; | ||
496 | // Restore the object position back to relative to the region | ||
497 | pos = m_rotationCenter + offset; | ||
498 | } | ||
499 | if (m_displacement != Vector3.Zero) | ||
500 | { | ||
501 | pos += m_displacement; | ||
502 | } | ||
503 | sceneObject.AbsolutePosition = pos; | ||
496 | } | 504 | } |
497 | } | 505 | } |
498 | 506 | ||
@@ -868,10 +876,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
868 | ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); | 876 | ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); |
869 | 877 | ||
870 | MemoryStream ms = new MemoryStream(data); | 878 | MemoryStream ms = new MemoryStream(data); |
871 | if (m_displacement != Vector3.Zero) | 879 | if (m_displacement != Vector3.Zero || m_rotation != 0f) |
872 | { | 880 | { |
873 | Vector2 terrainDisplacement = new Vector2(m_displacement.X, m_displacement.Y); | 881 | Vector2 rotationCenter = new Vector2(m_rotationCenter.X, m_rotationCenter.Y); |
874 | terrainModule.LoadFromStream(terrainPath, terrainDisplacement, ms); | 882 | terrainModule.LoadFromStream(terrainPath, m_displacement, m_rotation, rotationCenter, ms); |
875 | } | 883 | } |
876 | else | 884 | else |
877 | { | 885 | { |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 2a6f1eb..6fbac4c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs | |||
@@ -120,19 +120,38 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
120 | { | 120 | { |
121 | displacement = v == null ? Vector3.Zero : Vector3.Parse(v); | 121 | displacement = v == null ? Vector3.Zero : Vector3.Parse(v); |
122 | } | 122 | } |
123 | catch (Exception e) | 123 | catch |
124 | { | 124 | { |
125 | m_log.ErrorFormat("[ARCHIVER MODULE] failure parsing displacement"); | 125 | m_log.ErrorFormat("[ARCHIVER MODULE] failure parsing displacement"); |
126 | displacement = new Vector3(0f, 0f, 0f); | 126 | m_log.ErrorFormat("[ARCHIVER MODULE] Must be represented as vector3: --displacement \"<128,128,0>\""); |
127 | return; | ||
127 | } | 128 | } |
128 | }); | 129 | }); |
129 | options.Add("rotation=", delegate (string v) { | 130 | options.Add("rotation=", delegate (string v) { |
130 | rotation = float.Parse(v); | 131 | try |
131 | rotation = Util.Clamp<float>(rotation, -359f, 359f); | 132 | { |
133 | rotation = v == null ? 0f : float.Parse(v); | ||
134 | } | ||
135 | catch | ||
136 | { | ||
137 | m_log.ErrorFormat("[ARCHIVER MODULE] failure parsing rotation"); | ||
138 | m_log.ErrorFormat("[ARCHIVER MODULE] Must be an angle in degrees between -360 and +360: --rotation 45"); | ||
139 | return; | ||
140 | } | ||
141 | // Convert to radians for internals | ||
142 | rotation = Util.Clamp<float>(rotation, -359f, 359f) / 180f * (float)Math.PI; | ||
132 | }); | 143 | }); |
133 | options.Add("rotationcenter=", delegate (string v) { | 144 | options.Add("rotationcenter=", delegate (string v) { |
134 | // RA 20130119: libomv's Vector2.Parse doesn't work. Need to use vector3 for the moment | 145 | try |
135 | rotationCenter = Vector3.Parse(v); | 146 | { |
147 | rotationCenter = v == null ? Vector3.Zero : Vector3.Parse(v); | ||
148 | } | ||
149 | catch | ||
150 | { | ||
151 | m_log.ErrorFormat("[ARCHIVER MODULE] failure parsing rotation displacement"); | ||
152 | m_log.ErrorFormat("[ARCHIVER MODULE] Must be represented as vector3: --rotationcenter \"<128,128,0>\""); | ||
153 | return; | ||
154 | } | ||
136 | }); | 155 | }); |
137 | 156 | ||
138 | // Send a message to the region ready module | 157 | // Send a message to the region ready module |