aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs13
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs14
-rw-r--r--OpenSim/Framework/WearableCacheItem.cs118
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs19
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs181
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs134
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs7
-rw-r--r--OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs128
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs41
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs21
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs42
15 files changed, 609 insertions, 122 deletions
diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
index 4fa604f..5536564 100644
--- a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
30using System.Collections.Specialized; 31using System.Collections.Specialized;
31using System.Drawing; 32using System.Drawing;
32using System.Drawing.Imaging; 33using System.Drawing.Imaging;
@@ -50,6 +51,7 @@ namespace OpenSim.Capabilities.Handlers
50{ 51{
51 public class UploadBakedTextureHandler 52 public class UploadBakedTextureHandler
52 { 53 {
54
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 56
55 private Caps m_HostCapsObj; 57 private Caps m_HostCapsObj;
@@ -79,9 +81,9 @@ namespace OpenSim.Capabilities.Handlers
79 { 81 {
80 string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; 82 string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
81 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); 83 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
82 84
83 BakedTextureUploader uploader = 85 BakedTextureUploader uploader =
84 new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener); 86 new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_HostCapsObj.AgentID);
85 uploader.OnUpLoad += BakedTextureUploaded; 87 uploader.OnUpLoad += BakedTextureUploaded;
86 88
87 m_HostCapsObj.HttpListener.AddStreamHandler( 89 m_HostCapsObj.HttpListener.AddStreamHandler(
@@ -125,6 +127,7 @@ namespace OpenSim.Capabilities.Handlers
125 asset.Temporary = true; 127 asset.Temporary = true;
126 asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are 128 asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are
127 m_assetService.Store(asset); 129 m_assetService.Store(asset);
130
128 } 131 }
129 } 132 }
130 133
@@ -137,15 +140,19 @@ namespace OpenSim.Capabilities.Handlers
137 private string uploaderPath = String.Empty; 140 private string uploaderPath = String.Empty;
138 private UUID newAssetID; 141 private UUID newAssetID;
139 private IHttpServer httpListener; 142 private IHttpServer httpListener;
143 private UUID AgentId = UUID.Zero;
140 144
141 public BakedTextureUploader(string path, IHttpServer httpServer) 145 public BakedTextureUploader(string path, IHttpServer httpServer, UUID uUID)
142 { 146 {
143 newAssetID = UUID.Random(); 147 newAssetID = UUID.Random();
144 uploaderPath = path; 148 uploaderPath = path;
145 httpListener = httpServer; 149 httpListener = httpServer;
150 AgentId = uUID;
146 // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID); 151 // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID);
147 } 152 }
148 153
154
155
149 /// <summary> 156 /// <summary>
150 /// Handle raw uploaded baked texture data. 157 /// Handle raw uploaded baked texture data.
151 /// </summary> 158 /// </summary>
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 4df4fb6..ffc3527 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -66,7 +66,9 @@ namespace OpenSim.Framework
66 protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f); 66 protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f);
67 protected float m_avatarFeetOffset = 0; 67 protected float m_avatarFeetOffset = 0;
68 protected float m_avatarAnimOffset = 0; 68 protected float m_avatarAnimOffset = 0;
69 protected WearableCacheItem[] cacheitems; 69 protected WearableCacheItem[] m_cacheitems;
70 protected bool m_cacheItemsDirty = true;
71
70 public virtual int Serial 72 public virtual int Serial
71 { 73 {
72 get { return m_serial; } 74 get { return m_serial; }
@@ -118,8 +120,14 @@ namespace OpenSim.Framework
118 120
119 public virtual WearableCacheItem[] WearableCacheItems 121 public virtual WearableCacheItem[] WearableCacheItems
120 { 122 {
121 get { return cacheitems; } 123 get { return m_cacheitems; }
122 set { cacheitems = value; } 124 set { m_cacheitems = value; }
125 }
126
127 public virtual bool WearableCacheItemsDirty
128 {
129 get { return m_cacheItemsDirty; }
130 set { m_cacheItemsDirty = value; }
123 } 131 }
124 132
125 public AvatarAppearance() 133 public AvatarAppearance()
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs
index 83b1346..1aecf79 100644
--- a/OpenSim/Framework/WearableCacheItem.cs
+++ b/OpenSim/Framework/WearableCacheItem.cs
@@ -26,14 +26,132 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using OpenMetaverse; 30using OpenMetaverse;
31using OpenMetaverse.StructuredData;
30 32
31namespace OpenSim.Framework 33namespace OpenSim.Framework
32{ 34{
35 [Serializable]
33 public class WearableCacheItem 36 public class WearableCacheItem
34 { 37 {
35 public uint TextureIndex { get; set; } 38 public uint TextureIndex { get; set; }
36 public UUID CacheId { get; set; } 39 public UUID CacheId { get; set; }
37 public UUID TextureID { get; set; } 40 public UUID TextureID { get; set; }
41 public AssetBase TextureAsset { get; set; }
42
43
44 public static WearableCacheItem[] GetDefaultCacheItem()
45 {
46 int itemmax = 21;
47 WearableCacheItem[] retitems = new WearableCacheItem[itemmax];
48 for (uint i=0;i<itemmax;i++)
49 retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i + 1};
50 return retitems;
51 }
52 public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache)
53 {
54 List<WearableCacheItem> ret = new List<WearableCacheItem>();
55 if (pInput.Type == OSDType.Array)
56 {
57 OSDArray itemarray = (OSDArray) pInput;
58 foreach (OSDMap item in itemarray)
59 {
60 ret.Add(new WearableCacheItem()
61 {
62 TextureIndex = item["textureindex"].AsUInteger(),
63 CacheId = item["cacheid"].AsUUID(),
64 TextureID = item["textureid"].AsUUID()
65 });
66
67 if (dataCache != null && item.ContainsKey("assetdata"))
68 {
69 AssetBase asset = new AssetBase(item["textureid"].AsUUID(),"BakedTexture",(sbyte)AssetType.Texture,UUID.Zero.ToString());
70 asset.Temporary = true;
71 asset.Data = item["assetdata"].AsBinary();
72 dataCache.Cache(asset);
73 }
74 }
75 }
76 else if (pInput.Type == OSDType.Map)
77 {
78 OSDMap item = (OSDMap) pInput;
79 ret.Add(new WearableCacheItem(){
80 TextureIndex = item["textureindex"].AsUInteger(),
81 CacheId = item["cacheid"].AsUUID(),
82 TextureID = item["textureid"].AsUUID()
83 });
84 if (dataCache != null && item.ContainsKey("assetdata"))
85 {
86 string assetCreator = item["assetcreator"].AsString();
87 string assetName = item["assetname"].AsString();
88 AssetBase asset = new AssetBase(item["textureid"].AsUUID(), assetName, (sbyte)AssetType.Texture, assetCreator);
89 asset.Temporary = true;
90 asset.Data = item["assetdata"].AsBinary();
91 dataCache.Cache(asset);
92 }
93 }
94 else
95 {
96 return new WearableCacheItem[0];
97 }
98 return ret.ToArray();
99
100 }
101 public static OSD ToOSD(WearableCacheItem[] pcacheItems, IImprovedAssetCache dataCache)
102 {
103 OSDArray arr = new OSDArray();
104 foreach (WearableCacheItem item in pcacheItems)
105 {
106 OSDMap itemmap = new OSDMap();
107 itemmap.Add("textureindex", OSD.FromUInteger(item.TextureIndex));
108 itemmap.Add("cacheid", OSD.FromUUID(item.CacheId));
109 itemmap.Add("textureid", OSD.FromUUID(item.TextureID));
110 if (dataCache != null)
111 {
112 if (dataCache.Check(item.TextureID.ToString()))
113 {
114 AssetBase assetItem = dataCache.Get(item.TextureID.ToString());
115 if (assetItem != null)
116 {
117 itemmap.Add("assetdata", OSD.FromBinary(assetItem.Data));
118 itemmap.Add("assetcreator", OSD.FromString(assetItem.CreatorID));
119 itemmap.Add("assetname", OSD.FromString(assetItem.Name));
120 }
121 }
122 }
123 arr.Add(itemmap);
124 }
125 return arr;
126 }
127 public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems)
128 {
129 for (int i = 0; i < pcacheItems.Length; i++)
130 {
131 if (pcacheItems[i].TextureIndex == pTextureIndex)
132 return pcacheItems[i];
133 }
134 return null;
135 }
136 public static WearableCacheItem SearchTextureCacheId(UUID pCacheId, WearableCacheItem[] pcacheItems)
137 {
138 for (int i = 0; i < pcacheItems.Length; i++)
139 {
140 if (pcacheItems[i].CacheId == pCacheId)
141 return pcacheItems[i];
142 }
143 return null;
144 }
145 public static WearableCacheItem SearchTextureTextureId(UUID pTextureId, WearableCacheItem[] pcacheItems)
146 {
147 for (int i = 0; i < pcacheItems.Length; i++)
148 {
149 if (pcacheItems[i].TextureID == pTextureId)
150 return pcacheItems[i];
151 }
152 return null;
153 }
38 } 154 }
155
156
39} 157}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index f6146a9..b06788b 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -103,6 +103,7 @@ namespace OpenSim.Region.ClientStack.Linden
103 private static readonly string m_getObjectPhysicsDataPath = "0101/"; 103 private static readonly string m_getObjectPhysicsDataPath = "0101/";
104 private static readonly string m_getObjectCostPath = "0102/"; 104 private static readonly string m_getObjectCostPath = "0102/";
105 private static readonly string m_ResourceCostSelectedPath = "0103/"; 105 private static readonly string m_ResourceCostSelectedPath = "0103/";
106 private static readonly string m_UpdateAgentInformationPath = "0500/";
106 107
107 108
108 // These are callbacks which will be setup by the scene so that we can update scene data when we 109 // These are callbacks which will be setup by the scene so that we can update scene data when we
@@ -287,6 +288,8 @@ namespace OpenSim.Region.ClientStack.Linden
287 m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); 288 m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler);
288 IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); 289 IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected);
289 m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); 290 m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler);
291 IRequestHandler UpdateAgentInformationHandler = new RestStreamHandler("POST", capsBase + m_UpdateAgentInformationPath, UpdateAgentInformation);
292 m_HostCapsObj.RegisterHandler("UpdateAgentInformation", UpdateAgentInformationHandler);
290 293
291 m_HostCapsObj.RegisterHandler( 294 m_HostCapsObj.RegisterHandler(
292 "CopyInventoryFromNotecard", 295 "CopyInventoryFromNotecard",
@@ -1438,6 +1441,22 @@ namespace OpenSim.Region.ClientStack.Linden
1438 string response = OSDParser.SerializeLLSDXmlString(resp); 1441 string response = OSDParser.SerializeLLSDXmlString(resp);
1439 return response; 1442 return response;
1440 } 1443 }
1444
1445 public string UpdateAgentInformation(string request, string path,
1446 string param, IOSHttpRequest httpRequest,
1447 IOSHttpResponse httpResponse)
1448 {
1449 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
1450 OSDMap resp = new OSDMap();
1451
1452 OSDMap accessPrefs = new OSDMap();
1453 accessPrefs["max"] = "A";
1454
1455 resp["access_prefs"] = accessPrefs;
1456
1457 string response = OSDParser.SerializeLLSDXmlString(resp);
1458 return response;
1459 }
1441 } 1460 }
1442 1461
1443 public class AssetUploader 1462 public class AssetUploader
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
index 3b0ccd7..6bed95f 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
30using System.Collections.Specialized; 31using System.Collections.Specialized;
31using System.Drawing; 32using System.Drawing;
32using System.Drawing.Imaging; 33using System.Drawing.Imaging;
@@ -53,8 +54,8 @@ namespace OpenSim.Region.ClientStack.Linden
53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadBakedTextureModule")] 54 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadBakedTextureModule")]
54 public class UploadBakedTextureModule : INonSharedRegionModule 55 public class UploadBakedTextureModule : INonSharedRegionModule
55 { 56 {
56// private static readonly ILog m_log = 57 private static readonly ILog m_log =
57// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 58 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 59
59 /// <summary> 60 /// <summary>
60 /// For historical reasons this is fixed, but there 61 /// For historical reasons this is fixed, but there
@@ -64,31 +65,195 @@ namespace OpenSim.Region.ClientStack.Linden
64 private Scene m_scene; 65 private Scene m_scene;
65 private bool m_persistBakedTextures; 66 private bool m_persistBakedTextures;
66 67
68 private IBakedTextureModule m_BakedTextureModule;
69
67 public void Initialise(IConfigSource source) 70 public void Initialise(IConfigSource source)
68 { 71 {
69 IConfig appearanceConfig = source.Configs["Appearance"]; 72 IConfig appearanceConfig = source.Configs["Appearance"];
70 if (appearanceConfig != null) 73 if (appearanceConfig != null)
71 m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); 74 m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
75
76
72 } 77 }
73 78
74 public void AddRegion(Scene s) 79 public void AddRegion(Scene s)
75 { 80 {
76 m_scene = s; 81 m_scene = s;
82
77 } 83 }
78 84
79 public void RemoveRegion(Scene s) 85 public void RemoveRegion(Scene s)
80 { 86 {
87 s.EventManager.OnRegisterCaps -= RegisterCaps;
88 s.EventManager.OnNewPresence -= RegisterNewPresence;
89 s.EventManager.OnRemovePresence -= DeRegisterPresence;
90 m_BakedTextureModule = null;
91 m_scene = null;
81 } 92 }
82 93
94
95
83 public void RegionLoaded(Scene s) 96 public void RegionLoaded(Scene s)
84 { 97 {
85 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 98 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
99 m_scene.EventManager.OnNewPresence += RegisterNewPresence;
100 m_scene.EventManager.OnRemovePresence += DeRegisterPresence;
101
102 }
103
104 private void DeRegisterPresence(UUID agentId)
105 {
106 ScenePresence presence = null;
107 if (m_scene.TryGetScenePresence(agentId, out presence))
108 {
109 presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings;
110 }
111
112 }
113
114 private void RegisterNewPresence(ScenePresence presence)
115 {
116 presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings;
117
118 }
119
120 private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
121 {
122 int maxCacheitemsLoop = cacheItems.Length;
123 if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES)
124 {
125 maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES;
126 m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES);
127 }
128
129 m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
130 if (cacheItems.Length > 0)
131 {
132 m_log.Debug("[Cacheitems]: " + cacheItems.Length);
133 for (int iter = 0; iter < maxCacheitemsLoop; iter++)
134 {
135 m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
136 cacheItems[iter].TextureID);
137 }
138
139 ScenePresence p = null;
140 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p))
141 {
142
143 WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems;
144 if (existingitems == null)
145 {
146 if (m_BakedTextureModule != null)
147 {
148 WearableCacheItem[] savedcache = null;
149 try
150 {
151 if (p.Appearance.WearableCacheItemsDirty)
152 {
153 savedcache = m_BakedTextureModule.Get(p.UUID);
154 p.Appearance.WearableCacheItems = savedcache;
155 p.Appearance.WearableCacheItemsDirty = false;
156 }
157
158 }
159 /*
160 * The following Catch types DO NOT WORK with m_BakedTextureModule.Get
161 * it jumps to the General Packet Exception Handler if you don't catch Exception!
162 *
163 catch (System.Net.Sockets.SocketException)
164 {
165 cacheItems = null;
166 }
167 catch (WebException)
168 {
169 cacheItems = null;
170 }
171 catch (InvalidOperationException)
172 {
173 cacheItems = null;
174 } */
175 catch (Exception)
176 {
177 // The service logs a sufficient error message.
178 }
179
180
181 if (savedcache != null)
182 existingitems = savedcache;
183 }
184 }
185 // Existing items null means it's a fully new appearance
186 if (existingitems == null)
187 {
188
189 for (int i = 0; i < maxCacheitemsLoop; i++)
190 {
191 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
192 {
193 cacheItems[i].TextureID =
194 textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID;
195 if (m_scene.AssetService != null)
196 cacheItems[i].TextureAsset =
197 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
198 }
199 else
200 {
201 m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length);
202 }
203
204
205 }
206 }
207 else
208
209
210 {
211 // for each uploaded baked texture
212 for (int i = 0; i < maxCacheitemsLoop; i++)
213 {
214 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
215 {
216 cacheItems[i].TextureID =
217 textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID;
218 }
219 else
220 {
221 m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length);
222 }
223 }
224
225 for (int i = 0; i < maxCacheitemsLoop; i++)
226 {
227 if (cacheItems[i].TextureAsset == null)
228 {
229 cacheItems[i].TextureAsset =
230 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
231 }
232 }
233 }
234
235
236
237 p.Appearance.WearableCacheItems = cacheItems;
238
239
240
241 if (m_BakedTextureModule != null)
242 {
243 m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems);
244 p.Appearance.WearableCacheItemsDirty = true;
245
246 }
247 }
248 }
86 } 249 }
87 250
88 public void PostInitialise() 251 public void PostInitialise()
89 { 252 {
90 } 253 }
91 254
255
256
92 public void Close() { } 257 public void Close() { }
93 258
94 public string Name { get { return "UploadBakedTextureModule"; } } 259 public string Name { get { return "UploadBakedTextureModule"; } }
@@ -100,15 +265,23 @@ namespace OpenSim.Region.ClientStack.Linden
100 265
101 public void RegisterCaps(UUID agentID, Caps caps) 266 public void RegisterCaps(UUID agentID, Caps caps)
102 { 267 {
268 UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler(
269 caps, m_scene.AssetService, m_persistBakedTextures);
270
271
272
103 caps.RegisterHandler( 273 caps.RegisterHandler(
104 "UploadBakedTexture", 274 "UploadBakedTexture",
105 new RestStreamHandler( 275 new RestStreamHandler(
106 "POST", 276 "POST",
107 "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, 277 "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath,
108 new UploadBakedTextureHandler( 278 avatarhandler.UploadBakedTexture,
109 caps, m_scene.AssetService, m_persistBakedTextures).UploadBakedTexture,
110 "UploadBakedTexture", 279 "UploadBakedTexture",
111 agentID.ToString())); 280 agentID.ToString()));
281
282
283
284
112 } 285 }
113 } 286 }
114} \ No newline at end of file 287} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 7364f45..465d76d 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -3629,7 +3629,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3629 3629
3630 avp.Sender.IsTrial = false; 3630 avp.Sender.IsTrial = false;
3631 avp.Sender.ID = agentID; 3631 avp.Sender.ID = agentID;
3632 //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString()); 3632 m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
3633 OutPacket(avp, ThrottleOutPacketType.State); 3633 OutPacket(avp, ThrottleOutPacketType.State);
3634 } 3634 }
3635 3635
@@ -11725,32 +11725,134 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11725 // var item = fac.GetBakedTextureFaces(AgentId); 11725 // var item = fac.GetBakedTextureFaces(AgentId);
11726 //WearableCacheItem[] items = fac.GetCachedItems(AgentId); 11726 //WearableCacheItem[] items = fac.GetCachedItems(AgentId);
11727 11727
11728 IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); 11728 IAssetService cache = m_scene.AssetService;
11729 if (cache == null) 11729 IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
11730 //bakedTextureModule = null;
11731 int maxWearablesLoop = cachedtex.WearableData.Length;
11732 if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES)
11733 maxWearablesLoop = AvatarWearable.MAX_WEARABLES;
11734
11735 if (bakedTextureModule != null && cache != null)
11730 { 11736 {
11731 for (int i = 0; i < cachedtex.WearableData.Length; i++) 11737 // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid
11738
11739 WearableCacheItem[] cacheItems = null;
11740 ScenePresence p = m_scene.GetScenePresence(AgentId);
11741 if (p.Appearance != null)
11742 if (p.Appearance.WearableCacheItems == null || p.Appearance.WearableCacheItemsDirty)
11743 {
11744 try
11745 {
11746 cacheItems = bakedTextureModule.Get(AgentId);
11747 p.Appearance.WearableCacheItems = cacheItems;
11748 p.Appearance.WearableCacheItemsDirty = false;
11749 }
11750
11751 /*
11752 * The following Catch types DO NOT WORK, it jumps to the General Packet Exception Handler if you don't catch Exception!
11753 *
11754 catch (System.Net.Sockets.SocketException)
11755 {
11756 cacheItems = null;
11757 }
11758 catch (WebException)
11759 {
11760 cacheItems = null;
11761 }
11762 catch (InvalidOperationException)
11763 {
11764 cacheItems = null;
11765 } */
11766 catch (Exception)
11767 {
11768 cacheItems = null;
11769 }
11770
11771 }
11772 else if (p.Appearance.WearableCacheItems != null)
11773 {
11774 cacheItems = p.Appearance.WearableCacheItems;
11775 }
11776
11777 if (cache != null && cacheItems != null)
11732 { 11778 {
11733 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 11779 foreach (WearableCacheItem item in cacheItems)
11734 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; 11780 {
11735 cachedresp.WearableData[i].TextureID = UUID.Zero; //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); 11781
11736 cachedresp.WearableData[i].HostName = new byte[0]; 11782 if (cache.GetCached(item.TextureID.ToString()) == null)
11783 {
11784 item.TextureAsset.Temporary = true;
11785 cache.Store(item.TextureAsset);
11786 }
11787
11788
11789 }
11790 }
11791
11792 if (cacheItems != null)
11793 {
11794
11795 for (int i = 0; i < maxWearablesLoop; i++)
11796 {
11797 WearableCacheItem item =
11798 WearableCacheItem.SearchTextureIndex(cachedtex.WearableData[i].TextureIndex,cacheItems);
11799
11800 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11801 cachedresp.WearableData[i].TextureIndex= cachedtex.WearableData[i].TextureIndex;
11802 cachedresp.WearableData[i].HostName = new byte[0];
11803 if (item != null && cachedtex.WearableData[i].ID == item.CacheId)
11804 {
11805
11806 cachedresp.WearableData[i].TextureID = item.TextureID;
11807 }
11808 else
11809 {
11810 cachedresp.WearableData[i].TextureID = UUID.Zero;
11811 }
11812 }
11813 }
11814 else
11815 {
11816 for (int i = 0; i < maxWearablesLoop; i++)
11817 {
11818 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11819 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
11820 cachedresp.WearableData[i].TextureID = UUID.Zero;
11821 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11822 cachedresp.WearableData[i].HostName = new byte[0];
11823 }
11737 } 11824 }
11738 } 11825 }
11739 else 11826 else
11740 { 11827 {
11741 for (int i = 0; i < cachedtex.WearableData.Length; i++) 11828 if (cache == null)
11742 { 11829 {
11743 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 11830 for (int i = 0; i < maxWearablesLoop; i++)
11744 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; 11831 {
11832 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11833 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
11834 cachedresp.WearableData[i].TextureID = UUID.Zero;
11835 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11836 cachedresp.WearableData[i].HostName = new byte[0];
11837 }
11838 }
11839 else
11840 {
11841 for (int i = 0; i < maxWearablesLoop; i++)
11842 {
11843 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11844 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
11745 11845
11746 11846
11747 11847
11748 if (cache.Check(cachedtex.WearableData[i].ID.ToString())) 11848 if (cache.GetCached(cachedresp.WearableData[i].TextureID.ToString()) == null)
11749 cachedresp.WearableData[i].TextureID = UUID.Zero; 11849 cachedresp.WearableData[i].TextureID = UUID.Zero;
11750 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); 11850 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11751 else 11851 else
11752 cachedresp.WearableData[i].TextureID = UUID.Zero; // UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); 11852 cachedresp.WearableData[i].TextureID = UUID.Zero;
11753 cachedresp.WearableData[i].HostName = new byte[0]; 11853 // UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11854 cachedresp.WearableData[i].HostName = new byte[0];
11855 }
11754 } 11856 }
11755 } 11857 }
11756 cachedresp.Header.Zerocoded = true; 11858 cachedresp.Header.Zerocoded = true;
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 3080023..27cf204 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -205,10 +205,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
205// ((ScenePresence)sp).SetSize(box,off); 205// ((ScenePresence)sp).SetSize(box,off);
206 206
207 } 207 }
208 //if (cacheItems.Length > 0) 208
209 //{
210 sp.Appearance.WearableCacheItems = cacheItems;
211 //}
212 // Process the baked texture array 209 // Process the baked texture array
213 if (textureEntry != null) 210 if (textureEntry != null)
214 { 211 {
@@ -284,8 +281,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
284 public WearableCacheItem[] GetCachedItems(UUID agentId) 281 public WearableCacheItem[] GetCachedItems(UUID agentId)
285 { 282 {
286 ScenePresence sp = m_scene.GetScenePresence(agentId); 283 ScenePresence sp = m_scene.GetScenePresence(agentId);
287 Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = GetBakedTextureFaces(sp);
288
289 WearableCacheItem[] items = sp.Appearance.WearableCacheItems; 284 WearableCacheItem[] items = sp.Appearance.WearableCacheItems;
290 //foreach (WearableCacheItem item in items) 285 //foreach (WearableCacheItem item in items)
291 //{ 286 //{
diff --git a/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs
index d63898a..21ed44f 100644
--- a/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs
@@ -13,7 +13,7 @@ namespace OpenSim.Services.Interfaces
13{ 13{
14 public interface IBakedTextureModule 14 public interface IBakedTextureModule
15 { 15 {
16 AssetBase[] Get(UUID id); 16 WearableCacheItem[] Get(UUID id);
17 void Store(UUID id, AssetBase[] data); 17 void Store(UUID id, WearableCacheItem[] data);
18 } 18 }
19} 19}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 54e3b2d..a5ef2b7 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2982,6 +2982,7 @@ namespace OpenSim.Region.Framework.Scenes
2982 // start the scripts again (since this is done in RezAttachments()). 2982 // start the scripts again (since this is done in RezAttachments()).
2983 // XXX: This is convoluted. 2983 // XXX: This is convoluted.
2984 sp.IsChildAgent = false; 2984 sp.IsChildAgent = false;
2985 sp.IsLoggingIn = true;
2985 2986
2986 if (AttachmentsModule != null) 2987 if (AttachmentsModule != null)
2987 Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); 2988 Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); });
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index e68793a..2a0d2ea 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -144,7 +144,7 @@ namespace OpenSim.Region.Framework.Scenes
144 /// </remarks> 144 /// </remarks>
145 public bool IsRoot 145 public bool IsRoot
146 { 146 {
147 get { return ParentGroup.RootPart == this; } 147 get { return Object.ReferenceEquals(ParentGroup.RootPart, this); }
148 } 148 }
149 149
150 /// <summary> 150 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index b9cd3fc..1d6898b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -225,8 +225,6 @@ namespace OpenSim.Region.Framework.Scenes
225 /// </summary> 225 /// </summary>
226 public bool LandAtTarget { get; private set; } 226 public bool LandAtTarget { get; private set; }
227 227
228 private bool m_followCamAuto;
229
230 private int m_movementUpdateCount; 228 private int m_movementUpdateCount;
231 private const int NumMovementsBetweenRayCast = 5; 229 private const int NumMovementsBetweenRayCast = 5;
232 230
@@ -355,6 +353,9 @@ namespace OpenSim.Region.Framework.Scenes
355 /// </summary> 353 /// </summary>
356 protected Vector3 m_lastCameraPosition; 354 protected Vector3 m_lastCameraPosition;
357 355
356 private Vector4 m_lastCameraCollisionPlane = new Vector4(0f, 0f, 0f, 1);
357 private bool m_doingCamRayCast = false;
358
358 public Vector3 CameraPosition { get; set; } 359 public Vector3 CameraPosition { get; set; }
359 360
360 public Quaternion CameraRotation 361 public Quaternion CameraRotation
@@ -604,6 +605,7 @@ namespace OpenSim.Region.Framework.Scenes
604 } 605 }
605 606
606 public bool IsChildAgent { get; set; } 607 public bool IsChildAgent { get; set; }
608 public bool IsLoggingIn { get; set; }
607 609
608 /// <summary> 610 /// <summary>
609 /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. 611 /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero.
@@ -740,6 +742,7 @@ namespace OpenSim.Region.Framework.Scenes
740 AttachmentsSyncLock = new Object(); 742 AttachmentsSyncLock = new Object();
741 AllowMovement = true; 743 AllowMovement = true;
742 IsChildAgent = true; 744 IsChildAgent = true;
745 IsLoggingIn = false;
743 m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; 746 m_sendCoarseLocationsMethod = SendCoarseLocationsDefault;
744 Animator = new ScenePresenceAnimator(this); 747 Animator = new ScenePresenceAnimator(this);
745 PresenceType = type; 748 PresenceType = type;
@@ -912,6 +915,7 @@ namespace OpenSim.Region.Framework.Scenes
912 else 915 else
913 { 916 {
914 IsChildAgent = false; 917 IsChildAgent = false;
918 IsLoggingIn = false;
915 } 919 }
916 920
917 921
@@ -1405,35 +1409,43 @@ namespace OpenSim.Region.Framework.Scenes
1405 /// <param name="collisionPoint"></param> 1409 /// <param name="collisionPoint"></param>
1406 /// <param name="localid"></param> 1410 /// <param name="localid"></param>
1407 /// <param name="distance"></param> 1411 /// <param name="distance"></param>
1412 ///
1413
1414 private void UpdateCameraCollisionPlane(Vector4 plane)
1415 {
1416 if (m_lastCameraCollisionPlane != plane)
1417 {
1418 m_lastCameraCollisionPlane = plane;
1419 ControllingClient.SendCameraConstraint(plane);
1420 }
1421 }
1422
1408 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) 1423 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal)
1409 { 1424 {
1410 const float POSITION_TOLERANCE = 0.02f; 1425 const float POSITION_TOLERANCE = 0.02f;
1411 const float VELOCITY_TOLERANCE = 0.02f;
1412 const float ROTATION_TOLERANCE = 0.02f; 1426 const float ROTATION_TOLERANCE = 0.02f;
1413 1427
1414 if (m_followCamAuto) 1428 m_doingCamRayCast = false;
1429 if (hitYN && localid != LocalId)
1415 { 1430 {
1416 if (hitYN) 1431 CameraConstraintActive = true;
1417 { 1432 pNormal.X = (float)Math.Round(pNormal.X, 2);
1418 CameraConstraintActive = true; 1433 pNormal.Y = (float)Math.Round(pNormal.Y, 2);
1419 //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); 1434 pNormal.Z = (float)Math.Round(pNormal.Z, 2);
1420 1435 pNormal.Normalize();
1421 Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); 1436 collisionPoint.X = (float)Math.Round(collisionPoint.X, 1);
1422 ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); 1437 collisionPoint.Y = (float)Math.Round(collisionPoint.Y, 1);
1423 } 1438 collisionPoint.Z = (float)Math.Round(collisionPoint.Z, 1);
1424 else 1439
1425 { 1440 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, Vector3.Dot(collisionPoint, pNormal));
1426 if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || 1441 UpdateCameraCollisionPlane(plane);
1427 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || 1442 }
1428 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) 1443 else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
1429 { 1444 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE))
1430 if (CameraConstraintActive) 1445 {
1431 { 1446 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right...
1432 ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); 1447 UpdateCameraCollisionPlane(plane);
1433 CameraConstraintActive = false; 1448 CameraConstraintActive = false;
1434 }
1435 }
1436 }
1437 } 1449 }
1438 } 1450 }
1439 1451
@@ -1508,12 +1520,6 @@ namespace OpenSim.Region.Framework.Scenes
1508 // DrawDistance = agentData.Far; 1520 // DrawDistance = agentData.Far;
1509 DrawDistance = Scene.DefaultDrawDistance; 1521 DrawDistance = Scene.DefaultDrawDistance;
1510 1522
1511 // Check if Client has camera in 'follow cam' or 'build' mode.
1512 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
1513
1514 m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f)
1515 && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
1516
1517 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; 1523 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
1518 m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; 1524 m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
1519 1525
@@ -1533,24 +1539,38 @@ namespace OpenSim.Region.Framework.Scenes
1533 StandUp(); 1539 StandUp();
1534 } 1540 }
1535 1541
1536 //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto);
1537 // Raycast from the avatar's head to the camera to see if there's anything blocking the view 1542 // Raycast from the avatar's head to the camera to see if there's anything blocking the view
1538 if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) 1543 // this exclude checks may not be complete
1544
1545 if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast())
1539 { 1546 {
1540 if (m_followCamAuto) 1547 if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0)
1541 { 1548 {
1542 // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; 1549 Vector3 posAdjusted = AbsolutePosition;
1543 // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); 1550// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f;
1544 1551 posAdjusted.Z += 1.0f; // viewer current camera focus point
1545 Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; 1552 Vector3 tocam = CameraPosition - posAdjusted;
1546 Vector3 distTocam = CameraPosition - posAdjusted; 1553 tocam.X = (float)Math.Round(tocam.X, 1);
1547 float distTocamlen = distTocam.Length(); 1554 tocam.Y = (float)Math.Round(tocam.Y, 1);
1548 if (distTocamlen > 0) 1555 tocam.Z = (float)Math.Round(tocam.Z, 1);
1556
1557 float distTocamlen = tocam.Length();
1558 if (distTocamlen > 0.3f)
1549 { 1559 {
1550 distTocam *= 1.0f / distTocamlen; 1560 tocam *= (1.0f / distTocamlen);
1551 m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); 1561 posAdjusted.X = (float)Math.Round(posAdjusted.X, 1);
1562 posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1);
1563 posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1);
1564
1565 m_doingCamRayCast = true;
1566 m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback);
1552 } 1567 }
1553 1568 }
1569 else if (CameraConstraintActive && (m_mouseLook || ParentID != 0))
1570 {
1571 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right...
1572 UpdateCameraCollisionPlane(plane);
1573 CameraConstraintActive = false;
1554 } 1574 }
1555 } 1575 }
1556 1576
@@ -2265,7 +2285,6 @@ namespace OpenSim.Region.Framework.Scenes
2265 ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot"); 2285 ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot");
2266 return; 2286 return;
2267 } 2287 }
2268// m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString());
2269 2288
2270 RemoveFromPhysicalScene(); 2289 RemoveFromPhysicalScene();
2271 2290
@@ -2276,7 +2295,6 @@ namespace OpenSim.Region.Framework.Scenes
2276 2295
2277 part.AddSittingAvatar(UUID); 2296 part.AddSittingAvatar(UUID);
2278 2297
2279
2280 Vector3 cameraAtOffset = part.GetCameraAtOffset(); 2298 Vector3 cameraAtOffset = part.GetCameraAtOffset();
2281 Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); 2299 Vector3 cameraEyeOffset = part.GetCameraEyeOffset();
2282 bool forceMouselook = part.GetForceMouselook(); 2300 bool forceMouselook = part.GetForceMouselook();
@@ -2502,20 +2520,12 @@ namespace OpenSim.Region.Framework.Scenes
2502 // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to 2520 // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to
2503 // grab the latest PhysicsActor velocity, whereas m_velocity is often 2521 // grab the latest PhysicsActor velocity, whereas m_velocity is often
2504 // storing a requested force instead of an actual traveling velocity 2522 // storing a requested force instead of an actual traveling velocity
2505 if (Appearance.AvatarSize != m_lastSize) 2523 if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn)
2506 {
2507 m_lastSize = Appearance.AvatarSize;
2508 SendAvatarDataToAllAgents(); 2524 SendAvatarDataToAllAgents();
2509 }
2510 // Throw away duplicate or insignificant updates
2511 else if (
2512 // If the velocity has become zero, send it no matter what.
2513 (Velocity != m_lastVelocity && Velocity == Vector3.Zero)
2514 // otherwise, if things have changed reasonably, send the update
2515 || (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)
2516 || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE)
2517 || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)))
2518 2525
2526 if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
2527 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
2528 !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))
2519 { 2529 {
2520 SendTerseUpdateToAllClients(); 2530 SendTerseUpdateToAllClients();
2521 2531
@@ -2704,6 +2714,8 @@ namespace OpenSim.Region.Framework.Scenes
2704 return; 2714 return;
2705 } 2715 }
2706 2716
2717 m_lastSize = Appearance.AvatarSize;
2718
2707 int count = 0; 2719 int count = 0;
2708 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2720 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2709 { 2721 {
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
index 6e9281b..7fe3109 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
@@ -173,8 +173,13 @@ namespace OpenSim.Region.Physics.OdePlugin
173 d.GeomRaySetClosestHit(ray, closestHit); 173 d.GeomRaySetClosestHit(ray, closestHit);
174 174
175 if (req.callbackMethod is RaycastCallback) 175 if (req.callbackMethod is RaycastCallback)
176 {
176 // if we only want one get only one per Collision pair saving memory 177 // if we only want one get only one per Collision pair saving memory
177 CurrentRayFilter |= RayFilterFlags.ClosestHit; 178 CurrentRayFilter |= RayFilterFlags.ClosestHit;
179 d.GeomRaySetClosestHit(ray, 1);
180 }
181 else
182 d.GeomRaySetClosestHit(ray, closestHit);
178 } 183 }
179 184
180 if ((CurrentRayFilter & RayFilterFlags.ContactsUnImportant) != 0) 185 if ((CurrentRayFilter & RayFilterFlags.ContactsUnImportant) != 0)
@@ -555,10 +560,13 @@ namespace OpenSim.Region.Physics.OdePlugin
555 560
556 ContactResult collisionresult = new ContactResult(); 561 ContactResult collisionresult = new ContactResult();
557 collisionresult.ConsumerID = ID; 562 collisionresult.ConsumerID = ID;
558 collisionresult.Pos = new Vector3(curcontact.pos.X, curcontact.pos.Y, curcontact.pos.Z); 563 collisionresult.Pos.X = curcontact.pos.X;
564 collisionresult.Pos.Y = curcontact.pos.Y;
565 collisionresult.Pos.Z = curcontact.pos.Z;
559 collisionresult.Depth = curcontact.depth; 566 collisionresult.Depth = curcontact.depth;
560 collisionresult.Normal = new Vector3(curcontact.normal.X, curcontact.normal.Y, 567 collisionresult.Normal.X = curcontact.normal.X;
561 curcontact.normal.Z); 568 collisionresult.Normal.Y = curcontact.normal.Y;
569 collisionresult.Normal.Z = curcontact.normal.Z;
562 lock (m_contactResults) 570 lock (m_contactResults)
563 { 571 {
564 m_contactResults.Add(collisionresult); 572 m_contactResults.Add(collisionresult);
@@ -581,10 +589,13 @@ namespace OpenSim.Region.Physics.OdePlugin
581 589
582 if (curcontact.depth < collisionresult.Depth) 590 if (curcontact.depth < collisionresult.Depth)
583 { 591 {
584 collisionresult.Pos = new Vector3(curcontact.pos.X, curcontact.pos.Y, curcontact.pos.Z); 592 collisionresult.Pos.X = curcontact.pos.X;
593 collisionresult.Pos.Y = curcontact.pos.Y;
594 collisionresult.Pos.Z = curcontact.pos.Z;
585 collisionresult.Depth = curcontact.depth; 595 collisionresult.Depth = curcontact.depth;
586 collisionresult.Normal = new Vector3(curcontact.normal.X, curcontact.normal.Y, 596 collisionresult.Normal.X = curcontact.normal.X;
587 curcontact.normal.Z); 597 collisionresult.Normal.Y = curcontact.normal.Y;
598 collisionresult.Normal.Z = curcontact.normal.Z;
588 } 599 }
589 } 600 }
590 601
@@ -699,10 +710,13 @@ namespace OpenSim.Region.Physics.OdePlugin
699 710
700 ContactResult collisionresult = new ContactResult(); 711 ContactResult collisionresult = new ContactResult();
701 collisionresult.ConsumerID = ID; 712 collisionresult.ConsumerID = ID;
702 collisionresult.Pos = new Vector3(curcontact.pos.X, curcontact.pos.Y, curcontact.pos.Z); 713 collisionresult.Pos.X = curcontact.pos.X;
714 collisionresult.Pos.Y = curcontact.pos.Y;
715 collisionresult.Pos.Z = curcontact.pos.Z;
703 collisionresult.Depth = curcontact.depth; 716 collisionresult.Depth = curcontact.depth;
704 collisionresult.Normal = new Vector3(curcontact.normal.X, curcontact.normal.Y, 717 collisionresult.Normal.X = curcontact.normal.X;
705 curcontact.normal.Z); 718 collisionresult.Normal.Y = curcontact.normal.Y;
719 collisionresult.Normal.Z = curcontact.normal.Z;
706 lock (m_contactResults) 720 lock (m_contactResults)
707 { 721 {
708 m_contactResults.Add(collisionresult); 722 m_contactResults.Add(collisionresult);
@@ -725,10 +739,13 @@ namespace OpenSim.Region.Physics.OdePlugin
725 739
726 if (curcontact.depth < collisionresult.Depth) 740 if (curcontact.depth < collisionresult.Depth)
727 { 741 {
728 collisionresult.Pos = new Vector3(curcontact.pos.X, curcontact.pos.Y, curcontact.pos.Z); 742 collisionresult.Pos.X = curcontact.pos.X;
743 collisionresult.Pos.Y = curcontact.pos.Y;
744 collisionresult.Pos.Z = curcontact.pos.Z;
729 collisionresult.Depth = curcontact.depth; 745 collisionresult.Depth = curcontact.depth;
730 collisionresult.Normal = new Vector3(curcontact.normal.X, curcontact.normal.Y, 746 collisionresult.Normal.X = curcontact.normal.X;
731 curcontact.normal.Z); 747 collisionresult.Normal.Y = curcontact.normal.Y;
748 collisionresult.Normal.Z = curcontact.normal.Z;
732 } 749 }
733 } 750 }
734 751
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs
index ecc732a..e9023c3 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs
@@ -78,8 +78,12 @@ namespace OpenSim.Region.Physics.OdePlugin
78 78
79 IntPtr geom = ((OdePrim)actor).prim_geom; 79 IntPtr geom = ((OdePrim)actor).prim_geom;
80 80
81 Vector3 geopos = d.GeomGetPositionOMV(geom); 81// Vector3 geopos = d.GeomGetPositionOMV(geom);
82 Quaternion geomOri = d.GeomGetQuaternionOMV(geom); 82// Quaternion geomOri = d.GeomGetQuaternionOMV(geom);
83
84 Vector3 geopos = actor.Position;
85 Quaternion geomOri = actor.Orientation;
86
83 Quaternion geomInvOri = Quaternion.Conjugate(geomOri); 87 Quaternion geomInvOri = Quaternion.Conjugate(geomOri);
84 88
85 Quaternion ori = Quaternion.Identity; 89 Quaternion ori = Quaternion.Identity;
@@ -116,6 +120,7 @@ namespace OpenSim.Region.Physics.OdePlugin
116 } 120 }
117 121
118 int status = 1; 122 int status = 1;
123
119 offset = rayResults[0].Pos - geopos; 124 offset = rayResults[0].Pos - geopos;
120 125
121 d.GeomClassID geoclass = d.GeomGetClass(geom); 126 d.GeomClassID geoclass = d.GeomGetClass(geom);
@@ -191,13 +196,12 @@ namespace OpenSim.Region.Physics.OdePlugin
191 if (norm.Z < 0.5f) 196 if (norm.Z < 0.5f)
192 { 197 {
193 float rayDist = 4.0f; 198 float rayDist = 4.0f;
194 float curEdgeDist = 0.0f;
195 199
196 for (int i = 0; i < 6; i++) 200 for (int i = 0; i < 6; i++)
197 { 201 {
198 pivot.X -= 0.005f * norm.X; 202 pivot.X -= 0.01f * norm.X;
199 pivot.Y -= 0.005f * norm.Y; 203 pivot.Y -= 0.01f * norm.Y;
200 pivot.Z -= 0.005f * norm.Z; 204 pivot.Z -= 0.01f * norm.Z;
201 205
202 rayDir.X = -norm.X * norm.Z; 206 rayDir.X = -norm.X * norm.Z;
203 rayDir.Y = -norm.Y * norm.Z; 207 rayDir.Y = -norm.Y * norm.Z;
@@ -208,8 +212,6 @@ namespace OpenSim.Region.Physics.OdePlugin
208 if (rayResults.Count == 0) 212 if (rayResults.Count == 0)
209 break; 213 break;
210 214
211 curEdgeDist += rayResults[0].Depth;
212
213 if (Math.Abs(rayResults[0].Normal.Z) < 0.7f) 215 if (Math.Abs(rayResults[0].Normal.Z) < 0.7f)
214 { 216 {
215 rayDist -= rayResults[0].Depth; 217 rayDist -= rayResults[0].Depth;
@@ -226,7 +228,6 @@ namespace OpenSim.Region.Physics.OdePlugin
226 else 228 else
227 { 229 {
228 foundEdge = true; 230 foundEdge = true;
229 edgeDist = curEdgeDist;
230 edgePos = rayResults[0].Pos; 231 edgePos = rayResults[0].Pos;
231 break; 232 break;
232 } 233 }
@@ -254,7 +255,7 @@ namespace OpenSim.Region.Physics.OdePlugin
254 255
255 for (int i = 0; i < 3; i++) 256 for (int i = 0; i < 3; i++)
256 { 257 {
257 pivot.Z -= 0.005f; 258 pivot.Z -= 0.01f;
258 rayDir.X = toCamX; 259 rayDir.X = toCamX;
259 rayDir.Y = toCamY; 260 rayDir.Y = toCamY;
260 rayDir.Z = (-toCamX * norm.X - toCamY * norm.Y) / norm.Z; 261 rayDir.Z = (-toCamX * norm.X - toCamY * norm.Y) / norm.Z;
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index d045b59..0d18adb 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -2586,7 +2586,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2586 req.Normal = direction; 2586 req.Normal = direction;
2587 req.Origin = position; 2587 req.Origin = position;
2588 req.Count = 0; 2588 req.Count = 0;
2589 req.filter = RayFilterFlags.All; 2589 req.filter = RayFilterFlags.AllPrims;
2590 2590
2591 m_rayCastManager.QueueRequest(req); 2591 m_rayCastManager.QueueRequest(req);
2592 } 2592 }
@@ -2603,7 +2603,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2603 req.Normal = direction; 2603 req.Normal = direction;
2604 req.Origin = position; 2604 req.Origin = position;
2605 req.Count = Count; 2605 req.Count = Count;
2606 req.filter = RayFilterFlags.All; 2606 req.filter = RayFilterFlags.AllPrims;
2607 2607
2608 m_rayCastManager.QueueRequest(req); 2608 m_rayCastManager.QueueRequest(req);
2609 } 2609 }
@@ -2631,7 +2631,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2631 req.Normal = direction; 2631 req.Normal = direction;
2632 req.Origin = position; 2632 req.Origin = position;
2633 req.Count = Count; 2633 req.Count = Count;
2634 req.filter = RayFilterFlags.All; 2634 req.filter = RayFilterFlags.AllPrims;
2635 2635
2636 lock (SyncObject) 2636 lock (SyncObject)
2637 { 2637 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index aa389ba..9ae9b59 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2359,8 +2359,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2359 { 2359 {
2360 m_host.AddScriptLPS(1); 2360 m_host.AddScriptLPS(1);
2361 2361
2362
2363 // Teravus: if (m_host.ParentID == 0) is bug code because the ParentID for the Avatar will cause this to be nonzero for root prim attachments
2364 // which is then treated like a child prim rotation and it's offset gets cumulatively multiplied against.
2365 // to fix the scripted rotations we also have to check to see if the root part localid is the same as the host's localid.
2366 // RootPart != null should shortcircuit
2367
2362 // try to let this work as in SL... 2368 // try to let this work as in SL...
2363 if (m_host.ParentID == 0) 2369 if (m_host.ParentID == 0 || (m_host.ParentGroup != null && m_host == m_host.ParentGroup.RootPart))
2364 { 2370 {
2365 // special case: If we are root, rotate complete SOG to new rotation 2371 // special case: If we are root, rotate complete SOG to new rotation
2366 SetRot(m_host, rot); 2372 SetRot(m_host, rot);
@@ -2443,6 +2449,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2443 2449
2444 m_host.AddScriptLPS(1); 2450 m_host.AddScriptLPS(1);
2445 Quaternion q = m_host.GetWorldRotation(); 2451 Quaternion q = m_host.GetWorldRotation();
2452
2453 if (m_host.ParentGroup != null && m_host.ParentGroup.AttachmentPoint != 0)
2454 {
2455 ScenePresence avatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar);
2456 if (avatar != null)
2457 {
2458 if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0)
2459 q = avatar.CameraRotation * q; // Mouselook
2460 else
2461 q = avatar.Rotation * q; // Currently infrequently updated so may be inaccurate
2462 }
2463 }
2464
2446 return new LSL_Rotation(q.X, q.Y, q.Z, q.W); 2465 return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
2447 } 2466 }
2448 2467
@@ -2468,7 +2487,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2468 q = part.ParentGroup.GroupRotation; // just the group rotation 2487 q = part.ParentGroup.GroupRotation; // just the group rotation
2469 return new LSL_Rotation(q.X, q.Y, q.Z, q.W); 2488 return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
2470 } 2489 }
2490
2471 q = part.GetWorldRotation(); 2491 q = part.GetWorldRotation();
2492 if (part.ParentGroup.AttachmentPoint != 0)
2493 {
2494 ScenePresence avatar = World.GetScenePresence(part.ParentGroup.AttachedAvatar);
2495 if (avatar != null)
2496 {
2497 if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0)
2498 q = avatar.CameraRotation * q; // Mouselook
2499 else
2500 q = avatar.Rotation * q; // Currently infrequently updated so may be inaccurate
2501 }
2502 }
2503
2472 return new LSL_Rotation(q.X, q.Y, q.Z, q.W); 2504 return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
2473 } 2505 }
2474 2506
@@ -7909,7 +7941,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7909 7941
7910 LSL_Rotation q = rules.GetQuaternionItem(idx++); 7942 LSL_Rotation q = rules.GetQuaternionItem(idx++);
7911 // try to let this work as in SL... 7943 // try to let this work as in SL...
7912 if (part.ParentID == 0) 7944 if (part.ParentID == 0 || (part.ParentGroup != null && part == part.ParentGroup.RootPart))
7913 { 7945 {
7914 // special case: If we are root, rotate complete SOG to new rotation 7946 // special case: If we are root, rotate complete SOG to new rotation
7915 SetRot(part, q); 7947 SetRot(part, q);
@@ -8701,7 +8733,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8701 8733
8702 LSL_List remaining = GetPrimParams(m_host, rules, ref result); 8734 LSL_List remaining = GetPrimParams(m_host, rules, ref result);
8703 8735
8704 while (remaining != null && remaining.Length > 2) 8736 while ((object)remaining != null && remaining.Length > 2)
8705 { 8737 {
8706 int linknumber = remaining.GetLSLIntegerItem(0); 8738 int linknumber = remaining.GetLSLIntegerItem(0);
8707 rules = remaining.GetSublist(1, -1); 8739 rules = remaining.GetSublist(1, -1);
@@ -8742,11 +8774,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8742 remaining = GetPrimParams(avatar, rules, ref res); 8774 remaining = GetPrimParams(avatar, rules, ref res);
8743 } 8775 }
8744 8776
8745 if (remaining != null && remaining.Length > 0) 8777 if ((object)remaining != null && remaining.Length > 0)
8746 { 8778 {
8747 linknumber = remaining.GetLSLIntegerItem(0); 8779 linknumber = remaining.GetLSLIntegerItem(0);
8748 rules = remaining.GetSublist(1, -1); 8780 rules = remaining.GetSublist(1, -1);
8749 } 8781 }
8782 else
8783 break;
8750 } 8784 }
8751 8785
8752 return res; 8786 return res;