aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authordahlia2014-01-20 13:57:14 -0800
committerdahlia2014-01-20 13:57:14 -0800
commitaf58631f00b95081dc99f4f75e8ec6b031b8cf2a (patch)
tree4a09f4203a1efba27635f055de39b789a6bb4dd1 /OpenSim
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-af58631f00b95081dc99f4f75e8ec6b031b8cf2a.zip
opensim-SC-af58631f00b95081dc99f4f75e8ec6b031b8cf2a.tar.gz
opensim-SC-af58631f00b95081dc99f4f75e8ec6b031b8cf2a.tar.bz2
opensim-SC-af58631f00b95081dc99f4f75e8ec6b031b8cf2a.tar.xz
rather than converting existing materials to assets, just retrieve them and make them available for viewing. Any new materials added to the scene will become assets.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs44
1 files changed, 12 insertions, 32 deletions
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
index c4bc8a0..afb788b 100644
--- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
+++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
@@ -149,12 +149,10 @@ namespace OpenSim.Region.OptionalModules.Materials
149 } 149 }
150 150
151 /// <summary> 151 /// <summary>
152 /// Searches the part for any legacy materials stored in DynAttrs and converts them to assets, replacing 152 /// Finds any legacy materials stored in DynAttrs that may exist for this part and add them to 'm_regionMaterials'.
153 /// the MaterialIDs in the TextureEntries for the part.
154 /// Deletes the legacy materials from the part as they are no longer needed.
155 /// </summary> 153 /// </summary>
156 /// <param name="part"></param> 154 /// <param name="part"></param>
157 private void ConvertLegacyMaterialsInPart(SceneObjectPart part) 155 private void GetLegacyStoredMaterialsInPart(SceneObjectPart part)
158 { 156 {
159 if (part.DynAttrs == null) 157 if (part.DynAttrs == null)
160 return; 158 return;
@@ -183,10 +181,6 @@ namespace OpenSim.Region.OptionalModules.Materials
183 if (matsArr == null) 181 if (matsArr == null)
184 return; 182 return;
185 183
186 var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length);
187 if (te == null)
188 return;
189
190 foreach (OSD elemOsd in matsArr) 184 foreach (OSD elemOsd in matsArr)
191 { 185 {
192 if (elemOsd != null && elemOsd is OSDMap) 186 if (elemOsd != null && elemOsd is OSDMap)
@@ -194,32 +188,18 @@ namespace OpenSim.Region.OptionalModules.Materials
194 OSDMap matMap = elemOsd as OSDMap; 188 OSDMap matMap = elemOsd as OSDMap;
195 if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) 189 if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material"))
196 { 190 {
197 UUID id = matMap["ID"].AsUUID(); 191 try
198 OSDMap material = (OSDMap)matMap["Material"]; 192 {
199 bool used = false; 193 lock (m_regionMaterials)
200 194 m_regionMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"];
201 foreach (var face in te.FaceTextures) 195 }
202 if (face != null && face.MaterialID == id) 196 catch (Exception e)
203 used = true; 197 {
204 198 m_log.Warn("[Materials]: exception decoding persisted legacy material: " + e.ToString());
205 if (used)
206 { // store legacy material in new asset format, and update the part texture entry with the new hashed UUID
207
208 var newId = StoreMaterialAsAsset(part.CreatorID, material, part);
209 foreach (var face in te.FaceTextures)
210 if (face != null && face.MaterialID == id)
211 face.MaterialID = newId;
212 } 199 }
213 } 200 }
214 } 201 }
215 } 202 }
216
217 part.Shape.TextureEntry = te.GetBytes();
218 part.ParentGroup.HasGroupChanged = true;
219 part.ScheduleFullUpdate();
220
221 lock (part.DynAttrs)
222 part.DynAttrs.RemoveStore("OpenSim", "Materials");
223 } 203 }
224 204
225 /// <summary> 205 /// <summary>
@@ -230,12 +210,12 @@ namespace OpenSim.Region.OptionalModules.Materials
230 if (part.Shape == null) 210 if (part.Shape == null)
231 return; 211 return;
232 212
233 ConvertLegacyMaterialsInPart(part);
234
235 var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length); 213 var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length);
236 if (te == null) 214 if (te == null)
237 return; 215 return;
238 216
217 GetLegacyStoredMaterialsInPart(part);
218
239 GetStoredMaterialInFace(part, te.DefaultTexture); 219 GetStoredMaterialInFace(part, te.DefaultTexture);
240 220
241 foreach (Primitive.TextureEntryFace face in te.FaceTextures) 221 foreach (Primitive.TextureEntryFace face in te.FaceTextures)