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.cs234
1 files changed, 227 insertions, 7 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 56b2f13..dd797fc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -90,12 +90,38 @@ namespace OpenSim.Region.Framework.Scenes
90 SCALE = 0x40 90 SCALE = 0x40
91 } 91 }
92 92
93 public enum PrimType : int
94 {
95 BOX = 0,
96 CYLINDER = 1,
97 PRISM = 2,
98 SPHERE = 3,
99 TORUS = 4,
100 TUBE = 5,
101 RING = 6,
102 SCULPT = 7
103 }
104
93 #endregion Enumerations 105 #endregion Enumerations
94 106
95 public class SceneObjectPart : IScriptHost 107 public class SceneObjectPart : IScriptHost
96 { 108 {
109 /// <value>
110 /// Denote all sides of the prim
111 /// </value>
112 public const int ALL_SIDES = -1;
113
97 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 114 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
98 115
116 /// <value>
117 /// Is this sop a root part?
118 /// </value>
119 [XmlIgnore]
120 public bool IsRoot
121 {
122 get { return ParentGroup.RootPart == this; }
123 }
124
99 // use only one serializer to give the runtime a chance to optimize it (it won't do that if you 125 // use only one serializer to give the runtime a chance to optimize it (it won't do that if you
100 // use a new instance every time) 126 // use a new instance every time)
101 private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); 127 private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
@@ -737,6 +763,9 @@ namespace OpenSim.Region.Framework.Scenes
737 } 763 }
738 } 764 }
739 765
766 /// <value>
767 /// Text color.
768 /// </value>
740 public Color Color 769 public Color Color
741 { 770 {
742 get { return m_color; } 771 get { return m_color; }
@@ -1901,7 +1930,7 @@ namespace OpenSim.Region.Framework.Scenes
1901 foreach (uint localId in startedColliders) 1930 foreach (uint localId in startedColliders)
1902 { 1931 {
1903 if (localId == 0) 1932 if (localId == 0)
1904 return; 1933 continue;
1905 // always running this check because if the user deletes the object it would return a null reference. 1934 // always running this check because if the user deletes the object it would return a null reference.
1906 if (m_parentGroup == null) 1935 if (m_parentGroup == null)
1907 return; 1936 return;
@@ -2037,7 +2066,7 @@ namespace OpenSim.Region.Framework.Scenes
2037 { 2066 {
2038 // always running this check because if the user deletes the object it would return a null reference. 2067 // always running this check because if the user deletes the object it would return a null reference.
2039 if (localId == 0) 2068 if (localId == 0)
2040 return; 2069 continue;
2041 2070
2042 if (m_parentGroup == null) 2071 if (m_parentGroup == null)
2043 return; 2072 return;
@@ -2169,7 +2198,7 @@ namespace OpenSim.Region.Framework.Scenes
2169 foreach (uint localId in endedColliders) 2198 foreach (uint localId in endedColliders)
2170 { 2199 {
2171 if (localId == 0) 2200 if (localId == 0)
2172 return; 2201 continue;
2173 2202
2174 // always running this check because if the user deletes the object it would return a null reference. 2203 // always running this check because if the user deletes the object it would return a null reference.
2175 if (m_parentGroup == null) 2204 if (m_parentGroup == null)
@@ -2479,7 +2508,7 @@ namespace OpenSim.Region.Framework.Scenes
2479 //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString()); 2508 //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString());
2480 //ScheduleFullUpdate(); 2509 //ScheduleFullUpdate();
2481 } 2510 }
2482 2511
2483 public void RemoveScriptEvents(UUID scriptid) 2512 public void RemoveScriptEvents(UUID scriptid)
2484 { 2513 {
2485 lock (m_scriptEvents) 2514 lock (m_scriptEvents)
@@ -2533,6 +2562,8 @@ namespace OpenSim.Region.Framework.Scenes
2533 /// </summary> 2562 /// </summary>
2534 public void ScheduleFullUpdate() 2563 public void ScheduleFullUpdate()
2535 { 2564 {
2565// m_log.DebugFormat("[SCENE OBJECT PART]: Scheduling full update for {0} {1}", Name, LocalId);
2566
2536 if (m_parentGroup != null) 2567 if (m_parentGroup != null)
2537 { 2568 {
2538 m_parentGroup.QueueForUpdateCheck(); 2569 m_parentGroup.QueueForUpdateCheck();
@@ -2953,6 +2984,178 @@ namespace OpenSim.Region.Framework.Scenes
2953 } 2984 }
2954 } 2985 }
2955 2986
2987 /// <summary>
2988 /// Set the color of prim faces
2989 /// </summary>
2990 /// <param name="color"></param>
2991 /// <param name="face"></param>
2992 public void SetFaceColor(Vector3 color, int face)
2993 {
2994 Primitive.TextureEntry tex = Shape.Textures;
2995 Color4 texcolor;
2996 if (face >= 0 && face < GetNumberOfSides())
2997 {
2998 texcolor = tex.CreateFace((uint)face).RGBA;
2999 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
3000 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
3001 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
3002 tex.FaceTextures[face].RGBA = texcolor;
3003 UpdateTexture(tex);
3004 return;
3005 }
3006 else if (face == ALL_SIDES)
3007 {
3008 for (uint i = 0; i < GetNumberOfSides(); i++)
3009 {
3010 if (tex.FaceTextures[i] != null)
3011 {
3012 texcolor = tex.FaceTextures[i].RGBA;
3013 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
3014 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
3015 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
3016 tex.FaceTextures[i].RGBA = texcolor;
3017 }
3018 texcolor = tex.DefaultTexture.RGBA;
3019 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
3020 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
3021 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
3022 tex.DefaultTexture.RGBA = texcolor;
3023 }
3024 UpdateTexture(tex);
3025 return;
3026 }
3027 }
3028
3029 /// <summary>
3030 /// Get the number of sides that this part has.
3031 /// </summary>
3032 /// <returns></returns>
3033 public int GetNumberOfSides()
3034 {
3035 int ret = 0;
3036 bool hasCut;
3037 bool hasHollow;
3038 bool hasDimple;
3039 bool hasProfileCut;
3040
3041 PrimType primType = GetPrimType();
3042 HasCutHollowDimpleProfileCut(primType, Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
3043
3044 switch (primType)
3045 {
3046 case PrimType.BOX:
3047 ret = 6;
3048 if (hasCut) ret += 2;
3049 if (hasHollow) ret += 1;
3050 break;
3051 case PrimType.CYLINDER:
3052 ret = 3;
3053 if (hasCut) ret += 2;
3054 if (hasHollow) ret += 1;
3055 break;
3056 case PrimType.PRISM:
3057 ret = 5;
3058 if (hasCut) ret += 2;
3059 if (hasHollow) ret += 1;
3060 break;
3061 case PrimType.SPHERE:
3062 ret = 1;
3063 if (hasCut) ret += 2;
3064 if (hasDimple) ret += 2;
3065 if (hasHollow) ret += 1;
3066 break;
3067 case PrimType.TORUS:
3068 ret = 1;
3069 if (hasCut) ret += 2;
3070 if (hasProfileCut) ret += 2;
3071 if (hasHollow) ret += 1;
3072 break;
3073 case PrimType.TUBE:
3074 ret = 4;
3075 if (hasCut) ret += 2;
3076 if (hasProfileCut) ret += 2;
3077 if (hasHollow) ret += 1;
3078 break;
3079 case PrimType.RING:
3080 ret = 3;
3081 if (hasCut) ret += 2;
3082 if (hasProfileCut) ret += 2;
3083 if (hasHollow) ret += 1;
3084 break;
3085 case PrimType.SCULPT:
3086 ret = 1;
3087 break;
3088 }
3089 return ret;
3090 }
3091
3092 /// <summary>
3093 /// Tell us what type this prim is
3094 /// </summary>
3095 /// <param name="primShape"></param>
3096 /// <returns></returns>
3097 public PrimType GetPrimType()
3098 {
3099 if (Shape.SculptEntry)
3100 return PrimType.SCULPT;
3101 if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
3102 {
3103 if (Shape.PathCurve == (byte)Extrusion.Straight)
3104 return PrimType.BOX;
3105 else if (Shape.PathCurve == (byte)Extrusion.Curve1)
3106 return PrimType.TUBE;
3107 }
3108 else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
3109 {
3110 if (Shape.PathCurve == (byte)Extrusion.Straight)
3111 return PrimType.CYLINDER;
3112 // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
3113 else if (Shape.PathCurve == (byte)Extrusion.Curve1)
3114 return PrimType.TORUS;
3115 }
3116 else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
3117 {
3118 if (Shape.PathCurve == (byte)Extrusion.Curve1 || Shape.PathCurve == (byte)Extrusion.Curve2)
3119 return PrimType.SPHERE;
3120 }
3121 else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
3122 {
3123 if (Shape.PathCurve == (byte)Extrusion.Straight)
3124 return PrimType.PRISM;
3125 else if (Shape.PathCurve == (byte)Extrusion.Curve1)
3126 return PrimType.RING;
3127 }
3128
3129 return PrimType.BOX;
3130 }
3131
3132 /// <summary>
3133 /// Tell us if this object has cut, hollow, dimple, and other factors affecting the number of faces
3134 /// </summary>
3135 /// <param name="primType"></param>
3136 /// <param name="shape"></param>
3137 /// <param name="hasCut"></param>
3138 /// <param name="hasHollow"></param>
3139 /// <param name="hasDimple"></param>
3140 /// <param name="hasProfileCut"></param>
3141 protected static void HasCutHollowDimpleProfileCut(PrimType primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow,
3142 out bool hasDimple, out bool hasProfileCut)
3143 {
3144 if (primType == PrimType.BOX
3145 ||
3146 primType == PrimType.CYLINDER
3147 ||
3148 primType == PrimType.PRISM)
3149
3150 hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0);
3151 else
3152 hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0);
3153
3154 hasHollow = shape.ProfileHollow > 0;
3155 hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms
3156 hasProfileCut = hasDimple; // is it the same thing?
3157 }
3158
2956 public void SetGroup(UUID groupID, IClientAPI client) 3159 public void SetGroup(UUID groupID, IClientAPI client)
2957 { 3160 {
2958 _groupID = groupID; 3161 _groupID = groupID;
@@ -2984,6 +3187,11 @@ namespace OpenSim.Region.Framework.Scenes
2984 } 3187 }
2985 } 3188 }
2986 3189
3190 /// <summary>
3191 /// Set the events that this part will pass on to listeners.
3192 /// </summary>
3193 /// <param name="scriptid"></param>
3194 /// <param name="events"></param>
2987 public void SetScriptEvents(UUID scriptid, int events) 3195 public void SetScriptEvents(UUID scriptid, int events)
2988 { 3196 {
2989 // scriptEvents oldparts; 3197 // scriptEvents oldparts;
@@ -3936,9 +4144,13 @@ namespace OpenSim.Region.Framework.Scenes
3936 ScheduleFullUpdate(); 4144 ScheduleFullUpdate();
3937 } 4145 }
3938 4146
3939 // Added to handle bug in libsecondlife's TextureEntry.ToBytes() 4147 /// <summary>
3940 // not handling RGBA properly. Cycles through, and "fixes" the color 4148 /// Update the textures on the part.
3941 // info 4149 /// </summary>
4150 /// Added to handle bug in libsecondlife's TextureEntry.ToBytes()
4151 /// not handling RGBA properly. Cycles through, and "fixes" the color
4152 /// info
4153 /// <param name="tex"></param>
3942 public void UpdateTexture(Primitive.TextureEntry tex) 4154 public void UpdateTexture(Primitive.TextureEntry tex)
3943 { 4155 {
3944 //Color4 tmpcolor; 4156 //Color4 tmpcolor;
@@ -4042,6 +4254,8 @@ namespace OpenSim.Region.Framework.Scenes
4042 4254
4043 if (m_parentGroup == null) 4255 if (m_parentGroup == null)
4044 { 4256 {
4257// m_log.DebugFormat(
4258// "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents() since m_parentGroup == null", Name, LocalId);
4045 ScheduleFullUpdate(); 4259 ScheduleFullUpdate();
4046 return; 4260 return;
4047 } 4261 }
@@ -4058,9 +4272,15 @@ namespace OpenSim.Region.Framework.Scenes
4058 LocalFlags=(PrimFlags)objectflagupdate; 4272 LocalFlags=(PrimFlags)objectflagupdate;
4059 4273
4060 if (m_parentGroup != null && m_parentGroup.RootPart == this) 4274 if (m_parentGroup != null && m_parentGroup.RootPart == this)
4275 {
4061 m_parentGroup.aggregateScriptEvents(); 4276 m_parentGroup.aggregateScriptEvents();
4277 }
4062 else 4278 else
4279 {
4280// m_log.DebugFormat(
4281// "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId);
4063 ScheduleFullUpdate(); 4282 ScheduleFullUpdate();
4283 }
4064 } 4284 }
4065 4285
4066 public int registerTargetWaypoint(Vector3 target, float tolerance) 4286 public int registerTargetWaypoint(Vector3 target, float tolerance)