aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2010-04-13 04:36:08 +0100
committerMelanie2010-04-13 04:36:08 +0100
commit9920e219dd4a98d1ac62bfa4aa4679d50aa32b8f (patch)
tree0b57576deba41ef22c8fc0b29e6f2b92557fe3b0 /OpenSim/Region
parentMerge branch 'careminster' into careminster-presence-refactor (diff)
parentMerge branch '0.6.9-post-fixes' into careminster (diff)
downloadopensim-SC_OLD-9920e219dd4a98d1ac62bfa4aa4679d50aa32b8f.zip
opensim-SC_OLD-9920e219dd4a98d1ac62bfa4aa4679d50aa32b8f.tar.gz
opensim-SC_OLD-9920e219dd4a98d1ac62bfa4aa4679d50aa32b8f.tar.bz2
opensim-SC_OLD-9920e219dd4a98d1ac62bfa4aa4679d50aa32b8f.tar.xz
Merge branch 'careminster' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs9
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs229
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs8
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs8
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISnmpModule.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs16
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs50
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs76
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs256
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs111
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs22
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs30
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs1
18 files changed, 644 insertions, 201 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 773baf5..552f64c 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -5255,7 +5255,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5255 args.Channel = ch; 5255 args.Channel = ch;
5256 args.From = String.Empty; 5256 args.From = String.Empty;
5257 args.Message = Utils.BytesToString(msg); 5257 args.Message = Utils.BytesToString(msg);
5258 args.Type = ChatTypeEnum.Shout; 5258 args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
5259 args.Position = new Vector3(); 5259 args.Position = new Vector3();
5260 args.Scene = Scene; 5260 args.Scene = Scene;
5261 args.Sender = this; 5261 args.Sender = this;
@@ -11277,9 +11277,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11277 11277
11278 m_groupPowers.Clear(); 11278 m_groupPowers.Clear();
11279 11279
11280 for (int i = 0; i < GroupMembership.Length; i++) 11280 if (GroupMembership != null)
11281 { 11281 {
11282 m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers; 11282 for (int i = 0; i < GroupMembership.Length; i++)
11283 {
11284 m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
11285 }
11283 } 11286 }
11284 } 11287 }
11285 } 11288 }
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 37cdaae..9eaa758 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -406,6 +406,11 @@ namespace Flotsam.RegionModules.AssetCache
406 return asset; 406 return asset;
407 } 407 }
408 408
409 public AssetBase GetCached(string id)
410 {
411 return Get(id);
412 }
413
409 public void Expire(string id) 414 public void Expire(string id)
410 { 415 {
411 if (m_LogLevel >= 2) 416 if (m_LogLevel >= 2)
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
new file mode 100644
index 0000000..3b66859
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
@@ -0,0 +1,229 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Specialized;
31using System.Reflection;
32using System.IO;
33using System.Web;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using OpenMetaverse.StructuredData;
38using OpenSim.Framework;
39using OpenSim.Framework.Servers;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Services.Interfaces;
44using Caps = OpenSim.Framework.Capabilities.Caps;
45
46namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
47{
48 #region Stream Handler
49
50 public delegate byte[] StreamHandlerCallback(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse);
51
52 public class StreamHandler : BaseStreamHandler
53 {
54 StreamHandlerCallback m_callback;
55
56 public StreamHandler(string httpMethod, string path, StreamHandlerCallback callback)
57 : base(httpMethod, path)
58 {
59 m_callback = callback;
60 }
61
62 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
63 {
64 return m_callback(path, request, httpRequest, httpResponse);
65 }
66 }
67
68 #endregion Stream Handler
69
70 public class GetTextureModule : IRegionModule
71 {
72 private static readonly ILog m_log =
73 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
74 private Scene m_scene;
75 private IAssetService m_assetService;
76
77 #region IRegionModule Members
78
79 public void Initialise(Scene pScene, IConfigSource pSource)
80 {
81 m_scene = pScene;
82 }
83
84 public void PostInitialise()
85 {
86 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
87 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
88 }
89
90 public void Close() { }
91
92 public string Name { get { return "GetTextureModule"; } }
93 public bool IsSharedModule { get { return false; } }
94
95 public void RegisterCaps(UUID agentID, Caps caps)
96 {
97 UUID capID = UUID.Random();
98
99 m_log.Info("[GETTEXTURE]: /CAPS/" + capID);
100 caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture));
101 }
102
103 #endregion
104
105 private byte[] ProcessGetTexture(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
106 {
107 // TODO: Change this to a config option
108 const string REDIRECT_URL = null;
109
110 // Try to parse the texture ID from the request URL
111 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
112 string textureStr = GetOne(query, "texture_id");
113
114 if (m_assetService == null)
115 {
116 m_log.Error("[GETTEXTURE]: Cannot fetch texture " + textureStr + " without an asset service");
117 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
118 return null;
119 }
120
121 UUID textureID;
122 if (!String.IsNullOrEmpty(textureStr) && UUID.TryParse(textureStr, out textureID))
123 {
124 AssetBase texture;
125
126 if (!String.IsNullOrEmpty(REDIRECT_URL))
127 {
128 // Only try to fetch locally cached textures. Misses are redirected
129 texture = m_assetService.GetCached(textureID.ToString());
130
131 if (texture != null)
132 {
133 SendTexture(httpRequest, httpResponse, texture);
134 }
135 else
136 {
137 string textureUrl = REDIRECT_URL + textureID.ToString();
138 m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl);
139 httpResponse.RedirectLocation = textureUrl;
140 }
141 }
142 else
143 {
144 // Fetch locally or remotely. Misses return a 404
145 texture = m_assetService.Get(textureID.ToString());
146
147 if (texture != null)
148 {
149 SendTexture(httpRequest, httpResponse, texture);
150 }
151 else
152 {
153 m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found");
154 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
155 }
156 }
157 }
158 else
159 {
160 m_log.Warn("[GETTEXTURE]: Failed to parse a texture_id from GetTexture request: " + httpRequest.Url);
161 }
162
163 httpResponse.Send();
164 return null;
165 }
166
167 private void SendTexture(OSHttpRequest request, OSHttpResponse response, AssetBase texture)
168 {
169 string range = GetOne(request.Headers, "Range");
170 if (!String.IsNullOrEmpty(range))
171 {
172 // Range request
173 int start, end;
174 if (TryParseRange(range, out start, out end))
175 {
176 end = Utils.Clamp(end, 1, texture.Data.Length);
177 start = Utils.Clamp(start, 0, end - 1);
178
179 m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
180
181 if (end - start < texture.Data.Length)
182 response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
183
184 response.ContentLength = end - start;
185 response.ContentType = texture.Metadata.ContentType;
186
187 response.Body.Write(texture.Data, start, end - start);
188 }
189 else
190 {
191 m_log.Warn("Malformed Range header: " + range);
192 response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
193 }
194 }
195 else
196 {
197 // Full content request
198 response.ContentLength = texture.Data.Length;
199 response.ContentType = texture.Metadata.ContentType;
200 response.Body.Write(texture.Data, 0, texture.Data.Length);
201 }
202 }
203
204 private bool TryParseRange(string header, out int start, out int end)
205 {
206 if (header.StartsWith("bytes="))
207 {
208 string[] rangeValues = header.Substring(6).Split('-');
209 if (rangeValues.Length == 2)
210 {
211 if (Int32.TryParse(rangeValues[0], out start) && Int32.TryParse(rangeValues[1], out end))
212 return true;
213 }
214 }
215
216 start = end = 0;
217 return false;
218 }
219
220 private static string GetOne(NameValueCollection collection, string key)
221 {
222 string[] values = collection.GetValues(key);
223 if (values != null && values.Length > 0)
224 return values[0];
225
226 return null;
227 }
228 }
229}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
index af2f3d6..ebd6bbd 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
@@ -229,6 +229,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
229 return asset; 229 return asset;
230 } 230 }
231 231
232 public AssetBase GetCached(string id)
233 {
234 if (m_Cache != null)
235 return m_Cache.Get(id);
236
237 return null;
238 }
239
232 public AssetMetadata GetMetadata(string id) 240 public AssetMetadata GetMetadata(string id)
233 { 241 {
234 AssetBase asset = null; 242 AssetBase asset = null;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
index 50348da..1b3419d 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
@@ -165,6 +165,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
165 return asset; 165 return asset;
166 } 166 }
167 167
168 public AssetBase GetCached(string id)
169 {
170 if (m_Cache != null)
171 return m_Cache.Get(id);
172
173 return null;
174 }
175
168 public AssetMetadata GetMetadata(string id) 176 public AssetMetadata GetMetadata(string id)
169 { 177 {
170 AssetBase asset = null; 178 AssetBase asset = null;
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index f58904f..16ca3f9 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -73,8 +73,6 @@ namespace OpenSim.Region.Framework.Interfaces
73 /// </summary> 73 /// </summary>
74 void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); 74 void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource);
75 75
76 ArrayList GetScriptErrors(UUID itemID);
77
78 /// <summary> 76 /// <summary>
79 /// Stop all the scripts in this entity. 77 /// Stop all the scripts in this entity.
80 /// </summary> 78 /// </summary>
@@ -104,6 +102,8 @@ namespace OpenSim.Region.Framework.Interfaces
104 /// <param name="stateSource"></param> 102 /// <param name="stateSource"></param>
105 void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); 103 void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
106 104
105 ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
106
107 /// <summary> 107 /// <summary>
108 /// Stop a script which is in this prim's inventory. 108 /// Stop a script which is in this prim's inventory.
109 /// </summary> 109 /// </summary>
diff --git a/OpenSim/Region/Framework/Interfaces/ISnmpModule.cs b/OpenSim/Region/Framework/Interfaces/ISnmpModule.cs
new file mode 100644
index 0000000..6fd6ba7
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/ISnmpModule.cs
@@ -0,0 +1,12 @@
1///////////////////////////////////////////////////////////////////
2//
3// (c) Careminster LImited, Melanie Thielker and the Meta7 Team
4//
5// This file is not open source. All rights reserved
6// Mod 2
7public interface ISnmpModule
8{
9 void Alert(string message);
10 void Trap(int code,string simname,string Message);
11 void ColdStart(int step , string simname);
12}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 1875c48..357cdc4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -212,8 +212,7 @@ namespace OpenSim.Region.Framework.Scenes
212 { 212 {
213 // Needs to determine which engine was running it and use that 213 // Needs to determine which engine was running it and use that
214 // 214 //
215 part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); 215 errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0);
216 errors = part.Inventory.GetScriptErrors(item.ItemID);
217 } 216 }
218 else 217 else
219 { 218 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e4daa0b..671f8fc 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -156,6 +156,20 @@ namespace OpenSim.Region.Framework.Scenes
156 156
157 public IXfer XferManager; 157 public IXfer XferManager;
158 158
159 protected ISnmpModule m_snmpService = null;
160 public ISnmpModule SnmpService
161 {
162 get
163 {
164 if (m_snmpService == null)
165 {
166 m_snmpService = RequestModuleInterface<ISnmpModule>();
167 }
168
169 return m_snmpService;
170 }
171 }
172
159 protected IAssetService m_AssetService; 173 protected IAssetService m_AssetService;
160 protected IAuthorizationService m_AuthorizationService; 174 protected IAuthorizationService m_AuthorizationService;
161 175
@@ -1727,7 +1741,7 @@ namespace OpenSim.Region.Framework.Scenes
1727 public void SaveTerrain() 1741 public void SaveTerrain()
1728 { 1742 {
1729 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 1743 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
1730 } 1744 }
1731 1745
1732 public void StoreWindlightProfile(RegionLightShareData wl) 1746 public void StoreWindlightProfile(RegionLightShareData wl)
1733 { 1747 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 014b007..84c3719 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -104,8 +104,12 @@ namespace OpenSim.Region.Framework.Scenes
104 /// since the group's last persistent backup 104 /// since the group's last persistent backup
105 /// </summary> 105 /// </summary>
106 private bool m_hasGroupChanged = false; 106 private bool m_hasGroupChanged = false;
107 private long timeFirstChanged; 107 private long timeFirstChanged = 0;
108 private long timeLastChanged; 108 private long timeLastChanged = 0;
109 private long m_maxPersistTime = 0;
110 private long m_minPersistTime = 0;
111 private Random m_rand;
112
109 private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); 113 private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim();
110 114
111 public void lockPartsForRead(bool locked) 115 public void lockPartsForRead(bool locked)
@@ -182,6 +186,32 @@ namespace OpenSim.Region.Framework.Scenes
182 timeLastChanged = DateTime.Now.Ticks; 186 timeLastChanged = DateTime.Now.Ticks;
183 if (!m_hasGroupChanged) 187 if (!m_hasGroupChanged)
184 timeFirstChanged = DateTime.Now.Ticks; 188 timeFirstChanged = DateTime.Now.Ticks;
189 if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null)
190 {
191 if (m_rand == null)
192 {
193 byte[] val = new byte[16];
194 m_rootPart.UUID.ToBytes(val, 0);
195 m_rand = new Random(BitConverter.ToInt32(val, 0));
196 }
197
198 if (m_scene.GetRootAgentCount() == 0)
199 {
200 //If the region is empty, this change has been made by an automated process
201 //and thus we delay the persist time by a random amount between 1.5 and 2.5.
202
203 float factor = 1.5f + (float)(m_rand.NextDouble());
204 m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor);
205 m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor);
206 }
207 else
208 {
209 //If the region is not empty, we want to obey the minimum and maximum persist times
210 //but add a random factor so we stagger the object persistance a little
211 m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5
212 m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0
213 }
214 }
185 } 215 }
186 m_hasGroupChanged = value; 216 m_hasGroupChanged = value;
187 } 217 }
@@ -197,8 +227,19 @@ namespace OpenSim.Region.Framework.Scenes
197 return false; 227 return false;
198 if (m_scene.ShuttingDown) 228 if (m_scene.ShuttingDown)
199 return true; 229 return true;
230
231 if (m_minPersistTime == 0 || m_maxPersistTime == 0)
232 {
233 m_maxPersistTime = m_scene.m_persistAfter;
234 m_minPersistTime = m_scene.m_dontPersistBefore;
235 }
236
200 long currentTime = DateTime.Now.Ticks; 237 long currentTime = DateTime.Now.Ticks;
201 if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) 238
239 if (timeLastChanged == 0) timeLastChanged = currentTime;
240 if (timeFirstChanged == 0) timeFirstChanged = currentTime;
241
242 if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime)
202 return true; 243 return true;
203 return false; 244 return false;
204 } 245 }
@@ -530,6 +571,7 @@ namespace OpenSim.Region.Framework.Scenes
530 /// </summary> 571 /// </summary>
531 public SceneObjectGroup() 572 public SceneObjectGroup()
532 { 573 {
574
533 } 575 }
534 576
535 /// <summary> 577 /// <summary>
@@ -546,7 +588,7 @@ namespace OpenSim.Region.Framework.Scenes
546 /// Constructor. This object is added to the scene later via AttachToScene() 588 /// Constructor. This object is added to the scene later via AttachToScene()
547 /// </summary> 589 /// </summary>
548 public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) 590 public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
549 { 591 {
550 SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); 592 SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero));
551 } 593 }
552 594
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 836622d..07d58a1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -45,6 +45,8 @@ namespace OpenSim.Region.Framework.Scenes
45 45
46 private string m_inventoryFileName = String.Empty; 46 private string m_inventoryFileName = String.Empty;
47 private int m_inventoryFileNameSerial = 0; 47 private int m_inventoryFileNameSerial = 0;
48
49 private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>();
48 50
49 /// <value> 51 /// <value>
50 /// The part to which the inventory belongs. 52 /// The part to which the inventory belongs.
@@ -210,7 +212,7 @@ namespace OpenSim.Region.Framework.Scenes
210 } 212 }
211 } 213 }
212 214
213 public ArrayList GetScriptErrors(UUID itemID) 215 private ArrayList GetScriptErrors(UUID itemID)
214 { 216 {
215 ArrayList ret = new ArrayList(); 217 ArrayList ret = new ArrayList();
216 218
@@ -269,7 +271,10 @@ namespace OpenSim.Region.Framework.Scenes
269 // item.Name, item.ItemID, Name, UUID); 271 // item.Name, item.ItemID, Name, UUID);
270 272
271 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 273 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
274 {
275 StoreScriptError(item.ItemID, "no permission");
272 return; 276 return;
277 }
273 278
274 m_part.AddFlag(PrimFlags.Scripted); 279 m_part.AddFlag(PrimFlags.Scripted);
275 280
@@ -284,6 +289,7 @@ namespace OpenSim.Region.Framework.Scenes
284 m_items.LockItemsForWrite(false); 289 m_items.LockItemsForWrite(false);
285 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 290 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
286 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); 291 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
292 StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID));
287 m_part.ParentGroup.AddActiveScriptCount(1); 293 m_part.ParentGroup.AddActiveScriptCount(1);
288 m_part.ScheduleFullUpdate(); 294 m_part.ScheduleFullUpdate();
289 return; 295 return;
@@ -293,11 +299,13 @@ namespace OpenSim.Region.Framework.Scenes
293 { 299 {
294 if (null == asset) 300 if (null == asset)
295 { 301 {
302 string msg = String.Format("asset ID {0} could not be found", item.AssetID);
303 StoreScriptError(item.ItemID, msg);
296 m_log.ErrorFormat( 304 m_log.ErrorFormat(
297 "[PRIM INVENTORY]: " + 305 "[PRIM INVENTORY]: " +
298 "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", 306 "Couldn't start script {0}, {1} at {2} in {3} since {4}",
299 item.Name, item.ItemID, m_part.AbsolutePosition, 307 item.Name, item.ItemID, m_part.AbsolutePosition,
300 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); 308 m_part.ParentGroup.Scene.RegionInfo.RegionName, msg);
301 } 309 }
302 else 310 else
303 { 311 {
@@ -310,11 +318,16 @@ namespace OpenSim.Region.Framework.Scenes
310 string script = Utils.BytesToString(asset.Data); 318 string script = Utils.BytesToString(asset.Data);
311 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 319 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
312 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); 320 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
321 StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID));
313 m_part.ParentGroup.AddActiveScriptCount(1); 322 m_part.ParentGroup.AddActiveScriptCount(1);
314 m_part.ScheduleFullUpdate(); 323 m_part.ScheduleFullUpdate();
315 } 324 }
316 }); 325 });
317 } 326 }
327 else
328 {
329 StoreScriptError(item.ItemID, "scripts disabled");
330 }
318 } 331 }
319 332
320 private void RestoreSavedScriptState(UUID oldID, UUID newID) 333 private void RestoreSavedScriptState(UUID oldID, UUID newID)
@@ -391,24 +404,71 @@ namespace OpenSim.Region.Framework.Scenes
391 else 404 else
392 { 405 {
393 m_items.LockItemsForRead(false); 406 m_items.LockItemsForRead(false);
407 string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID,
408 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
409 StoreScriptError(itemId, msg);
394 m_log.ErrorFormat( 410 m_log.ErrorFormat(
395 "[PRIM INVENTORY]: " + 411 "[PRIM INVENTORY]: " +
396 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", 412 "Couldn't start script with ID {0} since it {1}", itemId, msg);
397 itemId, m_part.Name, m_part.UUID,
398 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
399 } 413 }
400 } 414 }
401 else 415 else
402 { 416 {
403 m_items.LockItemsForRead(false); 417 m_items.LockItemsForRead(false);
418 string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID);
419 StoreScriptError(itemId, msg);
404 m_log.ErrorFormat( 420 m_log.ErrorFormat(
405 "[PRIM INVENTORY]: " + 421 "[PRIM INVENTORY]: " +
406 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", 422 "Couldn't start script with ID {0} since it {1}", itemId, msg);
407 itemId, m_part.Name, m_part.UUID);
408 } 423 }
409 424
410 } 425 }
411 426
427 public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
428 {
429 ArrayList errors;
430
431 lock (m_scriptErrors)
432 {
433 m_scriptErrors.Remove(itemId);
434 }
435 CreateScriptInstance(itemId, startParam, postOnRez, engine, stateSource);
436 lock (m_scriptErrors)
437 {
438 while (!m_scriptErrors.TryGetValue(itemId, out errors))
439 {
440 if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000))
441 {
442 m_log.ErrorFormat(
443 "[PRIM INVENTORY]: " +
444 "timedout waiting for script {0} errors", itemId);
445 if (!m_scriptErrors.TryGetValue(itemId, out errors))
446 {
447 errors = new ArrayList(1);
448 errors.Add("timedout waiting for errors");
449 }
450 break;
451 }
452 }
453 m_scriptErrors.Remove(itemId);
454 }
455 return errors;
456 }
457 private void StoreScriptErrors(UUID itemId, ArrayList errors)
458 {
459 lock (m_scriptErrors)
460 {
461 m_scriptErrors[itemId] = errors;
462 System.Threading.Monitor.PulseAll(m_scriptErrors);
463 }
464 }
465 private void StoreScriptError(UUID itemId, string message)
466 {
467 ArrayList errors = new ArrayList(1);
468 errors.Add(message);
469 StoreScriptErrors(itemId, errors);
470 }
471
412 /// <summary> 472 /// <summary>
413 /// Stop a script which is in this prim's inventory. 473 /// Stop a script which is in this prim's inventory.
414 /// </summary> 474 /// </summary>
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index e8894f7..01c3f81 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -180,6 +180,7 @@ namespace OpenSim.Region.Physics.OdePlugin
180 internal int m_material = (int)Material.Wood; 180 internal int m_material = (int)Material.Wood;
181 181
182 private int frcount = 0; // Used to limit dynamics debug output to 182 private int frcount = 0; // Used to limit dynamics debug output to
183 private int revcount = 0; // Reverse motion while > 0
183 184
184 private IntPtr m_body = IntPtr.Zero; 185 private IntPtr m_body = IntPtr.Zero;
185 186
@@ -1888,22 +1889,19 @@ namespace OpenSim.Region.Physics.OdePlugin
1888 1889
1889 public void changemove(float timestep) 1890 public void changemove(float timestep)
1890 { 1891 {
1891//Console.WriteLine("changemove for {0}", m_primName ); 1892//Console.WriteLine("changemove sing/root {0} to {1}", m_primName, _position );
1892
1893 if (m_isphysical) 1893 if (m_isphysical)
1894 { 1894 {
1895//Console.WriteLine("phys {0} {1} {2}", m_disabled, m_taintremove, childPrim); 1895//Console.WriteLine("phys {0} {1} {2}", m_disabled, m_taintremove, childPrim);
1896// if (!m_disabled && !m_taintremove && !childPrim) After one edit m_disabled is sometimes set, disabling further edits! 1896// if (!m_disabled && !m_taintremove && !childPrim) After one edit m_disabled is sometimes set, disabling further edits!
1897 if (!m_taintremove && !childPrim) 1897 if (!m_taintremove && !childPrim)
1898 { 1898 {
1899//Console.WriteLine("physOK");
1900 if (Body == IntPtr.Zero) 1899 if (Body == IntPtr.Zero)
1901 enableBody(); 1900 enableBody();
1902 //Prim auto disable after 20 frames, 1901 //Prim auto disable after 20 frames,
1903 //if you move it, re-enable the prim manually. 1902 //if you move it, re-enable the prim manually.
1904 if (_parent != null) 1903 if (_parent != null)
1905 { 1904 {
1906//Console.WriteLine("physChild");
1907 if (m_linkJoint != IntPtr.Zero) 1905 if (m_linkJoint != IntPtr.Zero)
1908 { 1906 {
1909 d.JointDestroy(m_linkJoint); 1907 d.JointDestroy(m_linkJoint);
@@ -1912,7 +1910,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1912 } 1910 }
1913 if (Body != IntPtr.Zero) 1911 if (Body != IntPtr.Zero)
1914 { 1912 {
1915//Console.WriteLine("physNotIPZ");
1916 d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); 1913 d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
1917 1914
1918 if (_parent != null) 1915 if (_parent != null)
@@ -1945,7 +1942,6 @@ Console.WriteLine(" JointCreateFixed");
1945 } 1942 }
1946 else 1943 else
1947 { 1944 {
1948//Console.WriteLine("NONphys");
1949 // string primScenAvatarIn = _parent_scene.whichspaceamIin(_position); 1945 // string primScenAvatarIn = _parent_scene.whichspaceamIin(_position);
1950 // int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); 1946 // int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
1951 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1947 _parent_scene.waitForSpaceUnlock(m_targetSpace);
@@ -2382,9 +2378,7 @@ Console.WriteLine(" JointCreateFixed");
2382 if (IsPhysical) 2378 if (IsPhysical)
2383 { 2379 {
2384 if (Body != IntPtr.Zero) 2380 if (Body != IntPtr.Zero)
2385 {
2386 d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); 2381 d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z);
2387 }
2388 } 2382 }
2389 2383
2390 //resetCollisionAccounting(); 2384 //resetCollisionAccounting();
@@ -2394,31 +2388,9 @@ Console.WriteLine(" JointCreateFixed");
2394 2388
2395 public void UpdatePositionAndVelocity() 2389 public void UpdatePositionAndVelocity()
2396 { 2390 {
2397 return; // moved to the Move() method 2391 return; // moved to the Move () method
2398 }
2399/* No one uses this?
2400 public Matrix4 FromDMass(d.Mass pMass)
2401 {
2402 Matrix4 obj;
2403 obj.M11 = pMass.I.M00;
2404 obj.M12 = pMass.I.M01;
2405 obj.M13 = pMass.I.M02;
2406 obj.M14 = 0;
2407 obj.M21 = pMass.I.M10;
2408 obj.M22 = pMass.I.M11;
2409 obj.M23 = pMass.I.M12;
2410 obj.M24 = 0;
2411 obj.M31 = pMass.I.M20;
2412 obj.M32 = pMass.I.M21;
2413 obj.M33 = pMass.I.M22;
2414 obj.M34 = 0;
2415 obj.M41 = 0;
2416 obj.M42 = 0;
2417 obj.M43 = 0;
2418 obj.M44 = 1;
2419 return obj;
2420 } 2392 }
2421*/ 2393
2422 public d.Mass FromMatrix4(Matrix4 pMat, ref d.Mass obj) 2394 public d.Mass FromMatrix4(Matrix4 pMat, ref d.Mass obj)
2423 { 2395 {
2424 obj.I.M00 = pMat[0, 0]; 2396 obj.I.M00 = pMat[0, 0];
@@ -2654,15 +2626,15 @@ Console.WriteLine(" JointCreateFixed");
2654 // m_angularDeflectionEfficiency = pValue; 2626 // m_angularDeflectionEfficiency = pValue;
2655 break; 2627 break;
2656 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: 2628 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE:
2657 if (pValue < 0.01f) pValue = 0.01f; 2629 if (pValue < 0.1f) pValue = 0.1f;
2658 // m_angularDeflectionTimescale = pValue; 2630 // m_angularDeflectionTimescale = pValue;
2659 break; 2631 break;
2660 case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: 2632 case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE:
2661 if (pValue < 0.01f) pValue = 0.01f; 2633 if (pValue < 0.3f) pValue = 0.3f;
2662 m_angularMotorDecayTimescale = pValue; 2634 m_angularMotorDecayTimescale = pValue;
2663 break; 2635 break;
2664 case Vehicle.ANGULAR_MOTOR_TIMESCALE: 2636 case Vehicle.ANGULAR_MOTOR_TIMESCALE:
2665 if (pValue < 0.01f) pValue = 0.01f; 2637 if (pValue < 0.3f) pValue = 0.3f;
2666 m_angularMotorTimescale = pValue; 2638 m_angularMotorTimescale = pValue;
2667 break; 2639 break;
2668 case Vehicle.BANKING_EFFICIENCY: 2640 case Vehicle.BANKING_EFFICIENCY:
@@ -2691,7 +2663,7 @@ Console.WriteLine(" JointCreateFixed");
2691 m_VhoverHeight = pValue; 2663 m_VhoverHeight = pValue;
2692 break; 2664 break;
2693 case Vehicle.HOVER_TIMESCALE: 2665 case Vehicle.HOVER_TIMESCALE:
2694 if (pValue < 0.01f) pValue = 0.01f; 2666 if (pValue < 0.1f) pValue = 0.1f;
2695 m_VhoverTimescale = pValue; 2667 m_VhoverTimescale = pValue;
2696 break; 2668 break;
2697 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: 2669 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY:
@@ -2703,11 +2675,11 @@ Console.WriteLine(" JointCreateFixed");
2703 // m_linearDeflectionTimescale = pValue; 2675 // m_linearDeflectionTimescale = pValue;
2704 break; 2676 break;
2705 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: 2677 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
2706 if (pValue < 0.01f) pValue = 0.01f; 2678 if (pValue < 0.3f) pValue = 0.3f;
2707 m_linearMotorDecayTimescale = pValue; 2679 m_linearMotorDecayTimescale = pValue;
2708 break; 2680 break;
2709 case Vehicle.LINEAR_MOTOR_TIMESCALE: 2681 case Vehicle.LINEAR_MOTOR_TIMESCALE:
2710 if (pValue < 0.01f) pValue = 0.01f; 2682 if (pValue < 0.1f) pValue = 0.1f;
2711 m_linearMotorTimescale = pValue; 2683 m_linearMotorTimescale = pValue;
2712 break; 2684 break;
2713 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: 2685 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY:
@@ -2716,7 +2688,7 @@ Console.WriteLine(" JointCreateFixed");
2716 m_verticalAttractionEfficiency = pValue; 2688 m_verticalAttractionEfficiency = pValue;
2717 break; 2689 break;
2718 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: 2690 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE:
2719 if (pValue < 0.01f) pValue = 0.01f; 2691 if (pValue < 0.1f) pValue = 0.1f;
2720 m_verticalAttractionTimescale = pValue; 2692 m_verticalAttractionTimescale = pValue;
2721 break; 2693 break;
2722 2694
@@ -2732,6 +2704,7 @@ Console.WriteLine(" JointCreateFixed");
2732 UpdateAngDecay(); 2704 UpdateAngDecay();
2733 break; 2705 break;
2734 case Vehicle.LINEAR_FRICTION_TIMESCALE: 2706 case Vehicle.LINEAR_FRICTION_TIMESCALE:
2707 if (pValue < 0.1f) pValue = 0.1f;
2735 m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); 2708 m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue);
2736 break; 2709 break;
2737 case Vehicle.LINEAR_MOTOR_DIRECTION: 2710 case Vehicle.LINEAR_MOTOR_DIRECTION:
@@ -2771,6 +2744,9 @@ Console.WriteLine(" JointCreateFixed");
2771 UpdateAngDecay(); 2744 UpdateAngDecay();
2772 break; 2745 break;
2773 case Vehicle.LINEAR_FRICTION_TIMESCALE: 2746 case Vehicle.LINEAR_FRICTION_TIMESCALE:
2747 if (pValue.X < 0.1f) pValue.X = 0.1f;
2748 if (pValue.Y < 0.1f) pValue.Y = 0.1f;
2749 if (pValue.Z < 0.1f) pValue.Z = 0.1f;
2774 m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); 2750 m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
2775 break; 2751 break;
2776 case Vehicle.LINEAR_MOTOR_DIRECTION: 2752 case Vehicle.LINEAR_MOTOR_DIRECTION:
@@ -2967,7 +2943,7 @@ Console.WriteLine(" JointCreateFixed");
2967 2943
2968 internal void Halt() 2944 internal void Halt()
2969 { // Kill all motions, when non-physical 2945 { // Kill all motions, when non-physical
2970 m_linearMotorDirection = Vector3.Zero; 2946 // m_linearMotorDirection = Vector3.Zero;
2971 m_lLinMotorDVel = Vector3.Zero; 2947 m_lLinMotorDVel = Vector3.Zero;
2972 m_lLinObjectVel = Vector3.Zero; 2948 m_lLinObjectVel = Vector3.Zero;
2973 m_wLinObjectVel = Vector3.Zero; 2949 m_wLinObjectVel = Vector3.Zero;
@@ -2979,16 +2955,22 @@ Console.WriteLine(" JointCreateFixed");
2979 2955
2980 private void UpdateLinDecay() 2956 private void UpdateLinDecay()
2981 { 2957 {
2982 if (Math.Abs(m_linearMotorDirection.X) > Math.Abs(m_lLinMotorDVel.X)) m_lLinMotorDVel.X = m_linearMotorDirection.X; 2958// if (Math.Abs(m_linearMotorDirection.X) > Math.Abs(m_lLinMotorDVel.X)) m_lLinMotorDVel.X = m_linearMotorDirection.X;
2983 if (Math.Abs(m_linearMotorDirection.Y) > Math.Abs(m_lLinMotorDVel.Y)) m_lLinMotorDVel.Y = m_linearMotorDirection.Y; 2959// if (Math.Abs(m_linearMotorDirection.Y) > Math.Abs(m_lLinMotorDVel.Y)) m_lLinMotorDVel.Y = m_linearMotorDirection.Y;
2984 if (Math.Abs(m_linearMotorDirection.Z) > Math.Abs(m_lLinMotorDVel.Z)) m_lLinMotorDVel.Z = m_linearMotorDirection.Z; 2960// if (Math.Abs(m_linearMotorDirection.Z) > Math.Abs(m_lLinMotorDVel.Z)) m_lLinMotorDVel.Z = m_linearMotorDirection.Z;
2961 m_lLinMotorDVel.X = m_linearMotorDirection.X;
2962 m_lLinMotorDVel.Y = m_linearMotorDirection.Y;
2963 m_lLinMotorDVel.Z = m_linearMotorDirection.Z;
2985 } // else let the motor decay on its own 2964 } // else let the motor decay on its own
2986 2965
2987 private void UpdateAngDecay() 2966 private void UpdateAngDecay()
2988 { 2967 {
2989 if (Math.Abs(m_angularMotorDirection.X) > Math.Abs(m_angularMotorDVel.X)) m_angularMotorDVel.X = m_angularMotorDirection.X; 2968// if (Math.Abs(m_angularMotorDirection.X) > Math.Abs(m_angularMotorDVel.X)) m_angularMotorDVel.X = m_angularMotorDirection.X;
2990 if (Math.Abs(m_angularMotorDirection.Y) > Math.Abs(m_angularMotorDVel.Y)) m_angularMotorDVel.Y = m_angularMotorDirection.Y; 2969// if (Math.Abs(m_angularMotorDirection.Y) > Math.Abs(m_angularMotorDVel.Y)) m_angularMotorDVel.Y = m_angularMotorDirection.Y;
2991 if (Math.Abs(m_angularMotorDirection.Z) > Math.Abs(m_angularMotorDVel.Z)) m_angularMotorDVel.Z = m_angularMotorDirection.Z; 2970// if (Math.Abs(m_angularMotorDirection.Z) > Math.Abs(m_angularMotorDVel.Z)) m_angularMotorDVel.Z = m_angularMotorDirection.Z;
2971 m_angularMotorDVel.X = m_angularMotorDirection.X;
2972 m_angularMotorDVel.Y = m_angularMotorDirection.Y;
2973 m_angularMotorDVel.Z = m_angularMotorDirection.Z;
2992 } // else let the motor decay on its own 2974 } // else let the motor decay on its own
2993 2975
2994 public void Move(float timestep) 2976 public void Move(float timestep)
@@ -2996,44 +2978,114 @@ Console.WriteLine(" JointCreateFixed");
2996 float fx = 0; 2978 float fx = 0;
2997 float fy = 0; 2979 float fy = 0;
2998 float fz = 0; 2980 float fz = 0;
2981 Vector3 linvel; // velocity applied, including any reversal
2982 int outside = 0;
2983
2984 // If geomCrossingFailuresBeforeOutofbounds is set to 0 in OpenSim.ini then phys objects bounce off region borders.
2985 // This is a temp patch until proper region crossing is developed.
2986
2987 int failureLimit = _parent_scene.geomCrossingFailuresBeforeOutofbounds;
2988 int fence = _parent_scene.geomRegionFence;
2989
2990 float border_limit = 0.05f; // original limit
2991 if (fence == 1) border_limit = 0.5f; // bounce point
2999 2992
3000 frcount++; // used to limit debug comment output 2993 frcount++; // used to limit debug comment output
3001 if (frcount > 100) 2994 if (frcount > 10)
3002 frcount = 0; 2995 frcount = 0;
3003 2996
3004 if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // KF: Only move root prims. 2997 if(revcount > 0) revcount--;
2998
2999 if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // Only move root prims.
3005 { 3000 {
3006 3001 // Old public void UpdatePositionAndVelocity(), more accuratley calculated here
3007// Old public void UpdatePositionAndVelocity(), more accuratley calculated here
3008 bool lastZeroFlag = _zeroFlag; // was it stopped 3002 bool lastZeroFlag = _zeroFlag; // was it stopped
3003
3009 d.Vector3 vec = d.BodyGetPosition(Body); 3004 d.Vector3 vec = d.BodyGetPosition(Body);
3010 d.Quaternion ori = d.BodyGetQuaternion(Body);
3011 d.Vector3 vel = d.BodyGetLinearVel(Body);
3012 // d.Vector3 rotvel = d.BodyGetAngularVel(Body);
3013 d.Vector3 torque = d.BodyGetTorque(Body);
3014 _torque = new Vector3(torque.X, torque.Y, torque.Z);
3015 Vector3 l_position = Vector3.Zero; 3005 Vector3 l_position = Vector3.Zero;
3016 Quaternion l_orientation = Quaternion.Identity;
3017
3018 m_lastposition = _position;
3019 m_lastorientation = _orientation;
3020
3021 l_position.X = vec.X; 3006 l_position.X = vec.X;
3022 l_position.Y = vec.Y; 3007 l_position.Y = vec.Y;
3023 l_position.Z = vec.Z; 3008 l_position.Z = vec.Z;
3024 l_orientation.X = ori.X; 3009 m_lastposition = _position;
3025 l_orientation.Y = ori.Y; 3010 _position = l_position;
3026 l_orientation.Z = ori.Z; 3011
3027 l_orientation.W = ori.W; 3012 d.Quaternion ori = d.BodyGetQuaternion(Body);
3013 // Quaternion l_orientation = Quaternion.Identity;
3014 _orientation.X = ori.X;
3015 _orientation.Y = ori.Y;
3016 _orientation.Z = ori.Z;
3017 _orientation.W = ori.W;
3018 m_lastorientation = _orientation;
3019
3020 d.Vector3 vel = d.BodyGetLinearVel(Body);
3021 m_lastVelocity = _velocity;
3022 _velocity.X = vel.X;
3023 _velocity.Y = vel.Y;
3024 _velocity.Z = vel.Z;
3025 _acceleration = ((_velocity - m_lastVelocity) / timestep);
3026
3027 d.Vector3 torque = d.BodyGetTorque(Body);
3028 _torque = new Vector3(torque.X, torque.Y, torque.Z);
3029
3030 base.RequestPhysicsterseUpdate();
3031
3028//Console.WriteLine("Move {0} at {1}", m_primName, l_position); 3032//Console.WriteLine("Move {0} at {1}", m_primName, l_position);
3029 3033
3030 // Check if outside region horizontally 3034 // Check if outside region
3031 if (l_position.X > ((int)_parent_scene.WorldExtents.X - 0.05f) || 3035 // In Scene.cs/CrossPrimGroupIntoNewRegion the object is checked for 0.1M from border!
3032 l_position.X < 0f || 3036 if (l_position.X > ((float)_parent_scene.WorldExtents.X - border_limit))
3033 l_position.Y > ((int)_parent_scene.WorldExtents.Y - 0.05f) || 3037 {
3034 l_position.Y < 0f) 3038 l_position.X = ((float)_parent_scene.WorldExtents.X - border_limit);
3039 outside = 1;
3040 }
3041
3042 if (l_position.X < border_limit)
3043 {
3044 l_position.X = border_limit;
3045 outside = 2;
3046 }
3047 if (l_position.Y > ((float)_parent_scene.WorldExtents.Y - border_limit))
3048 {
3049 l_position.Y = ((float)_parent_scene.WorldExtents.Y - border_limit);
3050 outside = 3;
3051 }
3052
3053 if (l_position.Y < border_limit)
3035 { 3054 {
3036 if (m_crossingfailures < _parent_scene.geomCrossingFailuresBeforeOutofbounds) 3055 l_position.Y = border_limit;
3056 outside = 4;
3057 }
3058
3059 if (outside > 0)
3060 {
3061//Console.WriteLine(" fence = {0}",fence);
3062
3063//Console.WriteLine("Border {0}", l_position);
3064 if (fence == 1) // bounce object off boundary
3065 {
3066 if (revcount == 0)
3067 {
3068 if (outside < 3)
3069 {
3070 _velocity.X = -_velocity.X;
3071 }
3072 else
3073 {
3074 _velocity.Y = -_velocity.Y;
3075 }
3076 if (m_type != Vehicle.TYPE_NONE) Halt();
3077 _position = l_position;
3078 m_taintposition = _position;
3079 m_lastVelocity = _velocity;
3080 _acceleration = Vector3.Zero;
3081 d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
3082 d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
3083 base.RequestPhysicsterseUpdate();
3084
3085 revcount = 25; // wait for object to move away from border
3086 }
3087 } // else old crossing mode
3088 else if (m_crossingfailures < failureLimit)
3037 { // keep trying to cross? 3089 { // keep trying to cross?
3038 _position = l_position; 3090 _position = l_position;
3039 //_parent_scene.remActivePrim(this); 3091 //_parent_scene.remActivePrim(this);
@@ -3043,9 +3095,12 @@ Console.WriteLine(" JointCreateFixed");
3043 else 3095 else
3044 { // Too many tries 3096 { // Too many tries
3045 if (_parent == null) base.RaiseOutOfBounds(l_position); 3097 if (_parent == null) base.RaiseOutOfBounds(l_position);
3098//Console.WriteLine("ROOB 2");
3099
3046 return; // Dont process any other motion? 3100 return; // Dont process any other motion?
3047 } 3101 } // end various methods
3048 } // end outside region horizontally 3102 } // end outside region horizontally
3103
3049 3104
3050 if (l_position.Z < 0) 3105 if (l_position.Z < 0)
3051 { 3106 {
@@ -3057,6 +3112,8 @@ Console.WriteLine(" JointCreateFixed");
3057 3112
3058 //IsPhysical = false; 3113 //IsPhysical = false;
3059 if (_parent == null) base.RaiseOutOfBounds(_position); 3114 if (_parent == null) base.RaiseOutOfBounds(_position);
3115//Console.WriteLine("ROOB 3");
3116
3060 3117
3061 _acceleration.X = 0; // This stuff may stop client display but it has no 3118 _acceleration.X = 0; // This stuff may stop client display but it has no
3062 _acceleration.Y = 0; // effect on the object in phys engine! 3119 _acceleration.Y = 0; // effect on the object in phys engine!
@@ -3081,10 +3138,9 @@ Console.WriteLine(" JointCreateFixed");
3081 if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02) 3138 if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02)
3082 && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02) 3139 && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02)
3083 && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02) 3140 && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02)
3084 && (1.0 - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)) < 0.0001)) // KF 0.01 is far to large 3141 && (1.0 - Math.Abs(Quaternion.Dot(m_lastorientation, _orientation)) < 0.0001)) // KF 0.01 is far to large
3085 { 3142 {
3086 _zeroFlag = true; 3143 _zeroFlag = true;
3087//Console.WriteLine("ZFT 2");
3088 m_throttleUpdates = false; 3144 m_throttleUpdates = false;
3089 } 3145 }
3090 else 3146 else
@@ -3104,10 +3160,7 @@ Console.WriteLine(" JointCreateFixed");
3104 _acceleration.X = 0; 3160 _acceleration.X = 0;
3105 _acceleration.Y = 0; 3161 _acceleration.Y = 0;
3106 _acceleration.Z = 0; 3162 _acceleration.Z = 0;
3107 //_orientation.w = 0f; 3163
3108 //_orientation.X = 0f;
3109 //_orientation.Y = 0f;
3110 //_orientation.Z = 0f;
3111 m_rotationalVelocity.X = 0; 3164 m_rotationalVelocity.X = 0;
3112 m_rotationalVelocity.Y = 0; 3165 m_rotationalVelocity.Y = 0;
3113 m_rotationalVelocity.Z = 0; 3166 m_rotationalVelocity.Z = 0;
@@ -3132,26 +3185,6 @@ Console.WriteLine(" JointCreateFixed");
3132 base.RequestPhysicsterseUpdate(); 3185 base.RequestPhysicsterseUpdate();
3133 } 3186 }
3134 } 3187 }
3135
3136 m_lastVelocity = _velocity;
3137
3138 _position = l_position;
3139
3140 _velocity.X = vel.X;
3141 _velocity.Y = vel.Y;
3142 _velocity.Z = vel.Z;
3143// Why 2 calcs???
3144// _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
3145// _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f,
3146// _velocity.Y - m_lastVelocity.Y / 0.1f,
3147// _velocity.Z - m_lastVelocity.Z / 0.1f);
3148
3149 _acceleration = ((_velocity - m_lastVelocity) / timestep);
3150
3151 _orientation.X = ori.X;
3152 _orientation.Y = ori.Y;
3153 _orientation.Z = ori.Z;
3154 _orientation.W = ori.W;
3155 m_lastUpdateSent = false; 3188 m_lastUpdateSent = false;
3156 if (!m_throttleUpdates || throttleCounter > _parent_scene.geomUpdatesPerThrottledUpdate) 3189 if (!m_throttleUpdates || throttleCounter > _parent_scene.geomUpdatesPerThrottledUpdate)
3157 { 3190 {
@@ -3167,11 +3200,8 @@ Console.WriteLine(" JointCreateFixed");
3167 } 3200 }
3168 m_lastposition = l_position; 3201 m_lastposition = l_position;
3169 3202
3170 /// End of old UpdatePositionAndVelocity insert 3203 /// End UpdatePositionAndVelocity insert
3171 3204
3172//if (!Acceleration.ApproxEquals(Vector3.Zero, 0.01f)) Console.WriteLine("Move " + m_primName + " Accel=" + Acceleration);
3173// if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_type +
3174// " usePID=" + m_usePID + " seHover=" + m_useHoverPID + " useAPID=" + m_useAPID);
3175 if (m_type != Vehicle.TYPE_NONE) 3205 if (m_type != Vehicle.TYPE_NONE)
3176 { 3206 {
3177 // get body attitude 3207 // get body attitude
@@ -3202,12 +3232,13 @@ Console.WriteLine(" JointCreateFixed");
3202 { 3232 {
3203 m_lLinMotorDVel = Vector3.Zero; 3233 m_lLinMotorDVel = Vector3.Zero;
3204 } 3234 }
3205 else 3235
3236 /* else
3206 { 3237 {
3207 if (Math.Abs(m_lLinMotorDVel.X) < Math.Abs(m_lLinObjectVel.X)) m_lLinObjectVel.X = m_lLinMotorDVel.X; 3238 if (Math.Abs(m_lLinMotorDVel.X) < Math.Abs(m_lLinObjectVel.X)) m_lLinObjectVel.X = m_lLinMotorDVel.X;
3208 if (Math.Abs(m_lLinMotorDVel.Y) < Math.Abs(m_lLinObjectVel.Y)) m_lLinObjectVel.Y = m_lLinMotorDVel.Y; 3239 if (Math.Abs(m_lLinMotorDVel.Y) < Math.Abs(m_lLinObjectVel.Y)) m_lLinObjectVel.Y = m_lLinMotorDVel.Y;
3209 if (Math.Abs(m_lLinMotorDVel.Z) < Math.Abs(m_lLinObjectVel.Z)) m_lLinObjectVel.Z = m_lLinMotorDVel.Z; 3240 if (Math.Abs(m_lLinMotorDVel.Z) < Math.Abs(m_lLinObjectVel.Z)) m_lLinObjectVel.Z = m_lLinMotorDVel.Z;
3210 } 3241 } */
3211 } // end linear motor decay 3242 } // end linear motor decay
3212 3243
3213 if ( (! m_lLinMotorDVel.ApproxEquals(Vector3.Zero, 0.01f)) || (! m_lLinObjectVel.ApproxEquals(Vector3.Zero, 0.01f)) ) 3244 if ( (! m_lLinMotorDVel.ApproxEquals(Vector3.Zero, 0.01f)) || (! m_lLinObjectVel.ApproxEquals(Vector3.Zero, 0.01f)) )
@@ -3235,7 +3266,6 @@ Console.WriteLine(" JointCreateFixed");
3235 if (m_linearFrictionTimescale.Z < 300.0f) 3266 if (m_linearFrictionTimescale.Z < 300.0f)
3236 { 3267 {
3237 float fricfactor = m_linearFrictionTimescale.Z / timestep; 3268 float fricfactor = m_linearFrictionTimescale.Z / timestep;
3238//if(frcount == 0) Console.WriteLine("Zfric={0}", fricfactor);
3239 float fricZ = m_lLinObjectVel.Z / fricfactor; 3269 float fricZ = m_lLinObjectVel.Z / fricfactor;
3240 m_lLinObjectVel.Z -= fricZ; 3270 m_lLinObjectVel.Z -= fricZ;
3241 } 3271 }
@@ -3296,14 +3326,17 @@ Console.WriteLine(" JointCreateFixed");
3296 } 3326 }
3297 } 3327 }
3298 else 3328 else
3299 { // not hovering, Gravity rules 3329 { // not hovering
3300 m_wLinObjectVel.Z = vel_now.Z; 3330 if (m_wLinObjectVel.Z == 0f)
3331 { // Gravity rules
3332 m_wLinObjectVel.Z = vel_now.Z;
3333 } // else the motor has it
3301 } 3334 }
3302 3335 linvel = m_wLinObjectVel;
3303 3336
3304 // Vehicle Linear Motion done ======================================= 3337 // Vehicle Linear Motion done =======================================
3305 // Apply velocity 3338 // Apply velocity
3306 d.BodySetLinearVel(Body, m_wLinObjectVel.X, m_wLinObjectVel.Y, m_wLinObjectVel.Z); 3339 d.BodySetLinearVel(Body, linvel.X, linvel.Y, linvel.Z);
3307 // apply gravity force 3340 // apply gravity force
3308 d.BodyAddForce(Body, grav.X, grav.Y, grav.Z); 3341 d.BodyAddForce(Body, grav.X, grav.Y, grav.Z);
3309//if(frcount == 0) Console.WriteLine("Grav {0}", grav); 3342//if(frcount == 0) Console.WriteLine("Grav {0}", grav);
@@ -3626,9 +3659,10 @@ Console.WriteLine(" JointCreateFixed");
3626 // react to the physics scene by moving it's position. 3659 // react to the physics scene by moving it's position.
3627 // Avatar to Avatar collisions 3660 // Avatar to Avatar collisions
3628 // Prim to avatar collisions 3661 // Prim to avatar collisions
3662 d.Vector3 dlinvel = vel;
3629 3663
3630 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight); 3664 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
3631 d.BodySetLinearVel(Body, vel.X, vel.Y, 0); 3665 d.BodySetLinearVel(Body, dlinvel.X, dlinvel.Y, dlinvel.Z);
3632 d.BodyAddForce(Body, 0, 0, fz); 3666 d.BodyAddForce(Body, 0, 0, fz);
3633 //KF this prevents furthur motions return; 3667 //KF this prevents furthur motions return;
3634 } 3668 }
diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
index deb6164..79e2986 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs
@@ -224,6 +224,7 @@ namespace OpenSim.Region.Physics.OdePlugin
224 public float bodyPIDG = 25; 224 public float bodyPIDG = 25;
225 225
226 public int geomCrossingFailuresBeforeOutofbounds = 5; 226 public int geomCrossingFailuresBeforeOutofbounds = 5;
227 public int geomRegionFence = 0;
227 228
228 public float bodyMotorJointMaxforceTensor = 2; 229 public float bodyMotorJointMaxforceTensor = 2;
229 230
@@ -447,6 +448,7 @@ namespace OpenSim.Region.Physics.OdePlugin
447 geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); 448 geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3);
448 geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); 449 geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15);
449 geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5); 450 geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5);
451 geomRegionFence = physicsconfig.GetInt("region_border_fence", 0);
450 452
451 geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f); 453 geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f);
452 bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20); 454 bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20);
@@ -3419,76 +3421,56 @@ namespace OpenSim.Region.Physics.OdePlugin
3419 3421
3420 public void SetTerrain(float[] heightMap, Vector3 pOffset) 3422 public void SetTerrain(float[] heightMap, Vector3 pOffset)
3421 { 3423 {
3422 // this._heightmap[i] = (double)heightMap[i];
3423 // dbm (danx0r) -- creating a buffer zone of one extra sample all around
3424 //_origheightmap = heightMap;
3425 3424
3425 uint regionsize = (uint) Constants.RegionSize; // visible region size eg. 256(M)
3426
3427 uint heightmapWidth = regionsize + 1; // ODE map size 257 x 257 (Meters) (1 extra
3428 uint heightmapHeight = regionsize + 1;
3429
3430 uint heightmapWidthSamples = (uint)regionsize + 2; // Sample file size, 258 x 258 samples
3431 uint heightmapHeightSamples = (uint)regionsize + 2;
3432
3433 // Array of height samples for ODE
3426 float[] _heightmap; 3434 float[] _heightmap;
3435 _heightmap = new float[(heightmapWidthSamples * heightmapHeightSamples)]; // loaded samples 258 x 258
3427 3436
3428 // zero out a heightmap array float array (single dimension [flattened])) 3437 // Other ODE parameters
3429 //if ((int)Constants.RegionSize == 256)
3430 // _heightmap = new float[514 * 514];
3431 //else
3432
3433 _heightmap = new float[(((int)Constants.RegionSize + 2) * ((int)Constants.RegionSize + 2))];
3434
3435 uint heightmapWidth = Constants.RegionSize + 1;
3436 uint heightmapHeight = Constants.RegionSize + 1;
3437
3438 uint heightmapWidthSamples;
3439
3440 uint heightmapHeightSamples;
3441
3442 //if (((int)Constants.RegionSize) == 256)
3443 //{
3444 // heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2;
3445 // heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2;
3446 // heightmapWidth++;
3447 // heightmapHeight++;
3448 //}
3449 //else
3450 //{
3451
3452 heightmapWidthSamples = (uint)Constants.RegionSize + 1;
3453 heightmapHeightSamples = (uint)Constants.RegionSize + 1;
3454 //}
3455
3456 const float scale = 1.0f; 3438 const float scale = 1.0f;
3457 const float offset = 0.0f; 3439 const float offset = 0.0f;
3458 const float thickness = 0.2f; 3440 const float thickness = 2.0f; // Was 0.2f, Larger appears to prevent Av fall-through
3459 const int wrap = 0; 3441 const int wrap = 0;
3460 3442
3461 int regionsize = (int) Constants.RegionSize + 2; 3443 float hfmin = 2000f;
3462 //Double resolution 3444 float hfmax = -2000f;
3463 //if (((int)Constants.RegionSize) == 256) 3445 float minele = 0.0f; // Dont allow -ve heights
3464 // heightMap = ResizeTerrain512Interpolation(heightMap);
3465
3466
3467 // if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256)
3468 // regionsize = 512;
3469
3470 float hfmin = 2000;
3471 float hfmax = -2000;
3472 3446
3473 for (int x = 0; x < heightmapWidthSamples; x++) 3447 uint x = 0;
3448 uint y = 0;
3449 uint xx = 0;
3450 uint yy = 0;
3451
3452 // load the height samples array from the heightMap
3453 for ( x = 0; x < heightmapWidthSamples; x++) // 0 to 257
3454 {
3455 for ( y = 0; y < heightmapHeightSamples; y++) // 0 to 257
3474 { 3456 {
3475 for (int y = 0; y < heightmapHeightSamples; y++) 3457 xx = x - 1;
3476 { 3458 if (xx < 0) xx = 0;
3477 int xx = Util.Clip(x - 1, 0, regionsize - 1); 3459 if (xx > (regionsize - 1)) xx = regionsize - 1;
3478 int yy = Util.Clip(y - 1, 0, regionsize - 1); 3460
3479 3461 yy = y - 1;
3480 3462 if (yy < 0) yy = 0;
3481 float val= heightMap[yy * (int)Constants.RegionSize + xx]; 3463 if (yy > (regionsize - 1)) yy = regionsize - 1;
3482 _heightmap[x * ((int)Constants.RegionSize + 2) + y] = val; 3464 // Input xx = 0 0 1 2 ..... 254 255 255 256 total in
3483 3465 // Output x = 0 1 2 3 ..... 255 256 257 258 total out
3484 hfmin = (val < hfmin) ? val : hfmin; 3466 float val= heightMap[(yy * regionsize) + xx]; // input from heightMap, <0-255 * 256> <0-255>
3485 hfmax = (val > hfmax) ? val : hfmax; 3467 if (val < minele) val = minele;
3486 } 3468 _heightmap[x * (regionsize + 2) + y] = val; // samples output to _heightmap, <0-257 * 258> <0-257>
3469 hfmin = (val < hfmin) ? val : hfmin;
3470 hfmax = (val > hfmax) ? val : hfmax;
3487 } 3471 }
3472 }
3488 3473
3489
3490
3491
3492 lock (OdeLock) 3474 lock (OdeLock)
3493 { 3475 {
3494 IntPtr GroundGeom = IntPtr.Zero; 3476 IntPtr GroundGeom = IntPtr.Zero;
@@ -3504,19 +3486,17 @@ namespace OpenSim.Region.Physics.OdePlugin
3504 d.SpaceRemove(space, GroundGeom); 3486 d.SpaceRemove(space, GroundGeom);
3505 d.GeomDestroy(GroundGeom); 3487 d.GeomDestroy(GroundGeom);
3506 } 3488 }
3507
3508 } 3489 }
3509 IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); 3490 IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
3510 d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, heightmapWidth + 1, heightmapHeight + 1, 3491 d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0,
3511 (int)heightmapWidthSamples + 1, (int)heightmapHeightSamples + 1, scale, 3492 heightmapWidth, heightmapHeight, (int)heightmapWidthSamples,
3512 offset, thickness, wrap); 3493 (int)heightmapHeightSamples, scale, offset, thickness, wrap);
3513 d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); 3494 d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1);
3514 GroundGeom = d.CreateHeightfield(space, HeightmapData, 1); 3495 GroundGeom = d.CreateHeightfield(space, HeightmapData, 1);
3515 if (GroundGeom != IntPtr.Zero) 3496 if (GroundGeom != IntPtr.Zero)
3516 { 3497 {
3517 d.GeomSetCategoryBits(GroundGeom, (int)(CollisionCategories.Land)); 3498 d.GeomSetCategoryBits(GroundGeom, (int)(CollisionCategories.Land));
3518 d.GeomSetCollideBits(GroundGeom, (int)(CollisionCategories.Space)); 3499 d.GeomSetCollideBits(GroundGeom, (int)(CollisionCategories.Space));
3519
3520 } 3500 }
3521 geom_name_map[GroundGeom] = "Terrain"; 3501 geom_name_map[GroundGeom] = "Terrain";
3522 3502
@@ -3534,7 +3514,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3534 3514
3535 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); 3515 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
3536 d.GeomSetRotation(GroundGeom, ref R); 3516 d.GeomSetRotation(GroundGeom, ref R);
3537 d.GeomSetPosition(GroundGeom, (pOffset.X + ((int)Constants.RegionSize * 0.5f)) - 1, (pOffset.Y + ((int)Constants.RegionSize * 0.5f)) - 1, 0); 3517 d.GeomSetPosition(GroundGeom, (pOffset.X + (regionsize * 0.5f)) - 0.5f, (pOffset.Y + (regionsize * 0.5f)) - 0.5f, 0);
3538 IntPtr testGround = IntPtr.Zero; 3518 IntPtr testGround = IntPtr.Zero;
3539 if (RegionTerrain.TryGetValue(pOffset, out testGround)) 3519 if (RegionTerrain.TryGetValue(pOffset, out testGround))
3540 { 3520 {
@@ -3542,7 +3522,6 @@ namespace OpenSim.Region.Physics.OdePlugin
3542 } 3522 }
3543 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); 3523 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom);
3544 TerrainHeightFieldHeights.Add(GroundGeom,_heightmap); 3524 TerrainHeightFieldHeights.Add(GroundGeom,_heightmap);
3545
3546 } 3525 }
3547 } 3526 }
3548 3527
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
index 880ca1b..07cba60 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -113,6 +113,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
113 } 113 }
114 114
115 /// <summary> 115 /// <summary>
116 /// Like osGetAgents but returns enough info for a radar
117 /// </summary>
118 /// <returns>Strided list of the UUID, position and name of each avatar in the region</returns>
119 public LSL_List cmGetAvatarList()
120 {
121 LSL_List result = new LSL_List();
122 World.ForEachScenePresence(delegate (ScenePresence avatar)
123 {
124 if (avatar.UUID != m_host.OwnerID)
125 {
126 if (avatar.IsChildAgent == false)
127 {
128 result.Add(avatar.UUID);
129 result.Add(avatar.PhysicsActor.Position);
130 result.Add(avatar.Name);
131 }
132 }
133 });
134 return result;
135 }
136
137 /// <summary>
116 /// Get the current Windlight scene 138 /// Get the current Windlight scene
117 /// </summary> 139 /// </summary>
118 /// <returns>List of windlight parameters</returns> 140 /// <returns>List of windlight parameters</returns>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 3f630f4..228e9b8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2881,6 +2881,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2881 2881
2882 public void llLookAt(LSL_Vector target, double strength, double damping) 2882 public void llLookAt(LSL_Vector target, double strength, double damping)
2883 { 2883 {
2884 /*
2884 m_host.AddScriptLPS(1); 2885 m_host.AddScriptLPS(1);
2885 // Determine where we are looking from 2886 // Determine where we are looking from
2886 LSL_Vector from = llGetPos(); 2887 LSL_Vector from = llGetPos();
@@ -2900,12 +2901,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2900 // the angles of rotation in radians into rotation value 2901 // the angles of rotation in radians into rotation value
2901 2902
2902 LSL_Types.Quaternion rot = llEuler2Rot(angle); 2903 LSL_Types.Quaternion rot = llEuler2Rot(angle);
2903 /* 2904
2904 Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); 2905 // This would only work if your physics system contains an APID controller:
2905 m_host.startLookAt(rotation, (float)damping, (float)strength); 2906 // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
2906 This would only work if your physics system contains an APID controller */ 2907 // m_host.startLookAt(rotation, (float)damping, (float)strength);
2908
2907 // Orient the object to the angle calculated 2909 // Orient the object to the angle calculated
2908 llSetRot(rot); 2910 llSetRot(rot);
2911 */
2912
2913 //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object.
2914 //There's probably a smarter way of doing this, my rotation math-fu is weak.
2915 // http://bugs.meta7.com/view.php?id=28
2916 // - Tom
2917
2918 LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d));
2919 llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos()));
2920
2909 } 2921 }
2910 2922
2911 public void llRotLookAt(LSL_Rotation target, double strength, double damping) 2923 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
@@ -6222,6 +6234,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6222 tempf = (float)rules.GetLSLFloatItem(i + 1); 6234 tempf = (float)rules.GetLSLFloatItem(i + 1);
6223 prules.OuterAngle = (float)tempf; 6235 prules.OuterAngle = (float)tempf;
6224 break; 6236 break;
6237
6238 case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE:
6239 tempf = (float)rules.GetLSLFloatItem(i + 1);
6240 prules.InnerAngle = (float)tempf;
6241 break;
6242
6243 case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE:
6244 tempf = (float)rules.GetLSLFloatItem(i + 1);
6245 prules.OuterAngle = (float)tempf;
6246 break;
6225 } 6247 }
6226 6248
6227 } 6249 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
index f13b6e5..fba27f9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -44,5 +44,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
44 LSL_List cmGetWindlightScene(LSL_List rules); 44 LSL_List cmGetWindlightScene(LSL_List rules);
45 int cmSetWindlightScene(LSL_List rules); 45 int cmSetWindlightScene(LSL_List rules);
46 int cmSetWindlightSceneTargeted(LSL_List rules, key target); 46 int cmSetWindlightSceneTargeted(LSL_List rules, key target);
47 LSL_List cmGetAvatarList();
47 } 48 }
48} 49}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
index c0edaae..aaffbe4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -72,5 +72,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
72 { 72 {
73 return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target); 73 return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
74 } 74 }
75 public LSL_List cmGetAvatarList()
76 {
77 return m_CM_Functions.cmGetAvatarList();
78 }
75 } 79 }
76} 80}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index ee35fa4..b3e4740 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -274,6 +274,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
274 public const int CHANGED_ALLOWED_DROP = 64; 274 public const int CHANGED_ALLOWED_DROP = 64;
275 public const int CHANGED_OWNER = 128; 275 public const int CHANGED_OWNER = 128;
276 public const int CHANGED_REGION_RESTART = 256; 276 public const int CHANGED_REGION_RESTART = 256;
277 public const int CHANGED_REGION_START = 256; //LL Changed the constant from CHANGED_REGION_RESTART
277 public const int CHANGED_REGION = 512; 278 public const int CHANGED_REGION = 512;
278 public const int CHANGED_TELEPORT = 1024; 279 public const int CHANGED_TELEPORT = 1024;
279 public const int CHANGED_ANIMATION = 16384; 280 public const int CHANGED_ANIMATION = 16384;