aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs119
1 files changed, 95 insertions, 24 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 49b771f..248679b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -790,7 +790,7 @@ namespace OpenSim.Region.Framework.Scenes
790 } 790 }
791 catch (Exception e) 791 catch (Exception e)
792 { 792 {
793 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 793 m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e);
794 } 794 }
795 } 795 }
796 } 796 }
@@ -2979,17 +2979,20 @@ namespace OpenSim.Region.Framework.Scenes
2979 /// <param name="scale"></param> 2979 /// <param name="scale"></param>
2980 public void Resize(Vector3 scale) 2980 public void Resize(Vector3 scale)
2981 { 2981 {
2982 scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxNonphys);
2983 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys);
2984 scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys);
2985
2986 PhysicsActor pa = PhysActor; 2982 PhysicsActor pa = PhysActor;
2987 2983
2988 if (pa != null && pa.IsPhysical) 2984 if (ParentGroup.Scene != null)
2989 { 2985 {
2990 scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys); 2986 scale.X = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.X));
2991 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys); 2987 scale.Y = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Y));
2992 scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxPhys); 2988 scale.Z = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Z));
2989
2990 if (pa != null && pa.IsPhysical)
2991 {
2992 scale.X = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.X));
2993 scale.Y = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Y));
2994 scale.Z = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Z));
2995 }
2993 } 2996 }
2994 2997
2995// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale); 2998// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale);
@@ -3086,7 +3089,7 @@ namespace OpenSim.Region.Framework.Scenes
3086 // UUID, Name, TimeStampFull); 3089 // UUID, Name, TimeStampFull);
3087 3090
3088 if (ParentGroup.Scene != null) 3091 if (ParentGroup.Scene != null)
3089 ParentGroup.Scene.EventManager.TriggerSceneObjectPartUpdated(this); 3092 ParentGroup.Scene.EventManager.TriggerSceneObjectPartUpdated(this, true);
3090 } 3093 }
3091 3094
3092 /// <summary> 3095 /// <summary>
@@ -3120,7 +3123,7 @@ namespace OpenSim.Region.Framework.Scenes
3120 } 3123 }
3121 3124
3122 if (ParentGroup.Scene != null) 3125 if (ParentGroup.Scene != null)
3123 ParentGroup.Scene.EventManager.TriggerSceneObjectPartUpdated(this); 3126 ParentGroup.Scene.EventManager.TriggerSceneObjectPartUpdated(this, false);
3124 } 3127 }
3125 3128
3126 public void ScriptSetPhysicsStatus(bool UsePhysics) 3129 public void ScriptSetPhysicsStatus(bool UsePhysics)
@@ -3575,23 +3578,32 @@ namespace OpenSim.Region.Framework.Scenes
3575 } 3578 }
3576 3579
3577 /// <summary> 3580 /// <summary>
3578 /// Set the color of prim faces 3581 /// Set the color & alpha of prim faces
3579 /// </summary> 3582 /// </summary>
3580 /// <param name="color"></param>
3581 /// <param name="face"></param> 3583 /// <param name="face"></param>
3582 public void SetFaceColor(Vector3 color, int face) 3584 /// <param name="color"></param>
3585 /// <param name="alpha"></param>
3586 public void SetFaceColorAlpha(int face, Vector3 color, double ?alpha)
3583 { 3587 {
3588 Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f);
3589 float clippedAlpha = alpha.HasValue ?
3590 Util.Clip((float)alpha.Value, 0.0f, 1.0f) : 0;
3591
3584 // The only way to get a deep copy/ If we don't do this, we can 3592 // The only way to get a deep copy/ If we don't do this, we can
3585 // mever detect color changes further down. 3593 // never detect color changes further down.
3586 Byte[] buf = Shape.Textures.GetBytes(); 3594 Byte[] buf = Shape.Textures.GetBytes();
3587 Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length); 3595 Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length);
3588 Color4 texcolor; 3596 Color4 texcolor;
3589 if (face >= 0 && face < GetNumberOfSides()) 3597 if (face >= 0 && face < GetNumberOfSides())
3590 { 3598 {
3591 texcolor = tex.CreateFace((uint)face).RGBA; 3599 texcolor = tex.CreateFace((uint)face).RGBA;
3592 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); 3600 texcolor.R = clippedColor.X;
3593 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); 3601 texcolor.G = clippedColor.Y;
3594 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); 3602 texcolor.B = clippedColor.Z;
3603 if (alpha.HasValue)
3604 {
3605 texcolor.A = clippedAlpha;
3606 }
3595 tex.FaceTextures[face].RGBA = texcolor; 3607 tex.FaceTextures[face].RGBA = texcolor;
3596 UpdateTextureEntry(tex.GetBytes()); 3608 UpdateTextureEntry(tex.GetBytes());
3597 return; 3609 return;
@@ -3603,15 +3615,23 @@ namespace OpenSim.Region.Framework.Scenes
3603 if (tex.FaceTextures[i] != null) 3615 if (tex.FaceTextures[i] != null)
3604 { 3616 {
3605 texcolor = tex.FaceTextures[i].RGBA; 3617 texcolor = tex.FaceTextures[i].RGBA;
3606 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); 3618 texcolor.R = clippedColor.X;
3607 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); 3619 texcolor.G = clippedColor.Y;
3608 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); 3620 texcolor.B = clippedColor.Z;
3621 if (alpha.HasValue)
3622 {
3623 texcolor.A = clippedAlpha;
3624 }
3609 tex.FaceTextures[i].RGBA = texcolor; 3625 tex.FaceTextures[i].RGBA = texcolor;
3610 } 3626 }
3611 texcolor = tex.DefaultTexture.RGBA; 3627 texcolor = tex.DefaultTexture.RGBA;
3612 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); 3628 texcolor.R = clippedColor.X;
3613 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); 3629 texcolor.G = clippedColor.Y;
3614 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); 3630 texcolor.B = clippedColor.Z;
3631 if (alpha.HasValue)
3632 {
3633 texcolor.A = clippedAlpha;
3634 }
3615 tex.DefaultTexture.RGBA = texcolor; 3635 tex.DefaultTexture.RGBA = texcolor;
3616 } 3636 }
3617 UpdateTextureEntry(tex.GetBytes()); 3637 UpdateTextureEntry(tex.GetBytes());
@@ -4899,6 +4919,57 @@ namespace OpenSim.Region.Framework.Scenes
4899 ScheduleFullUpdate(); 4919 ScheduleFullUpdate();
4900 } 4920 }
4901 4921
4922 public void UpdateSlice(float begin, float end)
4923 {
4924 if (end < begin)
4925 {
4926 float temp = begin;
4927 begin = end;
4928 end = temp;
4929 }
4930 end = Math.Min(1f, Math.Max(0f, end));
4931 begin = Math.Min(Math.Min(1f, Math.Max(0f, begin)), end - 0.02f);
4932 if (begin < 0.02f && end < 0.02f)
4933 {
4934 begin = 0f;
4935 end = 0.02f;
4936 }
4937
4938 ushort uBegin = (ushort)(50000.0 * begin);
4939 ushort uEnd = (ushort)(50000.0 * (1f - end));
4940 bool updatePossiblyNeeded = false;
4941 PrimType primType = GetPrimType();
4942 if (primType == PrimType.SPHERE || primType == PrimType.TORUS || primType == PrimType.TUBE || primType == PrimType.RING)
4943 {
4944 if (m_shape.ProfileBegin != uBegin || m_shape.ProfileEnd != uEnd)
4945 {
4946 m_shape.ProfileBegin = uBegin;
4947 m_shape.ProfileEnd = uEnd;
4948 updatePossiblyNeeded = true;
4949 }
4950 }
4951 else if (m_shape.PathBegin != uBegin || m_shape.PathEnd != uEnd)
4952 {
4953 m_shape.PathBegin = uBegin;
4954 m_shape.PathEnd = uEnd;
4955 updatePossiblyNeeded = true;
4956 }
4957
4958 if (updatePossiblyNeeded && ParentGroup != null)
4959 {
4960 ParentGroup.HasGroupChanged = true;
4961 }
4962 if (updatePossiblyNeeded && PhysActor != null)
4963 {
4964 PhysActor.Shape = m_shape;
4965 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
4966 }
4967 if (updatePossiblyNeeded)
4968 {
4969 ScheduleFullUpdate();
4970 }
4971 }
4972
4902 /// <summary> 4973 /// <summary>
4903 /// If the part is a sculpt/mesh, retrieve the mesh data and reinsert it into the shape so that the physics 4974 /// If the part is a sculpt/mesh, retrieve the mesh data and reinsert it into the shape so that the physics
4904 /// engine can use it. 4975 /// engine can use it.