aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs226
-rw-r--r--bin/data/avataranimations.xml2
2 files changed, 184 insertions, 44 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index db83cb0..915b202 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -117,6 +117,11 @@ namespace OpenSim.Region.Framework.Scenes
117 117
118 private bool m_setAlwaysRun; 118 private bool m_setAlwaysRun;
119 119
120 private string m_movementAnimation = "DEFAULT";
121 private long m_animPersistUntil;
122 private bool m_allowFalling = false;
123
124
120 private Quaternion m_bodyRot= Quaternion.Identity; 125 private Quaternion m_bodyRot= Quaternion.Identity;
121 126
122 public bool IsRestrictedToRegion; 127 public bool IsRestrictedToRegion;
@@ -1943,66 +1948,191 @@ namespace OpenSim.Region.Framework.Scenes
1943 /// </summary> 1948 /// </summary>
1944 public string GetMovementAnimation() 1949 public string GetMovementAnimation()
1945 { 1950 {
1946 if (m_movementflag != 0) 1951 if ((m_animPersistUntil > 0) && (m_animPersistUntil > DateTime.Now.Ticks))
1947 { 1952 {
1948 // We are moving 1953 //We don't want our existing state to end yet.
1949 if (PhysicsActor != null && PhysicsActor.Flying) 1954 return m_movementAnimation;
1950 { 1955
1951 return "FLY"; 1956 }
1952 } 1957 else if (m_movementflag != 0)
1953 else if (PhysicsActor != null && (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 && 1958 {
1954 PhysicsActor.IsColliding) 1959 //We're moving
1960 m_allowFalling = true;
1961 if (PhysicsActor.IsColliding)
1955 { 1962 {
1956 if ((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || 1963 //And colliding. Can you guess what it is yet?
1957 (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0) 1964 if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)
1965 {
1966 //Down key is being pressed.
1967 if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) + (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
1968 {
1969 return "CROUCHWALK";
1970 }
1971 else
1972 {
1973 return "CROUCH";
1974 }
1975 }
1976 else if (m_setAlwaysRun)
1958 { 1977 {
1959 return "CROUCHWALK"; 1978 return "RUN";
1960 } 1979 }
1961 else 1980 else
1962 { 1981 {
1963 return "CROUCH"; 1982 //If we're prejumping then inhibit this, it's a problem
1983 //caused by a false positive on IsColliding
1984 if (m_movementAnimation == "PREJUMP")
1985 {
1986 return "PREJUMP";
1987 }
1988 else
1989 {
1990 return "WALK";
1991 }
1964 } 1992 }
1965 } 1993
1966 else if (PhysicsActor != null && !PhysicsActor.IsColliding && PhysicsActor.Velocity.Z < -2)
1967 {
1968 return "FALLDOWN";
1969 }
1970 else if (PhysicsActor != null && !PhysicsActor.IsColliding && Velocity.Z > 1e-6 &&
1971 (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
1972 {
1973 return "JUMP";
1974 }
1975 else if (m_setAlwaysRun)
1976 {
1977 return "RUN";
1978 } 1994 }
1979 else 1995 else
1980 { 1996 {
1981 return "WALK"; 1997 //We're not colliding. Colliding isn't cool these days.
1998 if (PhysicsActor.Flying)
1999 {
2000 //Are we moving forwards or backwards?
2001 if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0)
2002 {
2003 //Then we really are flying
2004 if (m_setAlwaysRun)
2005 {
2006 return "FLY";
2007 }
2008 else
2009 {
2010 return "FLYSLOW";
2011 }
2012 }
2013 else
2014 {
2015 if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
2016 {
2017 return "HOVER_UP";
2018 }
2019 else
2020 {
2021 return "HOVER_DOWN";
2022 }
2023 }
2024
2025 }
2026 else if (m_movementAnimation == "JUMP")
2027 {
2028 //If we were already jumping, continue to jump until we collide
2029 return "JUMP";
2030
2031 }
2032 else if (m_movementAnimation == "PREJUMP" && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == 0)
2033 {
2034 //If we were in a prejump, and the UP key is no longer being held down
2035 //then we're not going to fly, so we're jumping
2036 return "JUMP";
2037
2038 }
2039 else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
2040 {
2041 //They're pressing up, so we're either going to fly or jump
2042 return "PREJUMP";
2043 }
2044 else
2045 {
2046 //If we're moving and not flying and not jumping and not colliding..
2047
2048 if (m_movementAnimation == "WALK" || m_movementAnimation == "RUN")
2049 {
2050 //Let's not enter a FALLDOWN state here, since we're probably
2051 //not colliding because we're going down hill.
2052 return m_movementAnimation;
2053 }
2054 //Record the time we enter this state so we know whether to "land" or not
2055 m_animPersistUntil = DateTime.Now.Ticks;
2056 return "FALLDOWN";
2057
2058 }
1982 } 2059 }
1983 } 2060 }
1984 else 2061 else
1985 { 2062 {
1986 // We are not moving 2063 //We're not moving.
1987 if (PhysicsActor != null && !PhysicsActor.IsColliding && PhysicsActor.Velocity.Z < -2 && !PhysicsActor.Flying) 2064 if (PhysicsActor.IsColliding)
1988 {
1989 return "FALLDOWN";
1990 }
1991 else if (PhysicsActor != null && !PhysicsActor.IsColliding && Velocity.Z > 6 && !PhysicsActor.Flying)
1992 { 2065 {
1993 // HACK: We check if Velocity.Z > 6 for this animation in order to avoid false positives during normal movement. 2066 //But we are colliding.
1994 // TODO: set this animation only when on the ground and UP_POS is received? 2067 if (m_movementAnimation == "FALLDOWN")
2068 {
2069 //We're re-using the m_animPersistUntil value here to see how long we've been falling
2070 if ((DateTime.Now.Ticks - m_animPersistUntil) > TimeSpan.TicksPerSecond)
2071 {
2072 //Make sure we don't change state for a bit
2073 m_animPersistUntil = DateTime.Now.Ticks + TimeSpan.TicksPerSecond;
2074 return "LAND";
2075 }
2076 else
2077 {
2078 //We haven't been falling very long, we were probably just walking down hill
2079 return "STAND";
2080 }
2081 }
2082 else if (m_movementAnimation == "JUMP" || m_movementAnimation == "HOVER_DOWN")
2083 {
2084 //Make sure we don't change state for a bit
2085 m_animPersistUntil = DateTime.Now.Ticks + (1 * TimeSpan.TicksPerSecond);
2086 return "SOFT_LAND";
2087
2088 }
2089 else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
2090 {
2091 return "PREJUMP";
2092 }
2093 else if (PhysicsActor.Flying)
2094 {
2095 m_allowFalling = true;
2096 if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
2097 {
2098 return "HOVER_UP";
2099 }
2100 else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)
2101 {
2102 return "HOVER_DOWN";
2103 }
2104 else
2105 {
2106 return "HOVER";
2107 }
2108 }
2109 else
2110 {
2111 return "STAND";
2112 }
1995 2113
1996 // This is the standing jump
1997 return "JUMP";
1998 }
1999 else if (PhysicsActor != null && PhysicsActor.Flying)
2000 {
2001 return "HOVER";
2002 } 2114 }
2003 else 2115 else
2004 { 2116 {
2005 return "STAND"; 2117 //We're not colliding.
2118 if (PhysicsActor.Flying)
2119 {
2120
2121 return "HOVER";
2122
2123 }
2124 else if ((m_movementAnimation == "JUMP" || m_movementAnimation == "PREJUMP") && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == 0)
2125 {
2126
2127 return "JUMP";
2128
2129 }
2130 else
2131 {
2132 //Record the time we enter this state so we know whether to "land" or not
2133 m_animPersistUntil = DateTime.Now.Ticks;
2134 return "FALLDOWN";
2135 }
2006 } 2136 }
2007 } 2137 }
2008 } 2138 }
@@ -2012,8 +2142,18 @@ namespace OpenSim.Region.Framework.Scenes
2012 /// </summary> 2142 /// </summary>
2013 protected void UpdateMovementAnimations() 2143 protected void UpdateMovementAnimations()
2014 { 2144 {
2015 string animation = GetMovementAnimation(); 2145 string movementAnimation = GetMovementAnimation();
2016 TrySetMovementAnimation(animation); 2146
2147 if (movementAnimation == "FALLDOWN" && m_allowFalling == false)
2148 {
2149 movementAnimation = m_movementAnimation;
2150 }
2151 else
2152 {
2153 m_movementAnimation = movementAnimation;
2154 }
2155
2156 TrySetMovementAnimation(movementAnimation);
2017 } 2157 }
2018 2158
2019 /// <summary> 2159 /// <summary>
diff --git a/bin/data/avataranimations.xml b/bin/data/avataranimations.xml
index 08eab29..f90a457 100644
--- a/bin/data/avataranimations.xml
+++ b/bin/data/avataranimations.xml
@@ -61,7 +61,7 @@
61 <animation name="EXPRESS_WINK_EMOTE" state="">da020525-4d94-59d6-23d7-81fdebf33148</animation> 61 <animation name="EXPRESS_WINK_EMOTE" state="">da020525-4d94-59d6-23d7-81fdebf33148</animation>
62 <animation name="EXPRESS_WORRY" state="">9f496bd2-589a-709f-16cc-69bf7df1d36c</animation> 62 <animation name="EXPRESS_WORRY" state="">9f496bd2-589a-709f-16cc-69bf7df1d36c</animation>
63 <animation name="EXPRESS_WORRY_EMOTE" state="">9c05e5c7-6f07-6ca4-ed5a-b230390c3950</animation> 63 <animation name="EXPRESS_WORRY_EMOTE" state="">9c05e5c7-6f07-6ca4-ed5a-b230390c3950</animation>
64 <animation name="FALLDOWN" state="">666307d9-a860-572d-6fd4-c3ab8865c094</animation> 64 <animation name="FALLDOWN" state="Falling">666307d9-a860-572d-6fd4-c3ab8865c094</animation>
65 <animation name="FEMALE_WALK" state="Walking">f5fc7433-043d-e819-8298-f519a119b688</animation> 65 <animation name="FEMALE_WALK" state="Walking">f5fc7433-043d-e819-8298-f519a119b688</animation>
66 <animation name="FIST_PUMP" state="">7db00ccd-f380-f3ee-439d-61968ec69c8a</animation> 66 <animation name="FIST_PUMP" state="">7db00ccd-f380-f3ee-439d-61968ec69c8a</animation>
67 <animation name="FLY" state="Flying">aec4610c-757f-bc4e-c092-c6e9caf18daf</animation> 67 <animation name="FLY" state="Flying">aec4610c-757f-bc4e-c092-c6e9caf18daf</animation>