aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs151
1 files changed, 119 insertions, 32 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index b847d87..99d9564 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -58,7 +58,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
58 private int m_animTickFall; 58 private int m_animTickFall;
59// private int m_animTickJump; 59// private int m_animTickJump;
60 public int m_animTickJump; // ScenePresence has to see this to control +Z force 60 public int m_animTickJump; // ScenePresence has to see this to control +Z force
61 61 public bool m_jumping = false; // Add for jumping
62 public float m_jumpVelocity = 0f; // Add for jumping
63 private int m_landing = 0; // Add for jumping
64
62 /// <value> 65 /// <value>
63 /// The scene presence that this animator applies to 66 /// The scene presence that this animator applies to
64 /// </value> 67 /// </value>
@@ -141,9 +144,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation
141 /// </summary> 144 /// </summary>
142 public string GetMovementAnimation() 145 public string GetMovementAnimation()
143 { 146 {
147//Console.WriteLine("GMA-------"); //##
144 const float FALL_DELAY = 0.33f; 148 const float FALL_DELAY = 0.33f;
145 const float PREJUMP_DELAY = 0.25f; 149//rm for jumping const float PREJUMP_DELAY = 0.25f;
146 150 const float PREJUMP_DELAY = 200f; // mS add for jumping
151 const float JUMP_PERIOD = 800f; // mS add for jumping
147 #region Inputs 152 #region Inputs
148 153
149 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; 154 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags;
@@ -177,8 +182,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
177 182
178 // Is the avatar trying to move? 183 // Is the avatar trying to move?
179// bool moving = (move != Vector3.Zero); 184// bool moving = (move != Vector3.Zero);
180 bool jumping = m_animTickJump != 0; 185// rm for jumping bool jumping = m_animTickJump != 0;
181
182 #endregion Inputs 186 #endregion Inputs
183 187
184 #region Flying 188 #region Flying
@@ -187,6 +191,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation
187 { 191 {
188 m_animTickFall = 0; 192 m_animTickFall = 0;
189 m_animTickJump = 0; 193 m_animTickJump = 0;
194 m_jumping = false; //add for jumping flag
195 m_jumpVelocity = 0f; //add for jumping flag
196 actor.Selected = false; //add for jumping flag
190 197
191 if (move.X != 0f || move.Y != 0f) 198 if (move.X != 0f || move.Y != 0f)
192 { 199 {
@@ -213,8 +220,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
213 220
214 #region Falling/Floating/Landing 221 #region Falling/Floating/Landing
215 222
216 if (actor == null || !actor.IsColliding) 223// rm for jumping if (actor == null || !actor.IsColliding)
224 if ((actor == null || !actor.IsColliding) && !m_jumping) // add for jumping
217 { 225 {
226//Console.WriteLine("FFL"); //##
218 float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; 227 float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
219 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; 228 float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f;
220 229
@@ -223,7 +232,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
223 // Just started falling 232 // Just started falling
224 m_animTickFall = Environment.TickCount; 233 m_animTickFall = Environment.TickCount;
225 } 234 }
226 else if (!jumping && fallElapsed > FALL_DELAY) 235// else if (!jumping && fallElapsed > FALL_DELAY)
236 else if (!m_jumping && fallElapsed > FALL_DELAY) // add for jumping
227 { 237 {
228 // Falling long enough to trigger the animation 238 // Falling long enough to trigger the animation
229 return "FALLDOWN"; 239 return "FALLDOWN";
@@ -234,6 +244,67 @@ namespace OpenSim.Region.Framework.Scenes.Animation
234 244
235 #endregion Falling/Floating/Landing 245 #endregion Falling/Floating/Landing
236 246
247
248 #region Jumping // section added for jumping...
249
250 Vector3 vj = Vector3.Zero;
251 int jumptime;
252 jumptime = Environment.TickCount - m_animTickJump;
253
254
255 if ((move.Z > 0f) && (!m_jumping))
256 {
257//Console.WriteLine("PJ {0}", jumptime); //##
258 // Start jumping, prejump
259 m_animTickFall = 0;
260 m_jumping = true;
261 actor.Selected = true; // borrowed for jmping flag
262 m_animTickJump = Environment.TickCount;
263 vj.Z = 0.35f;
264m_jumpVelocity = 0.35f;
265 vj += actor.Velocity;
266// #@ actor.Velocity = vj;
267 return "PREJUMP";
268 }
269
270 if(m_jumping)
271 {
272 if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding)
273 {
274//Console.WriteLine("LA {0}", jumptime); //##
275 // end jumping
276 m_jumping = false;
277 actor.Selected = false; // borrowed for jumping flag
278m_jumpVelocity = 0f;
279 m_animTickFall = Environment.TickCount;
280 return "LAND";
281 }
282 else if (jumptime > JUMP_PERIOD)
283 {
284//Console.WriteLine("JD {0}", jumptime); //##
285 // jump down
286 vj = actor.Velocity;
287 vj.Z = 0f;
288m_jumpVelocity = 0f;
289// #@ actor.Velocity = vj;
290 return "JUMP";
291 }
292 else if (jumptime > PREJUMP_DELAY)
293 {
294//Console.WriteLine("JU {0}", jumptime); //##
295 // jump up
296 m_jumping = true;
297 vj.Z = 10f;
298m_jumpVelocity = 10f;
299 vj.X = actor.Velocity.X;
300 vj.Y = actor.Velocity.Y;
301// #@ actor.Velocity = vj;
302 return "JUMP";
303 }
304 }
305
306 #endregion Jumping // end added section
307
237 #region Ground Movement 308 #region Ground Movement
238 309
239 if (m_movementAnimation == "FALLDOWN") 310 if (m_movementAnimation == "FALLDOWN")
@@ -245,11 +316,26 @@ namespace OpenSim.Region.Framework.Scenes.Animation
245 } 316 }
246 else if (m_movementAnimation == "LAND") 317 else if (m_movementAnimation == "LAND")
247 { 318 {
248 float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; 319// rm jumping float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
249 if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY)) 320 int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping
321// rm jumping if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY))
322/* Try change ##
323 if ((m_animTickFall != 0) && (landElapsed <= 500)) // add for jumping
324 return "LAND";
325 */
326 // NB if this is set too long a weird anim reset from some place prevents STAND from being sent to client
327 if ((m_animTickFall != 0) && (landElapsed <= 300)) // add for jumping
328 {
329//Console.WriteLine("LAND"); //##
250 return "LAND"; 330 return "LAND";
331 }
332 else
333 {
334//Console.WriteLine("STAND"); //##
335 return "STAND";
336 }
251 } 337 }
252 338/* This section removed, replaced by jumping section
253 m_animTickFall = 0; 339 m_animTickFall = 0;
254 340
255 if (move.Z > 0f) 341 if (move.Z > 0f)
@@ -279,27 +365,28 @@ namespace OpenSim.Region.Framework.Scenes.Animation
279 { 365 {
280 // Not jumping 366 // Not jumping
281 m_animTickJump = 0; 367 m_animTickJump = 0;
282 368 */
283 if (move.X != 0f || move.Y != 0f) 369 // next section moved outside paren. and realigned for jumping
284 { 370 if (move.X != 0f || move.Y != 0f)
285 // Walking / crouchwalking / running 371 {
286 if (move.Z < 0f) 372 // Walking / crouchwalking / running
287 return "CROUCHWALK"; 373 if (move.Z < 0f)
288 else if (m_scenePresence.SetAlwaysRun) 374 return "CROUCHWALK";
289 return "RUN"; 375 else if (m_scenePresence.SetAlwaysRun)
290 else 376 return "RUN";
291 return "WALK";
292 }
293 else 377 else
294 { 378 return "WALK";
295 // Not walking
296 if (move.Z < 0f)
297 return "CROUCH";
298 else
299 return "STAND";
300 }
301 } 379 }
302 380// rm for jumping else
381 else if (!m_jumping) // add for jumping
382 {
383 // Not walking
384 if (move.Z < 0f)
385 return "CROUCH";
386 else
387 return "STAND";
388 }
389 // end section realign for jumping
303 #endregion Ground Movement 390 #endregion Ground Movement
304 391
305 return m_movementAnimation; 392 return m_movementAnimation;
@@ -311,15 +398,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation
311 public void UpdateMovementAnimations() 398 public void UpdateMovementAnimations()
312 { 399 {
313 m_movementAnimation = GetMovementAnimation(); 400 m_movementAnimation = GetMovementAnimation();
314 if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) 401/* if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump)
315 { 402 {
316 // This was the previous behavior before PREJUMP 403 // This was the previous behavior before PREJUMP
317 TrySetMovementAnimation("JUMP"); 404 TrySetMovementAnimation("JUMP");
318 } 405 }
319 else 406 else
320 { 407 { removed for jumping */
321 TrySetMovementAnimation(m_movementAnimation); 408 TrySetMovementAnimation(m_movementAnimation);
322 } 409// rm for jumping }
323 } 410 }
324 411
325 public UUID[] GetAnimationArray() 412 public UUID[] GetAnimationArray()