diff options
Diffstat (limited to '')
28 files changed, 1425 insertions, 584 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 12c979a..01b9299 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -2028,7 +2028,7 @@ namespace OpenSim.Data.MySQL | |||
2028 | 2028 | ||
2029 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2029 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
2030 | { | 2030 | { |
2031 | cmd.CommandText = "select UUID from prims where RegionUUID = ?RegionUUID"; | 2031 | cmd.CommandText = "select UUID from prims where RegionUUID = ?RegionUUID and SceneGroupID = UUID"; |
2032 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | 2032 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); |
2033 | 2033 | ||
2034 | using (IDataReader reader = ExecuteReader(cmd)) | 2034 | using (IDataReader reader = ExecuteReader(cmd)) |
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 1638541..2183fb6 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -40,6 +40,13 @@ namespace OpenSim.Framework | |||
40 | /// </summary> | 40 | /// </summary> |
41 | public class AvatarAppearance | 41 | public class AvatarAppearance |
42 | { | 42 | { |
43 | // SL box diferent to size | ||
44 | const float AVBOXAJUST = 0.2f; | ||
45 | // constrains for ubitode physics | ||
46 | const float AVBOXMINX = 0.2f; | ||
47 | const float AVBOXMINY = 0.3f; | ||
48 | const float AVBOXMINZ = 1.2f; | ||
49 | |||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 51 | ||
45 | // this is viewer capabilities and weared things dependent | 52 | // this is viewer capabilities and weared things dependent |
@@ -55,6 +62,10 @@ namespace OpenSim.Framework | |||
55 | protected AvatarWearable[] m_wearables; | 62 | protected AvatarWearable[] m_wearables; |
56 | protected Dictionary<int, List<AvatarAttachment>> m_attachments; | 63 | protected Dictionary<int, List<AvatarAttachment>> m_attachments; |
57 | protected float m_avatarHeight = 0; | 64 | protected float m_avatarHeight = 0; |
65 | protected Vector3 m_avatarSize = new Vector3(0.45f, 0.6f, 1.9f); // sl Z cloud value | ||
66 | protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f); | ||
67 | protected float m_avatarFeetOffset = 0; | ||
68 | protected float m_avatarAnimOffset = 0; | ||
58 | 69 | ||
59 | public virtual int Serial | 70 | public virtual int Serial |
60 | { | 71 | { |
@@ -68,6 +79,21 @@ namespace OpenSim.Framework | |||
68 | set { m_visualparams = value; } | 79 | set { m_visualparams = value; } |
69 | } | 80 | } |
70 | 81 | ||
82 | public virtual Vector3 AvatarSize | ||
83 | { | ||
84 | get { return m_avatarSize; } | ||
85 | } | ||
86 | |||
87 | public virtual Vector3 AvatarBoxSize | ||
88 | { | ||
89 | get { return m_avatarBoxSize; } | ||
90 | } | ||
91 | |||
92 | public virtual float AvatarFeetOffset | ||
93 | { | ||
94 | get { return m_avatarFeetOffset + m_avatarAnimOffset; } | ||
95 | } | ||
96 | |||
71 | public virtual Primitive.TextureEntry Texture | 97 | public virtual Primitive.TextureEntry Texture |
72 | { | 98 | { |
73 | get { return m_texture; } | 99 | get { return m_texture; } |
@@ -98,7 +124,8 @@ namespace OpenSim.Framework | |||
98 | SetDefaultWearables(); | 124 | SetDefaultWearables(); |
99 | SetDefaultTexture(); | 125 | SetDefaultTexture(); |
100 | SetDefaultParams(); | 126 | SetDefaultParams(); |
101 | SetHeight(); | 127 | // SetHeight(); |
128 | SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
102 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); | 129 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); |
103 | } | 130 | } |
104 | 131 | ||
@@ -107,7 +134,7 @@ namespace OpenSim.Framework | |||
107 | // m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance from OSDMap"); | 134 | // m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance from OSDMap"); |
108 | 135 | ||
109 | Unpack(map); | 136 | Unpack(map); |
110 | SetHeight(); | 137 | // SetHeight(); done in Unpack |
111 | } | 138 | } |
112 | 139 | ||
113 | public AvatarAppearance(AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) | 140 | public AvatarAppearance(AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) |
@@ -131,7 +158,9 @@ namespace OpenSim.Framework | |||
131 | else | 158 | else |
132 | SetDefaultParams(); | 159 | SetDefaultParams(); |
133 | 160 | ||
134 | SetHeight(); | 161 | // SetHeight(); |
162 | if(m_avatarHeight == 0) | ||
163 | SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
135 | 164 | ||
136 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); | 165 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); |
137 | } | 166 | } |
@@ -150,7 +179,8 @@ namespace OpenSim.Framework | |||
150 | SetDefaultWearables(); | 179 | SetDefaultWearables(); |
151 | SetDefaultTexture(); | 180 | SetDefaultTexture(); |
152 | SetDefaultParams(); | 181 | SetDefaultParams(); |
153 | SetHeight(); | 182 | // SetHeight(); |
183 | SetSize(new Vector3(0.45f, 0.6f, 1.9f)); | ||
154 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); | 184 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); |
155 | 185 | ||
156 | return; | 186 | return; |
@@ -179,7 +209,8 @@ namespace OpenSim.Framework | |||
179 | if (appearance.VisualParams != null) | 209 | if (appearance.VisualParams != null) |
180 | m_visualparams = (byte[])appearance.VisualParams.Clone(); | 210 | m_visualparams = (byte[])appearance.VisualParams.Clone(); |
181 | 211 | ||
182 | m_avatarHeight = appearance.m_avatarHeight; | 212 | // m_avatarHeight = appearance.m_avatarHeight; |
213 | SetSize(appearance.AvatarSize); | ||
183 | 214 | ||
184 | // Copy the attachment, force append mode since that ensures consistency | 215 | // Copy the attachment, force append mode since that ensures consistency |
185 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); | 216 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); |
@@ -346,8 +377,8 @@ namespace OpenSim.Framework | |||
346 | } | 377 | } |
347 | } | 378 | } |
348 | // Reset the height if the visual parameters actually changed | 379 | // Reset the height if the visual parameters actually changed |
349 | if (changed) | 380 | // if (changed) |
350 | SetHeight(); | 381 | // SetHeight(); |
351 | 382 | ||
352 | return changed; | 383 | return changed; |
353 | } | 384 | } |
@@ -363,6 +394,7 @@ namespace OpenSim.Framework | |||
363 | /// </summary> | 394 | /// </summary> |
364 | public virtual void SetHeight() | 395 | public virtual void SetHeight() |
365 | { | 396 | { |
397 | /* | ||
366 | // Start with shortest possible female avatar height | 398 | // Start with shortest possible female avatar height |
367 | m_avatarHeight = 1.14597f; | 399 | m_avatarHeight = 1.14597f; |
368 | // Add offset for male avatars | 400 | // Add offset for male avatars |
@@ -375,6 +407,35 @@ namespace OpenSim.Framework | |||
375 | + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f | 407 | + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f |
376 | + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f | 408 | + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f |
377 | + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; | 409 | + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; |
410 | */ | ||
411 | } | ||
412 | |||
413 | public void SetSize(Vector3 avSize) | ||
414 | { | ||
415 | if (avSize.X > 32f) | ||
416 | avSize.X = 32f; | ||
417 | else if (avSize.X < 0.1f) | ||
418 | avSize.X = 0.1f; | ||
419 | |||
420 | if (avSize.Y > 32f) | ||
421 | avSize.Y = 32f; | ||
422 | else if (avSize.Y < 0.1f) | ||
423 | avSize.Y = 0.1f; | ||
424 | if (avSize.Z > 32f) | ||
425 | avSize.Z = 32f; | ||
426 | else if (avSize.Z < 0.1f) | ||
427 | avSize.Z = 0.1f; | ||
428 | |||
429 | m_avatarSize = avSize; | ||
430 | m_avatarBoxSize = avSize; | ||
431 | m_avatarBoxSize.Z += AVBOXAJUST; | ||
432 | if (m_avatarBoxSize.X < AVBOXMINX) | ||
433 | m_avatarBoxSize.X = AVBOXMINX; | ||
434 | if (m_avatarBoxSize.Y < AVBOXMINY) | ||
435 | m_avatarBoxSize.Y = AVBOXMINY; | ||
436 | if (m_avatarBoxSize.Z < AVBOXMINZ) | ||
437 | m_avatarBoxSize.Z = AVBOXMINZ; | ||
438 | m_avatarHeight = m_avatarSize.Z; | ||
378 | } | 439 | } |
379 | 440 | ||
380 | public virtual void SetWearable(int wearableId, AvatarWearable wearable) | 441 | public virtual void SetWearable(int wearableId, AvatarWearable wearable) |
@@ -649,7 +710,8 @@ namespace OpenSim.Framework | |||
649 | if ((data != null) && (data["serial"] != null)) | 710 | if ((data != null) && (data["serial"] != null)) |
650 | m_serial = data["serial"].AsInteger(); | 711 | m_serial = data["serial"].AsInteger(); |
651 | if ((data != null) && (data["height"] != null)) | 712 | if ((data != null) && (data["height"] != null)) |
652 | m_avatarHeight = (float)data["height"].AsReal(); | 713 | // m_avatarHeight = (float)data["height"].AsReal(); |
714 | SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal())); | ||
653 | 715 | ||
654 | try | 716 | try |
655 | { | 717 | { |
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index f686c60..c9b67de 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -64,7 +64,7 @@ namespace OpenSim.Framework | |||
64 | 64 | ||
65 | public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); | 65 | public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); |
66 | 66 | ||
67 | public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams); | 67 | public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize); |
68 | 68 | ||
69 | public delegate void StartAnim(IClientAPI remoteClient, UUID animID); | 69 | public delegate void StartAnim(IClientAPI remoteClient, UUID animID); |
70 | 70 | ||
diff --git a/OpenSim/Framework/IImprovedAssetCache.cs b/OpenSim/Framework/IImprovedAssetCache.cs index 251215a..a0b8b55 100644 --- a/OpenSim/Framework/IImprovedAssetCache.cs +++ b/OpenSim/Framework/IImprovedAssetCache.cs | |||
@@ -33,6 +33,7 @@ namespace OpenSim.Framework | |||
33 | { | 33 | { |
34 | void Cache(AssetBase asset); | 34 | void Cache(AssetBase asset); |
35 | AssetBase Get(string id); | 35 | AssetBase Get(string id); |
36 | bool Check(string id); | ||
36 | void Expire(string id); | 37 | void Expire(string id); |
37 | void Clear(); | 38 | void Clear(); |
38 | } | 39 | } |
diff --git a/OpenSim/Framework/IMoneyModule.cs b/OpenSim/Framework/IMoneyModule.cs index 71de93a..7378d2e 100644 --- a/OpenSim/Framework/IMoneyModule.cs +++ b/OpenSim/Framework/IMoneyModule.cs | |||
@@ -33,7 +33,7 @@ namespace OpenSim.Framework | |||
33 | public interface IMoneyModule | 33 | public interface IMoneyModule |
34 | { | 34 | { |
35 | bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, | 35 | bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, |
36 | int amount); | 36 | int amount, UUID txn); |
37 | 37 | ||
38 | int GetBalance(UUID agentID); | 38 | int GetBalance(UUID agentID); |
39 | bool UploadCovered(UUID agentID, int amount); | 39 | bool UploadCovered(UUID agentID, int amount); |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 6b33561..908f628 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | |||
@@ -377,7 +377,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
377 | protocol = "https"; | 377 | protocol = "https"; |
378 | } | 378 | } |
379 | caps.RegisterHandler("GetMesh", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); | 379 | caps.RegisterHandler("GetMesh", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); |
380 | m_pollservices.Add(agentID, args); | 380 | m_pollservices[agentID] = args; |
381 | m_capsDict[agentID] = capUrl; | 381 | m_capsDict[agentID] = capUrl; |
382 | 382 | ||
383 | 383 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index dd87671..d4dbfb9 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -333,7 +333,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
333 | protocol = "https"; | 333 | protocol = "https"; |
334 | } | 334 | } |
335 | caps.RegisterHandler("GetTexture", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); | 335 | caps.RegisterHandler("GetTexture", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); |
336 | m_pollservices.Add(agentID, args); | 336 | m_pollservices[agentID] = args; |
337 | m_capsDict[agentID] = capUrl; | 337 | m_capsDict[agentID] = capUrl; |
338 | } | 338 | } |
339 | 339 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index c0daba2..ee66485 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -331,6 +331,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
331 | private Prioritizer m_prioritizer; | 331 | private Prioritizer m_prioritizer; |
332 | private bool m_disableFacelights = false; | 332 | private bool m_disableFacelights = false; |
333 | 333 | ||
334 | private bool m_VelocityInterpolate = false; | ||
334 | private const uint MaxTransferBytesPerPacket = 600; | 335 | private const uint MaxTransferBytesPerPacket = 600; |
335 | 336 | ||
336 | 337 | ||
@@ -4971,7 +4972,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4971 | // in that direction, even though we don't model this on the server. Implementing this in the future | 4972 | // in that direction, even though we don't model this on the server. Implementing this in the future |
4972 | // may improve movement smoothness. | 4973 | // may improve movement smoothness. |
4973 | // acceleration = new Vector3(1, 0, 0); | 4974 | // acceleration = new Vector3(1, 0, 0); |
4974 | 4975 | ||
4975 | angularVelocity = Vector3.Zero; | 4976 | angularVelocity = Vector3.Zero; |
4976 | 4977 | ||
4977 | if (sendTexture) | 4978 | if (sendTexture) |
@@ -5121,7 +5122,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5121 | update.PCode = (byte)PCode.Avatar; | 5122 | update.PCode = (byte)PCode.Avatar; |
5122 | update.ProfileCurve = 1; | 5123 | update.ProfileCurve = 1; |
5123 | update.PSBlock = Utils.EmptyBytes; | 5124 | update.PSBlock = Utils.EmptyBytes; |
5124 | update.Scale = new Vector3(0.45f, 0.6f, 1.9f); | 5125 | update.Scale = data.Appearance.AvatarSize; |
5126 | // update.Scale.Z -= 0.2f; | ||
5127 | |||
5125 | update.Text = Utils.EmptyBytes; | 5128 | update.Text = Utils.EmptyBytes; |
5126 | update.TextColor = new byte[4]; | 5129 | update.TextColor = new byte[4]; |
5127 | 5130 | ||
@@ -5309,8 +5312,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5309 | // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs | 5312 | // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs |
5310 | // for each AgentUpdate packet. | 5313 | // for each AgentUpdate packet. |
5311 | AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false); | 5314 | AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false); |
5312 | 5315 | ||
5313 | AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false); | 5316 | AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false); |
5317 | AddLocalPacketHandler(PacketType.VelocityInterpolateOff, HandleVelocityInterpolateOff, false); | ||
5318 | AddLocalPacketHandler(PacketType.VelocityInterpolateOn, HandleVelocityInterpolateOn, false); | ||
5314 | AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false); | 5319 | AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false); |
5315 | AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false); | 5320 | AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false); |
5316 | AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false); | 5321 | AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false); |
@@ -5828,6 +5833,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5828 | return true; | 5833 | return true; |
5829 | } | 5834 | } |
5830 | 5835 | ||
5836 | private bool HandleVelocityInterpolateOff(IClientAPI sender, Packet Pack) | ||
5837 | { | ||
5838 | VelocityInterpolateOffPacket p = (VelocityInterpolateOffPacket)Pack; | ||
5839 | if (p.AgentData.SessionID != SessionId || | ||
5840 | p.AgentData.AgentID != AgentId) | ||
5841 | return true; | ||
5842 | |||
5843 | m_VelocityInterpolate = false; | ||
5844 | return true; | ||
5845 | } | ||
5846 | |||
5847 | private bool HandleVelocityInterpolateOn(IClientAPI sender, Packet Pack) | ||
5848 | { | ||
5849 | VelocityInterpolateOnPacket p = (VelocityInterpolateOnPacket)Pack; | ||
5850 | if (p.AgentData.SessionID != SessionId || | ||
5851 | p.AgentData.AgentID != AgentId) | ||
5852 | return true; | ||
5853 | |||
5854 | m_VelocityInterpolate = true; | ||
5855 | return true; | ||
5856 | } | ||
5857 | |||
5858 | |||
5831 | private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack) | 5859 | private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack) |
5832 | { | 5860 | { |
5833 | AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack; | 5861 | AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack; |
@@ -6248,6 +6276,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6248 | // Temporarily protect ourselves from the mantis #951 failure. | 6276 | // Temporarily protect ourselves from the mantis #951 failure. |
6249 | // However, we could do this for several other handlers where a failure isn't terminal | 6277 | // However, we could do this for several other handlers where a failure isn't terminal |
6250 | // for the client session anyway, in order to protect ourselves against bad code in plugins | 6278 | // for the client session anyway, in order to protect ourselves against bad code in plugins |
6279 | Vector3 avSize = appear.AgentData.Size; | ||
6251 | try | 6280 | try |
6252 | { | 6281 | { |
6253 | byte[] visualparams = new byte[appear.VisualParam.Length]; | 6282 | byte[] visualparams = new byte[appear.VisualParam.Length]; |
@@ -6258,7 +6287,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6258 | if (appear.ObjectData.TextureEntry.Length > 1) | 6287 | if (appear.ObjectData.TextureEntry.Length > 1) |
6259 | te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); | 6288 | te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); |
6260 | 6289 | ||
6261 | handlerSetAppearance(sender, te, visualparams); | 6290 | handlerSetAppearance(sender, te, visualparams,avSize); |
6262 | } | 6291 | } |
6263 | catch (Exception e) | 6292 | catch (Exception e) |
6264 | { | 6293 | { |
@@ -11667,14 +11696,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11667 | cachedresp.WearableData = | 11696 | cachedresp.WearableData = |
11668 | new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length]; | 11697 | new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length]; |
11669 | 11698 | ||
11670 | for (int i = 0; i < cachedtex.WearableData.Length; i++) | 11699 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); |
11700 | if (cache == null) | ||
11671 | { | 11701 | { |
11672 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | 11702 | for (int i = 0; i < cachedtex.WearableData.Length; i++) |
11673 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; | 11703 | { |
11674 | cachedresp.WearableData[i].TextureID = UUID.Zero; | 11704 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); |
11675 | cachedresp.WearableData[i].HostName = new byte[0]; | 11705 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; |
11706 | cachedresp.WearableData[i].TextureID = UUID.Zero; | ||
11707 | cachedresp.WearableData[i].HostName = new byte[0]; | ||
11708 | } | ||
11709 | } | ||
11710 | else | ||
11711 | { | ||
11712 | for (int i = 0; i < cachedtex.WearableData.Length; i++) | ||
11713 | { | ||
11714 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | ||
11715 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; | ||
11716 | if(cache.Check(cachedtex.WearableData[i].ID.ToString())) | ||
11717 | cachedresp.WearableData[i].TextureID = UUID.Zero; | ||
11718 | else | ||
11719 | cachedresp.WearableData[i].TextureID = UUID.Zero; | ||
11720 | cachedresp.WearableData[i].HostName = new byte[0]; | ||
11721 | } | ||
11676 | } | 11722 | } |
11677 | |||
11678 | cachedresp.Header.Zerocoded = true; | 11723 | cachedresp.Header.Zerocoded = true; |
11679 | OutPacket(cachedresp, ThrottleOutPacketType.Task); | 11724 | OutPacket(cachedresp, ThrottleOutPacketType.Task); |
11680 | 11725 | ||
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index e40caec..f43305f 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -194,6 +194,12 @@ namespace OpenSim.Region.CoreModules.Asset | |||
194 | 194 | ||
195 | #region IImprovedAssetCache Members | 195 | #region IImprovedAssetCache Members |
196 | 196 | ||
197 | |||
198 | public bool Check(string id) | ||
199 | { | ||
200 | return false; | ||
201 | } | ||
202 | |||
197 | /// <summary> | 203 | /// <summary> |
198 | /// Cache asset. | 204 | /// Cache asset. |
199 | /// </summary> | 205 | /// </summary> |
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index 9742a5c..58ce61a 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs | |||
@@ -112,6 +112,10 @@ namespace OpenSim.Region.CoreModules.Asset | |||
112 | //////////////////////////////////////////////////////////// | 112 | //////////////////////////////////////////////////////////// |
113 | // IImprovedAssetCache | 113 | // IImprovedAssetCache |
114 | // | 114 | // |
115 | public bool Check(string id) | ||
116 | { | ||
117 | return false; | ||
118 | } | ||
115 | 119 | ||
116 | public void Cache(AssetBase asset) | 120 | public void Cache(AssetBase asset) |
117 | { | 121 | { |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index b1bb56b..a0f1e8c 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -348,6 +348,17 @@ namespace OpenSim.Region.CoreModules.Asset | |||
348 | return asset; | 348 | return asset; |
349 | } | 349 | } |
350 | 350 | ||
351 | private bool CheckFromMemoryCache(string id) | ||
352 | { | ||
353 | AssetBase asset = null; | ||
354 | |||
355 | if (m_MemoryCache.TryGetValue(id, out asset)) | ||
356 | return true; | ||
357 | |||
358 | return false; | ||
359 | } | ||
360 | |||
361 | |||
351 | /// <summary> | 362 | /// <summary> |
352 | /// Try to get an asset from the file cache. | 363 | /// Try to get an asset from the file cache. |
353 | /// </summary> | 364 | /// </summary> |
@@ -420,6 +431,50 @@ namespace OpenSim.Region.CoreModules.Asset | |||
420 | return asset; | 431 | return asset; |
421 | } | 432 | } |
422 | 433 | ||
434 | private bool CheckFromFileCache(string id) | ||
435 | { | ||
436 | bool found = false; | ||
437 | |||
438 | string filename = GetFileName(id); | ||
439 | if (File.Exists(filename)) | ||
440 | { | ||
441 | // actually check if we can open it, and so update expire | ||
442 | FileStream stream = null; | ||
443 | try | ||
444 | { | ||
445 | stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); | ||
446 | if (stream != null) | ||
447 | { | ||
448 | found = true; | ||
449 | stream.Close(); | ||
450 | } | ||
451 | |||
452 | } | ||
453 | catch (System.Runtime.Serialization.SerializationException e) | ||
454 | { | ||
455 | found = false; | ||
456 | m_log.ErrorFormat( | ||
457 | "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", | ||
458 | filename, id, e.Message, e.StackTrace); | ||
459 | |||
460 | // If there was a problem deserializing the asset, the asset may | ||
461 | // either be corrupted OR was serialized under an old format | ||
462 | // {different version of AssetBase} -- we should attempt to | ||
463 | // delete it and re-cache | ||
464 | File.Delete(filename); | ||
465 | } | ||
466 | catch (Exception e) | ||
467 | { | ||
468 | found = false; | ||
469 | m_log.ErrorFormat( | ||
470 | "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", | ||
471 | filename, id, e.Message, e.StackTrace); | ||
472 | } | ||
473 | } | ||
474 | |||
475 | return found; | ||
476 | } | ||
477 | |||
423 | public AssetBase Get(string id) | 478 | public AssetBase Get(string id) |
424 | { | 479 | { |
425 | m_Requests++; | 480 | m_Requests++; |
@@ -456,11 +511,26 @@ namespace OpenSim.Region.CoreModules.Asset | |||
456 | return asset; | 511 | return asset; |
457 | } | 512 | } |
458 | 513 | ||
514 | public bool Check(string id) | ||
515 | { | ||
516 | if (m_MemoryCacheEnabled && CheckFromMemoryCache(id)) | ||
517 | return true; | ||
518 | |||
519 | if (m_FileCacheEnabled && CheckFromFileCache(id)) | ||
520 | return true; | ||
521 | return false; | ||
522 | } | ||
523 | |||
459 | public AssetBase GetCached(string id) | 524 | public AssetBase GetCached(string id) |
460 | { | 525 | { |
461 | return Get(id); | 526 | return Get(id); |
462 | } | 527 | } |
463 | 528 | ||
529 | public AssetBase CheckCached(string id) | ||
530 | { | ||
531 | return Get(id); | ||
532 | } | ||
533 | |||
464 | public void Expire(string id) | 534 | public void Expire(string id) |
465 | { | 535 | { |
466 | if (m_LogLevel >= 2) | 536 | if (m_LogLevel >= 2) |
@@ -941,6 +1011,11 @@ namespace OpenSim.Region.CoreModules.Asset | |||
941 | return asset.Data; | 1011 | return asset.Data; |
942 | } | 1012 | } |
943 | 1013 | ||
1014 | public bool CheckData(string id) | ||
1015 | { | ||
1016 | return Check(id); ; | ||
1017 | } | ||
1018 | |||
944 | public bool Get(string id, object sender, AssetRetrieved handler) | 1019 | public bool Get(string id, object sender, AssetRetrieved handler) |
945 | { | 1020 | { |
946 | AssetBase asset = Get(id); | 1021 | AssetBase asset = Get(id); |
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index 9592ca0..ce9b546 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs | |||
@@ -115,6 +115,11 @@ namespace OpenSim.Region.CoreModules.Asset | |||
115 | // IImprovedAssetCache | 115 | // IImprovedAssetCache |
116 | // | 116 | // |
117 | 117 | ||
118 | public bool Check(string id) | ||
119 | { | ||
120 | return false; | ||
121 | } | ||
122 | |||
118 | public void Cache(AssetBase asset) | 123 | public void Cache(AssetBase asset) |
119 | { | 124 | { |
120 | if (asset != null) | 125 | if (asset != null) |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 8496005..3532b1d 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -145,6 +145,21 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
145 | SetAppearance(sp, appearance.Texture, appearance.VisualParams); | 145 | SetAppearance(sp, appearance.Texture, appearance.VisualParams); |
146 | } | 146 | } |
147 | 147 | ||
148 | |||
149 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize) | ||
150 | { | ||
151 | float oldoff = sp.Appearance.AvatarFeetOffset; | ||
152 | Vector3 oldbox = sp.Appearance.AvatarBoxSize; | ||
153 | |||
154 | SetAppearance(sp, textureEntry, visualParams); | ||
155 | sp.Appearance.SetSize(avSize); | ||
156 | |||
157 | float off = sp.Appearance.AvatarFeetOffset; | ||
158 | Vector3 box = sp.Appearance.AvatarBoxSize; | ||
159 | if (oldoff != off || oldbox != box) | ||
160 | ((ScenePresence)sp).SetSize(box, off); | ||
161 | } | ||
162 | |||
148 | /// <summary> | 163 | /// <summary> |
149 | /// Set appearance data (texture asset IDs and slider settings) | 164 | /// Set appearance data (texture asset IDs and slider settings) |
150 | /// </summary> | 165 | /// </summary> |
@@ -174,12 +189,21 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
174 | // m_log.DebugFormat( | 189 | // m_log.DebugFormat( |
175 | // "[AVFACTORY]: Setting visual params for {0} to {1}", | 190 | // "[AVFACTORY]: Setting visual params for {0} to {1}", |
176 | // client.Name, string.Join(", ", visualParamsStrings)); | 191 | // client.Name, string.Join(", ", visualParamsStrings)); |
177 | 192 | /* | |
178 | float oldHeight = sp.Appearance.AvatarHeight; | 193 | float oldHeight = sp.Appearance.AvatarHeight; |
179 | changed = sp.Appearance.SetVisualParams(visualParams); | 194 | changed = sp.Appearance.SetVisualParams(visualParams); |
180 | 195 | ||
181 | if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) | 196 | if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) |
182 | ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); | 197 | ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); |
198 | */ | ||
199 | // float oldoff = sp.Appearance.AvatarFeetOffset; | ||
200 | // Vector3 oldbox = sp.Appearance.AvatarBoxSize; | ||
201 | changed = sp.Appearance.SetVisualParams(visualParams); | ||
202 | // float off = sp.Appearance.AvatarFeetOffset; | ||
203 | // Vector3 box = sp.Appearance.AvatarBoxSize; | ||
204 | // if(oldoff != off || oldbox != box) | ||
205 | // ((ScenePresence)sp).SetSize(box,off); | ||
206 | |||
183 | } | 207 | } |
184 | 208 | ||
185 | // Process the baked texture array | 209 | // Process the baked texture array |
@@ -337,6 +361,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
337 | public bool ValidateBakedTextureCache(IScenePresence sp) | 361 | public bool ValidateBakedTextureCache(IScenePresence sp) |
338 | { | 362 | { |
339 | bool defonly = true; // are we only using default textures | 363 | bool defonly = true; // are we only using default textures |
364 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
340 | 365 | ||
341 | // Process the texture entry | 366 | // Process the texture entry |
342 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | 367 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) |
@@ -361,8 +386,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
361 | 386 | ||
362 | defonly = false; // found a non-default texture reference | 387 | defonly = false; // found a non-default texture reference |
363 | 388 | ||
364 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | 389 | if (cache != null) |
365 | return false; | 390 | { |
391 | if (!cache.Check(face.TextureID.ToString())) | ||
392 | return false; | ||
393 | } | ||
394 | else | ||
395 | { | ||
396 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | ||
397 | return false; | ||
398 | } | ||
366 | } | 399 | } |
367 | 400 | ||
368 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); | 401 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); |
@@ -374,6 +407,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
374 | public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) | 407 | public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) |
375 | { | 408 | { |
376 | int texturesRebaked = 0; | 409 | int texturesRebaked = 0; |
410 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
377 | 411 | ||
378 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | 412 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) |
379 | { | 413 | { |
@@ -397,21 +431,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
397 | 431 | ||
398 | if (missingTexturesOnly) | 432 | if (missingTexturesOnly) |
399 | { | 433 | { |
400 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) | 434 | if (cache != null) |
401 | { | 435 | { |
402 | continue; | 436 | if (cache.Check(face.TextureID.ToString())) |
437 | continue; | ||
438 | else | ||
439 | { | ||
440 | m_log.DebugFormat( | ||
441 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | ||
442 | face.TextureID, idx, sp.Name); | ||
443 | } | ||
403 | } | 444 | } |
404 | else | 445 | else |
405 | { | 446 | { |
406 | // On inter-simulator teleports, this occurs if baked textures are not being stored by the | 447 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) |
407 | // grid asset service (which means that they are not available to the new region and so have | 448 | { |
408 | // to be re-requested from the client). | 449 | continue; |
409 | // | 450 | } |
410 | // The only available core OpenSimulator behaviour right now | 451 | |
411 | // is not to store these textures, temporarily or otherwise. | 452 | else |
412 | m_log.DebugFormat( | 453 | { |
413 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | 454 | // On inter-simulator teleports, this occurs if baked textures are not being stored by the |
414 | face.TextureID, idx, sp.Name); | 455 | // grid asset service (which means that they are not available to the new region and so have |
456 | // to be re-requested from the client). | ||
457 | // | ||
458 | // The only available core OpenSimulator behaviour right now | ||
459 | // is not to store these textures, temporarily or otherwise. | ||
460 | m_log.DebugFormat( | ||
461 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | ||
462 | face.TextureID, idx, sp.Name); | ||
463 | } | ||
415 | } | 464 | } |
416 | } | 465 | } |
417 | else | 466 | else |
@@ -611,12 +660,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
611 | /// <param name="client"></param> | 660 | /// <param name="client"></param> |
612 | /// <param name="texture"></param> | 661 | /// <param name="texture"></param> |
613 | /// <param name="visualParam"></param> | 662 | /// <param name="visualParam"></param> |
614 | private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) | 663 | private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize) |
615 | { | 664 | { |
616 | // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); | 665 | // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); |
617 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 666 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
618 | if (sp != null) | 667 | if (sp != null) |
619 | SetAppearance(sp, textureEntry, visualParams); | 668 | SetAppearance(sp, textureEntry, visualParams,avSize); |
620 | else | 669 | else |
621 | m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); | 670 | m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); |
622 | } | 671 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index bc62d51..2051a53 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -3457,7 +3457,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3457 | part.ClonePermissions(RootPart); | 3457 | part.ClonePermissions(RootPart); |
3458 | }); | 3458 | }); |
3459 | 3459 | ||
3460 | RootPart.OwnerMask = newOwnerMask | foldedPerms; | 3460 | uint lockMask = ~(uint)PermissionMask.Move; |
3461 | uint lockBit = RootPart.OwnerMask & (uint)PermissionMask.Move; | ||
3462 | RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask); | ||
3461 | RootPart.ScheduleFullUpdate(); | 3463 | RootPart.ScheduleFullUpdate(); |
3462 | } | 3464 | } |
3463 | 3465 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1250a11..041eac2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -140,6 +140,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
140 | private Vector3 m_lastPosition; | 140 | private Vector3 m_lastPosition; |
141 | private Quaternion m_lastRotation; | 141 | private Quaternion m_lastRotation; |
142 | private Vector3 m_lastVelocity; | 142 | private Vector3 m_lastVelocity; |
143 | private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); | ||
144 | |||
143 | 145 | ||
144 | private Vector3? m_forceToApply; | 146 | private Vector3? m_forceToApply; |
145 | private int m_userFlags; | 147 | private int m_userFlags; |
@@ -560,7 +562,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
560 | // Scene.RegionInfo.RegionName, Name, m_velocity); | 562 | // Scene.RegionInfo.RegionName, Name, m_velocity); |
561 | } | 563 | } |
562 | } | 564 | } |
565 | /* | ||
566 | public override Vector3 AngularVelocity | ||
567 | { | ||
568 | get | ||
569 | { | ||
570 | if (PhysicsActor != null) | ||
571 | { | ||
572 | m_rotationalvelocity = PhysicsActor.RotationalVelocity; | ||
563 | 573 | ||
574 | // m_log.DebugFormat( | ||
575 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", | ||
576 | // m_velocity, Name, Scene.RegionInfo.RegionName); | ||
577 | } | ||
578 | |||
579 | return m_rotationalvelocity; | ||
580 | } | ||
581 | } | ||
582 | */ | ||
564 | private Quaternion m_bodyRot = Quaternion.Identity; | 583 | private Quaternion m_bodyRot = Quaternion.Identity; |
565 | 584 | ||
566 | public Quaternion Rotation | 585 | public Quaternion Rotation |
@@ -569,7 +588,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
569 | set | 588 | set |
570 | { | 589 | { |
571 | m_bodyRot = value; | 590 | m_bodyRot = value; |
572 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | 591 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); |
592 | if (PhysicsActor != null) | ||
593 | { | ||
594 | try | ||
595 | { | ||
596 | PhysicsActor.Orientation = value; | ||
597 | } | ||
598 | catch (Exception e) | ||
599 | { | ||
600 | m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); | ||
601 | } | ||
602 | } | ||
573 | } | 603 | } |
574 | } | 604 | } |
575 | 605 | ||
@@ -1247,6 +1277,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1247 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); | 1277 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); |
1248 | } | 1278 | } |
1249 | 1279 | ||
1280 | public void SetSize(Vector3 size, float feetoffset) | ||
1281 | { | ||
1282 | if (PhysicsActor != null && !IsChildAgent) | ||
1283 | PhysicsActor.setAvatarSize(size, feetoffset); | ||
1284 | |||
1285 | } | ||
1286 | |||
1250 | /// <summary> | 1287 | /// <summary> |
1251 | /// Complete Avatar's movement into the region. | 1288 | /// Complete Avatar's movement into the region. |
1252 | /// </summary> | 1289 | /// </summary> |
@@ -2064,12 +2101,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
2064 | } | 2101 | } |
2065 | else | 2102 | else |
2066 | { | 2103 | { |
2067 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 2104 | // if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) |
2068 | { | 2105 | // { |
2069 | // m_log.DebugFormat( | 2106 | // m_log.DebugFormat( |
2070 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", | 2107 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", |
2071 | // Name, part.Name, part.LocalId); | 2108 | // Name, part.Name, part.LocalId); |
2072 | 2109 | ||
2110 | if (m_scene.PhysicsScene != null && | ||
2111 | part.PhysActor != null && | ||
2112 | Util.GetDistanceTo(AbsolutePosition, pos) <= 30) | ||
2113 | { | ||
2114 | |||
2115 | Vector3 camdif = CameraPosition - part.AbsolutePosition; | ||
2116 | camdif.Normalize(); | ||
2117 | |||
2118 | // m_log.InfoFormat("sit {0} {1}", offset.ToString(), camdif.ToString()); | ||
2119 | |||
2120 | if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) | ||
2121 | return; | ||
2122 | } | ||
2123 | |||
2124 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | ||
2125 | { | ||
2126 | |||
2073 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 2127 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
2074 | canSit = true; | 2128 | canSit = true; |
2075 | } | 2129 | } |
@@ -2142,197 +2196,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
2142 | SendSitResponse(targetID, offset, Quaternion.Identity); | 2196 | SendSitResponse(targetID, offset, Quaternion.Identity); |
2143 | } | 2197 | } |
2144 | 2198 | ||
2145 | /* | 2199 | public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) |
2146 | public void SitRayCastAvatarPosition(SceneObjectPart part) | ||
2147 | { | 2200 | { |
2148 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2149 | Vector3 StartRayCastPosition = AbsolutePosition; | ||
2150 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2151 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2152 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); | ||
2153 | } | ||
2154 | 2201 | ||
2155 | public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2202 | if (status < 0) |
2156 | { | ||
2157 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2158 | if (part != null) | ||
2159 | { | ||
2160 | if (hitYN) | ||
2161 | { | ||
2162 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2163 | { | ||
2164 | SitRaycastFindEdge(collisionPoint, normal); | ||
2165 | m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2166 | } | ||
2167 | else | ||
2168 | { | ||
2169 | SitRayCastAvatarPositionCameraZ(part); | ||
2170 | } | ||
2171 | } | ||
2172 | else | ||
2173 | { | ||
2174 | SitRayCastAvatarPositionCameraZ(part); | ||
2175 | } | ||
2176 | } | ||
2177 | else | ||
2178 | { | 2203 | { |
2179 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2204 | ControllingClient.SendAlertMessage("Sit position no longer exists"); |
2180 | m_requestedSitTargetUUID = UUID.Zero; | 2205 | return; |
2181 | m_requestedSitTargetID = 0; | ||
2182 | m_requestedSitOffset = Vector3.Zero; | ||
2183 | } | 2206 | } |
2184 | 2207 | ||
2185 | } | 2208 | if (status == 0) |
2186 | 2209 | return; | |
2187 | public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) | ||
2188 | { | ||
2189 | // Next, try to raycast from the camera Z position | ||
2190 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2191 | Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; | ||
2192 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2193 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2194 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); | ||
2195 | } | ||
2196 | 2210 | ||
2197 | public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2211 | SceneObjectPart part = m_scene.GetSceneObjectPart(partID); |
2198 | { | 2212 | if (part == null || part.ParentGroup.IsAttachment) |
2199 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2200 | if (part != null) | ||
2201 | { | ||
2202 | if (hitYN) | ||
2203 | { | ||
2204 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2205 | { | ||
2206 | SitRaycastFindEdge(collisionPoint, normal); | ||
2207 | m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2208 | } | ||
2209 | else | ||
2210 | { | ||
2211 | SitRayCastCameraPosition(part); | ||
2212 | } | ||
2213 | } | ||
2214 | else | ||
2215 | { | ||
2216 | SitRayCastCameraPosition(part); | ||
2217 | } | ||
2218 | } | ||
2219 | else | ||
2220 | { | 2213 | { |
2221 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2214 | return; |
2222 | m_requestedSitTargetUUID = UUID.Zero; | ||
2223 | m_requestedSitTargetID = 0; | ||
2224 | m_requestedSitOffset = Vector3.Zero; | ||
2225 | } | 2215 | } |
2226 | 2216 | ||
2227 | } | 2217 | // m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString()); |
2228 | 2218 | ||
2229 | public void SitRayCastCameraPosition(SceneObjectPart part) | 2219 | part.AddSittingAvatar(UUID); |
2230 | { | ||
2231 | // Next, try to raycast from the camera position | ||
2232 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2233 | Vector3 StartRayCastPosition = CameraPosition; | ||
2234 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2235 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2236 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); | ||
2237 | } | ||
2238 | 2220 | ||
2239 | public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2221 | Vector3 cameraAtOffset = part.GetCameraAtOffset(); |
2240 | { | 2222 | Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); |
2241 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2223 | bool forceMouselook = part.GetForceMouselook(); |
2242 | if (part != null) | ||
2243 | { | ||
2244 | if (hitYN) | ||
2245 | { | ||
2246 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2247 | { | ||
2248 | SitRaycastFindEdge(collisionPoint, normal); | ||
2249 | m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2250 | } | ||
2251 | else | ||
2252 | { | ||
2253 | SitRayHorizontal(part); | ||
2254 | } | ||
2255 | } | ||
2256 | else | ||
2257 | { | ||
2258 | SitRayHorizontal(part); | ||
2259 | } | ||
2260 | } | ||
2261 | else | ||
2262 | { | ||
2263 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2264 | m_requestedSitTargetUUID = UUID.Zero; | ||
2265 | m_requestedSitTargetID = 0; | ||
2266 | m_requestedSitOffset = Vector3.Zero; | ||
2267 | } | ||
2268 | 2224 | ||
2269 | } | 2225 | ControllingClient.SendSitResponse( |
2226 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2270 | 2227 | ||
2271 | public void SitRayHorizontal(SceneObjectPart part) | 2228 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
2272 | { | ||
2273 | // Next, try to raycast from the avatar position to fwd | ||
2274 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2275 | Vector3 StartRayCastPosition = CameraPosition; | ||
2276 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2277 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2278 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); | ||
2279 | } | ||
2280 | 2229 | ||
2281 | public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2230 | // assuming no autopilot in use |
2282 | { | 2231 | Velocity = Vector3.Zero; |
2283 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2232 | RemoveFromPhysicalScene(); |
2284 | if (part != null) | ||
2285 | { | ||
2286 | if (hitYN) | ||
2287 | { | ||
2288 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2289 | { | ||
2290 | SitRaycastFindEdge(collisionPoint, normal); | ||
2291 | m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2292 | // Next, try to raycast from the camera position | ||
2293 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2294 | Vector3 StartRayCastPosition = CameraPosition; | ||
2295 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2296 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2297 | //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); | ||
2298 | } | ||
2299 | else | ||
2300 | { | ||
2301 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2302 | m_requestedSitTargetUUID = UUID.Zero; | ||
2303 | m_requestedSitTargetID = 0; | ||
2304 | m_requestedSitOffset = Vector3.Zero; | ||
2305 | } | ||
2306 | } | ||
2307 | else | ||
2308 | { | ||
2309 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2310 | m_requestedSitTargetUUID = UUID.Zero; | ||
2311 | m_requestedSitTargetID = 0; | ||
2312 | m_requestedSitOffset = Vector3.Zero; | ||
2313 | } | ||
2314 | } | ||
2315 | else | ||
2316 | { | ||
2317 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2318 | m_requestedSitTargetUUID = UUID.Zero; | ||
2319 | m_requestedSitTargetID = 0; | ||
2320 | m_requestedSitOffset = Vector3.Zero; | ||
2321 | } | ||
2322 | 2233 | ||
2323 | } | 2234 | Rotation = Orientation; |
2235 | m_pos = offset; | ||
2324 | 2236 | ||
2325 | private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) | 2237 | m_requestedSitTargetID = 0; // invalidate the viewer sit comand for now |
2326 | { | 2238 | part.ParentGroup.AddAvatar(UUID); |
2327 | int i = 0; | ||
2328 | //throw new NotImplementedException(); | ||
2329 | //m_requestedSitTargetUUID = UUID.Zero; | ||
2330 | //m_requestedSitTargetID = 0; | ||
2331 | //m_requestedSitOffset = Vector3.Zero; | ||
2332 | 2239 | ||
2333 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); | 2240 | ParentPart = part; |
2241 | ParentID = part.LocalId; | ||
2242 | |||
2243 | Animator.TrySetMovementAnimation("SIT"); | ||
2244 | SendAvatarDataToAllAgents(); | ||
2334 | } | 2245 | } |
2335 | */ | 2246 | |
2336 | 2247 | ||
2337 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2248 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2338 | { | 2249 | { |
@@ -2531,9 +2442,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2531 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | 2442 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to |
2532 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | 2443 | // grab the latest PhysicsActor velocity, whereas m_velocity is often |
2533 | // storing a requested force instead of an actual traveling velocity | 2444 | // storing a requested force instead of an actual traveling velocity |
2445 | if (Appearance.AvatarSize != m_lastSize) | ||
2446 | { | ||
2447 | m_lastSize = Appearance.AvatarSize; | ||
2448 | SendAvatarDataToAllAgents(); | ||
2449 | } | ||
2534 | 2450 | ||
2535 | // Throw away duplicate or insignificant updates | 2451 | else if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2536 | if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || | ||
2537 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 2452 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2538 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) | 2453 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2539 | { | 2454 | { |
@@ -2831,6 +2746,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2831 | 2746 | ||
2832 | avatar.ControllingClient.SendAppearance( | 2747 | avatar.ControllingClient.SendAppearance( |
2833 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); | 2748 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); |
2749 | |||
2750 | |||
2834 | } | 2751 | } |
2835 | 2752 | ||
2836 | #endregion | 2753 | #endregion |
@@ -3403,15 +3320,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3403 | } | 3320 | } |
3404 | 3321 | ||
3405 | if (Appearance.AvatarHeight == 0) | 3322 | if (Appearance.AvatarHeight == 0) |
3406 | Appearance.SetHeight(); | 3323 | // Appearance.SetHeight(); |
3324 | Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
3407 | 3325 | ||
3408 | PhysicsScene scene = m_scene.PhysicsScene; | 3326 | PhysicsScene scene = m_scene.PhysicsScene; |
3409 | 3327 | ||
3410 | Vector3 pVec = AbsolutePosition; | 3328 | Vector3 pVec = AbsolutePosition; |
3411 | 3329 | ||
3330 | /* | ||
3331 | PhysicsActor = scene.AddAvatar( | ||
3332 | LocalId, Firstname + "." + Lastname, pVec, | ||
3333 | new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); | ||
3334 | */ | ||
3335 | |||
3412 | PhysicsActor = scene.AddAvatar( | 3336 | PhysicsActor = scene.AddAvatar( |
3413 | LocalId, Firstname + "." + Lastname, pVec, | 3337 | LocalId, Firstname + "." + Lastname, pVec, |
3414 | new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); | 3338 | Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); |
3415 | 3339 | ||
3416 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3340 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3417 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3341 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
@@ -3430,6 +3354,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3430 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); | 3354 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); |
3431 | } | 3355 | } |
3432 | 3356 | ||
3357 | |||
3433 | /// <summary> | 3358 | /// <summary> |
3434 | /// Event called by the physics plugin to tell the avatar about a collision. | 3359 | /// Event called by the physics plugin to tell the avatar about a collision. |
3435 | /// </summary> | 3360 | /// </summary> |
@@ -3459,7 +3384,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3459 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3384 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3460 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3385 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3461 | 3386 | ||
3462 | CollisionPlane = Vector4.UnitW; | ||
3463 | 3387 | ||
3464 | // // No collisions at all means we may be flying. Update always | 3388 | // // No collisions at all means we may be flying. Update always |
3465 | // // to make falling work | 3389 | // // to make falling work |
@@ -3471,6 +3395,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3471 | 3395 | ||
3472 | if (coldata.Count != 0) | 3396 | if (coldata.Count != 0) |
3473 | { | 3397 | { |
3398 | /* | ||
3474 | switch (Animator.CurrentMovementAnimation) | 3399 | switch (Animator.CurrentMovementAnimation) |
3475 | { | 3400 | { |
3476 | case "STAND": | 3401 | case "STAND": |
@@ -3479,24 +3404,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
3479 | case "CROUCH": | 3404 | case "CROUCH": |
3480 | case "CROUCHWALK": | 3405 | case "CROUCHWALK": |
3481 | { | 3406 | { |
3407 | */ | ||
3482 | ContactPoint lowest; | 3408 | ContactPoint lowest; |
3483 | lowest.SurfaceNormal = Vector3.Zero; | 3409 | lowest.SurfaceNormal = Vector3.Zero; |
3484 | lowest.Position = Vector3.Zero; | 3410 | lowest.Position = Vector3.Zero; |
3485 | lowest.Position.Z = Single.NaN; | 3411 | lowest.Position.Z = float.MaxValue; |
3486 | 3412 | ||
3487 | foreach (ContactPoint contact in coldata.Values) | 3413 | foreach (ContactPoint contact in coldata.Values) |
3488 | { | 3414 | { |
3489 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) | 3415 | |
3416 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | ||
3490 | { | 3417 | { |
3491 | lowest = contact; | 3418 | lowest = contact; |
3492 | } | 3419 | } |
3493 | } | 3420 | } |
3494 | 3421 | ||
3495 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | 3422 | if (lowest.Position.Z != float.MaxValue) |
3423 | { | ||
3424 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | ||
3425 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
3426 | } | ||
3427 | else | ||
3428 | CollisionPlane = Vector4.UnitW; | ||
3429 | /* | ||
3496 | } | 3430 | } |
3497 | break; | 3431 | break; |
3498 | } | 3432 | } |
3433 | */ | ||
3499 | } | 3434 | } |
3435 | else | ||
3436 | CollisionPlane = Vector4.UnitW; | ||
3500 | 3437 | ||
3501 | RaiseCollisionScriptEvents(coldata); | 3438 | RaiseCollisionScriptEvents(coldata); |
3502 | 3439 | ||
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index a31ccac..1b4ed1e 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs | |||
@@ -911,7 +911,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
911 | // Mimicking LLClientView which gets always set appearance from client. | 911 | // Mimicking LLClientView which gets always set appearance from client. |
912 | AvatarAppearance appearance; | 912 | AvatarAppearance appearance; |
913 | m_scene.GetAvatarAppearance(this, out appearance); | 913 | m_scene.GetAvatarAppearance(this, out appearance); |
914 | OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone()); | 914 | OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone(),appearance.AvatarSize); |
915 | } | 915 | } |
916 | 916 | ||
917 | public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) | 917 | public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) |
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs index c0d1355..c7e3a7a 100644 --- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs +++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs | |||
@@ -199,7 +199,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule | |||
199 | { | 199 | { |
200 | } | 200 | } |
201 | 201 | ||
202 | public bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, int amount) | 202 | public bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, int amount, UUID txn) |
203 | { | 203 | { |
204 | string description = String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID)); | 204 | string description = String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID)); |
205 | 205 | ||
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index be36be3..e2789d6 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -61,6 +61,7 @@ namespace OpenSim.Region.Physics.Manager | |||
61 | public Vector3 SurfaceNormal; | 61 | public Vector3 SurfaceNormal; |
62 | public float PenetrationDepth; | 62 | public float PenetrationDepth; |
63 | public float RelativeSpeed; | 63 | public float RelativeSpeed; |
64 | public bool CharacterFeet; | ||
64 | 65 | ||
65 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) | 66 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) |
66 | { | 67 | { |
@@ -68,6 +69,16 @@ namespace OpenSim.Region.Physics.Manager | |||
68 | SurfaceNormal = surfaceNormal; | 69 | SurfaceNormal = surfaceNormal; |
69 | PenetrationDepth = penetrationDepth; | 70 | PenetrationDepth = penetrationDepth; |
70 | RelativeSpeed = 0f; // for now let this one be set explicity | 71 | RelativeSpeed = 0f; // for now let this one be set explicity |
72 | CharacterFeet = true; // keep other plugins work as before | ||
73 | } | ||
74 | |||
75 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth, bool feet) | ||
76 | { | ||
77 | Position = position; | ||
78 | SurfaceNormal = surfaceNormal; | ||
79 | PenetrationDepth = penetrationDepth; | ||
80 | RelativeSpeed = 0f; // for now let this one be set explicity | ||
81 | CharacterFeet = feet; // keep other plugins work as before | ||
71 | } | 82 | } |
72 | } | 83 | } |
73 | 84 | ||
@@ -173,6 +184,11 @@ namespace OpenSim.Region.Physics.Manager | |||
173 | 184 | ||
174 | public abstract Vector3 Size { get; set; } | 185 | public abstract Vector3 Size { get; set; } |
175 | 186 | ||
187 | public virtual void setAvatarSize(Vector3 size, float feetOffset) | ||
188 | { | ||
189 | Size = size; | ||
190 | } | ||
191 | |||
176 | public virtual bool Phantom { get; set; } | 192 | public virtual bool Phantom { get; set; } |
177 | 193 | ||
178 | public virtual bool IsVolumeDtc | 194 | public virtual bool IsVolumeDtc |
@@ -398,6 +414,7 @@ namespace OpenSim.Region.Physics.Manager | |||
398 | // Warning in a parent part it returns itself, not null | 414 | // Warning in a parent part it returns itself, not null |
399 | public virtual PhysicsActor ParentActor { get { return this; } } | 415 | public virtual PhysicsActor ParentActor { get { return this; } } |
400 | 416 | ||
417 | |||
401 | } | 418 | } |
402 | 419 | ||
403 | public class NullPhysicsActor : PhysicsActor | 420 | public class NullPhysicsActor : PhysicsActor |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index ce269fa..a442cf0 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs | |||
@@ -38,6 +38,7 @@ namespace OpenSim.Region.Physics.Manager | |||
38 | 38 | ||
39 | public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal); | 39 | public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal); |
40 | public delegate void RayCallback(List<ContactResult> list); | 40 | public delegate void RayCallback(List<ContactResult> list); |
41 | public delegate void SitAvatarCallback(int status, uint partID, Vector3 offset, Quaternion Orientation); | ||
41 | 42 | ||
42 | public delegate void JointMoved(PhysicsJoint joint); | 43 | public delegate void JointMoved(PhysicsJoint joint); |
43 | public delegate void JointDeactivated(PhysicsJoint joint); | 44 | public delegate void JointDeactivated(PhysicsJoint joint); |
@@ -127,8 +128,10 @@ namespace OpenSim.Region.Physics.Manager | |||
127 | /// <param name="size"></param> | 128 | /// <param name="size"></param> |
128 | /// <param name="isFlying"></param> | 129 | /// <param name="isFlying"></param> |
129 | /// <returns></returns> | 130 | /// <returns></returns> |
130 | public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying); | 131 | public virtual PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) |
131 | 132 | { | |
133 | return null; | ||
134 | } | ||
132 | /// <summary> | 135 | /// <summary> |
133 | /// Add an avatar | 136 | /// Add an avatar |
134 | /// </summary> | 137 | /// </summary> |
@@ -145,6 +148,12 @@ namespace OpenSim.Region.Physics.Manager | |||
145 | return ret; | 148 | return ret; |
146 | } | 149 | } |
147 | 150 | ||
151 | public virtual PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying) | ||
152 | { | ||
153 | PhysicsActor ret = AddAvatar(localID, avName, position, size, isFlying); | ||
154 | return ret; | ||
155 | } | ||
156 | |||
148 | /// <summary> | 157 | /// <summary> |
149 | /// Remove an avatar. | 158 | /// Remove an avatar. |
150 | /// </summary> | 159 | /// </summary> |
@@ -349,5 +358,9 @@ namespace OpenSim.Region.Physics.Manager | |||
349 | return new List<ContactResult>(); | 358 | return new List<ContactResult>(); |
350 | } | 359 | } |
351 | 360 | ||
361 | public virtual int SitAvatar(PhysicsActor actor, Vector3 AbsolutePosition, Vector3 CameraPosition, Vector3 offset, Vector3 AvatarSize, SitAvatarCallback PhysicsSitResponse) | ||
362 | { | ||
363 | return 0; | ||
364 | } | ||
352 | } | 365 | } |
353 | } | 366 | } |
diff --git a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs index 1e9b8bc..b67422f 100644 --- a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs +++ b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs | |||
@@ -205,12 +205,35 @@ namespace OpenSim.Region.Physics.Meshing | |||
205 | 205 | ||
206 | } | 206 | } |
207 | 207 | ||
208 | private float fRound(float f) | ||
209 | { | ||
210 | int i; | ||
211 | if (f == 0f) | ||
212 | return f; | ||
213 | else if (f > 0f) | ||
214 | i = (int)(1e5f * f + 0.5f); | ||
215 | else | ||
216 | i = (int)(1e5f * f - 0.5f); | ||
217 | |||
218 | return ((float)i * 1e-5f); | ||
219 | } | ||
208 | 220 | ||
209 | public void Add(Triangle triangle) | 221 | public void Add(Triangle triangle) |
210 | { | 222 | { |
211 | if (m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero) | 223 | if (m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero) |
212 | throw new NotSupportedException("Attempt to Add to a pinned Mesh"); | 224 | throw new NotSupportedException("Attempt to Add to a pinned Mesh"); |
213 | 225 | ||
226 | // round down | ||
227 | triangle.v1.X = fRound(triangle.v1.X); | ||
228 | triangle.v1.Y = fRound(triangle.v1.Y); | ||
229 | triangle.v1.Z = fRound(triangle.v1.Z); | ||
230 | triangle.v2.X = fRound(triangle.v2.X); | ||
231 | triangle.v2.Y = fRound(triangle.v2.Y); | ||
232 | triangle.v2.Z = fRound(triangle.v2.Z); | ||
233 | triangle.v3.X = fRound(triangle.v3.X); | ||
234 | triangle.v3.Y = fRound(triangle.v3.Y); | ||
235 | triangle.v3.Z = fRound(triangle.v3.Z); | ||
236 | |||
214 | if ((triangle.v1.X == triangle.v2.X && triangle.v1.Y == triangle.v2.Y && triangle.v1.Z == triangle.v2.Z) | 237 | if ((triangle.v1.X == triangle.v2.X && triangle.v1.Y == triangle.v2.Y && triangle.v1.Z == triangle.v2.Z) |
215 | || (triangle.v1.X == triangle.v3.X && triangle.v1.Y == triangle.v3.Y && triangle.v1.Z == triangle.v3.Z) | 238 | || (triangle.v1.X == triangle.v3.X && triangle.v1.Y == triangle.v3.Y && triangle.v1.Z == triangle.v3.Z) |
216 | || (triangle.v2.X == triangle.v3.X && triangle.v2.Y == triangle.v3.Y && triangle.v2.Z == triangle.v3.Z) | 239 | || (triangle.v2.X == triangle.v3.X && triangle.v2.Y == triangle.v3.Y && triangle.v2.Z == triangle.v3.Z) |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index f5bf05d..bb04ea7 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | |||
@@ -74,19 +74,32 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
74 | 74 | ||
75 | private Vector3 _position; | 75 | private Vector3 _position; |
76 | private Vector3 _zeroPosition; | 76 | private Vector3 _zeroPosition; |
77 | private bool _zeroFlag = false; | ||
78 | private Vector3 _velocity; | 77 | private Vector3 _velocity; |
79 | private Vector3 _target_velocity; | 78 | private Vector3 _target_velocity; |
80 | private Vector3 _acceleration; | 79 | private Vector3 _acceleration; |
81 | private Vector3 m_rotationalVelocity; | 80 | private Vector3 m_rotationalVelocity; |
81 | private Vector3 m_size; | ||
82 | private Quaternion m_orientation; | ||
83 | private Quaternion m_orientation2D; | ||
82 | private float m_mass = 80f; | 84 | private float m_mass = 80f; |
83 | public float m_density = 60f; | 85 | public float m_density = 60f; |
84 | private bool m_pidControllerActive = true; | 86 | private bool m_pidControllerActive = true; |
85 | public float PID_D = 800.0f; | 87 | |
86 | public float PID_P = 900.0f; | 88 | const float basePID_D = 0.55f; // scaled for unit mass unit time (2200 /(50*80)) |
87 | //private static float POSTURE_SERVO = 10000.0f; | 89 | const float basePID_P = 0.225f; // scaled for unit mass unit time (900 /(50*80)) |
88 | public float CAPSULE_RADIUS = 0.37f; | 90 | public float PID_D; |
89 | public float CAPSULE_LENGTH = 2.140599f; | 91 | public float PID_P; |
92 | |||
93 | private float timeStep; | ||
94 | private float invtimeStep; | ||
95 | |||
96 | private float m_feetOffset = 0; | ||
97 | private float feetOff = 0; | ||
98 | private float feetSZ = 0.5f; | ||
99 | const float feetScale = 0.8f; | ||
100 | private float boneOff = 0; | ||
101 | private float m_lastVelocitySqr = 0; | ||
102 | |||
90 | public float walkDivisor = 1.3f; | 103 | public float walkDivisor = 1.3f; |
91 | public float runDivisor = 0.8f; | 104 | public float runDivisor = 0.8f; |
92 | private bool flying = false; | 105 | private bool flying = false; |
@@ -94,6 +107,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
94 | private bool m_iscollidingGround = false; | 107 | private bool m_iscollidingGround = false; |
95 | private bool m_iscollidingObj = false; | 108 | private bool m_iscollidingObj = false; |
96 | private bool m_alwaysRun = false; | 109 | private bool m_alwaysRun = false; |
110 | |||
111 | private bool _zeroFlag = false; | ||
112 | |||
97 | private int m_requestedUpdateFrequency = 0; | 113 | private int m_requestedUpdateFrequency = 0; |
98 | private uint m_localID = 0; | 114 | private uint m_localID = 0; |
99 | public bool m_returnCollisions = false; | 115 | public bool m_returnCollisions = false; |
@@ -111,6 +127,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
111 | int m_colliderfilter = 0; | 127 | int m_colliderfilter = 0; |
112 | int m_colliderGroundfilter = 0; | 128 | int m_colliderGroundfilter = 0; |
113 | int m_colliderObjectfilter = 0; | 129 | int m_colliderObjectfilter = 0; |
130 | bool m_collisionException = false; | ||
114 | 131 | ||
115 | // Default we're a Character | 132 | // Default we're a Character |
116 | private CollisionCategories m_collisionCategories = (CollisionCategories.Character); | 133 | private CollisionCategories m_collisionCategories = (CollisionCategories.Character); |
@@ -123,10 +140,18 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
123 | // we do land collisions not ode | CollisionCategories.Land); | 140 | // we do land collisions not ode | CollisionCategories.Land); |
124 | public IntPtr Body = IntPtr.Zero; | 141 | public IntPtr Body = IntPtr.Zero; |
125 | private OdeScene _parent_scene; | 142 | private OdeScene _parent_scene; |
126 | public IntPtr Shell = IntPtr.Zero; | 143 | private IntPtr topbox = IntPtr.Zero; |
144 | private IntPtr midbox = IntPtr.Zero; | ||
145 | private IntPtr feetbox = IntPtr.Zero; | ||
146 | private IntPtr bbox = IntPtr.Zero; | ||
147 | public IntPtr collider = IntPtr.Zero; | ||
148 | |||
127 | public IntPtr Amotor = IntPtr.Zero; | 149 | public IntPtr Amotor = IntPtr.Zero; |
150 | |||
128 | public d.Mass ShellMass; | 151 | public d.Mass ShellMass; |
129 | // public bool collidelock = false; | 152 | |
153 | |||
154 | |||
130 | 155 | ||
131 | public int m_eventsubscription = 0; | 156 | public int m_eventsubscription = 0; |
132 | private int m_cureventsubscription = 0; | 157 | private int m_cureventsubscription = 0; |
@@ -139,9 +164,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
139 | 164 | ||
140 | float mu; | 165 | float mu; |
141 | 166 | ||
142 | public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float density, float walk_divisor, float rundivisor) | 167 | |
168 | |||
169 | public OdeCharacter(uint localID, String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor) | ||
143 | { | 170 | { |
144 | m_uuid = UUID.Random(); | 171 | m_uuid = UUID.Random(); |
172 | m_localID = localID; | ||
173 | |||
174 | timeStep = parent_scene.ODE_STEPSIZE; | ||
175 | invtimeStep = 1 / timeStep; | ||
145 | 176 | ||
146 | if (pos.IsFinite()) | 177 | if (pos.IsFinite()) |
147 | { | 178 | { |
@@ -163,22 +194,37 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
163 | 194 | ||
164 | _parent_scene = parent_scene; | 195 | _parent_scene = parent_scene; |
165 | 196 | ||
166 | PID_D = pid_d; | 197 | |
167 | PID_P = pid_p; | 198 | m_size.X = pSize.X; |
168 | CAPSULE_RADIUS = capsule_radius; | 199 | m_size.Y = pSize.Y; |
200 | m_size.Z = pSize.Z; | ||
201 | |||
202 | if(m_size.X <0.01f) | ||
203 | m_size.X = 0.01f; | ||
204 | if(m_size.Y <0.01f) | ||
205 | m_size.Y = 0.01f; | ||
206 | if(m_size.Z <0.01f) | ||
207 | m_size.Z = 0.01f; | ||
208 | |||
209 | m_feetOffset = pfeetOffset; | ||
210 | m_orientation = Quaternion.Identity; | ||
211 | m_orientation2D = Quaternion.Identity; | ||
169 | m_density = density; | 212 | m_density = density; |
170 | m_mass = 80f; // sure we have a default | ||
171 | 213 | ||
172 | // force lower density for testing | 214 | // force lower density for testing |
173 | m_density = 3.0f; | 215 | m_density = 3.0f; |
174 | 216 | ||
217 | m_density *= 1.4f; // scale to have mass similar to capsule | ||
218 | |||
175 | mu = parent_scene.AvatarFriction; | 219 | mu = parent_scene.AvatarFriction; |
176 | 220 | ||
177 | walkDivisor = walk_divisor; | 221 | walkDivisor = walk_divisor; |
178 | runDivisor = rundivisor; | 222 | runDivisor = rundivisor; |
179 | 223 | ||
180 | CAPSULE_LENGTH = size.Z * 1.15f - CAPSULE_RADIUS * 2.0f; | 224 | m_mass = m_density * m_size.X * m_size.Y * m_size.Z; ; // sure we have a default |
181 | //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); | 225 | |
226 | PID_D = basePID_D * m_mass * invtimeStep; | ||
227 | PID_P = basePID_P * m_mass * invtimeStep; | ||
182 | 228 | ||
183 | m_isPhysical = false; // current status: no ODE information exists | 229 | m_isPhysical = false; // current status: no ODE information exists |
184 | 230 | ||
@@ -261,7 +307,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
261 | set | 307 | set |
262 | { | 308 | { |
263 | flying = value; | 309 | flying = value; |
264 | // m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying); | 310 | // m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying); |
265 | } | 311 | } |
266 | } | 312 | } |
267 | 313 | ||
@@ -305,25 +351,25 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
305 | get { return m_iscollidingGround; } | 351 | get { return m_iscollidingGround; } |
306 | set | 352 | set |
307 | { | 353 | { |
308 | /* we now control this | 354 | /* we now control this |
309 | if (value) | 355 | if (value) |
310 | { | 356 | { |
311 | m_colliderGroundfilter += 2; | 357 | m_colliderGroundfilter += 2; |
312 | if (m_colliderGroundfilter > 2) | 358 | if (m_colliderGroundfilter > 2) |
313 | m_colliderGroundfilter = 2; | 359 | m_colliderGroundfilter = 2; |
314 | } | 360 | } |
315 | else | 361 | else |
316 | { | 362 | { |
317 | m_colliderGroundfilter--; | 363 | m_colliderGroundfilter--; |
318 | if (m_colliderGroundfilter < 0) | 364 | if (m_colliderGroundfilter < 0) |
319 | m_colliderGroundfilter = 0; | 365 | m_colliderGroundfilter = 0; |
320 | } | 366 | } |
321 | 367 | ||
322 | if (m_colliderGroundfilter == 0) | 368 | if (m_colliderGroundfilter == 0) |
323 | m_iscollidingGround = false; | 369 | m_iscollidingGround = false; |
324 | else | 370 | else |
325 | m_iscollidingGround = true; | 371 | m_iscollidingGround = true; |
326 | */ | 372 | */ |
327 | } | 373 | } |
328 | 374 | ||
329 | } | 375 | } |
@@ -355,7 +401,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
355 | else | 401 | else |
356 | m_iscollidingObj = true; | 402 | m_iscollidingObj = true; |
357 | 403 | ||
358 | // m_iscollidingObj = value; | 404 | // m_iscollidingObj = value; |
359 | 405 | ||
360 | if (m_iscollidingObj) | 406 | if (m_iscollidingObj) |
361 | m_pidControllerActive = false; | 407 | m_pidControllerActive = false; |
@@ -420,13 +466,21 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
420 | /// </summary> | 466 | /// </summary> |
421 | public override Vector3 Size | 467 | public override Vector3 Size |
422 | { | 468 | { |
423 | get { | 469 | get |
424 | float d = CAPSULE_RADIUS * 2; | 470 | { |
425 | return new Vector3(d, d, (CAPSULE_LENGTH +d)/1.15f); } | 471 | return m_size; |
472 | } | ||
426 | set | 473 | set |
427 | { | 474 | { |
428 | if (value.IsFinite()) | 475 | if (value.IsFinite()) |
429 | { | 476 | { |
477 | if(value.X <0.01f) | ||
478 | value.X = 0.01f; | ||
479 | if(value.Y <0.01f) | ||
480 | value.Y = 0.01f; | ||
481 | if(value.Z <0.01f) | ||
482 | value.Z = 0.01f; | ||
483 | |||
430 | AddChange(changes.Size, value); | 484 | AddChange(changes.Size, value); |
431 | } | 485 | } |
432 | else | 486 | else |
@@ -436,6 +490,28 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
436 | } | 490 | } |
437 | } | 491 | } |
438 | 492 | ||
493 | public override void setAvatarSize(Vector3 size, float feetOffset) | ||
494 | { | ||
495 | if (size.IsFinite()) | ||
496 | { | ||
497 | if (size.X < 0.01f) | ||
498 | size.X = 0.01f; | ||
499 | if (size.Y < 0.01f) | ||
500 | size.Y = 0.01f; | ||
501 | if (size.Z < 0.01f) | ||
502 | size.Z = 0.01f; | ||
503 | |||
504 | strAvatarSize st = new strAvatarSize(); | ||
505 | st.size = size; | ||
506 | st.offset = feetOffset; | ||
507 | AddChange(changes.AvatarSize, st); | ||
508 | } | ||
509 | else | ||
510 | { | ||
511 | m_log.Warn("[PHYSICS]: Got a NaN AvatarSize from Scene on a Character"); | ||
512 | } | ||
513 | |||
514 | } | ||
439 | /// <summary> | 515 | /// <summary> |
440 | /// This creates the Avatar's physical Surrogate at the position supplied | 516 | /// This creates the Avatar's physical Surrogate at the position supplied |
441 | /// </summary> | 517 | /// </summary> |
@@ -452,8 +528,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
452 | { | 528 | { |
453 | get | 529 | get |
454 | { | 530 | { |
455 | float AVvolume = (float)(Math.PI * CAPSULE_RADIUS * CAPSULE_RADIUS * (1.3333333333f * CAPSULE_RADIUS + CAPSULE_LENGTH)); | 531 | return m_mass; |
456 | return m_density * AVvolume; | ||
457 | } | 532 | } |
458 | } | 533 | } |
459 | public override void link(PhysicsActor obj) | 534 | public override void link(PhysicsActor obj) |
@@ -571,9 +646,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
571 | 646 | ||
572 | public override Quaternion Orientation | 647 | public override Quaternion Orientation |
573 | { | 648 | { |
574 | get { return Quaternion.Identity; } | 649 | get { return m_orientation; } |
575 | set | 650 | set |
576 | { | 651 | { |
652 | // fakeori = value; | ||
653 | // givefakeori++; | ||
654 | value.Normalize(); | ||
655 | AddChange(changes.Orientation, value); | ||
577 | } | 656 | } |
578 | } | 657 | } |
579 | 658 | ||
@@ -625,54 +704,116 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
625 | AddChange(changes.Momentum, momentum); | 704 | AddChange(changes.Momentum, momentum); |
626 | } | 705 | } |
627 | 706 | ||
707 | private void ajustCollider() | ||
708 | { | ||
709 | float vq = _velocity.LengthSquared(); | ||
710 | if (m_lastVelocitySqr != vq) | ||
711 | { | ||
712 | m_lastVelocitySqr = vq; | ||
713 | if (vq > 100.0f) | ||
714 | { | ||
715 | Vector3 off = _velocity; | ||
716 | float t = 0.5f * timeStep; | ||
717 | off = off * t; | ||
718 | d.GeomSetOffsetPosition(bbox, off.X, off.Y, off.Z); | ||
719 | off.X = 2.0f * (m_size.X + Math.Abs(off.X)); | ||
720 | off.Y = 2.0f * (m_size.Y + Math.Abs(off.Y)); | ||
721 | off.Z = m_size.Z + 2.0f * Math.Abs(off.Z); | ||
722 | d.GeomBoxSetLengths(bbox, off.X, off.Y, off.Z); | ||
723 | |||
724 | d.GeomSetCategoryBits(bbox, (uint)m_collisionCategories); | ||
725 | d.GeomSetCollideBits(bbox, (uint)m_collisionFlags); | ||
726 | d.GeomSetCategoryBits(topbox, 0); | ||
727 | d.GeomSetCollideBits(topbox, 0); | ||
728 | d.GeomSetCategoryBits(midbox, 0); | ||
729 | d.GeomSetCollideBits(midbox, 0); | ||
730 | d.GeomSetCategoryBits(feetbox, 0); | ||
731 | d.GeomSetCollideBits(feetbox, 0); | ||
732 | } | ||
733 | else | ||
734 | { | ||
735 | d.GeomSetCategoryBits(bbox, 0); | ||
736 | d.GeomSetCollideBits(bbox, 0); | ||
737 | d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories); | ||
738 | d.GeomSetCollideBits(topbox, (uint)m_collisionFlags); | ||
739 | d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories); | ||
740 | d.GeomSetCollideBits(midbox, (uint)m_collisionFlags); | ||
741 | d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories); | ||
742 | d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags); | ||
743 | } | ||
744 | } | ||
745 | } | ||
628 | 746 | ||
629 | // WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access | ||
630 | // to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only | ||
631 | // place that is safe to call this routine AvatarGeomAndBodyCreation. | ||
632 | private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ) | 747 | private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ) |
633 | { | 748 | { |
634 | _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); | 749 | // sizes one day should came from visual parameters |
635 | if (CAPSULE_LENGTH <= 0) | 750 | float sx = m_size.X; |
636 | { | 751 | float sy = m_size.Y; |
637 | m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!"); | 752 | float sz = m_size.Z; |
638 | CAPSULE_LENGTH = 0.01f; | ||
639 | 753 | ||
640 | } | 754 | float topsx = sx * 0.9f; |
755 | float midsx = sx; | ||
756 | float feetsx = sx * feetScale; | ||
757 | float bonesx = sx * 0.2f; | ||
641 | 758 | ||
642 | if (CAPSULE_RADIUS <= 0) | 759 | float topsy = sy * 0.4f; |
643 | { | 760 | float midsy = sy; |
644 | m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!"); | 761 | float feetsy = sy * feetScale * 0.8f; |
645 | CAPSULE_RADIUS = 0.01f; | 762 | float bonesy = feetsy * 0.2f; |
646 | 763 | ||
647 | } | 764 | float topsz = sz * 0.15f; |
648 | Shell = d.CreateCapsule(_parent_scene.ActiveSpace, CAPSULE_RADIUS, CAPSULE_LENGTH); | 765 | float feetsz = sz * 0.45f; |
766 | if (feetsz > 0.6f) | ||
767 | feetsz = 0.6f; | ||
768 | |||
769 | float midsz = sz - topsz - feetsz; | ||
770 | float bonesz = sz; | ||
771 | |||
772 | float bot = -sz * 0.5f + m_feetOffset; | ||
773 | |||
774 | boneOff = bot + 0.3f; | ||
775 | |||
776 | float feetz = bot + feetsz * 0.5f; | ||
777 | bot += feetsz; | ||
649 | 778 | ||
650 | d.GeomSetCategoryBits(Shell, (uint)m_collisionCategories); | 779 | feetOff = bot; |
651 | d.GeomSetCollideBits(Shell, (uint)m_collisionFlags); | 780 | feetSZ = feetsz; |
652 | 781 | ||
653 | d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH); | 782 | float midz = bot + midsz * 0.5f; |
783 | bot += midsz; | ||
784 | float topz = bot + topsz * 0.5f; | ||
654 | 785 | ||
655 | m_mass = ShellMass.mass; // update mass | 786 | _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); |
656 | 787 | ||
657 | // rescale PID parameters | 788 | collider = d.HashSpaceCreate(_parent_scene.CharsSpace); |
658 | PID_D = _parent_scene.avPIDD; | 789 | d.HashSpaceSetLevels(collider, -4, 3); |
659 | PID_P = _parent_scene.avPIDP; | 790 | d.SpaceSetSublevel(collider, 3); |
791 | d.SpaceSetCleanup(collider, false); | ||
792 | d.GeomSetCategoryBits(collider, (uint)m_collisionCategories); | ||
793 | d.GeomSetCollideBits(collider, (uint)m_collisionFlags); | ||
660 | 794 | ||
661 | // rescale PID parameters so that this aren't affected by mass | 795 | feetbox = d.CreateBox(collider, feetsx, feetsy, feetsz); |
662 | // and so don't get unstable for some masses | 796 | midbox = d.CreateBox(collider, midsx, midsy, midsz); |
663 | // also scale by ode time step so you don't need to refix them | 797 | topbox = d.CreateBox(collider, topsx, topsy, topsz); |
798 | bbox = d.CreateBox(collider, m_size.X, m_size.Y, m_size.Z); | ||
664 | 799 | ||
665 | PID_D /= 50 * 80; //scale to original mass of around 80 and 50 ODE fps | 800 | m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass |
666 | PID_D *= m_mass / _parent_scene.ODE_STEPSIZE; | 801 | |
667 | PID_P /= 50 * 80; | 802 | d.MassSetBoxTotal(out ShellMass, m_mass, m_size.X, m_size.Y, m_size.Z); |
668 | PID_P *= m_mass / _parent_scene.ODE_STEPSIZE; | 803 | |
804 | PID_D = basePID_D * m_mass / _parent_scene.ODE_STEPSIZE; | ||
805 | PID_P = basePID_P * m_mass / _parent_scene.ODE_STEPSIZE; | ||
669 | 806 | ||
670 | Body = d.BodyCreate(_parent_scene.world); | 807 | Body = d.BodyCreate(_parent_scene.world); |
671 | 808 | ||
672 | _zeroFlag = false; | 809 | _zeroFlag = false; |
810 | m_collisionException = false; | ||
673 | m_pidControllerActive = true; | 811 | m_pidControllerActive = true; |
674 | m_freemove = false; | 812 | m_freemove = false; |
675 | 813 | ||
814 | _velocity = Vector3.Zero; | ||
815 | m_lastVelocitySqr = 0; | ||
816 | |||
676 | d.BodySetAutoDisableFlag(Body, false); | 817 | d.BodySetAutoDisableFlag(Body, false); |
677 | d.BodySetPosition(Body, npositionX, npositionY, npositionZ); | 818 | d.BodySetPosition(Body, npositionX, npositionY, npositionZ); |
678 | 819 | ||
@@ -681,7 +822,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
681 | _position.Z = npositionZ; | 822 | _position.Z = npositionZ; |
682 | 823 | ||
683 | d.BodySetMass(Body, ref ShellMass); | 824 | d.BodySetMass(Body, ref ShellMass); |
684 | d.GeomSetBody(Shell, Body); | 825 | d.GeomSetBody(feetbox, Body); |
826 | d.GeomSetBody(midbox, Body); | ||
827 | d.GeomSetBody(topbox, Body); | ||
828 | d.GeomSetBody(bbox, Body); | ||
829 | |||
830 | d.GeomSetOffsetPosition(feetbox, 0, 0, feetz); | ||
831 | d.GeomSetOffsetPosition(midbox, 0, 0, midz); | ||
832 | d.GeomSetOffsetPosition(topbox, 0, 0, topz); | ||
833 | |||
834 | ajustCollider(); | ||
835 | |||
685 | 836 | ||
686 | // The purpose of the AMotor here is to keep the avatar's physical | 837 | // The purpose of the AMotor here is to keep the avatar's physical |
687 | // surrogate from rotating while moving | 838 | // surrogate from rotating while moving |
@@ -741,15 +892,222 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
741 | Body = IntPtr.Zero; | 892 | Body = IntPtr.Zero; |
742 | } | 893 | } |
743 | 894 | ||
744 | //kill the Geometry | 895 | //kill the Geoms |
745 | if (Shell != IntPtr.Zero) | 896 | if (topbox != IntPtr.Zero) |
746 | { | 897 | { |
747 | // _parent_scene.geom_name_map.Remove(Shell); | 898 | _parent_scene.actor_name_map.Remove(topbox); |
748 | _parent_scene.actor_name_map.Remove(Shell); | 899 | _parent_scene.waitForSpaceUnlock(collider); |
749 | _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); | 900 | d.GeomDestroy(topbox); |
750 | d.GeomDestroy(Shell); | 901 | topbox = IntPtr.Zero; |
751 | Shell = IntPtr.Zero; | ||
752 | } | 902 | } |
903 | if (midbox != IntPtr.Zero) | ||
904 | { | ||
905 | _parent_scene.actor_name_map.Remove(midbox); | ||
906 | _parent_scene.waitForSpaceUnlock(collider); | ||
907 | d.GeomDestroy(midbox); | ||
908 | midbox = IntPtr.Zero; | ||
909 | } | ||
910 | if (feetbox != IntPtr.Zero) | ||
911 | { | ||
912 | _parent_scene.actor_name_map.Remove(feetbox); | ||
913 | _parent_scene.waitForSpaceUnlock(collider); | ||
914 | d.GeomDestroy(feetbox); | ||
915 | feetbox = IntPtr.Zero; | ||
916 | } | ||
917 | |||
918 | if (bbox != IntPtr.Zero) | ||
919 | { | ||
920 | _parent_scene.actor_name_map.Remove(bbox); | ||
921 | _parent_scene.waitForSpaceUnlock(collider); | ||
922 | d.GeomDestroy(bbox); | ||
923 | bbox = IntPtr.Zero; | ||
924 | } | ||
925 | |||
926 | if (collider != IntPtr.Zero) | ||
927 | { | ||
928 | d.SpaceDestroy(collider); | ||
929 | collider = IntPtr.Zero; | ||
930 | } | ||
931 | |||
932 | } | ||
933 | |||
934 | //in place 2D rotation around Z assuming rot is normalised and is a rotation around Z | ||
935 | public void RotateXYonZ(ref float x, ref float y, ref Quaternion rot) | ||
936 | { | ||
937 | float sin = 2.0f * rot.Z * rot.W; | ||
938 | float cos = rot.W * rot.W - rot.Z * rot.Z; | ||
939 | float tx = x; | ||
940 | |||
941 | x = tx * cos - y * sin; | ||
942 | y = tx * sin + y * cos; | ||
943 | } | ||
944 | public void RotateXYonZ(ref float x, ref float y, ref float sin, ref float cos) | ||
945 | { | ||
946 | float tx = x; | ||
947 | x = tx * cos - y * sin; | ||
948 | y = tx * sin + y * cos; | ||
949 | } | ||
950 | public void invRotateXYonZ(ref float x, ref float y, ref float sin, ref float cos) | ||
951 | { | ||
952 | float tx = x; | ||
953 | x = tx * cos + y * sin; | ||
954 | y = -tx * sin + y * cos; | ||
955 | } | ||
956 | |||
957 | public void invRotateXYonZ(ref float x, ref float y, ref Quaternion rot) | ||
958 | { | ||
959 | float sin = - 2.0f * rot.Z * rot.W; | ||
960 | float cos = rot.W * rot.W - rot.Z * rot.Z; | ||
961 | float tx = x; | ||
962 | |||
963 | x = tx * cos - y * sin; | ||
964 | y = tx * sin + y * cos; | ||
965 | } | ||
966 | |||
967 | |||
968 | public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact, ref bool feetcollision) | ||
969 | { | ||
970 | feetcollision = false; | ||
971 | if (m_collisionException) | ||
972 | return false; | ||
973 | |||
974 | Vector3 offset; | ||
975 | |||
976 | if (me == bbox) // if moving fast | ||
977 | { | ||
978 | // force a full inelastic collision | ||
979 | m_collisionException = true; | ||
980 | |||
981 | offset = m_size * m_orientation2D; | ||
982 | |||
983 | offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth; | ||
984 | offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth; | ||
985 | offset.Z = (float)Math.Abs(offset.Z) * 0.5f + contact.depth; | ||
986 | |||
987 | if (reverse) | ||
988 | { | ||
989 | offset.X *= -contact.normal.X; | ||
990 | offset.Y *= -contact.normal.Y; | ||
991 | offset.Z *= -contact.normal.Z; | ||
992 | } | ||
993 | else | ||
994 | { | ||
995 | offset.X *= contact.normal.X; | ||
996 | offset.Y *= contact.normal.Y; | ||
997 | offset.Z *= contact.normal.Z; | ||
998 | } | ||
999 | |||
1000 | offset.X += contact.pos.X; | ||
1001 | offset.Y += contact.pos.Y; | ||
1002 | offset.Z += contact.pos.Z; | ||
1003 | |||
1004 | _position = offset; | ||
1005 | return false; | ||
1006 | } | ||
1007 | |||
1008 | offset.X = contact.pos.X - _position.X; | ||
1009 | offset.Y = contact.pos.Y - _position.Y; | ||
1010 | |||
1011 | if (me == topbox) | ||
1012 | { | ||
1013 | offset.Z = contact.pos.Z - _position.Z; | ||
1014 | |||
1015 | offset.Normalize(); | ||
1016 | |||
1017 | if (reverse) | ||
1018 | { | ||
1019 | contact.normal.X = offset.X; | ||
1020 | contact.normal.Y = offset.Y; | ||
1021 | contact.normal.Z = offset.Z; | ||
1022 | } | ||
1023 | else | ||
1024 | { | ||
1025 | contact.normal.X = -offset.X; | ||
1026 | contact.normal.Y = -offset.Y; | ||
1027 | contact.normal.Z = -offset.Z; | ||
1028 | } | ||
1029 | return true; | ||
1030 | } | ||
1031 | |||
1032 | if (me == midbox) | ||
1033 | { | ||
1034 | if (Math.Abs(contact.normal.Z) > 0.95f) | ||
1035 | offset.Z = contact.pos.Z - _position.Z; | ||
1036 | else | ||
1037 | offset.Z = contact.normal.Z; | ||
1038 | |||
1039 | offset.Normalize(); | ||
1040 | |||
1041 | if (reverse) | ||
1042 | { | ||
1043 | contact.normal.X = offset.X; | ||
1044 | contact.normal.Y = offset.Y; | ||
1045 | contact.normal.Z = offset.Z; | ||
1046 | } | ||
1047 | else | ||
1048 | { | ||
1049 | contact.normal.X = -offset.X; | ||
1050 | contact.normal.Y = -offset.Y; | ||
1051 | contact.normal.Z = -offset.Z; | ||
1052 | } | ||
1053 | |||
1054 | return true; | ||
1055 | } | ||
1056 | |||
1057 | else if (me == feetbox) | ||
1058 | { | ||
1059 | float h = contact.pos.Z - _position.Z; | ||
1060 | |||
1061 | if (Math.Abs(contact.normal.Z) > 0.95f) | ||
1062 | { | ||
1063 | if (contact.normal.Z > 0) | ||
1064 | contact.normal.Z = 1.0f; | ||
1065 | else | ||
1066 | contact.normal.Z = -1.0f; | ||
1067 | contact.normal.X = 0.0f; | ||
1068 | contact.normal.Y = 0.0f; | ||
1069 | feetcollision = true; | ||
1070 | if (h < boneOff) | ||
1071 | IsColliding = true; | ||
1072 | return true; | ||
1073 | } | ||
1074 | |||
1075 | offset.Z = h - feetOff; // distance from top of feetbox | ||
1076 | |||
1077 | if (offset.Z > 0) | ||
1078 | return false; | ||
1079 | |||
1080 | if (offset.Z > -0.01) | ||
1081 | { | ||
1082 | offset.X = 0; | ||
1083 | offset.Y = 0; | ||
1084 | offset.Z = -1.0f; | ||
1085 | } | ||
1086 | else | ||
1087 | { | ||
1088 | offset.Normalize(); | ||
1089 | } | ||
1090 | |||
1091 | if (reverse) | ||
1092 | { | ||
1093 | contact.normal.X = offset.X; | ||
1094 | contact.normal.Y = offset.Y; | ||
1095 | contact.normal.Z = offset.Z; | ||
1096 | } | ||
1097 | else | ||
1098 | { | ||
1099 | contact.normal.X = -offset.X; | ||
1100 | contact.normal.Y = -offset.Y; | ||
1101 | contact.normal.Z = -offset.Z; | ||
1102 | } | ||
1103 | feetcollision = true; | ||
1104 | if (h < boneOff) | ||
1105 | IsColliding = true; | ||
1106 | } | ||
1107 | else | ||
1108 | return false; | ||
1109 | |||
1110 | return true; | ||
753 | } | 1111 | } |
754 | 1112 | ||
755 | /// <summary> | 1113 | /// <summary> |
@@ -757,11 +1115,28 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
757 | /// This is the avatar's movement control + PID Controller | 1115 | /// This is the avatar's movement control + PID Controller |
758 | /// </summary> | 1116 | /// </summary> |
759 | /// <param name="timeStep"></param> | 1117 | /// <param name="timeStep"></param> |
760 | public void Move(float timeStep, List<OdeCharacter> defects) | 1118 | public void Move(List<OdeCharacter> defects) |
761 | { | 1119 | { |
762 | if (Body == IntPtr.Zero) | 1120 | if (Body == IntPtr.Zero) |
763 | return; | 1121 | return; |
764 | 1122 | ||
1123 | if (m_collisionException) | ||
1124 | { | ||
1125 | d.BodySetPosition(Body,_position.X, _position.Y, _position.Z); | ||
1126 | d.BodySetLinearVel(Body, 0, 0, 0); | ||
1127 | |||
1128 | float v = _velocity.Length(); | ||
1129 | if (v != 0) | ||
1130 | { | ||
1131 | v = 5.0f / v; | ||
1132 | _velocity = _velocity * v; | ||
1133 | d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); | ||
1134 | } | ||
1135 | ajustCollider(); | ||
1136 | m_collisionException = false; | ||
1137 | return; | ||
1138 | } | ||
1139 | |||
765 | d.Vector3 dtmp = d.BodyGetPosition(Body); | 1140 | d.Vector3 dtmp = d.BodyGetPosition(Body); |
766 | Vector3 localpos = new Vector3(dtmp.X, dtmp.Y, dtmp.Z); | 1141 | Vector3 localpos = new Vector3(dtmp.X, dtmp.Y, dtmp.Z); |
767 | 1142 | ||
@@ -769,10 +1144,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
769 | // so force it back to identity | 1144 | // so force it back to identity |
770 | 1145 | ||
771 | d.Quaternion qtmp; | 1146 | d.Quaternion qtmp; |
772 | qtmp.W = 1; | 1147 | qtmp.W = m_orientation2D.W; |
773 | qtmp.X = 0; | 1148 | qtmp.X = m_orientation2D.X; |
774 | qtmp.Y = 0; | 1149 | qtmp.Y = m_orientation2D.Y; |
775 | qtmp.Z = 0; | 1150 | qtmp.Z = m_orientation2D.Z; |
776 | d.BodySetQuaternion(Body, ref qtmp); | 1151 | d.BodySetQuaternion(Body, ref qtmp); |
777 | 1152 | ||
778 | if (m_pidControllerActive == false) | 1153 | if (m_pidControllerActive == false) |
@@ -835,10 +1210,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
835 | 1210 | ||
836 | //****************************************** | 1211 | //****************************************** |
837 | // colide with land | 1212 | // colide with land |
838 | d.AABB aabb; | ||
839 | d.GeomGetAABB(Shell, out aabb); | ||
840 | float chrminZ = aabb.MinZ; | ||
841 | 1213 | ||
1214 | d.AABB aabb; | ||
1215 | d.GeomGetAABB(feetbox, out aabb); | ||
1216 | float chrminZ = aabb.MinZ; ; // move up a bit | ||
842 | Vector3 posch = localpos; | 1217 | Vector3 posch = localpos; |
843 | 1218 | ||
844 | float ftmp; | 1219 | float ftmp; |
@@ -881,11 +1256,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
881 | contact.PenetrationDepth = depth; | 1256 | contact.PenetrationDepth = depth; |
882 | contact.Position.X = localpos.X; | 1257 | contact.Position.X = localpos.X; |
883 | contact.Position.Y = localpos.Y; | 1258 | contact.Position.Y = localpos.Y; |
884 | contact.Position.Z = chrminZ; | 1259 | contact.Position.Z = terrainheight; |
885 | contact.SurfaceNormal.X = 0f; | 1260 | contact.SurfaceNormal.X = 0.0f; |
886 | contact.SurfaceNormal.Y = 0f; | 1261 | contact.SurfaceNormal.Y = 0.0f; |
887 | contact.SurfaceNormal.Z = -1f; | 1262 | contact.SurfaceNormal.Z = -1f; |
888 | contact.RelativeSpeed = -vel.Z; | 1263 | contact.RelativeSpeed = -vel.Z; |
1264 | contact.CharacterFeet = true; | ||
889 | AddCollisionEvent(0, contact); | 1265 | AddCollisionEvent(0, contact); |
890 | 1266 | ||
891 | vec.Z *= 0.5f; | 1267 | vec.Z *= 0.5f; |
@@ -904,6 +1280,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
904 | m_iscollidingGround = false; | 1280 | m_iscollidingGround = false; |
905 | } | 1281 | } |
906 | 1282 | ||
1283 | |||
907 | //****************************************** | 1284 | //****************************************** |
908 | 1285 | ||
909 | bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f); | 1286 | bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f); |
@@ -1039,21 +1416,58 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1039 | } | 1416 | } |
1040 | 1417 | ||
1041 | // update our local ideia of position velocity and aceleration | 1418 | // update our local ideia of position velocity and aceleration |
1419 | // _position = localpos; | ||
1042 | _position = localpos; | 1420 | _position = localpos; |
1421 | |||
1043 | if (_zeroFlag) | 1422 | if (_zeroFlag) |
1044 | { | 1423 | { |
1045 | _velocity = Vector3.Zero; | 1424 | _velocity = Vector3.Zero; |
1046 | _acceleration = Vector3.Zero; | 1425 | _acceleration = Vector3.Zero; |
1426 | m_rotationalVelocity = Vector3.Zero; | ||
1047 | } | 1427 | } |
1048 | else | 1428 | else |
1049 | { | 1429 | { |
1050 | _acceleration = _velocity; // previus velocity | 1430 | Vector3 a =_velocity; // previus velocity |
1051 | _velocity = vel; | 1431 | SetSmooth(ref _velocity, ref vel, 2); |
1052 | _acceleration = (vel - _acceleration) / timeStep; | 1432 | a = (_velocity - a) * invtimeStep; |
1433 | SetSmooth(ref _acceleration, ref a, 2); | ||
1434 | |||
1435 | dtmp = d.BodyGetAngularVel(Body); | ||
1436 | m_rotationalVelocity.X = 0f; | ||
1437 | m_rotationalVelocity.Y = 0f; | ||
1438 | m_rotationalVelocity.Z = dtmp.Z; | ||
1439 | Math.Round(m_rotationalVelocity.Z,3); | ||
1053 | } | 1440 | } |
1054 | 1441 | ajustCollider(); | |
1442 | } | ||
1443 | |||
1444 | public void round(ref Vector3 v, int digits) | ||
1445 | { | ||
1446 | v.X = (float)Math.Round(v.X, digits); | ||
1447 | v.Y = (float)Math.Round(v.Y, digits); | ||
1448 | v.Z = (float)Math.Round(v.Z, digits); | ||
1449 | } | ||
1450 | |||
1451 | public void SetSmooth(ref Vector3 dst, ref Vector3 value) | ||
1452 | { | ||
1453 | dst.X = 0.1f * dst.X + 0.9f * value.X; | ||
1454 | dst.Y = 0.1f * dst.Y + 0.9f * value.Y; | ||
1455 | dst.Z = 0.1f * dst.Z + 0.9f * value.Z; | ||
1055 | } | 1456 | } |
1056 | 1457 | ||
1458 | public void SetSmooth(ref Vector3 dst, ref Vector3 value, int rounddigits) | ||
1459 | { | ||
1460 | dst.X = 0.4f * dst.X + 0.6f * value.X; | ||
1461 | dst.X = (float)Math.Round(dst.X, rounddigits); | ||
1462 | |||
1463 | dst.Y = 0.4f * dst.Y + 0.6f * value.Y; | ||
1464 | dst.Y = (float)Math.Round(dst.Y, rounddigits); | ||
1465 | |||
1466 | dst.Z = 0.4f * dst.Z + 0.6f * value.Z; | ||
1467 | dst.Z = (float)Math.Round(dst.Z, rounddigits); | ||
1468 | } | ||
1469 | |||
1470 | |||
1057 | /// <summary> | 1471 | /// <summary> |
1058 | /// Updates the reported position and velocity. | 1472 | /// Updates the reported position and velocity. |
1059 | /// Used to copy variables from unmanaged space at heartbeat rate and also trigger scene updates acording | 1473 | /// Used to copy variables from unmanaged space at heartbeat rate and also trigger scene updates acording |
@@ -1176,20 +1590,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1176 | { | 1590 | { |
1177 | if (NewStatus) | 1591 | if (NewStatus) |
1178 | { | 1592 | { |
1179 | // Create avatar capsule and related ODE data | 1593 | AvatarGeomAndBodyDestroy(); |
1180 | if ((Shell != IntPtr.Zero)) | ||
1181 | { | ||
1182 | // a lost shell ? | ||
1183 | m_log.Warn("[PHYSICS]: re-creating the following avatar ODE data, even though it already exists - " | ||
1184 | + (Shell != IntPtr.Zero ? "Shell " : "") | ||
1185 | + (Body != IntPtr.Zero ? "Body " : "") | ||
1186 | + (Amotor != IntPtr.Zero ? "Amotor " : "")); | ||
1187 | AvatarGeomAndBodyDestroy(); | ||
1188 | } | ||
1189 | 1594 | ||
1190 | AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z); | 1595 | AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z); |
1191 | 1596 | ||
1192 | _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; | 1597 | _parent_scene.actor_name_map[collider] = (PhysicsActor)this; |
1598 | _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this; | ||
1599 | _parent_scene.actor_name_map[midbox] = (PhysicsActor)this; | ||
1600 | _parent_scene.actor_name_map[topbox] = (PhysicsActor)this; | ||
1601 | _parent_scene.actor_name_map[bbox] = (PhysicsActor)this; | ||
1193 | _parent_scene.AddCharacter(this); | 1602 | _parent_scene.AddCharacter(this); |
1194 | } | 1603 | } |
1195 | else | 1604 | else |
@@ -1218,39 +1627,40 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1218 | { | 1627 | { |
1219 | } | 1628 | } |
1220 | 1629 | ||
1221 | private void changeSize(Vector3 Size) | 1630 | private void changeAvatarSize(strAvatarSize st) |
1222 | { | 1631 | { |
1223 | if (Size.IsFinite()) | 1632 | m_feetOffset = st.offset; |
1633 | changeSize(st.size); | ||
1634 | } | ||
1635 | |||
1636 | private void changeSize(Vector3 pSize) | ||
1637 | { | ||
1638 | if (pSize.IsFinite()) | ||
1224 | { | 1639 | { |
1225 | float caplen = Size.Z; | 1640 | // for now only look to Z changes since viewers also don't change X and Y |
1641 | if (pSize.Z != m_size.Z) | ||
1642 | { | ||
1643 | AvatarGeomAndBodyDestroy(); | ||
1226 | 1644 | ||
1227 | caplen = caplen * 1.15f - CAPSULE_RADIUS * 2.0f; | ||
1228 | 1645 | ||
1229 | if (caplen != CAPSULE_LENGTH) | 1646 | float oldsz = m_size.Z; |
1230 | { | 1647 | m_size = pSize; |
1231 | if (Shell != IntPtr.Zero && Body != IntPtr.Zero && Amotor != IntPtr.Zero) | ||
1232 | { | ||
1233 | AvatarGeomAndBodyDestroy(); | ||
1234 | 1648 | ||
1235 | float prevCapsule = CAPSULE_LENGTH; | ||
1236 | CAPSULE_LENGTH = caplen; | ||
1237 | 1649 | ||
1238 | AvatarGeomAndBodyCreation(_position.X, _position.Y, | 1650 | AvatarGeomAndBodyCreation(_position.X, _position.Y, |
1239 | _position.Z + (CAPSULE_LENGTH - prevCapsule) * 0.5f); | 1651 | _position.Z + (m_size.Z - oldsz) * 0.5f); |
1240 | 1652 | ||
1241 | Velocity = Vector3.Zero; | 1653 | Velocity = Vector3.Zero; |
1654 | |||
1242 | 1655 | ||
1243 | _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; | 1656 | _parent_scene.actor_name_map[collider] = (PhysicsActor)this; |
1244 | } | 1657 | _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this; |
1245 | else | 1658 | _parent_scene.actor_name_map[midbox] = (PhysicsActor)this; |
1246 | { | 1659 | _parent_scene.actor_name_map[topbox] = (PhysicsActor)this; |
1247 | m_log.Warn("[PHYSICS]: trying to change capsule size, but the following ODE data is missing - " | 1660 | _parent_scene.actor_name_map[bbox] = (PhysicsActor)this; |
1248 | + (Shell == IntPtr.Zero ? "Shell " : "") | ||
1249 | + (Body == IntPtr.Zero ? "Body " : "") | ||
1250 | + (Amotor == IntPtr.Zero ? "Amotor " : "")); | ||
1251 | } | ||
1252 | } | 1661 | } |
1253 | m_freemove = false; | 1662 | m_freemove = false; |
1663 | m_collisionException = false; | ||
1254 | m_pidControllerActive = true; | 1664 | m_pidControllerActive = true; |
1255 | } | 1665 | } |
1256 | else | 1666 | else |
@@ -1270,6 +1680,36 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1270 | 1680 | ||
1271 | private void changeOrientation(Quaternion newOri) | 1681 | private void changeOrientation(Quaternion newOri) |
1272 | { | 1682 | { |
1683 | if (m_orientation != newOri) | ||
1684 | { | ||
1685 | m_orientation = newOri; // keep a copy for core use | ||
1686 | // but only use rotations around Z | ||
1687 | |||
1688 | m_orientation2D.W = newOri.W; | ||
1689 | m_orientation2D.Z = newOri.Z; | ||
1690 | |||
1691 | float t = m_orientation2D.W * m_orientation2D.W + m_orientation2D.Z * m_orientation2D.Z; | ||
1692 | if (t > 0) | ||
1693 | { | ||
1694 | t = 1.0f / (float)Math.Sqrt(t); | ||
1695 | m_orientation2D.W *= t; | ||
1696 | m_orientation2D.Z *= t; | ||
1697 | } | ||
1698 | else | ||
1699 | { | ||
1700 | m_orientation2D.W = 1.0f; | ||
1701 | m_orientation2D.Z = 0f; | ||
1702 | } | ||
1703 | m_orientation2D.Y = 0f; | ||
1704 | m_orientation2D.X = 0f; | ||
1705 | |||
1706 | d.Quaternion myrot = new d.Quaternion(); | ||
1707 | myrot.X = m_orientation2D.X; | ||
1708 | myrot.Y = m_orientation2D.Y; | ||
1709 | myrot.Z = m_orientation2D.Z; | ||
1710 | myrot.W = m_orientation2D.W; | ||
1711 | d.BodySetQuaternion(Body, ref myrot); | ||
1712 | } | ||
1273 | } | 1713 | } |
1274 | 1714 | ||
1275 | private void changeVelocity(Vector3 newVel) | 1715 | private void changeVelocity(Vector3 newVel) |
@@ -1351,6 +1791,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1351 | 1791 | ||
1352 | if (Body != IntPtr.Zero) | 1792 | if (Body != IntPtr.Zero) |
1353 | d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z); | 1793 | d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z); |
1794 | ajustCollider(); | ||
1354 | } | 1795 | } |
1355 | 1796 | ||
1356 | private void donullchange() | 1797 | private void donullchange() |
@@ -1359,7 +1800,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1359 | 1800 | ||
1360 | public bool DoAChange(changes what, object arg) | 1801 | public bool DoAChange(changes what, object arg) |
1361 | { | 1802 | { |
1362 | if (Shell == IntPtr.Zero && what != changes.Add && what != changes.Remove) | 1803 | if (collider == IntPtr.Zero && what != changes.Add && what != changes.Remove) |
1363 | { | 1804 | { |
1364 | return false; | 1805 | return false; |
1365 | } | 1806 | } |
@@ -1425,6 +1866,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1425 | changeSize((Vector3)arg); | 1866 | changeSize((Vector3)arg); |
1426 | break; | 1867 | break; |
1427 | 1868 | ||
1869 | case changes.AvatarSize: | ||
1870 | changeAvatarSize((strAvatarSize)arg); | ||
1871 | break; | ||
1872 | |||
1428 | case changes.Momentum: | 1873 | case changes.Momentum: |
1429 | changeMomentum((Vector3)arg); | 1874 | changeMomentum((Vector3)arg); |
1430 | break; | 1875 | break; |
@@ -1472,5 +1917,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1472 | { | 1917 | { |
1473 | _parent_scene.AddChange((PhysicsActor)this, what, arg); | 1918 | _parent_scene.AddChange((PhysicsActor)this, what, arg); |
1474 | } | 1919 | } |
1920 | |||
1921 | private struct strAvatarSize | ||
1922 | { | ||
1923 | public Vector3 size; | ||
1924 | public float offset; | ||
1925 | } | ||
1926 | |||
1475 | } | 1927 | } |
1476 | } | 1928 | } |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index dc247a9..faa9488 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | |||
@@ -84,7 +84,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
84 | 84 | ||
85 | private Vector3 _position; | 85 | private Vector3 _position; |
86 | private Vector3 _velocity; | 86 | private Vector3 _velocity; |
87 | private Vector3 _torque; | 87 | private Vector3 m_torque; |
88 | private Vector3 m_lastVelocity; | 88 | private Vector3 m_lastVelocity; |
89 | private Vector3 m_lastposition; | 89 | private Vector3 m_lastposition; |
90 | private Vector3 m_rotationalVelocity; | 90 | private Vector3 m_rotationalVelocity; |
@@ -597,7 +597,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
597 | if (!IsPhysical || Body == IntPtr.Zero) | 597 | if (!IsPhysical || Body == IntPtr.Zero) |
598 | return Vector3.Zero; | 598 | return Vector3.Zero; |
599 | 599 | ||
600 | return _torque; | 600 | return m_torque; |
601 | } | 601 | } |
602 | 602 | ||
603 | set | 603 | set |
@@ -2425,10 +2425,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2425 | { | 2425 | { |
2426 | if (!childPrim) | 2426 | if (!childPrim) |
2427 | { | 2427 | { |
2428 | m_force = Vector3.Zero; | 2428 | // m_force = Vector3.Zero; |
2429 | m_forceacc = Vector3.Zero; | 2429 | m_forceacc = Vector3.Zero; |
2430 | m_angularForceacc = Vector3.Zero; | 2430 | m_angularForceacc = Vector3.Zero; |
2431 | _torque = Vector3.Zero; | 2431 | // m_torque = Vector3.Zero; |
2432 | _velocity = Vector3.Zero; | 2432 | _velocity = Vector3.Zero; |
2433 | _acceleration = Vector3.Zero; | 2433 | _acceleration = Vector3.Zero; |
2434 | m_rotationalVelocity = Vector3.Zero; | 2434 | m_rotationalVelocity = Vector3.Zero; |
@@ -2521,7 +2521,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2521 | prm.m_collisionCategories = m_collisionCategories; | 2521 | prm.m_collisionCategories = m_collisionCategories; |
2522 | prm.m_collisionFlags = m_collisionFlags; | 2522 | prm.m_collisionFlags = m_collisionFlags; |
2523 | 2523 | ||
2524 | if (prm.prim_geom != null) | 2524 | if (prm.prim_geom != IntPtr.Zero) |
2525 | { | 2525 | { |
2526 | 2526 | ||
2527 | if (prm.m_NoColide) | 2527 | if (prm.m_NoColide) |
@@ -2542,7 +2542,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2542 | // ((OdePrim)_parent).ChildSelectedChange(true); | 2542 | // ((OdePrim)_parent).ChildSelectedChange(true); |
2543 | 2543 | ||
2544 | 2544 | ||
2545 | if (prim_geom != null) | 2545 | if (prim_geom != IntPtr.Zero) |
2546 | { | 2546 | { |
2547 | if (m_NoColide) | 2547 | if (m_NoColide) |
2548 | { | 2548 | { |
@@ -2968,7 +2968,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2968 | d.BodyEnable(Body); | 2968 | d.BodyEnable(Body); |
2969 | 2969 | ||
2970 | } | 2970 | } |
2971 | _torque = newtorque; | 2971 | m_torque = newtorque; |
2972 | } | 2972 | } |
2973 | } | 2973 | } |
2974 | 2974 | ||
@@ -3364,7 +3364,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3364 | 3364 | ||
3365 | Vector3 trq; | 3365 | Vector3 trq; |
3366 | 3366 | ||
3367 | trq = _torque; | 3367 | trq = m_torque; |
3368 | trq += m_angularForceacc; | 3368 | trq += m_angularForceacc; |
3369 | m_angularForceacc = Vector3.Zero; | 3369 | m_angularForceacc = Vector3.Zero; |
3370 | if (trq.X != 0 || trq.Y != 0 || trq.Z != 0) | 3370 | if (trq.X != 0 || trq.Y != 0 || trq.Z != 0) |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs index 799a324..561ab1c 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs | |||
@@ -324,7 +324,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
324 | { | 324 | { |
325 | // Collide tests | 325 | // Collide tests |
326 | if ((CurrentRayFilter & FilterActiveSpace) != 0) | 326 | if ((CurrentRayFilter & FilterActiveSpace) != 0) |
327 | { | ||
327 | d.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback); | 328 | d.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback); |
329 | d.SpaceCollide2(ray, m_scene.CharsSpace, IntPtr.Zero, nearCallback); | ||
330 | } | ||
328 | if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount)) | 331 | if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount)) |
329 | d.SpaceCollide2(ray, m_scene.StaticSpace, IntPtr.Zero, nearCallback); | 332 | d.SpaceCollide2(ray, m_scene.StaticSpace, IntPtr.Zero, nearCallback); |
330 | if ((CurrentRayFilter & RayFilterFlags.land) != 0 && (m_contactResults.Count < CurrentMaxCount)) | 333 | if ((CurrentRayFilter & RayFilterFlags.land) != 0 && (m_contactResults.Count < CurrentMaxCount)) |
@@ -552,7 +555,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
552 | break; | 555 | break; |
553 | 556 | ||
554 | default: | 557 | default: |
555 | return; | ||
556 | break; | 558 | break; |
557 | } | 559 | } |
558 | } | 560 | } |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs new file mode 100644 index 0000000..225bff8 --- /dev/null +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs | |||
@@ -0,0 +1,183 @@ | |||
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 | // Ubit 2012 | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Runtime.InteropServices; | ||
32 | using System.Text; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Physics.Manager; | ||
35 | using OdeAPI; | ||
36 | using log4net; | ||
37 | using OpenMetaverse; | ||
38 | |||
39 | namespace OpenSim.Region.Physics.OdePlugin | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// </summary> | ||
43 | public class ODESitAvatar | ||
44 | { | ||
45 | private OdeScene m_scene; | ||
46 | private ODERayCastRequestManager m_raymanager; | ||
47 | |||
48 | public ODESitAvatar(OdeScene pScene, ODERayCastRequestManager raymanager) | ||
49 | { | ||
50 | m_scene = pScene; | ||
51 | m_raymanager = raymanager; | ||
52 | } | ||
53 | |||
54 | private static Vector3 SitAjust = new Vector3(0, 0, 0.4f); | ||
55 | |||
56 | public void Sit(PhysicsActor actor, Vector3 avPos, Vector3 avCameraPosition, Vector3 offset, Vector3 avOffset, SitAvatarCallback PhysicsSitResponse) | ||
57 | { | ||
58 | if (!m_scene.haveActor(actor) || !(actor is OdePrim) || ((OdePrim)actor).prim_geom == IntPtr.Zero) | ||
59 | { | ||
60 | PhysicsSitResponse(-1, actor.LocalID, offset, Quaternion.Identity); | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | IntPtr geom = ((OdePrim)actor).prim_geom; | ||
65 | |||
66 | d.Vector3 dtmp = d.GeomGetPosition(geom); | ||
67 | Vector3 geopos; | ||
68 | geopos.X = dtmp.X; | ||
69 | geopos.Y = dtmp.Y; | ||
70 | geopos.Z = dtmp.Z; | ||
71 | |||
72 | |||
73 | d.AABB aabb; | ||
74 | Quaternion ori; | ||
75 | d.Quaternion qtmp; | ||
76 | d.GeomCopyQuaternion(geom, out qtmp); | ||
77 | Quaternion geomOri; | ||
78 | geomOri.X = qtmp.X; | ||
79 | geomOri.Y = qtmp.Y; | ||
80 | geomOri.Z = qtmp.Z; | ||
81 | geomOri.W = qtmp.W; | ||
82 | Quaternion geomInvOri; | ||
83 | geomInvOri.X = -qtmp.X; | ||
84 | geomInvOri.Y = -qtmp.Y; | ||
85 | geomInvOri.Z = -qtmp.Z; | ||
86 | geomInvOri.W = qtmp.W; | ||
87 | |||
88 | Vector3 target = geopos + offset; | ||
89 | Vector3 rayDir = target - avCameraPosition; | ||
90 | float raylen = rayDir.Length(); | ||
91 | float t = 1 / raylen; | ||
92 | rayDir.X *= t; | ||
93 | rayDir.Y *= t; | ||
94 | rayDir.Z *= t; | ||
95 | |||
96 | raylen += 0.5f; | ||
97 | List<ContactResult> rayResults; | ||
98 | |||
99 | rayResults = m_scene.RaycastActor(actor, avCameraPosition, rayDir , raylen, 1); | ||
100 | if (rayResults.Count == 0 || rayResults[0].ConsumerID != actor.LocalID) | ||
101 | { | ||
102 | d.GeomGetAABB(geom,out aabb); | ||
103 | offset = new Vector3(avOffset.X, 0, aabb.MaxZ + avOffset.Z - geopos.Z); | ||
104 | ori = geomInvOri; | ||
105 | offset *= geomInvOri; | ||
106 | |||
107 | PhysicsSitResponse(1, actor.LocalID, offset, ori); | ||
108 | return; | ||
109 | } | ||
110 | |||
111 | offset = rayResults[0].Pos - geopos; | ||
112 | double ang; | ||
113 | float s; | ||
114 | float c; | ||
115 | |||
116 | d.GeomClassID geoclass = d.GeomGetClass(geom); | ||
117 | |||
118 | if (geoclass == d.GeomClassID.SphereClass) | ||
119 | { | ||
120 | float r = d.GeomSphereGetRadius(geom); | ||
121 | |||
122 | offset.Normalize(); | ||
123 | offset *= r; | ||
124 | |||
125 | ang = Math.Atan2(offset.Y, offset.X); | ||
126 | ang *= 0.5d; | ||
127 | s = (float)Math.Sin(ang); | ||
128 | c = (float)Math.Cos(ang); | ||
129 | |||
130 | ori = new Quaternion(0, 0, s, c); | ||
131 | |||
132 | if (r < 0.4f) | ||
133 | { | ||
134 | offset = new Vector3(0, 0, r); | ||
135 | } | ||
136 | else if (offset.Z < 0.4f) | ||
137 | { | ||
138 | t = offset.Z; | ||
139 | float rsq = r * r; | ||
140 | |||
141 | t = 1.0f / (rsq - t * t); | ||
142 | offset.X *= t; | ||
143 | offset.Y *= t; | ||
144 | offset.Z = 0.4f; | ||
145 | t = rsq - 0.16f; | ||
146 | offset.X *= t; | ||
147 | offset.Y *= t; | ||
148 | } | ||
149 | |||
150 | offset += avOffset * ori; | ||
151 | |||
152 | ori = geomInvOri * ori; | ||
153 | offset *= geomInvOri; | ||
154 | |||
155 | PhysicsSitResponse(1, actor.LocalID, offset, ori); | ||
156 | return; | ||
157 | } | ||
158 | |||
159 | Vector3 norm = rayResults[0].Normal; | ||
160 | |||
161 | if (norm.Z < 0) | ||
162 | { | ||
163 | PhysicsSitResponse(0, actor.LocalID, offset, Quaternion.Identity); | ||
164 | return; | ||
165 | } | ||
166 | |||
167 | ang = Math.Atan2(-rayDir.Y, -rayDir.X); | ||
168 | ang *= 0.5d; | ||
169 | s = (float)Math.Sin(ang); | ||
170 | c = (float)Math.Cos(ang); | ||
171 | |||
172 | ori = new Quaternion(0, 0, s, c); | ||
173 | |||
174 | offset += avOffset * ori; | ||
175 | |||
176 | ori = geomInvOri * ori; | ||
177 | offset *= geomInvOri; | ||
178 | |||
179 | PhysicsSitResponse(1, actor.LocalID, offset, ori); | ||
180 | return; | ||
181 | } | ||
182 | } | ||
183 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 54bc29f..fbf2f0d 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -147,6 +147,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
147 | PIDHoverActive, | 147 | PIDHoverActive, |
148 | 148 | ||
149 | Size, | 149 | Size, |
150 | AvatarSize, | ||
150 | Shape, | 151 | Shape, |
151 | PhysRepData, | 152 | PhysRepData, |
152 | AddPhysRep, | 153 | AddPhysRep, |
@@ -177,7 +178,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
177 | public changes what; | 178 | public changes what; |
178 | public Object arg; | 179 | public Object arg; |
179 | } | 180 | } |
180 | 181 | ||
182 | |||
183 | |||
181 | public class OdeScene : PhysicsScene | 184 | public class OdeScene : PhysicsScene |
182 | { | 185 | { |
183 | private readonly ILog m_log; | 186 | private readonly ILog m_log; |
@@ -224,9 +227,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
224 | // private IntPtr WaterHeightmapData = IntPtr.Zero; | 227 | // private IntPtr WaterHeightmapData = IntPtr.Zero; |
225 | // private GCHandle WaterMapHandler = new GCHandle(); | 228 | // private GCHandle WaterMapHandler = new GCHandle(); |
226 | 229 | ||
227 | public float avPIDD = 2200f; // make it visible | ||
228 | public float avPIDP = 900f; // make it visible | ||
229 | private float avCapRadius = 0.37f; | ||
230 | private float avDensity = 3f; | 230 | private float avDensity = 3f; |
231 | private float avMovementDivisorWalk = 1.3f; | 231 | private float avMovementDivisorWalk = 1.3f; |
232 | private float avMovementDivisorRun = 0.8f; | 232 | private float avMovementDivisorRun = 0.8f; |
@@ -299,9 +299,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
299 | 299 | ||
300 | public IntPtr TopSpace; // the global space | 300 | public IntPtr TopSpace; // the global space |
301 | public IntPtr ActiveSpace; // space for active prims | 301 | public IntPtr ActiveSpace; // space for active prims |
302 | public IntPtr CharsSpace; // space for active prims | ||
302 | public IntPtr StaticSpace; // space for the static things around | 303 | public IntPtr StaticSpace; // space for the static things around |
303 | public IntPtr GroundSpace; // space for ground | 304 | public IntPtr GroundSpace; // space for ground |
304 | 305 | ||
306 | public IntPtr SharedRay; | ||
307 | |||
305 | // some speedup variables | 308 | // some speedup variables |
306 | private int spaceGridMaxX; | 309 | private int spaceGridMaxX; |
307 | private int spaceGridMaxY; | 310 | private int spaceGridMaxY; |
@@ -359,8 +362,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
359 | 362 | ||
360 | nearCallback = near; | 363 | nearCallback = near; |
361 | 364 | ||
362 | m_rayCastManager = new ODERayCastRequestManager(this); | 365 | m_rayCastManager = new ODERayCastRequestManager(this); |
363 | |||
364 | 366 | ||
365 | lock (OdeLock) | 367 | lock (OdeLock) |
366 | { | 368 | { |
@@ -372,21 +374,25 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
372 | 374 | ||
373 | // now the major subspaces | 375 | // now the major subspaces |
374 | ActiveSpace = d.HashSpaceCreate(TopSpace); | 376 | ActiveSpace = d.HashSpaceCreate(TopSpace); |
377 | CharsSpace = d.HashSpaceCreate(TopSpace); | ||
375 | StaticSpace = d.HashSpaceCreate(TopSpace); | 378 | StaticSpace = d.HashSpaceCreate(TopSpace); |
376 | GroundSpace = d.HashSpaceCreate(TopSpace); | 379 | GroundSpace = d.HashSpaceCreate(TopSpace); |
377 | } | 380 | } |
378 | catch | 381 | catch |
379 | { | 382 | { |
380 | // i must RtC#FM | 383 | // i must RtC#FM |
384 | // i did! | ||
381 | } | 385 | } |
382 | 386 | ||
383 | d.HashSpaceSetLevels(TopSpace, -2, 8); | 387 | d.HashSpaceSetLevels(TopSpace, -2, 8); |
384 | d.HashSpaceSetLevels(ActiveSpace, -2, 8); | 388 | d.HashSpaceSetLevels(ActiveSpace, -2, 8); |
389 | d.HashSpaceSetLevels(CharsSpace, -4, 3); | ||
385 | d.HashSpaceSetLevels(StaticSpace, -2, 8); | 390 | d.HashSpaceSetLevels(StaticSpace, -2, 8); |
386 | d.HashSpaceSetLevels(GroundSpace, 0, 8); | 391 | d.HashSpaceSetLevels(GroundSpace, 0, 8); |
387 | 392 | ||
388 | // demote to second level | 393 | // demote to second level |
389 | d.SpaceSetSublevel(ActiveSpace, 1); | 394 | d.SpaceSetSublevel(ActiveSpace, 1); |
395 | d.SpaceSetSublevel(CharsSpace, 1); | ||
390 | d.SpaceSetSublevel(StaticSpace, 1); | 396 | d.SpaceSetSublevel(StaticSpace, 1); |
391 | d.SpaceSetSublevel(GroundSpace, 1); | 397 | d.SpaceSetSublevel(GroundSpace, 1); |
392 | 398 | ||
@@ -396,11 +402,24 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
396 | CollisionCategories.Phantom | | 402 | CollisionCategories.Phantom | |
397 | CollisionCategories.VolumeDtc | 403 | CollisionCategories.VolumeDtc |
398 | )); | 404 | )); |
399 | d.GeomSetCollideBits(ActiveSpace, 0); | 405 | d.GeomSetCollideBits(ActiveSpace, (uint)(CollisionCategories.Space | |
406 | CollisionCategories.Geom | | ||
407 | CollisionCategories.Character | | ||
408 | CollisionCategories.Phantom | | ||
409 | CollisionCategories.VolumeDtc | ||
410 | )); | ||
411 | d.GeomSetCategoryBits(CharsSpace, (uint)(CollisionCategories.Space | | ||
412 | CollisionCategories.Geom | | ||
413 | CollisionCategories.Character | | ||
414 | CollisionCategories.Phantom | | ||
415 | CollisionCategories.VolumeDtc | ||
416 | )); | ||
417 | d.GeomSetCollideBits(CharsSpace, 0); | ||
418 | |||
400 | d.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space | | 419 | d.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space | |
401 | CollisionCategories.Geom | | 420 | CollisionCategories.Geom | |
402 | CollisionCategories.Land | | 421 | // CollisionCategories.Land | |
403 | CollisionCategories.Water | | 422 | // CollisionCategories.Water | |
404 | CollisionCategories.Phantom | | 423 | CollisionCategories.Phantom | |
405 | CollisionCategories.VolumeDtc | 424 | CollisionCategories.VolumeDtc |
406 | )); | 425 | )); |
@@ -412,6 +431,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
412 | contactgroup = d.JointGroupCreate(0); | 431 | contactgroup = d.JointGroupCreate(0); |
413 | //contactgroup | 432 | //contactgroup |
414 | 433 | ||
434 | SharedRay = d.CreateRay(TopSpace, 1.0f); | ||
435 | |||
415 | d.WorldSetAutoDisableFlag(world, false); | 436 | d.WorldSetAutoDisableFlag(world, false); |
416 | } | 437 | } |
417 | } | 438 | } |
@@ -468,7 +489,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
468 | avDensity = physicsconfig.GetFloat("av_density", avDensity); | 489 | avDensity = physicsconfig.GetFloat("av_density", avDensity); |
469 | avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk); | 490 | avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk); |
470 | avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", avMovementDivisorRun); | 491 | avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", avMovementDivisorRun); |
471 | avCapRadius = physicsconfig.GetFloat("av_capsule_radius", avCapRadius); | ||
472 | 492 | ||
473 | contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision); | 493 | contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision); |
474 | 494 | ||
@@ -494,7 +514,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
494 | odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f); | 514 | odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f); |
495 | 515 | ||
496 | ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); | 516 | ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); |
497 | GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); | 517 | GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); |
498 | 518 | ||
499 | m_materialContactsData[(int)Material.Stone].mu = 0.8f; | 519 | m_materialContactsData[(int)Material.Stone].mu = 0.8f; |
500 | m_materialContactsData[(int)Material.Stone].bounce = 0.4f; | 520 | m_materialContactsData[(int)Material.Stone].bounce = 0.4f; |
@@ -718,35 +738,35 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
718 | 738 | ||
719 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) | 739 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) |
720 | return; | 740 | return; |
721 | /* | 741 | /* |
722 | // debug | 742 | // debug |
723 | PhysicsActor dp2; | 743 | PhysicsActor dp2; |
724 | if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass) | 744 | if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass) |
725 | { | 745 | { |
726 | d.AABB aabb; | 746 | d.AABB aabb; |
727 | d.GeomGetAABB(g2, out aabb); | 747 | d.GeomGetAABB(g2, out aabb); |
728 | float x = aabb.MaxX - aabb.MinX; | 748 | float x = aabb.MaxX - aabb.MinX; |
729 | float y = aabb.MaxY - aabb.MinY; | 749 | float y = aabb.MaxY - aabb.MinY; |
730 | float z = aabb.MaxZ - aabb.MinZ; | 750 | float z = aabb.MaxZ - aabb.MinZ; |
731 | if (x > 60.0f || y > 60.0f || z > 60.0f) | 751 | if (x > 60.0f || y > 60.0f || z > 60.0f) |
732 | { | 752 | { |
733 | if (!actor_name_map.TryGetValue(g2, out dp2)) | 753 | if (!actor_name_map.TryGetValue(g2, out dp2)) |
734 | m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2"); | 754 | m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2"); |
735 | else | 755 | else |
736 | m_log.WarnFormat("[PHYSICS]: land versus large prim geo {0},size {1}, AABBsize <{2},{3},{4}>, at {5} ori {6},({7})", | 756 | m_log.WarnFormat("[PHYSICS]: land versus large prim geo {0},size {1}, AABBsize <{2},{3},{4}>, at {5} ori {6},({7})", |
737 | dp2.Name, dp2.Size, x, y, z, | 757 | dp2.Name, dp2.Size, x, y, z, |
738 | dp2.Position.ToString(), | 758 | dp2.Position.ToString(), |
739 | dp2.Orientation.ToString(), | 759 | dp2.Orientation.ToString(), |
740 | dp2.Orientation.Length()); | 760 | dp2.Orientation.Length()); |
741 | return; | 761 | return; |
742 | } | 762 | } |
743 | } | 763 | } |
744 | // | 764 | // |
745 | */ | 765 | */ |
746 | 766 | ||
747 | 767 | ||
748 | if(d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || | 768 | if (d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || |
749 | d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc) | 769 | d.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc) |
750 | { | 770 | { |
751 | int cflags; | 771 | int cflags; |
752 | unchecked | 772 | unchecked |
@@ -761,7 +781,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
761 | catch (SEHException) | 781 | catch (SEHException) |
762 | { | 782 | { |
763 | m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); | 783 | m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); |
764 | // ode.drelease(world); | 784 | // ode.drelease(world); |
765 | base.TriggerPhysicsBasedRestart(); | 785 | base.TriggerPhysicsBasedRestart(); |
766 | } | 786 | } |
767 | catch (Exception e) | 787 | catch (Exception e) |
@@ -801,26 +821,25 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
801 | 821 | ||
802 | // get first contact | 822 | // get first contact |
803 | d.ContactGeom curContact = new d.ContactGeom(); | 823 | d.ContactGeom curContact = new d.ContactGeom(); |
824 | |||
804 | if (!GetCurContactGeom(0, ref curContact)) | 825 | if (!GetCurContactGeom(0, ref curContact)) |
805 | return; | 826 | return; |
806 | // for now it's the one with max depth | 827 | |
807 | ContactPoint maxDepthContact = new ContactPoint( | ||
808 | new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z), | ||
809 | new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z), | ||
810 | curContact.depth | ||
811 | ); | ||
812 | // do volume detection case | 828 | // do volume detection case |
813 | if ( | 829 | if ((p1.IsVolumeDtc || p2.IsVolumeDtc)) |
814 | (p1.IsVolumeDtc || p2.IsVolumeDtc)) | ||
815 | { | 830 | { |
831 | ContactPoint maxDepthContact = new ContactPoint( | ||
832 | new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z), | ||
833 | new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z), | ||
834 | curContact.depth, false | ||
835 | ); | ||
836 | |||
816 | collision_accounting_events(p1, p2, maxDepthContact); | 837 | collision_accounting_events(p1, p2, maxDepthContact); |
817 | return; | 838 | return; |
818 | } | 839 | } |
819 | 840 | ||
820 | // big messy collision analises | 841 | // big messy collision analises |
821 | 842 | ||
822 | Vector3 normoverride = Vector3.Zero; //damm c# | ||
823 | |||
824 | float mu = 0; | 843 | float mu = 0; |
825 | float bounce = 0; | 844 | float bounce = 0; |
826 | float cfm = 0.0001f; | 845 | float cfm = 0.0001f; |
@@ -831,34 +850,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
831 | ContactData contactdata1 = new ContactData(0, 0, false); | 850 | ContactData contactdata1 = new ContactData(0, 0, false); |
832 | ContactData contactdata2 = new ContactData(0, 0, false); | 851 | ContactData contactdata2 = new ContactData(0, 0, false); |
833 | 852 | ||
834 | bool dop1foot = false; | 853 | bool dop1ava = false; |
835 | bool dop2foot = false; | 854 | bool dop2ava = false; |
836 | bool ignore = false; | 855 | bool ignore = false; |
837 | bool AvanormOverride = false; | ||
838 | 856 | ||
839 | switch (p1.PhysicsActorType) | 857 | switch (p1.PhysicsActorType) |
840 | { | 858 | { |
841 | case (int)ActorTypes.Agent: | 859 | case (int)ActorTypes.Agent: |
842 | { | 860 | { |
843 | AvanormOverride = true; | 861 | dop1ava = true; |
844 | Vector3 tmp = p2.Position - p1.Position; | ||
845 | normoverride = p2.Velocity - p1.Velocity; | ||
846 | mu = normoverride.LengthSquared(); | ||
847 | |||
848 | if (mu > 1e-6) | ||
849 | { | ||
850 | mu = 1.0f / (float)Math.Sqrt(mu); | ||
851 | normoverride *= mu; | ||
852 | mu = Vector3.Dot(tmp, normoverride); | ||
853 | if (mu > 0) | ||
854 | normoverride *= -1; | ||
855 | } | ||
856 | else | ||
857 | { | ||
858 | tmp.Normalize(); | ||
859 | normoverride = -tmp; | ||
860 | } | ||
861 | |||
862 | switch (p2.PhysicsActorType) | 862 | switch (p2.PhysicsActorType) |
863 | { | 863 | { |
864 | case (int)ActorTypes.Agent: | 864 | case (int)ActorTypes.Agent: |
@@ -869,7 +869,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
869 | case (int)ActorTypes.Prim: | 869 | case (int)ActorTypes.Prim: |
870 | if (p2.Velocity.LengthSquared() > 0.0f) | 870 | if (p2.Velocity.LengthSquared() > 0.0f) |
871 | p2.CollidingObj = true; | 871 | p2.CollidingObj = true; |
872 | dop1foot = true; | ||
873 | break; | 872 | break; |
874 | 873 | ||
875 | default: | 874 | default: |
@@ -883,30 +882,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
883 | switch (p2.PhysicsActorType) | 882 | switch (p2.PhysicsActorType) |
884 | { | 883 | { |
885 | case (int)ActorTypes.Agent: | 884 | case (int)ActorTypes.Agent: |
886 | AvanormOverride = true; | ||
887 | |||
888 | Vector3 tmp = p2.Position - p1.Position; | ||
889 | normoverride = p2.Velocity - p1.Velocity; | ||
890 | mu = normoverride.LengthSquared(); | ||
891 | if (mu > 1e-6) | ||
892 | { | ||
893 | mu = 1.0f / (float)Math.Sqrt(mu); | ||
894 | normoverride *= mu; | ||
895 | mu = Vector3.Dot(tmp, normoverride); | ||
896 | if (mu > 0) | ||
897 | normoverride *= -1; | ||
898 | } | ||
899 | else | ||
900 | { | ||
901 | tmp.Normalize(); | ||
902 | normoverride = -tmp; | ||
903 | } | ||
904 | 885 | ||
905 | bounce = 0; | 886 | dop2ava = true; |
906 | mu = 0; | ||
907 | cfm = 0.0001f; | ||
908 | 887 | ||
909 | dop2foot = true; | ||
910 | if (p1.Velocity.LengthSquared() > 0.0f) | 888 | if (p1.Velocity.LengthSquared() > 0.0f) |
911 | p1.CollidingObj = true; | 889 | p1.CollidingObj = true; |
912 | break; | 890 | break; |
@@ -1011,146 +989,78 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1011 | default: | 989 | default: |
1012 | break; | 990 | break; |
1013 | } | 991 | } |
992 | |||
1014 | if (ignore) | 993 | if (ignore) |
1015 | return; | 994 | return; |
1016 | 995 | ||
1017 | IntPtr Joint; | ||
1018 | 996 | ||
1019 | int i = 0; | 997 | d.ContactGeom maxContact = curContact; |
1020 | while(true) | 998 | // if (IgnoreNegSides && curContact.side1 < 0) |
1021 | { | 999 | // maxContact.depth = float.MinValue; |
1022 | 1000 | ||
1023 | if (IgnoreNegSides && curContact.side1 < 0) | 1001 | d.ContactGeom minContact = curContact; |
1024 | { | 1002 | // if (IgnoreNegSides && curContact.side1 < 0) |
1025 | if (++i >= count) | 1003 | // minContact.depth = float.MaxValue; |
1026 | break; | 1004 | |
1005 | IntPtr Joint; | ||
1006 | bool FeetCollision = false; | ||
1007 | int ncontacts = 0; | ||
1027 | 1008 | ||
1028 | if (!GetCurContactGeom(i, ref curContact)) | ||
1029 | break; | ||
1030 | } | ||
1031 | else | ||
1032 | 1009 | ||
1010 | int i = 0; | ||
1011 | |||
1012 | while (true) | ||
1033 | { | 1013 | { |
1014 | if (m_global_contactcount >= maxContactsbeforedeath) | ||
1015 | break; | ||
1034 | 1016 | ||
1035 | if (AvanormOverride) | 1017 | // if (!(IgnoreNegSides && curContact.side1 < 0)) |
1036 | { | 1018 | { |
1037 | if (curContact.depth > 0.3f) | 1019 | bool noskip = true; |
1020 | if (dop1ava) | ||
1021 | { | ||
1022 | if (!(((OdeCharacter)p1).Collide(g1,false, ref curContact, ref FeetCollision))) | ||
1023 | |||
1024 | noskip = false; | ||
1025 | } | ||
1026 | else if (dop2ava) | ||
1038 | { | 1027 | { |
1039 | if (dop1foot && (p1.Position.Z - curContact.pos.Z) > (p1.Size.Z - avCapRadius) * 0.5f) | 1028 | if (!(((OdeCharacter)p2).Collide(g2,true, ref curContact, ref FeetCollision))) |
1040 | p1.IsColliding = true; | 1029 | noskip = false; |
1041 | if (dop2foot && (p2.Position.Z - curContact.pos.Z) > (p2.Size.Z - avCapRadius) * 0.5f) | ||
1042 | p2.IsColliding = true; | ||
1043 | curContact.normal.X = normoverride.X; | ||
1044 | curContact.normal.Y = normoverride.Y; | ||
1045 | curContact.normal.Z = normoverride.Z; | ||
1046 | } | 1030 | } |
1047 | 1031 | ||
1048 | else | 1032 | if (noskip) |
1049 | { | 1033 | { |
1050 | if (dop1foot) | 1034 | m_global_contactcount++; |
1051 | { | 1035 | ncontacts++; |
1052 | float sz = p1.Size.Z; | ||
1053 | Vector3 vtmp = p1.Position; | ||
1054 | float ppos = curContact.pos.Z - vtmp.Z + (sz - avCapRadius) * 0.5f; | ||
1055 | if (ppos > 0f) | ||
1056 | { | ||
1057 | if (!p1.Flying) | ||
1058 | { | ||
1059 | d.AABB aabb; | ||
1060 | d.GeomGetAABB(g2, out aabb); | ||
1061 | float tmp = vtmp.Z - sz * .18f; | ||
1062 | |||
1063 | if (aabb.MaxZ < tmp) | ||
1064 | { | ||
1065 | vtmp.X = curContact.pos.X - vtmp.X; | ||
1066 | vtmp.Y = curContact.pos.Y - vtmp.Y; | ||
1067 | vtmp.Z = -0.2f; | ||
1068 | vtmp.Normalize(); | ||
1069 | curContact.normal.X = vtmp.X; | ||
1070 | curContact.normal.Y = vtmp.Y; | ||
1071 | curContact.normal.Z = vtmp.Z; | ||
1072 | } | ||
1073 | } | ||
1074 | } | ||
1075 | else | ||
1076 | p1.IsColliding = true; | ||
1077 | 1036 | ||
1078 | } | 1037 | Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale); |
1038 | d.JointAttach(Joint, b1, b2); | ||
1079 | 1039 | ||
1080 | if (dop2foot) | 1040 | if (curContact.depth > maxContact.depth) |
1081 | { | 1041 | maxContact = curContact; |
1082 | float sz = p2.Size.Z; | ||
1083 | Vector3 vtmp = p2.Position; | ||
1084 | float ppos = curContact.pos.Z - vtmp.Z + (sz - avCapRadius) * 0.5f; | ||
1085 | if (ppos > 0f) | ||
1086 | { | ||
1087 | if (!p2.Flying) | ||
1088 | { | ||
1089 | d.AABB aabb; | ||
1090 | d.GeomGetAABB(g1, out aabb); | ||
1091 | float tmp = vtmp.Z - sz * .18f; | ||
1092 | |||
1093 | if (aabb.MaxZ < tmp) | ||
1094 | { | ||
1095 | vtmp.X = curContact.pos.X - vtmp.X; | ||
1096 | vtmp.Y = curContact.pos.Y - vtmp.Y; | ||
1097 | vtmp.Z = -0.2f; | ||
1098 | vtmp.Normalize(); | ||
1099 | curContact.normal.X = vtmp.X; | ||
1100 | curContact.normal.Y = vtmp.Y; | ||
1101 | curContact.normal.Z = vtmp.Z; | ||
1102 | } | ||
1103 | } | ||
1104 | } | ||
1105 | else | ||
1106 | p2.IsColliding = true; | ||
1107 | 1042 | ||
1108 | } | 1043 | if (curContact.depth < minContact.depth) |
1044 | minContact = curContact; | ||
1109 | } | 1045 | } |
1110 | } | 1046 | } |
1111 | 1047 | ||
1112 | Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale); | ||
1113 | d.JointAttach(Joint, b1, b2); | ||
1114 | |||
1115 | if (++m_global_contactcount >= maxContactsbeforedeath) | ||
1116 | break; | ||
1117 | |||
1118 | if (++i >= count) | 1048 | if (++i >= count) |
1119 | break; | 1049 | break; |
1120 | 1050 | ||
1121 | if (!GetCurContactGeom(i, ref curContact)) | 1051 | if (!GetCurContactGeom(i, ref curContact)) |
1122 | break; | 1052 | break; |
1123 | |||
1124 | if (curContact.depth > maxDepthContact.PenetrationDepth) | ||
1125 | { | ||
1126 | maxDepthContact.Position.X = curContact.pos.X; | ||
1127 | maxDepthContact.Position.Y = curContact.pos.Y; | ||
1128 | maxDepthContact.Position.Z = curContact.pos.Z; | ||
1129 | maxDepthContact.SurfaceNormal.X = curContact.normal.X; | ||
1130 | maxDepthContact.SurfaceNormal.Y = curContact.normal.Y; | ||
1131 | maxDepthContact.SurfaceNormal.Z = curContact.normal.Z; | ||
1132 | maxDepthContact.PenetrationDepth = curContact.depth; | ||
1133 | } | ||
1134 | } | 1053 | } |
1135 | } | ||
1136 | |||
1137 | collision_accounting_events(p1, p2, maxDepthContact); | ||
1138 | 1054 | ||
1139 | /* | 1055 | if (ncontacts > 0) |
1140 | if (notskipedcount > geomContactPointsStartthrottle) | ||
1141 | { | 1056 | { |
1142 | // If there are more then 3 contact points, it's likely | 1057 | ContactPoint maxDepthContact = new ContactPoint( |
1143 | // that we've got a pile of objects, so ... | 1058 | new Vector3(maxContact.pos.X, maxContact.pos.Y, maxContact.pos.Z), |
1144 | // We don't want to send out hundreds of terse updates over and over again | 1059 | new Vector3(minContact.normal.X, minContact.normal.Y, minContact.normal.Z), |
1145 | // so lets throttle them and send them again after it's somewhat sorted out. | 1060 | maxContact.depth, FeetCollision |
1146 | this needs checking so out for now | 1061 | ); |
1147 | if (b1 != IntPtr.Zero) | 1062 | collision_accounting_events(p1, p2, maxDepthContact); |
1148 | p1.ThrottleUpdates = true; | ||
1149 | if (b2 != IntPtr.Zero) | ||
1150 | p2.ThrottleUpdates = true; | ||
1151 | |||
1152 | } | 1063 | } |
1153 | */ | ||
1154 | } | 1064 | } |
1155 | 1065 | ||
1156 | private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) | 1066 | private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) |
@@ -1234,14 +1144,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1234 | { | 1144 | { |
1235 | foreach (OdeCharacter chr in _characters) | 1145 | foreach (OdeCharacter chr in _characters) |
1236 | { | 1146 | { |
1237 | if (chr == null || chr.Shell == IntPtr.Zero || chr.Body == IntPtr.Zero) | 1147 | if (chr == null || chr.Body == IntPtr.Zero) |
1238 | continue; | 1148 | continue; |
1239 | 1149 | ||
1240 | chr.IsColliding = false; | 1150 | chr.IsColliding = false; |
1241 | // chr.CollidingGround = false; not done here | 1151 | // chr.CollidingGround = false; not done here |
1242 | chr.CollidingObj = false; | 1152 | chr.CollidingObj = false; |
1243 | // do colisions with static space | 1153 | // do colisions with static space |
1244 | d.SpaceCollide2(StaticSpace, chr.Shell, IntPtr.Zero, nearCallback); | 1154 | d.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, nearCallback); |
1155 | |||
1156 | // chars with chars | ||
1157 | d.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback); | ||
1245 | // no coll with gnd | 1158 | // no coll with gnd |
1246 | } | 1159 | } |
1247 | } | 1160 | } |
@@ -1283,16 +1196,25 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1283 | m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); | 1196 | m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); |
1284 | } | 1197 | } |
1285 | } | 1198 | } |
1286 | // finally colide active things amoung them | 1199 | // colide active amoung them |
1287 | try | 1200 | try |
1288 | { | 1201 | { |
1289 | d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback); | 1202 | d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback); |
1290 | } | 1203 | } |
1291 | catch (AccessViolationException) | 1204 | catch (AccessViolationException) |
1292 | { | 1205 | { |
1206 | m_log.Warn("[PHYSICS]: Unable to collide Active with Characters space"); | ||
1207 | } | ||
1208 | // and with chars | ||
1209 | try | ||
1210 | { | ||
1211 | d.SpaceCollide2(CharsSpace,ActiveSpace, IntPtr.Zero, nearCallback); | ||
1212 | } | ||
1213 | catch (AccessViolationException) | ||
1214 | { | ||
1293 | m_log.Warn("[PHYSICS]: Unable to collide in Active space"); | 1215 | m_log.Warn("[PHYSICS]: Unable to collide in Active space"); |
1294 | } | 1216 | } |
1295 | // _perloopContact.Clear(); | 1217 | // _perloopContact.Clear(); |
1296 | } | 1218 | } |
1297 | 1219 | ||
1298 | #endregion | 1220 | #endregion |
@@ -1328,13 +1250,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1328 | 1250 | ||
1329 | #region Add/Remove Entities | 1251 | #region Add/Remove Entities |
1330 | 1252 | ||
1331 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) | 1253 | public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying) |
1332 | { | 1254 | { |
1333 | Vector3 pos; | 1255 | Vector3 pos; |
1334 | pos.X = position.X; | 1256 | pos.X = position.X; |
1335 | pos.Y = position.Y; | 1257 | pos.Y = position.Y; |
1336 | pos.Z = position.Z; | 1258 | pos.Z = position.Z; |
1337 | OdeCharacter newAv = new OdeCharacter(avName, this, pos, size, avPIDD, avPIDP, avCapRadius, avDensity, avMovementDivisorWalk, avMovementDivisorRun); | 1259 | OdeCharacter newAv = new OdeCharacter(localID,avName, this, pos, size, feetOffset, avDensity, avMovementDivisorWalk, avMovementDivisorRun); |
1338 | newAv.Flying = isFlying; | 1260 | newAv.Flying = isFlying; |
1339 | newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; | 1261 | newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; |
1340 | 1262 | ||
@@ -1777,7 +1699,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1777 | foreach (OdeCharacter actor in _characters) | 1699 | foreach (OdeCharacter actor in _characters) |
1778 | { | 1700 | { |
1779 | if (actor != null) | 1701 | if (actor != null) |
1780 | actor.Move(ODE_STEPSIZE, defects); | 1702 | actor.Move(defects); |
1781 | } | 1703 | } |
1782 | if (defects.Count != 0) | 1704 | if (defects.Count != 0) |
1783 | { | 1705 | { |
@@ -2788,5 +2710,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2788 | } | 2710 | } |
2789 | return new List<ContactResult>(); | 2711 | return new List<ContactResult>(); |
2790 | } | 2712 | } |
2713 | |||
2714 | public override int SitAvatar(PhysicsActor actor, Vector3 AbsolutePosition, Vector3 CameraPosition, Vector3 offset, Vector3 AvatarSize, SitAvatarCallback PhysicsSitResponse) | ||
2715 | { | ||
2716 | Util.FireAndForget( delegate | ||
2717 | { | ||
2718 | ODESitAvatar sitAvatar = new ODESitAvatar(this, m_rayCastManager); | ||
2719 | if(sitAvatar != null) | ||
2720 | sitAvatar.Sit(actor, AbsolutePosition, CameraPosition, offset, AvatarSize, PhysicsSitResponse); | ||
2721 | }); | ||
2722 | return 1; | ||
2723 | } | ||
2724 | |||
2791 | } | 2725 | } |
2792 | } | 2726 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 94fd940..6879ebb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -317,8 +317,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
317 | comms.DeleteListener(itemID); | 317 | comms.DeleteListener(itemID); |
318 | 318 | ||
319 | IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); | 319 | IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); |
320 | xmlrpc.DeleteChannels(itemID); | 320 | if (xmlrpc != null) |
321 | xmlrpc.CancelSRDRequests(itemID); | 321 | { |
322 | xmlrpc.DeleteChannels(itemID); | ||
323 | xmlrpc.CancelSRDRequests(itemID); | ||
324 | } | ||
322 | 325 | ||
323 | // Remove Sensors | 326 | // Remove Sensors |
324 | m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); | 327 | m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 07b7123..3a9d0ff 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -3013,7 +3013,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3013 | } | 3013 | } |
3014 | 3014 | ||
3015 | bool result = money.ObjectGiveMoney( | 3015 | bool result = money.ObjectGiveMoney( |
3016 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); | 3016 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount,UUID.Zero); |
3017 | 3017 | ||
3018 | if (result) | 3018 | if (result) |
3019 | return 1; | 3019 | return 1; |
@@ -6384,7 +6384,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6384 | } | 6384 | } |
6385 | else | 6385 | else |
6386 | { | 6386 | { |
6387 | agentSize = new LSL_Vector(0.45, 0.6, avatar.Appearance.AvatarHeight); | 6387 | // agentSize = new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight); |
6388 | Vector3 s = avatar.Appearance.AvatarSize; | ||
6389 | agentSize = new LSL_Vector(s.X, s.Y, s.Z); | ||
6388 | } | 6390 | } |
6389 | return agentSize; | 6391 | return agentSize; |
6390 | } | 6392 | } |
@@ -8598,8 +8600,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8598 | // and standing avatar since server 1.36 | 8600 | // and standing avatar since server 1.36 |
8599 | LSL_Vector lower; | 8601 | LSL_Vector lower; |
8600 | LSL_Vector upper; | 8602 | LSL_Vector upper; |
8603 | |||
8604 | Vector3 box = presence.Appearance.AvatarBoxSize * 0.5f; | ||
8605 | |||
8601 | if (presence.Animator.Animations.ImplicitDefaultAnimation.AnimID | 8606 | if (presence.Animator.Animations.ImplicitDefaultAnimation.AnimID |
8602 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 8607 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) |
8608 | /* | ||
8603 | { | 8609 | { |
8604 | // This is for ground sitting avatars | 8610 | // This is for ground sitting avatars |
8605 | float height = presence.Appearance.AvatarHeight / 2.66666667f; | 8611 | float height = presence.Appearance.AvatarHeight / 2.66666667f; |
@@ -8617,6 +8623,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8617 | // Adjust to the documented error offsets (see LSL Wiki) | 8623 | // Adjust to the documented error offsets (see LSL Wiki) |
8618 | lower += new LSL_Vector(0.05f, 0.05f, 0.05f); | 8624 | lower += new LSL_Vector(0.05f, 0.05f, 0.05f); |
8619 | upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); | 8625 | upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); |
8626 | */ | ||
8627 | { | ||
8628 | // This is for ground sitting avatars TODO! | ||
8629 | lower = new LSL_Vector(-box.X - 0.1125, -box.Y, box.Z * -1.0f); | ||
8630 | upper = new LSL_Vector(box.X + 0.1125, box.Y, box.Z * -1.0f); | ||
8631 | } | ||
8632 | else | ||
8633 | { | ||
8634 | // This is for standing/flying avatars | ||
8635 | lower = new LSL_Vector(-box.X, -box.Y, -box.Z); | ||
8636 | upper = new LSL_Vector(box.X, box.Y, box.Z); | ||
8637 | } | ||
8620 | 8638 | ||
8621 | if (lower.x > upper.x) | 8639 | if (lower.x > upper.x) |
8622 | lower.x = upper.x; | 8640 | lower.x = upper.x; |
@@ -12536,7 +12554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12536 | } | 12554 | } |
12537 | 12555 | ||
12538 | bool result = money.ObjectGiveMoney( | 12556 | bool result = money.ObjectGiveMoney( |
12539 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); | 12557 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount,UUID.Zero); |
12540 | 12558 | ||
12541 | if (result) | 12559 | if (result) |
12542 | { | 12560 | { |
@@ -12938,7 +12956,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12938 | 12956 | ||
12939 | case (int)ScriptBaseClass.PRIM_SIZE: | 12957 | case (int)ScriptBaseClass.PRIM_SIZE: |
12940 | // as in llGetAgentSize above | 12958 | // as in llGetAgentSize above |
12941 | res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight)); | 12959 | // res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight)); |
12960 | Vector3 s = avatar.Appearance.AvatarSize; | ||
12961 | res.Add(new LSL_Vector(s.X, s.Y, s.Z)); | ||
12962 | |||
12942 | break; | 12963 | break; |
12943 | 12964 | ||
12944 | case (int)ScriptBaseClass.PRIM_ROTATION: | 12965 | case (int)ScriptBaseClass.PRIM_ROTATION: |
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs index 0caa521..c0130f1 100644 --- a/OpenSim/Services/Interfaces/IAvatarService.cs +++ b/OpenSim/Services/Interfaces/IAvatarService.cs | |||
@@ -201,7 +201,13 @@ namespace OpenSim.Services.Interfaces | |||
201 | appearance.Serial = Int32.Parse(Data["Serial"]); | 201 | appearance.Serial = Int32.Parse(Data["Serial"]); |
202 | 202 | ||
203 | if (Data.ContainsKey("AvatarHeight")) | 203 | if (Data.ContainsKey("AvatarHeight")) |
204 | appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]); | 204 | { |
205 | float h = float.Parse(Data["AvatarHeight"]); | ||
206 | if( h == 0f) | ||
207 | h = 1.9f; | ||
208 | appearance.SetSize(new Vector3(0.45f, 0.6f, h )); | ||
209 | // appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]); | ||
210 | } | ||
205 | 211 | ||
206 | // Legacy Wearables | 212 | // Legacy Wearables |
207 | if (Data.ContainsKey("BodyItem")) | 213 | if (Data.ContainsKey("BodyItem")) |
@@ -339,6 +345,7 @@ namespace OpenSim.Services.Interfaces | |||
339 | appearance.Wearables[AvatarWearable.EYES].Wear( | 345 | appearance.Wearables[AvatarWearable.EYES].Wear( |
340 | AvatarWearable.DefaultWearables[ | 346 | AvatarWearable.DefaultWearables[ |
341 | AvatarWearable.EYES][0]); | 347 | AvatarWearable.EYES][0]); |
348 | |||
342 | } | 349 | } |
343 | catch | 350 | catch |
344 | { | 351 | { |