aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorMelanie2012-04-13 03:03:44 +0100
committerMelanie2012-04-13 03:03:44 +0100
commit5e3a76361fa097a2c47f6d37884786ec5777590c (patch)
tree85d791855e6e3646194a572fae5f2fb3d7a84110 /OpenSim/Region/Framework/Scenes
parentMerge branch 'master' into careminster (diff)
parentmake llGetGeometricCenter() work as in current SL. Now this is not real geom ... (diff)
downloadopensim-SC-5e3a76361fa097a2c47f6d37884786ec5777590c.zip
opensim-SC-5e3a76361fa097a2c47f6d37884786ec5777590c.tar.gz
opensim-SC-5e3a76361fa097a2c47f6d37884786ec5777590c.tar.bz2
opensim-SC-5e3a76361fa097a2c47f6d37884786ec5777590c.tar.xz
Merge branch 'master' of ssh://melanie@3dhosting.de/var/git/careminster into careminster
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs30
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs439
2 files changed, 196 insertions, 273 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index ced3fb5..6f3a084 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3955,7 +3955,35 @@ namespace OpenSim.Region.Framework.Scenes
3955 } 3955 }
3956 } 3956 }
3957 } 3957 }
3958 3958
3959 public Vector3 GetGeometricCenter()
3960 {
3961 // this is not real geometric center but a average of positions relative to root prim acording to
3962 // http://wiki.secondlife.com/wiki/llGetGeometricCenter
3963 // ignoring tortured prims details since sl also seems to ignore
3964 // so no real use in doing it on physics
3965
3966 Vector3 gc = Vector3.Zero;
3967
3968 int nparts = m_parts.Count;
3969 if (nparts <= 1)
3970 return gc;
3971
3972 SceneObjectPart[] parts = m_parts.GetArray();
3973 nparts = parts.Length; // just in case it changed
3974 if (nparts <= 1)
3975 return gc;
3976
3977 // average all parts positions
3978 for (int i = 0; i < nparts; i++)
3979 gc += parts[i].GetWorldPosition();
3980 gc /= nparts;
3981
3982 // relative to root:
3983 gc -= AbsolutePosition;
3984 return gc;
3985 }
3986
3959 public float GetMass() 3987 public float GetMass()
3960 { 3988 {
3961 float retmass = 0f; 3989 float retmass = 0f;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 969ddaf..511ab19 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -122,6 +122,11 @@ namespace OpenSim.Region.Framework.Scenes
122 /// Denote all sides of the prim 122 /// Denote all sides of the prim
123 /// </value> 123 /// </value>
124 public const int ALL_SIDES = -1; 124 public const int ALL_SIDES = -1;
125
126 private const scriptEvents PhyscicsNeededSubsEvents = (
127 scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end |
128 scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end
129 );
125 130
126 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 131 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
127 132
@@ -1821,18 +1826,20 @@ namespace OpenSim.Region.Framework.Scenes
1821 /// </summary> 1826 /// </summary>
1822 /// <param name="rootObjectFlags"></param> 1827 /// <param name="rootObjectFlags"></param>
1823 /// <param name="VolumeDetectActive"></param> 1828 /// <param name="VolumeDetectActive"></param>
1829 /// <param name="building"></param>
1824 1830
1825 public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool building) 1831 public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building)
1826 { 1832 {
1833 VolumeDetectActive = _VolumeDetectActive; //?? as is used this is redundante
1834
1827 if (!ParentGroup.Scene.CollidablePrims) 1835 if (!ParentGroup.Scene.CollidablePrims)
1828 return; 1836 return;
1829 1837
1830 if (PhysicsShapeType == (byte)PhysShapeType.none) 1838 if (PhysicsShapeType == (byte)PhysShapeType.none)
1831 return; 1839 return;
1832 1840
1833 bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; 1841 bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0;
1834 bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; 1842 bool isPhantom = (_ObjectFlags & (uint) PrimFlags.Phantom) != 0;
1835
1836 1843
1837 if (IsJoint()) 1844 if (IsJoint())
1838 { 1845 {
@@ -1840,68 +1847,11 @@ namespace OpenSim.Region.Framework.Scenes
1840 } 1847 }
1841 else 1848 else
1842 { 1849 {
1843 // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored 1850 if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment
1844// if (VolumeDetectActive) 1851 && !(Shape.PathCurve == (byte)Extrusion.Flexible))
1845// isPhantom = false; 1852 AddToPhysics(isPhysical, isPhantom, building, true);
1846 1853 else
1847 // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition 1854 PhysActor = null; // just to be sure
1848 // or flexible
1849 // if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible))
1850 if ((!isPhantom || isPhysical || VolumeDetectActive) && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible))
1851 {
1852 Vector3 velocity = Velocity;
1853 Vector3 rotationalVelocity = AngularVelocity;
1854 try
1855 {
1856 PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape(
1857 string.Format("{0}/{1}", Name, UUID),
1858 Shape,
1859 AbsolutePosition,
1860 Scale,
1861 GetWorldRotation(),
1862 isPhysical,
1863 isPhantom,
1864 PhysicsShapeType,
1865 m_localId);
1866 }
1867 catch
1868 {
1869 m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid);
1870 PhysActor = null;
1871 }
1872
1873 PhysicsActor pa = PhysActor;
1874
1875 if (pa != null)
1876 {
1877 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
1878 pa.SetMaterial(Material);
1879
1880 // if root part apply vehicle
1881 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId)
1882 m_vehicle.SetVehicle(pa);
1883
1884 DoPhysicsPropertyUpdate(isPhysical, true);
1885 if(VolumeDetectActive) // change if not the default only
1886 pa.SetVolumeDetect(1);
1887
1888 if (!building)
1889 pa.Building = false;
1890
1891 Velocity = velocity;
1892 AngularVelocity = rotationalVelocity;
1893 pa.Velocity = velocity;
1894 pa.RotationalVelocity = rotationalVelocity;
1895
1896 // if not vehicle and root part apply force and torque
1897 if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE)
1898 && LocalId == ParentGroup.RootPart.LocalId)
1899 {
1900 pa.Force = Force;
1901 pa.Torque = Torque;
1902 }
1903 }
1904 }
1905 } 1855 }
1906 } 1856 }
1907 1857
@@ -2310,18 +2260,29 @@ namespace OpenSim.Region.Framework.Scenes
2310 2260
2311 public Vector3 GetGeometricCenter() 2261 public Vector3 GetGeometricCenter()
2312 { 2262 {
2313 PhysicsActor pa = PhysActor; 2263 // this is not real geometric center but a average of positions relative to root prim acording to
2314 2264 // http://wiki.secondlife.com/wiki/llGetGeometricCenter
2315 if (pa != null) 2265 // ignoring tortured prims details since sl also seems to ignore
2316 { 2266 // so no real use in doing it on physics
2317 Vector3 vtmp = pa.CenterOfMass; 2267 if (ParentGroup.IsDeleted)
2318 return vtmp;
2319 }
2320 else
2321 return new Vector3(0, 0, 0); 2268 return new Vector3(0, 0, 0);
2269
2270 return ParentGroup.GetGeometricCenter();
2271
2272 /*
2273 PhysicsActor pa = PhysActor;
2274
2275 if (pa != null)
2276 {
2277 Vector3 vtmp = pa.CenterOfMass;
2278 return vtmp;
2279 }
2280 else
2281 return new Vector3(0, 0, 0);
2282 */
2322 } 2283 }
2323 2284
2324 public float GetMass() 2285 public float GetMass()
2325 { 2286 {
2326 PhysicsActor pa = PhysActor; 2287 PhysicsActor pa = PhysActor;
2327 2288
@@ -4628,7 +4589,6 @@ namespace OpenSim.Region.Framework.Scenes
4628 /// <param name="SetTemporary"></param> 4589 /// <param name="SetTemporary"></param>
4629 /// <param name="SetPhantom"></param> 4590 /// <param name="SetPhantom"></param>
4630 /// <param name="SetVD"></param> 4591 /// <param name="SetVD"></param>
4631// public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD)
4632 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) 4592 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building)
4633 { 4593 {
4634 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); 4594 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0);
@@ -4639,209 +4599,92 @@ namespace OpenSim.Region.Framework.Scenes
4639 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4599 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4640 return; 4600 return;
4641 4601
4642 // do this first
4643 if (building && PhysActor != null && PhysActor.Building != building)
4644 PhysActor.Building = building;
4645
4646 // Special cases for VD. VD can only be called from a script
4647 // and can't be combined with changes to other states. So we can rely
4648 // that...
4649 // ... if VD is changed, all others are not.
4650 // ... if one of the others is changed, VD is not.
4651
4652/*
4653 if (SetVD) // VD is active, special logic applies
4654
4655 volume detection is now independent of phantom in sl
4656
4657 {
4658 // State machine logic for VolumeDetect
4659 // More logic below
4660
4661
4662 bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom;
4663
4664 if (phanReset) // Phantom changes from on to off switch VD off too
4665 {
4666 SetVD = false; // Switch it of for the course of this routine
4667 VolumeDetectActive = false; // and also permanently
4668 if (PhysActor != null)
4669 PhysActor.SetVolumeDetect(0); // Let physics know about it too
4670 }
4671 else
4672 {
4673 // If volumedetect is active we don't want phantom to be applied.
4674 // If this is a new call to VD out of the state "phantom"
4675 // this will also cause the prim to be visible to physics
4676 SetPhantom = false;
4677 }
4678 }
4679 else if (wasVD)
4680 {
4681 // Correspondingly, if VD is turned off, also turn off phantom
4682 SetPhantom = false;
4683 }
4684
4685 if (UsePhysics && IsJoint())
4686 {
4687 SetPhantom = true;
4688 }
4689*/
4690 if (UsePhysics) 4602 if (UsePhysics)
4691 {
4692 AddFlag(PrimFlags.Physics); 4603 AddFlag(PrimFlags.Physics);
4693/*
4694 if (!wasUsingPhysics)
4695 {
4696 DoPhysicsPropertyUpdate(UsePhysics, false);
4697
4698 if (!ParentGroup.IsDeleted)
4699 {
4700 if (LocalId == ParentGroup.RootPart.LocalId)
4701 {
4702 ParentGroup.CheckSculptAndLoad();
4703 }
4704 }
4705 }
4706 */
4707 }
4708 else 4604 else
4709 {
4710 RemFlag(PrimFlags.Physics); 4605 RemFlag(PrimFlags.Physics);
4711/*
4712 if (wasUsingPhysics)
4713 {
4714 DoPhysicsPropertyUpdate(UsePhysics, false);
4715 }
4716*/
4717 }
4718 4606
4719 if (SetPhantom) 4607 if (SetPhantom)
4720 AddFlag(PrimFlags.Phantom); 4608 AddFlag(PrimFlags.Phantom);
4721 else 4609 else
4722 RemFlag(PrimFlags.Phantom); 4610 RemFlag(PrimFlags.Phantom);
4723 4611
4612 if (SetTemporary)
4613 AddFlag(PrimFlags.TemporaryOnRez);
4614 else
4615 RemFlag(PrimFlags.TemporaryOnRez);
4616
4617 VolumeDetectActive = SetVD;
4618
4619 if (ParentGroup.Scene == null)
4620 return;
4621
4622 PhysicsActor pa = PhysActor;
4623
4624 if (pa != null && building && pa.Building != building)
4625 pa.Building = building;
4626
4724 if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none 4627 if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none
4725 || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints 4628 || (Shape.PathCurve == (byte)Extrusion.Flexible))
4726 { 4629 {
4727// AddFlag(PrimFlags.Phantom); 4630 if (pa != null)
4631 {
4632 ParentGroup.Scene.RemovePhysicalPrim(1);
4633 RemoveFromPhysics();
4634 }
4728 4635
4729 Velocity = new Vector3(0, 0, 0); 4636 Velocity = new Vector3(0, 0, 0);
4730 Acceleration = new Vector3(0, 0, 0); 4637 Acceleration = new Vector3(0, 0, 0);
4731 if (ParentGroup.RootPart == this) 4638 if (ParentGroup.RootPart == this)
4732 AngularVelocity = new Vector3(0, 0, 0); 4639 AngularVelocity = new Vector3(0, 0, 0);
4733
4734 if (PhysActor != null)
4735 {
4736 ParentGroup.Scene.RemovePhysicalPrim(1);
4737 RemoveFromPhysics();
4738 }
4739 } 4640 }
4740 else 4641 else
4741 { 4642 {
4742 if (ParentGroup.Scene == null)
4743 return;
4744
4745 if (ParentGroup.Scene.CollidablePrims) 4643 if (ParentGroup.Scene.CollidablePrims)
4746 { 4644 {
4747 if (PhysActor == null) 4645 if (pa == null)
4748 { 4646 {
4749 PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( 4647 AddToPhysics(UsePhysics, SetPhantom, building , false);
4750 string.Format("{0}/{1}", Name, UUID), 4648 pa = PhysActor;
4751 Shape, 4649
4752 AbsolutePosition, 4650 if (pa != null)
4753 Scale,
4754 GetWorldRotation(), //physics wants world rotation like all other functions send
4755 UsePhysics,
4756 SetPhantom,
4757 PhysicsShapeType,
4758 m_localId);
4759
4760 PhysActor.SetMaterial(Material);
4761
4762 // if root part apply vehicle
4763 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId)
4764 m_vehicle.SetVehicle(PhysActor);
4765
4766 DoPhysicsPropertyUpdate(UsePhysics, true);
4767
4768 if (!ParentGroup.IsDeleted)
4769 { 4651 {
4770 if (LocalId == ParentGroup.RootPart.LocalId) 4652 if (
4653// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4654// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4655// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4656// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4657// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4658// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4659 ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
4660// (CollisionSound != UUID.Zero)
4661 )
4771 { 4662 {
4772 ParentGroup.CheckSculptAndLoad(); 4663 pa.OnCollisionUpdate += PhysicsCollision;
4664 pa.SubscribeEvents(1000);
4773 } 4665 }
4774 } 4666 }
4775
4776 if (
4777 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4778 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4779 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4780 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4781 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4782 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4783 (CollisionSound != UUID.Zero)
4784 )
4785 {
4786 PhysActor.OnCollisionUpdate += PhysicsCollision;
4787 PhysActor.SubscribeEvents(1000);
4788 }
4789 } 4667 }
4668
4790 else // it already has a physical representation 4669 else // it already has a physical representation
4791 { 4670 {
4792 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. 4671 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
4793 4672
4794 if (!ParentGroup.IsDeleted) 4673 if(VolumeDetectActive)
4795 { 4674 pa.SetVolumeDetect(1);
4796 if (LocalId == ParentGroup.RootPart.LocalId) 4675 else
4797 { 4676 pa.SetVolumeDetect(0);
4798 ParentGroup.CheckSculptAndLoad();
4799 }
4800 }
4801 }
4802 }
4803 }
4804 4677
4805 PhysicsActor pa = PhysActor; 4678 if (pa.Building != building)
4806 if (SetVD) 4679 pa.Building = building;
4807 { 4680 }
4808 // If the above logic worked (this is urgent candidate to unit tests!)
4809 // we now have a physicsactor.
4810 // Defensive programming calls for a check here.
4811 // Better would be throwing an exception that could be catched by a unit test as the internal
4812 // logic should make sure, this Physactor is always here.
4813 if (pa != null)
4814 {
4815 pa.SetVolumeDetect(1);
4816// AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
4817 this.VolumeDetectActive = true;
4818 }
4819 }
4820 else
4821 {
4822 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
4823 // (mumbles, well, at least if you have infinte CPU powers :-))
4824 if (pa != null)
4825 {
4826 pa.SetVolumeDetect(0);
4827 this.VolumeDetectActive = false;
4828 } 4681 }
4829 } 4682 }
4830
4831 if (SetTemporary)
4832 {
4833 AddFlag(PrimFlags.TemporaryOnRez);
4834 }
4835 else
4836 {
4837 RemFlag(PrimFlags.TemporaryOnRez);
4838 }
4839 4683
4840 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 4684 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
4841 4685
4842 // and last in case we have a new actor and not building 4686 // and last in case we have a new actor and not building
4843 if (pa != null && pa.Building != building) 4687
4844 pa.Building = building;
4845 if (ParentGroup != null) 4688 if (ParentGroup != null)
4846 { 4689 {
4847 ParentGroup.HasGroupChanged = true; 4690 ParentGroup.HasGroupChanged = true;
@@ -4853,48 +4696,104 @@ namespace OpenSim.Region.Framework.Scenes
4853 4696
4854 /// <summary> 4697 /// <summary>
4855 /// Adds this part to the physics scene. 4698 /// Adds this part to the physics scene.
4699 /// and sets the PhysActor property
4856 /// </summary> 4700 /// </summary>
4857 /// <remarks>This method also sets the PhysActor property.</remarks> 4701 /// <param name="isPhysical">Add this prim as physical.</param>
4858 /// <param name="rigidBody">Add this prim with a rigid body.</param> 4702 /// <param name="isPhantom">Add this prim as phantom.</param>
4859 /// <returns> 4703 /// <param name="building">tells physics to delay full construction of object</param>
4860 /// The physics actor. null if there was a failure. 4704 /// <param name="applyDynamics">applies velocities, force and torque</param>
4861 /// </returns> 4705 private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics)
4862 private PhysicsActor AddToPhysics(bool rigidBody) 4706 {
4863 {
4864 PhysicsActor pa; 4707 PhysicsActor pa;
4865 4708
4709 Vector3 velocity = Velocity;
4710 Vector3 rotationalVelocity = AngularVelocity;;
4711
4866 try 4712 try
4867 { 4713 {
4868 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( 4714 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape(
4869 string.Format("{0}/{1}", Name, UUID), 4715 string.Format("{0}/{1}", Name, UUID),
4870 Shape, 4716 Shape,
4871 AbsolutePosition, 4717 AbsolutePosition,
4872 Scale, 4718 Scale,
4873 RotationOffset, 4719 GetWorldRotation(),
4874 rigidBody, 4720 isPhysical,
4875 m_localId); 4721 isPhantom,
4722 PhysicsShapeType,
4723 m_localId);
4876 } 4724 }
4877 catch 4725 catch (Exception ex)
4878 { 4726 {
4879 m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); 4727 m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message);
4880 pa = null; 4728 pa = null;
4881 } 4729 }
4882 4730
4883 // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical
4884 // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor
4885 // being set.
4886 PhysActor = pa;
4887
4888 // Basic Physics can also return null as well as an exception catch.
4889 if (pa != null) 4731 if (pa != null)
4890 { 4732 {
4891 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info 4733 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
4892 pa.SetMaterial(Material); 4734 pa.SetMaterial(Material);
4893 DoPhysicsPropertyUpdate(rigidBody, true); 4735
4736 if (VolumeDetectActive) // change if not the default only
4737 pa.SetVolumeDetect(1);
4738
4739 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId)
4740 m_vehicle.SetVehicle(pa);
4741
4742 // we are going to tell rest of code about physics so better have this here
4743 PhysActor = pa;
4744
4745 // DoPhysicsPropertyUpdate(isPhysical, true);
4746 // lets expand it here just with what it really needs to do
4747
4748 if (isPhysical)
4749 {
4750 if (ParentGroup.RootPart.KeyframeMotion != null)
4751 ParentGroup.RootPart.KeyframeMotion.Stop();
4752 ParentGroup.RootPart.KeyframeMotion = null;
4753 ParentGroup.Scene.AddPhysicalPrim(1);
4754
4755 pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
4756 pa.OnOutOfBounds += PhysicsOutOfBounds;
4757
4758 if (ParentID != 0 && ParentID != LocalId)
4759 {
4760 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
4761
4762 if (parentPa != null)
4763 {
4764 pa.link(parentPa);
4765 }
4766 }
4767 }
4768
4769 if (applyDynamics)
4770 // do independent of isphysical so parameters get setted (at least some)
4771 {
4772 Velocity = velocity;
4773 AngularVelocity = rotationalVelocity;
4774 pa.Velocity = velocity;
4775 pa.RotationalVelocity = rotationalVelocity;
4776
4777 // if not vehicle and root part apply force and torque
4778 if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE)
4779 && LocalId == ParentGroup.RootPart.LocalId)
4780 {
4781 pa.Force = Force;
4782 pa.Torque = Torque;
4783 }
4784 }
4785
4786 if (Shape.SculptEntry)
4787 CheckSculptAndLoad();
4788 else
4789 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
4790
4791 if (!building)
4792 pa.Building = false;
4894 } 4793 }
4895 4794
4896 return pa; 4795 PhysActor = pa;
4897 } 4796 }
4898 4797
4899 /// <summary> 4798 /// <summary>
4900 /// This removes the part from the physics scene. 4799 /// This removes the part from the physics scene.
@@ -5103,10 +5002,6 @@ namespace OpenSim.Region.Framework.Scenes
5103 PhysicsActor pa = PhysActor; 5002 PhysicsActor pa = PhysActor;
5104 if (pa != null) 5003 if (pa != null)
5105 { 5004 {
5106 const scriptEvents NeededSubsEvents = (
5107 scriptEvents.collision | scriptEvents.collision_start| scriptEvents.collision_end |
5108 scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end
5109 );
5110 if ( 5005 if (
5111// ((AggregateScriptEvents & scriptEvents.collision) != 0) || 5006// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
5112// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || 5007// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
@@ -5114,7 +5009,7 @@ namespace OpenSim.Region.Framework.Scenes
5114// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || 5009// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
5115// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || 5010// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
5116// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || 5011// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
5117 ((AggregateScriptEvents & NeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) 5012 ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
5118 ) 5013 )
5119 { 5014 {
5120 // subscribe to physics updates. 5015 // subscribe to physics updates.