diff options
author | Melanie Thielker | 2014-10-03 18:27:27 +0200 |
---|---|---|
committer | Melanie Thielker | 2014-10-03 18:27:27 +0200 |
commit | 93fa3777d2de7d5d17039ee18014c9d73e13cbc5 (patch) | |
tree | a54caa4ae0003025024918088c1c88094c219663 | |
parent | Also store names of assets in the AnimationSet (diff) | |
parent | clean up coments, use a even faster XY move request detection (diff) | |
download | opensim-SC_OLD-93fa3777d2de7d5d17039ee18014c9d73e13cbc5.zip opensim-SC_OLD-93fa3777d2de7d5d17039ee18014c9d73e13cbc5.tar.gz opensim-SC_OLD-93fa3777d2de7d5d17039ee18014c9d73e13cbc5.tar.bz2 opensim-SC_OLD-93fa3777d2de7d5d17039ee18014c9d73e13cbc5.tar.xz |
Merge branch 'ubitworkmaster'
11 files changed, 637 insertions, 309 deletions
diff --git a/OpenSim/Framework/AnimationSet.cs b/OpenSim/Framework/AnimationSet.cs index fa71405..6c5b15c 100644 --- a/OpenSim/Framework/AnimationSet.cs +++ b/OpenSim/Framework/AnimationSet.cs | |||
@@ -37,6 +37,54 @@ namespace OpenSim.Framework | |||
37 | { | 37 | { |
38 | private bool m_parseError = false; | 38 | private bool m_parseError = false; |
39 | 39 | ||
40 | public const uint createBasePermitions = (uint)(PermissionMask.All); // no export ? | ||
41 | public const uint createNextPermitions = (uint)(PermissionMask.Copy | PermissionMask.Modify); | ||
42 | |||
43 | public const uint allowedBasePermitions = (uint)(PermissionMask.Copy | PermissionMask.Modify); | ||
44 | public const uint allowedNextPermitions = 0; | ||
45 | |||
46 | public static void setCreateItemPermitions(InventoryItemBase it) | ||
47 | { | ||
48 | if (it == null) | ||
49 | return; | ||
50 | |||
51 | it.BasePermissions = createBasePermitions; | ||
52 | it.CurrentPermissions = createBasePermitions; | ||
53 | // it.GroupPermissions &= allowedPermitions; | ||
54 | it.NextPermissions = createNextPermitions; | ||
55 | // it.EveryOnePermissions &= allowedPermitions; | ||
56 | it.GroupPermissions = 0; | ||
57 | it.EveryOnePermissions = 0; | ||
58 | } | ||
59 | |||
60 | public static void enforceItemPermitions(InventoryItemBase it, bool IsCreator) | ||
61 | { | ||
62 | if (it == null) | ||
63 | return; | ||
64 | |||
65 | uint bp; | ||
66 | uint np; | ||
67 | |||
68 | if (IsCreator) | ||
69 | { | ||
70 | bp = createBasePermitions; | ||
71 | np = createNextPermitions; | ||
72 | } | ||
73 | else | ||
74 | { | ||
75 | bp = allowedBasePermitions; | ||
76 | np = allowedNextPermitions; | ||
77 | } | ||
78 | |||
79 | it.BasePermissions &= bp; | ||
80 | it.CurrentPermissions &= bp; | ||
81 | // it.GroupPermissions &= allowedPermitions; | ||
82 | it.NextPermissions &= np; | ||
83 | // it.EveryOnePermissions &= allowedPermitions; | ||
84 | it.GroupPermissions = 0; | ||
85 | it.EveryOnePermissions = 0; | ||
86 | } | ||
87 | |||
40 | public int AnimationCount { get; private set; } | 88 | public int AnimationCount { get; private set; } |
41 | private Dictionary<string, KeyValuePair<string, UUID>> m_animations = new Dictionary<string, KeyValuePair<string, UUID>>(); | 89 | private Dictionary<string, KeyValuePair<string, UUID>> m_animations = new Dictionary<string, KeyValuePair<string, UUID>>(); |
42 | 90 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 0e38d05..75634e0 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -1125,10 +1125,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1125 | 1125 | ||
1126 | if (inType == (sbyte)CustomInventoryType.AnimationSet) | 1126 | if (inType == (sbyte)CustomInventoryType.AnimationSet) |
1127 | { | 1127 | { |
1128 | item.BasePermissions = (uint)(PermissionMask.Copy | PermissionMask.Modify); | 1128 | AnimationSet.setCreateItemPermitions(item); |
1129 | item.CurrentPermissions = (uint)(PermissionMask.Copy| PermissionMask.Modify); | ||
1130 | item.EveryOnePermissions = 0; | ||
1131 | item.NextPermissions = 0; | ||
1132 | } | 1129 | } |
1133 | 1130 | ||
1134 | else if (restrictPerms) | 1131 | else if (restrictPerms) |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 12ee3b2..6385aed 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -607,7 +607,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
607 | 607 | ||
608 | // Disable UDP handling for this client | 608 | // Disable UDP handling for this client |
609 | m_udpClient.Shutdown(); | 609 | m_udpClient.Shutdown(); |
610 | 610 | ||
611 | 611 | ||
612 | //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 612 | //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
613 | //GC.Collect(); | 613 | //GC.Collect(); |
@@ -4912,6 +4912,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4912 | IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>(); | 4912 | IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>(); |
4913 | if (eq != null) | 4913 | if (eq != null) |
4914 | { | 4914 | { |
4915 | |||
4915 | OSD message_body = updateMessage.Serialize(); | 4916 | OSD message_body = updateMessage.Serialize(); |
4916 | // Add new fields here until OMV has them | 4917 | // Add new fields here until OMV has them |
4917 | OSDMap bodyMap = (OSDMap)message_body; | 4918 | OSDMap bodyMap = (OSDMap)message_body; |
@@ -4923,8 +4924,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4923 | OSDMap message = new OSDMap(); | 4924 | OSDMap message = new OSDMap(); |
4924 | message.Add("message", OSD.FromString("ParcelProperties")); | 4925 | message.Add("message", OSD.FromString("ParcelProperties")); |
4925 | message.Add("body", message_body); | 4926 | message.Add("body", message_body); |
4927 | |||
4926 | eq.Enqueue (message, this.AgentId); | 4928 | eq.Enqueue (message, this.AgentId); |
4927 | //eq.ParcelProperties(updateMessage, this.AgentId); | 4929 | |
4930 | // eq.ParcelProperties(updateMessage, this.AgentId); | ||
4928 | } | 4931 | } |
4929 | else | 4932 | else |
4930 | { | 4933 | { |
@@ -12420,8 +12423,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
12420 | uint regionY = 0; | 12423 | uint regionY = 0; |
12421 | 12424 | ||
12422 | Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY); | 12425 | Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY); |
12423 | locx = Convert.ToSingle(args[0]) - (float)regionX; | 12426 | locx = (float)(Convert.ToDouble(args[0]) - (double)regionX); |
12424 | locy = Convert.ToSingle(args[1]) - (float)regionY; | 12427 | locy = (float)(Convert.ToDouble(args[1]) - (double)regionY); |
12425 | locz = Convert.ToSingle(args[2]); | 12428 | locz = Convert.ToSingle(args[2]); |
12426 | 12429 | ||
12427 | Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo; | 12430 | Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo; |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 94782f9..64a9610 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -178,7 +178,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
178 | sbyte assetType, | 178 | sbyte assetType, |
179 | byte wearableType, uint nextOwnerMask, int creationDate) | 179 | byte wearableType, uint nextOwnerMask, int creationDate) |
180 | { | 180 | { |
181 | m_log.DebugFormat("[INVENTORY ACCESS MODULE]: Received request to create inventory item {0} in folder {1}", name, folderID); | 181 | m_log.DebugFormat("[INVENTORY ACCESS MODULE]: Received request to create inventory item {0} in folder {1}, transactionID {2}", name, |
182 | folderID, transactionID); | ||
182 | 183 | ||
183 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) | 184 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) |
184 | return; | 185 | return; |
@@ -219,7 +220,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
219 | m_Scene.AssetService.Store(asset); | 220 | m_Scene.AssetService.Store(asset); |
220 | m_Scene.CreateNewInventoryItem( | 221 | m_Scene.CreateNewInventoryItem( |
221 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, | 222 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, |
222 | name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate,transactionID); | 223 | name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate,transactionID); |
223 | } | 224 | } |
224 | else | 225 | else |
225 | { | 226 | { |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index c8555ab..bbb280b 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -1200,32 +1200,30 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1200 | { | 1200 | { |
1201 | //the proprieties to who changed them | 1201 | //the proprieties to who changed them |
1202 | 1202 | ||
1203 | land.SendLandProperties(0, true, LandChannel.LAND_RESULT_SINGLE, remote_client); | 1203 | land.SendLandProperties(0, false, LandChannel.LAND_RESULT_SINGLE, remote_client); |
1204 | 1204 | ||
1205 | if (needOverlay) | 1205 | UUID parcelID = land.LandData.GlobalID; |
1206 | { | 1206 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) |
1207 | UUID parcelID = land.LandData.GlobalID; | 1207 | { |
1208 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) | 1208 | if (avatar.IsDeleted || avatar.isNPC) |
1209 | { | 1209 | return; |
1210 | if (avatar.IsDeleted || avatar.isNPC) | ||
1211 | return; | ||
1212 | 1210 | ||
1213 | IClientAPI client = avatar.ControllingClient; | 1211 | IClientAPI client = avatar.ControllingClient; |
1212 | if (needOverlay) | ||
1214 | SendParcelOverlay(client); | 1213 | SendParcelOverlay(client); |
1215 | 1214 | ||
1216 | if (avatar.IsChildAgent) | 1215 | if (avatar.IsChildAgent) |
1217 | return; | 1216 | return; |
1218 | 1217 | ||
1219 | ILandObject aland = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 1218 | ILandObject aland = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); |
1220 | if (aland != null) | 1219 | if (aland != null) |
1221 | { | 1220 | { |
1222 | if (client != remote_client || land != aland) | 1221 | if (client != remote_client || land != aland) |
1223 | aland.SendLandProperties(0, false, LandChannel.LAND_RESULT_SINGLE, client); | 1222 | aland.SendLandProperties(0, false, LandChannel.LAND_RESULT_SINGLE, client); |
1224 | } | 1223 | } |
1225 | if (avatar.currentParcelUUID == parcelID) | 1224 | if (avatar.currentParcelUUID == parcelID) |
1226 | avatar.currentParcelUUID = parcelID; // force parcel flags review | 1225 | avatar.currentParcelUUID = parcelID; // force parcel flags review |
1227 | }); | 1226 | }); |
1228 | } | ||
1229 | } | 1227 | } |
1230 | } | 1228 | } |
1231 | 1229 | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index e002feb..a3cd4a5 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -1244,6 +1244,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1244 | public void SetMediaUrl(string url) | 1244 | public void SetMediaUrl(string url) |
1245 | { | 1245 | { |
1246 | LandData.MediaURL = url; | 1246 | LandData.MediaURL = url; |
1247 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, LandData); | ||
1247 | SendLandUpdateToAvatarsOverMe(); | 1248 | SendLandUpdateToAvatarsOverMe(); |
1248 | } | 1249 | } |
1249 | 1250 | ||
@@ -1254,6 +1255,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1254 | public void SetMusicUrl(string url) | 1255 | public void SetMusicUrl(string url) |
1255 | { | 1256 | { |
1256 | LandData.MusicURL = url; | 1257 | LandData.MusicURL = url; |
1258 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, LandData); | ||
1257 | SendLandUpdateToAvatarsOverMe(); | 1259 | SendLandUpdateToAvatarsOverMe(); |
1258 | } | 1260 | } |
1259 | 1261 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index db3b834..2d1b0df 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
48 | 48 | ||
49 | public AnimationSet Animations | 49 | public AnimationSet Animations |
50 | { | 50 | { |
51 | get { return m_animations; } | 51 | get { return m_animations; } |
52 | } | 52 | } |
53 | protected AnimationSet m_animations = new AnimationSet(); | 53 | protected AnimationSet m_animations = new AnimationSet(); |
54 | 54 | ||
@@ -56,25 +56,27 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
56 | /// The current movement animation | 56 | /// The current movement animation |
57 | /// </value> | 57 | /// </value> |
58 | public string CurrentMovementAnimation { get; private set; } | 58 | public string CurrentMovementAnimation { get; private set; } |
59 | 59 | ||
60 | private int m_animTickFall; | 60 | private int m_animTickFall; |
61 | public int m_animTickJump; // ScenePresence has to see this to control +Z force | 61 | private int m_animTickLand; |
62 | public bool m_jumping = false; | 62 | private int m_animTickJump; |
63 | public float m_jumpVelocity = 0f; | 63 | |
64 | // private int m_landing = 0; | 64 | public bool m_jumping = false; |
65 | |||
66 | // private int m_landing = 0; | ||
65 | 67 | ||
66 | /// <summary> | 68 | /// <summary> |
67 | /// Is the avatar falling? | 69 | /// Is the avatar falling? |
68 | /// </summary> | 70 | /// </summary> |
69 | public bool Falling { get; private set; } | 71 | public bool Falling { get; private set; } |
70 | 72 | ||
71 | private float m_fallHeight; | 73 | private float m_lastFallVelocity; |
72 | 74 | ||
73 | /// <value> | 75 | /// <value> |
74 | /// The scene presence that this animator applies to | 76 | /// The scene presence that this animator applies to |
75 | /// </value> | 77 | /// </value> |
76 | protected ScenePresence m_scenePresence; | 78 | protected ScenePresence m_scenePresence; |
77 | 79 | ||
78 | public ScenePresenceAnimator(ScenePresence sp) | 80 | public ScenePresenceAnimator(ScenePresence sp) |
79 | { | 81 | { |
80 | m_scenePresence = sp; | 82 | m_scenePresence = sp; |
@@ -89,7 +91,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
89 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); | 91 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); |
90 | if (m_scenePresence.Scene.DebugAnimations) | 92 | if (m_scenePresence.Scene.DebugAnimations) |
91 | m_log.DebugFormat( | 93 | m_log.DebugFormat( |
92 | "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", | 94 | "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", |
93 | GetAnimName(animID), animID, m_scenePresence.Name); | 95 | GetAnimName(animID), animID, m_scenePresence.Name); |
94 | 96 | ||
95 | if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) | 97 | if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) |
@@ -111,7 +113,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
111 | if (animID == UUID.Zero) | 113 | if (animID == UUID.Zero) |
112 | return; | 114 | return; |
113 | 115 | ||
114 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", animID, name, m_scenePresence.Name); | 116 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", animID, name, m_scenePresence.Name); |
115 | 117 | ||
116 | AddAnimation(animID, objectID); | 118 | AddAnimation(animID, objectID); |
117 | } | 119 | } |
@@ -131,7 +133,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
131 | 133 | ||
132 | if (m_scenePresence.Scene.DebugAnimations) | 134 | if (m_scenePresence.Scene.DebugAnimations) |
133 | m_log.DebugFormat( | 135 | m_log.DebugFormat( |
134 | "[SCENE PRESENCE ANIMATOR]: Removing animation {0} {1} for {2}", | 136 | "[SCENE PRESENCE ANIMATOR]: Removing animation {0} {1} for {2}", |
135 | GetAnimName(animID), animID, m_scenePresence.Name); | 137 | GetAnimName(animID), animID, m_scenePresence.Name); |
136 | 138 | ||
137 | if (m_animations.Remove(animID, allowNoDefault)) | 139 | if (m_animations.Remove(animID, allowNoDefault)) |
@@ -153,7 +155,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
153 | else | 155 | else |
154 | m_animations.Remove(animID, false); | 156 | m_animations.Remove(animID, false); |
155 | } | 157 | } |
156 | if(sendPack) | 158 | if (sendPack) |
157 | SendAnimPack(); | 159 | SendAnimPack(); |
158 | } | 160 | } |
159 | 161 | ||
@@ -205,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
205 | 207 | ||
206 | if (aoSitGndAnim != UUID.Zero) | 208 | if (aoSitGndAnim != UUID.Zero) |
207 | { | 209 | { |
208 | avnChangeAnim(aoSitGndAnim, false, false); | 210 | avnChangeAnim(aoSitGndAnim, false, true); |
209 | aoSitGndAnim = UUID.Zero; | 211 | aoSitGndAnim = UUID.Zero; |
210 | } | 212 | } |
211 | 213 | ||
@@ -238,9 +240,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
238 | if (m_animations.TrySetDefaultAnimation( | 240 | if (m_animations.TrySetDefaultAnimation( |
239 | anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) | 241 | anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) |
240 | { | 242 | { |
241 | // m_log.DebugFormat( | 243 | // m_log.DebugFormat( |
242 | // "[SCENE PRESENCE ANIMATOR]: Updating movement animation to {0} for {1}", | 244 | // "[SCENE PRESENCE ANIMATOR]: Updating movement animation to {0} for {1}", |
243 | // anim, m_scenePresence.Name); | 245 | // anim, m_scenePresence.Name); |
244 | 246 | ||
245 | // 16384 is CHANGED_ANIMATION | 247 | // 16384 is CHANGED_ANIMATION |
246 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION }); | 248 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION }); |
@@ -258,83 +260,119 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
258 | return ret; | 260 | return ret; |
259 | } | 261 | } |
260 | 262 | ||
263 | public enum motionControlStates : byte | ||
264 | { | ||
265 | sitted = 0, | ||
266 | flying, | ||
267 | falling, | ||
268 | jumping, | ||
269 | landing, | ||
270 | onsurface | ||
271 | } | ||
272 | |||
273 | public motionControlStates currentControlState = motionControlStates.onsurface; | ||
274 | |||
261 | /// <summary> | 275 | /// <summary> |
262 | /// This method determines the proper movement related animation | 276 | /// This method determines the proper movement related animation |
263 | /// </summary> | 277 | /// </summary> |
264 | private string DetermineMovementAnimation() | 278 | private string DetermineMovementAnimation() |
265 | { | 279 | { |
266 | const float FALL_DELAY = 800f; | 280 | const int FALL_DELAY = 800; |
267 | const float PREJUMP_DELAY = 200f; | 281 | const int PREJUMP_DELAY = 200; |
268 | const float JUMP_PERIOD = 800f; | 282 | const int JUMP_PERIOD = 800; |
269 | #region Inputs | 283 | #region Inputs |
270 | 284 | ||
285 | if (m_scenePresence.IsInTransit) | ||
286 | return CurrentMovementAnimation; | ||
287 | |||
271 | if (m_scenePresence.SitGround) | 288 | if (m_scenePresence.SitGround) |
289 | { | ||
290 | currentControlState = motionControlStates.sitted; | ||
272 | return "SITGROUND"; | 291 | return "SITGROUND"; |
292 | } | ||
273 | if (m_scenePresence.ParentID != 0 || m_scenePresence.ParentUUID != UUID.Zero) | 293 | if (m_scenePresence.ParentID != 0 || m_scenePresence.ParentUUID != UUID.Zero) |
294 | { | ||
295 | currentControlState = motionControlStates.sitted; | ||
274 | return "SIT"; | 296 | return "SIT"; |
297 | } | ||
275 | 298 | ||
276 | AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; | 299 | AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; |
277 | PhysicsActor actor = m_scenePresence.PhysicsActor; | 300 | PhysicsActor actor = m_scenePresence.PhysicsActor; |
278 | 301 | ||
279 | // Create forward and left vectors from the current avatar rotation | 302 | const AgentManager.ControlFlags ANYXYMASK = ( |
280 | Matrix4 rotMatrix = Matrix4.CreateFromQuaternion(m_scenePresence.Rotation); | 303 | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | |
281 | Vector3 fwd = Vector3.Transform(Vector3.UnitX, rotMatrix); | 304 | AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG | |
282 | Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); | 305 | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS | |
306 | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | ||
307 | ); | ||
283 | 308 | ||
284 | // Check control flags | 309 | // Check control flags |
285 | bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS); | 310 | /* not in use |
286 | bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); | 311 | bool heldForward = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS)) != 0); |
287 | bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); | 312 | bool heldBack = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG)) != 0); |
288 | bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG); | 313 | bool heldLeft = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS)) != 0); |
314 | bool heldRight = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG)) != 0); | ||
315 | */ | ||
289 | bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; | 316 | bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; |
290 | bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; | 317 | bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; |
291 | bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; | 318 | // bool heldUp = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS)) != 0); |
292 | bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; | 319 | // excluded nudge up so it doesn't trigger jump state |
320 | bool heldUp = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_POS)) != 0); | ||
321 | bool heldDown = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG)) != 0); | ||
293 | //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; | 322 | //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; |
294 | //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK; | 323 | //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK; |
295 | if (heldForward || heldBack || heldLeft || heldRight || heldUp || heldDown) | 324 | |
325 | bool heldOnXY = ((controlFlags & ANYXYMASK) != 0); | ||
326 | if (heldOnXY || heldUp || heldDown) | ||
296 | { | 327 | { |
297 | heldTurnLeft = false; | 328 | heldTurnLeft = false; |
298 | heldTurnRight = false; | 329 | heldTurnRight = false; |
299 | } | 330 | } |
300 | 331 | ||
301 | // Direction in which the avatar is trying to move | ||
302 | Vector3 move = Vector3.Zero; | ||
303 | if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } | ||
304 | if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } | ||
305 | if (heldLeft) { move.X += left.X; move.Y += left.Y; } | ||
306 | if (heldRight) { move.X -= left.X; move.Y -= left.Y; } | ||
307 | if (heldUp) { move.Z += 1; } | ||
308 | if (heldDown) { move.Z -= 1; } | ||
309 | |||
310 | // Is the avatar trying to move? | ||
311 | // bool moving = (move != Vector3.Zero); | ||
312 | #endregion Inputs | 332 | #endregion Inputs |
313 | 333 | ||
334 | // no physics actor case | ||
335 | if (actor == null) | ||
336 | { | ||
337 | // well what to do? | ||
338 | |||
339 | currentControlState = motionControlStates.onsurface; | ||
340 | if (heldOnXY) | ||
341 | return "WALK"; | ||
342 | |||
343 | return "STAND"; | ||
344 | } | ||
345 | |||
314 | #region Flying | 346 | #region Flying |
315 | 347 | ||
316 | if (actor != null && actor.Flying) | 348 | bool isColliding = actor.IsColliding; |
349 | |||
350 | if (actor.Flying) | ||
317 | { | 351 | { |
318 | m_animTickFall = 0; | 352 | m_animTickFall = 0; |
319 | m_animTickJump = 0; | 353 | m_animTickJump = 0; |
320 | m_jumping = false; | 354 | m_jumping = false; |
321 | Falling = false; | 355 | Falling = false; |
322 | m_jumpVelocity = 0f; | ||
323 | actor.Selected = false; | ||
324 | m_fallHeight = actor.Position.Z; // save latest flying height | ||
325 | 356 | ||
326 | if (move.X != 0f || move.Y != 0f) | 357 | currentControlState = motionControlStates.flying; |
358 | |||
359 | if (heldOnXY) | ||
327 | { | 360 | { |
328 | return (m_scenePresence.Scene.m_useFlySlow ? "FLYSLOW" : "FLY"); | 361 | return (m_scenePresence.Scene.m_useFlySlow ? "FLYSLOW" : "FLY"); |
329 | } | 362 | } |
330 | else if (move.Z > 0f) | 363 | else if (heldUp) |
331 | { | 364 | { |
332 | return "HOVER_UP"; | 365 | return "HOVER_UP"; |
333 | } | 366 | } |
334 | else if (move.Z < 0f) | 367 | else if (heldDown) |
335 | { | 368 | { |
336 | if (actor != null && actor.IsColliding) | 369 | if (isColliding) |
370 | { | ||
371 | actor.Flying = false; | ||
372 | currentControlState = motionControlStates.landing; | ||
373 | m_animTickLand = Environment.TickCount; | ||
337 | return "LAND"; | 374 | return "LAND"; |
375 | } | ||
338 | else | 376 | else |
339 | return "HOVER_DOWN"; | 377 | return "HOVER_DOWN"; |
340 | } | 378 | } |
@@ -343,81 +381,88 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
343 | return "HOVER"; | 381 | return "HOVER"; |
344 | } | 382 | } |
345 | } | 383 | } |
384 | else | ||
385 | { | ||
386 | if (isColliding && currentControlState == motionControlStates.flying) | ||
387 | { | ||
388 | currentControlState = motionControlStates.landing; | ||
389 | m_animTickLand = Environment.TickCount; | ||
390 | return "LAND"; | ||
391 | } | ||
392 | } | ||
346 | 393 | ||
347 | #endregion Flying | 394 | #endregion Flying |
348 | 395 | ||
349 | #region Falling/Floating/Landing | 396 | #region Falling/Floating/Landing |
350 | 397 | ||
351 | if ((actor == null || !actor.IsColliding) && !m_jumping) | 398 | if (!isColliding && currentControlState != motionControlStates.jumping) |
352 | { | 399 | { |
353 | float fallElapsed = (float)(Environment.TickCount - m_animTickFall); | 400 | float fallVelocity = actor.Velocity.Z; |
354 | float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; | ||
355 | 401 | ||
356 | if (!m_jumping && (fallVelocity < -3.0f)) | 402 | if (fallVelocity < -2.5f) |
357 | Falling = true; | 403 | Falling = true; |
358 | 404 | ||
359 | if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) | 405 | if (m_animTickFall == 0 || (fallVelocity >= -0.5f)) |
360 | { | 406 | { |
361 | // not falling yet, or going up | ||
362 | // reset start of fall time | ||
363 | m_animTickFall = Environment.TickCount; | 407 | m_animTickFall = Environment.TickCount; |
364 | } | 408 | } |
365 | else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.WasFlying)) | 409 | else |
366 | { | 410 | { |
367 | // Falling long enough to trigger the animation | 411 | int fallElapsed = (Environment.TickCount - m_animTickFall); |
368 | return "FALLDOWN"; | 412 | if ((fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f)) |
413 | { | ||
414 | currentControlState = motionControlStates.falling; | ||
415 | m_lastFallVelocity = fallVelocity; | ||
416 | // Falling long enough to trigger the animation | ||
417 | return "FALLDOWN"; | ||
418 | } | ||
369 | } | 419 | } |
370 | 420 | ||
371 | // Check if the user has stopped walking just now | 421 | // Check if the user has stopped walking just now |
372 | if (CurrentMovementAnimation == "WALK" && (move == Vector3.Zero)) | 422 | if (CurrentMovementAnimation == "WALK" && !heldOnXY && !heldDown && !heldUp) |
373 | return "STAND"; | 423 | return "STAND"; |
374 | 424 | ||
375 | return CurrentMovementAnimation; | 425 | return CurrentMovementAnimation; |
376 | } | 426 | } |
377 | 427 | ||
378 | #endregion Falling/Floating/Landing | 428 | m_animTickFall = 0; |
379 | 429 | ||
430 | #endregion Falling/Floating/Landing | ||
380 | 431 | ||
381 | #region Jumping // section added for jumping... | 432 | #region Jumping // section added for jumping... |
382 | 433 | ||
383 | int jumptime; | 434 | if (isColliding && heldUp && currentControlState != motionControlStates.jumping) |
384 | jumptime = Environment.TickCount - m_animTickJump; | 435 | { |
385 | |||
386 | if ((move.Z > 0f) && (!m_jumping)) | ||
387 | { | ||
388 | // Start jumping, prejump | 436 | // Start jumping, prejump |
389 | m_animTickFall = 0; | 437 | currentControlState = motionControlStates.jumping; |
390 | m_jumping = true; | 438 | m_jumping = true; |
391 | Falling = false; | 439 | Falling = false; |
392 | actor.Selected = true; // borrowed for jumping flag | ||
393 | m_animTickJump = Environment.TickCount; | 440 | m_animTickJump = Environment.TickCount; |
394 | m_jumpVelocity = 0.35f; | ||
395 | return "PREJUMP"; | 441 | return "PREJUMP"; |
396 | } | 442 | } |
397 | 443 | ||
398 | if (m_jumping) | 444 | if (currentControlState == motionControlStates.jumping) |
399 | { | 445 | { |
446 | int jumptime = Environment.TickCount - m_animTickJump; | ||
400 | if ((jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) | 447 | if ((jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) |
401 | { | 448 | { |
402 | // end jumping | 449 | // end jumping |
403 | m_jumping = false; | 450 | m_jumping = false; |
404 | Falling = false; | 451 | Falling = false; |
405 | actor.Selected = false; // borrowed for jumping flag | 452 | actor.Selected = false; // borrowed for jumping flag |
406 | m_jumpVelocity = 0f; | 453 | m_animTickLand = Environment.TickCount; |
407 | m_animTickFall = Environment.TickCount; | 454 | currentControlState = motionControlStates.landing; |
408 | return "LAND"; | 455 | return "LAND"; |
409 | } | 456 | } |
410 | else if (jumptime > JUMP_PERIOD) | 457 | else if (jumptime > JUMP_PERIOD) |
411 | { | 458 | { |
412 | // jump down | 459 | // jump down |
413 | m_jumpVelocity = 0f; | ||
414 | return "JUMP"; | 460 | return "JUMP"; |
415 | } | 461 | } |
416 | else if (jumptime > PREJUMP_DELAY) | 462 | else if (jumptime > PREJUMP_DELAY) |
417 | { | 463 | { |
418 | // jump up | 464 | // jump up |
419 | m_jumping = true; | 465 | m_jumping = true; |
420 | m_jumpVelocity = 10f; | ||
421 | return "JUMP"; | 466 | return "JUMP"; |
422 | } | 467 | } |
423 | } | 468 | } |
@@ -426,45 +471,52 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
426 | 471 | ||
427 | #region Ground Movement | 472 | #region Ground Movement |
428 | 473 | ||
429 | if (CurrentMovementAnimation == "FALLDOWN") | 474 | if (currentControlState == motionControlStates.falling) |
430 | { | 475 | { |
431 | Falling = false; | 476 | Falling = false; |
432 | m_animTickFall = Environment.TickCount; | 477 | currentControlState = motionControlStates.landing; |
478 | m_animTickLand = Environment.TickCount; | ||
433 | // TODO: SOFT_LAND support | 479 | // TODO: SOFT_LAND support |
434 | float fallHeight = m_fallHeight - actor.Position.Z; | 480 | float fallVsq = m_lastFallVelocity * m_lastFallVelocity; |
435 | if (fallHeight > 15.0f) | 481 | if (fallVsq > 300f) // aprox 20*h |
436 | return "STANDUP"; | 482 | return "STANDUP"; |
437 | else if (fallHeight > 8.0f) | 483 | else if (fallVsq > 160f) |
438 | return "SOFT_LAND"; | 484 | return "SOFT_LAND"; |
439 | else | 485 | else |
440 | return "LAND"; | 486 | return "LAND"; |
441 | } | 487 | } |
442 | else if ((CurrentMovementAnimation == "LAND") || (CurrentMovementAnimation == "SOFT_LAND") || (CurrentMovementAnimation == "STANDUP")) | 488 | |
489 | |||
490 | if (currentControlState == motionControlStates.landing) | ||
443 | { | 491 | { |
444 | int landElapsed = Environment.TickCount - m_animTickFall; | 492 | Falling = false; |
493 | int landElapsed = Environment.TickCount - m_animTickLand; | ||
445 | int limit = 1000; | 494 | int limit = 1000; |
446 | if (CurrentMovementAnimation == "LAND") | 495 | if (CurrentMovementAnimation == "LAND") |
447 | limit = 350; | 496 | limit = 350; |
448 | // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client | 497 | // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client |
449 | 498 | ||
450 | if ((m_animTickFall != 0) && (landElapsed <= limit)) | 499 | if ((m_animTickLand != 0) && (landElapsed <= limit)) |
451 | { | 500 | { |
452 | return CurrentMovementAnimation; | 501 | return CurrentMovementAnimation; |
453 | } | 502 | } |
454 | else | 503 | else |
455 | { | 504 | { |
456 | m_fallHeight = actor.Position.Z; // save latest flying height | 505 | currentControlState = motionControlStates.onsurface; |
506 | m_animTickLand = 0; | ||
457 | return "STAND"; | 507 | return "STAND"; |
458 | } | 508 | } |
459 | } | 509 | } |
460 | 510 | ||
511 | |||
461 | // next section moved outside paren. and realigned for jumping | 512 | // next section moved outside paren. and realigned for jumping |
462 | if (move.X != 0f || move.Y != 0f) | 513 | |
514 | if (heldOnXY) | ||
463 | { | 515 | { |
464 | m_fallHeight = actor.Position.Z; // save latest flying height | 516 | currentControlState = motionControlStates.onsurface; |
465 | Falling = false; | 517 | Falling = false; |
466 | // Walking / crouchwalking / running | 518 | // Walking / crouchwalking / running |
467 | if (move.Z < 0f) | 519 | if (heldDown) |
468 | { | 520 | { |
469 | return "CROUCHWALK"; | 521 | return "CROUCHWALK"; |
470 | } | 522 | } |
@@ -480,9 +532,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
480 | } | 532 | } |
481 | else if (!m_jumping) | 533 | else if (!m_jumping) |
482 | { | 534 | { |
535 | currentControlState = motionControlStates.onsurface; | ||
483 | Falling = false; | 536 | Falling = false; |
484 | // Not walking | 537 | // Not walking |
485 | if (move.Z < 0) | 538 | if(heldDown) |
486 | return "CROUCH"; | 539 | return "CROUCH"; |
487 | else if (heldTurnLeft) | 540 | else if (heldTurnLeft) |
488 | return "TURNLEFT"; | 541 | return "TURNLEFT"; |
@@ -493,8 +546,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
493 | } | 546 | } |
494 | #endregion Ground Movement | 547 | #endregion Ground Movement |
495 | 548 | ||
496 | Falling = false; | ||
497 | |||
498 | return CurrentMovementAnimation; | 549 | return CurrentMovementAnimation; |
499 | } | 550 | } |
500 | 551 | ||
@@ -504,7 +555,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
504 | /// <returns>'true' if the animation was changed</returns> | 555 | /// <returns>'true' if the animation was changed</returns> |
505 | public bool UpdateMovementAnimations() | 556 | public bool UpdateMovementAnimations() |
506 | { | 557 | { |
507 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Updating movement animations for {0}", m_scenePresence.Name); | 558 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Updating movement animations for {0}", m_scenePresence.Name); |
508 | 559 | ||
509 | bool ret = false; | 560 | bool ret = false; |
510 | lock (m_animations) | 561 | lock (m_animations) |
@@ -552,19 +603,19 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
552 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); | 603 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); |
553 | return animIDs; | 604 | return animIDs; |
554 | } | 605 | } |
555 | 606 | ||
556 | public BinBVHAnimation GenerateRandomAnimation() | 607 | public BinBVHAnimation GenerateRandomAnimation() |
557 | { | 608 | { |
558 | int rnditerations = 3; | 609 | int rnditerations = 3; |
559 | BinBVHAnimation anim = new BinBVHAnimation(); | 610 | BinBVHAnimation anim = new BinBVHAnimation(); |
560 | List<string> parts = new List<string>(); | 611 | List<string> parts = new List<string>(); |
561 | parts.Add("mPelvis");parts.Add("mHead");parts.Add("mTorso"); | 612 | parts.Add("mPelvis"); parts.Add("mHead"); parts.Add("mTorso"); |
562 | parts.Add("mHipLeft");parts.Add("mHipRight");parts.Add("mHipLeft");parts.Add("mKneeLeft"); | 613 | parts.Add("mHipLeft"); parts.Add("mHipRight"); parts.Add("mHipLeft"); parts.Add("mKneeLeft"); |
563 | parts.Add("mKneeRight");parts.Add("mCollarLeft");parts.Add("mCollarRight");parts.Add("mNeck"); | 614 | parts.Add("mKneeRight"); parts.Add("mCollarLeft"); parts.Add("mCollarRight"); parts.Add("mNeck"); |
564 | parts.Add("mElbowLeft");parts.Add("mElbowRight");parts.Add("mWristLeft");parts.Add("mWristRight"); | 615 | parts.Add("mElbowLeft"); parts.Add("mElbowRight"); parts.Add("mWristLeft"); parts.Add("mWristRight"); |
565 | parts.Add("mShoulderLeft");parts.Add("mShoulderRight");parts.Add("mAnkleLeft");parts.Add("mAnkleRight"); | 616 | parts.Add("mShoulderLeft"); parts.Add("mShoulderRight"); parts.Add("mAnkleLeft"); parts.Add("mAnkleRight"); |
566 | parts.Add("mEyeRight");parts.Add("mChest");parts.Add("mToeLeft");parts.Add("mToeRight"); | 617 | parts.Add("mEyeRight"); parts.Add("mChest"); parts.Add("mToeLeft"); parts.Add("mToeRight"); |
567 | parts.Add("mFootLeft");parts.Add("mFootRight");parts.Add("mEyeLeft"); | 618 | parts.Add("mFootLeft"); parts.Add("mFootRight"); parts.Add("mEyeLeft"); |
568 | anim.HandPose = 1; | 619 | anim.HandPose = 1; |
569 | anim.InPoint = 0; | 620 | anim.InPoint = 0; |
570 | anim.OutPoint = (rnditerations * .10f); | 621 | anim.OutPoint = (rnditerations * .10f); |
@@ -588,12 +639,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
588 | for (int i = 0; i < rnditerations; i++) | 639 | for (int i = 0; i < rnditerations; i++) |
589 | { | 640 | { |
590 | anim.Joints[j].rotationkeys[i] = new binBVHJointKey(); | 641 | anim.Joints[j].rotationkeys[i] = new binBVHJointKey(); |
591 | anim.Joints[j].rotationkeys[i].time = (i*.10f); | 642 | anim.Joints[j].rotationkeys[i].time = (i * .10f); |
592 | anim.Joints[j].rotationkeys[i].key_element.X = ((float) rnd.NextDouble()*2 - 1); | 643 | anim.Joints[j].rotationkeys[i].key_element.X = ((float)rnd.NextDouble() * 2 - 1); |
593 | anim.Joints[j].rotationkeys[i].key_element.Y = ((float) rnd.NextDouble()*2 - 1); | 644 | anim.Joints[j].rotationkeys[i].key_element.Y = ((float)rnd.NextDouble() * 2 - 1); |
594 | anim.Joints[j].rotationkeys[i].key_element.Z = ((float) rnd.NextDouble()*2 - 1); | 645 | anim.Joints[j].rotationkeys[i].key_element.Z = ((float)rnd.NextDouble() * 2 - 1); |
595 | anim.Joints[j].positionkeys[i] = new binBVHJointKey(); | 646 | anim.Joints[j].positionkeys[i] = new binBVHJointKey(); |
596 | anim.Joints[j].positionkeys[i].time = (i*.10f); | 647 | anim.Joints[j].positionkeys[i].time = (i * .10f); |
597 | anim.Joints[j].positionkeys[i].key_element.X = 0; | 648 | anim.Joints[j].positionkeys[i].key_element.X = 0; |
598 | anim.Joints[j].positionkeys[i].key_element.Y = 0; | 649 | anim.Joints[j].positionkeys[i].key_element.Y = 0; |
599 | anim.Joints[j].positionkeys[i].key_element.Z = 0; | 650 | anim.Joints[j].positionkeys[i].key_element.Z = 0; |
@@ -620,22 +671,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
620 | /// <param name="objectIDs"></param> | 671 | /// <param name="objectIDs"></param> |
621 | public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) | 672 | public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) |
622 | { | 673 | { |
623 | /* | ||
624 | if (m_scenePresence.IsChildAgent) | ||
625 | return; | ||
626 | |||
627 | // m_log.DebugFormat( | ||
628 | // "[SCENE PRESENCE ANIMATOR]: Sending anim pack with animations '{0}', sequence '{1}', uuids '{2}'", | ||
629 | // string.Join(",", Array.ConvertAll<UUID, string>(animations, a => a.ToString())), | ||
630 | // string.Join(",", Array.ConvertAll<int, string>(seqs, s => s.ToString())), | ||
631 | // string.Join(",", Array.ConvertAll<UUID, string>(objectIDs, o => o.ToString()))); | ||
632 | |||
633 | m_scenePresence.Scene.ForEachClient( | ||
634 | delegate(IClientAPI client) | ||
635 | { | ||
636 | client.SendAnimations(animations, seqs, m_scenePresence.ControllingClient.AgentId, objectIDs); | ||
637 | }); | ||
638 | */ | ||
639 | m_scenePresence.SendAnimPack(animations, seqs, objectIDs); | 674 | m_scenePresence.SendAnimPack(animations, seqs, objectIDs); |
640 | } | 675 | } |
641 | 676 | ||
@@ -645,7 +680,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
645 | sequenceNums = null; | 680 | sequenceNums = null; |
646 | objectIDs = null; | 681 | objectIDs = null; |
647 | 682 | ||
648 | if(m_animations != null) | 683 | if (m_animations != null) |
649 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); | 684 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); |
650 | } | 685 | } |
651 | 686 | ||
@@ -668,7 +703,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
668 | public void SendAnimPack() | 703 | public void SendAnimPack() |
669 | { | 704 | { |
670 | //m_log.Debug("Sending animation pack to all"); | 705 | //m_log.Debug("Sending animation pack to all"); |
671 | 706 | ||
672 | if (m_scenePresence.IsChildAgent) | 707 | if (m_scenePresence.IsChildAgent) |
673 | return; | 708 | return; |
674 | 709 | ||
@@ -678,7 +713,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
678 | 713 | ||
679 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); | 714 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); |
680 | 715 | ||
681 | // SendAnimPack(animIDs, sequenceNums, objectIDs); | 716 | // SendAnimPack(animIDs, sequenceNums, objectIDs); |
682 | m_scenePresence.SendAnimPack(animIDs, sequenceNums, objectIDs); | 717 | m_scenePresence.SendAnimPack(animIDs, sequenceNums, objectIDs); |
683 | } | 718 | } |
684 | 719 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e003a59..5197f58 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -1063,6 +1063,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1063 | if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) | 1063 | if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) |
1064 | return; | 1064 | return; |
1065 | 1065 | ||
1066 | if (type != (sbyte)AssetType.Link || type != (sbyte)AssetType.LinkFolder) | ||
1067 | return; | ||
1068 | |||
1069 | |||
1066 | ScenePresence presence; | 1070 | ScenePresence presence; |
1067 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | 1071 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) |
1068 | { | 1072 | { |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5946979..42d3684 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -287,14 +287,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
287 | set { PhysicsActor.Flying = value; } | 287 | set { PhysicsActor.Flying = value; } |
288 | } | 288 | } |
289 | 289 | ||
290 | // add for fly velocity control | 290 | public bool IsColliding |
291 | private bool FlyingOld {get; set;} | ||
292 | public bool WasFlying | ||
293 | { | ||
294 | get; private set; | ||
295 | } | ||
296 | |||
297 | public bool IsColliding | ||
298 | { | 291 | { |
299 | get { return PhysicsActor != null && PhysicsActor.IsColliding; } | 292 | get { return PhysicsActor != null && PhysicsActor.IsColliding; } |
300 | // We would expect setting IsColliding to be private but it's used by a hack in Scene | 293 | // We would expect setting IsColliding to be private but it's used by a hack in Scene |
@@ -936,7 +929,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
936 | /// <remarks> | 929 | /// <remarks> |
937 | /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers. | 930 | /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers. |
938 | /// </remarks> | 931 | /// </remarks> |
939 | private float AgentControlStopSlowWhilstMoving = 0.5f; | 932 | private float AgentControlStopSlowWhilstMoving = 0.2f; |
940 | 933 | ||
941 | private bool m_forceFly; | 934 | private bool m_forceFly; |
942 | 935 | ||
@@ -2174,7 +2167,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2174 | bool DCFlagKeyPressed = false; | 2167 | bool DCFlagKeyPressed = false; |
2175 | Vector3 agent_control_v3 = Vector3.Zero; | 2168 | Vector3 agent_control_v3 = Vector3.Zero; |
2176 | 2169 | ||
2177 | bool newFlying = actor.Flying; | 2170 | bool newFlying = false; |
2178 | 2171 | ||
2179 | if (ForceFly) | 2172 | if (ForceFly) |
2180 | newFlying = true; | 2173 | newFlying = true; |
@@ -2286,11 +2279,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2286 | if (Flying && !ForceFly) | 2279 | if (Flying && !ForceFly) |
2287 | { | 2280 | { |
2288 | // Need to stop in mid air if user holds down AGENT_CONTROL_STOP | 2281 | // Need to stop in mid air if user holds down AGENT_CONTROL_STOP |
2289 | if (AgentControlStopActive) | 2282 | // if (AgentControlStopActive) |
2290 | { | 2283 | // { |
2291 | agent_control_v3 = Vector3.Zero; | 2284 | // agent_control_v3 = Vector3.Zero; |
2292 | } | 2285 | // } |
2293 | else | 2286 | // else |
2294 | { | 2287 | { |
2295 | // Landing detection code | 2288 | // Landing detection code |
2296 | 2289 | ||
@@ -2298,38 +2291,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
2298 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 2291 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
2299 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 2292 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
2300 | 2293 | ||
2301 | //m_log.Debug("[CONTROL]: " +flags); | 2294 | //m_log.Debug("[CONTROL]: " +flags); |
2302 | // Applies a satisfying roll effect to the avatar when flying. | 2295 | // Applies a satisfying roll effect to the avatar when flying. |
2303 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) | 2296 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) |
2304 | { | 2297 | { |
2305 | ApplyFlyingRoll( | 2298 | ApplyFlyingRoll( |
2306 | FLY_ROLL_RADIANS_PER_UPDATE, | 2299 | FLY_ROLL_RADIANS_PER_UPDATE, |
2307 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, | 2300 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, |
2308 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); | 2301 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); |
2309 | } | 2302 | } |
2310 | else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 && | 2303 | else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 && |
2311 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) | 2304 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) |
2312 | { | 2305 | { |
2313 | ApplyFlyingRoll( | 2306 | ApplyFlyingRoll( |
2314 | -FLY_ROLL_RADIANS_PER_UPDATE, | 2307 | -FLY_ROLL_RADIANS_PER_UPDATE, |
2315 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, | 2308 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, |
2316 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); | 2309 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); |
2317 | } | 2310 | } |
2318 | else | 2311 | else |
2319 | { | 2312 | { |
2320 | if (m_AngularVelocity.Z != 0) | 2313 | if (m_AngularVelocity.Z != 0) |
2321 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); | 2314 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); |
2322 | } | ||
2323 | |||
2324 | if (Flying && IsColliding && controlland) | ||
2325 | { | ||
2326 | // nesting this check because LengthSquared() is expensive and we don't | ||
2327 | // want to do it every step when flying. | ||
2328 | if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) | ||
2329 | StopFlying(); | ||
2330 | } | 2315 | } |
2316 | |||
2317 | /* | ||
2318 | if (Flying && IsColliding && controlland) | ||
2319 | { | ||
2320 | // nesting this check because LengthSquared() is expensive and we don't | ||
2321 | // want to do it every step when flying. | ||
2322 | if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) | ||
2323 | StopFlying(); | ||
2324 | } | ||
2325 | */ | ||
2331 | } | 2326 | } |
2332 | } | 2327 | } |
2328 | else if (IsColliding && agent_control_v3.Z < 0f) | ||
2329 | agent_control_v3.Z = 0; | ||
2330 | // else if(AgentControlStopActive %% Velocity.Z <0.01f) | ||
2331 | |||
2333 | 2332 | ||
2334 | // m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name); | 2333 | // m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name); |
2335 | 2334 | ||
@@ -2342,32 +2341,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2342 | if (update_movementflag | 2341 | if (update_movementflag |
2343 | || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0))) | 2342 | || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0))) |
2344 | { | 2343 | { |
2345 | // if (update_movementflag || !AgentControlStopActive || MovementFlag != 0) | ||
2346 | // { | ||
2347 | // m_log.DebugFormat( | ||
2348 | // "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, mf = {4}, ur = {5}", | ||
2349 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name, | ||
2350 | // update_movementflag, MovementFlag, update_rotation); | ||
2351 | |||
2352 | float speedModifier; | ||
2353 | 2344 | ||
2354 | if (AgentControlStopActive) | 2345 | if (AgentControlStopActive) |
2355 | speedModifier = AgentControlStopSlowWhilstMoving; | 2346 | { |
2347 | // if (MovementFlag == 0 && Animator.Falling) | ||
2348 | if (MovementFlag == 0 && Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) | ||
2349 | { | ||
2350 | AddNewMovement(agent_control_v3, AgentControlStopSlowWhilstMoving, true); | ||
2351 | } | ||
2356 | else | 2352 | else |
2357 | speedModifier = 1; | 2353 | AddNewMovement(agent_control_v3, AgentControlStopSlowWhilstMoving); |
2354 | } | ||
2355 | |||
2356 | else | ||
2357 | AddNewMovement(agent_control_v3); | ||
2358 | 2358 | ||
2359 | AddNewMovement(agent_control_v3, speedModifier); | ||
2360 | // } | ||
2361 | } | 2359 | } |
2362 | // else | ||
2363 | // { | ||
2364 | // if (!update_movementflag) | ||
2365 | // { | ||
2366 | // m_log.DebugFormat( | ||
2367 | // "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", | ||
2368 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name); | ||
2369 | // } | ||
2370 | // } | ||
2371 | 2360 | ||
2372 | if (update_movementflag && ParentID == 0) | 2361 | if (update_movementflag && ParentID == 0) |
2373 | { | 2362 | { |
@@ -3246,68 +3235,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
3246 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 3235 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
3247 | /// <param name="thisAddSpeedModifier"> | 3236 | /// <param name="thisAddSpeedModifier"> |
3248 | /// Optional additional speed modifier for this particular add. Default is 1</param> | 3237 | /// Optional additional speed modifier for this particular add. Default is 1</param> |
3249 | public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1) | 3238 | public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1, bool breaking = false) |
3250 | { | 3239 | { |
3251 | // m_log.DebugFormat( | 3240 | // m_log.DebugFormat( |
3252 | // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", | 3241 | // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", |
3253 | // vec, Rotation, thisAddSpeedModifier, Name); | 3242 | // vec, Rotation, thisAddSpeedModifier, Name); |
3254 | 3243 | ||
3244 | // rotate from avatar coord space to world | ||
3245 | // for now all controls assume this is only a rotation around Z | ||
3246 | // if not all checks below need to be done before this rotation | ||
3255 | Vector3 direc = vec * Rotation; | 3247 | Vector3 direc = vec * Rotation; |
3256 | direc.Normalize(); | 3248 | direc.Normalize(); |
3257 | 3249 | ||
3258 | if (Flying != FlyingOld) // add for fly velocity control | 3250 | // mouse look situation ? |
3259 | { | ||
3260 | FlyingOld = Flying; // add for fly velocity control | ||
3261 | if (!Flying) | ||
3262 | WasFlying = true; // add for fly velocity control | ||
3263 | } | ||
3264 | |||
3265 | if (IsColliding) | ||
3266 | WasFlying = false; // add for fly velocity control | ||
3267 | |||
3268 | if ((vec.Z == 0f) && !Flying) | 3251 | if ((vec.Z == 0f) && !Flying) |
3269 | direc.Z = 0f; // Prevent camera WASD up. | 3252 | direc.Z = 0f; // Prevent camera WASD up. |
3270 | 3253 | ||
3254 | // odd rescalings | ||
3271 | direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier; | 3255 | direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier; |
3272 | 3256 | ||
3273 | // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); | 3257 | // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); |
3274 | 3258 | ||
3275 | if (PhysicsActor != null) | 3259 | if (Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) |
3276 | { | 3260 | { |
3277 | if (Flying) | 3261 | if (breaking) |
3278 | { | 3262 | direc.Z = -9999f; //hack to tell physics to stop on Z |
3263 | else | ||
3264 | direc = Vector3.Zero; | ||
3265 | } | ||
3266 | else if (Flying) | ||
3267 | { | ||
3268 | if (IsColliding && direc.Z < 0) | ||
3269 | // landing situation, prevent avatar moving or it may fail to land | ||
3270 | // animator will handle this condition and do the land | ||
3271 | direc = Vector3.Zero; | ||
3272 | else | ||
3279 | direc *= 4.0f; | 3273 | direc *= 4.0f; |
3280 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 3274 | } |
3281 | //if (controlland) | 3275 | else if (IsColliding) |
3282 | // m_log.Info("[AGENT]: landCommand"); | 3276 | { |
3283 | //if (IsColliding) | 3277 | if (direc.Z > 2.0f) // reinforce jumps |
3284 | // m_log.Info("[AGENT]: colliding"); | ||
3285 | //if (Flying && IsColliding && controlland) | ||
3286 | //{ | ||
3287 | // StopFlying(); | ||
3288 | // m_log.Info("[AGENT]: Stop Flying"); | ||
3289 | //} | ||
3290 | } | ||
3291 | if (Animator.Falling && WasFlying) // if falling from flying, disable motion add | ||
3292 | { | ||
3293 | direc *= 0.0f; | ||
3294 | } | ||
3295 | else if (!Flying && IsColliding) | ||
3296 | { | 3278 | { |
3297 | if (direc.Z > 2.0f) | 3279 | direc.Z *= 2.6f; |
3298 | { | ||
3299 | direc.Z *= 2.6f; | ||
3300 | |||
3301 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | ||
3302 | // Animator.TrySetMovementAnimation("PREJUMP"); | ||
3303 | // Animator.TrySetMovementAnimation("JUMP"); | ||
3304 | } | ||
3305 | } | 3280 | } |
3281 | else if (direc.Z < 0) // on a surface moving down (pg down) only changes animation | ||
3282 | direc.Z = 0; | ||
3306 | } | 3283 | } |
3307 | 3284 | ||
3308 | // m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); | 3285 | // m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); |
3309 | 3286 | ||
3310 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | ||
3311 | m_forceToApply = direc; | 3287 | m_forceToApply = direc; |
3312 | Animator.UpdateMovementAnimations(); | 3288 | Animator.UpdateMovementAnimations(); |
3313 | } | 3289 | } |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index daf6c7c..992fae7 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | |||
@@ -79,6 +79,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
79 | private Vector3 _acceleration; | 79 | private Vector3 _acceleration; |
80 | private Vector3 m_rotationalVelocity; | 80 | private Vector3 m_rotationalVelocity; |
81 | private Vector3 m_size; | 81 | private Vector3 m_size; |
82 | private Vector3 m_collideNormal; | ||
82 | private Quaternion m_orientation; | 83 | private Quaternion m_orientation; |
83 | private Quaternion m_orientation2D; | 84 | private Quaternion m_orientation2D; |
84 | private float m_mass = 80f; | 85 | private float m_mass = 80f; |
@@ -109,6 +110,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
109 | 110 | ||
110 | private bool _zeroFlag = false; | 111 | private bool _zeroFlag = false; |
111 | 112 | ||
113 | |||
112 | private uint m_localID = 0; | 114 | private uint m_localID = 0; |
113 | public bool m_returnCollisions = false; | 115 | public bool m_returnCollisions = false; |
114 | // taints and their non-tainted counterparts | 116 | // taints and their non-tainted counterparts |
@@ -153,9 +155,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
153 | public UUID m_uuid; | 155 | public UUID m_uuid; |
154 | public bool bad = false; | 156 | public bool bad = false; |
155 | 157 | ||
156 | float mu; | 158 | float mu; |
157 | |||
158 | |||
159 | 159 | ||
160 | public OdeCharacter(uint localID, String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor) | 160 | public OdeCharacter(uint localID, String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor) |
161 | { | 161 | { |
@@ -864,11 +864,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
864 | x = tx * cos - y * sin; | 864 | x = tx * cos - y * sin; |
865 | y = tx * sin + y * cos; | 865 | y = tx * sin + y * cos; |
866 | } | 866 | } |
867 | 867 | ||
868 | 868 | public bool Collide(IntPtr me, IntPtr other, bool reverse, ref d.ContactGeom contact, | |
869 | public bool Collide(IntPtr me,IntPtr other, bool reverse, ref d.ContactGeom contact, ref bool feetcollision) | 869 | ref d.ContactGeom altContact , ref bool useAltcontact, ref bool feetcollision) |
870 | { | 870 | { |
871 | feetcollision = false; | 871 | feetcollision = false; |
872 | useAltcontact = false; | ||
872 | 873 | ||
873 | if (me == capsule) | 874 | if (me == capsule) |
874 | { | 875 | { |
@@ -899,31 +900,78 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
899 | { | 900 | { |
900 | feetcollision = true; | 901 | feetcollision = true; |
901 | if (h < boneOff) | 902 | if (h < boneOff) |
903 | { | ||
904 | m_collideNormal.X = contact.normal.X; | ||
905 | m_collideNormal.Y = contact.normal.Y; | ||
906 | m_collideNormal.Z = contact.normal.Z; | ||
902 | IsColliding = true; | 907 | IsColliding = true; |
908 | } | ||
903 | } | 909 | } |
904 | return true; | 910 | return true; |
905 | } | 911 | } |
912 | /* | ||
913 | d.AABB aabb; | ||
914 | d.GeomGetAABB(other,out aabb); | ||
915 | float othertop = aabb.MaxZ - _position.Z; | ||
916 | */ | ||
917 | // if (offset.Z > 0 || othertop > -feetOff || contact.normal.Z > 0.35f) | ||
918 | if (offset.Z > 0 || contact.normal.Z > 0.35f) | ||
919 | { | ||
920 | if (offset.Z <= 0) | ||
921 | { | ||
922 | feetcollision = true; | ||
923 | if (h < boneOff) | ||
924 | { | ||
925 | m_collideNormal.X = contact.normal.X; | ||
926 | m_collideNormal.Y = contact.normal.Y; | ||
927 | m_collideNormal.Z = contact.normal.Z; | ||
928 | IsColliding = true; | ||
929 | } | ||
930 | } | ||
906 | 931 | ||
907 | if (offset.Z > 0) | 932 | if (contact.normal.Z < 0.2f) |
933 | { | ||
934 | contact.normal.Z = 0; | ||
935 | float t = contact.normal.X * contact.normal.X + contact.normal.Y * contact.normal.Y; | ||
936 | if (t > 0) | ||
937 | { | ||
938 | t = 1.0f / t; | ||
939 | contact.normal.X *= t; | ||
940 | contact.normal.Y *= t; | ||
941 | } | ||
942 | } | ||
908 | return true; | 943 | return true; |
944 | } | ||
945 | |||
946 | altContact = contact; | ||
947 | useAltcontact = true; | ||
909 | 948 | ||
910 | offset.Normalize(); | 949 | offset.Normalize(); |
911 | 950 | ||
951 | if (contact.depth > 0.1f) | ||
952 | contact.depth = 0.1f; | ||
953 | |||
912 | if (reverse) | 954 | if (reverse) |
913 | { | 955 | { |
914 | contact.normal.X = offset.X; | 956 | altContact.normal.X = offset.X; |
915 | contact.normal.Y = offset.Y; | 957 | altContact.normal.Y = offset.Y; |
916 | contact.normal.Z = offset.Z; | 958 | altContact.normal.Z = offset.Z; |
917 | } | 959 | } |
918 | else | 960 | else |
919 | { | 961 | { |
920 | contact.normal.X = -offset.X; | 962 | altContact.normal.X = -offset.X; |
921 | contact.normal.Y = -offset.Y; | 963 | altContact.normal.Y = -offset.Y; |
922 | contact.normal.Z = -offset.Z; | 964 | altContact.normal.Z = -offset.Z; |
923 | } | 965 | } |
966 | |||
924 | feetcollision = true; | 967 | feetcollision = true; |
925 | if (h < boneOff) | 968 | if (h < boneOff) |
969 | { | ||
970 | m_collideNormal.X = contact.normal.X; | ||
971 | m_collideNormal.Y = contact.normal.Y; | ||
972 | m_collideNormal.Z = contact.normal.Z; | ||
926 | IsColliding = true; | 973 | IsColliding = true; |
974 | } | ||
927 | return true; | 975 | return true; |
928 | } | 976 | } |
929 | return false; | 977 | return false; |
@@ -1003,6 +1051,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1003 | Vector3 vel = new Vector3(dtmp.X, dtmp.Y, dtmp.Z); | 1051 | Vector3 vel = new Vector3(dtmp.X, dtmp.Y, dtmp.Z); |
1004 | float velLengthSquared = vel.LengthSquared(); | 1052 | float velLengthSquared = vel.LengthSquared(); |
1005 | 1053 | ||
1054 | |||
1055 | Vector3 ctz = _target_velocity; | ||
1056 | |||
1006 | float movementdivisor = 1f; | 1057 | float movementdivisor = 1f; |
1007 | //Ubit change divisions into multiplications below | 1058 | //Ubit change divisions into multiplications below |
1008 | if (!m_alwaysRun) | 1059 | if (!m_alwaysRun) |
@@ -1010,13 +1061,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1010 | else | 1061 | else |
1011 | movementdivisor = 1 / runDivisor; | 1062 | movementdivisor = 1 / runDivisor; |
1012 | 1063 | ||
1064 | ctz.X *= movementdivisor; | ||
1065 | ctz.Y *= movementdivisor; | ||
1066 | |||
1013 | //****************************************** | 1067 | //****************************************** |
1014 | // colide with land | 1068 | // colide with land |
1015 | 1069 | ||
1016 | d.AABB aabb; | 1070 | d.AABB aabb; |
1017 | // d.GeomGetAABB(feetbox, out aabb); | 1071 | // d.GeomGetAABB(feetbox, out aabb); |
1018 | d.GeomGetAABB(capsule, out aabb); | 1072 | d.GeomGetAABB(capsule, out aabb); |
1019 | float chrminZ = aabb.MinZ; ; // move up a bit | 1073 | float chrminZ = aabb.MinZ; // move up a bit |
1020 | Vector3 posch = localpos; | 1074 | Vector3 posch = localpos; |
1021 | 1075 | ||
1022 | float ftmp; | 1076 | float ftmp; |
@@ -1031,15 +1085,18 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1031 | float terrainheight = _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y); | 1085 | float terrainheight = _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y); |
1032 | if (chrminZ < terrainheight) | 1086 | if (chrminZ < terrainheight) |
1033 | { | 1087 | { |
1088 | if (ctz.Z < 0) | ||
1089 | ctz.Z = 0; | ||
1090 | |||
1091 | Vector3 n = _parent_scene.GetTerrainNormalAtXY(posch.X, posch.Y); | ||
1034 | float depth = terrainheight - chrminZ; | 1092 | float depth = terrainheight - chrminZ; |
1093 | |||
1094 | vec.Z = depth * PID_P * 50; | ||
1095 | |||
1035 | if (!flying) | 1096 | if (!flying) |
1036 | { | 1097 | vec.Z += -vel.Z * PID_D; |
1037 | vec.Z = -vel.Z * PID_D * 1.5f + depth * PID_P * 50; | ||
1038 | } | ||
1039 | else | ||
1040 | vec.Z = depth * PID_P * 50; | ||
1041 | 1098 | ||
1042 | if (depth < 0.1f) | 1099 | if (depth < 0.2f) |
1043 | { | 1100 | { |
1044 | m_colliderGroundfilter++; | 1101 | m_colliderGroundfilter++; |
1045 | if (m_colliderGroundfilter > 2) | 1102 | if (m_colliderGroundfilter > 2) |
@@ -1053,50 +1110,83 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1053 | m_freemove = false; | 1110 | m_freemove = false; |
1054 | } | 1111 | } |
1055 | 1112 | ||
1113 | m_collideNormal.X = n.X; | ||
1114 | m_collideNormal.Y = n.Y; | ||
1115 | m_collideNormal.Z = n.Z; | ||
1116 | |||
1056 | m_iscollidingGround = true; | 1117 | m_iscollidingGround = true; |
1057 | 1118 | ||
1119 | |||
1058 | ContactPoint contact = new ContactPoint(); | 1120 | ContactPoint contact = new ContactPoint(); |
1059 | contact.PenetrationDepth = depth; | 1121 | contact.PenetrationDepth = depth; |
1060 | contact.Position.X = localpos.X; | 1122 | contact.Position.X = localpos.X; |
1061 | contact.Position.Y = localpos.Y; | 1123 | contact.Position.Y = localpos.Y; |
1062 | contact.Position.Z = terrainheight; | 1124 | contact.Position.Z = terrainheight; |
1063 | contact.SurfaceNormal.X = 0.0f; | 1125 | contact.SurfaceNormal.X = -n.X; |
1064 | contact.SurfaceNormal.Y = 0.0f; | 1126 | contact.SurfaceNormal.Y = -n.Y; |
1065 | contact.SurfaceNormal.Z = -1f; | 1127 | contact.SurfaceNormal.Z = -n.Z; |
1066 | contact.RelativeSpeed = -vel.Z; | 1128 | contact.RelativeSpeed = -vel.Z; |
1067 | contact.CharacterFeet = true; | 1129 | contact.CharacterFeet = true; |
1068 | AddCollisionEvent(0, contact); | 1130 | AddCollisionEvent(0, contact); |
1069 | 1131 | ||
1070 | vec.Z *= 0.5f; | 1132 | // vec.Z *= 0.5f; |
1071 | } | 1133 | } |
1072 | } | 1134 | } |
1073 | 1135 | ||
1074 | else | 1136 | else |
1075 | { | 1137 | { |
1076 | m_colliderGroundfilter = 0; | 1138 | m_colliderGroundfilter -= 5; |
1077 | m_iscollidingGround = false; | 1139 | if (m_colliderGroundfilter <= 0) |
1140 | { | ||
1141 | m_colliderGroundfilter = 0; | ||
1142 | m_iscollidingGround = false; | ||
1143 | } | ||
1078 | } | 1144 | } |
1079 | } | 1145 | } |
1080 | else | 1146 | else |
1081 | { | 1147 | { |
1082 | m_colliderGroundfilter = 0; | 1148 | m_colliderGroundfilter -= 5; |
1083 | m_iscollidingGround = false; | 1149 | if (m_colliderGroundfilter <= 0) |
1150 | { | ||
1151 | m_colliderGroundfilter = 0; | ||
1152 | m_iscollidingGround = false; | ||
1153 | } | ||
1084 | } | 1154 | } |
1085 | 1155 | ||
1086 | 1156 | ||
1087 | //****************************************** | 1157 | //****************************************** |
1158 | if (!m_iscolliding) | ||
1159 | m_collideNormal.Z = 0; | ||
1160 | |||
1161 | bool tviszero = (ctz.X == 0.0f && ctz.Y == 0.0f && ctz.Z == 0.0f); | ||
1162 | |||
1088 | 1163 | ||
1089 | bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f); | ||
1090 | 1164 | ||
1091 | // if (!tviszero || m_iscolliding || velLengthSquared <0.01) | ||
1092 | if (!tviszero) | 1165 | if (!tviszero) |
1166 | { | ||
1093 | m_freemove = false; | 1167 | m_freemove = false; |
1094 | 1168 | ||
1169 | // movement relative to surface if moving on it | ||
1170 | // dont disturbe vertical movement, ie jumps | ||
1171 | if (m_iscolliding && !flying && ctz.Z == 0 && m_collideNormal.Z > 0.2f && m_collideNormal.Z < 0.94f) | ||
1172 | { | ||
1173 | float p = ctz.X * m_collideNormal.X + ctz.Y * m_collideNormal.Y; | ||
1174 | ctz.X *= (float)Math.Sqrt(1 - m_collideNormal.X * m_collideNormal.X); | ||
1175 | ctz.Y *= (float)Math.Sqrt(1 - m_collideNormal.Y * m_collideNormal.Y); | ||
1176 | ctz.Z -= p; | ||
1177 | if (ctz.Z < 0) | ||
1178 | ctz.Z *= 2; | ||
1179 | |||
1180 | } | ||
1181 | |||
1182 | } | ||
1183 | |||
1184 | |||
1095 | if (!m_freemove) | 1185 | if (!m_freemove) |
1096 | { | 1186 | { |
1097 | 1187 | ||
1098 | // if velocity is zero, use position control; otherwise, velocity control | 1188 | // if velocity is zero, use position control; otherwise, velocity control |
1099 | if (tviszero && m_iscolliding) | 1189 | if (tviszero && m_iscolliding && !flying) |
1100 | { | 1190 | { |
1101 | // keep track of where we stopped. No more slippin' & slidin' | 1191 | // keep track of where we stopped. No more slippin' & slidin' |
1102 | if (!_zeroFlag) | 1192 | if (!_zeroFlag) |
@@ -1129,22 +1219,48 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1129 | { | 1219 | { |
1130 | if (!flying) | 1220 | if (!flying) |
1131 | { | 1221 | { |
1132 | if (_target_velocity.Z > 0.0f) | 1222 | // we are on a surface |
1223 | if (ctz.Z > 0f) | ||
1133 | { | 1224 | { |
1134 | // We're colliding with something and we're not flying but we're moving | 1225 | // moving up or JUMPING |
1135 | // This means we're walking or running. JUMPING | 1226 | vec.Z += (ctz.Z - vel.Z) * PID_D * 1.2f;// +(_zeroPosition.Z - localpos.Z) * PID_P; |
1136 | vec.Z += (_target_velocity.Z - vel.Z) * PID_D * 1.2f;// +(_zeroPosition.Z - localpos.Z) * PID_P; | 1227 | vec.X += (ctz.X - vel.X) * (PID_D); |
1228 | vec.Y += (ctz.Y - vel.Y) * (PID_D); | ||
1137 | } | 1229 | } |
1230 | else | ||
1231 | { | ||
1232 | // we are moving down on a surface | ||
1233 | if (ctz.Z == 0) | ||
1234 | { | ||
1235 | if (vel.Z > 0) | ||
1236 | vec.Z -= vel.Z * PID_D * 2.0f; | ||
1237 | vec.X += (ctz.X - vel.X) * (PID_D); | ||
1238 | vec.Y += (ctz.Y - vel.Y) * (PID_D); | ||
1239 | } | ||
1240 | // intencionally going down | ||
1241 | else | ||
1242 | { | ||
1243 | if (ctz.Z < vel.Z) | ||
1244 | vec.Z += (ctz.Z - vel.Z) * PID_D * 2.0f; | ||
1245 | else | ||
1246 | { | ||
1247 | } | ||
1248 | |||
1249 | if (Math.Abs(ctz.X) > Math.Abs(vel.X)) | ||
1250 | vec.X += (ctz.X - vel.X) * (PID_D); | ||
1251 | if (Math.Abs(ctz.Y) > Math.Abs(vel.Y)) | ||
1252 | vec.Y += (ctz.Y - vel.Y) * (PID_D); | ||
1253 | } | ||
1254 | } | ||
1255 | |||
1138 | // We're standing on something | 1256 | // We're standing on something |
1139 | vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D); | ||
1140 | vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D); | ||
1141 | } | 1257 | } |
1142 | else | 1258 | else |
1143 | { | 1259 | { |
1144 | // We're flying and colliding with something | 1260 | // We're flying and colliding with something |
1145 | vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 0.0625f); | 1261 | vec.X += (ctz.X - vel.X) * (PID_D * 0.0625f); |
1146 | vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 0.0625f); | 1262 | vec.Y += (ctz.Y - vel.Y) * (PID_D * 0.0625f); |
1147 | vec.Z += (_target_velocity.Z - vel.Z) * (PID_D); | 1263 | vec.Z += (ctz.Z - vel.Z) * (PID_D); |
1148 | } | 1264 | } |
1149 | } | 1265 | } |
1150 | else // ie not colliding | 1266 | else // ie not colliding |
@@ -1152,9 +1268,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1152 | if (flying) //(!m_iscolliding && flying) | 1268 | if (flying) //(!m_iscolliding && flying) |
1153 | { | 1269 | { |
1154 | // we're in mid air suspended | 1270 | // we're in mid air suspended |
1155 | vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 1.667f); | 1271 | vec.X += (ctz.X - vel.X) * (PID_D * 1.667f); |
1156 | vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 1.667f); | 1272 | vec.Y += (ctz.Y - vel.Y) * (PID_D * 1.667f); |
1157 | vec.Z += (_target_velocity.Z - vel.Z) * (PID_D); | 1273 | vec.Z += (ctz.Z - vel.Z) * (PID_D); |
1158 | } | 1274 | } |
1159 | 1275 | ||
1160 | else | 1276 | else |
@@ -1163,8 +1279,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1163 | // m_iscolliding includes collisions with the ground. | 1279 | // m_iscolliding includes collisions with the ground. |
1164 | 1280 | ||
1165 | // d.Vector3 pos = d.BodyGetPosition(Body); | 1281 | // d.Vector3 pos = d.BodyGetPosition(Body); |
1166 | vec.X = (_target_velocity.X - vel.X) * PID_D * 0.833f; | 1282 | vec.X += (ctz.X - vel.X) * PID_D * 0.833f; |
1167 | vec.Y = (_target_velocity.Y - vel.Y) * PID_D * 0.833f; | 1283 | vec.Y += (ctz.Y - vel.Y) * PID_D * 0.833f; |
1284 | // hack for breaking on fall | ||
1285 | if (ctz.Z == -9999f) | ||
1286 | vec.Z += -vel.Z * PID_D - _parent_scene.gravityz * m_mass; | ||
1168 | } | 1287 | } |
1169 | } | 1288 | } |
1170 | } | 1289 | } |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 9bf2abe..2adbe01 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -935,18 +935,22 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
935 | SharedTmpcontact.surface.mu = mu; | 935 | SharedTmpcontact.surface.mu = mu; |
936 | SharedTmpcontact.surface.bounce = bounce; | 936 | SharedTmpcontact.surface.bounce = bounce; |
937 | 937 | ||
938 | d.ContactGeom altContact = new d.ContactGeom(); | ||
939 | bool useAltcontact = false; | ||
940 | bool noskip = true; | ||
941 | |||
938 | while (true) | 942 | while (true) |
939 | { | 943 | { |
940 | // if (!(IgnoreNegSides && curContact.side1 < 0)) | 944 | // if (!(IgnoreNegSides && curContact.side1 < 0)) |
941 | { | 945 | { |
942 | bool noskip = true; | 946 | noskip = true; |
947 | useAltcontact = false; | ||
948 | |||
943 | if (dop1ava) | 949 | if (dop1ava) |
944 | { | 950 | { |
945 | if (!(((OdeCharacter)p1).Collide(g1, g2, false, ref curContact, ref FeetCollision))) | 951 | if ((((OdeCharacter)p1).Collide(g1, g2, false, ref curContact, ref altContact , ref useAltcontact, ref FeetCollision))) |
946 | noskip = false; | ||
947 | else | ||
948 | { | 952 | { |
949 | if(p2.PhysicsActorType == (int)ActorTypes.Agent) | 953 | if (p2.PhysicsActorType == (int)ActorTypes.Agent) |
950 | { | 954 | { |
951 | p1.CollidingObj = true; | 955 | p1.CollidingObj = true; |
952 | p2.CollidingObj = true; | 956 | p2.CollidingObj = true; |
@@ -954,18 +958,32 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
954 | else if (p2.Velocity.LengthSquared() > 0.0f) | 958 | else if (p2.Velocity.LengthSquared() > 0.0f) |
955 | p2.CollidingObj = true; | 959 | p2.CollidingObj = true; |
956 | } | 960 | } |
961 | else | ||
962 | noskip = false; | ||
957 | } | 963 | } |
958 | else if (dop2ava) | 964 | else if (dop2ava) |
959 | { | 965 | { |
960 | if (!(((OdeCharacter)p2).Collide(g2,g1, true, ref curContact, ref FeetCollision))) | 966 | if ((((OdeCharacter)p2).Collide(g2, g1, true, ref curContact, ref altContact , ref useAltcontact, ref FeetCollision))) |
967 | { | ||
968 | if (p1.PhysicsActorType == (int)ActorTypes.Agent) | ||
969 | { | ||
970 | p1.CollidingObj = true; | ||
971 | p2.CollidingObj = true; | ||
972 | } | ||
973 | else if (p2.Velocity.LengthSquared() > 0.0f) | ||
974 | p1.CollidingObj = true; | ||
975 | } | ||
976 | else | ||
961 | noskip = false; | 977 | noskip = false; |
962 | else if (p1.Velocity.LengthSquared() > 0.0f) | ||
963 | p1.CollidingObj = true; | ||
964 | } | 978 | } |
965 | 979 | ||
966 | if (noskip) | 980 | if (noskip) |
967 | { | 981 | { |
968 | Joint = CreateContacJoint(ref curContact); | 982 | if(useAltcontact) |
983 | Joint = CreateContacJoint(ref altContact); | ||
984 | else | ||
985 | Joint = CreateContacJoint(ref curContact); | ||
986 | |||
969 | if (Joint == IntPtr.Zero) | 987 | if (Joint == IntPtr.Zero) |
970 | break; | 988 | break; |
971 | 989 | ||
@@ -1924,12 +1942,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1924 | dy = 0; | 1942 | dy = 0; |
1925 | } | 1943 | } |
1926 | } | 1944 | } |
1927 | |||
1928 | else | 1945 | else |
1929 | { | 1946 | { |
1930 | // we still have square fixed size regions | 1947 | // we still have square fixed size regions |
1931 | // also flip x and y because of how map is done for ODE fliped axis | 1948 | // also flip x and y because of how map is done for ODE fliped axis |
1932 | // so ix,iy,dx and dy are inter exchanged | 1949 | // so ix,iy,dx and dy are inter exchanged |
1950 | |||
1933 | if (x < regsize - 1) | 1951 | if (x < regsize - 1) |
1934 | { | 1952 | { |
1935 | iy = (int)x; | 1953 | iy = (int)x; |
@@ -1976,7 +1994,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1976 | */ | 1994 | */ |
1977 | h0 = ((float)heights[iy]); // 0,0 vertice | 1995 | h0 = ((float)heights[iy]); // 0,0 vertice |
1978 | 1996 | ||
1979 | if ((dy > dx)) | 1997 | if (dy>dx) |
1980 | { | 1998 | { |
1981 | iy += regsize; | 1999 | iy += regsize; |
1982 | h2 = (float)heights[iy]; // 0,1 vertice | 2000 | h2 = (float)heights[iy]; // 0,1 vertice |
@@ -1994,6 +2012,133 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1994 | return h0 + h1 + h2; | 2012 | return h0 + h1 + h2; |
1995 | } | 2013 | } |
1996 | 2014 | ||
2015 | public Vector3 GetTerrainNormalAtXY(float x, float y) | ||
2016 | { | ||
2017 | int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
2018 | int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
2019 | |||
2020 | IntPtr heightFieldGeom = IntPtr.Zero; | ||
2021 | Vector3 norm = new Vector3(0, 0, 1); | ||
2022 | |||
2023 | // get region map | ||
2024 | if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom)) | ||
2025 | return norm; | ||
2026 | |||
2027 | if (heightFieldGeom == IntPtr.Zero) | ||
2028 | return norm; | ||
2029 | |||
2030 | if (!TerrainHeightFieldHeights.ContainsKey(heightFieldGeom)) | ||
2031 | return norm; | ||
2032 | |||
2033 | // TerrainHeightField for ODE as offset 1m | ||
2034 | x += 1f - offsetX; | ||
2035 | y += 1f - offsetY; | ||
2036 | |||
2037 | // make position fit into array | ||
2038 | if (x < 0) | ||
2039 | x = 0; | ||
2040 | if (y < 0) | ||
2041 | y = 0; | ||
2042 | |||
2043 | // integer indexs | ||
2044 | int ix; | ||
2045 | int iy; | ||
2046 | // interpolators offset | ||
2047 | float dx; | ||
2048 | float dy; | ||
2049 | |||
2050 | |||
2051 | int regsize = (int)Constants.RegionSize + 3; // map size see setterrain number of samples | ||
2052 | int xstep = 1; | ||
2053 | int ystep = regsize; | ||
2054 | bool firstTri = false; | ||
2055 | |||
2056 | if (OdeUbitLib) | ||
2057 | { | ||
2058 | if (x < regsize - 1) | ||
2059 | { | ||
2060 | ix = (int)x; | ||
2061 | dx = x - (float)ix; | ||
2062 | } | ||
2063 | else // out world use external height | ||
2064 | { | ||
2065 | ix = regsize - 2; | ||
2066 | dx = 0; | ||
2067 | } | ||
2068 | if (y < regsize - 1) | ||
2069 | { | ||
2070 | iy = (int)y; | ||
2071 | dy = y - (float)iy; | ||
2072 | } | ||
2073 | else | ||
2074 | { | ||
2075 | iy = regsize - 2; | ||
2076 | dy = 0; | ||
2077 | } | ||
2078 | firstTri = dy > dx; | ||
2079 | } | ||
2080 | |||
2081 | else | ||
2082 | { | ||
2083 | xstep = regsize; | ||
2084 | ystep = 1; | ||
2085 | // we still have square fixed size regions | ||
2086 | // also flip x and y because of how map is done for ODE fliped axis | ||
2087 | // so ix,iy,dx and dy are inter exchanged | ||
2088 | if (x < regsize - 1) | ||
2089 | { | ||
2090 | iy = (int)x; | ||
2091 | dy = x - (float)iy; | ||
2092 | } | ||
2093 | else // out world use external height | ||
2094 | { | ||
2095 | iy = regsize - 2; | ||
2096 | dy = 0; | ||
2097 | } | ||
2098 | if (y < regsize - 1) | ||
2099 | { | ||
2100 | ix = (int)y; | ||
2101 | dx = y - (float)ix; | ||
2102 | } | ||
2103 | else | ||
2104 | { | ||
2105 | ix = regsize - 2; | ||
2106 | dx = 0; | ||
2107 | } | ||
2108 | firstTri = dx > dy; | ||
2109 | } | ||
2110 | |||
2111 | float h0; | ||
2112 | float h1; | ||
2113 | float h2; | ||
2114 | |||
2115 | iy *= regsize; | ||
2116 | iy += ix; // all indexes have iy + ix | ||
2117 | |||
2118 | float[] heights = TerrainHeightFieldHeights[heightFieldGeom]; | ||
2119 | |||
2120 | if (firstTri) | ||
2121 | { | ||
2122 | h1 = ((float)heights[iy]); // 0,0 vertice | ||
2123 | iy += ystep; | ||
2124 | h0 = (float)heights[iy]; // 0,1 | ||
2125 | h2 = (float)heights[iy+xstep]; // 1,1 vertice | ||
2126 | norm.X = h0 - h2; | ||
2127 | norm.Y = h1 - h0; | ||
2128 | } | ||
2129 | else | ||
2130 | { | ||
2131 | h2 = ((float)heights[iy]); // 0,0 vertice | ||
2132 | iy += xstep; | ||
2133 | h0 = ((float)heights[iy]); // 1,0 vertice | ||
2134 | h1 = (float)heights[iy+ystep]; // vertice 1,1 | ||
2135 | norm.X = h2 - h0; | ||
2136 | norm.Y = h0 - h1; | ||
2137 | } | ||
2138 | norm.Z = 1; | ||
2139 | norm.Normalize(); | ||
2140 | return norm; | ||
2141 | } | ||
1997 | 2142 | ||
1998 | public override void SetTerrain(float[] heightMap) | 2143 | public override void SetTerrain(float[] heightMap) |
1999 | { | 2144 | { |