diff options
author | Justin Clark-Casey (justincc) | 2012-03-21 23:57:39 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-03-21 23:57:39 +0000 |
commit | 1a8769e6eff0eab750a528f27d127637edbd292b (patch) | |
tree | eb488868d606738222ff47493c82fb19a903cb42 /OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs | |
parent | If "debug scene updates true" then print out to log when a garbage collection... (diff) | |
download | opensim-SC_OLD-1a8769e6eff0eab750a528f27d127637edbd292b.zip opensim-SC_OLD-1a8769e6eff0eab750a528f27d127637edbd292b.tar.gz opensim-SC_OLD-1a8769e6eff0eab750a528f27d127637edbd292b.tar.bz2 opensim-SC_OLD-1a8769e6eff0eab750a528f27d127637edbd292b.tar.xz |
Instead of loading default avatar animations in both SLUtil and AvatarAnimations, load just in AvatarAnimations instead.
This lets us remove the dependency of OpenSim.Framework.dll on data/avataranimations.xml, which is not necessary for ROBUST.
This commit also takes care of the odd situation where animations are stored and used internally with uppercase names (e.g. "STAND")
but scripts refer to them with lowercase names (e.g. "sit").
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs | 81 |
1 files changed, 63 insertions, 18 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs b/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs index 659c3a5..ec928f4 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs | |||
@@ -26,38 +26,83 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | ||
29 | using System.Xml; | 30 | using System.Xml; |
31 | using log4net; | ||
30 | using OpenMetaverse; | 32 | using OpenMetaverse; |
31 | 33 | ||
32 | namespace OpenSim.Region.Framework.Scenes.Animation | 34 | namespace OpenSim.Region.Framework.Scenes.Animation |
33 | { | 35 | { |
34 | public class AvatarAnimations | 36 | public class AvatarAnimations |
35 | { | 37 | { |
36 | public Dictionary<string, UUID> AnimsUUID = new Dictionary<string, UUID>(); | 38 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
37 | public Dictionary<UUID, string> AnimsNames = new Dictionary<UUID, string>(); | ||
38 | public Dictionary<UUID, string> AnimStateNames = new Dictionary<UUID, string>(); | ||
39 | 39 | ||
40 | public AvatarAnimations() | 40 | public static readonly string DefaultAnimationsPath = "data/avataranimations.xml"; |
41 | |||
42 | public static Dictionary<string, UUID> AnimsUUID = new Dictionary<string, UUID>(); | ||
43 | public static Dictionary<UUID, string> AnimsNames = new Dictionary<UUID, string>(); | ||
44 | public static Dictionary<UUID, string> AnimStateNames = new Dictionary<UUID, string>(); | ||
45 | |||
46 | static AvatarAnimations() | ||
47 | { | ||
48 | LoadAnimations(DefaultAnimationsPath); | ||
49 | } | ||
50 | |||
51 | /// <summary> | ||
52 | /// Load the default SL avatar animations. | ||
53 | /// </summary> | ||
54 | /// <returns></returns> | ||
55 | private static void LoadAnimations(string path) | ||
41 | { | 56 | { |
42 | using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml")) | 57 | // Dictionary<string, UUID> animations = new Dictionary<string, UUID>(); |
58 | |||
59 | using (XmlTextReader reader = new XmlTextReader(path)) | ||
43 | { | 60 | { |
44 | XmlDocument doc = new XmlDocument(); | 61 | XmlDocument doc = new XmlDocument(); |
45 | doc.Load(reader); | 62 | doc.Load(reader); |
46 | foreach (XmlNode nod in doc.DocumentElement.ChildNodes) | 63 | // if (doc.DocumentElement != null) |
47 | { | 64 | // { |
48 | if (nod.Attributes["name"] != null) | 65 | foreach (XmlNode nod in doc.DocumentElement.ChildNodes) |
49 | { | 66 | { |
50 | string name = (string)nod.Attributes["name"].Value; | 67 | if (nod.Attributes["name"] != null) |
51 | UUID id = (UUID)nod.InnerText; | 68 | { |
52 | string animState = (string)nod.Attributes["state"].Value; | 69 | string name = nod.Attributes["name"].Value; |
53 | 70 | UUID id = (UUID)nod.InnerText; | |
54 | AnimsUUID.Add(name, id); | 71 | string animState = (string)nod.Attributes["state"].Value; |
55 | AnimsNames.Add(id, name); | 72 | |
56 | if (animState != "") | 73 | AnimsUUID.Add(name, id); |
57 | AnimStateNames.Add(id, animState); | 74 | AnimsNames.Add(id, name); |
75 | if (animState != "") | ||
76 | AnimStateNames.Add(id, animState); | ||
77 | |||
78 | // m_log.DebugFormat("[AVATAR ANIMATIONS]: Loaded {0} {1} {2}", id, name, animState); | ||
79 | } | ||
58 | } | 80 | } |
59 | } | 81 | // } |
82 | } | ||
83 | |||
84 | // return animations; | ||
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// Get the default avatar animation with the given name. | ||
89 | /// </summary> | ||
90 | /// <param name="name"></param> | ||
91 | /// <returns></returns> | ||
92 | public static UUID GetDefaultAnimation(string name) | ||
93 | { | ||
94 | // m_log.DebugFormat( | ||
95 | // "[AVATAR ANIMATIONS]: Looking for default avatar animation with name {0}", name); | ||
96 | |||
97 | if (AnimsUUID.ContainsKey(name)) | ||
98 | { | ||
99 | // m_log.DebugFormat( | ||
100 | // "[AVATAR ANIMATIONS]: Found {0} {1} in GetDefaultAvatarAnimation()", AnimsUUID[name], name); | ||
101 | |||
102 | return AnimsUUID[name]; | ||
60 | } | 103 | } |
104 | |||
105 | return UUID.Zero; | ||
61 | } | 106 | } |
62 | } | 107 | } |
63 | } | 108 | } \ No newline at end of file |