aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs40
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs7
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs14
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs71
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs12
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs43
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs11
11 files changed, 179 insertions, 43 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 8d503bd..c7f4c20 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -111,6 +111,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
111 111
112 #region IAvatarFactoryModule 112 #region IAvatarFactoryModule
113 113
114 /// </summary>
115 /// <param name="sp"></param>
116 /// <param name="texture"></param>
117 /// <param name="visualParam"></param>
118 public void SetAppearance(IScenePresence sp, AvatarAppearance appearance)
119 {
120 SetAppearance(sp, appearance.Texture, appearance.VisualParams);
121 }
122
114 /// <summary> 123 /// <summary>
115 /// Set appearance data (texture asset IDs and slider settings) 124 /// Set appearance data (texture asset IDs and slider settings)
116 /// </summary> 125 /// </summary>
@@ -156,14 +165,23 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
156 changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; 165 changed = sp.Appearance.SetTextureEntries(textureEntry) || changed;
157 166
158// WriteBakedTexturesReport(sp, m_log.DebugFormat); 167// WriteBakedTexturesReport(sp, m_log.DebugFormat);
159 if (!ValidateBakedTextureCache(sp)) 168
169 // If bake textures are missing and this is not an NPC, request a rebake from client
170 if (!ValidateBakedTextureCache(sp) && (((ScenePresence)sp).PresenceType != PresenceType.Npc))
160 RequestRebake(sp, true); 171 RequestRebake(sp, true);
161 172
162 // This appears to be set only in the final stage of the appearance 173 // This appears to be set only in the final stage of the appearance
163 // update transaction. In theory, we should be able to do an immediate 174 // update transaction. In theory, we should be able to do an immediate
164 // appearance send and save here. 175 // appearance send and save here.
165 } 176 }
166 177
178 // NPC should send to clients immediately and skip saving appearance
179 if (((ScenePresence)sp).PresenceType == PresenceType.Npc)
180 {
181 SendAppearance((ScenePresence)sp);
182 return;
183 }
184
167 // save only if there were changes, send no matter what (doesn't hurt to send twice) 185 // save only if there were changes, send no matter what (doesn't hurt to send twice)
168 if (changed) 186 if (changed)
169 QueueAppearanceSave(sp.ControllingClient.AgentId); 187 QueueAppearanceSave(sp.ControllingClient.AgentId);
@@ -174,6 +192,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
174 // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); 192 // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString());
175 } 193 }
176 194
195 private void SendAppearance(ScenePresence sp)
196 {
197 // Send the appearance to everyone in the scene
198 sp.SendAppearanceToAllOtherAgents();
199
200 // Send animations back to the avatar as well
201 sp.Animator.SendAnimPack();
202 }
203
177 public bool SendAppearance(UUID agentId) 204 public bool SendAppearance(UUID agentId)
178 { 205 {
179// m_log.DebugFormat("[AVFACTORY]: Sending appearance for {0}", agentId); 206// m_log.DebugFormat("[AVFACTORY]: Sending appearance for {0}", agentId);
@@ -185,12 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
185 return false; 212 return false;
186 } 213 }
187 214
188 // Send the appearance to everyone in the scene 215 SendAppearance(sp);
189 sp.SendAppearanceToAllOtherAgents();
190
191 // Send animations back to the avatar as well
192 sp.Animator.SendAnimPack();
193
194 return true; 216 return true;
195 } 217 }
196 218
@@ -626,4 +648,4 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
626 outputAction("{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt"); 648 outputAction("{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt");
627 } 649 }
628 } 650 }
629} \ No newline at end of file 651}
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 5e7d37a..ba38488 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -707,7 +707,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions
707 // Object owners should be able to edit their own content 707 // Object owners should be able to edit their own content
708 if (currentUser == objectOwner) 708 if (currentUser == objectOwner)
709 { 709 {
710 permission = true; 710 // there is no way that later code can change this back to false
711 // so just return true immediately and short circuit the more
712 // expensive group checks
713 return true;
714
715 //permission = true;
711 } 716 }
712 else if (group.IsAttachment) 717 else if (group.IsAttachment)
713 { 718 {
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
index 39a760c..34aca33 100644
--- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
@@ -35,6 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces
35 35
36 public interface IAvatarFactoryModule 36 public interface IAvatarFactoryModule
37 { 37 {
38 void SetAppearance(IScenePresence sp, AvatarAppearance appearance);
38 void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams); 39 void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams);
39 40
40 /// <summary> 41 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index ec5cf32..bbdf35d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3408,9 +3408,9 @@ namespace OpenSim.Region.Framework.Scenes
3408 3408
3409 // Don't disable this log message - it's too helpful 3409 // Don't disable this log message - it's too helpful
3410 m_log.DebugFormat( 3410 m_log.DebugFormat(
3411 "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6}, position {7})", 3411 "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags {8}, position {9})",
3412 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3412 RegionInfo.RegionName, (agent.child ? "child" : "root"),agent.firstname, agent.lastname,
3413 agent.AgentID, agent.circuitcode, teleportFlags, agent.startpos); 3413 agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, teleportFlags, agent.startpos);
3414 3414
3415 if (LoginsDisabled) 3415 if (LoginsDisabled)
3416 { 3416 {
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index e44060c..429fc06 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -297,13 +297,10 @@ namespace OpenSim.Region.Framework.Scenes
297 /// </summary> 297 /// </summary>
298 public PhysicsActor PhysicsActor { get; private set; } 298 public PhysicsActor PhysicsActor { get; private set; }
299 299
300 private byte m_movementflag; 300 /// <summary>
301 301 /// Record user movement inputs.
302 public byte MovementFlag 302 /// </summary>
303 { 303 public byte MovementFlag { get; private set; }
304 set { m_movementflag = value; }
305 get { return m_movementflag; }
306 }
307 304
308 private bool m_updateflag; 305 private bool m_updateflag;
309 306
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index ba33122..4b80e37 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -1486,7 +1486,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1486 m_SOPXmlProcessors, 1486 m_SOPXmlProcessors,
1487 reader, 1487 reader,
1488 (o, nodeName, e) 1488 (o, nodeName, e)
1489 => m_log.ErrorFormat( 1489 => m_log.DebugFormat(
1490 "[SceneObjectSerializer]: Exception while parsing {0} in object {1} {2}: {3}{4}", 1490 "[SceneObjectSerializer]: Exception while parsing {0} in object {1} {2}: {3}{4}",
1491 ((SceneObjectPart)o).Name, ((SceneObjectPart)o).UUID, nodeName, e.Message, e.StackTrace)); 1491 ((SceneObjectPart)o).Name, ((SceneObjectPart)o).UUID, nodeName, e.Message, e.StackTrace));
1492 1492
@@ -1539,14 +1539,18 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1539 1539
1540 reader.ReadStartElement(name, String.Empty); // Shape 1540 reader.ReadStartElement(name, String.Empty); // Shape
1541 1541
1542 ExternalRepresentationUtils.ExecuteReadProcessors( 1542 errors = ExternalRepresentationUtils.ExecuteReadProcessors(
1543 shape, 1543 shape,
1544 m_ShapeXmlProcessors, 1544 m_ShapeXmlProcessors,
1545 reader, 1545 reader,
1546 (o, nodeName, e) 1546 (o, nodeName, e)
1547 => m_log.ErrorFormat( 1547 =>
1548 "[SceneObjectSerializer]: Exception while parsing Shape property {0}: {1}{2}", 1548 {
1549 nodeName, e.Message, e.StackTrace)); 1549 m_log.DebugFormat(
1550 "[SceneObjectSerializer]: Exception while parsing Shape property {0}: {1}{2}",
1551 nodeName, e.Message, e.StackTrace);
1552 }
1553 );
1550 1554
1551 reader.ReadEndElement(); // Shape 1555 reader.ReadEndElement(); // Shape
1552 1556
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index 1b675a6..8af3652 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -63,9 +63,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
63 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 63 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
64 64
65 // Capability string prefixes 65 // Capability string prefixes
66 private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; 66 private static readonly string m_parcelVoiceInfoRequestPath = "0207/";
67 private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; 67 private static readonly string m_provisionVoiceAccountRequestPath = "0208/";
68 private static readonly string m_chatSessionRequestPath = "0009/"; 68 private static readonly string m_chatSessionRequestPath = "0209/";
69 69
70 // Control info 70 // Control info
71 private static bool m_Enabled = false; 71 private static bool m_Enabled = false;
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
index 42008da..130513d 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
@@ -30,6 +30,7 @@ using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Collections.Specialized; 31using System.Collections.Specialized;
32using System.Reflection; 32using System.Reflection;
33using System.Threading;
33 34
34using Nwc.XmlRpc; 35using Nwc.XmlRpc;
35 36
@@ -167,6 +168,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
167 168
168 private bool m_debugEnabled = false; 169 private bool m_debugEnabled = false;
169 170
171 private Dictionary<string, bool> m_pendingRequests = new Dictionary<string,bool>();
172
170 private ExpiringCache<string, OSDMap> m_memoryCache; 173 private ExpiringCache<string, OSDMap> m_memoryCache;
171 private int m_cacheTimeout = 30; 174 private int m_cacheTimeout = 30;
172 175
@@ -1348,6 +1351,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1348 // Immediately forward the request if the cache is disabled. 1351 // Immediately forward the request if the cache is disabled.
1349 if (m_cacheTimeout == 0) 1352 if (m_cacheTimeout == 0)
1350 { 1353 {
1354 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: cache is disabled");
1351 return WebUtil.PostToService(m_groupsServerURI, requestArgs); 1355 return WebUtil.PostToService(m_groupsServerURI, requestArgs);
1352 } 1356 }
1353 1357
@@ -1355,6 +1359,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1355 if (requestArgs["RequestMethod"] == "RemoveGeneric" 1359 if (requestArgs["RequestMethod"] == "RemoveGeneric"
1356 || requestArgs["RequestMethod"] == "AddGeneric") 1360 || requestArgs["RequestMethod"] == "AddGeneric")
1357 { 1361 {
1362 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: clearing generics cache");
1363
1358 // Any and all updates cause the cache to clear 1364 // Any and all updates cause the cache to clear
1359 m_memoryCache.Clear(); 1365 m_memoryCache.Clear();
1360 1366
@@ -1366,18 +1372,67 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1366 1372
1367 // Create the cache key for the request and see if we have it cached 1373 // Create the cache key for the request and see if we have it cached
1368 string CacheKey = WebUtil.BuildQueryString(requestArgs); 1374 string CacheKey = WebUtil.BuildQueryString(requestArgs);
1369 OSDMap response = null; 1375
1370 if (!m_memoryCache.TryGetValue(CacheKey, out response)) 1376 // This code uses a leader/follower pattern. On a cache miss, the request is added
1377 // to a queue; the first thread to add it to the queue completes the request while
1378 // follow on threads busy wait for the results, this situation seems to happen
1379 // often when checking permissions
1380 while (true)
1371 { 1381 {
1372 // if it wasn't in the cache, pass the request to the Simian Grid Services 1382 OSDMap response = null;
1373 response = WebUtil.PostToService(m_groupsServerURI, requestArgs); 1383 bool firstRequest = false;
1374 1384
1375 // and cache the response 1385 lock (m_memoryCache)
1376 m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout)); 1386 {
1387 if (m_memoryCache.TryGetValue(CacheKey, out response))
1388 return response;
1389
1390 if (! m_pendingRequests.ContainsKey(CacheKey))
1391 {
1392 m_pendingRequests.Add(CacheKey,true);
1393 firstRequest = true;
1394 }
1395 }
1396
1397 if (firstRequest)
1398 {
1399 // if it wasn't in the cache, pass the request to the Simian Grid Services
1400 try
1401 {
1402 response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
1403 }
1404 catch (Exception e)
1405 {
1406 m_log.InfoFormat("[SIMIAN GROUPS CONNECTOR] request failed {0}",CacheKey);
1407 }
1408
1409 // and cache the response
1410 lock (m_memoryCache)
1411 {
1412 m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout));
1413 m_pendingRequests.Remove(CacheKey);
1414 }
1415
1416 return response;
1417 }
1418
1419 Thread.Sleep(50); // waiting for a web request to complete, 50msecs is reasonable
1377 } 1420 }
1378 1421
1379 // return cached response 1422 // if (!m_memoryCache.TryGetValue(CacheKey, out response))
1380 return response; 1423 // {
1424 // m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: query not in the cache");
1425 // Util.PrintCallStack();
1426
1427 // // if it wasn't in the cache, pass the request to the Simian Grid Services
1428 // response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
1429
1430 // // and cache the response
1431 // m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout));
1432 // }
1433
1434 // // return cached response
1435 // return response;
1381 } 1436 }
1382 #endregion 1437 #endregion
1383 1438
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 6803644..d395206 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -96,15 +96,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
96 if (!m_avatars.ContainsKey(agentId)) 96 if (!m_avatars.ContainsKey(agentId))
97 return false; 97 return false;
98 98
99 // Delete existing sp attachments
99 scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); 100 scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false);
100 101
101 AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); 102 // Set new sp appearance. Also sends to clients.
102 sp.Appearance = npcAppearance; 103 scene.RequestModuleInterface<IAvatarFactoryModule>().SetAppearance(sp, new AvatarAppearance(appearance, true));
104
105 // Rez needed sp attachments
103 scene.AttachmentsModule.RezAttachments(sp); 106 scene.AttachmentsModule.RezAttachments(sp);
104 107
105 IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>();
106 module.SendAppearance(sp.UUID);
107
108 return true; 108 return true;
109 } 109 }
110 110
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 7c1c046..6d1f41d 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -156,6 +156,22 @@ namespace OpenSim.Region.Physics.OdePlugin
156 internal UUID m_uuid { get; private set; } 156 internal UUID m_uuid { get; private set; }
157 internal bool bad = false; 157 internal bool bad = false;
158 158
159 /// <summary>
160 /// ODE Avatar.
161 /// </summary>
162 /// <param name="avName"></param>
163 /// <param name="parent_scene"></param>
164 /// <param name="pos"></param>
165 /// <param name="size"></param>
166 /// <param name="pid_d"></param>
167 /// <param name="pid_p"></param>
168 /// <param name="capsule_radius"></param>
169 /// <param name="tensor"></param>
170 /// <param name="density">
171 /// Only used right now to return information to LSL. Not actually used to set mass in ODE!
172 /// </param>
173 /// <param name="walk_divisor"></param>
174 /// <param name="rundivisor"></param>
159 public OdeCharacter( 175 public OdeCharacter(
160 String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, 176 String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p,
161 float capsule_radius, float tensor, float density, 177 float capsule_radius, float tensor, float density,
@@ -786,6 +802,10 @@ namespace OpenSim.Region.Physics.OdePlugin
786 Vector3 vec = Vector3.Zero; 802 Vector3 vec = Vector3.Zero;
787 d.Vector3 vel = d.BodyGetLinearVel(Body); 803 d.Vector3 vel = d.BodyGetLinearVel(Body);
788 804
805// m_log.DebugFormat(
806// "[ODE CHARACTER]: Current velocity in Move() is <{0},{1},{2}>, target {3} for {4}",
807// vel.X, vel.Y, vel.Z, _target_velocity, Name);
808
789 float movementdivisor = 1f; 809 float movementdivisor = 1f;
790 810
791 if (!m_alwaysRun) 811 if (!m_alwaysRun)
@@ -884,18 +904,20 @@ namespace OpenSim.Region.Physics.OdePlugin
884 904
885 if (flying) 905 if (flying)
886 { 906 {
907 // This also acts as anti-gravity so that we hover when flying rather than fall.
887 vec.Z = (_target_velocity.Z - vel.Z) * (PID_D); 908 vec.Z = (_target_velocity.Z - vel.Z) * (PID_D);
888 } 909 }
889 } 910 }
890 911
891 if (flying) 912 if (flying)
892 { 913 {
914 // Anti-gravity so that we hover when flying rather than fall.
893 vec.Z += ((-1 * _parent_scene.gravityz) * m_mass); 915 vec.Z += ((-1 * _parent_scene.gravityz) * m_mass);
894 916
895 //Added for auto fly height. Kitto Flora 917 //Added for auto fly height. Kitto Flora
896 //d.Vector3 pos = d.BodyGetPosition(Body); 918 //d.Vector3 pos = d.BodyGetPosition(Body);
897 float target_altitude = _parent_scene.GetTerrainHeightAtXY(_position.X, _position.Y) + MinimumGroundFlightOffset; 919 float target_altitude = _parent_scene.GetTerrainHeightAtXY(_position.X, _position.Y) + MinimumGroundFlightOffset;
898 920
899 if (_position.Z < target_altitude) 921 if (_position.Z < target_altitude)
900 { 922 {
901 vec.Z += (target_altitude - _position.Z) * PID_P * 5.0f; 923 vec.Z += (target_altitude - _position.Z) * PID_P * 5.0f;
@@ -921,6 +943,25 @@ namespace OpenSim.Region.Physics.OdePlugin
921 943
922 return; 944 return;
923 } 945 }
946
947 d.Vector3 newVel = d.BodyGetLinearVel(Body);
948 if (newVel.X >= 256 || newVel.X <= 256 || newVel.Y >= 256 || newVel.Y <= 256 || newVel.Z >= 256 || newVel.Z <= 256)
949 {
950// m_log.DebugFormat(
951// "[ODE CHARACTER]: Limiting falling velocity from {0} to {1} for {2}", newVel.Z, -9.8, Name);
952
953 newVel.X = Util.Clamp<float>(newVel.X, -255f, 255f);
954 newVel.Y = Util.Clamp<float>(newVel.Y, -255f, 255f);
955
956 if (!flying)
957 newVel.Z
958 = Util.Clamp<float>(
959 newVel.Z, -_parent_scene.AvatarTerminalVelocity, _parent_scene.AvatarTerminalVelocity);
960 else
961 newVel.Z = Util.Clamp<float>(newVel.Z, -255f, 255f);
962
963 d.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z);
964 }
924 } 965 }
925 966
926 /// <summary> 967 /// <summary>
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 4530c09..598530c 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -144,6 +144,8 @@ namespace OpenSim.Region.Physics.OdePlugin
144 public float gravityy = 0f; 144 public float gravityy = 0f;
145 public float gravityz = -9.8f; 145 public float gravityz = -9.8f;
146 146
147 public float AvatarTerminalVelocity { get; set; }
148
147 private float contactsurfacelayer = 0.001f; 149 private float contactsurfacelayer = 0.001f;
148 150
149 private int worldHashspaceLow = -4; 151 private int worldHashspaceLow = -4;
@@ -459,6 +461,15 @@ namespace OpenSim.Region.Physics.OdePlugin
459 gravityy = physicsconfig.GetFloat("world_gravityy", 0f); 461 gravityy = physicsconfig.GetFloat("world_gravityy", 0f);
460 gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f); 462 gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f);
461 463
464 float avatarTerminalVelocity = physicsconfig.GetFloat("avatar_terminal_velocity", 54f);
465 AvatarTerminalVelocity = Util.Clamp<float>(avatarTerminalVelocity, 0, 255f);
466 if (AvatarTerminalVelocity != avatarTerminalVelocity)
467 {
468 m_log.WarnFormat(
469 "[ODE SCENE]: avatar_terminal_velocity of {0} is invalid. Clamping to {1}",
470 avatarTerminalVelocity, AvatarTerminalVelocity);
471 }
472
462 worldHashspaceLow = physicsconfig.GetInt("world_hashspace_size_low", -4); 473 worldHashspaceLow = physicsconfig.GetInt("world_hashspace_size_low", -4);
463 worldHashspaceHigh = physicsconfig.GetInt("world_hashspace_size_high", 128); 474 worldHashspaceHigh = physicsconfig.GetInt("world_hashspace_size_high", 128);
464 475