aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs96
1 files changed, 81 insertions, 15 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 6b4d47a..0315c92 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -167,7 +167,11 @@ namespace OpenSim.Region.Environment.Scenes
167 167
168 [XmlIgnore] 168 [XmlIgnore]
169 public PhysicsVector RotationAxis = new PhysicsVector(1f,1f,1f); 169 public PhysicsVector RotationAxis = new PhysicsVector(1f,1f,1f);
170 170
171 [XmlIgnore]
172 public bool VolumeDetectActive = false; // XmlIgnore set to avoid problems with persistance until I come to care for this
173 // Certainly this must be a persistant setting finally
174
171 /// <summary> 175 /// <summary>
172 /// This part's inventory 176 /// This part's inventory
173 /// </summary> 177 /// </summary>
@@ -2178,6 +2182,16 @@ if (m_shape != null) {
2178 m_parentGroup.ScriptSetPhysicsStatus(UsePhysics); 2182 m_parentGroup.ScriptSetPhysicsStatus(UsePhysics);
2179 } 2183 }
2180 2184
2185 public void ScriptSetVolumeDetect(bool SetVD)
2186 {
2187
2188 if (m_parentGroup != null)
2189 {
2190 m_parentGroup.ScriptSetVolumeDetect(SetVD);
2191 }
2192 }
2193
2194
2181 public void SculptTextureCallback(UUID textureID, AssetBase texture) 2195 public void SculptTextureCallback(UUID textureID, AssetBase texture)
2182 { 2196 {
2183 if (m_shape.SculptEntry) 2197 if (m_shape.SculptEntry)
@@ -2484,14 +2498,6 @@ if (m_shape != null) {
2484 } 2498 }
2485 } 2499 }
2486 2500
2487 public void SetVolumeDetect(int param)
2488 {
2489 if (PhysActor != null)
2490 {
2491 PhysActor.SetVolumeDetect(param);
2492 }
2493 }
2494
2495 public void SetGroup(UUID groupID, IClientAPI client) 2501 public void SetGroup(UUID groupID, IClientAPI client)
2496 { 2502 {
2497 _groupID = groupID; 2503 _groupID = groupID;
@@ -3184,17 +3190,46 @@ if (m_shape != null) {
3184 } 3190 }
3185 } 3191 }
3186 3192
3187 public void UpdatePrimFlags(bool UsePhysics, bool IsTemporary, bool IsPhantom) 3193 public void UpdatePrimFlags(bool UsePhysics, bool IsTemporary, bool IsPhantom, bool IsVD)
3188 { 3194 {
3189 bool wasUsingPhysics = ((ObjectFlags & (uint) PrimFlags.Physics) != 0); 3195 bool wasUsingPhysics = ((ObjectFlags & (uint) PrimFlags.Physics) != 0);
3190 bool wasTemporary = ((ObjectFlags & (uint)PrimFlags.TemporaryOnRez) != 0); 3196 bool wasTemporary = ((ObjectFlags & (uint)PrimFlags.TemporaryOnRez) != 0);
3191 bool wasPhantom = ((ObjectFlags & (uint)PrimFlags.Phantom) != 0); 3197 bool wasPhantom = ((ObjectFlags & (uint)PrimFlags.Phantom) != 0);
3198 bool wasVD = VolumeDetectActive;
3192 3199
3193 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == IsTemporary) && (wasPhantom == IsPhantom)) 3200 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == IsTemporary) && (wasPhantom == IsPhantom) && (IsVD==wasVD) )
3194 { 3201 {
3195 return; 3202 return;
3196 } 3203 }
3197 3204
3205 // Special cases for VD. VD can only be called from a script
3206 // and can't be combined with changes to other states. So we can rely
3207 // that...
3208 // ... if VD is changed, all others are not.
3209 // ... if one of the others is changed, VD is not.
3210 if (IsVD) // VD is active, special logic applies
3211 {
3212 // State machine logic for VolumeDetect
3213 // More logic below
3214 bool phanReset = (IsPhantom != wasPhantom) && !IsPhantom;
3215
3216 if (phanReset) // Phantom changes from on to off switch VD off too
3217 {
3218 IsVD = false; // Switch it of for the course of this routine
3219 VolumeDetectActive = false; // and also permanently
3220 if (PhysActor != null)
3221 PhysActor.SetVolumeDetect(0); // Let physics know about it too
3222 }
3223 else
3224 {
3225 IsPhantom = false;
3226 // If volumedetect is active we don't want phantom to be applied.
3227 // If this is a new call to VD out of the state "phantom"
3228 // this will also cause the prim to be visible to physics
3229 }
3230
3231 }
3232
3198 if (UsePhysics) 3233 if (UsePhysics)
3199 { 3234 {
3200 AddFlag(PrimFlags.Physics); 3235 AddFlag(PrimFlags.Physics);
@@ -3222,6 +3257,7 @@ if (m_shape != null) {
3222 } 3257 }
3223 } 3258 }
3224 3259
3260
3225 if (IsPhantom || IsAttachment) 3261 if (IsPhantom || IsAttachment)
3226 { 3262 {
3227 AddFlag(PrimFlags.Phantom); 3263 AddFlag(PrimFlags.Phantom);
@@ -3232,11 +3268,13 @@ if (m_shape != null) {
3232 PhysActor = null; 3268 PhysActor = null;
3233 } 3269 }
3234 } 3270 }
3235 else 3271 else // Not phantom
3236 { 3272 {
3237 RemFlag(PrimFlags.Phantom); 3273 RemFlag(PrimFlags.Phantom);
3274
3238 if (PhysActor == null) 3275 if (PhysActor == null)
3239 { 3276 {
3277 // It's not phantom anymore. So make sure the physics engine get's knowledge of it
3240 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( 3278 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
3241 Name, 3279 Name,
3242 Shape, 3280 Shape,
@@ -3261,10 +3299,11 @@ if (m_shape != null) {
3261 } 3299 }
3262 } 3300 }
3263 } 3301 }
3264 else 3302 else // it already has a physical representation
3265 { 3303 {
3266 PhysActor.IsPhysical = UsePhysics; 3304 PhysActor.IsPhysical = UsePhysics;
3267 DoPhysicsPropertyUpdate(UsePhysics, false); 3305
3306 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim
3268 if (m_parentGroup != null) 3307 if (m_parentGroup != null)
3269 { 3308 {
3270 if (!m_parentGroup.IsDeleted) 3309 if (!m_parentGroup.IsDeleted)
@@ -3278,6 +3317,32 @@ if (m_shape != null) {
3278 } 3317 }
3279 } 3318 }
3280 3319
3320 if (IsVD)
3321 {
3322 // If the above logic worked (this is urgent candidate to unit tests!)
3323 // we now have a physicsactor.
3324 // Defensive programming calls for a check here.
3325 // Better would be throwing an exception that could be catched by a unit test as the internal
3326 // logic should make sure, this Physactor is always here.
3327 if (this.PhysActor != null)
3328 {
3329 PhysActor.SetVolumeDetect(1);
3330 AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
3331 this.VolumeDetectActive = true;
3332 }
3333
3334 }
3335 else
3336 { // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
3337 // (mumbles, well, at least if you have infinte CPU powers :-) )
3338 if (this.PhysActor != null)
3339 {
3340 PhysActor.SetVolumeDetect(0);
3341 }
3342 this.VolumeDetectActive = false;
3343 }
3344
3345
3281 if (IsTemporary) 3346 if (IsTemporary)
3282 { 3347 {
3283 AddFlag(PrimFlags.TemporaryOnRez); 3348 AddFlag(PrimFlags.TemporaryOnRez);
@@ -3287,6 +3352,7 @@ if (m_shape != null) {
3287 RemFlag(PrimFlags.TemporaryOnRez); 3352 RemFlag(PrimFlags.TemporaryOnRez);
3288 } 3353 }
3289 // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 3354 // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
3355
3290 ParentGroup.HasGroupChanged = true; 3356 ParentGroup.HasGroupChanged = true;
3291 ScheduleFullUpdate(); 3357 ScheduleFullUpdate();
3292 } 3358 }