From 741badc4fa1da61d86fdbb2d33056fa8c6599e69 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Mar 2012 19:24:41 +0000 Subject: [PATCH] let PhysicsShapeType none remove physics remove physics on child parts **UnTested** --- .../Framework/Scenes/SceneObjectPart.cs | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ace53f6584..a68b3eb455 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1657,9 +1657,13 @@ namespace OpenSim.Region.Framework.Scenes if (!ParentGroup.Scene.CollidablePrims) return; + if (PhysicsShapeType == (byte)PhysShapeType.none) + return; + bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; + if (IsJoint()) { DoPhysicsPropertyUpdate(isPhysical, true); @@ -2016,6 +2020,7 @@ namespace OpenSim.Region.Framework.Scenes if (PhysActor.Phantom != phan) PhysActor.Phantom = phan; + // If this part is a sculpt then delay the physics update until we've asynchronously loaded the // mesh data. if (Shape.SculptEntry) @@ -4414,11 +4419,34 @@ namespace OpenSim.Region.Framework.Scenes if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) return; - PhysicsShapeType = (byte)physdata.PhysShapeType; - Density = physdata.Density; - GravityModifier = physdata.GravitationModifier; - Friction = physdata.Friction; - Bounciness = physdata.Bounce; + if (PhysicsShapeType != (byte)physdata.PhysShapeType) + { + PhysicsShapeType = (byte)physdata.PhysShapeType; + + if (PhysicsShapeType == (byte)PhysShapeType.none) + { + if (PhysActor != null) + { + Velocity = new Vector3(0, 0, 0); + Acceleration = new Vector3(0, 0, 0); + if (ParentGroup.RootPart == this) + AngularVelocity = new Vector3(0, 0, 0); + ParentGroup.Scene.RemovePhysicalPrim(1); + RemoveFromPhysics(); + } + } + else if (PhysActor == null) + ApplyPhysics((uint)Flags, VolumeDetectActive, false); + } + + if(Density != physdata.Density) + Density = physdata.Density; + if(GravityModifier != physdata.GravitationModifier) + GravityModifier = physdata.GravitationModifier; + if(Friction != physdata.Friction) + Friction = physdata.Friction; + if(Bounciness != physdata.Bounce) + Bounciness = physdata.Bounce; } /// /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. @@ -4448,9 +4476,10 @@ namespace OpenSim.Region.Framework.Scenes // ... if VD is changed, all others are not. // ... if one of the others is changed, VD is not. +/* if (SetVD) // VD is active, special logic applies - /* volume detection is now independent of phantom in sl + volume detection is now independent of phantom in sl { // State machine logic for VolumeDetect @@ -4471,9 +4500,8 @@ namespace OpenSim.Region.Framework.Scenes // If volumedetect is active we don't want phantom to be applied. // If this is a new call to VD out of the state "phantom" // this will also cause the prim to be visible to physics - */ SetPhantom = false; -/* } + } } else if (wasVD) { @@ -4520,10 +4548,10 @@ namespace OpenSim.Region.Framework.Scenes else RemFlag(PrimFlags.Phantom); - if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment + if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints { - AddFlag(PrimFlags.Phantom); +// AddFlag(PrimFlags.Phantom); Velocity = new Vector3(0, 0, 0); Acceleration = new Vector3(0, 0, 0);