aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/DataSnapshot/ObjectSnapshot.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
index 9639095..76dac61 100644
--- a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
+++ b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
@@ -45,6 +45,10 @@ namespace OpenSim.Region.DataSnapshot.Providers
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private bool m_stale = true; 46 private bool m_stale = true;
47 47
48 private static UUID m_DefaultImage = new UUID("89556747-24cb-43ed-920b-47caed15465f");
49 private static UUID m_BlankImage = new UUID("5748decc-f629-461c-9a36-a35a221fe21f");
50
51
48 public void Initialize(Scene scene, DataSnapshotManager parent) 52 public void Initialize(Scene scene, DataSnapshotManager parent)
49 { 53 {
50 m_scene = scene; 54 m_scene = scene;
@@ -142,6 +146,19 @@ namespace OpenSim.Region.DataSnapshot.Providers
142 node.InnerText = land.LandData.GlobalID.ToString(); 146 node.InnerText = land.LandData.GlobalID.ToString();
143 xmlobject.AppendChild(node); 147 xmlobject.AppendChild(node);
144 148
149 node = nodeFactory.CreateNode(XmlNodeType.Element, "location", "");
150 Vector3 loc = obj.AbsolutePosition;
151 node.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString();
152 xmlobject.AppendChild(node);
153
154 string bestImage = GuessImage(obj);
155 if (bestImage != string.Empty)
156 {
157 node = nodeFactory.CreateNode(XmlNodeType.Element, "image", "");
158 node.InnerText = bestImage;
159 xmlobject.AppendChild(node);
160 }
161
145 parent.AppendChild(xmlobject); 162 parent.AppendChild(xmlobject);
146 } 163 }
147 } 164 }
@@ -173,5 +190,58 @@ namespace OpenSim.Region.DataSnapshot.Providers
173 } 190 }
174 191
175 public event ProviderStale OnStale; 192 public event ProviderStale OnStale;
193
194 /// <summary>
195 /// Guesses the best image, based on a simple heuristic. It guesses only for boxes.
196 /// We're optimizing for boxes, because those are the most common objects
197 /// marked "Show in search" -- boxes with content inside.For other shapes,
198 /// it's really hard to tell which texture should be grabbed.
199 /// </summary>
200 /// <param name="sog"></param>
201 /// <returns></returns>
202 private string GuessImage(SceneObjectGroup sog)
203 {
204 string bestguess = string.Empty;
205 Dictionary<UUID, int> counts = new Dictionary<UUID, int>();
206 if (sog.RootPart.Shape != null && sog.RootPart.Shape.ProfileShape == ProfileShape.Square &&
207 sog.RootPart.Shape.Textures != null && sog.RootPart.Shape.Textures.FaceTextures != null)
208 {
209 if (sog.RootPart.Shape.Textures.DefaultTexture.TextureID != UUID.Zero &&
210 sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_DefaultImage &&
211 sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_BlankImage &&
212 sog.RootPart.Shape.Textures.DefaultTexture.RGBA.A < 50)
213 {
214 counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = 8;
215 }
216
217 foreach (Primitive.TextureEntryFace tentry in sog.RootPart.Shape.Textures.FaceTextures)
218 {
219 if (tentry != null)
220 {
221 if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50)
222 {
223 int c = 0;
224 counts.TryGetValue(tentry.TextureID, out c);
225 counts[tentry.TextureID] = c + 1;
226 // decrease the default texture count
227 if (counts.ContainsKey(sog.RootPart.Shape.Textures.DefaultTexture.TextureID))
228 counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] - 1;
229 }
230 }
231 }
232
233 // Let's pick the most unique texture
234 int min = 9999;
235 foreach (KeyValuePair<UUID, int> kv in counts)
236 {
237 if (kv.Value < min && kv.Value >= 1)
238 {
239 bestguess = kv.Key.ToString();
240 min = kv.Value;
241 }
242 }
243 }
244 return bestguess;
245 }
176 } 246 }
177} 247}