diff options
author | UbitUmarov | 2012-04-09 18:03:37 +0100 |
---|---|---|
committer | UbitUmarov | 2012-04-09 18:03:37 +0100 |
commit | ad544bdd3d37700af7c8d05bafaed7cdd3dd3cd6 (patch) | |
tree | 578e3bf03bde0e1bbeed8229ae68bbf12787031c /OpenSim/Region | |
parent | Fix a LSL merge artefact (diff) | |
download | opensim-SC-ad544bdd3d37700af7c8d05bafaed7cdd3dd3cd6.zip opensim-SC-ad544bdd3d37700af7c8d05bafaed7cdd3dd3cd6.tar.gz opensim-SC-ad544bdd3d37700af7c8d05bafaed7cdd3dd3cd6.tar.bz2 opensim-SC-ad544bdd3d37700af7c8d05bafaed7cdd3dd3cd6.tar.xz |
sop.AddToPhysics(..) fixed and in use. For now it seems it needs to set sop.PhysActor, so made it return void.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 410 |
1 files changed, 147 insertions, 263 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 969ddaf..d419710 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 | ||
@@ -4628,7 +4578,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4628 | /// <param name="SetTemporary"></param> | 4578 | /// <param name="SetTemporary"></param> |
4629 | /// <param name="SetPhantom"></param> | 4579 | /// <param name="SetPhantom"></param> |
4630 | /// <param name="SetVD"></param> | 4580 | /// <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) | 4581 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) |
4633 | { | 4582 | { |
4634 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); | 4583 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); |
@@ -4639,209 +4588,92 @@ namespace OpenSim.Region.Framework.Scenes | |||
4639 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) | 4588 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) |
4640 | return; | 4589 | return; |
4641 | 4590 | ||
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) | 4591 | if (UsePhysics) |
4691 | { | ||
4692 | AddFlag(PrimFlags.Physics); | 4592 | 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 | 4593 | else |
4709 | { | ||
4710 | RemFlag(PrimFlags.Physics); | 4594 | RemFlag(PrimFlags.Physics); |
4711 | /* | ||
4712 | if (wasUsingPhysics) | ||
4713 | { | ||
4714 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4715 | } | ||
4716 | */ | ||
4717 | } | ||
4718 | 4595 | ||
4719 | if (SetPhantom) | 4596 | if (SetPhantom) |
4720 | AddFlag(PrimFlags.Phantom); | 4597 | AddFlag(PrimFlags.Phantom); |
4721 | else | 4598 | else |
4722 | RemFlag(PrimFlags.Phantom); | 4599 | RemFlag(PrimFlags.Phantom); |
4723 | 4600 | ||
4601 | if (SetTemporary) | ||
4602 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4603 | else | ||
4604 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4605 | |||
4606 | VolumeDetectActive = SetVD; | ||
4607 | |||
4608 | if (ParentGroup.Scene == null) | ||
4609 | return; | ||
4610 | |||
4611 | PhysicsActor pa = PhysActor; | ||
4612 | |||
4613 | if (pa != null && building && pa.Building != building) | ||
4614 | pa.Building = building; | ||
4615 | |||
4724 | if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none | 4616 | 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 | 4617 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) |
4726 | { | 4618 | { |
4727 | // AddFlag(PrimFlags.Phantom); | 4619 | if (pa != null) |
4620 | { | ||
4621 | ParentGroup.Scene.RemovePhysicalPrim(1); | ||
4622 | RemoveFromPhysics(); | ||
4623 | } | ||
4728 | 4624 | ||
4729 | Velocity = new Vector3(0, 0, 0); | 4625 | Velocity = new Vector3(0, 0, 0); |
4730 | Acceleration = new Vector3(0, 0, 0); | 4626 | Acceleration = new Vector3(0, 0, 0); |
4731 | if (ParentGroup.RootPart == this) | 4627 | if (ParentGroup.RootPart == this) |
4732 | AngularVelocity = new Vector3(0, 0, 0); | 4628 | AngularVelocity = new Vector3(0, 0, 0); |
4733 | |||
4734 | if (PhysActor != null) | ||
4735 | { | ||
4736 | ParentGroup.Scene.RemovePhysicalPrim(1); | ||
4737 | RemoveFromPhysics(); | ||
4738 | } | ||
4739 | } | 4629 | } |
4740 | else | 4630 | else |
4741 | { | 4631 | { |
4742 | if (ParentGroup.Scene == null) | ||
4743 | return; | ||
4744 | |||
4745 | if (ParentGroup.Scene.CollidablePrims) | 4632 | if (ParentGroup.Scene.CollidablePrims) |
4746 | { | 4633 | { |
4747 | if (PhysActor == null) | 4634 | if (pa == null) |
4748 | { | 4635 | { |
4749 | PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( | 4636 | AddToPhysics(UsePhysics, SetPhantom, building , false); |
4750 | string.Format("{0}/{1}", Name, UUID), | 4637 | pa = PhysActor; |
4751 | Shape, | 4638 | |
4752 | AbsolutePosition, | 4639 | 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 | { | 4640 | { |
4770 | if (LocalId == ParentGroup.RootPart.LocalId) | 4641 | if ( |
4642 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4643 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4644 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4645 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4646 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4647 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4648 | ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | ||
4649 | // (CollisionSound != UUID.Zero) | ||
4650 | ) | ||
4771 | { | 4651 | { |
4772 | ParentGroup.CheckSculptAndLoad(); | 4652 | pa.OnCollisionUpdate += PhysicsCollision; |
4653 | pa.SubscribeEvents(1000); | ||
4773 | } | 4654 | } |
4774 | } | 4655 | } |
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 | } | 4656 | } |
4657 | |||
4790 | else // it already has a physical representation | 4658 | else // it already has a physical representation |
4791 | { | 4659 | { |
4792 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. | 4660 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. |
4793 | 4661 | ||
4794 | if (!ParentGroup.IsDeleted) | 4662 | if(VolumeDetectActive) |
4795 | { | 4663 | pa.SetVolumeDetect(1); |
4796 | if (LocalId == ParentGroup.RootPart.LocalId) | 4664 | else |
4797 | { | 4665 | pa.SetVolumeDetect(0); |
4798 | ParentGroup.CheckSculptAndLoad(); | ||
4799 | } | ||
4800 | } | ||
4801 | } | ||
4802 | } | ||
4803 | } | ||
4804 | 4666 | ||
4805 | PhysicsActor pa = PhysActor; | 4667 | if (pa.Building != building) |
4806 | if (SetVD) | 4668 | pa.Building = building; |
4807 | { | 4669 | } |
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 | } | 4670 | } |
4829 | } | 4671 | } |
4830 | |||
4831 | if (SetTemporary) | ||
4832 | { | ||
4833 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4834 | } | ||
4835 | else | ||
4836 | { | ||
4837 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4838 | } | ||
4839 | 4672 | ||
4840 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | 4673 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); |
4841 | 4674 | ||
4842 | // and last in case we have a new actor and not building | 4675 | // and last in case we have a new actor and not building |
4843 | if (pa != null && pa.Building != building) | 4676 | |
4844 | pa.Building = building; | ||
4845 | if (ParentGroup != null) | 4677 | if (ParentGroup != null) |
4846 | { | 4678 | { |
4847 | ParentGroup.HasGroupChanged = true; | 4679 | ParentGroup.HasGroupChanged = true; |
@@ -4853,48 +4685,104 @@ namespace OpenSim.Region.Framework.Scenes | |||
4853 | 4685 | ||
4854 | /// <summary> | 4686 | /// <summary> |
4855 | /// Adds this part to the physics scene. | 4687 | /// Adds this part to the physics scene. |
4688 | /// and sets the PhysActor property | ||
4856 | /// </summary> | 4689 | /// </summary> |
4857 | /// <remarks>This method also sets the PhysActor property.</remarks> | 4690 | /// <param name="isPhysical">Add this prim as physical.</param> |
4858 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | 4691 | /// <param name="isPhantom">Add this prim as phantom.</param> |
4859 | /// <returns> | 4692 | /// <param name="building">tells physics to delay full construction of object</param> |
4860 | /// The physics actor. null if there was a failure. | 4693 | /// <param name="applyDynamics">applies velocities, force and torque</param> |
4861 | /// </returns> | 4694 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) |
4862 | private PhysicsActor AddToPhysics(bool rigidBody) | 4695 | { |
4863 | { | ||
4864 | PhysicsActor pa; | 4696 | PhysicsActor pa; |
4865 | 4697 | ||
4698 | Vector3 velocity = Velocity; | ||
4699 | Vector3 rotationalVelocity = AngularVelocity;; | ||
4700 | |||
4866 | try | 4701 | try |
4867 | { | 4702 | { |
4868 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | 4703 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( |
4869 | string.Format("{0}/{1}", Name, UUID), | 4704 | string.Format("{0}/{1}", Name, UUID), |
4870 | Shape, | 4705 | Shape, |
4871 | AbsolutePosition, | 4706 | AbsolutePosition, |
4872 | Scale, | 4707 | Scale, |
4873 | RotationOffset, | 4708 | GetWorldRotation(), |
4874 | rigidBody, | 4709 | isPhysical, |
4875 | m_localId); | 4710 | isPhantom, |
4711 | PhysicsShapeType, | ||
4712 | m_localId); | ||
4876 | } | 4713 | } |
4877 | catch | 4714 | catch (Exception ex) |
4878 | { | 4715 | { |
4879 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); | 4716 | m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message); |
4880 | pa = null; | 4717 | pa = null; |
4881 | } | 4718 | } |
4882 | 4719 | ||
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) | 4720 | if (pa != null) |
4890 | { | 4721 | { |
4891 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | 4722 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info |
4892 | pa.SetMaterial(Material); | 4723 | pa.SetMaterial(Material); |
4893 | DoPhysicsPropertyUpdate(rigidBody, true); | 4724 | |
4725 | if (VolumeDetectActive) // change if not the default only | ||
4726 | pa.SetVolumeDetect(1); | ||
4727 | |||
4728 | if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) | ||
4729 | m_vehicle.SetVehicle(pa); | ||
4730 | |||
4731 | // we are going to tell rest of code about physics so better have this here | ||
4732 | PhysActor = pa; | ||
4733 | |||
4734 | // DoPhysicsPropertyUpdate(isPhysical, true); | ||
4735 | // lets expand it here just with what it really needs to do | ||
4736 | |||
4737 | if (isPhysical) | ||
4738 | { | ||
4739 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
4740 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
4741 | ParentGroup.RootPart.KeyframeMotion = null; | ||
4742 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
4743 | |||
4744 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | ||
4745 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
4746 | |||
4747 | if (ParentID != 0 && ParentID != LocalId) | ||
4748 | { | ||
4749 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | ||
4750 | |||
4751 | if (parentPa != null) | ||
4752 | { | ||
4753 | pa.link(parentPa); | ||
4754 | } | ||
4755 | } | ||
4756 | } | ||
4757 | |||
4758 | if (applyDynamics) | ||
4759 | // do independent of isphysical so parameters get setted (at least some) | ||
4760 | { | ||
4761 | Velocity = velocity; | ||
4762 | AngularVelocity = rotationalVelocity; | ||
4763 | pa.Velocity = velocity; | ||
4764 | pa.RotationalVelocity = rotationalVelocity; | ||
4765 | |||
4766 | // if not vehicle and root part apply force and torque | ||
4767 | if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) | ||
4768 | && LocalId == ParentGroup.RootPart.LocalId) | ||
4769 | { | ||
4770 | pa.Force = Force; | ||
4771 | pa.Torque = Torque; | ||
4772 | } | ||
4773 | } | ||
4774 | |||
4775 | if (Shape.SculptEntry) | ||
4776 | CheckSculptAndLoad(); | ||
4777 | else | ||
4778 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
4779 | |||
4780 | if (!building) | ||
4781 | pa.Building = false; | ||
4894 | } | 4782 | } |
4895 | 4783 | ||
4896 | return pa; | 4784 | PhysActor = pa; |
4897 | } | 4785 | } |
4898 | 4786 | ||
4899 | /// <summary> | 4787 | /// <summary> |
4900 | /// This removes the part from the physics scene. | 4788 | /// This removes the part from the physics scene. |
@@ -5103,10 +4991,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
5103 | PhysicsActor pa = PhysActor; | 4991 | PhysicsActor pa = PhysActor; |
5104 | if (pa != null) | 4992 | if (pa != null) |
5105 | { | 4993 | { |
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 ( | 4994 | if ( |
5111 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | 4995 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || |
5112 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | 4996 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || |
@@ -5114,7 +4998,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5114 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | 4998 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || |
5115 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | 4999 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || |
5116 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | 5000 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || |
5117 | ((AggregateScriptEvents & NeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | 5001 | ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) |
5118 | ) | 5002 | ) |
5119 | { | 5003 | { |
5120 | // subscribe to physics updates. | 5004 | // subscribe to physics updates. |