aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
authorOren Hurvitz2013-09-25 10:56:05 +0300
committerJustin Clark-Casey (justincc)2013-10-15 23:59:16 +0100
commitd0c17808391e93964dcaf0ffcf06899c5669f4ff (patch)
treeaff765cc1e1359a89aef48ad266ae1ab95e04fd0 /OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
parentAs discussed on many previous occasions, switch the default physics engine in... (diff)
downloadopensim-SC_OLD-d0c17808391e93964dcaf0ffcf06899c5669f4ff.zip
opensim-SC_OLD-d0c17808391e93964dcaf0ffcf06899c5669f4ff.tar.gz
opensim-SC_OLD-d0c17808391e93964dcaf0ffcf06899c5669f4ff.tar.bz2
opensim-SC_OLD-d0c17808391e93964dcaf0ffcf06899c5669f4ff.tar.xz
Fixed rezzing coalesced objects from a prim's inventory
Previously only the first object in the Coalesced Object was rezzed. Now all the objects are rezzed.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs119
1 files changed, 97 insertions, 22 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 4bebbe8..65536db 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -31,6 +31,7 @@ using System.Collections;
31using System.Reflection; 31using System.Reflection;
32using System.Text; 32using System.Text;
33using System.Timers; 33using System.Timers;
34using System.Xml;
34using OpenMetaverse; 35using OpenMetaverse;
35using OpenMetaverse.Packets; 36using OpenMetaverse.Packets;
36using log4net; 37using log4net;
@@ -2135,6 +2136,69 @@ namespace OpenSim.Region.Framework.Scenes
2135 } 2136 }
2136 2137
2137 /// <summary> 2138 /// <summary>
2139 /// Returns the list of Scene Objects in an asset.
2140 /// </summary>
2141 /// <remarks>
2142 /// Returns one object if the asset is a regular object, and multiple objects for a coalesced object.
2143 /// </remarks>
2144 /// <param name="assetData">Asset data</param>
2145 /// <param name="attachment">Whether the item is an attachment</param>
2146 /// <param name="objlist">The objects included in the asset</param>
2147 /// <param name="veclist">Relative positions of the objects</param>
2148 /// <param name="bbox">Bounding box of all the objects</param>
2149 /// <param name="offsetHeight">Offset in the Z axis from the centre of the bounding box
2150 /// to the centre of the root prim (relevant only when returning a single object)</param>
2151 /// <returns>true = returning a single object; false = multiple objects</returns>
2152 public bool GetObjectsToRez(byte[] assetData, bool attachment, out List<SceneObjectGroup> objlist, out List<Vector3> veclist,
2153 out Vector3 bbox, out float offsetHeight)
2154 {
2155 objlist = new List<SceneObjectGroup>();
2156 veclist = new List<Vector3>();
2157
2158 XmlDocument doc = new XmlDocument();
2159 string xmlData = Utils.BytesToString(assetData);
2160 doc.LoadXml(xmlData);
2161 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject");
2162
2163 if (e == null || attachment) // Single
2164 {
2165 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
2166 objlist.Add(g);
2167 veclist.Add(new Vector3(0, 0, 0));
2168 bbox = g.GetAxisAlignedBoundingBox(out offsetHeight);
2169 return true;
2170 }
2171 else
2172 {
2173 XmlElement coll = (XmlElement)e;
2174 float bx = Convert.ToSingle(coll.GetAttribute("x"));
2175 float by = Convert.ToSingle(coll.GetAttribute("y"));
2176 float bz = Convert.ToSingle(coll.GetAttribute("z"));
2177 bbox = new Vector3(bx, by, bz);
2178 offsetHeight = 0;
2179
2180 XmlNodeList groups = e.SelectNodes("SceneObjectGroup");
2181 foreach (XmlNode n in groups)
2182 {
2183 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml);
2184 objlist.Add(g);
2185
2186 XmlElement el = (XmlElement)n;
2187 string rawX = el.GetAttribute("offsetx");
2188 string rawY = el.GetAttribute("offsety");
2189 string rawZ = el.GetAttribute("offsetz");
2190
2191 float x = Convert.ToSingle(rawX);
2192 float y = Convert.ToSingle(rawY);
2193 float z = Convert.ToSingle(rawZ);
2194 veclist.Add(new Vector3(x, y, z));
2195 }
2196 }
2197
2198 return false;
2199 }
2200
2201 /// <summary>
2138 /// Event Handler Rez an object into a scene 2202 /// Event Handler Rez an object into a scene
2139 /// Calls the non-void event handler 2203 /// Calls the non-void event handler
2140 /// </summary> 2204 /// </summary>
@@ -2209,19 +2273,25 @@ namespace OpenSim.Region.Framework.Scenes
2209 /// will be used if it exists.</param> 2273 /// will be used if it exists.</param>
2210 /// <param name="vel">The velocity of the rezzed object.</param> 2274 /// <param name="vel">The velocity of the rezzed object.</param>
2211 /// <param name="param"></param> 2275 /// <param name="param"></param>
2212 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful</returns> 2276 /// <returns>The SceneObjectGroup(s) rezzed, or null if rez was unsuccessful</returns>
2213 public virtual SceneObjectGroup RezObject( 2277 public virtual List<SceneObjectGroup> RezObject(
2214 SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param) 2278 SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param)
2215 { 2279 {
2216 if (null == item) 2280 if (null == item)
2217 return null; 2281 return null;
2282
2283 List<SceneObjectGroup> objlist;
2284 List<Vector3> veclist;
2218 2285
2219 SceneObjectGroup group = sourcePart.Inventory.GetRezReadySceneObject(item); 2286 bool success = sourcePart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist);
2220 2287 if (!success)
2221 if (null == group)
2222 return null; 2288 return null;
2223 2289
2224 if (!Permissions.CanRezObject(group.PrimCount, item.OwnerID, pos)) 2290 int totalPrims = 0;
2291 foreach (SceneObjectGroup group in objlist)
2292 totalPrims += group.PrimCount;
2293
2294 if (!Permissions.CanRezObject(totalPrims, item.OwnerID, pos))
2225 return null; 2295 return null;
2226 2296
2227 if (!Permissions.BypassPermissions()) 2297 if (!Permissions.BypassPermissions())
@@ -2230,23 +2300,28 @@ namespace OpenSim.Region.Framework.Scenes
2230 sourcePart.Inventory.RemoveInventoryItem(item.ItemID); 2300 sourcePart.Inventory.RemoveInventoryItem(item.ItemID);
2231 } 2301 }
2232 2302
2233 2303 for (int i = 0; i < objlist.Count; i++)
2234 if (group.IsAttachment == false && group.RootPart.Shape.State != 0)
2235 { 2304 {
2236 group.RootPart.AttachedPos = group.AbsolutePosition; 2305 SceneObjectGroup group = objlist[i];
2237 group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; 2306 Vector3 curpos = pos + veclist[i];
2307
2308 if (group.IsAttachment == false && group.RootPart.Shape.State != 0)
2309 {
2310 group.RootPart.AttachedPos = group.AbsolutePosition;
2311 group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint;
2312 }
2313
2314 group.FromPartID = sourcePart.UUID;
2315 AddNewSceneObject(group, true, curpos, rot, vel);
2316
2317 // We can only call this after adding the scene object, since the scene object references the scene
2318 // to find out if scripts should be activated at all.
2319 group.CreateScriptInstances(param, true, DefaultScriptEngine, 3);
2320
2321 group.ScheduleGroupForFullUpdate();
2238 } 2322 }
2239 2323
2240 group.FromPartID = sourcePart.UUID; 2324 return objlist;
2241 AddNewSceneObject(group, true, pos, rot, vel);
2242
2243 // We can only call this after adding the scene object, since the scene object references the scene
2244 // to find out if scripts should be activated at all.
2245 group.CreateScriptInstances(param, true, DefaultScriptEngine, 3);
2246
2247 group.ScheduleGroupForFullUpdate();
2248
2249 return group;
2250 } 2325 }
2251 2326
2252 public virtual bool returnObjects(SceneObjectGroup[] returnobjects, 2327 public virtual bool returnObjects(SceneObjectGroup[] returnobjects,