aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2011-11-05 22:34:36 +0000
committerMelanie2011-11-05 22:34:36 +0000
commit5517e210682b329152e4face3a59945ff6d71c25 (patch)
treef63184a096ed7714cf1c7b2d9c2f17bc9a505195
parentChange m_falling public to a getter property. (diff)
downloadopensim-SC_OLD-5517e210682b329152e4face3a59945ff6d71c25.zip
opensim-SC_OLD-5517e210682b329152e4face3a59945ff6d71c25.tar.gz
opensim-SC_OLD-5517e210682b329152e4face3a59945ff6d71c25.tar.bz2
opensim-SC_OLD-5517e210682b329152e4face3a59945ff6d71c25.tar.xz
Harmonize with core and remove extraneous comments with no information in them
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs144
1 files changed, 39 insertions, 105 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index c39f34f..68e405e 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -58,20 +58,18 @@ namespace OpenSim.Region.Framework.Scenes.Animation
58 { 58 {
59 get { return m_movementAnimation; } 59 get { return m_movementAnimation; }
60 } 60 }
61 // protected string m_movementAnimation = "DEFAULT"; //KF: 'DEFAULT' does not exist! 61 protected string m_movementAnimation = "CROUCH";
62 protected string m_movementAnimation = "CROUCH"; //KF: CROUCH ensures reliable Av Anim. init.
63 private int m_animTickFall; 62 private int m_animTickFall;
64// private int m_animTickJump;
65 public int m_animTickJump; // ScenePresence has to see this to control +Z force 63 public int m_animTickJump; // ScenePresence has to see this to control +Z force
66 public bool m_jumping = false; // Add for jumping 64 public bool m_jumping = false;
67 public float m_jumpVelocity = 0f; // Add for jumping 65 public float m_jumpVelocity = 0f;
68 private int m_landing = 0; // Add for jumping 66 private int m_landing = 0;
69 public bool Falling 67 public bool Falling
70 { 68 {
71 get { return m_falling; } 69 get { return m_falling; }
72 } 70 }
73 private bool m_falling = false; // Add for falling 71 private bool m_falling = false;
74 private float m_fallHeight; // Add for falling 72 private float m_fallHeight;
75 73
76 /// <value> 74 /// <value>
77 /// The scene presence that this animator applies to 75 /// The scene presence that this animator applies to
@@ -133,9 +131,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
133 131
134 public void ResetAnimations() 132 public void ResetAnimations()
135 { 133 {
136Console.WriteLine("ResetA.............");
137 m_animations.Clear(); 134 m_animations.Clear();
138TrySetMovementAnimation("STAND"); 135 TrySetMovementAnimation("STAND");
139 } 136 }
140 137
141 /// <summary> 138 /// <summary>
@@ -165,16 +162,11 @@ TrySetMovementAnimation("STAND");
165 /// </summary> 162 /// </summary>
166 public string GetMovementAnimation() 163 public string GetMovementAnimation()
167 { 164 {
168//Console.WriteLine("GMA-------"); //## 165 const float FALL_DELAY = 800f;
169//#@ const float FALL_DELAY = 0.33f; 166 const float PREJUMP_DELAY = 200f;
170 const float FALL_DELAY = 800f; //## mS 167 const float JUMP_PERIOD = 800f;
171//rm for jumping const float PREJUMP_DELAY = 0.25f;
172 const float PREJUMP_DELAY = 200f; // mS add for jumping
173 const float JUMP_PERIOD = 800f; // mS add for jumping
174 #region Inputs 168 #region Inputs
175
176 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; 169 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags;
177// m_log.DebugFormat("[ANIM]: Control flags: {0}", controlFlags);
178 PhysicsActor actor = m_scenePresence.PhysicsActor; 170 PhysicsActor actor = m_scenePresence.PhysicsActor;
179 171
180 // Create forward and left vectors from the current avatar rotation 172 // Create forward and left vectors from the current avatar rotation
@@ -196,16 +188,15 @@ TrySetMovementAnimation("STAND");
196 188
197 // Direction in which the avatar is trying to move 189 // Direction in which the avatar is trying to move
198 Vector3 move = Vector3.Zero; 190 Vector3 move = Vector3.Zero;
191 if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; }
199 if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } 192 if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; }
200 if (heldLeft) { move.X += left.X; move.Y += left.Y; } 193 if (heldLeft) { move.X += left.X; move.Y += left.Y; }
201 if (heldRight) { move.X -= left.X; move.Y -= left.Y; } 194 if (heldRight) { move.X -= left.X; move.Y -= left.Y; }
202 if (heldUp) { move.Z += 1; } 195 if (heldUp) { move.Z += 1; }
203 if (heldDown) { move.Z -= 1; } 196 if (heldDown) { move.Z -= 1; }
204 if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; }
205 197
206 // Is the avatar trying to move? 198 // Is the avatar trying to move?
207// bool moving = (move != Vector3.Zero); 199// bool moving = (move != Vector3.Zero);
208// rm for jumping bool jumping = m_animTickJump != 0;
209 #endregion Inputs 200 #endregion Inputs
210 201
211 #region Flying 202 #region Flying
@@ -214,10 +205,10 @@ TrySetMovementAnimation("STAND");
214 { 205 {
215 m_animTickFall = 0; 206 m_animTickFall = 0;
216 m_animTickJump = 0; 207 m_animTickJump = 0;
217 m_jumping = false; //add for jumping 208 m_jumping = false;
218 m_falling = true; //add for falling 209 m_falling = true;
219 m_jumpVelocity = 0f; //add for jumping 210 m_jumpVelocity = 0f;
220 actor.Selected = false; //add for jumping flag 211 actor.Selected = false;
221 m_fallHeight = actor.Position.Z; // save latest flying height 212 m_fallHeight = actor.Position.Z; // save latest flying height
222 213
223 if (move.X != 0f || move.Y != 0f) 214 if (move.X != 0f || move.Y != 0f)
@@ -231,10 +222,9 @@ TrySetMovementAnimation("STAND");
231 else if (move.Z < 0f) 222 else if (move.Z < 0f)
232 { 223 {
233 if (actor != null && actor.IsColliding) 224 if (actor != null && actor.IsColliding)
234 { //## 225 {
235//Console.WriteLine("LAND FLYING"); // ##
236 return "LAND"; 226 return "LAND";
237 } //# 227 }
238 else 228 else
239 return "HOVER_DOWN"; 229 return "HOVER_DOWN";
240 } 230 }
@@ -248,28 +238,22 @@ TrySetMovementAnimation("STAND");
248 238
249 #region Falling/Floating/Landing 239 #region Falling/Floating/Landing
250 240
251// rm for jumping if (actor == null || !actor.IsColliding) 241 if ((actor == null || !actor.IsColliding) && !m_jumping)
252 if ((actor == null || !actor.IsColliding) && !m_jumping) // add for jumping
253 { 242 {
254// rm float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; 243 float fallElapsed = (float)(Environment.TickCount - m_animTickFall);
255 float fallElapsed = (float)(Environment.TickCount - m_animTickFall); // add, in mS
256 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; 244 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f;
257//Console.WriteLine("falling t={0} v={1}", fallElapsed, fallVelocity); //##
258 245
259// rm for fall if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f)) 246 if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true;
260 if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; // add for falling and jumping
261 247
262 if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) // add for jumping 248 if (m_animTickFall == 0 || (fallVelocity >= 0.0f))
263 // not falling yet or going up
264 { 249 {
250 // not falling yet, or going up
265 // reset start of fall time 251 // reset start of fall time
266 m_animTickFall = Environment.TickCount; 252 m_animTickFall = Environment.TickCount;
267 } 253 }
268// else if (!jumping && fallElapsed > FALL_DELAY) 254 else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.WasFlying))
269 else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.WasFlying)) // add for falling and jumping
270 { 255 {
271 // Falling long enough to trigger the animation 256 // Falling long enough to trigger the animation
272//Console.WriteLine("FALLDOWN"); //##
273 return "FALLDOWN"; 257 return "FALLDOWN";
274 } 258 }
275 259
@@ -287,12 +271,11 @@ TrySetMovementAnimation("STAND");
287 271
288 if ((move.Z > 0f) && (!m_jumping)) 272 if ((move.Z > 0f) && (!m_jumping))
289 { 273 {
290//Console.WriteLine("PJ {0}", jumptime); //##
291 // Start jumping, prejump 274 // Start jumping, prejump
292 m_animTickFall = 0; 275 m_animTickFall = 0;
293 m_jumping = true; 276 m_jumping = true;
294 m_falling = false; 277 m_falling = false;
295 actor.Selected = true; // borrowed for jmping flag 278 actor.Selected = true; // borrowed for jumping flag
296 m_animTickJump = Environment.TickCount; 279 m_animTickJump = Environment.TickCount;
297 m_jumpVelocity = 0.35f; 280 m_jumpVelocity = 0.35f;
298 return "PREJUMP"; 281 return "PREJUMP";
@@ -302,7 +285,6 @@ TrySetMovementAnimation("STAND");
302 { 285 {
303 if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) 286 if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding)
304 { 287 {
305//Console.WriteLine("LA {0}", jumptime); //##
306 // end jumping 288 // end jumping
307 m_jumping = false; 289 m_jumping = false;
308 m_falling = false; 290 m_falling = false;
@@ -313,14 +295,12 @@ TrySetMovementAnimation("STAND");
313 } 295 }
314 else if (jumptime > JUMP_PERIOD) 296 else if (jumptime > JUMP_PERIOD)
315 { 297 {
316//Console.WriteLine("JD {0}", jumptime); //##
317 // jump down 298 // jump down
318 m_jumpVelocity = 0f; 299 m_jumpVelocity = 0f;
319 return "JUMP"; 300 return "JUMP";
320 } 301 }
321 else if (jumptime > PREJUMP_DELAY) 302 else if (jumptime > PREJUMP_DELAY)
322 { 303 {
323//Console.WriteLine("JU {0}", jumptime); //##
324 // jump up 304 // jump up
325 m_jumping = true; 305 m_jumping = true;
326 m_jumpVelocity = 10f; 306 m_jumpVelocity = 10f;
@@ -328,7 +308,7 @@ TrySetMovementAnimation("STAND");
328 } 308 }
329 } 309 }
330 310
331 #endregion Jumping // end added section 311 #endregion Jumping
332 312
333 #region Ground Movement 313 #region Ground Movement
334 314
@@ -338,72 +318,36 @@ TrySetMovementAnimation("STAND");
338 m_animTickFall = Environment.TickCount; 318 m_animTickFall = Environment.TickCount;
339 // TODO: SOFT_LAND support 319 // TODO: SOFT_LAND support
340 float fallHeight = m_fallHeight - actor.Position.Z; 320 float fallHeight = m_fallHeight - actor.Position.Z;
341//Console.WriteLine("Hit from {0}", fallHeight); //## 321 if (fallHeight > 15.0f)
342 if (fallHeight > 15.0f) // add for falling
343 return "STANDUP"; 322 return "STANDUP";
344 else if (fallHeight > 8.0f) // add for falling 323 else if (fallHeight > 8.0f)
345 return "SOFT_LAND"; // add for falling 324 return "SOFT_LAND";
346 else // add for falling 325 else
347 return "LAND"; // add for falling 326 return "LAND";
348 } 327 }
349// rm jumping float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
350// rm jumping if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY))
351// rm for landing return "LAND";
352 else if ((m_movementAnimation == "LAND") || (m_movementAnimation == "SOFT_LAND") || (m_movementAnimation == "STANDUP")) 328 else if ((m_movementAnimation == "LAND") || (m_movementAnimation == "SOFT_LAND") || (m_movementAnimation == "STANDUP"))
353 { 329 {
354 int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping 330 int landElapsed = Environment.TickCount - m_animTickFall;
355 int limit = 1000; // add for jumping 331 int limit = 1000;
356 if(m_movementAnimation == "LAND") limit = 350; // add for jumping 332 if(m_movementAnimation == "LAND") limit = 350;
357 // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client 333 // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client
358 334
359 if ((m_animTickFall != 0) && (landElapsed <= limit)) // add for jumping 335 if ((m_animTickFall != 0) && (landElapsed <= limit))
360 { 336 {
361//Console.WriteLine("Lelapse {0}", m_movementAnimation); //##
362 return m_movementAnimation; 337 return m_movementAnimation;
363 } 338 }
364 else 339 else
365 { 340 {
366//Console.WriteLine("end/STAND"); //##
367 m_fallHeight = actor.Position.Z; // save latest flying height 341 m_fallHeight = actor.Position.Z; // save latest flying height
368 return "STAND"; 342 return "STAND";
369 } 343 }
370 } 344 }
371/* This section removed, replaced by jumping section
372 m_animTickFall = 0;
373
374 if (move.Z > 0.2f)
375 {
376 // Jumping
377 if (!jumping)
378 {
379 // Begin prejump
380 m_animTickJump = Environment.TickCount;
381 return "PREJUMP";
382 }
383 else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 800.0f)
384 {
385 // Start actual jump
386 if (m_animTickJump == -1)
387 {
388 // Already jumping! End the current jump
389 m_animTickJump = 0;
390 return "JUMP";
391 }
392 345
393 m_animTickJump = -1;
394 return "JUMP";
395 }
396 }
397 else
398 {
399 // Not jumping
400 m_animTickJump = 0;
401 */
402 // next section moved outside paren. and realigned for jumping 346 // next section moved outside paren. and realigned for jumping
403 if (move.X != 0f || move.Y != 0f) 347 if (move.X != 0f || move.Y != 0f)
404 { 348 {
405 m_fallHeight = actor.Position.Z; // save latest flying height 349 m_fallHeight = actor.Position.Z; // save latest flying height
406 m_falling = false; // Add for falling 350 m_falling = false;
407 // Walking / crouchwalking / running 351 // Walking / crouchwalking / running
408 if (move.Z < 0f) 352 if (move.Z < 0f)
409 return "CROUCHWALK"; 353 return "CROUCHWALK";
@@ -412,10 +356,9 @@ TrySetMovementAnimation("STAND");
412 else 356 else
413 return "WALK"; 357 return "WALK";
414 } 358 }
415// rm for jumping else 359 else if (!m_jumping)
416 else if (!m_jumping) // add for jumping
417 { 360 {
418 m_falling = false; // Add for falling 361 m_falling = false;
419 // Not walking 362 // Not walking
420 if (move.Z < 0) 363 if (move.Z < 0)
421 return "CROUCH"; 364 return "CROUCH";
@@ -426,10 +369,9 @@ TrySetMovementAnimation("STAND");
426 else 369 else
427 return "STAND"; 370 return "STAND";
428 } 371 }
429 // end section realign for jumping
430 #endregion Ground Movement 372 #endregion Ground Movement
431 373
432 m_falling = false; // Add for falling 374 m_falling = false;
433 return m_movementAnimation; 375 return m_movementAnimation;
434 } 376 }
435 377
@@ -439,15 +381,7 @@ TrySetMovementAnimation("STAND");
439 public void UpdateMovementAnimations() 381 public void UpdateMovementAnimations()
440 { 382 {
441 m_movementAnimation = GetMovementAnimation(); 383 m_movementAnimation = GetMovementAnimation();
442/* if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) 384 TrySetMovementAnimation(m_movementAnimation);
443 {
444 // This was the previous behavior before PREJUMP
445 TrySetMovementAnimation("JUMP");
446 }
447 else
448 { removed for jumping */
449 TrySetMovementAnimation(m_movementAnimation);
450// rm for jumping }
451 } 385 }
452 386
453 public UUID[] GetAnimationArray() 387 public UUID[] GetAnimationArray()