aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-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
13 files changed, 573 insertions, 484 deletions
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 }