Browse Source

a few more changes to texturesentry handling on libomv and os

UbitUmarov 5 years ago
parent
commit
8bb644159e

+ 2 - 0
OpenSim/Framework/MapAndArray.cs

@@ -173,6 +173,8 @@ namespace OpenSim.Framework
             {
                 if (m_array == null)
                 {
+                    if(m_dict.Count == 0)
+                        return new TValue[0];
                     m_array = new TValue[m_dict.Count];
                     m_dict.Values.CopyTo(m_array, 0);
                 }

+ 38 - 26
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs

@@ -248,11 +248,7 @@ namespace OpenSim.Region.Framework.Scenes
 
         public scriptEvents AggregateScriptEvents;
 
-        public Vector3 AttachedPos
-        {
-            get;
-            set;
-        }
+        public Vector3 AttachedPos  { get; set; }
 
         // rotation locks on local X,Y and or Z axis bit flags
         // bits are as in llSetStatus defined in SceneObjectGroup.axisSelect enum
@@ -955,13 +951,6 @@ namespace OpenSim.Region.Framework.Scenes
                         m_log.Error("[SCENEOBJECTPART]: ROTATIONOFFSET" + ex.Message);
                     }
                 }
-
-//                float roll, pitch, yaw = 0;
-//                m_rotationOffset.GetEulerAngles(out roll, out pitch, out yaw);
-//
-//                m_log.DebugFormat(
-//                    "[SCENE OBJECT PART]: Set euler {0} for RotationOffset on {1} {2}",
-//                    new Vector3(roll, pitch, yaw), Name, LocalId);
             }
         }
 
@@ -2266,7 +2255,8 @@ namespace OpenSim.Region.Framework.Scenes
             dupe.KeyframeMotion = null;
             dupe.PayPrice = (int[])PayPrice.Clone();
 
-            dupe.DynAttrs.CopyFrom(DynAttrs);
+            if(DynAttrs != null)
+                dupe.DynAttrs.CopyFrom(DynAttrs);
 
             if (userExposed)
             {
@@ -3834,7 +3824,7 @@ namespace OpenSim.Region.Framework.Scenes
                     texcolor.A = clippedAlpha;
                 }
                 tex.FaceTextures[face].RGBA = texcolor;
-                UpdateTextureEntry(tex.GetBytes());
+                UpdateTextureEntry(tex);
                 return;
             }
             else if (face == ALL_SIDES)
@@ -3863,7 +3853,7 @@ namespace OpenSim.Region.Framework.Scenes
                     }
                     tex.DefaultTexture.RGBA = texcolor;
                 }
-                UpdateTextureEntry(tex.GetBytes());
+                UpdateTextureEntry(tex);
                 return;
             }
         }
@@ -5178,15 +5168,7 @@ namespace OpenSim.Region.Framework.Scenes
         /// <param name="serializedTextureEntry"></param>
         public void UpdateTextureEntry(byte[] serializedTextureEntry)
         {
-            UpdateTextureEntry(new Primitive.TextureEntry(serializedTextureEntry, 0, serializedTextureEntry.Length));
-        }
-
-        /// <summary>
-        /// Update the texture entry for this part.
-        /// </summary>
-        /// <param name="newTex"></param>
-        public void UpdateTextureEntry(Primitive.TextureEntry newTex)
-        {
+            Primitive.TextureEntry newTex = new Primitive.TextureEntry(serializedTextureEntry, 0, serializedTextureEntry.Length);
             Primitive.TextureEntry oldTex = Shape.Textures;
 
             Changed changeFlags = 0;
@@ -5215,7 +5197,7 @@ namespace OpenSim.Region.Framework.Scenes
 
             bool otherFieldsChanged = false;
             int nsides = GetNumberOfSides();
-            for (int i = 0 ; i < nsides; i++)
+            for (int i = 0; i < nsides; i++)
             {
                 Primitive.TextureEntryFace newFace = defaultNewFace;
                 Primitive.TextureEntryFace oldFace = defaultOldFace;
@@ -5253,7 +5235,7 @@ namespace OpenSim.Region.Framework.Scenes
                     if (oldFace.Rotation != newFace.Rotation) otherFieldsChanged = true;
                     if (oldFace.Shiny != newFace.Shiny) otherFieldsChanged = true;
                     if (oldFace.TexMapType != newFace.TexMapType) otherFieldsChanged = true;
-                    if(otherFieldsChanged)
+                    if (otherFieldsChanged)
                         changeFlags |= Changed.TEXTURE;
                 }
             }
@@ -5264,6 +5246,36 @@ namespace OpenSim.Region.Framework.Scenes
             TriggerScriptChangedEvent(changeFlags);
             ParentGroup.HasGroupChanged = true;
             ScheduleFullUpdate();
+
+        }
+
+        /// <summary>
+        /// Update the texture entry for this part.
+        /// </summary>
+        /// <param name="newTex"></param>
+        public void UpdateTextureEntry(Primitive.TextureEntry newTex)
+        {
+            TextureAttributes dirty = newTex.GetDirtyFlags(32, true);
+            dirty &= ~TextureAttributes.MaterialID;
+            if(dirty == TextureAttributes.None)
+                return;
+
+            Changed changeFlags = 0;
+            if((dirty & TextureAttributes.RGBA) != 0)
+            {
+                changeFlags = Changed.COLOR;
+                dirty &= ~TextureAttributes.RGBA;
+            }
+            if (dirty != TextureAttributes.None)
+                changeFlags |= Changed.TEXTURE;
+
+            if (changeFlags == 0)
+                return;
+
+            m_shape.TextureEntry = newTex.GetBytes();
+            TriggerScriptChangedEvent(changeFlags);
+            ParentGroup.HasGroupChanged = true;
+            ScheduleFullUpdate();
         }
 
         internal void UpdatePhysicsSubscribedEvents()

+ 56 - 33
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs

@@ -1947,7 +1947,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
                 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
                 tex.FaceTextures[face].RGBA = texcolor;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
             else if (face == ScriptBaseClass.ALL_SIDES)
@@ -1968,7 +1968,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                     texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
                     tex.DefaultTexture.RGBA = texcolor;
                 }
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
 
@@ -2069,7 +2069,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             {
                 tex.CreateFace((uint) face);
                 tex.FaceTextures[face].TexMapType = textype;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
             else if (face == ScriptBaseClass.ALL_SIDES)
@@ -2080,9 +2080,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                     {
                         tex.FaceTextures[i].TexMapType = textype;
                     }
-                    tex.DefaultTexture.TexMapType = textype;
                 }
-                part.UpdateTextureEntry(tex.GetBytes());
+                tex.DefaultTexture.TexMapType = textype;
+                part.UpdateTextureEntry(tex);
                 return;
             }
         }
@@ -2099,7 +2099,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             {
                 tex.CreateFace((uint) face);
                 tex.FaceTextures[face].Glow = glow;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
             else if (face == ScriptBaseClass.ALL_SIDES)
@@ -2110,9 +2110,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                     {
                         tex.FaceTextures[i].Glow = glow;
                     }
-                    tex.DefaultTexture.Glow = glow;
                 }
-                part.UpdateTextureEntry(tex.GetBytes());
+                tex.DefaultTexture.Glow = glow;
+                part.UpdateTextureEntry(tex);
                 return;
             }
         }
@@ -2151,7 +2151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 tex.CreateFace((uint) face);
                 tex.FaceTextures[face].Shiny = sval;
                 tex.FaceTextures[face].Bump = bump;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
             else if (face == ScriptBaseClass.ALL_SIDES)
@@ -2163,10 +2163,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                         tex.FaceTextures[i].Shiny = sval;
                         tex.FaceTextures[i].Bump = bump;
                     }
-                    tex.DefaultTexture.Shiny = sval;
-                    tex.DefaultTexture.Bump = bump;
                 }
-                part.UpdateTextureEntry(tex.GetBytes());
+                tex.DefaultTexture.Shiny = sval;
+                tex.DefaultTexture.Bump = bump;
+                part.UpdateTextureEntry(tex);
                 return;
             }
         }
@@ -2182,7 +2182,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
              {
                  tex.CreateFace((uint) face);
                  tex.FaceTextures[face].Fullbright = bright;
-                 part.UpdateTextureEntry(tex.GetBytes());
+                 part.UpdateTextureEntry(tex);
                  return;
              }
              else if (face == ScriptBaseClass.ALL_SIDES)
@@ -2195,7 +2195,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                      }
                  }
                  tex.DefaultTexture.Fullbright = bright;
-                 part.UpdateTextureEntry(tex.GetBytes());
+                 part.UpdateTextureEntry(tex);
                  return;
              }
          }
@@ -2263,7 +2263,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 texcolor = tex.CreateFace((uint)face).RGBA;
                 texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
                 tex.FaceTextures[face].RGBA = texcolor;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
             else if (face == ScriptBaseClass.ALL_SIDES)
@@ -2287,7 +2287,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                     tex.DefaultTexture.RGBA = texcolor;
                 }
 
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
         }
@@ -2464,7 +2464,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
                 texface.TextureID = textureID;
                 tex.FaceTextures[face] = texface;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
             else if (face == ScriptBaseClass.ALL_SIDES)
@@ -2477,7 +2477,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                     }
                 }
                 tex.DefaultTexture.TextureID = textureID;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
         }
@@ -2504,7 +2504,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 texface.RepeatU = (float)u;
                 texface.RepeatV = (float)v;
                 tex.FaceTextures[face] = texface;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
             if (face == ScriptBaseClass.ALL_SIDES)
@@ -2519,7 +2519,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 }
                 tex.DefaultTexture.RepeatU = (float)u;
                 tex.DefaultTexture.RepeatV = (float)v;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
         }
@@ -2545,7 +2545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 texface.OffsetU = (float)u;
                 texface.OffsetV = (float)v;
                 tex.FaceTextures[face] = texface;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
             if (face == ScriptBaseClass.ALL_SIDES)
@@ -2560,7 +2560,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 }
                 tex.DefaultTexture.OffsetU = (float)u;
                 tex.DefaultTexture.OffsetV = (float)v;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
         }
@@ -2585,7 +2585,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
                 texface.Rotation = (float)rotation;
                 tex.FaceTextures[face] = texface;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
             if (face == ScriptBaseClass.ALL_SIDES)
@@ -2598,7 +2598,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                     }
                 }
                 tex.DefaultTexture.Rotation = (float)rotation;
-                part.UpdateTextureEntry(tex.GetBytes());
+                part.UpdateTextureEntry(tex);
                 return;
             }
         }
@@ -13110,6 +13110,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             ParcelMediaCommandEnum? commandToSend = null;
             float time = 0.0f; // default is from start
 
+            uint cmndFlags = 0;
             ScenePresence presence = null;
             int cmd;
             for (int i = 0; i < commandList.Data.Length; i++)
@@ -13142,19 +13143,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 
                     case ParcelMediaCommandEnum.Loop:
                         loop = 1;
+                        cmndFlags |= (1 << ScriptBaseClass.PARCEL_MEDIA_COMMAND_LOOP);
                         commandToSend = command;
                         update = true; //need to send the media update packet to set looping
                         break;
 
                     case ParcelMediaCommandEnum.Play:
                         loop = 0;
+                        cmndFlags |= (1 << ScriptBaseClass.PARCEL_MEDIA_COMMAND_PLAY);
                         commandToSend = command;
                         update = true; //need to send the media update packet to make sure it doesn't loop
                         break;
 
                     case ParcelMediaCommandEnum.Pause:
+                        cmndFlags |= (1 << ScriptBaseClass.PARCEL_MEDIA_COMMAND_PAUSE);
+                        commandToSend = command;
+                        break;
                     case ParcelMediaCommandEnum.Stop:
+                        cmndFlags |= (1 << ScriptBaseClass.PARCEL_MEDIA_COMMAND_STOP);
+                        commandToSend = command;
+                        break;
                     case ParcelMediaCommandEnum.Unload:
+                        cmndFlags |= (1 << ScriptBaseClass.PARCEL_MEDIA_COMMAND_UNLOAD);
                         commandToSend = command;
                         break;
 
@@ -13190,6 +13200,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                             if (commandList.Data[i + 1] is LSL_Float)
                             {
                                 time = (float)(LSL_Float)commandList.Data[i + 1];
+                                cmndFlags |= (1 << ScriptBaseClass.PARCEL_MEDIA_COMMAND_TIME);
                             }
                             else Error("llParcelMediaCommandList", "The argument of PARCEL_MEDIA_COMMAND_TIME must be a float");
                             ++i;
@@ -13316,14 +13327,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                     {
                         if (sp.currentParcelUUID == landData.GlobalID)
                         {
-                            sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this?
+                            sp.ControllingClient.SendParcelMediaCommand(cmndFlags,
                                             commandToSend.Value, time);
                         }
                     });
                 }
                 else if (!presence.IsChildAgent)
                 {
-                    presence.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this?
+                    presence.ControllingClient.SendParcelMediaCommand(cmndFlags,
                                             commandToSend.Value, time);
                 }
             }
@@ -13334,6 +13345,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
         {
             m_host.AddScriptLPS(1);
             LSL_List list = new LSL_List();
+            Vector3 pos = m_host.AbsolutePosition;
+
+            ILandObject landObject = World.LandChannel.GetLandObject(pos);
+            if(landObject == null)
+                return list;
+
+            if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, landObject, GroupPowers.ChangeMedia, false))
+                return list;
+
+            LandData land = landObject.LandData;
+            if(land == null)
+                return list;
+
             //TO DO: make the implementation for the missing commands
             //PARCEL_MEDIA_COMMAND_LOOP_SET    float loop      Use this to get or set the parcel's media loop duration. (1.19.1 RC0 or later)
             for (int i = 0; i < aList.Data.Length; i++)
@@ -13344,27 +13368,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                     switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString()))
                     {
                         case ParcelMediaCommandEnum.Url:
-                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaURL));
+                            list.Add(new LSL_String(land.MediaURL));
                             break;
                         case ParcelMediaCommandEnum.Desc:
-                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).Description));
+                            list.Add(new LSL_String(land.MediaDescription));
                             break;
                         case ParcelMediaCommandEnum.Texture:
-                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaID.ToString()));
+                            list.Add(new LSL_String(land.MediaID.ToString()));
                             break;
                         case ParcelMediaCommandEnum.Type:
-                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaType));
+                            list.Add(new LSL_String(land.MediaType));
                             break;
                         case ParcelMediaCommandEnum.Size:
-                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaWidth));
-                            list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaHeight));
+                            list.Add(new LSL_String(land.MediaWidth));
+                            list.Add(new LSL_String(land.MediaHeight));
                             break;
                         default:
                             ParcelMediaCommandEnum mediaCommandEnum = ParcelMediaCommandEnum.Url;
                             NotImplemented("llParcelMediaQuery", "Parameter not supported yet: " + Enum.Parse(mediaCommandEnum.GetType() , aList.Data[i].ToString()).ToString());
                             break;
                     }
-
                 }
             }
             ScriptSleep(m_sleepMsOnParcelMediaQuery);

BIN
bin/OpenMetaverse.Rendering.Meshmerizer.dll


BIN
bin/OpenMetaverse.StructuredData.dll


BIN
bin/OpenMetaverse.dll


BIN
bin/OpenMetaverseTypes.dll