aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKittoFlora2009-11-19 20:20:03 +0100
committerKittoFlora2009-11-19 20:20:03 +0100
commit251d1b8fbbc311ea267d0a44d5878df480d69338 (patch)
tree4ef142946d9b05d42564ddba63a99a67db5659bc
parentClean up messages in ODE (diff)
parentMerge branch 'master' into careminster (diff)
downloadopensim-SC-251d1b8fbbc311ea267d0a44d5878df480d69338.zip
opensim-SC-251d1b8fbbc311ea267d0a44d5878df480d69338.tar.gz
opensim-SC-251d1b8fbbc311ea267d0a44d5878df480d69338.tar.bz2
opensim-SC-251d1b8fbbc311ea267d0a44d5878df480d69338.tar.xz
Merge branch 'careminster' into tests
-rw-r--r--OpenSim/Data/IPresenceData.cs11
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs19
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs33
-rw-r--r--OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs5
-rw-r--r--OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs (renamed from OpenSim/Region/Framework/Scenes/AnimationSet.cs)23
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs (renamed from OpenSim/Region/Framework/Scenes/AvatarAnimations.cs)2
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs (renamed from OpenSim/Region/Framework/Scenes/BinBVHAnimation.cs)2
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs448
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs521
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs26
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs9
-rw-r--r--OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs61
-rw-r--r--OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs182
-rw-r--r--OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs44
-rw-r--r--OpenSim/Services/Interfaces/IPresenceService.cs8
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs14
-rw-r--r--OpenSim/Tests/Common/Mock/MockUserService.cs26
23 files changed, 911 insertions, 546 deletions
diff --git a/OpenSim/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs
index ca661a2..e5a8ebd 100644
--- a/OpenSim/Data/IPresenceData.cs
+++ b/OpenSim/Data/IPresenceData.cs
@@ -32,11 +32,11 @@ using OpenSim.Framework;
32 32
33namespace OpenSim.Data 33namespace OpenSim.Data
34{ 34{
35 public class PresenceData 35 public struct PresenceData
36 { 36 {
37 public UUID PrincipalID; 37 public UUID UUID;
38 public UUID RegionID; 38 public UUID currentRegion;
39 public Dictionary<string, object> Data; 39 public Dictionary<string, string> Data;
40 } 40 }
41 41
42 /// <summary> 42 /// <summary>
@@ -48,7 +48,8 @@ namespace OpenSim.Data
48 48
49 PresenceData Get(UUID principalID); 49 PresenceData Get(UUID principalID);
50 50
51 bool SetDataItem(UUID principalID, string item, string value); 51 bool SetUserDataItem(UUID principalID, string item, string value);
52 bool SetRegionDataItem(UUID principalID, string item, string value);
52 53
53 bool Delete(UUID regionID); 54 bool Delete(UUID regionID);
54 } 55 }
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index 4eb4a24..4e27e26 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -112,7 +112,7 @@ namespace OpenSim.Data.MySQL
112 for (int i = 0 ; i < fields.Length ; i++) 112 for (int i = 0 ; i < fields.Length ; i++)
113 { 113 {
114 cmd.Parameters.AddWithValue(fields[i], keys[i]); 114 cmd.Parameters.AddWithValue(fields[i], keys[i]);
115 terms.Add(fields[i] + " = ?" + fields[i]); 115 terms.Add("`" + fields[i] + "` = ?" + fields[i]);
116 } 116 }
117 117
118 string where = String.Join(" and ", terms.ToArray()); 118 string where = String.Join(" and ", terms.ToArray());
@@ -190,11 +190,26 @@ namespace OpenSim.Data.MySQL
190 return DoQuery(cmd); 190 return DoQuery(cmd);
191 } 191 }
192 192
193 public void Store(T row) 193 public bool Store(T row)
194 { 194 {
195 MySqlCommand cmd = new MySqlCommand(); 195 MySqlCommand cmd = new MySqlCommand();
196 196
197 string query = ""; 197 string query = "";
198
199 return false;
200 }
201
202 public bool Delete(string field, string val)
203 {
204 MySqlCommand cmd = new MySqlCommand();
205
206 cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field);
207 cmd.Parameters.AddWithValue(field, val);
208
209 if (ExecuteNonQuery(cmd) > 0)
210 return true;
211
212 return false;
198 } 213 }
199 } 214 }
200} 215}
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index 97231ff..e43d634 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -1153,7 +1153,7 @@ namespace OpenSim.Framework
1153 prim.Light.Radius = this.LightRadius; 1153 prim.Light.Radius = this.LightRadius;
1154 } 1154 }
1155 1155
1156 prim.Textures = new Primitive.TextureEntry(this.TextureEntry, 0, this.TextureEntry.Length); 1156 prim.Textures = this.Textures;
1157 1157
1158 prim.Properties = new Primitive.ObjectProperties(); 1158 prim.Properties = new Primitive.ObjectProperties();
1159 prim.Properties.Name = "Primitive"; 1159 prim.Properties.Name = "Primitive";
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
index ce32443..cc8bdb6 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
@@ -28,33 +28,6 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31/*
32 * Copyright (c) Contributors, http://opensimulator.org/
33 * See CONTRIBUTORS.TXT for a full list of copyright holders.
34 *
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions are met:
37 * * Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * * Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * * Neither the name of the OpenSimulator Project nor the
43 * names of its contributors may be used to endorse or promote products
44 * derived from this software without specific prior written permission.
45 *
46 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
47 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
48 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
49 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
50 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
51 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
52 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
55 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 */
57
58using System.IO; 31using System.IO;
59using System.Text; 32using System.Text;
60using HttpServer; 33using HttpServer;
@@ -77,9 +50,7 @@ namespace OpenSim.Framework.Servers.HttpServer
77 private readonly BaseHttpServer m_server; 50 private readonly BaseHttpServer m_server;
78 private BlockingQueue<PollServiceHttpRequest> m_request; 51 private BlockingQueue<PollServiceHttpRequest> m_request;
79 private bool m_running = true; 52 private bool m_running = true;
80 private int m_timeout = 250; 53 private int m_timeout = 250;
81
82
83 54
84 public PollServiceWorkerThread(BaseHttpServer pSrv, int pTimeout) 55 public PollServiceWorkerThread(BaseHttpServer pSrv, int pTimeout)
85 { 56 {
@@ -135,4 +106,4 @@ namespace OpenSim.Framework.Servers.HttpServer
135 m_request.Enqueue(pPollServiceHttpRequest); 106 m_request.Enqueue(pPollServiceHttpRequest);
136 } 107 }
137 } 108 }
138} 109} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index 43761fc..f51d0c2 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -124,7 +124,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
124 { 124 {
125 if (RenderPlugins.ContainsKey(contentType)) 125 if (RenderPlugins.ContainsKey(contentType))
126 { 126 {
127
128 DynamicTextureUpdater updater = new DynamicTextureUpdater(); 127 DynamicTextureUpdater updater = new DynamicTextureUpdater();
129 updater.SimUUID = simID; 128 updater.SimUUID = simID;
130 updater.PrimID = primID; 129 updater.PrimID = primID;
@@ -275,7 +274,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
275 /// </summary> 274 /// </summary>
276 public void DataReceived(byte[] data, Scene scene) 275 public void DataReceived(byte[] data, Scene scene)
277 { 276 {
278
279 SceneObjectPart part = scene.GetSceneObjectPart(PrimID); 277 SceneObjectPart part = scene.GetSceneObjectPart(PrimID);
280 278
281 if (part == null || data == null || data.Length <= 1) 279 if (part == null || data == null || data.Length <= 1)
@@ -364,7 +362,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
364 362
365 if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0)) 363 if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
366 { 364 {
367 // scene.CommsManager.AssetCache.ExpireAsset(oldID);
368 scene.AssetService.Delete(oldID.ToString()); 365 scene.AssetService.Delete(oldID.ToString());
369 } 366 }
370 } 367 }
@@ -433,4 +430,4 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
433 430
434 #endregion 431 #endregion
435 } 432 }
436} 433} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
index 95f9cef..abcaf91 100644
--- a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
+++ b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
@@ -30,10 +30,8 @@ using OpenMetaverse;
30 30
31namespace OpenSim.Region.Framework.Interfaces 31namespace OpenSim.Region.Framework.Interfaces
32{ 32{
33
34 public interface IDynamicTextureManager 33 public interface IDynamicTextureManager
35 { 34 {
36
37 void RegisterRender(string handleType, IDynamicTextureRender render); 35 void RegisterRender(string handleType, IDynamicTextureRender render);
38 void ReturnData(UUID id, byte[] data); 36 void ReturnData(UUID id, byte[] data);
39 37
diff --git a/OpenSim/Region/Framework/Scenes/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
index 740d168..9176d3d 100644
--- a/OpenSim/Region/Framework/Scenes/AnimationSet.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
@@ -32,20 +32,21 @@ using OpenMetaverse;
32 32
33using Animation = OpenSim.Framework.Animation; 33using Animation = OpenSim.Framework.Animation;
34 34
35namespace OpenSim.Region.Framework.Scenes 35namespace OpenSim.Region.Framework.Scenes.Animation
36{ 36{
37 [Serializable] 37 [Serializable]
38 public class AnimationSet 38 public class AnimationSet
39 { 39 {
40 public static AvatarAnimations Animations = new AvatarAnimations(); 40 public static AvatarAnimations Animations = new AvatarAnimations();
41 41
42 private Animation m_defaultAnimation = new Animation(); 42 private OpenSim.Framework.Animation m_defaultAnimation = new OpenSim.Framework.Animation();
43 private List<Animation> m_animations = new List<Animation>(); 43 private List<OpenSim.Framework.Animation> m_animations = new List<OpenSim.Framework.Animation>();
44 44
45 public Animation DefaultAnimation 45 public OpenSim.Framework.Animation DefaultAnimation
46 { 46 {
47 get { return m_defaultAnimation; } 47 get { return m_defaultAnimation; }
48 } 48 }
49
49 public AnimationSet() 50 public AnimationSet()
50 { 51 {
51 ResetDefaultAnimation(); 52 ResetDefaultAnimation();
@@ -71,7 +72,7 @@ namespace OpenSim.Region.Framework.Scenes
71 { 72 {
72 if (!HasAnimation(animID)) 73 if (!HasAnimation(animID))
73 { 74 {
74 m_animations.Add(new Animation(animID, sequenceNum, objectID)); 75 m_animations.Add(new OpenSim.Framework.Animation(animID, sequenceNum, objectID));
75 return true; 76 return true;
76 } 77 }
77 } 78 }
@@ -115,7 +116,7 @@ namespace OpenSim.Region.Framework.Scenes
115 { 116 {
116 if (m_defaultAnimation.AnimID != animID) 117 if (m_defaultAnimation.AnimID != animID)
117 { 118 {
118 m_defaultAnimation = new Animation(animID, sequenceNum, objectID); 119 m_defaultAnimation = new OpenSim.Framework.Animation(animID, sequenceNum, objectID);
119 return true; 120 return true;
120 } 121 }
121 return false; 122 return false;
@@ -159,13 +160,13 @@ namespace OpenSim.Region.Framework.Scenes
159 } 160 }
160 } 161 }
161 162
162 public Animation[] ToArray() 163 public OpenSim.Framework.Animation[] ToArray()
163 { 164 {
164 Animation[] theArray = new Animation[m_animations.Count]; 165 OpenSim.Framework.Animation[] theArray = new OpenSim.Framework.Animation[m_animations.Count];
165 uint i = 0; 166 uint i = 0;
166 try 167 try
167 { 168 {
168 foreach (Animation anim in m_animations) 169 foreach (OpenSim.Framework.Animation anim in m_animations)
169 theArray[i++] = anim; 170 theArray[i++] = anim;
170 } 171 }
171 catch 172 catch
@@ -175,9 +176,9 @@ namespace OpenSim.Region.Framework.Scenes
175 return theArray; 176 return theArray;
176 } 177 }
177 178
178 public void FromArray(Animation[] theArray) 179 public void FromArray(OpenSim.Framework.Animation[] theArray)
179 { 180 {
180 foreach (Animation anim in theArray) 181 foreach (OpenSim.Framework.Animation anim in theArray)
181 m_animations.Add(anim); 182 m_animations.Add(anim);
182 } 183 }
183 } 184 }
diff --git a/OpenSim/Region/Framework/Scenes/AvatarAnimations.cs b/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs
index 72d599a..659c3a5 100644
--- a/OpenSim/Region/Framework/Scenes/AvatarAnimations.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs
@@ -29,7 +29,7 @@ using System.Collections.Generic;
29using System.Xml; 29using System.Xml;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32namespace OpenSim.Region.Framework.Scenes 32namespace OpenSim.Region.Framework.Scenes.Animation
33{ 33{
34 public class AvatarAnimations 34 public class AvatarAnimations
35 { 35 {
diff --git a/OpenSim/Region/Framework/Scenes/BinBVHAnimation.cs b/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs
index 5f2eb0d..3afc87f 100644
--- a/OpenSim/Region/Framework/Scenes/BinBVHAnimation.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs
@@ -29,7 +29,7 @@ using System;
29using System.IO; 29using System.IO;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32namespace OpenSim.Region.Framework.Scenes 32namespace OpenSim.Region.Framework.Scenes.Animation
33{ 33{
34 /// <summary> 34 /// <summary>
35 /// Written to decode and encode a binary animation asset. 35 /// Written to decode and encode a binary animation asset.
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
new file mode 100644
index 0000000..cbe4118
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -0,0 +1,448 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Region.Physics.Manager;
35
36namespace OpenSim.Region.Framework.Scenes.Animation
37{
38 /// <summary>
39 /// Handle all animation duties for a scene presence
40 /// </summary>
41 public class ScenePresenceAnimator
42 {
43 public AnimationSet Animations
44 {
45 get { return m_animations; }
46 }
47 protected AnimationSet m_animations = new AnimationSet();
48
49 /// <value>
50 /// The current movement animation
51 /// </value>
52 public string CurrentMovementAnimation
53 {
54 get { return m_movementAnimation; }
55 }
56 protected string m_movementAnimation = "DEFAULT";
57
58 private int m_animTickFall;
59 private int m_animTickJump;
60
61 /// <value>
62 /// The scene presence that this animator applies to
63 /// </value>
64 protected ScenePresence m_scenePresence;
65
66 public ScenePresenceAnimator(ScenePresence sp)
67 {
68 m_scenePresence = sp;
69 }
70
71 public void AddAnimation(UUID animID, UUID objectID)
72 {
73 if (m_scenePresence.IsChildAgent)
74 return;
75
76 if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID))
77 SendAnimPack();
78 }
79
80 // Called from scripts
81 public void AddAnimation(string name, UUID objectID)
82 {
83 if (m_scenePresence.IsChildAgent)
84 return;
85
86 UUID animID = m_scenePresence.ControllingClient.GetDefaultAnimation(name);
87 if (animID == UUID.Zero)
88 return;
89
90 AddAnimation(animID, objectID);
91 }
92
93 public void RemoveAnimation(UUID animID)
94 {
95 if (m_scenePresence.IsChildAgent)
96 return;
97
98 if (m_animations.Remove(animID))
99 SendAnimPack();
100 }
101
102 // Called from scripts
103 public void RemoveAnimation(string name)
104 {
105 if (m_scenePresence.IsChildAgent)
106 return;
107
108 UUID animID = m_scenePresence.ControllingClient.GetDefaultAnimation(name);
109 if (animID == UUID.Zero)
110 return;
111
112 RemoveAnimation(animID);
113 }
114
115 public void ResetAnimations()
116 {
117 m_animations.Clear();
118 }
119
120 /// <summary>
121 /// The movement animation is reserved for "main" animations
122 /// that are mutually exclusive, e.g. flying and sitting.
123 /// </summary>
124 public void TrySetMovementAnimation(string anim)
125 {
126 //m_log.DebugFormat("Updating movement animation to {0}", anim);
127
128 if (!m_scenePresence.IsChildAgent)
129 {
130 if (m_animations.TrySetDefaultAnimation(
131 anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero))
132 {
133 // 16384 is CHANGED_ANIMATION
134 m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 });
135 SendAnimPack();
136 }
137 }
138 }
139
140 /// <summary>
141 /// This method determines the proper movement related animation
142 /// </summary>
143 public string GetMovementAnimation()
144 {
145 const float FALL_DELAY = 0.33f;
146 const float PREJUMP_DELAY = 0.25f;
147
148 #region Inputs
149
150 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags;
151 PhysicsActor actor = m_scenePresence.PhysicsActor;
152
153 // Create forward and left vectors from the current avatar rotation
154 Matrix4 rotMatrix = Matrix4.CreateFromQuaternion(m_scenePresence.Rotation);
155 Vector3 fwd = Vector3.Transform(Vector3.UnitX, rotMatrix);
156 Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix);
157
158 // Check control flags
159 bool heldForward = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
160 bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG;
161 bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS;
162 bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG;
163 //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT;
164 //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT;
165 bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS;
166 bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG;
167 //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY;
168 //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK;
169
170 // Direction in which the avatar is trying to move
171 Vector3 move = Vector3.Zero;
172 if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; }
173 if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; }
174 if (heldLeft) { move.X += left.X; move.Y += left.Y; }
175 if (heldRight) { move.X -= left.X; move.Y -= left.Y; }
176 if (heldUp) { move.Z += 1; }
177 if (heldDown) { move.Z -= 1; }
178
179 // Is the avatar trying to move?
180// bool moving = (move != Vector3.Zero);
181 bool jumping = m_animTickJump != 0;
182
183 #endregion Inputs
184
185 #region Flying
186
187 if (actor != null && actor.Flying)
188 {
189 m_animTickFall = 0;
190 m_animTickJump = 0;
191
192 if (move.X != 0f || move.Y != 0f)
193 {
194 return (m_scenePresence.Scene.m_useFlySlow ? "FLYSLOW" : "FLY");
195 }
196 else if (move.Z > 0f)
197 {
198 return "HOVER_UP";
199 }
200 else if (move.Z < 0f)
201 {
202 if (actor != null && actor.IsColliding)
203 return "LAND";
204 else
205 return "HOVER_DOWN";
206 }
207 else
208 {
209 return "HOVER";
210 }
211 }
212
213 #endregion Flying
214
215 #region Falling/Floating/Landing
216
217 if (actor == null || !actor.IsColliding)
218 {
219 float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
220 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f;
221
222 if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f))
223 {
224 // Just started falling
225 m_animTickFall = Environment.TickCount;
226 }
227 else if (!jumping && fallElapsed > FALL_DELAY)
228 {
229 // Falling long enough to trigger the animation
230 return "FALLDOWN";
231 }
232
233 return m_movementAnimation;
234 }
235
236 #endregion Falling/Floating/Landing
237
238 #region Ground Movement
239
240 if (m_movementAnimation == "FALLDOWN")
241 {
242 m_animTickFall = Environment.TickCount;
243
244 // TODO: SOFT_LAND support
245 return "LAND";
246 }
247 else if (m_movementAnimation == "LAND")
248 {
249 float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
250
251 if (landElapsed <= FALL_DELAY)
252 return "LAND";
253 }
254
255 m_animTickFall = 0;
256
257 if (move.Z > 0f)
258 {
259 // Jumping
260 if (!jumping)
261 {
262 // Begin prejump
263 m_animTickJump = Environment.TickCount;
264 return "PREJUMP";
265 }
266 else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 1000.0f)
267 {
268 // Start actual jump
269 if (m_animTickJump == -1)
270 {
271 // Already jumping! End the current jump
272 m_animTickJump = 0;
273 return "JUMP";
274 }
275
276 m_animTickJump = -1;
277 return "JUMP";
278 }
279 }
280 else
281 {
282 // Not jumping
283 m_animTickJump = 0;
284
285 if (move.X != 0f || move.Y != 0f)
286 {
287 // Walking / crouchwalking / running
288 if (move.Z < 0f)
289 return "CROUCHWALK";
290 else if (m_scenePresence.SetAlwaysRun)
291 return "RUN";
292 else
293 return "WALK";
294 }
295 else
296 {
297 // Not walking
298 if (move.Z < 0f)
299 return "CROUCH";
300 else
301 return "STAND";
302 }
303 }
304
305 #endregion Ground Movement
306
307 return m_movementAnimation;
308 }
309
310 /// <summary>
311 /// Update the movement animation of this avatar according to its current state
312 /// </summary>
313 public void UpdateMovementAnimations()
314 {
315 m_movementAnimation = GetMovementAnimation();
316
317 if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump)
318 {
319 // This was the previous behavior before PREJUMP
320 TrySetMovementAnimation("JUMP");
321 }
322 else
323 {
324 TrySetMovementAnimation(m_movementAnimation);
325 }
326 }
327
328 public UUID[] GetAnimationArray()
329 {
330 UUID[] animIDs;
331 int[] sequenceNums;
332 UUID[] objectIDs;
333 m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs);
334 return animIDs;
335 }
336
337 public BinBVHAnimation GenerateRandomAnimation()
338 {
339 int rnditerations = 3;
340 BinBVHAnimation anim = new BinBVHAnimation();
341 List<string> parts = new List<string>();
342 parts.Add("mPelvis");parts.Add("mHead");parts.Add("mTorso");
343 parts.Add("mHipLeft");parts.Add("mHipRight");parts.Add("mHipLeft");parts.Add("mKneeLeft");
344 parts.Add("mKneeRight");parts.Add("mCollarLeft");parts.Add("mCollarRight");parts.Add("mNeck");
345 parts.Add("mElbowLeft");parts.Add("mElbowRight");parts.Add("mWristLeft");parts.Add("mWristRight");
346 parts.Add("mShoulderLeft");parts.Add("mShoulderRight");parts.Add("mAnkleLeft");parts.Add("mAnkleRight");
347 parts.Add("mEyeRight");parts.Add("mChest");parts.Add("mToeLeft");parts.Add("mToeRight");
348 parts.Add("mFootLeft");parts.Add("mFootRight");parts.Add("mEyeLeft");
349 anim.HandPose = 1;
350 anim.InPoint = 0;
351 anim.OutPoint = (rnditerations * .10f);
352 anim.Priority = 7;
353 anim.Loop = false;
354 anim.Length = (rnditerations * .10f);
355 anim.ExpressionName = "afraid";
356 anim.EaseInTime = 0;
357 anim.EaseOutTime = 0;
358
359 string[] strjoints = parts.ToArray();
360 anim.Joints = new binBVHJoint[strjoints.Length];
361 for (int j = 0; j < strjoints.Length; j++)
362 {
363 anim.Joints[j] = new binBVHJoint();
364 anim.Joints[j].Name = strjoints[j];
365 anim.Joints[j].Priority = 7;
366 anim.Joints[j].positionkeys = new binBVHJointKey[rnditerations];
367 anim.Joints[j].rotationkeys = new binBVHJointKey[rnditerations];
368 Random rnd = new Random();
369 for (int i = 0; i < rnditerations; i++)
370 {
371 anim.Joints[j].rotationkeys[i] = new binBVHJointKey();
372 anim.Joints[j].rotationkeys[i].time = (i*.10f);
373 anim.Joints[j].rotationkeys[i].key_element.X = ((float) rnd.NextDouble()*2 - 1);
374 anim.Joints[j].rotationkeys[i].key_element.Y = ((float) rnd.NextDouble()*2 - 1);
375 anim.Joints[j].rotationkeys[i].key_element.Z = ((float) rnd.NextDouble()*2 - 1);
376 anim.Joints[j].positionkeys[i] = new binBVHJointKey();
377 anim.Joints[j].positionkeys[i].time = (i*.10f);
378 anim.Joints[j].positionkeys[i].key_element.X = 0;
379 anim.Joints[j].positionkeys[i].key_element.Y = 0;
380 anim.Joints[j].positionkeys[i].key_element.Z = 0;
381 }
382 }
383
384 AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation);
385 Animasset.Data = anim.ToBytes();
386 Animasset.Temporary = true;
387 Animasset.Local = true;
388 Animasset.Description = "dance";
389 //BinBVHAnimation bbvhanim = new BinBVHAnimation(Animasset.Data);
390
391 m_scenePresence.Scene.AssetService.Store(Animasset);
392 AddAnimation(Animasset.FullID, m_scenePresence.UUID);
393 return anim;
394 }
395
396 /// <summary>
397 ///
398 /// </summary>
399 /// <param name="animations"></param>
400 /// <param name="seqs"></param>
401 /// <param name="objectIDs"></param>
402 public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs)
403 {
404 if (m_scenePresence.IsChildAgent)
405 return;
406
407 m_scenePresence.Scene.ForEachClient(
408 delegate(IClientAPI client)
409 {
410 client.SendAnimations(animations, seqs, m_scenePresence.ControllingClient.AgentId, objectIDs);
411 });
412 }
413
414 public void SendAnimPackToClient(IClientAPI client)
415 {
416 if (m_scenePresence.IsChildAgent)
417 return;
418
419 UUID[] animIDs;
420 int[] sequenceNums;
421 UUID[] objectIDs;
422
423 m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs);
424
425 m_scenePresence.ControllingClient.SendAnimations(
426 animIDs, sequenceNums, m_scenePresence.ControllingClient.AgentId, objectIDs);
427 }
428
429 /// <summary>
430 /// Send animation information about this avatar to all clients.
431 /// </summary>
432 public void SendAnimPack()
433 {
434 //m_log.Debug("Sending animation pack to all");
435
436 if (m_scenePresence.IsChildAgent)
437 return;
438
439 UUID[] animIDs;
440 int[] sequenceNums;
441 UUID[] objectIDs;
442
443 m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs);
444
445 SendAnimPack(animIDs, sequenceNums, objectIDs);
446 }
447 }
448} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
index d7e62a8..0f9c190 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
@@ -82,7 +82,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
82 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>(); 82 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
83 83
84 // Reset animations; the viewer does that in teleports. 84 // Reset animations; the viewer does that in teleports.
85 avatar.ResetAnimations(); 85 avatar.Animator.ResetAnimations();
86 86
87 if (regionHandle == m_regionInfo.RegionHandle) 87 if (regionHandle == m_regionInfo.RegionHandle)
88 { 88 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index aeca7df..2e15b86 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1266,7 +1266,7 @@ namespace OpenSim.Region.Framework.Scenes
1266 // allocations, and there is no more work to be done until someone logs in 1266 // allocations, and there is no more work to be done until someone logs in
1267 GC.Collect(); 1267 GC.Collect();
1268 1268
1269 m_log.Debug("[REGION]: Enabling Logins"); 1269 m_log.DebugFormat("[REGION]: Enabling Logins for {0}", RegionInfo.RegionName);
1270 loginsdisabled = false; 1270 loginsdisabled = false;
1271 } 1271 }
1272 } 1272 }
@@ -1276,24 +1276,25 @@ namespace OpenSim.Region.Framework.Scenes
1276 } 1276 }
1277 catch (AccessViolationException e) 1277 catch (AccessViolationException e)
1278 { 1278 {
1279 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1279 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1280 } 1280 }
1281 //catch (NullReferenceException e) 1281 //catch (NullReferenceException e)
1282 //{ 1282 //{
1283 // m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1283 // m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1284 //} 1284 //}
1285 catch (InvalidOperationException e) 1285 catch (InvalidOperationException e)
1286 { 1286 {
1287 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1287 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1288 } 1288 }
1289 catch (Exception e) 1289 catch (Exception e)
1290 { 1290 {
1291 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1291 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1292 } 1292 }
1293 finally 1293 finally
1294 { 1294 {
1295 m_lastupdate = DateTime.UtcNow; 1295 m_lastupdate = DateTime.UtcNow;
1296 } 1296 }
1297
1297 maintc = Environment.TickCount - maintc; 1298 maintc = Environment.TickCount - maintc;
1298 maintc = (int)(m_timespan * 1000) - maintc; 1299 maintc = (int)(m_timespan * 1000) - maintc;
1299 1300
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 4a2db5e..76c6cab 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -801,7 +801,7 @@ namespace OpenSim.Region.Framework.Scenes
801 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>(); 801 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
802 802
803 // Reset animations; the viewer does that in teleports. 803 // Reset animations; the viewer does that in teleports.
804 avatar.ResetAnimations(); 804 avatar.Animator.ResetAnimations();
805 805
806 if (regionHandle == m_regionInfo.RegionHandle) 806 if (regionHandle == m_regionInfo.RegionHandle)
807 { 807 {
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 08c144a..1dedcf1 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Client; 35using OpenSim.Framework.Client;
36using OpenSim.Framework.Communications.Cache; 36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes.Animation;
38using OpenSim.Region.Framework.Scenes.Types; 39using OpenSim.Region.Framework.Scenes.Types;
39using OpenSim.Region.Physics.Manager; 40using OpenSim.Region.Physics.Manager;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion; 41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
@@ -79,6 +80,7 @@ namespace OpenSim.Region.Framework.Scenes
79// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); 80// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
80 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); 81 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
81 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); 82 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
83
82 /// <summary> 84 /// <summary>
83 /// Experimentally determined "fudge factor" to make sit-target positions 85 /// Experimentally determined "fudge factor" to make sit-target positions
84 /// the same as in SecondLife. Fudge factor was tested for 36 different 86 /// the same as in SecondLife. Fudge factor was tested for 36 different
@@ -93,7 +95,15 @@ namespace OpenSim.Region.Framework.Scenes
93 95
94 private ISceneViewer m_sceneViewer; 96 private ISceneViewer m_sceneViewer;
95 97
96 private AnimationSet m_animations = new AnimationSet(); 98 /// <value>
99 /// The animator for this avatar
100 /// </value>
101 public ScenePresenceAnimator Animator
102 {
103 get { return m_animator; }
104 }
105 protected ScenePresenceAnimator m_animator;
106
97 private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); 107 private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>();
98 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; 108 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
99 private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; 109 private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO;
@@ -134,12 +144,7 @@ namespace OpenSim.Region.Framework.Scenes
134 private int m_perfMonMS; 144 private int m_perfMonMS;
135 145
136 private bool m_setAlwaysRun; 146 private bool m_setAlwaysRun;
137 147
138 private string m_movementAnimation = "DEFAULT";
139 private int m_animTickFall;
140 private int m_animTickJump;
141 private bool m_useFlySlow;
142 private bool m_usePreJump;
143 private bool m_forceFly; 148 private bool m_forceFly;
144 private bool m_flyDisabled; 149 private bool m_flyDisabled;
145 150
@@ -227,7 +232,6 @@ namespace OpenSim.Region.Framework.Scenes
227 DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, 232 DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
228 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG 233 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
229 } 234 }
230
231 235
232 /// <summary> 236 /// <summary>
233 /// Position at which a significant movement was made 237 /// Position at which a significant movement was made
@@ -238,7 +242,10 @@ namespace OpenSim.Region.Framework.Scenes
238 string m_callbackURI; 242 string m_callbackURI;
239 ulong m_rootRegionHandle; 243 ulong m_rootRegionHandle;
240 244
241 private IScriptModule[] m_scriptEngines; 245 /// <value>
246 /// Script engines present in the scene
247 /// </value>
248 private IScriptModule[] m_scriptEngines;
242 249
243 #region Properties 250 #region Properties
244 251
@@ -586,11 +593,6 @@ namespace OpenSim.Region.Framework.Scenes
586 } 593 }
587 } 594 }
588 595
589 public AnimationSet Animations
590 {
591 get { return m_animations; }
592 }
593
594 private bool m_inTransit; 596 private bool m_inTransit;
595 private bool m_mouseLook; 597 private bool m_mouseLook;
596 private bool m_leftButtonDown; 598 private bool m_leftButtonDown;
@@ -625,6 +627,7 @@ namespace OpenSim.Region.Framework.Scenes
625 627
626 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) 628 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo)
627 { 629 {
630 m_animator = new ScenePresenceAnimator(this);
628 m_sendCourseLocationsMethod = SendCoarseLocationsDefault; 631 m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
629 CreateSceneViewer(); 632 CreateSceneViewer();
630 m_rootRegionHandle = reginfo.RegionHandle; 633 m_rootRegionHandle = reginfo.RegionHandle;
@@ -637,15 +640,12 @@ namespace OpenSim.Region.Framework.Scenes
637 m_regionInfo = reginfo; 640 m_regionInfo = reginfo;
638 m_localId = m_scene.AllocateLocalId(); 641 m_localId = m_scene.AllocateLocalId();
639 642
640 m_useFlySlow = m_scene.m_useFlySlow;
641 m_usePreJump = m_scene.m_usePreJump;
642
643 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 643 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
644 if (gm != null) 644 if (gm != null)
645 m_grouptitle = gm.GetGroupTitle(m_uuid); 645 m_grouptitle = gm.GetGroupTitle(m_uuid);
646 646
647 m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); 647 m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>();
648 648
649 AbsolutePosition = posLastSignificantMove = m_CameraCenter = 649 AbsolutePosition = posLastSignificantMove = m_CameraCenter =
650 m_lastCameraCenter = m_controllingClient.StartPos; 650 m_lastCameraCenter = m_controllingClient.StartPos;
651 651
@@ -656,7 +656,8 @@ namespace OpenSim.Region.Framework.Scenes
656 656
657 AdjustKnownSeeds(); 657 AdjustKnownSeeds();
658 658
659 TrySetMovementAnimation("STAND"); // TODO: I think, this won't send anything, as we are still a child here... 659 // TODO: I think, this won't send anything, as we are still a child here...
660 Animator.TrySetMovementAnimation("STAND");
660 661
661 // we created a new ScenePresence (a new child agent) in a fresh region. 662 // we created a new ScenePresence (a new child agent) in a fresh region.
662 // Request info about all the (root) agents in this region 663 // Request info about all the (root) agents in this region
@@ -665,21 +666,18 @@ namespace OpenSim.Region.Framework.Scenes
665 666
666 RegisterToEvents(); 667 RegisterToEvents();
667 SetDirectionVectors(); 668 SetDirectionVectors();
668
669 } 669 }
670 670
671 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, 671 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
672 AvatarWearable[] wearables) 672 AvatarWearable[] wearables)
673 : this(client, world, reginfo) 673 : this(client, world, reginfo)
674 { 674 {
675 CreateSceneViewer(); 675 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
676 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
677 } 676 }
678 677
679 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) 678 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
680 : this(client, world, reginfo) 679 : this(client, world, reginfo)
681 { 680 {
682 CreateSceneViewer();
683 m_appearance = appearance; 681 m_appearance = appearance;
684 } 682 }
685 683
@@ -857,7 +855,7 @@ namespace OpenSim.Region.Framework.Scenes
857 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying 855 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
858 // avatar to return to the standing position in mid-air. On login it looks like this is being sent 856 // avatar to return to the standing position in mid-air. On login it looks like this is being sent
859 // elsewhere anyway 857 // elsewhere anyway
860 //SendAnimPack(); 858 // Animator.SendAnimPack();
861 859
862 m_scene.SwapRootAgentCount(false); 860 m_scene.SwapRootAgentCount(false);
863 861
@@ -879,7 +877,7 @@ namespace OpenSim.Region.Framework.Scenes
879 ScenePresence presence = animAgents[i]; 877 ScenePresence presence = animAgents[i];
880 878
881 if (presence != this) 879 if (presence != this)
882 presence.SendAnimPackToClient(ControllingClient); 880 presence.Animator.SendAnimPackToClient(ControllingClient);
883 } 881 }
884 882
885 m_scene.EventManager.TriggerOnMakeRootAgent(this); 883 m_scene.EventManager.TriggerOnMakeRootAgent(this);
@@ -894,7 +892,7 @@ namespace OpenSim.Region.Framework.Scenes
894 /// </summary> 892 /// </summary>
895 public void MakeChildAgent() 893 public void MakeChildAgent()
896 { 894 {
897 m_animations.Clear(); 895 Animator.ResetAnimations();
898 896
899// m_log.DebugFormat( 897// m_log.DebugFormat(
900// "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", 898// "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}",
@@ -995,7 +993,7 @@ namespace OpenSim.Region.Framework.Scenes
995 AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f)); 993 AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f));
996 } 994 }
997 995
998 TrySetMovementAnimation("LAND"); 996 Animator.TrySetMovementAnimation("LAND");
999 SendFullUpdateToAllClients(); 997 SendFullUpdateToAllClients();
1000 } 998 }
1001 999
@@ -1247,7 +1245,7 @@ namespace OpenSim.Region.Framework.Scenes
1247 // TODO: This doesn't prevent the user from walking yet. 1245 // TODO: This doesn't prevent the user from walking yet.
1248 // Setting parent ID would fix this, if we knew what value 1246 // Setting parent ID would fix this, if we knew what value
1249 // to use. Or we could add a m_isSitting variable. 1247 // to use. Or we could add a m_isSitting variable.
1250 TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); 1248 Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
1251 } 1249 }
1252 1250
1253 // In the future, these values might need to go global. 1251 // In the future, these values might need to go global.
@@ -1453,7 +1451,7 @@ namespace OpenSim.Region.Framework.Scenes
1453 AddNewMovement(agent_control_v3, q); 1451 AddNewMovement(agent_control_v3, q);
1454 1452
1455 if (update_movementflag) 1453 if (update_movementflag)
1456 UpdateMovementAnimations(); 1454 Animator.UpdateMovementAnimations();
1457 } 1455 }
1458 } 1456 }
1459 1457
@@ -1561,7 +1559,7 @@ namespace OpenSim.Region.Framework.Scenes
1561 } 1559 }
1562 } 1560 }
1563 /// <summary> 1561 /// <summary>
1564 /// Perform the logic necessary to stand the client up. This method also executes 1562 /// Perform the logic necessary to stand the avatar up. This method also executes
1565 /// the stand animation. 1563 /// the stand animation.
1566 /// </summary> 1564 /// </summary>
1567 public void StandUp() 1565 public void StandUp()
@@ -1611,7 +1609,7 @@ namespace OpenSim.Region.Framework.Scenes
1611 } 1609 }
1612 } 1610 }
1613 1611
1614 TrySetMovementAnimation("STAND"); 1612 Animator.TrySetMovementAnimation("STAND");
1615 } 1613 }
1616 1614
1617 private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) 1615 private SceneObjectPart FindNextAvailableSitTarget(UUID targetID)
@@ -1850,7 +1848,7 @@ namespace OpenSim.Region.Framework.Scenes
1850 Velocity = Vector3.Zero; 1848 Velocity = Vector3.Zero;
1851 RemoveFromPhysicalScene(); 1849 RemoveFromPhysicalScene();
1852 1850
1853 TrySetMovementAnimation(sitAnimation); 1851 Animator.TrySetMovementAnimation(sitAnimation);
1854 SendFullUpdateToAllClients(); 1852 SendFullUpdateToAllClients();
1855 // This may seem stupid, but Our Full updates don't send avatar rotation :P 1853 // This may seem stupid, but Our Full updates don't send avatar rotation :P
1856 // So we're also sending a terse update (which has avatar rotation) 1854 // So we're also sending a terse update (which has avatar rotation)
@@ -1870,352 +1868,15 @@ namespace OpenSim.Region.Framework.Scenes
1870 PhysicsActor.SetAlwaysRun = pSetAlwaysRun; 1868 PhysicsActor.SetAlwaysRun = pSetAlwaysRun;
1871 } 1869 }
1872 } 1870 }
1873 public BinBVHAnimation GenerateRandomAnimation()
1874 {
1875 int rnditerations = 3;
1876 BinBVHAnimation anim = new BinBVHAnimation();
1877 List<string> parts = new List<string>();
1878 parts.Add("mPelvis");parts.Add("mHead");parts.Add("mTorso");
1879 parts.Add("mHipLeft");parts.Add("mHipRight");parts.Add("mHipLeft");parts.Add("mKneeLeft");
1880 parts.Add("mKneeRight");parts.Add("mCollarLeft");parts.Add("mCollarRight");parts.Add("mNeck");
1881 parts.Add("mElbowLeft");parts.Add("mElbowRight");parts.Add("mWristLeft");parts.Add("mWristRight");
1882 parts.Add("mShoulderLeft");parts.Add("mShoulderRight");parts.Add("mAnkleLeft");parts.Add("mAnkleRight");
1883 parts.Add("mEyeRight");parts.Add("mChest");parts.Add("mToeLeft");parts.Add("mToeRight");
1884 parts.Add("mFootLeft");parts.Add("mFootRight");parts.Add("mEyeLeft");
1885 anim.HandPose = 1;
1886 anim.InPoint = 0;
1887 anim.OutPoint = (rnditerations * .10f);
1888 anim.Priority = 7;
1889 anim.Loop = false;
1890 anim.Length = (rnditerations * .10f);
1891 anim.ExpressionName = "afraid";
1892 anim.EaseInTime = 0;
1893 anim.EaseOutTime = 0;
1894
1895 string[] strjoints = parts.ToArray();
1896 anim.Joints = new binBVHJoint[strjoints.Length];
1897 for (int j = 0; j < strjoints.Length; j++)
1898 {
1899 anim.Joints[j] = new binBVHJoint();
1900 anim.Joints[j].Name = strjoints[j];
1901 anim.Joints[j].Priority = 7;
1902 anim.Joints[j].positionkeys = new binBVHJointKey[rnditerations];
1903 anim.Joints[j].rotationkeys = new binBVHJointKey[rnditerations];
1904 Random rnd = new Random();
1905 for (int i = 0; i < rnditerations; i++)
1906 {
1907 anim.Joints[j].rotationkeys[i] = new binBVHJointKey();
1908 anim.Joints[j].rotationkeys[i].time = (i*.10f);
1909 anim.Joints[j].rotationkeys[i].key_element.X = ((float) rnd.NextDouble()*2 - 1);
1910 anim.Joints[j].rotationkeys[i].key_element.Y = ((float) rnd.NextDouble()*2 - 1);
1911 anim.Joints[j].rotationkeys[i].key_element.Z = ((float) rnd.NextDouble()*2 - 1);
1912 anim.Joints[j].positionkeys[i] = new binBVHJointKey();
1913 anim.Joints[j].positionkeys[i].time = (i*.10f);
1914 anim.Joints[j].positionkeys[i].key_element.X = 0;
1915 anim.Joints[j].positionkeys[i].key_element.Y = 0;
1916 anim.Joints[j].positionkeys[i].key_element.Z = 0;
1917 }
1918 }
1919
1920
1921 AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation);
1922 Animasset.Data = anim.ToBytes();
1923 Animasset.Temporary = true;
1924 Animasset.Local = true;
1925 Animasset.Description = "dance";
1926 //BinBVHAnimation bbvhanim = new BinBVHAnimation(Animasset.Data);
1927
1928
1929 m_scene.AssetService.Store(Animasset);
1930 AddAnimation(Animasset.FullID, UUID);
1931 return anim;
1932 }
1933 public void AddAnimation(UUID animID, UUID objectID)
1934 {
1935 if (m_isChildAgent)
1936 return;
1937
1938 if (m_animations.Add(animID, m_controllingClient.NextAnimationSequenceNumber, objectID))
1939 SendAnimPack();
1940 }
1941
1942 // Called from scripts
1943 public void AddAnimation(string name, UUID objectID)
1944 {
1945 if (m_isChildAgent)
1946 return;
1947
1948 UUID animID = m_controllingClient.GetDefaultAnimation(name);
1949 if (animID == UUID.Zero)
1950 return;
1951
1952 AddAnimation(animID, objectID);
1953 }
1954
1955 public void RemoveAnimation(UUID animID)
1956 {
1957 if (m_isChildAgent)
1958 return;
1959
1960 if (m_animations.Remove(animID))
1961 SendAnimPack();
1962 }
1963
1964 // Called from scripts
1965 public void RemoveAnimation(string name)
1966 {
1967 if (m_isChildAgent)
1968 return;
1969
1970 UUID animID = m_controllingClient.GetDefaultAnimation(name);
1971 if (animID == UUID.Zero)
1972 return;
1973
1974 RemoveAnimation(animID);
1975 }
1976
1977 public UUID[] GetAnimationArray()
1978 {
1979 UUID[] animIDs;
1980 int[] sequenceNums;
1981 UUID[] objectIDs;
1982 m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs);
1983 return animIDs;
1984 }
1985 1871
1986 public void HandleStartAnim(IClientAPI remoteClient, UUID animID) 1872 public void HandleStartAnim(IClientAPI remoteClient, UUID animID)
1987 { 1873 {
1988 AddAnimation(animID, UUID.Zero); 1874 Animator.AddAnimation(animID, UUID.Zero);
1989 } 1875 }
1990 1876
1991 public void HandleStopAnim(IClientAPI remoteClient, UUID animID) 1877 public void HandleStopAnim(IClientAPI remoteClient, UUID animID)
1992 { 1878 {
1993 RemoveAnimation(animID); 1879 Animator.RemoveAnimation(animID);
1994 }
1995
1996 /// <summary>
1997 /// The movement animation is reserved for "main" animations
1998 /// that are mutually exclusive, e.g. flying and sitting.
1999 /// </summary>
2000 protected void TrySetMovementAnimation(string anim)
2001 {
2002 //m_log.DebugFormat("Updating movement animation to {0}", anim);
2003
2004 if (!m_isChildAgent)
2005 {
2006 if (m_animations.TrySetDefaultAnimation(anim, m_controllingClient.NextAnimationSequenceNumber, UUID.Zero))
2007 {
2008 if (m_scriptEngines != null)
2009 {
2010 lock (m_attachments)
2011 {
2012 foreach (SceneObjectGroup grp in m_attachments)
2013 {
2014 // 16384 is CHANGED_ANIMATION
2015 //
2016 // Send this to all attachment root prims
2017 //
2018 foreach (IScriptModule m in m_scriptEngines)
2019 {
2020 if (m == null) // No script engine loaded
2021 continue;
2022
2023 m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { 16384 });
2024 }
2025 }
2026 }
2027 }
2028 SendAnimPack();
2029 }
2030 }
2031 }
2032
2033 /// <summary>
2034 /// This method determines the proper movement related animation
2035 /// </summary>
2036 public string GetMovementAnimation()
2037 {
2038 const float FALL_DELAY = 0.33f;
2039 const float PREJUMP_DELAY = 0.25f;
2040
2041 #region Inputs
2042
2043 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_AgentControlFlags;
2044 PhysicsActor actor = m_physicsActor;
2045
2046 // Create forward and left vectors from the current avatar rotation
2047 Matrix4 rotMatrix = Matrix4.CreateFromQuaternion(m_bodyRot);
2048 Vector3 fwd = Vector3.Transform(Vector3.UnitX, rotMatrix);
2049 Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix);
2050
2051 // Check control flags
2052 bool heldForward = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
2053 bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG;
2054 bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS;
2055 bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG;
2056 //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT;
2057 //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT;
2058 bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS;
2059 bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG;
2060 //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY;
2061 //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK;
2062
2063 // Direction in which the avatar is trying to move
2064 Vector3 move = Vector3.Zero;
2065 if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; }
2066 if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; }
2067 if (heldLeft) { move.X += left.X; move.Y += left.Y; }
2068 if (heldRight) { move.X -= left.X; move.Y -= left.Y; }
2069 if (heldUp) { move.Z += 1; }
2070 if (heldDown) { move.Z -= 1; }
2071
2072 // Is the avatar trying to move?
2073// bool moving = (move != Vector3.Zero);
2074 bool jumping = m_animTickJump != 0;
2075
2076 #endregion Inputs
2077
2078 #region Flying
2079
2080 if (actor != null && actor.Flying)
2081 {
2082 m_animTickFall = 0;
2083 m_animTickJump = 0;
2084
2085 if (move.X != 0f || move.Y != 0f)
2086 {
2087 return (m_useFlySlow ? "FLYSLOW" : "FLY");
2088 }
2089 else if (move.Z > 0f)
2090 {
2091 return "HOVER_UP";
2092 }
2093 else if (move.Z < 0f)
2094 {
2095 if (actor != null && actor.IsColliding)
2096 return "LAND";
2097 else
2098 return "HOVER_DOWN";
2099 }
2100 else
2101 {
2102 return "HOVER";
2103 }
2104 }
2105
2106 #endregion Flying
2107
2108 #region Falling/Floating/Landing
2109
2110 if (actor == null || !actor.IsColliding)
2111 {
2112 float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
2113 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f;
2114
2115 if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f))
2116 {
2117 // Just started falling
2118 m_animTickFall = Environment.TickCount;
2119 }
2120 else if (!jumping && fallElapsed > FALL_DELAY)
2121 {
2122 // Falling long enough to trigger the animation
2123 return "FALLDOWN";
2124 }
2125
2126 return m_movementAnimation;
2127 }
2128
2129 #endregion Falling/Floating/Landing
2130
2131 #region Ground Movement
2132
2133 if (m_movementAnimation == "FALLDOWN")
2134 {
2135 m_animTickFall = Environment.TickCount;
2136
2137 // TODO: SOFT_LAND support
2138 return "LAND";
2139 }
2140 else if (m_movementAnimation == "LAND")
2141 {
2142 float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
2143
2144 if (landElapsed <= FALL_DELAY)
2145 return "LAND";
2146 }
2147
2148 m_animTickFall = 0;
2149
2150 if (move.Z > 0f)
2151 {
2152 // Jumping
2153 if (!jumping)
2154 {
2155 // Begin prejump
2156 m_animTickJump = Environment.TickCount;
2157 return "PREJUMP";
2158 }
2159 else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 1000.0f)
2160 {
2161 // Start actual jump
2162 if (m_animTickJump == -1)
2163 {
2164 // Already jumping! End the current jump
2165 m_animTickJump = 0;
2166 return "JUMP";
2167 }
2168
2169 m_animTickJump = -1;
2170 return "JUMP";
2171 }
2172 }
2173 else
2174 {
2175 // Not jumping
2176 m_animTickJump = 0;
2177
2178 if (move.X != 0f || move.Y != 0f)
2179 {
2180 // Walking / crouchwalking / running
2181 if (move.Z < 0f)
2182 return "CROUCHWALK";
2183 else if (m_setAlwaysRun)
2184 return "RUN";
2185 else
2186 return "WALK";
2187 }
2188 else
2189 {
2190 // Not walking
2191 if (move.Z < 0f)
2192 return "CROUCH";
2193 else
2194 return "STAND";
2195 }
2196 }
2197
2198 #endregion Ground Movement
2199
2200 return m_movementAnimation;
2201 }
2202
2203 /// <summary>
2204 /// Update the movement animation of this avatar according to its current state
2205 /// </summary>
2206 protected void UpdateMovementAnimations()
2207 {
2208 m_movementAnimation = GetMovementAnimation();
2209
2210 if (m_movementAnimation == "PREJUMP" && !m_usePreJump)
2211 {
2212 // This was the previous behavior before PREJUMP
2213 TrySetMovementAnimation("JUMP");
2214 }
2215 else
2216 {
2217 TrySetMovementAnimation(m_movementAnimation);
2218 }
2219 } 1880 }
2220 1881
2221 /// <summary> 1882 /// <summary>
@@ -2289,8 +1950,8 @@ namespace OpenSim.Region.Framework.Scenes
2289 direc.Z *= 3.0f; 1950 direc.Z *= 3.0f;
2290 1951
2291 // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. 1952 // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored.
2292 TrySetMovementAnimation("PREJUMP"); 1953 Animator.TrySetMovementAnimation("PREJUMP");
2293 TrySetMovementAnimation("JUMP"); 1954 Animator.TrySetMovementAnimation("JUMP");
2294 } 1955 }
2295 } 1956 }
2296 } 1957 }
@@ -2504,7 +2165,7 @@ namespace OpenSim.Region.Framework.Scenes
2504 { 2165 {
2505 avatar.SendFullUpdateToOtherClient(this); 2166 avatar.SendFullUpdateToOtherClient(this);
2506 avatar.SendAppearanceToOtherAgent(this); 2167 avatar.SendAppearanceToOtherAgent(this);
2507 avatar.SendAnimPackToClient(ControllingClient); 2168 avatar.Animator.SendAnimPackToClient(ControllingClient);
2508 } 2169 }
2509 } 2170 }
2510 } 2171 }
@@ -2512,7 +2173,7 @@ namespace OpenSim.Region.Framework.Scenes
2512 m_scene.StatsReporter.AddAgentUpdates(avatars.Length); 2173 m_scene.StatsReporter.AddAgentUpdates(avatars.Length);
2513 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2174 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
2514 2175
2515 //SendAnimPack(); 2176 //Animator.SendAnimPack();
2516 } 2177 }
2517 2178
2518 public void SendFullUpdateToAllClients() 2179 public void SendFullUpdateToAllClients()
@@ -2529,7 +2190,7 @@ namespace OpenSim.Region.Framework.Scenes
2529 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2190 m_scene.StatsReporter.AddAgentUpdates(avatars.Count);
2530 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2191 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
2531 2192
2532 SendAnimPack(); 2193 Animator.SendAnimPack();
2533 } 2194 }
2534 2195
2535 /// <summary> 2196 /// <summary>
@@ -2646,7 +2307,7 @@ namespace OpenSim.Region.Framework.Scenes
2646 SendAppearanceToAllOtherAgents(); 2307 SendAppearanceToAllOtherAgents();
2647 if (!m_startAnimationSet) 2308 if (!m_startAnimationSet)
2648 { 2309 {
2649 UpdateMovementAnimations(); 2310 Animator.UpdateMovementAnimations();
2650 m_startAnimationSet = true; 2311 m_startAnimationSet = true;
2651 } 2312 }
2652 2313
@@ -2674,54 +2335,6 @@ namespace OpenSim.Region.Framework.Scenes
2674 set { m_appearance = value; } 2335 set { m_appearance = value; }
2675 } 2336 }
2676 2337
2677 /// <summary>
2678 ///
2679 /// </summary>
2680 /// <param name="animations"></param>
2681 /// <param name="seqs"></param>
2682 /// <param name="objectIDs"></param>
2683 public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs)
2684 {
2685 if (m_isChildAgent)
2686 return;
2687
2688 m_scene.ForEachClient(
2689 delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId, objectIDs); });
2690 }
2691
2692 public void SendAnimPackToClient(IClientAPI client)
2693 {
2694 if (m_isChildAgent)
2695 return;
2696 UUID[] animIDs;
2697 int[] sequenceNums;
2698 UUID[] objectIDs;
2699
2700 m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs);
2701
2702 client.SendAnimations(animIDs, sequenceNums, m_controllingClient.AgentId, objectIDs);
2703 }
2704
2705 /// <summary>
2706 /// Send animation information about this avatar to all clients.
2707 /// </summary>
2708 public void SendAnimPack()
2709 {
2710 //m_log.Debug("Sending animation pack to all");
2711
2712 if (m_isChildAgent)
2713 return;
2714
2715 UUID[] animIDs;
2716 int[] sequenceNums;
2717 UUID[] objectIDs;
2718
2719 m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs);
2720
2721 SendAnimPack(animIDs, sequenceNums, objectIDs);
2722 }
2723
2724
2725 #endregion 2338 #endregion
2726 2339
2727 #region Significant Movement Method 2340 #region Significant Movement Method
@@ -2919,13 +2532,9 @@ namespace OpenSim.Region.Framework.Scenes
2919 public void Reset() 2532 public void Reset()
2920 { 2533 {
2921 // Put the child agent back at the center 2534 // Put the child agent back at the center
2922 AbsolutePosition = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); 2535 AbsolutePosition
2923 ResetAnimations(); 2536 = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70);
2924 } 2537 Animator.ResetAnimations();
2925
2926 public void ResetAnimations()
2927 {
2928 m_animations.Clear();
2929 } 2538 }
2930 2539
2931 /// <summary> 2540 /// <summary>
@@ -3149,7 +2758,7 @@ namespace OpenSim.Region.Framework.Scenes
3149 // Animations 2758 // Animations
3150 try 2759 try
3151 { 2760 {
3152 cAgent.Anims = m_animations.ToArray(); 2761 cAgent.Anims = Animator.Animations.ToArray();
3153 } 2762 }
3154 catch { } 2763 catch { }
3155 2764
@@ -3228,15 +2837,13 @@ namespace OpenSim.Region.Framework.Scenes
3228 // Animations 2837 // Animations
3229 try 2838 try
3230 { 2839 {
3231 m_animations.Clear(); 2840 Animator.ResetAnimations();
3232 m_animations.FromArray(cAgent.Anims); 2841 Animator.Animations.FromArray(cAgent.Anims);
3233 } 2842 }
3234 catch { } 2843 catch { }
3235 2844
3236 //cAgent.GroupID = ?? 2845 //cAgent.GroupID = ??
3237 //Groups??? 2846 //Groups???
3238
3239
3240 } 2847 }
3241 2848
3242 public bool CopyAgent(out IAgentData agent) 2849 public bool CopyAgent(out IAgentData agent)
@@ -3318,7 +2925,7 @@ namespace OpenSim.Region.Framework.Scenes
3318 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) 2925 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
3319 // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( 2926 // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents(
3320 // as of this comment the interval is set in AddToPhysicalScene 2927 // as of this comment the interval is set in AddToPhysicalScene
3321 UpdateMovementAnimations(); 2928 Animator.UpdateMovementAnimations();
3322 2929
3323 CollisionEventUpdate collisionData = (CollisionEventUpdate)e; 2930 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
3324 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; 2931 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;
@@ -3327,7 +2934,7 @@ namespace OpenSim.Region.Framework.Scenes
3327 2934
3328 if (coldata.Count != 0) 2935 if (coldata.Count != 0)
3329 { 2936 {
3330 switch (m_movementAnimation) 2937 switch (Animator.CurrentMovementAnimation)
3331 { 2938 {
3332 case "STAND": 2939 case "STAND":
3333 case "WALK": 2940 case "WALK":
@@ -3415,6 +3022,7 @@ namespace OpenSim.Region.Framework.Scenes
3415 } 3022 }
3416 m_attachments.Clear(); 3023 m_attachments.Clear();
3417 } 3024 }
3025
3418 lock (m_knownChildRegions) 3026 lock (m_knownChildRegions)
3419 { 3027 {
3420 m_knownChildRegions.Clear(); 3028 m_knownChildRegions.Clear();
@@ -3425,6 +3033,7 @@ namespace OpenSim.Region.Framework.Scenes
3425 m_reprioritization_timer.Enabled = false; 3033 m_reprioritization_timer.Enabled = false;
3426 m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize); 3034 m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize);
3427 } 3035 }
3036
3428 // I don't get it but mono crashes when you try to dispose of this timer, 3037 // I don't get it but mono crashes when you try to dispose of this timer,
3429 // unsetting the elapsed callback should be enough to allow for cleanup however. 3038 // unsetting the elapsed callback should be enough to allow for cleanup however.
3430 //m_reprioritizationTimer.Dispose(); 3039 //m_reprioritizationTimer.Dispose();
@@ -3436,8 +3045,9 @@ namespace OpenSim.Region.Framework.Scenes
3436 3045
3437 public ScenePresence() 3046 public ScenePresence()
3438 { 3047 {
3439 m_sendCourseLocationsMethod = SendCoarseLocationsDefault; 3048 m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
3440 CreateSceneViewer(); 3049 CreateSceneViewer();
3050 m_animator = new ScenePresenceAnimator(this);
3441 } 3051 }
3442 3052
3443 public void AddAttachment(SceneObjectGroup gobj) 3053 public void AddAttachment(SceneObjectGroup gobj)
@@ -3497,6 +3107,35 @@ namespace OpenSim.Region.Framework.Scenes
3497 return true; 3107 return true;
3498 } 3108 }
3499 3109
3110 /// <summary>
3111 /// Send a script event to this scene presence's attachments
3112 /// </summary>
3113 /// <param name="eventName">The name of the event</param>
3114 /// <param name="args">The arguments for the event</param>
3115 public void SendScriptEventToAttachments(string eventName, Object[] args)
3116 {
3117 if (m_scriptEngines != null)
3118 {
3119 lock (m_attachments)
3120 {
3121 foreach (SceneObjectGroup grp in m_attachments)
3122 {
3123 // 16384 is CHANGED_ANIMATION
3124 //
3125 // Send this to all attachment root prims
3126 //
3127 foreach (IScriptModule m in m_scriptEngines)
3128 {
3129 if (m == null) // No script engine loaded
3130 continue;
3131
3132 m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { 16384 });
3133 }
3134 }
3135 }
3136 }
3137 }
3138
3500 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent) 3139 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent)
3501 { 3140 {
3502 lock (m_attachments) 3141 lock (m_attachments)
@@ -3939,4 +3578,4 @@ namespace OpenSim.Region.Framework.Scenes
3939 } 3578 }
3940 } 3579 }
3941 } 3580 }
3942} 3581} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index f24869b..8d32e66 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -1179,8 +1179,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1179 1179
1180 return m_clientRequestIDInfo[client.AgentId].RequestID; 1180 return m_clientRequestIDInfo[client.AgentId].RequestID;
1181 } 1181 }
1182 1182// Unreachable code!
1183 return new GroupRequestID(); 1183// return new GroupRequestID();
1184 } 1184 }
1185 1185
1186 /// <summary> 1186 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index fc17808..5fb2775 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -40,10 +40,11 @@ using OpenSim;
40using OpenSim.Framework; 40using OpenSim.Framework;
41using OpenSim.Framework.Communications.Cache; 41using OpenSim.Framework.Communications.Cache;
42using OpenSim.Region.CoreModules; 42using OpenSim.Region.CoreModules;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.CoreModules.World.Land; 43using OpenSim.Region.CoreModules.World.Land;
45using OpenSim.Region.CoreModules.World.Terrain; 44using OpenSim.Region.CoreModules.World.Terrain;
45using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes; 46using OpenSim.Region.Framework.Scenes;
47using OpenSim.Region.Framework.Scenes.Animation;
47using OpenSim.Region.Physics.Manager; 48using OpenSim.Region.Physics.Manager;
48using OpenSim.Region.ScriptEngine.Shared; 49using OpenSim.Region.ScriptEngine.Shared;
49using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; 50using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
@@ -3097,11 +3098,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3097 if (presence != null) 3098 if (presence != null)
3098 { 3099 {
3099 // Do NOT try to parse UUID, animations cannot be triggered by ID 3100 // Do NOT try to parse UUID, animations cannot be triggered by ID
3100 UUID animID=InventoryKey(anim, (int)AssetType.Animation); 3101 UUID animID = InventoryKey(anim, (int)AssetType.Animation);
3101 if (animID == UUID.Zero) 3102 if (animID == UUID.Zero)
3102 presence.AddAnimation(anim, m_host.UUID); 3103 presence.Animator.AddAnimation(anim, m_host.UUID);
3103 else 3104 else
3104 presence.AddAnimation(animID, m_host.UUID); 3105 presence.Animator.AddAnimation(animID, m_host.UUID);
3105 } 3106 }
3106 } 3107 }
3107 } 3108 }
@@ -3141,9 +3142,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3141 if (presence != null) 3142 if (presence != null)
3142 { 3143 {
3143 if (animID == UUID.Zero) 3144 if (animID == UUID.Zero)
3144 presence.RemoveAnimation(anim); 3145 presence.Animator.RemoveAnimation(anim);
3145 else 3146 else
3146 presence.RemoveAnimation(animID); 3147 presence.Animator.RemoveAnimation(animID);
3147 } 3148 }
3148 } 3149 }
3149 } 3150 }
@@ -3987,12 +3988,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3987 3988
3988 if (presence != null) 3989 if (presence != null)
3989 { 3990 {
3990 AnimationSet currentAnims = presence.Animations; 3991 AnimationSet currentAnims = presence.Animator.Animations;
3991 string currentAnimationState = String.Empty; 3992 string currentAnimationState = String.Empty;
3992 if (animationstateNames.TryGetValue(currentAnims.DefaultAnimation.AnimID, out currentAnimationState)) 3993 if (animationstateNames.TryGetValue(currentAnims.DefaultAnimation.AnimID, out currentAnimationState))
3993 return currentAnimationState; 3994 return currentAnimationState;
3994 } 3995 }
3995 } 3996 }
3997
3996 return String.Empty; 3998 return String.Empty;
3997 } 3999 }
3998 4000
@@ -5326,7 +5328,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5326 flags |= ScriptBaseClass.AGENT_TYPING; 5328 flags |= ScriptBaseClass.AGENT_TYPING;
5327 } 5329 }
5328 5330
5329 string agentMovementAnimation = agent.GetMovementAnimation(); 5331 string agentMovementAnimation = agent.Animator.GetMovementAnimation();
5330 5332
5331 if (agentMovementAnimation == "CROUCH") 5333 if (agentMovementAnimation == "CROUCH")
5332 { 5334 {
@@ -5358,7 +5360,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5358 flags |= ScriptBaseClass.AGENT_SITTING; 5360 flags |= ScriptBaseClass.AGENT_SITTING;
5359 } 5361 }
5360 5362
5361 if (agent.Animations.DefaultAnimation.AnimID == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) 5363 if (agent.Animator.Animations.DefaultAnimation.AnimID
5364 == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"])
5362 { 5365 {
5363 flags |= ScriptBaseClass.AGENT_SITTING; 5366 flags |= ScriptBaseClass.AGENT_SITTING;
5364 } 5367 }
@@ -7148,7 +7151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7148 if (av == null || av.IsChildAgent) // only if in the region 7151 if (av == null || av.IsChildAgent) // only if in the region
7149 return l; 7152 return l;
7150 UUID[] anims; 7153 UUID[] anims;
7151 anims = av.GetAnimationArray(); 7154 anims = av.Animator.GetAnimationArray();
7152 foreach (UUID foo in anims) 7155 foreach (UUID foo in anims)
7153 l.Add(foo.ToString()); 7156 l.Add(foo.ToString());
7154 return l; 7157 return l;
@@ -7276,7 +7279,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7276 { 7279 {
7277 LSL_Vector lower; 7280 LSL_Vector lower;
7278 LSL_Vector upper; 7281 LSL_Vector upper;
7279 if (presence.Animations.DefaultAnimation.AnimID == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) 7282 if (presence.Animator.Animations.DefaultAnimation.AnimID
7283 == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"])
7280 { 7284 {
7281 // This is for ground sitting avatars 7285 // This is for ground sitting avatars
7282 float height = presence.Appearance.AvatarHeight / 2.66666667f; 7286 float height = presence.Appearance.AvatarHeight / 2.66666667f;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 3ffcff0..7fdbac8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -741,9 +741,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
741 } 741 }
742 } 742 }
743 if (animID == UUID.Zero) 743 if (animID == UUID.Zero)
744 target.AddAnimation(animation, m_host.UUID); 744 target.Animator.AddAnimation(animation, m_host.UUID);
745 else 745 else
746 target.AddAnimation(animID, m_host.UUID); 746 target.Animator.AddAnimation(animID, m_host.UUID);
747 } 747 }
748 } 748 }
749 } 749 }
@@ -773,10 +773,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
773 } 773 }
774 } 774 }
775 } 775 }
776
776 if (animID == UUID.Zero) 777 if (animID == UUID.Zero)
777 target.RemoveAnimation(animation); 778 target.Animator.RemoveAnimation(animation);
778 else 779 else
779 target.RemoveAnimation(animID); 780 target.Animator.RemoveAnimation(animID);
780 } 781 }
781 } 782 }
782 } 783 }
diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs b/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs
new file mode 100644
index 0000000..899cd8f
--- /dev/null
+++ b/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs
@@ -0,0 +1,61 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using Nini.Config;
30using OpenSim.Server.Base;
31using OpenSim.Services.Interfaces;
32using OpenSim.Framework.Servers.HttpServer;
33using OpenSim.Server.Handlers.Base;
34
35namespace OpenSim.Server.Handlers.Presence
36{
37 public class PresenceServiceConnector : ServiceConnector
38 {
39 private IPresenceService m_PresenceService;
40 private string m_ConfigName = "PresenceService";
41
42 public PresenceServiceConnector(IConfigSource config, IHttpServer server, string configName) :
43 base(config, server, configName)
44 {
45 IConfig serverConfig = config.Configs[m_ConfigName];
46 if (serverConfig == null)
47 throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
48
49 string gridService = serverConfig.GetString("LocalServiceModule",
50 String.Empty);
51
52 if (gridService == String.Empty)
53 throw new Exception("No LocalServiceModule in config file");
54
55 Object[] args = new Object[] { config };
56 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(gridService, args);
57
58 server.AddStreamHandler(new PresenceServerPostHandler(m_PresenceService));
59 }
60 }
61}
diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs
new file mode 100644
index 0000000..2558fa0
--- /dev/null
+++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs
@@ -0,0 +1,182 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using Nini.Config;
29using log4net;
30using System;
31using System.Reflection;
32using System.IO;
33using System.Net;
34using System.Text;
35using System.Text.RegularExpressions;
36using System.Xml;
37using System.Xml.Serialization;
38using System.Collections.Generic;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
41using OpenSim.Framework;
42using OpenSim.Framework.Servers.HttpServer;
43using OpenMetaverse;
44
45namespace OpenSim.Server.Handlers.Presence
46{
47 public class PresenceServerPostHandler : BaseStreamHandler
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 private IPresenceService m_PresenceService;
52
53 public PresenceServerPostHandler(IPresenceService service) :
54 base("POST", "/presence")
55 {
56 m_PresenceService = service;
57 }
58
59 public override byte[] Handle(string path, Stream requestData,
60 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
61 {
62 StreamReader sr = new StreamReader(requestData);
63 string body = sr.ReadToEnd();
64 sr.Close();
65 body = body.Trim();
66
67 //m_log.DebugFormat("[XXX]: query String: {0}", body);
68
69 try
70 {
71 Dictionary<string, string> request =
72 ServerUtils.ParseQueryString(body);
73
74 if (!request.ContainsKey("METHOD"))
75 return FailureResult();
76
77 string method = request["METHOD"];
78
79 switch (method)
80 {
81 case "report":
82 return Report(request);
83 }
84 m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method);
85 }
86 catch (Exception e)
87 {
88 m_log.Debug("[PRESENCE HANDLER]: Exception {0}" + e);
89 }
90
91 return FailureResult();
92
93 }
94
95 byte[] Report(Dictionary<string, string> request)
96 {
97 PresenceInfo info = new PresenceInfo();
98 info.Data = new Dictionary<string, string>();
99
100 if (request["PrincipalID"] == null || request["RegionID"] == null)
101 return FailureResult();
102
103 if (!UUID.TryParse(request["PrincipalID"].ToString(),
104 out info.PrincipalID))
105 return FailureResult();
106
107 if (!UUID.TryParse(request["RegionID"].ToString(),
108 out info.RegionID))
109 return FailureResult();
110
111 foreach (KeyValuePair<string, string> kvp in request)
112 {
113 if (kvp.Key == "METHOD" ||
114 kvp.Key == "PrincipalID" ||
115 kvp.Key == "RegionID")
116 continue;
117
118 info.Data[kvp.Key] = kvp.Value;
119 }
120
121 if (m_PresenceService.Report(info))
122 return SuccessResult();
123
124 return FailureResult();
125 }
126
127 private byte[] SuccessResult()
128 {
129 XmlDocument doc = new XmlDocument();
130
131 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
132 "", "");
133
134 doc.AppendChild(xmlnode);
135
136 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
137 "");
138
139 doc.AppendChild(rootElement);
140
141 XmlElement result = doc.CreateElement("", "Result", "");
142 result.AppendChild(doc.CreateTextNode("Success"));
143
144 rootElement.AppendChild(result);
145
146 return DocToBytes(doc);
147 }
148
149 private byte[] FailureResult()
150 {
151 XmlDocument doc = new XmlDocument();
152
153 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
154 "", "");
155
156 doc.AppendChild(xmlnode);
157
158 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
159 "");
160
161 doc.AppendChild(rootElement);
162
163 XmlElement result = doc.CreateElement("", "Result", "");
164 result.AppendChild(doc.CreateTextNode("Failure"));
165
166 rootElement.AppendChild(result);
167
168 return DocToBytes(doc);
169 }
170
171 private byte[] DocToBytes(XmlDocument doc)
172 {
173 MemoryStream ms = new MemoryStream();
174 XmlTextWriter xw = new XmlTextWriter(ms, null);
175 xw.Formatting = Formatting.Indented;
176 doc.WriteTo(xw);
177 xw.Flush();
178
179 return ms.ToArray();
180 }
181 }
182}
diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
index e047f71..f86b453 100644
--- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
@@ -231,13 +231,14 @@ namespace OpenSim.Services.Connectors
231 } 231 }
232 catch (TimeoutException e) 232 catch (TimeoutException e)
233 { 233 {
234 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation to {0} timed out {0} {1}.", m_ServerURI, 234 m_log.ErrorFormat(
235 e.Source, e.Message); 235 "[INVENTORY CONNECTOR]: GetFolderContent operation to {0} for {1} timed out {2} {3}.",
236 m_ServerURI, folderID, e.Source, e.Message);
236 } 237 }
237 catch (Exception e) 238 catch (Exception e)
238 { 239 {
239 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1} (old server?).", 240 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed for {0}, {1} {2} (old server?).",
240 e.Source, e.Message); 241 folderID, e.Source, e.Message);
241 } 242 }
242 243
243 InventoryCollection nullCollection = new InventoryCollection(); 244 InventoryCollection nullCollection = new InventoryCollection();
@@ -256,8 +257,8 @@ namespace OpenSim.Services.Connectors
256 } 257 }
257 catch (Exception e) 258 catch (Exception e)
258 { 259 {
259 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Add new inventory folder operation failed, {0} {1}", 260 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Add new inventory folder operation failed for {0} {1}, {2} {3}",
260 e.Source, e.Message); 261 folder.Name, folder.ID, e.Source, e.Message);
261 } 262 }
262 263
263 return false; 264 return false;
@@ -272,8 +273,8 @@ namespace OpenSim.Services.Connectors
272 } 273 }
273 catch (Exception e) 274 catch (Exception e)
274 { 275 {
275 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Update inventory folder operation failed, {0} {1}", 276 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Update inventory folder operation failed for {0} {1}, {2} {3}",
276 e.Source, e.Message); 277 folder.Name, folder.ID, e.Source, e.Message);
277 } 278 }
278 279
279 return false; 280 return false;
@@ -307,8 +308,8 @@ namespace OpenSim.Services.Connectors
307 } 308 }
308 catch (Exception e) 309 catch (Exception e)
309 { 310 {
310 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Move inventory folder operation failed, {0} {1}", 311 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Move inventory folder operation failed for {0} {1}, {2} {3}",
311 e.Source, e.Message); 312 folder.Name, folder.ID, e.Source, e.Message);
312 } 313 }
313 314
314 return false; 315 return false;
@@ -323,8 +324,8 @@ namespace OpenSim.Services.Connectors
323 } 324 }
324 catch (Exception e) 325 catch (Exception e)
325 { 326 {
326 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Move inventory folder operation failed, {0} {1}", 327 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Purge inventory folder operation failed for {0} {1}, {2} {3}",
327 e.Source, e.Message); 328 folder.Name, folder.ID, e.Source, e.Message);
328 } 329 }
329 330
330 return false; 331 return false;
@@ -340,8 +341,8 @@ namespace OpenSim.Services.Connectors
340 } 341 }
341 catch (Exception e) 342 catch (Exception e)
342 { 343 {
343 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Get folder items operation failed, {0} {1}", 344 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Get folder items operation failed for folder {0}, {1} {2}",
344 e.Source, e.Message); 345 folderID, e.Source, e.Message);
345 } 346 }
346 347
347 return null; 348 return null;
@@ -356,8 +357,8 @@ namespace OpenSim.Services.Connectors
356 } 357 }
357 catch (Exception e) 358 catch (Exception e)
358 { 359 {
359 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Add new inventory item operation failed, {0} {1}", 360 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Add new inventory item operation failed for {0} {1}, {2} {3}",
360 e.Source, e.Message); 361 item.Name, item.ID, e.Source, e.Message);
361 } 362 }
362 363
363 return false; 364 return false;
@@ -372,8 +373,8 @@ namespace OpenSim.Services.Connectors
372 } 373 }
373 catch (Exception e) 374 catch (Exception e)
374 { 375 {
375 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Update new inventory item operation failed, {0} {1}", 376 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Update new inventory item operation failed for {0} {1}, {2} {3}",
376 e.Source, e.Message); 377 item.Name, item.ID, e.Source, e.Message);
377 } 378 }
378 379
379 return false; 380 return false;
@@ -443,7 +444,7 @@ namespace OpenSim.Services.Connectors
443 } 444 }
444 catch (Exception e) 445 catch (Exception e)
445 { 446 {
446 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Delete inventory item operation failed, {0} {1}", 447 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Delete inventory items operation failed, {0} {1}",
447 e.Source, e.Message); 448 e.Source, e.Message);
448 } 449 }
449 450
@@ -475,7 +476,7 @@ namespace OpenSim.Services.Connectors
475 } 476 }
476 catch (Exception e) 477 catch (Exception e)
477 { 478 {
478 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Query inventory item operation failed, {0} {1}", 479 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Query inventory folder operation failed, {0} {1}",
479 e.Source, e.Message); 480 e.Source, e.Message);
480 } 481 }
481 482
@@ -576,9 +577,6 @@ namespace OpenSim.Services.Connectors
576 } 577 }
577 578
578 callback(folders, items); 579 callback(folders, items);
579
580 } 580 }
581
582
583 } 581 }
584} 582}
diff --git a/OpenSim/Services/Interfaces/IPresenceService.cs b/OpenSim/Services/Interfaces/IPresenceService.cs
index d33b6bc..aa1c5bf 100644
--- a/OpenSim/Services/Interfaces/IPresenceService.cs
+++ b/OpenSim/Services/Interfaces/IPresenceService.cs
@@ -31,7 +31,15 @@ using OpenMetaverse;
31 31
32namespace OpenSim.Services.Interfaces 32namespace OpenSim.Services.Interfaces
33{ 33{
34 public class PresenceInfo
35 {
36 public UUID PrincipalID;
37 public UUID RegionID;
38 public Dictionary<string, string> Data;
39 }
40
34 public interface IPresenceService 41 public interface IPresenceService
35 { 42 {
43 bool Report(PresenceInfo presence);
36 } 44 }
37} 45}
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs
index ba8eec8..2157462 100644
--- a/OpenSim/Services/PresenceService/PresenceService.cs
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -49,5 +49,19 @@ namespace OpenSim.Services.PresenceService
49 : base(config) 49 : base(config)
50 { 50 {
51 } 51 }
52
53 public bool Report(PresenceInfo presence)
54 {
55 PresenceData p = new PresenceData();
56 p.Data = new Dictionary<string, string>();
57
58 p.UUID = presence.PrincipalID;
59 p.currentRegion = presence.RegionID;
60
61 foreach (KeyValuePair<string, string> kvp in presence.Data)
62 p.Data[kvp.Key] = kvp.Value;
63
64 return false;
65 }
52 } 66 }
53} 67}
diff --git a/OpenSim/Tests/Common/Mock/MockUserService.cs b/OpenSim/Tests/Common/Mock/MockUserService.cs
index 1e27fb7..62c41c7 100644
--- a/OpenSim/Tests/Common/Mock/MockUserService.cs
+++ b/OpenSim/Tests/Common/Mock/MockUserService.cs
@@ -1,3 +1,29 @@
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 */
1 27
2using System; 28using System;
3using System.Collections.Generic; 29using System.Collections.Generic;