From a97f6f86680026de6350f301d52307c187726875 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 7 Sep 2013 13:11:31 -0400 Subject: Fix configuration/ini expansion issue. Thanks to smxy for testing. --- OpenSim/Region/Application/ConfigurationLoader.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index bc7ecb7..010ae5a 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs @@ -203,10 +203,10 @@ namespace OpenSim m_config.Source.Merge(envConfigSource); } - ReadConfigSettings(); - m_config.Source.ExpandKeyValues(); + ReadConfigSettings(); + return m_config; } -- cgit v1.1 From b05cb3b2bfd6f3912fb33a790b7c2d1ed898d539 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 9 Sep 2013 14:47:49 -0700 Subject: Change collision logic in SceneObjectPart so land_collision will happen. The previous logic would generate land_collision_start and land_collision_end but would not generate the land_collision itself. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c9ff4f3..2e11162 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2464,12 +2464,9 @@ namespace OpenSim.Region.Framework.Scenes SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); if (startedColliders.Contains(0)) - { - if (m_lastColliders.Contains(0)) - SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); - else - SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); - } + SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); + if (m_lastColliders.Contains(0)) + SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); if (endedColliders.Contains(0)) SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); } -- cgit v1.1 From 725751fd6c0101b8610e84716d28b6af91e20b61 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 6 Aug 2013 10:32:56 -0700 Subject: BulletSim: fixes for change linkset implementation of physical linksets. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 29 +++++++++++++++++++++- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 6 ++--- .../Physics/BulletSPlugin/BSLinksetCompound.cs | 14 +++++------ .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 8 +++--- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 11 +++++--- 5 files changed, 50 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index d1d318c..4455df4 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -29,6 +29,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; +using System.Threading; using OpenSim.Framework; using OpenSim.Region.CoreModules; @@ -198,7 +199,33 @@ public class ExtendedPhysics : INonSharedRegionModule Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; if (rootPhysActor != null) { - ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + if (rootPhysActor.IsPhysical) + { + // Change a physical linkset by making non-physical, waiting for one heartbeat so all + // the prim and linkset state is updated, changing the type and making the + // linkset physical again. + containingGroup.ScriptSetPhysicsStatus(false); + Thread.Sleep(150); // longer than one heartbeat tick + + // A kludge for the moment. + // Since compound linksets move the children but don't generate position updates to the + // simulator, it is possible for compound linkset children to have out-of-sync simulator + // and physical positions. The following causes the simulator to push the real child positions + // down into the physics engine to get everything synced. + containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition); + containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation); + + ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + Thread.Sleep(150); // longer than one heartbeat tick + + containingGroup.ScriptSetPhysicsStatus(true); + } + else + { + // Non-physical linksets don't have a physical instantiation so there is no state to + // worry about being updated. + ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + } } else { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 3afd52e..a051002 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -148,7 +148,7 @@ public abstract class BSLinkset // Returns a new linkset for the child which is a linkset of one (just the // orphened child). // Called at runtime. - public BSLinkset RemoveMeFromLinkset(BSPrimLinkable child) + public BSLinkset RemoveMeFromLinkset(BSPrimLinkable child, bool inTaintTime) { lock (m_linksetActivityLock) { @@ -157,7 +157,7 @@ public abstract class BSLinkset // Cannot remove the root from a linkset. return this; } - RemoveChildFromLinkset(child); + RemoveChildFromLinkset(child, inTaintTime); LinksetMass = ComputeLinksetMass(); } @@ -255,7 +255,7 @@ public abstract class BSLinkset // I am the root of a linkset and one of my children is being removed. // Safe to call even if the child is not really in my linkset. - protected abstract void RemoveChildFromLinkset(BSPrimLinkable child); + protected abstract void RemoveChildFromLinkset(BSPrimLinkable child, bool inTaintTime); // When physical properties are changed the linkset needs to recalculate // its internal properties. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 085d195..47ab842 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -242,7 +242,7 @@ public sealed class BSLinksetCompound : BSLinkset { bool ret = false; - DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}", + DetailLog("{0},BSLinksetCompound.RemoveDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}", child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody, IsRoot(child)); ScheduleRebuild(child); @@ -270,7 +270,7 @@ public sealed class BSLinksetCompound : BSLinkset // Remove the specified child from the linkset. // Safe to call even if the child is not really in the linkset. - protected override void RemoveChildFromLinkset(BSPrimLinkable child) + protected override void RemoveChildFromLinkset(BSPrimLinkable child, bool inTaintTime) { child.ClearDisplacement(); @@ -282,12 +282,12 @@ public sealed class BSLinksetCompound : BSLinkset child.LocalID, child.PhysBody.AddrString); // Cause the child's body to be rebuilt and thus restored to normal operation - child.ForceBodyShapeRebuild(false); + child.ForceBodyShapeRebuild(inTaintTime); if (!HasAnyChildren) { // The linkset is now empty. The root needs rebuilding. - LinksetRoot.ForceBodyShapeRebuild(false); + LinksetRoot.ForceBodyShapeRebuild(inTaintTime); } else { @@ -318,10 +318,10 @@ public sealed class BSLinksetCompound : BSLinkset // being destructed and going non-physical. LinksetRoot.ForceBodyShapeRebuild(true); - // There is no reason to build all this physical stuff for a non-physical linkset. - if (!LinksetRoot.IsPhysicallyActive) + // There is no reason to build all this physical stuff for a non-physical or empty linkset. + if (!LinksetRoot.IsPhysicallyActive || !HasAnyChildren) { - DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); + DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,notPhysicalOrNoChildren", LinksetRoot.LocalID); return; // Note the 'finally' clause at the botton which will get executed. } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 4bac222..d4ee27d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -224,7 +224,7 @@ public sealed class BSLinksetConstraints : BSLinkset // Remove the specified child from the linkset. // Safe to call even if the child is not really in my linkset. - protected override void RemoveChildFromLinkset(BSPrimLinkable child) + protected override void RemoveChildFromLinkset(BSPrimLinkable child, bool inTaintTime) { if (m_children.Remove(child)) { @@ -236,7 +236,7 @@ public sealed class BSLinksetConstraints : BSLinkset rootx.LocalID, rootx.PhysBody.AddrString, childx.LocalID, childx.PhysBody.AddrString); - m_physicsScene.TaintedObject("BSLinksetConstraints.RemoveChildFromLinkset", delegate() + m_physicsScene.TaintedObject(inTaintTime, "BSLinksetConstraints.RemoveChildFromLinkset", delegate() { PhysicallyUnlinkAChildFromRoot(rootx, childx); }); @@ -382,9 +382,9 @@ public sealed class BSLinksetConstraints : BSLinkset Rebuilding = true; // There is no reason to build all this physical stuff for a non-physical linkset. - if (!LinksetRoot.IsPhysicallyActive) + if (!LinksetRoot.IsPhysicallyActive || !HasAnyChildren) { - DetailLog("{0},BSLinksetConstraint.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); + DetailLog("{0},BSLinksetConstraint.RecomputeLinksetCompound,notPhysicalOrNoChildren", LinksetRoot.LocalID); return; // Note the 'finally' clause at the botton which will get executed. } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 7179a6d..38d1f88 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -66,7 +66,7 @@ public class BSPrimLinkable : BSPrimDisplaced public override void Destroy() { - Linkset = Linkset.RemoveMeFromLinkset(this); + Linkset = Linkset.RemoveMeFromLinkset(this, false /* inTaintTime */); base.Destroy(); } @@ -94,7 +94,7 @@ public class BSPrimLinkable : BSPrimDisplaced BSPhysObject parentBefore = Linkset.LinksetRoot; // DEBUG int childrenBefore = Linkset.NumberOfChildren; // DEBUG - Linkset = Linkset.RemoveMeFromLinkset(this); + Linkset = Linkset.RemoveMeFromLinkset(this, false /* inTaintTime*/); DetailLog("{0},BSPrimLinkset.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ", LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren); @@ -240,6 +240,8 @@ public class BSPrimLinkable : BSPrimDisplaced bool ret = false; if (LinksetType != newType) { + DetailLog("{0},BSPrimLinkset.ConvertLinkset,oldT={1},newT={2}", LocalID, LinksetType, newType); + // Set the implementation type first so the call to BSLinkset.Factory gets the new type. this.LinksetType = newType; @@ -263,7 +265,10 @@ public class BSPrimLinkable : BSPrimDisplaced // Remove the children from the old linkset and add to the new (will be a new instance from the factory) foreach (BSPrimLinkable child in children) { - oldLinkset.RemoveMeFromLinkset(child); + oldLinkset.RemoveMeFromLinkset(child, true /*inTaintTime*/); + } + foreach (BSPrimLinkable child in children) + { newLinkset.AddMeToLinkset(child); child.Linkset = newLinkset; } -- cgit v1.1 From 48ee73bfa771de64685a694417b34188f0a3350e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Aug 2013 07:54:47 -0700 Subject: BulletSim: add API and calls for spring constraint parameters. --- OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs | 36 ++++++++++++++++++++ OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs | 38 ++++++++++++++++++++++ .../Region/Physics/BulletSPlugin/BSApiTemplate.cs | 8 +++++ 3 files changed, 82 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs index 12a0c17..6c36485 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs @@ -596,6 +596,30 @@ public override bool SetBreakingImpulseThreshold(BulletConstraint constrain, flo return BSAPICPP.SetBreakingImpulseThreshold2(constrainu.ptr, threshold); } +public override bool SpringEnable(BulletConstraint constrain, int index, float numericTrueFalse) +{ + BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; + return BSAPICPP.ConstraintSpringEnable2(constrainu.ptr, index, numericTrueFalse); +} + +public override bool SpringSetEquilibriumPoint(BulletConstraint constrain, int index, float equilibriumPoint) +{ + BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; + return BSAPICPP.ConstraintSpringSetEquilibriumPoint2(constrainu.ptr, index, equilibriumPoint); +} + +public override bool SpringSetStiffness(BulletConstraint constrain, int index, float stiffnesss) +{ + BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; + return BSAPICPP.ConstraintSpringSetStiffness2(constrainu.ptr, index, stiffnesss); +} + +public override bool SpringSetDamping(BulletConstraint constrain, int index, float damping) +{ + BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; + return BSAPICPP.ConstraintSpringSetDamping2(constrainu.ptr, index, damping); +} + public override bool CalculateTransforms(BulletConstraint constrain) { BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; @@ -1601,6 +1625,18 @@ public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enabl public static extern bool SetBreakingImpulseThreshold2(IntPtr constrain, float threshold); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool ConstraintSpringEnable2(IntPtr constrain, int index, float numericTrueFalse); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool ConstraintSpringSetEquilibriumPoint2(IntPtr constrain, int index, float equilibriumPoint); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool ConstraintSpringSetStiffness2(IntPtr constrain, int index, float stiffness); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool ConstraintSpringSetDamping2(IntPtr constrain, int index, float damping); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool CalculateTransforms2(IntPtr constrain); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs index 2a820be..9ad12a9 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs @@ -752,6 +752,44 @@ private sealed class BulletConstraintXNA : BulletConstraint constraint.SetBreakingImpulseThreshold(threshold); return true; } + public override bool SpringEnable(BulletConstraint pConstraint, int index, float numericTrueFalse) + { + Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint; + constraint.EnableSpring(index, (numericTrueFalse == 0f ? false : true)); + return true; + } + + public override bool SpringSetEquilibriumPoint(BulletConstraint pConstraint, int index, float equilibriumPoint) + { + Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint; + if (index == -1) + { + constraint.SetEquilibriumPoint(); + } + else + { + if (equilibriumPoint == -1) + constraint.SetEquilibriumPoint(index); + else + constraint.SetEquilibriumPoint(index, equilibriumPoint); + } + return true; + } + + public override bool SpringSetStiffness(BulletConstraint pConstraint, int index, float stiffness) + { + Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint; + constraint.SetStiffness(index, stiffness); + return true; + } + + public override bool SpringSetDamping(BulletConstraint pConstraint, int index, float damping) + { + Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint; + constraint.SetDamping(index, damping); + return true; + } + //BulletSimAPI.SetAngularDamping(Prim.PhysBody.ptr, angularDamping); public override void SetAngularDamping(BulletBody pBody, float angularDamping) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs index 6cdc112..8cca29f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs @@ -441,6 +441,14 @@ public abstract bool TranslationalLimitMotor(BulletConstraint constrain, float e public abstract bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold); +public abstract bool SpringEnable(BulletConstraint constrain, int index, float numericTrueFalse); + +public abstract bool SpringSetEquilibriumPoint(BulletConstraint constrain, int index, float equilibriumPoint); + +public abstract bool SpringSetStiffness(BulletConstraint constrain, int index, float stiffnesss); + +public abstract bool SpringSetDamping(BulletConstraint constrain, int index, float damping); + public abstract bool CalculateTransforms(BulletConstraint constrain); public abstract bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis); -- cgit v1.1 From 9a7d0e489cf726f00379917cd507839d5fe56725 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Aug 2013 07:55:46 -0700 Subject: BulletSim: add spring constraint to linkset constraint types. --- .../Physics/BulletSPlugin/BSConstraintSpring.cs | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs new file mode 100755 index 0000000..01d67d4 --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs @@ -0,0 +1,85 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyrightD + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.BulletSPlugin +{ + +public sealed class BSConstraintSpring : BSConstraint6Dof +{ + public override ConstraintType Type { get { return ConstraintType.D6_SPRING_CONSTRAINT_TYPE; } } + + public BSConstraintSpring(BulletWorld world, BulletBody obj1, BulletBody obj2, + Vector3 frame1Loc, Quaternion frame1Rot, + Vector3 frame2Loc, Quaternion frame2Rot, + bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) + :base(world, obj1, obj2) + { + m_constraint = PhysicsScene.PE.Create6DofSpringConstraint(world, obj1, obj2, + frame1Loc, frame1Rot, frame2Loc, frame2Rot, + useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); + m_enabled = true; + + world.physicsScene.DetailLog("{0},BSConstraintSpring,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", + BSScene.DetailLogZero, world.worldID, + obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); + } + + public bool SetEnable(int index, bool axisEnable) + { + bool ret = false; + + return ret; + } + + public bool SetStiffness(int index, float stiffness) + { + bool ret = false; + + return ret; + } + + public bool SetDamping(int index, float damping) + { + bool ret = false; + + return ret; + } + + public bool SetEquilibriumPoint(int index, float eqPoint) + { + bool ret = false; + + return ret; + } + +} + +} \ No newline at end of file -- cgit v1.1 From 0971c7ae77cae3d238be31f46994b4692af949e3 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Aug 2013 07:56:37 -0700 Subject: BulletSim: complete linkage of spring constraint into linkset constraint. --- .../Physics/BulletSPlugin/BSConstraint6Dof.cs | 9 ++- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 2 + .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 81 ++++++++++++++++++---- 3 files changed, 77 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs index d0949f5..5008ff7 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs @@ -32,12 +32,19 @@ using OpenMetaverse; namespace OpenSim.Region.Physics.BulletSPlugin { -public sealed class BSConstraint6Dof : BSConstraint +public class BSConstraint6Dof : BSConstraint { private static string LogHeader = "[BULLETSIM 6DOF CONSTRAINT]"; public override ConstraintType Type { get { return ConstraintType.D6_CONSTRAINT_TYPE; } } + public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2) :base(world) + { + m_body1 = obj1; + m_body2 = obj2; + m_enabled = false; + } + // Create a btGeneric6DofConstraint public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2, Vector3 frame1, Quaternion frame1rot, diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index a051002..d4b1c1e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -77,6 +77,8 @@ public abstract class BSLinkset { member = pMember; } + public virtual void ResetLink() { } + public virtual void SetLinkParameters(BSConstraint constrain) { } } public LinksetImplementation LinksetImpl { get; protected set; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index d4ee27d..f3b70c3 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -51,16 +51,26 @@ public sealed class BSLinksetConstraints : BSLinkset public float cfm; public float erp; public float solverIterations; + // + public OMV.Vector3 frameInAloc; + public OMV.Quaternion frameInArot; + public OMV.Vector3 frameInBloc; + public OMV.Quaternion frameInBrot; + // Spring + public float springDamping; + public float springStiffness; + + public BSLinkInfoConstraint(BSPrimLinkable pMember) : base(pMember) { constraint = null; - ResetToFixedConstraint(); + ResetLink(); } // Set all the parameters for this constraint to a fixed, non-movable constraint. - public void ResetToFixedConstraint() + public override void ResetLink() { constraintType = ConstraintType.D6_CONSTRAINT_TYPE; linearLimitLow = OMV.Vector3.Zero; @@ -74,10 +84,16 @@ public sealed class BSLinksetConstraints : BSLinkset cfm = BSParam.LinkConstraintCFM; erp = BSParam.LinkConstraintERP; solverIterations = BSParam.LinkConstraintSolverIterations; + frameInAloc = OMV.Vector3.Zero; + frameInArot = OMV.Quaternion.Identity; + frameInBloc = OMV.Vector3.Zero; + frameInBrot = OMV.Quaternion.Identity; + springDamping = -1f; + springStiffness = -1f; } // Given a constraint, apply the current constraint parameters to same. - public void SetConstraintParameters(BSConstraint constrain) + public override void SetLinkParameters(BSConstraint constrain) { switch (constraintType) { @@ -85,6 +101,7 @@ public sealed class BSLinksetConstraints : BSLinkset BSConstraint6Dof constrain6dof = constrain as BSConstraint6Dof; if (constrain6dof != null) { + // NOTE: D6_SPRING_CONSTRAINT_TYPE should be updated if you change any of this code. // zero linear and angular limits makes the objects unable to move in relation to each other constrain6dof.SetLinearLimits(linearLimitLow, linearLimitHigh); constrain6dof.SetAngularLimits(angularLimitLow, angularLimitHigh); @@ -99,6 +116,31 @@ public sealed class BSLinksetConstraints : BSLinkset } } break; + case ConstraintType.D6_SPRING_CONSTRAINT_TYPE: + BSConstraintSpring constrainSpring = constrain as BSConstraintSpring; + if (constrainSpring != null) + { + // zero linear and angular limits makes the objects unable to move in relation to each other + constrainSpring.SetLinearLimits(linearLimitLow, linearLimitHigh); + constrainSpring.SetAngularLimits(angularLimitLow, angularLimitHigh); + + // tweek the constraint to increase stability + constrainSpring.UseFrameOffset(useFrameOffset); + constrainSpring.TranslationalLimitMotor(enableTransMotor, transMotorMaxVel, transMotorMaxForce); + constrainSpring.SetCFMAndERP(cfm, erp); + if (solverIterations != 0f) + { + constrainSpring.SetSolverIterations(solverIterations); + } + for (int ii = 0; ii < 6; ii++) + { + if (springDamping != -1) + constrainSpring.SetDamping(ii, springDamping); + if (springStiffness != -1) + constrainSpring.SetStiffness(ii, springStiffness); + } + } + break; default: break; } @@ -262,8 +304,8 @@ public sealed class BSLinksetConstraints : BSLinkset // Create a static constraint between the two passed objects private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSLinkInfo li) { - BSLinkInfoConstraint liConstraint = li as BSLinkInfoConstraint; - if (liConstraint == null) + BSLinkInfoConstraint linkInfo = li as BSLinkInfoConstraint; + if (linkInfo == null) return null; // Zero motion for children so they don't interpolate @@ -271,27 +313,25 @@ public sealed class BSLinksetConstraints : BSLinkset BSConstraint constrain = null; - switch (liConstraint.constraintType) + switch (linkInfo.constraintType) { case ConstraintType.D6_CONSTRAINT_TYPE: // Relative position normalized to the root prim // Essentually a vector pointing from center of rootPrim to center of li.member - OMV.Vector3 childRelativePosition = liConstraint.member.Position - rootPrim.Position; + OMV.Vector3 childRelativePosition = linkInfo.member.Position - rootPrim.Position; // real world coordinate of midpoint between the two objects OMV.Vector3 midPoint = rootPrim.Position + (childRelativePosition / 2); - DetailLog("{0},BSLinksetConstraint.BuildConstraint,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", - rootPrim.LocalID, - rootPrim.LocalID, rootPrim.PhysBody.AddrString, - liConstraint.member.LocalID, liConstraint.member.PhysBody.AddrString, - rootPrim.Position, liConstraint.member.Position, midPoint); + DetailLog("{0},BSLinksetConstraint.BuildConstraint,6Dof,rBody={1},cBody={2},rLoc={3},cLoc={4},midLoc={7}", + rootPrim.LocalID, rootPrim.PhysBody, linkInfo.member.PhysBody, + rootPrim.Position, linkInfo.member.Position, midPoint); // create a constraint that allows no freedom of movement between the two objects // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 constrain = new BSConstraint6Dof( - m_physicsScene.World, rootPrim.PhysBody, liConstraint.member.PhysBody, midPoint, true, true ); + m_physicsScene.World, rootPrim.PhysBody, linkInfo.member.PhysBody, midPoint, true, true ); /* NOTE: below is an attempt to build constraint with full frame computation, etc. * Using the midpoint is easier since it lets the Bullet code manipulate the transforms @@ -320,11 +360,23 @@ public sealed class BSLinksetConstraints : BSLinkset */ break; + case ConstraintType.D6_SPRING_CONSTRAINT_TYPE: + constrain = new BSConstraintSpring(m_physicsScene.World, rootPrim.PhysBody, linkInfo.member.PhysBody, + linkInfo.frameInAloc, linkInfo.frameInArot, linkInfo.frameInBloc, linkInfo.frameInBrot, + true /*useLinearReferenceFrameA*/, + true /*disableCollisionsBetweenLinkedBodies*/); + DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", + rootPrim.LocalID, + rootPrim.LocalID, rootPrim.PhysBody.AddrString, + linkInfo.member.LocalID, linkInfo.member.PhysBody.AddrString, + rootPrim.Position, linkInfo.member.Position); + + break; default: break; } - liConstraint.SetConstraintParameters(constrain); + linkInfo.SetLinkParameters(constrain); m_physicsScene.Constraints.AddConstraint(constrain); @@ -401,6 +453,7 @@ public sealed class BSLinksetConstraints : BSLinkset // If constraint doesn't exist yet, create it. constrain = BuildConstraint(LinksetRoot, li); } + li.SetLinkParameters(constrain); constrain.RecomputeConstraintVariables(linksetMass); // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG -- cgit v1.1 From 993bcec088ce5c3ec2f76f61842f19cbdcc89384 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Aug 2013 10:15:28 -0700 Subject: BulletSim: add unmanaged and XNA functions for hinge, slider and spring constraints. --- OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs | 45 ++++++ OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs | 174 ++++++++++++++++++++- .../Region/Physics/BulletSPlugin/BSApiTemplate.cs | 24 +++ 3 files changed, 241 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs index 6c36485..8dfb01c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs @@ -596,6 +596,12 @@ public override bool SetBreakingImpulseThreshold(BulletConstraint constrain, flo return BSAPICPP.SetBreakingImpulseThreshold2(constrainu.ptr, threshold); } +public override bool HingeSetLimits(BulletConstraint constrain, float low, float high, float softness, float bias, float relaxation) +{ + BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; + return BSAPICPP.HingeSetLimits2(constrainu.ptr, low, high, softness, bias, relaxation); +} + public override bool SpringEnable(BulletConstraint constrain, int index, float numericTrueFalse) { BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; @@ -620,6 +626,30 @@ public override bool SpringSetDamping(BulletConstraint constrain, int index, flo return BSAPICPP.ConstraintSpringSetDamping2(constrainu.ptr, index, damping); } +public override bool SliderSetLimits(BulletConstraint constrain, int lowerUpper, int linAng, float val) +{ + BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; + return BSAPICPP.SliderSetLimits2(constrainu.ptr, lowerUpper, linAng, val); +} + +public override bool SliderSet(BulletConstraint constrain, int softRestDamp, int dirLimOrtho, int linAng, float val) +{ + BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; + return BSAPICPP.SliderSet2(constrainu.ptr, softRestDamp, dirLimOrtho, linAng, val); +} + +public override bool SliderMotorEnable(BulletConstraint constrain, int linAng, float numericTrueFalse) +{ + BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; + return BSAPICPP.SliderMotorEnable2(constrainu.ptr, linAng, numericTrueFalse); +} + +public override bool SliderMotor(BulletConstraint constrain, int forceVel, int linAng, float val) +{ + BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; + return BSAPICPP.SliderMotor2(constrainu.ptr, forceVel, linAng, val); +} + public override bool CalculateTransforms(BulletConstraint constrain) { BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; @@ -1625,6 +1655,9 @@ public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enabl public static extern bool SetBreakingImpulseThreshold2(IntPtr constrain, float threshold); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool HingeSetLimits2(IntPtr constrain, float low, float high, float softness, float bias, float relaxation); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool ConstraintSpringEnable2(IntPtr constrain, int index, float numericTrueFalse); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] @@ -1637,6 +1670,18 @@ public static extern bool ConstraintSpringSetStiffness2(IntPtr constrain, int in public static extern bool ConstraintSpringSetDamping2(IntPtr constrain, int index, float damping); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool SliderSetLimits2(IntPtr constrain, int lowerUpper, int linAng, float val); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool SliderSet2(IntPtr constrain, int softRestDamp, int dirLimOrtho, int linAng, float val); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool SliderMotorEnable2(IntPtr constrain, int linAng, float numericTrueFalse); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool SliderMotor2(IntPtr constrain, int forceVel, int linAng, float val); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool CalculateTransforms2(IntPtr constrain); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs index 9ad12a9..ff2b497 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs @@ -752,6 +752,15 @@ private sealed class BulletConstraintXNA : BulletConstraint constraint.SetBreakingImpulseThreshold(threshold); return true; } + public override bool HingeSetLimits(BulletConstraint pConstraint, float low, float high, float softness, float bias, float relaxation) + { + HingeConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as HingeConstraint; + if (softness == HINGE_NOT_SPECIFIED) + constraint.SetLimit(low, high); + else + constraint.SetLimit(low, high, softness, bias, relaxation); + return true; + } public override bool SpringEnable(BulletConstraint pConstraint, int index, float numericTrueFalse) { Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint; @@ -762,13 +771,13 @@ private sealed class BulletConstraintXNA : BulletConstraint public override bool SpringSetEquilibriumPoint(BulletConstraint pConstraint, int index, float equilibriumPoint) { Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint; - if (index == -1) + if (index == SPRING_NOT_SPECIFIED) { constraint.SetEquilibriumPoint(); } else { - if (equilibriumPoint == -1) + if (equilibriumPoint == SPRING_NOT_SPECIFIED) constraint.SetEquilibriumPoint(index); else constraint.SetEquilibriumPoint(index, equilibriumPoint); @@ -790,6 +799,167 @@ private sealed class BulletConstraintXNA : BulletConstraint return true; } + public override bool SliderSetLimits(BulletConstraint pConstraint, int lowerUpper, int linAng, float val) + { + SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint; + switch (lowerUpper) + { + case SLIDER_LOWER_LIMIT: + switch (linAng) + { + case SLIDER_LINEAR: + constraint.SetLowerLinLimit(val); + break; + case SLIDER_ANGULAR: + constraint.SetLowerAngLimit(val); + break; + } + break; + case SLIDER_UPPER_LIMIT: + switch (linAng) + { + case SLIDER_LINEAR: + constraint.SetUpperLinLimit(val); + break; + case SLIDER_ANGULAR: + constraint.SetUpperAngLimit(val); + break; + } + break; + } + return true; + } + public override bool SliderSet(BulletConstraint pConstraint, int softRestDamp, int dirLimOrtho, int linAng, float val) + { + SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint; + switch (softRestDamp) + { + case SLIDER_SET_SOFTNESS: + switch (dirLimOrtho) + { + case SLIDER_SET_DIRECTION: + switch (linAng) + { + case SLIDER_LINEAR: constraint.SetSoftnessDirLin(val); break; + case SLIDER_ANGULAR: constraint.SetSoftnessDirAng(val); break; + } + break; + case SLIDER_SET_LIMIT: + switch (linAng) + { + case SLIDER_LINEAR: constraint.SetSoftnessLimLin(val); break; + case SLIDER_ANGULAR: constraint.SetSoftnessLimAng(val); break; + } + break; + case SLIDER_SET_ORTHO: + switch (linAng) + { + case SLIDER_LINEAR: constraint.SetSoftnessOrthoLin(val); break; + case SLIDER_ANGULAR: constraint.SetSoftnessOrthoAng(val); break; + } + break; + } + break; + case SLIDER_SET_RESTITUTION: + switch (dirLimOrtho) + { + case SLIDER_SET_DIRECTION: + switch (linAng) + { + case SLIDER_LINEAR: constraint.SetRestitutionDirLin(val); break; + case SLIDER_ANGULAR: constraint.SetRestitutionDirAng(val); break; + } + break; + case SLIDER_SET_LIMIT: + switch (linAng) + { + case SLIDER_LINEAR: constraint.SetRestitutionLimLin(val); break; + case SLIDER_ANGULAR: constraint.SetRestitutionLimAng(val); break; + } + break; + case SLIDER_SET_ORTHO: + switch (linAng) + { + case SLIDER_LINEAR: constraint.SetRestitutionOrthoLin(val); break; + case SLIDER_ANGULAR: constraint.SetRestitutionOrthoAng(val); break; + } + break; + } + break; + case SLIDER_SET_DAMPING: + switch (dirLimOrtho) + { + case SLIDER_SET_DIRECTION: + switch (linAng) + { + case SLIDER_LINEAR: constraint.SetDampingDirLin(val); break; + case SLIDER_ANGULAR: constraint.SetDampingDirAng(val); break; + } + break; + case SLIDER_SET_LIMIT: + switch (linAng) + { + case SLIDER_LINEAR: constraint.SetDampingLimLin(val); break; + case SLIDER_ANGULAR: constraint.SetDampingLimAng(val); break; + } + break; + case SLIDER_SET_ORTHO: + switch (linAng) + { + case SLIDER_LINEAR: constraint.SetDampingOrthoLin(val); break; + case SLIDER_ANGULAR: constraint.SetDampingOrthoAng(val); break; + } + break; + } + break; + } + return true; + } + public override bool SliderMotorEnable(BulletConstraint pConstraint, int linAng, float numericTrueFalse) + { + SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint; + switch (linAng) + { + case SLIDER_LINEAR: + constraint.SetPoweredLinMotor(numericTrueFalse == 0.0 ? false : true); + break; + case SLIDER_ANGULAR: + constraint.SetPoweredAngMotor(numericTrueFalse == 0.0 ? false : true); + break; + } + return true; + } + public override bool SliderMotor(BulletConstraint pConstraint, int forceVel, int linAng, float val) + { + SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint; + switch (forceVel) + { + case SLIDER_MOTOR_VELOCITY: + switch (linAng) + { + case SLIDER_LINEAR: + constraint.SetTargetLinMotorVelocity(val); + break; + case SLIDER_ANGULAR: + constraint.SetTargetAngMotorVelocity(val); + break; + } + break; + case SLIDER_MAX_MOTOR_FORCE: + switch (linAng) + { + case SLIDER_LINEAR: + constraint.SetMaxLinMotorForce(val); + break; + case SLIDER_ANGULAR: + constraint.SetMaxAngMotorForce(val); + break; + } + break; + } + return true; + } + //BulletSimAPI.SetAngularDamping(Prim.PhysBody.ptr, angularDamping); public override void SetAngularDamping(BulletBody pBody, float angularDamping) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs index 8cca29f..b241059 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs @@ -441,14 +441,38 @@ public abstract bool TranslationalLimitMotor(BulletConstraint constrain, float e public abstract bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold); +public const int HINGE_NOT_SPECIFIED = -1; +public abstract bool HingeSetLimits(BulletConstraint constrain, float low, float high, float softness, float bias, float relaxation); + public abstract bool SpringEnable(BulletConstraint constrain, int index, float numericTrueFalse); +public const int SPRING_NOT_SPECIFIED = -1; public abstract bool SpringSetEquilibriumPoint(BulletConstraint constrain, int index, float equilibriumPoint); public abstract bool SpringSetStiffness(BulletConstraint constrain, int index, float stiffnesss); public abstract bool SpringSetDamping(BulletConstraint constrain, int index, float damping); +public const int SLIDER_LOWER_LIMIT = 0; +public const int SLIDER_UPPER_LIMIT = 1; +public const int SLIDER_LINEAR = 2; +public const int SLIDER_ANGULAR = 3; +public abstract bool SliderSetLimits(BulletConstraint constrain, int lowerUpper, int linAng, float val); + +public const int SLIDER_SET_SOFTNESS = 4; +public const int SLIDER_SET_RESTITUTION = 5; +public const int SLIDER_SET_DAMPING = 6; +public const int SLIDER_SET_DIRECTION = 7; +public const int SLIDER_SET_LIMIT = 8; +public const int SLIDER_SET_ORTHO = 9; +public abstract bool SliderSet(BulletConstraint constrain, int softRestDamp, int dirLimOrtho, int linAng, float val); + +public abstract bool SliderMotorEnable(BulletConstraint constrain, int linAng, float numericTrueFalse); + +public const int SLIDER_MOTOR_VELOCITY = 10; +public const int SLIDER_MAX_MOTOR_FORCE = 11; +public abstract bool SliderMotor(BulletConstraint constrain, int forceVel, int linAng, float val); + public abstract bool CalculateTransforms(BulletConstraint constrain); public abstract bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis); -- cgit v1.1 From c6a6631efc74ac8c139e0ae8cad683496fdd0050 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Aug 2013 10:24:37 -0700 Subject: BulletSim: move linkset extension operations into BSPrimLinkable where they should be. --- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 32 +---------------- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 41 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 31 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index d5b999d..4685b48 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -41,7 +41,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin [Serializable] public class BSPrim : BSPhysObject { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly string LogHeader = "[BULLETS PRIM]"; // _size is what the user passed. Scale is what we pass to the physics engine with the mesh. @@ -1555,36 +1555,6 @@ public class BSPrim : BSPhysObject object ret = null; switch (pFunct) { - case BSScene.PhysFunctGetLinksetType: - { - BSPrimLinkable myHandle = this as BSPrimLinkable; - if (myHandle != null) - { - ret = (object)myHandle.LinksetType; - } - m_log.DebugFormat("{0} Extension.physGetLinksetType, type={1}", LogHeader, ret); - break; - } - case BSScene.PhysFunctSetLinksetType: - { - if (pParams.Length > 0) - { - BSLinkset.LinksetImplementation linksetType = (BSLinkset.LinksetImplementation)pParams[0]; - BSPrimLinkable myHandle = this as BSPrimLinkable; - if (myHandle != null && myHandle.Linkset.IsRoot(myHandle)) - { - PhysScene.TaintedObject("BSPrim.PhysFunctSetLinksetType", delegate() - { - // Cause the linkset type to change - m_log.DebugFormat("{0} Extension.physSetLinksetType, oldType={1}, newType={2}", - LogHeader, myHandle.Linkset.LinksetImpl, linksetType); - myHandle.ConvertLinkset(linksetType); - }); - } - ret = (object)(int)linksetType; - } - break; - } default: ret = base.Extension(pFunct, pParams); break; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 38d1f88..fc639ad 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -41,6 +41,8 @@ public class BSPrimLinkable : BSPrimDisplaced // operations necessary for keeping the linkset created and, additionally, this // calls the linkset implementation for its creation and management. + private static readonly string LogHeader = "[BULLETS PRIMLINKABLE]"; + // This adds the overrides for link() and delink() so the prim is linkable. public BSLinkset Linkset { get; set; } @@ -279,5 +281,44 @@ public class BSPrimLinkable : BSPrimDisplaced } return ret; } + + #region Extension + public override object Extension(string pFunct, params object[] pParams) + { + object ret = null; + switch (pFunct) + { + case BSScene.PhysFunctGetLinksetType: + { + ret = (object)LinksetType; + m_log.DebugFormat("{0} Extension.physGetLinksetType, type={1}", LogHeader, ret); + break; + } + case BSScene.PhysFunctSetLinksetType: + { + if (pParams.Length > 0) + { + BSLinkset.LinksetImplementation linksetType = (BSLinkset.LinksetImplementation)pParams[0]; + if (Linkset.IsRoot(this)) + { + PhysScene.TaintedObject("BSPrim.PhysFunctSetLinksetType", delegate() + { + // Cause the linkset type to change + m_log.DebugFormat("{0} Extension.physSetLinksetType, oldType={1}, newType={2}", + LogHeader, Linkset.LinksetImpl, linksetType); + ConvertLinkset(linksetType); + }); + } + ret = (object)(int)linksetType; + } + break; + } + default: + ret = base.Extension(pFunct, pParams); + break; + } + return ret; + } + #endregion // Extension } } -- cgit v1.1 From f3cc20050e8e4ce047509589f828ccafbc59e3a9 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Aug 2013 11:13:53 -0700 Subject: BulletSim: initial implementation of physChangeLinkFixed that resets a linkset's link back to a fixed, non-moving connection. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 82 +++++++++++++++++++++- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 29 +++++--- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 4 ++ 3 files changed, 105 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 4455df4..decb61a 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -61,6 +61,10 @@ public class ExtendedPhysics : INonSharedRegionModule // Per prim functions. See BSPrim. public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; + public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; + public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge"; + public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring"; + public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider"; // ============================================================= @@ -250,7 +254,6 @@ public class ExtendedPhysics : INonSharedRegionModule public int physGetLinksetType(UUID hostID, UUID scriptID) { int ret = -1; - if (!Enabled) return ret; // The part that is requesting the change. @@ -287,5 +290,82 @@ public class ExtendedPhysics : INonSharedRegionModule } return ret; } + + [ScriptInvocation] + public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum) + { + int ret = -1; + if (!Enabled) return ret; + + // The part that is requesting the change. + SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); + + if (requestingPart != null) + { + // The type is is always on the root of a linkset. + SceneObjectGroup containingGroup = requestingPart.ParentGroup; + SceneObjectPart rootPart = containingGroup.RootPart; + + if (rootPart != null) + { + Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; + if (rootPhysActor != null) + { + SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); + if (linkPart != null) + { + Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor; + if (linkPhysActor != null) + { + ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkFixed, linkNum, linkPhysActor); + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}", + LogHeader, rootPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}", + LogHeader, requestingPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); + } + return ret; + } + + [ScriptInvocation] + public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum) + { + return 0; + } + + [ScriptInvocation] + public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum) + { + return 0; + } + + [ScriptInvocation] + public int physChangeLinkSlider(UUID hostID, UUID scriptID, int linkNum) + { + return 0; + } } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index fc639ad..77d8246 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -60,10 +60,7 @@ public class BSPrimLinkable : BSPrimDisplaced Linkset = BSLinkset.Factory(PhysScene, this); - PhysScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate() - { - Linkset.Refresh(this); - }); + Linkset.Refresh(this); } public override void Destroy() @@ -82,7 +79,7 @@ public class BSPrimLinkable : BSPrimDisplaced Linkset = parent.Linkset.AddMeToLinkset(this); - DetailLog("{0},BSPrimLinkset.link,call,parentBefore={1}, childrenBefore=={2}, parentAfter={3}, childrenAfter={4}", + DetailLog("{0},BSPrimLinkable.link,call,parentBefore={1}, childrenBefore=={2}, parentAfter={3}, childrenAfter={4}", LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren); } return; @@ -98,7 +95,7 @@ public class BSPrimLinkable : BSPrimDisplaced Linkset = Linkset.RemoveMeFromLinkset(this, false /* inTaintTime*/); - DetailLog("{0},BSPrimLinkset.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ", + DetailLog("{0},BSPrimLinkable.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ", LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren); return; } @@ -110,7 +107,7 @@ public class BSPrimLinkable : BSPrimDisplaced set { base.Position = value; - PhysScene.TaintedObject("BSPrimLinkset.setPosition", delegate() + PhysScene.TaintedObject("BSPrimLinkable.setPosition", delegate() { Linkset.UpdateProperties(UpdatedProperties.Position, this); }); @@ -124,7 +121,7 @@ public class BSPrimLinkable : BSPrimDisplaced set { base.Orientation = value; - PhysScene.TaintedObject("BSPrimLinkset.setOrientation", delegate() + PhysScene.TaintedObject("BSPrimLinkable.setOrientation", delegate() { Linkset.UpdateProperties(UpdatedProperties.Orientation, this); }); @@ -242,7 +239,7 @@ public class BSPrimLinkable : BSPrimDisplaced bool ret = false; if (LinksetType != newType) { - DetailLog("{0},BSPrimLinkset.ConvertLinkset,oldT={1},newT={2}", LocalID, LinksetType, newType); + DetailLog("{0},BSPrimLinkable.ConvertLinkset,oldT={1},newT={2}", LocalID, LinksetType, newType); // Set the implementation type first so the call to BSLinkset.Factory gets the new type. this.LinksetType = newType; @@ -288,12 +285,14 @@ public class BSPrimLinkable : BSPrimDisplaced object ret = null; switch (pFunct) { + // physGetLinksetType(); case BSScene.PhysFunctGetLinksetType: { ret = (object)LinksetType; m_log.DebugFormat("{0} Extension.physGetLinksetType, type={1}", LogHeader, ret); break; } + // physSetLinksetType(type); case BSScene.PhysFunctSetLinksetType: { if (pParams.Length > 0) @@ -313,6 +312,18 @@ public class BSPrimLinkable : BSPrimDisplaced } break; } + // physChangeLinkFixed(linknum); + // Params: int linkNum, PhysActor linkedPrim + case BSScene.PhysFunctChangeLinkFixed: + { + if (pParams.Length > 1) + { + int linkNum = (int)pParams[0]; + Manager.PhysicsActor linkActor = (Manager.PhysicsActor)pParams[1]; + Linkset.Refresh(this); + } + break; + } default: ret = base.Extension(pFunct, pParams); break; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index c92c9b9..571db86 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -875,6 +875,10 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters // Per prim functions. See BSPrim. public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; + public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; + public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge"; + public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring"; + public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider"; // ============================================================= public override object Extension(string pFunct, params object[] pParams) -- cgit v1.1 From dff0fb56902f62b070ec6fd05769babfad32ed2e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Aug 2013 11:18:23 -0700 Subject: BulletSim: Linkset.Refresh() calls internal ScheduleRebuild() to recreate the linkset physics at next PostTaint time. Replace the existing calls to ScheduleRebuild to be calls to Refresh(). This allows external routines to make changes to parameters and then cause the linkset to rebuild. --- .../Region/Physics/BulletSPlugin/BSLinksetCompound.cs | 17 ++++++++--------- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 11 ++++++----- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 47ab842..8f12189 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -90,10 +90,9 @@ public sealed class BSLinksetCompound : BSLinkset // its internal properties. public override void Refresh(BSPrimLinkable requestor) { - base.Refresh(requestor); - // Something changed so do the rebuilding thing - // ScheduleRebuild(); + ScheduleRebuild(requestor); + base.Refresh(requestor); } // Schedule a refresh to happen after all the other taint processing. @@ -127,7 +126,7 @@ public sealed class BSLinksetCompound : BSLinkset if (IsRoot(child)) { // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return ret; } @@ -144,7 +143,7 @@ public sealed class BSLinksetCompound : BSLinkset if (IsRoot(child)) { // Schedule a rebuild to verify that the root shape is set to the real shape. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return ret; } @@ -227,7 +226,7 @@ public sealed class BSLinksetCompound : BSLinkset // there will already be a rebuild scheduled. DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild.schedulingRebuild,whichUpdated={1}", updated.LocalID, whichUpdated); - ScheduleRebuild(updated); + Refresh(updated); } } } @@ -245,7 +244,7 @@ public sealed class BSLinksetCompound : BSLinkset DetailLog("{0},BSLinksetCompound.RemoveDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}", child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody, IsRoot(child)); - ScheduleRebuild(child); + Refresh(child); return ret; } @@ -263,7 +262,7 @@ public sealed class BSLinksetCompound : BSLinkset DetailLog("{0},BSLinksetCompound.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); // Rebuild the compound shape with the new child shape included - ScheduleRebuild(child); + Refresh(child); } return; } @@ -292,7 +291,7 @@ public sealed class BSLinksetCompound : BSLinkset else { // Rebuild the compound shape with the child removed - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } } return; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index f3b70c3..db323c2 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -158,6 +158,7 @@ public sealed class BSLinksetConstraints : BSLinkset // refresh will happen once after all the other taints are applied. public override void Refresh(BSPrimLinkable requestor) { + ScheduleRebuild(requestor); base.Refresh(requestor); } @@ -194,7 +195,7 @@ public sealed class BSLinksetConstraints : BSLinkset if (IsRoot(child)) { // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return ret; } @@ -213,7 +214,7 @@ public sealed class BSLinksetConstraints : BSLinkset if (IsRoot(child)) { // Schedule a rebuild to verify that the root shape is set to the real shape. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return ret; } @@ -241,7 +242,7 @@ public sealed class BSLinksetConstraints : BSLinkset // Just undo all the constraints for this linkset. Rebuild at the end of the step. ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); // Cause the constraints, et al to be rebuilt before the next simulation step. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return ret; } @@ -259,7 +260,7 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); // Cause constraints and assorted properties to be recomputed before the next simulation step. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return; } @@ -283,7 +284,7 @@ public sealed class BSLinksetConstraints : BSLinkset PhysicallyUnlinkAChildFromRoot(rootx, childx); }); // See that the linkset parameters are recomputed at the end of the taint time. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } else { -- cgit v1.1 From 6aee08ac3c48b55ebd8e945c8b11f17dc1ab3151 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 8 Aug 2013 08:36:36 -0700 Subject: BulletSim: add physChangeLinkSpring to change linkset link to be a spring constraint. Add implementation to create spring constraint. Send up property updates for linkset children at the end of flexible linkset links. The simulator probably doesn't do the right thing yet. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 73 ++++++++++++++- .../Region/Physics/BulletSPlugin/BSApiTemplate.cs | 4 +- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 24 +++++ .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 102 ++++++++++++++++++++- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 9 +- 5 files changed, 198 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index decb61a..278e9e7 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -291,6 +291,10 @@ public class ExtendedPhysics : INonSharedRegionModule return ret; } + // physChangeLinkFixed(integer linkNum) + // Change the link between the root and the linkNum into a fixed, static physical connection. + // This needs to change 'linkNum' into the physical object because lower level code has + // no access to the link numbers. [ScriptInvocation] public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum) { @@ -353,13 +357,76 @@ public class ExtendedPhysics : INonSharedRegionModule [ScriptInvocation] public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum) { - return 0; + return -1; } [ScriptInvocation] - public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum) + public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum, + Vector3 frameInAloc, Quaternion frameInArot, + Vector3 frameInBloc, Quaternion frameInBrot, + Vector3 linearLimitLow, Vector3 linearLimitHigh, + Vector3 angularLimitLow, Vector3 angularLimitHigh + ) { - return 0; + int ret = -1; + if (!Enabled) return ret; + + // The part that is requesting the change. + SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); + + if (requestingPart != null) + { + // The type is is always on the root of a linkset. + SceneObjectGroup containingGroup = requestingPart.ParentGroup; + SceneObjectPart rootPart = containingGroup.RootPart; + + if (rootPart != null) + { + Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; + if (rootPhysActor != null) + { + SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); + if (linkPart != null) + { + Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor; + if (linkPhysActor != null) + { + ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkSpring, linkNum, linkPhysActor, + frameInAloc, frameInArot, + frameInBloc, frameInBrot, + linearLimitLow, linearLimitHigh, + angularLimitLow, angularLimitHigh + ); + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}", + LogHeader, rootPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}", + LogHeader, requestingPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); + } + return ret; } [ScriptInvocation] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs index b241059..9d8838b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs @@ -43,7 +43,9 @@ public enum ConstraintType : int SLIDER_CONSTRAINT_TYPE, CONTACT_CONSTRAINT_TYPE, D6_SPRING_CONSTRAINT_TYPE, - MAX_CONSTRAINT_TYPE + MAX_CONSTRAINT_TYPE, // last type defined by Bullet + // + FIXED_CONSTRAINT_TYPE = 1234 // BulletSim constraint that is fixed and unmoving } // =============================================================================== diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index d4b1c1e..2058e3a 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -79,6 +79,8 @@ public abstract class BSLinkset } public virtual void ResetLink() { } public virtual void SetLinkParameters(BSConstraint constrain) { } + // Returns 'true' if physical property updates from the child should be reported to the simulator + public virtual bool ShouldUpdateChildProperties() { return false; } } public LinksetImplementation LinksetImpl { get; protected set; } @@ -224,6 +226,21 @@ public abstract class BSLinkset return ret; } + // Check the type of the link and return 'true' if the link is flexible and the + // updates from the child should be sent to the simulator so things change. + public virtual bool ShouldReportPropertyUpdates(BSPrimLinkable child) + { + bool ret = false; + + BSLinkInfo linkInfo; + if (m_children.TryGetValue(child, out linkInfo)) + { + ret = linkInfo.ShouldUpdateChildProperties(); + } + + return ret; + } + // Called after a simulation step to post a collision with this object. // Return 'true' if linkset processed the collision. 'false' says the linkset didn't have // anything to add for the collision and it should be passed through normal processing. @@ -432,6 +449,13 @@ public abstract class BSLinkset return com; } + #region Extension + public virtual object Extension(string pFunct, params object[] pParams) + { + return null; + } + #endregion // Extension + // Invoke the detailed logger and output something if it's enabled. protected void DetailLog(string msg, params Object[] args) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index db323c2..17fec9d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -60,8 +60,6 @@ public sealed class BSLinksetConstraints : BSLinkset public float springDamping; public float springStiffness; - - public BSLinkInfoConstraint(BSPrimLinkable pMember) : base(pMember) { @@ -72,7 +70,8 @@ public sealed class BSLinksetConstraints : BSLinkset // Set all the parameters for this constraint to a fixed, non-movable constraint. public override void ResetLink() { - constraintType = ConstraintType.D6_CONSTRAINT_TYPE; + // constraintType = ConstraintType.D6_CONSTRAINT_TYPE; + constraintType = ConstraintType.FIXED_CONSTRAINT_TYPE; linearLimitLow = OMV.Vector3.Zero; linearLimitHigh = OMV.Vector3.Zero; angularLimitLow = OMV.Vector3.Zero; @@ -97,6 +96,7 @@ public sealed class BSLinksetConstraints : BSLinkset { switch (constraintType) { + case ConstraintType.FIXED_CONSTRAINT_TYPE: case ConstraintType.D6_CONSTRAINT_TYPE: BSConstraint6Dof constrain6dof = constrain as BSConstraint6Dof; if (constrain6dof != null) @@ -145,6 +145,20 @@ public sealed class BSLinksetConstraints : BSLinkset break; } } + + // Return 'true' if the property updates from the physics engine should be reported + // to the simulator. + // If the constraint is fixed, we don't need to report as the simulator and viewer will + // report the right things. + public override bool ShouldUpdateChildProperties() + { + bool ret = true; + + if (constraintType == ConstraintType.FIXED_CONSTRAINT_TYPE) + ret = false; + + return ret; + } } public BSLinksetConstraints(BSScene scene, BSPrimLinkable parent) : base(scene, parent) @@ -316,6 +330,7 @@ public sealed class BSLinksetConstraints : BSLinkset switch (linkInfo.constraintType) { + case ConstraintType.FIXED_CONSTRAINT_TYPE: case ConstraintType.D6_CONSTRAINT_TYPE: // Relative position normalized to the root prim // Essentually a vector pointing from center of rootPrim to center of li.member @@ -466,5 +481,86 @@ public sealed class BSLinksetConstraints : BSLinkset Rebuilding = false; } } + + #region Extension + public override object Extension(string pFunct, params object[] pParams) + { + object ret = null; + switch (pFunct) + { + // pParams = (int linkNUm, PhysActor linkChild) + case BSScene.PhysFunctChangeLinkFixed: + if (pParams.Length > 1) + { + BSPrimLinkable child = pParams[1] as BSPrimLinkable; + if (child != null) + { + m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() + { + // Pick up all the constraints currently created. + RemoveDependencies(child); + + BSLinkInfo linkInfo = null; + if (m_children.TryGetValue(child, out linkInfo)) + { + BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; + if (linkInfoC != null) + { + // Setting to fixed is easy. The reset state is the fixed link configuration. + linkInfoC.ResetLink(); + ret = (object)true; + } + } + // Cause the whole linkset to be rebuilt in post-taint time. + Refresh(child); + }); + } + } + break; + case BSScene.PhysFunctChangeLinkSpring: + if (pParams.Length > 11) + { + BSPrimLinkable child = pParams[1] as BSPrimLinkable; + if (child != null) + { + m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() + { + // Pick up all the constraints currently created. + RemoveDependencies(child); + + BSLinkInfo linkInfo = null; + if (m_children.TryGetValue(child, out linkInfo)) + { + BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; + if (linkInfoC != null) + { + // Start with a reset link definition + linkInfoC.ResetLink(); + linkInfoC.constraintType = ConstraintType.D6_SPRING_CONSTRAINT_TYPE; + linkInfoC.frameInAloc = (OMV.Vector3)pParams[2]; + linkInfoC.frameInArot = (OMV.Quaternion)pParams[3]; + linkInfoC.frameInBloc = (OMV.Vector3)pParams[4]; + linkInfoC.frameInBrot = (OMV.Quaternion)pParams[5]; + linkInfoC.linearLimitLow = (OMV.Vector3)pParams[6]; + linkInfoC.linearLimitHigh = (OMV.Vector3)pParams[7]; + linkInfoC.angularLimitLow = (OMV.Vector3)pParams[8]; + linkInfoC.angularLimitHigh = (OMV.Vector3)pParams[9]; + ret = (object)true; + } + } + // Cause the whole linkset to be rebuilt in post-taint time. + Refresh(child); + }); + } + } + break; + default: + ret = base.Extension(pFunct, pParams); + break; + } + return ret; + } + #endregion // Extension + } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 77d8246..4c384a6 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -179,7 +179,7 @@ public class BSPrimLinkable : BSPrimDisplaced // Do any filtering/modification needed for linksets. public override void UpdateProperties(EntityProperties entprop) { - if (Linkset.IsRoot(this)) + if (Linkset.IsRoot(this) || Linkset.ShouldReportPropertyUpdates(this)) { // Properties are only updated for the roots of a linkset. // TODO: this will have to change when linksets are articulated. @@ -316,12 +316,7 @@ public class BSPrimLinkable : BSPrimDisplaced // Params: int linkNum, PhysActor linkedPrim case BSScene.PhysFunctChangeLinkFixed: { - if (pParams.Length > 1) - { - int linkNum = (int)pParams[0]; - Manager.PhysicsActor linkActor = (Manager.PhysicsActor)pParams[1]; - Linkset.Refresh(this); - } + Linkset.Extension(pFunct, pParams); break; } default: -- cgit v1.1 From b2a1348adc2bd27d3266a7d7c7594a2aa8272100 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 8 Aug 2013 16:37:37 -0700 Subject: BulletSim: update C++ HACD parameters to values that handle enclosed hollow spaces better. This shouldn't affect many since this HACD routine is off by default. --- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index fcb892a..737dda1 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -683,21 +683,21 @@ public static class BSParam 0f ), new ParameterDefn("BHullMaxVerticesPerHull", "Bullet impl: max number of vertices per created hull", - 100f ), + 200f ), new ParameterDefn("BHullMinClusters", "Bullet impl: minimum number of hulls to create per mesh", - 2f ), + 10f ), new ParameterDefn("BHullCompacityWeight", "Bullet impl: weight factor for how compact to make hulls", - 0.1f ), + 20f ), new ParameterDefn("BHullVolumeWeight", "Bullet impl: weight factor for volume in created hull", - 0f ), + 0.1f ), new ParameterDefn("BHullConcavity", "Bullet impl: weight factor for how convex a created hull can be", - 100f ), + 10f ), new ParameterDefn("BHullAddExtraDistPoints", "Bullet impl: whether to add extra vertices for long distance vectors", - false ), + true ), new ParameterDefn("BHullAddNeighboursDistPoints", "Bullet impl: whether to add extra vertices between neighbor hulls", - false ), + true ), new ParameterDefn("BHullAddFacesPoints", "Bullet impl: whether to add extra vertices to break up hull faces", - false ), + true ), new ParameterDefn("BHullShouldAdjustCollisionMargin", "Bullet impl: whether to shrink resulting hulls to account for collision margin", false ), -- cgit v1.1 From 455d36c4c70a55c5d48dc1410b8729929fafedf6 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 9 Aug 2013 10:59:10 -0700 Subject: BulletSim: add physChangeLinkParams to set individual parameters on link constraints. Not fully functional. Remove double definition of ExtendedPhysics parameters by having BulletSim reference the optional module (addition to prebuild.xml and usings). --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 265 +++++++++++++-------- .../Physics/BulletSPlugin/BSConstraintConeTwist.cs | 54 +++++ .../Physics/BulletSPlugin/BSConstraintSlider.cs | 55 +++++ .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 85 +++---- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 18 +- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 14 -- 6 files changed, 324 insertions(+), 167 deletions(-) create mode 100755 OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs create mode 100755 OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 278e9e7..baf5a5b 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -36,6 +36,7 @@ using OpenSim.Region.CoreModules; using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Physics.Manager; using Mono.Addins; using Nini.Config; @@ -62,9 +63,8 @@ public class ExtendedPhysics : INonSharedRegionModule public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; - public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge"; - public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring"; - public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider"; + public const string PhysFunctChangeLinkType = "BulletSim.ChangeLinkType"; + public const string PhysFunctChangeLinkParams = "BulletSim.ChangeLinkParams"; // ============================================================= @@ -200,7 +200,7 @@ public class ExtendedPhysics : INonSharedRegionModule if (rootPart != null) { - Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; + PhysicsActor rootPhysActor = rootPart.PhysActor; if (rootPhysActor != null) { if (rootPhysActor.IsPhysical) @@ -219,7 +219,7 @@ public class ExtendedPhysics : INonSharedRegionModule containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition); containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation); - ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType)); Thread.Sleep(150); // longer than one heartbeat tick containingGroup.ScriptSetPhysicsStatus(true); @@ -228,7 +228,7 @@ public class ExtendedPhysics : INonSharedRegionModule { // Non-physical linksets don't have a physical instantiation so there is no state to // worry about being updated. - ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType)); } } else @@ -267,10 +267,10 @@ public class ExtendedPhysics : INonSharedRegionModule if (rootPart != null) { - Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; + PhysicsActor rootPhysActor = rootPart.PhysActor; if (rootPhysActor != null) { - ret = (int)rootPhysActor.Extension(PhysFunctGetLinksetType); + ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType)); } else { @@ -291,148 +291,225 @@ public class ExtendedPhysics : INonSharedRegionModule return ret; } + [ScriptConstant] + public static int PHYS_LINK_TYPE_FIXED = 1234; + [ScriptConstant] + public static int PHYS_LINK_TYPE_HINGE = 4; + [ScriptConstant] + public static int PHYS_LINK_TYPE_SPRING = 9; + [ScriptConstant] + public static int PHYS_LINK_TYPE_6DOF = 6; + [ScriptConstant] + public static int PHYS_LINK_TYPE_SLIDER = 7; + + // physChangeLinkType(integer linkNum, integer typeCode) + [ScriptInvocation] + public int physChangeLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode) + { + int ret = -1; + if (!Enabled) return ret; + + PhysicsActor rootPhysActor; + PhysicsActor childPhysActor; + + if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) + { + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, typeCode)); + } + + return ret; + } + // physChangeLinkFixed(integer linkNum) // Change the link between the root and the linkNum into a fixed, static physical connection. - // This needs to change 'linkNum' into the physical object because lower level code has - // no access to the link numbers. [ScriptInvocation] public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum) { int ret = -1; if (!Enabled) return ret; - // The part that is requesting the change. - SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); + PhysicsActor rootPhysActor; + PhysicsActor childPhysActor; + + if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) + { + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, PHYS_LINK_TYPE_FIXED)); + } + + return ret; + } + + // Code for specifying params. + // The choice if 14400 is arbitrary and only serves to catch parameter code misuse. + public static int PHYS_PARAM_MIN = 14401; + [ScriptConstant] + public static int PHYS_PARAM_FRAMEINA_LOC = 14401; + [ScriptConstant] + public static int PHYS_PARAM_FRAMEINA_ROT = 14402; + [ScriptConstant] + public static int PHYS_PARAM_FRAMEINB_LOC = 14403; + [ScriptConstant] + public static int PHYS_PARAM_FRAMEINB_ROT = 14404; + [ScriptConstant] + public static int PHYS_PARAM_LINEAR_LIMIT_LOW = 14405; + [ScriptConstant] + public static int PHYS_PARAM_LINEAR_LIMIT_HIGH = 14406; + [ScriptConstant] + public static int PHYS_PARAM_ANGULAR_LIMIT_LOW = 14407; + [ScriptConstant] + public static int PHYS_PARAM_ANGULAR_LIMIT_HIGH = 14408; + [ScriptConstant] + public static int PHYS_PARAM_USE_FRAME_OFFSET = 14409; + [ScriptConstant] + public static int PHYS_PARAM_ENABLE_TRANSMOTOR = 14410; + [ScriptConstant] + public static int PHYS_PARAM_TRANSMOTOR_MAXVEL = 14411; + [ScriptConstant] + public static int PHYS_PARAM_TRANSMOTOR_MAXFORCE = 14412; + [ScriptConstant] + public static int PHYS_PARAM_CFM = 14413; + [ScriptConstant] + public static int PHYS_PARAM_ERP = 14414; + [ScriptConstant] + public static int PHYS_PARAM_SOLVER_ITERATIONS = 14415; + [ScriptConstant] + public static int PHYS_PARAM_SPRING_DAMPING = 14416; + [ScriptConstant] + public static int PHYS_PARAM_SPRING_STIFFNESS = 14417; + public static int PHYS_PARAM_MAX = 14417; + // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) + [ScriptInvocation] + public int physChangeLinkParams(UUID hostID, UUID scriptID, int linkNum, object[] parms) + { + int ret = -1; + if (!Enabled) return ret; + + PhysicsActor rootPhysActor; + PhysicsActor childPhysActor; + + if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) + { + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, childPhysActor, parms)); + } + + return ret; + } + + private bool GetRootPhysActor(UUID hostID, out PhysicsActor rootPhysActor) + { + SceneObjectGroup containingGroup; + SceneObjectPart rootPart; + return GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor); + } + + private bool GetRootPhysActor(UUID hostID, out SceneObjectGroup containingGroup, out SceneObjectPart rootPart, out PhysicsActor rootPhysActor) + { + bool ret = false; + rootPhysActor = null; + containingGroup = null; + rootPart = null; + + SceneObjectPart requestingPart; + + requestingPart = BaseScene.GetSceneObjectPart(hostID); if (requestingPart != null) { // The type is is always on the root of a linkset. - SceneObjectGroup containingGroup = requestingPart.ParentGroup; - SceneObjectPart rootPart = containingGroup.RootPart; - - if (rootPart != null) + containingGroup = requestingPart.ParentGroup; + if (containingGroup != null && !containingGroup.IsDeleted) { - Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; - if (rootPhysActor != null) + rootPart = containingGroup.RootPart; + if (rootPart != null) { - SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); - if (linkPart != null) + rootPhysActor = rootPart.PhysActor; + if (rootPhysActor != null) { - Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor; - if (linkPhysActor != null) - { - ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkFixed, linkNum, linkPhysActor); - } - else - { - m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}", - LogHeader, rootPart.Name, hostID, linkNum); - } + ret = true; } else { - m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", - LogHeader, rootPart.Name, hostID, linkNum); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}", + LogHeader, rootPart.Name, hostID); } } else { - m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}", - LogHeader, rootPart.Name, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not exist. RequestingPartName={1}, hostID={2}", + LogHeader, requestingPart.Name, hostID); } } else { - m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}", - LogHeader, requestingPart.Name, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Containing group missing or deleted. hostID={1}", LogHeader, hostID); } } else { - m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: cannot find script object in scene. hostID={1}", LogHeader, hostID); } + return ret; } - [ScriptInvocation] - public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum) + // Find the root and child PhysActors based on the linkNum. + // Return 'true' if both are found and returned. + private bool GetRootAndChildPhysActors(UUID hostID, int linkNum, out PhysicsActor rootPhysActor, out PhysicsActor childPhysActor) { - return -1; - } + bool ret = false; + rootPhysActor = null; + childPhysActor = null; - [ScriptInvocation] - public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum, - Vector3 frameInAloc, Quaternion frameInArot, - Vector3 frameInBloc, Quaternion frameInBrot, - Vector3 linearLimitLow, Vector3 linearLimitHigh, - Vector3 angularLimitLow, Vector3 angularLimitHigh - ) - { - int ret = -1; - if (!Enabled) return ret; + SceneObjectGroup containingGroup; + SceneObjectPart rootPart; - // The part that is requesting the change. - SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); - - if (requestingPart != null) + if (GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor)) { - // The type is is always on the root of a linkset. - SceneObjectGroup containingGroup = requestingPart.ParentGroup; - SceneObjectPart rootPart = containingGroup.RootPart; - - if (rootPart != null) + SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); + if (linkPart != null) { - Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; - if (rootPhysActor != null) + childPhysActor = linkPart.PhysActor; + if (childPhysActor != null) { - SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); - if (linkPart != null) - { - Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor; - if (linkPhysActor != null) - { - ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkSpring, linkNum, linkPhysActor, - frameInAloc, frameInArot, - frameInBloc, frameInBrot, - linearLimitLow, linearLimitHigh, - angularLimitLow, angularLimitHigh - ); - } - else - { - m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}", - LogHeader, rootPart.Name, hostID, linkNum); - } - } - else - { - m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", - LogHeader, rootPart.Name, hostID, linkNum); - } + ret = true; } else { - m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}", - LogHeader, rootPart.Name, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); } } else { - m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}", - LogHeader, requestingPart.Name, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); } } else { - m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); + m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}", + LogHeader, rootPart.Name, hostID); } + return ret; } - [ScriptInvocation] - public int physChangeLinkSlider(UUID hostID, UUID scriptID, int linkNum) + // Extension() returns an object. Convert that object into the integer error we expect to return. + private int MakeIntError(object extensionRet) { - return 0; + int ret = -1; + if (extensionRet != null) + { + try + { + ret = (int)extensionRet; + } + catch + { + ret = -1; + } + } + return ret; } } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs new file mode 100755 index 0000000..7a76a9a --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs @@ -0,0 +1,54 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyrightD + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.BulletSPlugin +{ + +public sealed class BSConstraintConeTwist : BSConstraint +{ + public override ConstraintType Type { get { return ConstraintType.CONETWIST_CONSTRAINT_TYPE; } } + + public BSConstraintConeTwist(BulletWorld world, BulletBody obj1, BulletBody obj2, + Vector3 frameInAloc, Quaternion frameInArot, + Vector3 frameInBloc, Quaternion frameInBrot, + bool disableCollisionsBetweenLinkedBodies) + : base(world) + { + m_body1 = obj1; + m_body2 = obj2; + m_constraint = PhysicsScene.PE.CreateConeTwistConstraint(world, obj1, obj2, + frameInAloc, frameInArot, frameInBloc, frameInBrot, + disableCollisionsBetweenLinkedBodies); + m_enabled = true; + } +} + +} diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs new file mode 100755 index 0000000..37cfa07 --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs @@ -0,0 +1,55 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyrightD + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.BulletSPlugin +{ + +public sealed class BSConstraintSlider : BSConstraint +{ + public override ConstraintType Type { get { return ConstraintType.SLIDER_CONSTRAINT_TYPE; } } + + public BSConstraintSlider(BulletWorld world, BulletBody obj1, BulletBody obj2, + Vector3 frameInAloc, Quaternion frameInArot, + Vector3 frameInBloc, Quaternion frameInBrot, + bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) + : base(world) + { + m_body1 = obj1; + m_body2 = obj2; + m_constraint = PhysicsScene.PE.CreateSliderConstraint(world, obj1, obj2, + frameInAloc, frameInArot, frameInBloc, frameInBrot, + useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); + m_enabled = true; + } + +} + +} diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 17fec9d..c09dd42 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -28,6 +28,8 @@ using System; using System.Collections.Generic; using System.Text; +using OpenSim.Region.OptionalModules.Scripting; + using OMV = OpenMetaverse; namespace OpenSim.Region.Physics.BulletSPlugin @@ -489,71 +491,46 @@ public sealed class BSLinksetConstraints : BSLinkset switch (pFunct) { // pParams = (int linkNUm, PhysActor linkChild) - case BSScene.PhysFunctChangeLinkFixed: + case ExtendedPhysics.PhysFunctChangeLinkType: if (pParams.Length > 1) { - BSPrimLinkable child = pParams[1] as BSPrimLinkable; - if (child != null) + int requestedType = (int)pParams[1]; + if (requestedType == (int)ConstraintType.FIXED_CONSTRAINT_TYPE + || requestedType == (int)ConstraintType.D6_CONSTRAINT_TYPE + || requestedType == (int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE + || requestedType == (int)ConstraintType.HINGE_CONSTRAINT_TYPE + || requestedType == (int)ConstraintType.CONETWIST_CONSTRAINT_TYPE + || requestedType == (int)ConstraintType.SLIDER_CONSTRAINT_TYPE) { - m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() + BSPrimLinkable child = pParams[0] as BSPrimLinkable; + if (child != null) { - // Pick up all the constraints currently created. - RemoveDependencies(child); - - BSLinkInfo linkInfo = null; - if (m_children.TryGetValue(child, out linkInfo)) + m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() { - BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; - if (linkInfoC != null) - { - // Setting to fixed is easy. The reset state is the fixed link configuration. - linkInfoC.ResetLink(); - ret = (object)true; - } - } - // Cause the whole linkset to be rebuilt in post-taint time. - Refresh(child); - }); - } - } - break; - case BSScene.PhysFunctChangeLinkSpring: - if (pParams.Length > 11) - { - BSPrimLinkable child = pParams[1] as BSPrimLinkable; - if (child != null) - { - m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() - { - // Pick up all the constraints currently created. - RemoveDependencies(child); + // Pick up all the constraints currently created. + RemoveDependencies(child); - BSLinkInfo linkInfo = null; - if (m_children.TryGetValue(child, out linkInfo)) - { - BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; - if (linkInfoC != null) + BSLinkInfo linkInfo = null; + if (m_children.TryGetValue(child, out linkInfo)) { - // Start with a reset link definition - linkInfoC.ResetLink(); - linkInfoC.constraintType = ConstraintType.D6_SPRING_CONSTRAINT_TYPE; - linkInfoC.frameInAloc = (OMV.Vector3)pParams[2]; - linkInfoC.frameInArot = (OMV.Quaternion)pParams[3]; - linkInfoC.frameInBloc = (OMV.Vector3)pParams[4]; - linkInfoC.frameInBrot = (OMV.Quaternion)pParams[5]; - linkInfoC.linearLimitLow = (OMV.Vector3)pParams[6]; - linkInfoC.linearLimitHigh = (OMV.Vector3)pParams[7]; - linkInfoC.angularLimitLow = (OMV.Vector3)pParams[8]; - linkInfoC.angularLimitHigh = (OMV.Vector3)pParams[9]; - ret = (object)true; + BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; + if (linkInfoC != null) + { + // Setting to fixed is easy. The reset state is the fixed link configuration. + linkInfoC.ResetLink(); + linkInfoC.constraintType = (ConstraintType)requestedType; + ret = (object)true; + } } - } - // Cause the whole linkset to be rebuilt in post-taint time. - Refresh(child); - }); + // Cause the whole linkset to be rebuilt in post-taint time. + Refresh(child); + }); + } } } break; + case ExtendedPhysics.PhysFunctChangeLinkParams: + break; default: ret = base.Extension(pFunct, pParams); break; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 4c384a6..6136257 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -30,6 +30,7 @@ using System.Linq; using System.Text; using OpenSim.Framework; +using OpenSim.Region.OptionalModules.Scripting; using OMV = OpenMetaverse; @@ -286,14 +287,14 @@ public class BSPrimLinkable : BSPrimDisplaced switch (pFunct) { // physGetLinksetType(); - case BSScene.PhysFunctGetLinksetType: + case ExtendedPhysics.PhysFunctGetLinksetType: { ret = (object)LinksetType; m_log.DebugFormat("{0} Extension.physGetLinksetType, type={1}", LogHeader, ret); break; } // physSetLinksetType(type); - case BSScene.PhysFunctSetLinksetType: + case ExtendedPhysics.PhysFunctSetLinksetType: { if (pParams.Length > 0) { @@ -312,9 +313,16 @@ public class BSPrimLinkable : BSPrimDisplaced } break; } - // physChangeLinkFixed(linknum); - // Params: int linkNum, PhysActor linkedPrim - case BSScene.PhysFunctChangeLinkFixed: + // physChangeLinkType(linknum, typeCode); + // Params: PhysActor linkedPrim, int typeCode + case ExtendedPhysics.PhysFunctChangeLinkType: + { + Linkset.Extension(pFunct, pParams); + break; + } + // physChangeLinkParams(linknum, [code, value, code, value, ...]); + // Params: PhysActor linkedPrim, object[] params + case ExtendedPhysics.PhysFunctChangeLinkParams: { Linkset.Extension(pFunct, pParams); break; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 571db86..7440468 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -867,20 +867,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters public override bool IsThreaded { get { return false; } } #region Extensions - // ============================================================= - // Per scene functions. See below. - - // Per avatar functions. See BSCharacter. - - // Per prim functions. See BSPrim. - public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; - public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; - public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; - public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge"; - public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring"; - public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider"; - // ============================================================= - public override object Extension(string pFunct, params object[] pParams) { return base.Extension(pFunct, pParams); -- cgit v1.1 From f6fdfd16f55c3e1bd55775f1f21e0ac9e44ff2ee Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 9 Aug 2013 17:01:35 -0700 Subject: BulletSim: change ExtendedPhysics constants to 'const' so they can be used as case variables in switch statements. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 56 +++++++++++----------- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 22 +++++++++ 2 files changed, 50 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index baf5a5b..e0f16d6 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -160,7 +160,7 @@ public class ExtendedPhysics : INonSharedRegionModule } [ScriptConstant] - public static int PHYS_CENTER_OF_MASS = 1 << 0; + public const int PHYS_CENTER_OF_MASS = 1 << 0; [ScriptInvocation] public string physGetEngineType(UUID hostID, UUID scriptID) @@ -176,11 +176,11 @@ public class ExtendedPhysics : INonSharedRegionModule } [ScriptConstant] - public static int PHYS_LINKSET_TYPE_CONSTRAINT = 0; + public const int PHYS_LINKSET_TYPE_CONSTRAINT = 0; [ScriptConstant] - public static int PHYS_LINKSET_TYPE_COMPOUND = 1; + public const int PHYS_LINKSET_TYPE_COMPOUND = 1; [ScriptConstant] - public static int PHYS_LINKSET_TYPE_MANUAL = 2; + public const int PHYS_LINKSET_TYPE_MANUAL = 2; [ScriptInvocation] public int physSetLinksetType(UUID hostID, UUID scriptID, int linksetType) @@ -292,15 +292,15 @@ public class ExtendedPhysics : INonSharedRegionModule } [ScriptConstant] - public static int PHYS_LINK_TYPE_FIXED = 1234; + public const int PHYS_LINK_TYPE_FIXED = 1234; [ScriptConstant] - public static int PHYS_LINK_TYPE_HINGE = 4; + public const int PHYS_LINK_TYPE_HINGE = 4; [ScriptConstant] - public static int PHYS_LINK_TYPE_SPRING = 9; + public const int PHYS_LINK_TYPE_SPRING = 9; [ScriptConstant] - public static int PHYS_LINK_TYPE_6DOF = 6; + public const int PHYS_LINK_TYPE_6DOF = 6; [ScriptConstant] - public static int PHYS_LINK_TYPE_SLIDER = 7; + public const int PHYS_LINK_TYPE_SLIDER = 7; // physChangeLinkType(integer linkNum, integer typeCode) [ScriptInvocation] @@ -341,42 +341,42 @@ public class ExtendedPhysics : INonSharedRegionModule // Code for specifying params. // The choice if 14400 is arbitrary and only serves to catch parameter code misuse. - public static int PHYS_PARAM_MIN = 14401; + public const int PHYS_PARAM_MIN = 14401; [ScriptConstant] - public static int PHYS_PARAM_FRAMEINA_LOC = 14401; + public const int PHYS_PARAM_FRAMEINA_LOC = 14401; [ScriptConstant] - public static int PHYS_PARAM_FRAMEINA_ROT = 14402; + public const int PHYS_PARAM_FRAMEINA_ROT = 14402; [ScriptConstant] - public static int PHYS_PARAM_FRAMEINB_LOC = 14403; + public const int PHYS_PARAM_FRAMEINB_LOC = 14403; [ScriptConstant] - public static int PHYS_PARAM_FRAMEINB_ROT = 14404; + public const int PHYS_PARAM_FRAMEINB_ROT = 14404; [ScriptConstant] - public static int PHYS_PARAM_LINEAR_LIMIT_LOW = 14405; + public const int PHYS_PARAM_LINEAR_LIMIT_LOW = 14405; [ScriptConstant] - public static int PHYS_PARAM_LINEAR_LIMIT_HIGH = 14406; + public const int PHYS_PARAM_LINEAR_LIMIT_HIGH = 14406; [ScriptConstant] - public static int PHYS_PARAM_ANGULAR_LIMIT_LOW = 14407; + public const int PHYS_PARAM_ANGULAR_LIMIT_LOW = 14407; [ScriptConstant] - public static int PHYS_PARAM_ANGULAR_LIMIT_HIGH = 14408; + public const int PHYS_PARAM_ANGULAR_LIMIT_HIGH = 14408; [ScriptConstant] - public static int PHYS_PARAM_USE_FRAME_OFFSET = 14409; + public const int PHYS_PARAM_USE_FRAME_OFFSET = 14409; [ScriptConstant] - public static int PHYS_PARAM_ENABLE_TRANSMOTOR = 14410; + public const int PHYS_PARAM_ENABLE_TRANSMOTOR = 14410; [ScriptConstant] - public static int PHYS_PARAM_TRANSMOTOR_MAXVEL = 14411; + public const int PHYS_PARAM_TRANSMOTOR_MAXVEL = 14411; [ScriptConstant] - public static int PHYS_PARAM_TRANSMOTOR_MAXFORCE = 14412; + public const int PHYS_PARAM_TRANSMOTOR_MAXFORCE = 14412; [ScriptConstant] - public static int PHYS_PARAM_CFM = 14413; + public const int PHYS_PARAM_CFM = 14413; [ScriptConstant] - public static int PHYS_PARAM_ERP = 14414; + public const int PHYS_PARAM_ERP = 14414; [ScriptConstant] - public static int PHYS_PARAM_SOLVER_ITERATIONS = 14415; + public const int PHYS_PARAM_SOLVER_ITERATIONS = 14415; [ScriptConstant] - public static int PHYS_PARAM_SPRING_DAMPING = 14416; + public const int PHYS_PARAM_SPRING_DAMPING = 14416; [ScriptConstant] - public static int PHYS_PARAM_SPRING_STIFFNESS = 14417; - public static int PHYS_PARAM_MAX = 14417; + public const int PHYS_PARAM_SPRING_STIFFNESS = 14417; + public const int PHYS_PARAM_MAX = 14417; // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) [ScriptInvocation] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index c09dd42..b72afc0 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -530,6 +530,28 @@ public sealed class BSLinksetConstraints : BSLinkset } break; case ExtendedPhysics.PhysFunctChangeLinkParams: + int setParam = 2; + switch (setParam) + { + case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: + case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: + case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC: + case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT: + case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW: + case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH: + case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW: + case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH: + case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET: + case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR: + case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL: + case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE: + case ExtendedPhysics.PHYS_PARAM_CFM: + case ExtendedPhysics.PHYS_PARAM_ERP: + case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS: + case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: + case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: + break; + } break; default: ret = base.Extension(pFunct, pParams); -- cgit v1.1 From e1120cb74db9092cc0f9a7fc245d2f2ed6160b7a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 16 Aug 2013 13:44:31 -0700 Subject: BulletSim: add extended physics function physGetLinkType(linkNum). Add implementation of physChangeLinkParams() in BSLinksetConstraint. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 19 +++ OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 11 ++ .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 145 ++++++++++++++++++--- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 11 +- 4 files changed, 163 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index e0f16d6..d035f7b 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -64,6 +64,7 @@ public class ExtendedPhysics : INonSharedRegionModule public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; public const string PhysFunctChangeLinkType = "BulletSim.ChangeLinkType"; + public const string PhysFunctGetLinkType = "BulletSim.GetLinkType"; public const string PhysFunctChangeLinkParams = "BulletSim.ChangeLinkParams"; // ============================================================= @@ -320,6 +321,24 @@ public class ExtendedPhysics : INonSharedRegionModule return ret; } + // physGetLinkType(integer linkNum) + [ScriptInvocation] + public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode) + { + int ret = -1; + if (!Enabled) return ret; + + PhysicsActor rootPhysActor; + PhysicsActor childPhysActor; + + if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) + { + ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, childPhysActor)); + } + + return ret; + } + // physChangeLinkFixed(integer linkNum) // Change the link between the root and the linkNum into a fixed, static physical connection. [ScriptInvocation] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 2058e3a..77f69a5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -209,6 +209,17 @@ public abstract class BSLinkset return ret; } + public bool TryGetLinkInfo(BSPrimLinkable child, out BSLinkInfo foundInfo) + { + bool ret = false; + BSLinkInfo found = null; + lock (m_linksetActivityLock) + { + ret = m_children.TryGetValue(child, out found); + } + foundInfo = found; + return ret; + } // Perform an action on each member of the linkset including root prim. // Depends on the action on whether this should be done at taint time. public delegate bool ForEachLinkInfoAction(BSLinkInfo obj); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index b72afc0..92df84e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -168,6 +168,8 @@ public sealed class BSLinksetConstraints : BSLinkset LinksetImpl = LinksetImplementation.Constraint; } + private static string LogHeader = "[BULLETSIM LINKSET CONSTRAINT]"; + // When physical properties are changed the linkset needs to recalculate // its internal properties. // This is queued in the 'post taint' queue so the @@ -511,7 +513,7 @@ public sealed class BSLinksetConstraints : BSLinkset RemoveDependencies(child); BSLinkInfo linkInfo = null; - if (m_children.TryGetValue(child, out linkInfo)) + if (TryGetLinkInfo(child, out linkInfo)) { BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; if (linkInfoC != null) @@ -529,28 +531,129 @@ public sealed class BSLinksetConstraints : BSLinkset } } break; + case ExtendedPhysics.PhysFunctGetLinkType: + if (pParams.Length > 0) + { + BSPrimLinkable child = pParams[0] as BSPrimLinkable; + if (child != null) + { + BSLinkInfo linkInfo = null; + if (TryGetLinkInfo(child, out linkInfo)) + { + BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; + if (linkInfoC != null) + { + ret = (object)(int)linkInfoC.constraintType; + } + } + } + } + break; case ExtendedPhysics.PhysFunctChangeLinkParams: - int setParam = 2; - switch (setParam) + // There should be two parameters: the childActor and a list of parameters to set + try + { + if (pParams.Length > 1) + { + BSPrimLinkable child = pParams[0] as BSPrimLinkable; + object[] setOps = (object[])pParams[1]; + BSLinkInfo baseLinkInfo = null; + if (TryGetLinkInfo(child, out baseLinkInfo)) + { + BSLinkInfoConstraint linkInfo = baseLinkInfo as BSLinkInfoConstraint; + if (linkInfo != null) + { + float valueFloat; + bool valueBool; + OMV.Vector3 valueVector; + OMV.Quaternion valueQuaternion; + + int opIndex = 0; + while (opIndex < setOps.Length) + { + int thisOp = (int)setOps[opIndex]; + switch (thisOp) + { + case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.frameInAloc = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: + valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1]; + linkInfo.frameInArot = valueQuaternion; + break; + case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.frameInBloc = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT: + valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1]; + linkInfo.frameInBrot = valueQuaternion; + break; + case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.linearLimitLow = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.linearLimitHigh = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.angularLimitLow = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH: + valueVector = (OMV.Vector3)setOps[opIndex + 1]; + linkInfo.angularLimitHigh = valueVector; + break; + case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET: + valueBool = (bool)setOps[opIndex + 1]; + linkInfo.useFrameOffset = valueBool; + break; + case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR: + valueBool = (bool)setOps[opIndex + 1]; + linkInfo.enableTransMotor = valueBool; + break; + case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.transMotorMaxVel = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.transMotorMaxForce = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_CFM: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.cfm = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_ERP: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.erp = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.solverIterations = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.springDamping = valueFloat; + break; + case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: + valueFloat = (float)setOps[opIndex + 1]; + linkInfo.springStiffness = valueFloat; + break; + default: + break; + } + } + } + } + } + } + catch (Exception e) { - case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: - case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: - case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC: - case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT: - case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW: - case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH: - case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW: - case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH: - case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET: - case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR: - case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL: - case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE: - case ExtendedPhysics.PHYS_PARAM_CFM: - case ExtendedPhysics.PHYS_PARAM_ERP: - case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS: - case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: - case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: - break; + // There are many ways to mess up the parameters. If not just right don't fail without some error. + m_physicsScene.Logger.WarnFormat("{0} bad parameters in physSetLinksetParams: {1}", LogHeader, e); } break; default: diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 6136257..28ea8c0 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -317,14 +317,21 @@ public class BSPrimLinkable : BSPrimDisplaced // Params: PhysActor linkedPrim, int typeCode case ExtendedPhysics.PhysFunctChangeLinkType: { - Linkset.Extension(pFunct, pParams); + ret = Linkset.Extension(pFunct, pParams); + break; + } + // physGetLinkType(linknum); + // Params: PhysActor linkedPrim + case ExtendedPhysics.PhysFunctGetLinkType: + { + ret = Linkset.Extension(pFunct, pParams); break; } // physChangeLinkParams(linknum, [code, value, code, value, ...]); // Params: PhysActor linkedPrim, object[] params case ExtendedPhysics.PhysFunctChangeLinkParams: { - Linkset.Extension(pFunct, pParams); + ret = Linkset.Extension(pFunct, pParams); break; } default: -- cgit v1.1 From 6d83f3f02190509119f65da92def19d08ef825f9 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 19 Aug 2013 11:08:22 -0700 Subject: BulletSim: adjust avatar capsule height calculation to be closer to defined SL heights. Correct BSParam avatar height defaults to be what's in OpenSimDefaults.ini. --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 15 ++++++++++----- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 291dfcd..28b2a7e 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -676,18 +676,20 @@ public sealed class BSCharacter : BSPhysObject float heightAdjust = BSParam.AvatarHeightMidFudge; if (BSParam.AvatarHeightLowFudge != 0f || BSParam.AvatarHeightHighFudge != 0f) { - // An avatar is between 1.61 and 2.12 meters. Midpoint is 1.87m. - // The "times 4" relies on the fact that the difference from the midpoint to the extremes is exactly 0.25 - float midHeightOffset = size.Z - 1.87f; + const float AVATAR_LOW = 1.1f; + const float AVATAR_MID = 1.775f; // 1.87f + const float AVATAR_HI = 2.45f; + // An avatar is between 1.1 and 2.45 meters. Midpoint is 1.775m. + float midHeightOffset = size.Z - AVATAR_MID; if (midHeightOffset < 0f) { // Small avatar. Add the adjustment based on the distance from midheight - heightAdjust += -1f * midHeightOffset * 4f * BSParam.AvatarHeightLowFudge; + heightAdjust += ((-1f * midHeightOffset) / (AVATAR_MID - AVATAR_LOW)) * BSParam.AvatarHeightLowFudge; } else { // Large avatar. Add the adjustment based on the distance from midheight - heightAdjust += midHeightOffset * 4f * BSParam.AvatarHeightHighFudge; + heightAdjust += ((midHeightOffset) / (AVATAR_HI - AVATAR_MID)) * BSParam.AvatarHeightHighFudge; } } // The total scale height is the central cylindar plus the caps on the two ends. @@ -698,6 +700,9 @@ public sealed class BSCharacter : BSPhysObject if (newScale.Z < 0) newScale.Z = 0.1f; + DetailLog("{0},BSCharacter.ComputerAvatarScale,size={1},lowF={2},midF={3},hiF={4},adj={5},newScale={6}", + LocalID, size, BSParam.AvatarHeightLowFudge, BSParam.AvatarHeightMidFudge, BSParam.AvatarHeightHighFudge, heightAdjust, newScale); + return newScale; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 737dda1..4e92e6d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -570,9 +570,9 @@ public static class BSParam new ParameterDefn("AvatarHeightLowFudge", "A fudge factor to make small avatars stand on the ground", -0.2f ), new ParameterDefn("AvatarHeightMidFudge", "A fudge distance to adjust average sized avatars to be standing on ground", - 0.2f ), + 0.1f ), new ParameterDefn("AvatarHeightHighFudge", "A fudge factor to make tall avatars stand on the ground", - 0.2f ), + 0.1f ), new ParameterDefn("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions", 0.1f ), new ParameterDefn("AvatarBelowGroundUpCorrectionMeters", "Meters to move avatar up if it seems to be below ground", -- cgit v1.1 From 4781297b4ee5908b76039ce3b38291eb2e89e157 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 20 Aug 2013 08:14:08 -0700 Subject: BulletSim: Extension parameters passed through the classes made to pass just and array of objects rather than a mixture of parameters and array. Makes understanding and parsing what is being passed much easier. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 23 ++++-- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 93 ++++++++++++++++------ OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 1 + .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 15 ++-- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 1 + 5 files changed, 98 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index d035f7b..90cf15a 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -315,7 +315,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, typeCode)); + object[] parms = { childPhysActor, typeCode }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms)); } return ret; @@ -323,7 +324,7 @@ public class ExtendedPhysics : INonSharedRegionModule // physGetLinkType(integer linkNum) [ScriptInvocation] - public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode) + public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum) { int ret = -1; if (!Enabled) return ret; @@ -333,7 +334,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, childPhysActor)); + object[] parms = { childPhysActor }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms)); } return ret; @@ -352,7 +354,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, PHYS_LINK_TYPE_FIXED)); + object[] parms = { childPhysActor , PHYS_LINK_TYPE_FIXED }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms)); } return ret; @@ -409,7 +412,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, childPhysActor, parms)); + object[] parms2 = AddToBeginningOfArray(childPhysActor, parms); + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, parms2)); } return ret; @@ -513,6 +517,15 @@ public class ExtendedPhysics : INonSharedRegionModule return ret; } + // Return an array of objects with the passed object as the first object of a new array + private object[] AddToBeginningOfArray(object firstOne, object[] prevArray) + { + object[] newArray = new object[1 + prevArray.Length]; + newArray[0] = firstOne; + prevArray.CopyTo(newArray, 1); + return newArray; + } + // Extension() returns an object. Convert that object into the integer error we expect to return. private int MakeIntError(object extensionRet) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 92df84e..87716b4 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -343,7 +343,7 @@ public sealed class BSLinksetConstraints : BSLinkset // real world coordinate of midpoint between the two objects OMV.Vector3 midPoint = rootPrim.Position + (childRelativePosition / 2); - DetailLog("{0},BSLinksetConstraint.BuildConstraint,6Dof,rBody={1},cBody={2},rLoc={3},cLoc={4},midLoc={7}", + DetailLog("{0},BSLinksetConstraint.BuildConstraint,6Dof,rBody={1},cBody={2},rLoc={3},cLoc={4},midLoc={5}", rootPrim.LocalID, rootPrim.PhysBody, linkInfo.member.PhysBody, rootPrim.Position, linkInfo.member.Position, midPoint); @@ -492,11 +492,12 @@ public sealed class BSLinksetConstraints : BSLinkset object ret = null; switch (pFunct) { - // pParams = (int linkNUm, PhysActor linkChild) + // pParams = [ BSPhysObject child, integer linkType ] case ExtendedPhysics.PhysFunctChangeLinkType: if (pParams.Length > 1) { int requestedType = (int)pParams[1]; + DetailLog("{0},BSLinksetConstraint.SetLinkType,requestedType={1}", LinksetRoot.LocalID, requestedType); if (requestedType == (int)ConstraintType.FIXED_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.D6_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE @@ -507,7 +508,7 @@ public sealed class BSLinksetConstraints : BSLinkset BSPrimLinkable child = pParams[0] as BSPrimLinkable; if (child != null) { - m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() + m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkType", delegate() { // Pick up all the constraints currently created. RemoveDependencies(child); @@ -522,15 +523,35 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfoC.ResetLink(); linkInfoC.constraintType = (ConstraintType)requestedType; ret = (object)true; + DetailLog("{0},BSLinksetConstraint.SetLinkType,link={1},type={2}", + linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType); + } + else + { + DetailLog("{0},BSLinksetConstraint.SetLinkType,linkInfoNotConstraint,childID={1}", LinksetRoot.LocalID, child.LocalID); } } + else + { + DetailLog("{0},BSLinksetConstraint.SetLinkType,noLinkInfoForChild,childID={1}", LinksetRoot.LocalID, child.LocalID); + } // Cause the whole linkset to be rebuilt in post-taint time. Refresh(child); }); } + else + { + DetailLog("{0},BSLinksetConstraint.SetLinkType,childNotBSPrimLinkable", LinksetRoot.LocalID); + } + } + else + { + DetailLog("{0},BSLinksetConstraint.SetLinkType,illegalRequestedType,reqested={1},spring={2}", + LinksetRoot.LocalID, requestedType, ((int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE)); } } break; + // pParams = [] case ExtendedPhysics.PhysFunctGetLinkType: if (pParams.Length > 0) { @@ -544,11 +565,15 @@ public sealed class BSLinksetConstraints : BSLinkset if (linkInfoC != null) { ret = (object)(int)linkInfoC.constraintType; + DetailLog("{0},BSLinksetConstraint.GetLinkType,link={1},type={2}", + linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType); + } } } } break; + // pParams = [ BSPhysObject child, int op, object opParams, int op, object opParams, ... ] case ExtendedPhysics.PhysFunctChangeLinkParams: // There should be two parameters: the childActor and a list of parameters to set try @@ -556,7 +581,6 @@ public sealed class BSLinksetConstraints : BSLinkset if (pParams.Length > 1) { BSPrimLinkable child = pParams[0] as BSPrimLinkable; - object[] setOps = (object[])pParams[1]; BSLinkInfo baseLinkInfo = null; if (TryGetLinkInfo(child, out baseLinkInfo)) { @@ -568,85 +592,106 @@ public sealed class BSLinksetConstraints : BSLinkset OMV.Vector3 valueVector; OMV.Quaternion valueQuaternion; - int opIndex = 0; - while (opIndex < setOps.Length) + int opIndex = 1; + while (opIndex < pParams.Length) { - int thisOp = (int)setOps[opIndex]; + int thisOp = (int)pParams[opIndex]; + DetailLog("{0},BSLinksetConstraint.ChangeLinkParams2,op={1},val={2}", + linkInfo.member.LocalID, thisOp, pParams[opIndex+1]); switch (thisOp) { case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.frameInAloc = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: - valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1]; + valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1]; linkInfo.frameInArot = valueQuaternion; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.frameInBloc = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT: - valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1]; + valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1]; linkInfo.frameInBrot = valueQuaternion; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.linearLimitLow = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.linearLimitHigh = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.angularLimitLow = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH: - valueVector = (OMV.Vector3)setOps[opIndex + 1]; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.angularLimitHigh = valueVector; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET: - valueBool = (bool)setOps[opIndex + 1]; + valueBool = (bool)pParams[opIndex + 1]; linkInfo.useFrameOffset = valueBool; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR: - valueBool = (bool)setOps[opIndex + 1]; + valueBool = (bool)pParams[opIndex + 1]; linkInfo.enableTransMotor = valueBool; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.transMotorMaxVel = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.transMotorMaxForce = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_CFM: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.cfm = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ERP: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.erp = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.solverIterations = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.springDamping = valueFloat; + opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: - valueFloat = (float)setOps[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 1]; linkInfo.springStiffness = valueFloat; + opIndex += 2; break; default: break; } } } + // Something changed so a rebuild is in order + Refresh(child); } } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 4685b48..45056bc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -1552,6 +1552,7 @@ public class BSPrim : BSPhysObject #region Extension public override object Extension(string pFunct, params object[] pParams) { + DetailLog("{0} BSPrim.Extension,op={1}", LocalID, pFunct); object ret = null; switch (pFunct) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 28ea8c0..531f8fb 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -283,17 +283,20 @@ public class BSPrimLinkable : BSPrimDisplaced #region Extension public override object Extension(string pFunct, params object[] pParams) { + DetailLog("{0} BSPrimLinkable.Extension,op={1},nParam={2}", LocalID, pFunct, pParams.Length); object ret = null; switch (pFunct) { // physGetLinksetType(); + // pParams = [] case ExtendedPhysics.PhysFunctGetLinksetType: { ret = (object)LinksetType; - m_log.DebugFormat("{0} Extension.physGetLinksetType, type={1}", LogHeader, ret); + DetailLog("{0},BSPrimLinkable.Extension.physGetLinksetType,type={1}", LocalID, ret); break; } // physSetLinksetType(type); + // pParams = [ BSPhysObject child, integer type ] case ExtendedPhysics.PhysFunctSetLinksetType: { if (pParams.Length > 0) @@ -304,8 +307,8 @@ public class BSPrimLinkable : BSPrimDisplaced PhysScene.TaintedObject("BSPrim.PhysFunctSetLinksetType", delegate() { // Cause the linkset type to change - m_log.DebugFormat("{0} Extension.physSetLinksetType, oldType={1}, newType={2}", - LogHeader, Linkset.LinksetImpl, linksetType); + DetailLog("{0},BSPrimLinkable.Extension.physSetLinksetType, oldType={1},newType={2}", + LocalID, Linkset.LinksetImpl, linksetType); ConvertLinkset(linksetType); }); } @@ -314,21 +317,21 @@ public class BSPrimLinkable : BSPrimDisplaced break; } // physChangeLinkType(linknum, typeCode); - // Params: PhysActor linkedPrim, int typeCode + // pParams = [ BSPhysObject child, integer linkType ] case ExtendedPhysics.PhysFunctChangeLinkType: { ret = Linkset.Extension(pFunct, pParams); break; } // physGetLinkType(linknum); - // Params: PhysActor linkedPrim + // pParams = [ BSPhysObject child ] case ExtendedPhysics.PhysFunctGetLinkType: { ret = Linkset.Extension(pFunct, pParams); break; } // physChangeLinkParams(linknum, [code, value, code, value, ...]); - // Params: PhysActor linkedPrim, object[] params + // pParams = [ BSPhysObject child, object[] [ string op, object opParam, string op, object opParam, ... ] ] case ExtendedPhysics.PhysFunctChangeLinkParams: { ret = Linkset.Extension(pFunct, pParams); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 7440468..b2ec0e5 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -869,6 +869,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters #region Extensions public override object Extension(string pFunct, params object[] pParams) { + DetailLog("{0} BSScene.Extension,op={1}", DetailLogZero, pFunct); return base.Extension(pFunct, pParams); } #endregion // Extensions -- cgit v1.1 From 995314f91f72eef0048a58f30e8dd8051f6bf14e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 20 Aug 2013 09:20:48 -0700 Subject: BulletSim: add ID parameter to TaintedObject calls so logging will include LocalID of object which created the taint. --- .../Physics/BulletSPlugin/BSActorAvatarMove.cs | 2 +- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 26 +++++----- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 4 +- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 2 +- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 6 +-- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 58 +++++++++++----------- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 6 +-- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 55 +++++++++++++------- 8 files changed, 89 insertions(+), 70 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs index 68bc1b9..04a4a32 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs @@ -105,7 +105,7 @@ public class BSActorAvatarMove : BSActor // into the movement motor. public void SetVelocityAndTarget(OMV.Vector3 vel, OMV.Vector3 targ, bool inTaintTime) { - m_physicsScene.TaintedObject(inTaintTime, "BSActorAvatarMove.setVelocityAndTarget", delegate() + m_physicsScene.TaintedObject(inTaintTime, m_controllingPrim.LocalID, "BSActorAvatarMove.setVelocityAndTarget", delegate() { if (m_velocityMotor != null) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 28b2a7e..fc18960 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -93,7 +93,7 @@ public sealed class BSCharacter : BSPhysObject LocalID, _size, Scale, Density, _avatarVolume, RawMass, pos); // do actual creation in taint time - PhysScene.TaintedObject("BSCharacter.create", delegate() + PhysScene.TaintedObject(LocalID, "BSCharacter.create", delegate() { DetailLog("{0},BSCharacter.create,taint", LocalID); // New body and shape into PhysBody and PhysShape @@ -121,7 +121,7 @@ public sealed class BSCharacter : BSPhysObject base.Destroy(); DetailLog("{0},BSCharacter.Destroy", LocalID); - PhysScene.TaintedObject("BSCharacter.destroy", delegate() + PhysScene.TaintedObject(LocalID, "BSCharacter.destroy", delegate() { PhysScene.Shapes.DereferenceBody(PhysBody, null /* bodyCallback */); PhysBody.Clear(); @@ -209,7 +209,7 @@ public sealed class BSCharacter : BSPhysObject DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}", LocalID, _size, Scale, Density, _avatarVolume, RawMass); - PhysScene.TaintedObject("BSCharacter.setSize", delegate() + PhysScene.TaintedObject(LocalID, "BSCharacter.setSize", delegate() { if (PhysBody.HasPhysicalBody && PhysShape.physShapeInfo.HasPhysicalShape) { @@ -257,7 +257,7 @@ public sealed class BSCharacter : BSPhysObject _rotationalVelocity = OMV.Vector3.Zero; // Zero some other properties directly into the physics engine - PhysScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() + PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.ZeroMotion", delegate() { if (PhysBody.HasPhysicalBody) PhysScene.PE.ClearAllForces(PhysBody); @@ -267,7 +267,7 @@ public sealed class BSCharacter : BSPhysObject { _rotationalVelocity = OMV.Vector3.Zero; - PhysScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() + PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.ZeroMotion", delegate() { if (PhysBody.HasPhysicalBody) { @@ -291,7 +291,7 @@ public sealed class BSCharacter : BSPhysObject set { RawPosition = value; - PhysScene.TaintedObject("BSCharacter.setPosition", delegate() + PhysScene.TaintedObject(LocalID, "BSCharacter.setPosition", delegate() { DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation); PositionSanityCheck(); @@ -363,7 +363,7 @@ public sealed class BSCharacter : BSPhysObject { // The new position value must be pushed into the physics engine but we can't // just assign to "Position" because of potential call loops. - PhysScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate() + PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.PositionSanityCheck", delegate() { DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation); ForcePosition = RawPosition; @@ -390,7 +390,7 @@ public sealed class BSCharacter : BSPhysObject set { RawForce = value; // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); - PhysScene.TaintedObject("BSCharacter.SetForce", delegate() + PhysScene.TaintedObject(LocalID, "BSCharacter.SetForce", delegate() { DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, RawForce); if (PhysBody.HasPhysicalBody) @@ -438,7 +438,7 @@ public sealed class BSCharacter : BSPhysObject set { RawVelocity = value; // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, RawVelocity); - PhysScene.TaintedObject("BSCharacter.setVelocity", delegate() + PhysScene.TaintedObject(LocalID, "BSCharacter.setVelocity", delegate() { if (m_moveActor != null) m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, true /* inTaintTime */); @@ -480,7 +480,7 @@ public sealed class BSCharacter : BSPhysObject if (RawOrientation != value) { RawOrientation = value; - PhysScene.TaintedObject("BSCharacter.setOrientation", delegate() + PhysScene.TaintedObject(LocalID, "BSCharacter.setOrientation", delegate() { // Bullet assumes we know what we are doing when forcing orientation // so it lets us go against all the rules and just compensates for them later. @@ -560,7 +560,7 @@ public sealed class BSCharacter : BSPhysObject public override bool FloatOnWater { set { _floatOnWater = value; - PhysScene.TaintedObject("BSCharacter.setFloatOnWater", delegate() + PhysScene.TaintedObject(LocalID, "BSCharacter.setFloatOnWater", delegate() { if (PhysBody.HasPhysicalBody) { @@ -588,7 +588,7 @@ public sealed class BSCharacter : BSPhysObject public override float Buoyancy { get { return _buoyancy; } set { _buoyancy = value; - PhysScene.TaintedObject("BSCharacter.setBuoyancy", delegate() + PhysScene.TaintedObject(LocalID, "BSCharacter.setBuoyancy", delegate() { DetailLog("{0},BSCharacter.setBuoyancy,taint,buoy={1}", LocalID, _buoyancy); ForceBuoyancy = _buoyancy; @@ -633,7 +633,7 @@ public sealed class BSCharacter : BSPhysObject OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); // DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce); - PhysScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate() + PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.AddForce", delegate() { // Bullet adds this central force to the total force for this tick // DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 87716b4..b2a9501 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -297,7 +297,7 @@ public sealed class BSLinksetConstraints : BSLinkset rootx.LocalID, rootx.PhysBody.AddrString, childx.LocalID, childx.PhysBody.AddrString); - m_physicsScene.TaintedObject(inTaintTime, "BSLinksetConstraints.RemoveChildFromLinkset", delegate() + m_physicsScene.TaintedObject(inTaintTime, childx.LocalID, "BSLinksetConstraints.RemoveChildFromLinkset", delegate() { PhysicallyUnlinkAChildFromRoot(rootx, childx); }); @@ -508,7 +508,7 @@ public sealed class BSLinksetConstraints : BSLinkset BSPrimLinkable child = pParams[0] as BSPrimLinkable; if (child != null) { - m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkType", delegate() + m_physicsScene.TaintedObject(child.LocalID, "BSLinksetConstraint.PhysFunctChangeLinkType", delegate() { // Pick up all the constraints currently created. RemoveDependencies(child); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 4e92e6d..2f1799b 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -826,7 +826,7 @@ public static class BSParam private static void ResetConstraintSolverTainted(BSScene pPhysScene, float v) { BSScene physScene = pPhysScene; - physScene.TaintedObject("BSParam.ResetConstraintSolver", delegate() + physScene.TaintedObject(BSScene.DetailLogZero, "BSParam.ResetConstraintSolver", delegate() { physScene.PE.ResetConstraintSolver(physScene.World); }); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 9dc52d5..2efb1a5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -121,7 +121,7 @@ public abstract class BSPhysObject : PhysicsActor public virtual void Destroy() { PhysicalActors.Enable(false); - PhysScene.TaintedObject("BSPhysObject.Destroy", delegate() + PhysScene.TaintedObject(LocalID, "BSPhysObject.Destroy", delegate() { PhysicalActors.Dispose(); }); @@ -509,7 +509,7 @@ public abstract class BSPhysObject : PhysicsActor // make sure first collision happens NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs); - PhysScene.TaintedObject(TypeName+".SubscribeEvents", delegate() + PhysScene.TaintedObject(LocalID, TypeName+".SubscribeEvents", delegate() { if (PhysBody.HasPhysicalBody) CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); @@ -524,7 +524,7 @@ public abstract class BSPhysObject : PhysicsActor public override void UnSubscribeEvents() { // DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName); SubscribedEventsMs = 0; - PhysScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() + PhysScene.TaintedObject(LocalID, TypeName+".UnSubscribeEvents", delegate() { // Make sure there is a body there because sometimes destruction happens in an un-ideal order. if (PhysBody.HasPhysicalBody) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 45056bc..15b7090 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -102,7 +102,7 @@ public class BSPrim : BSPhysObject // DetailLog("{0},BSPrim.constructor,call", LocalID); // do the actual object creation at taint time - PhysScene.TaintedObject("BSPrim.create", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.create", delegate() { // Make sure the object is being created with some sanity. ExtremeSanityCheck(true /* inTaintTime */); @@ -126,7 +126,7 @@ public class BSPrim : BSPhysObject // Undo any vehicle properties this.VehicleType = (int)Vehicle.TYPE_NONE; - PhysScene.TaintedObject("BSPrim.Destroy", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.Destroy", delegate() { DetailLog("{0},BSPrim.Destroy,taint,", LocalID); // If there are physical body and shape, release my use of same. @@ -161,7 +161,7 @@ public class BSPrim : BSPhysObject } public override bool ForceBodyShapeRebuild(bool inTaintTime) { - PhysScene.TaintedObject(inTaintTime, "BSPrim.ForceBodyShapeRebuild", delegate() + PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ForceBodyShapeRebuild", delegate() { _mass = CalculateMass(); // changing the shape changes the mass CreateGeomAndObject(true); @@ -178,7 +178,7 @@ public class BSPrim : BSPhysObject if (value != _isSelected) { _isSelected = value; - PhysScene.TaintedObject("BSPrim.setSelected", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setSelected", delegate() { DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected); SetObjectDynamic(false); @@ -224,7 +224,7 @@ public class BSPrim : BSPhysObject _rotationalVelocity = OMV.Vector3.Zero; // Zero some other properties in the physics engine - PhysScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() + PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ZeroMotion", delegate() { if (PhysBody.HasPhysicalBody) PhysScene.PE.ClearAllForces(PhysBody); @@ -234,7 +234,7 @@ public class BSPrim : BSPhysObject { _rotationalVelocity = OMV.Vector3.Zero; // Zero some other properties in the physics engine - PhysScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() + PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ZeroMotion", delegate() { // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); if (PhysBody.HasPhysicalBody) @@ -262,7 +262,7 @@ public class BSPrim : BSPhysObject }); // Update parameters so the new actor's Refresh() action is called at the right time. - PhysScene.TaintedObject("BSPrim.LockAngularMotion", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.LockAngularMotion", delegate() { UpdatePhysicalParameters(); }); @@ -287,7 +287,7 @@ public class BSPrim : BSPhysObject RawPosition = value; PositionSanityCheck(false); - PhysScene.TaintedObject("BSPrim.setPosition", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setPosition", delegate() { DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation); ForcePosition = RawPosition; @@ -531,7 +531,7 @@ public class BSPrim : BSPhysObject set { Vehicle type = (Vehicle)value; - PhysScene.TaintedObject("setVehicleType", delegate() + PhysScene.TaintedObject(LocalID, "setVehicleType", delegate() { // Some vehicle scripts change vehicle type on the fly as an easy way to // change all the parameters. Like a plane changing to CAR when on the @@ -561,7 +561,7 @@ public class BSPrim : BSPhysObject } public override void VehicleFloatParam(int param, float value) { - PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.VehicleFloatParam", delegate() { BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) @@ -573,7 +573,7 @@ public class BSPrim : BSPhysObject } public override void VehicleVectorParam(int param, OMV.Vector3 value) { - PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.VehicleVectorParam", delegate() { BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) @@ -585,7 +585,7 @@ public class BSPrim : BSPhysObject } public override void VehicleRotationParam(int param, OMV.Quaternion rotation) { - PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.VehicleRotationParam", delegate() { BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) @@ -597,7 +597,7 @@ public class BSPrim : BSPhysObject } public override void VehicleFlags(int param, bool remove) { - PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.VehicleFlags", delegate() { BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) @@ -613,7 +613,7 @@ public class BSPrim : BSPhysObject if (_isVolumeDetect != newValue) { _isVolumeDetect = newValue; - PhysScene.TaintedObject("BSPrim.SetVolumeDetect", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.SetVolumeDetect", delegate() { // DetailLog("{0},setVolumeDetect,taint,volDetect={1}", LocalID, _isVolumeDetect); SetObjectDynamic(true); @@ -628,7 +628,7 @@ public class BSPrim : BSPhysObject public override void SetMaterial(int material) { base.SetMaterial(material); - PhysScene.TaintedObject("BSPrim.SetMaterial", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.SetMaterial", delegate() { UpdatePhysicalParameters(); }); @@ -641,7 +641,7 @@ public class BSPrim : BSPhysObject if (base.Friction != value) { base.Friction = value; - PhysScene.TaintedObject("BSPrim.setFriction", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setFriction", delegate() { UpdatePhysicalParameters(); }); @@ -656,7 +656,7 @@ public class BSPrim : BSPhysObject if (base.Restitution != value) { base.Restitution = value; - PhysScene.TaintedObject("BSPrim.setRestitution", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setRestitution", delegate() { UpdatePhysicalParameters(); }); @@ -673,7 +673,7 @@ public class BSPrim : BSPhysObject if (base.Density != value) { base.Density = value; - PhysScene.TaintedObject("BSPrim.setDensity", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setDensity", delegate() { UpdatePhysicalParameters(); }); @@ -688,7 +688,7 @@ public class BSPrim : BSPhysObject if (base.GravModifier != value) { base.GravModifier = value; - PhysScene.TaintedObject("BSPrim.setGravityModifier", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setGravityModifier", delegate() { UpdatePhysicalParameters(); }); @@ -699,7 +699,7 @@ public class BSPrim : BSPhysObject get { return RawVelocity; } set { RawVelocity = value; - PhysScene.TaintedObject("BSPrim.setVelocity", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setVelocity", delegate() { // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, RawVelocity); ForceVelocity = RawVelocity; @@ -745,7 +745,7 @@ public class BSPrim : BSPhysObject return; RawOrientation = value; - PhysScene.TaintedObject("BSPrim.setOrientation", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setOrientation", delegate() { ForceOrientation = RawOrientation; }); @@ -776,7 +776,7 @@ public class BSPrim : BSPhysObject if (_isPhysical != value) { _isPhysical = value; - PhysScene.TaintedObject("BSPrim.setIsPhysical", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setIsPhysical", delegate() { DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical); SetObjectDynamic(true); @@ -1020,7 +1020,7 @@ public class BSPrim : BSPhysObject public override bool FloatOnWater { set { _floatOnWater = value; - PhysScene.TaintedObject("BSPrim.setFloatOnWater", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setFloatOnWater", delegate() { if (_floatOnWater) CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); @@ -1037,7 +1037,7 @@ public class BSPrim : BSPhysObject _rotationalVelocity = value; Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity); // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); - PhysScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setRotationalVelocity", delegate() { ForceRotationalVelocity = _rotationalVelocity; }); @@ -1068,7 +1068,7 @@ public class BSPrim : BSPhysObject get { return _buoyancy; } set { _buoyancy = value; - PhysScene.TaintedObject("BSPrim.setBuoyancy", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.setBuoyancy", delegate() { ForceBuoyancy = _buoyancy; }); @@ -1142,7 +1142,7 @@ public class BSPrim : BSPhysObject // DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); OMV.Vector3 addForce = force; - PhysScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() + PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.AddForce", delegate() { // Bullet adds this central force to the total force for this tick. // Deep down in Bullet: @@ -1172,7 +1172,7 @@ public class BSPrim : BSPhysObject OMV.Vector3 addImpulse = Util.ClampV(impulse, BSParam.MaxAddForceMagnitude); // DetailLog("{0},BSPrim.addForceImpulse,call,impulse={1}", LocalID, impulse); - PhysScene.TaintedObject(inTaintTime, "BSPrim.AddImpulse", delegate() + PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.AddImpulse", delegate() { // Bullet adds this impulse immediately to the velocity DetailLog("{0},BSPrim.addForceImpulse,taint,impulseforce={1}", LocalID, addImpulse); @@ -1197,7 +1197,7 @@ public class BSPrim : BSPhysObject if (force.IsFinite()) { OMV.Vector3 angForce = force; - PhysScene.TaintedObject(inTaintTime, "BSPrim.AddAngularForce", delegate() + PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.AddAngularForce", delegate() { if (PhysBody.HasPhysicalBody) { @@ -1221,7 +1221,7 @@ public class BSPrim : BSPhysObject public void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime) { OMV.Vector3 applyImpulse = impulse; - PhysScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate() + PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ApplyTorqueImpulse", delegate() { if (PhysBody.HasPhysicalBody) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 531f8fb..840265b 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -108,7 +108,7 @@ public class BSPrimLinkable : BSPrimDisplaced set { base.Position = value; - PhysScene.TaintedObject("BSPrimLinkable.setPosition", delegate() + PhysScene.TaintedObject(LocalID, "BSPrimLinkable.setPosition", delegate() { Linkset.UpdateProperties(UpdatedProperties.Position, this); }); @@ -122,7 +122,7 @@ public class BSPrimLinkable : BSPrimDisplaced set { base.Orientation = value; - PhysScene.TaintedObject("BSPrimLinkable.setOrientation", delegate() + PhysScene.TaintedObject(LocalID, "BSPrimLinkable.setOrientation", delegate() { Linkset.UpdateProperties(UpdatedProperties.Orientation, this); }); @@ -304,7 +304,7 @@ public class BSPrimLinkable : BSPrimDisplaced BSLinkset.LinksetImplementation linksetType = (BSLinkset.LinksetImplementation)pParams[0]; if (Linkset.IsRoot(this)) { - PhysScene.TaintedObject("BSPrim.PhysFunctSetLinksetType", delegate() + PhysScene.TaintedObject(LocalID, "BSPrim.PhysFunctSetLinksetType", delegate() { // Cause the linkset type to change DetailLog("{0},BSPrimLinkable.Extension.physSetLinksetType, oldType={1},newType={2}", diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index b2ec0e5..24233cc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -157,12 +157,20 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters public delegate void TaintCallback(); private struct TaintCallbackEntry { + public String originator; public String ident; public TaintCallback callback; - public TaintCallbackEntry(string i, TaintCallback c) + public TaintCallbackEntry(string pIdent, TaintCallback pCallBack) { - ident = i; - callback = c; + originator = BSScene.DetailLogZero; + ident = pIdent; + callback = pCallBack; + } + public TaintCallbackEntry(string pOrigin, string pIdent, TaintCallback pCallBack) + { + originator = pOrigin; + ident = pIdent; + callback = pCallBack; } } private Object _taintLock = new Object(); // lock for using the next object @@ -888,26 +896,37 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters // Calls to the PhysicsActors can't directly call into the physics engine // because it might be busy. We delay changes to a known time. // We rely on C#'s closure to save and restore the context for the delegate. - public void TaintedObject(String ident, TaintCallback callback) + public void TaintedObject(string pOriginator, string pIdent, TaintCallback pCallback) { - if (!m_initialized) return; - - lock (_taintLock) - { - _taintOperations.Add(new TaintCallbackEntry(ident, callback)); - } - - return; + TaintedObject(false /*inTaintTime*/, pOriginator, pIdent, pCallback); + } + public void TaintedObject(uint pOriginator, String pIdent, TaintCallback pCallback) + { + TaintedObject(false /*inTaintTime*/, m_physicsLoggingEnabled ? pOriginator.ToString() : BSScene.DetailLogZero, pIdent, pCallback); + } + public void TaintedObject(bool inTaintTime, String pIdent, TaintCallback pCallback) + { + TaintedObject(inTaintTime, BSScene.DetailLogZero, pIdent, pCallback); + } + public void TaintedObject(bool inTaintTime, uint pOriginator, String pIdent, TaintCallback pCallback) + { + TaintedObject(inTaintTime, m_physicsLoggingEnabled ? pOriginator.ToString() : BSScene.DetailLogZero, pIdent, pCallback); } - // Sometimes a potentially tainted operation can be used in and out of taint time. // This routine executes the command immediately if in taint-time otherwise it is queued. - public void TaintedObject(bool inTaintTime, string ident, TaintCallback callback) + public void TaintedObject(bool inTaintTime, string pOriginator, string pIdent, TaintCallback pCallback) { + if (!m_initialized) return; + if (inTaintTime) - callback(); + pCallback(); else - TaintedObject(ident, callback); + { + lock (_taintLock) + { + _taintOperations.Add(new TaintCallbackEntry(pOriginator, pIdent, pCallback)); + } + } } private void TriggerPreStepEvent(float timeStep) @@ -951,7 +970,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters { try { - DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", DetailLogZero, tcbe.ident); // DEBUG DEBUG DEBUG + DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", tcbe.originator, tcbe.ident); // DEBUG DEBUG DEBUG tcbe.callback(); } catch (Exception e) @@ -1081,7 +1100,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters string xval = val; List xlIDs = lIDs; string xparm = parm; - TaintedObject("BSScene.UpdateParameterSet", delegate() { + TaintedObject(DetailLogZero, "BSScene.UpdateParameterSet", delegate() { BSParam.ParameterDefnBase thisParam; if (BSParam.TryGetParameter(xparm, out thisParam)) { -- cgit v1.1 From d09c35f5063114880aecb94a938bfc49f5af5f7d Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 20 Aug 2013 13:09:40 -0700 Subject: BulletSim: pass both root and child BSPhysObjects to Extension function. Update routines to use the new parameters list from above change. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 30 +++++++++++--------- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 32 ++++++++++++---------- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 14 +++++----- 3 files changed, 41 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 90cf15a..10e13b9 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -220,7 +220,8 @@ public class ExtendedPhysics : INonSharedRegionModule containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition); containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation); - ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType)); + object[] parms2 = { rootPhysActor, null, linksetType }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, parms2)); Thread.Sleep(150); // longer than one heartbeat tick containingGroup.ScriptSetPhysicsStatus(true); @@ -229,7 +230,8 @@ public class ExtendedPhysics : INonSharedRegionModule { // Non-physical linksets don't have a physical instantiation so there is no state to // worry about being updated. - ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType)); + object[] parms2 = { rootPhysActor, null, linksetType }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, parms2)); } } else @@ -271,7 +273,8 @@ public class ExtendedPhysics : INonSharedRegionModule PhysicsActor rootPhysActor = rootPart.PhysActor; if (rootPhysActor != null) { - ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType)); + object[] parms2 = { rootPhysActor, null }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType, parms2)); } else { @@ -315,8 +318,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - object[] parms = { childPhysActor, typeCode }; - ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms)); + object[] parms2 = { rootPhysActor, childPhysActor, typeCode }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2)); } return ret; @@ -334,8 +337,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - object[] parms = { childPhysActor }; - ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms)); + object[] parms2 = { rootPhysActor, childPhysActor }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms2)); } return ret; @@ -354,8 +357,8 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - object[] parms = { childPhysActor , PHYS_LINK_TYPE_FIXED }; - ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms)); + object[] parms2 = { rootPhysActor, childPhysActor , PHYS_LINK_TYPE_FIXED }; + ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2)); } return ret; @@ -412,7 +415,7 @@ public class ExtendedPhysics : INonSharedRegionModule if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) { - object[] parms2 = AddToBeginningOfArray(childPhysActor, parms); + object[] parms2 = AddToBeginningOfArray(rootPhysActor, childPhysActor, parms); ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, parms2)); } @@ -518,11 +521,12 @@ public class ExtendedPhysics : INonSharedRegionModule } // Return an array of objects with the passed object as the first object of a new array - private object[] AddToBeginningOfArray(object firstOne, object[] prevArray) + private object[] AddToBeginningOfArray(object firstOne, object secondOne, object[] prevArray) { - object[] newArray = new object[1 + prevArray.Length]; + object[] newArray = new object[2 + prevArray.Length]; newArray[0] = firstOne; - prevArray.CopyTo(newArray, 1); + newArray[1] = secondOne; + prevArray.CopyTo(newArray, 2); return newArray; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index b2a9501..a9ae89d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -385,7 +385,7 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfo.frameInAloc, linkInfo.frameInArot, linkInfo.frameInBloc, linkInfo.frameInBrot, true /*useLinearReferenceFrameA*/, true /*disableCollisionsBetweenLinkedBodies*/); - DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", + DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6}", rootPrim.LocalID, rootPrim.LocalID, rootPrim.PhysBody.AddrString, linkInfo.member.LocalID, linkInfo.member.PhysBody.AddrString, @@ -492,12 +492,12 @@ public sealed class BSLinksetConstraints : BSLinkset object ret = null; switch (pFunct) { - // pParams = [ BSPhysObject child, integer linkType ] + // pParams = [ BSPhysObject root, BSPhysObject child, integer linkType ] case ExtendedPhysics.PhysFunctChangeLinkType: - if (pParams.Length > 1) + if (pParams.Length > 2) { - int requestedType = (int)pParams[1]; - DetailLog("{0},BSLinksetConstraint.SetLinkType,requestedType={1}", LinksetRoot.LocalID, requestedType); + int requestedType = (int)pParams[2]; + DetailLog("{0},BSLinksetConstraint.ChangeLinkType,requestedType={1}", LinksetRoot.LocalID, requestedType); if (requestedType == (int)ConstraintType.FIXED_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.D6_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE @@ -505,9 +505,11 @@ public sealed class BSLinksetConstraints : BSLinkset || requestedType == (int)ConstraintType.CONETWIST_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.SLIDER_CONSTRAINT_TYPE) { - BSPrimLinkable child = pParams[0] as BSPrimLinkable; + BSPrimLinkable child = pParams[1] as BSPrimLinkable; if (child != null) { + DetailLog("{0},BSLinksetConstraint.ChangeLinkType,rootID={1},childID={2},type={3}", + LinksetRoot.LocalID, LinksetRoot.LocalID, child.LocalID, requestedType); m_physicsScene.TaintedObject(child.LocalID, "BSLinksetConstraint.PhysFunctChangeLinkType", delegate() { // Pick up all the constraints currently created. @@ -523,17 +525,17 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfoC.ResetLink(); linkInfoC.constraintType = (ConstraintType)requestedType; ret = (object)true; - DetailLog("{0},BSLinksetConstraint.SetLinkType,link={1},type={2}", + DetailLog("{0},BSLinksetConstraint.ChangeLinkType,link={1},type={2}", linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType); } else { - DetailLog("{0},BSLinksetConstraint.SetLinkType,linkInfoNotConstraint,childID={1}", LinksetRoot.LocalID, child.LocalID); + DetailLog("{0},BSLinksetConstraint.ChangeLinkType,linkInfoNotConstraint,childID={1}", LinksetRoot.LocalID, child.LocalID); } } else { - DetailLog("{0},BSLinksetConstraint.SetLinkType,noLinkInfoForChild,childID={1}", LinksetRoot.LocalID, child.LocalID); + DetailLog("{0},BSLinksetConstraint.ChangeLinkType,noLinkInfoForChild,childID={1}", LinksetRoot.LocalID, child.LocalID); } // Cause the whole linkset to be rebuilt in post-taint time. Refresh(child); @@ -551,11 +553,11 @@ public sealed class BSLinksetConstraints : BSLinkset } } break; - // pParams = [] + // pParams = [ BSPhysObject root, BSPhysObject child ] case ExtendedPhysics.PhysFunctGetLinkType: if (pParams.Length > 0) { - BSPrimLinkable child = pParams[0] as BSPrimLinkable; + BSPrimLinkable child = pParams[1] as BSPrimLinkable; if (child != null) { BSLinkInfo linkInfo = null; @@ -573,14 +575,14 @@ public sealed class BSLinksetConstraints : BSLinkset } } break; - // pParams = [ BSPhysObject child, int op, object opParams, int op, object opParams, ... ] + // pParams = [ BSPhysObject root, BSPhysObject child, int op, object opParams, int op, object opParams, ... ] case ExtendedPhysics.PhysFunctChangeLinkParams: // There should be two parameters: the childActor and a list of parameters to set try { - if (pParams.Length > 1) + if (pParams.Length > 2) { - BSPrimLinkable child = pParams[0] as BSPrimLinkable; + BSPrimLinkable child = pParams[1] as BSPrimLinkable; BSLinkInfo baseLinkInfo = null; if (TryGetLinkInfo(child, out baseLinkInfo)) { @@ -592,7 +594,7 @@ public sealed class BSLinksetConstraints : BSLinkset OMV.Vector3 valueVector; OMV.Quaternion valueQuaternion; - int opIndex = 1; + int opIndex = 2; while (opIndex < pParams.Length) { int thisOp = (int)pParams[opIndex]; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 840265b..126b146 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -288,7 +288,7 @@ public class BSPrimLinkable : BSPrimDisplaced switch (pFunct) { // physGetLinksetType(); - // pParams = [] + // pParams = [ BSPhysObject root, null ] case ExtendedPhysics.PhysFunctGetLinksetType: { ret = (object)LinksetType; @@ -296,12 +296,12 @@ public class BSPrimLinkable : BSPrimDisplaced break; } // physSetLinksetType(type); - // pParams = [ BSPhysObject child, integer type ] + // pParams = [ BSPhysObject root, null, integer type ] case ExtendedPhysics.PhysFunctSetLinksetType: { - if (pParams.Length > 0) + if (pParams.Length > 2) { - BSLinkset.LinksetImplementation linksetType = (BSLinkset.LinksetImplementation)pParams[0]; + BSLinkset.LinksetImplementation linksetType = (BSLinkset.LinksetImplementation)pParams[2]; if (Linkset.IsRoot(this)) { PhysScene.TaintedObject(LocalID, "BSPrim.PhysFunctSetLinksetType", delegate() @@ -317,21 +317,21 @@ public class BSPrimLinkable : BSPrimDisplaced break; } // physChangeLinkType(linknum, typeCode); - // pParams = [ BSPhysObject child, integer linkType ] + // pParams = [ BSPhysObject root, BSPhysObject child, integer linkType ] case ExtendedPhysics.PhysFunctChangeLinkType: { ret = Linkset.Extension(pFunct, pParams); break; } // physGetLinkType(linknum); - // pParams = [ BSPhysObject child ] + // pParams = [ BSPhysObject root, BSPhysObject child ] case ExtendedPhysics.PhysFunctGetLinkType: { ret = Linkset.Extension(pFunct, pParams); break; } // physChangeLinkParams(linknum, [code, value, code, value, ...]); - // pParams = [ BSPhysObject child, object[] [ string op, object opParam, string op, object opParam, ... ] ] + // pParams = [ BSPhysObject root, BSPhysObject child, object[] [ string op, object opParam, string op, object opParam, ... ] ] case ExtendedPhysics.PhysFunctChangeLinkParams: { ret = Linkset.Extension(pFunct, pParams); -- cgit v1.1 From e0b457d3c3daabc065aa66376bc17472d4b43e8f Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 21 Aug 2013 16:02:42 -0700 Subject: BulletSim: add position and rotation update for child prim physics update events. Normally, physics engines do not return updates for child prims so, under normal operation, this code should never execute. Will only be used when using flexible linkset linkages. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2e11162..b30c024 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2502,6 +2502,26 @@ namespace OpenSim.Region.Framework.Scenes //ParentGroup.RootPart.m_groupPosition = newpos; } + if (pa != null && ParentID != 0 && ParentGroup != null) + { + // RA: Special case where a child object is requesting property updates. + // This happens when linksets are modified to use flexible links rather than + // the default links. + // The simulator code presumes that child parts are only modified by scripts + // so the logic for changing position/rotation/etc does not take into + // account the physical object actually moving. + // This code updates the offset position and rotation of the child and then + // lets the update code push the update to the viewer. + // Since physics engines do not normally generate this event for linkset children, + // this code will not be active unless you have a specially configured + // physics engine. + Quaternion invRootRotation = Quaternion.Normalize(Quaternion.Inverse(ParentGroup.RootPart.RotationOffset)); + m_offsetPosition = pa.Position - m_groupPosition; + RotationOffset = pa.Orientation * invRootRotation; + m_log.DebugFormat("{0} PhysicsRequestingTerseUpdate child: pos={1}, rot={2}, offPos={3}, offRot={4}", + "[SCENE OBJECT PART]", pa.Position, pa.Orientation, m_offsetPosition, RotationOffset); + } + ScheduleTerseUpdate(); } -- cgit v1.1 From 3dbf4a1002216e2d14c20353a5993ea63413d03d Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 22 Aug 2013 09:05:26 -0700 Subject: BulletSim: remove chatty debug message from previous commit. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b30c024..b3e6b67 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2504,7 +2504,7 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null && ParentID != 0 && ParentGroup != null) { - // RA: Special case where a child object is requesting property updates. + // Special case where a child object is requesting property updates. // This happens when linksets are modified to use flexible links rather than // the default links. // The simulator code presumes that child parts are only modified by scripts @@ -2518,8 +2518,8 @@ namespace OpenSim.Region.Framework.Scenes Quaternion invRootRotation = Quaternion.Normalize(Quaternion.Inverse(ParentGroup.RootPart.RotationOffset)); m_offsetPosition = pa.Position - m_groupPosition; RotationOffset = pa.Orientation * invRootRotation; - m_log.DebugFormat("{0} PhysicsRequestingTerseUpdate child: pos={1}, rot={2}, offPos={3}, offRot={4}", - "[SCENE OBJECT PART]", pa.Position, pa.Orientation, m_offsetPosition, RotationOffset); + // m_log.DebugFormat("{0} PhysicsRequestingTerseUpdate child: pos={1}, rot={2}, offPos={3}, offRot={4}", + // "[SCENE OBJECT PART]", pa.Position, pa.Orientation, m_offsetPosition, RotationOffset); } ScheduleTerseUpdate(); -- cgit v1.1 From 67195618d580eb6cd848cf1e6462572ad2b2b118 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 22 Aug 2013 09:07:58 -0700 Subject: BulletSim: add requestor's ID to post taint detail log message. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 24233cc..b3dfa41 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -987,10 +987,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters // will replace any previous operation by the same object. public void PostTaintObject(String ident, uint ID, TaintCallback callback) { - string uniqueIdent = ident + "-" + ID.ToString(); + string IDAsString = ID.ToString(); + string uniqueIdent = ident + "-" + IDAsString; lock (_taintLock) { - _postTaintOperations[uniqueIdent] = new TaintCallbackEntry(uniqueIdent, callback); + _postTaintOperations[uniqueIdent] = new TaintCallbackEntry(IDAsString, uniqueIdent, callback); } return; -- cgit v1.1 From 30b3657a66e5a4012b96baae2c0424ec13409f83 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 22 Aug 2013 09:08:58 -0700 Subject: BulletSim: implementation of setting spring specific physical parameters. Add setting of linkset type to physChangeLinkParams. Lots of detail logging for setting of linkset constraint parameters. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 6 ++- .../Physics/BulletSPlugin/BSConstraint6Dof.cs | 16 ++++--- .../Physics/BulletSPlugin/BSConstraintSpring.cs | 43 ++++++++++-------- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 52 +++++++++++++++++----- 4 files changed, 81 insertions(+), 36 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 10e13b9..2f88e2b 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -367,6 +367,7 @@ public class ExtendedPhysics : INonSharedRegionModule // Code for specifying params. // The choice if 14400 is arbitrary and only serves to catch parameter code misuse. public const int PHYS_PARAM_MIN = 14401; + [ScriptConstant] public const int PHYS_PARAM_FRAMEINA_LOC = 14401; [ScriptConstant] @@ -401,7 +402,10 @@ public class ExtendedPhysics : INonSharedRegionModule public const int PHYS_PARAM_SPRING_DAMPING = 14416; [ScriptConstant] public const int PHYS_PARAM_SPRING_STIFFNESS = 14417; - public const int PHYS_PARAM_MAX = 14417; + [ScriptConstant] + public const int PHYS_PARAM_LINK_TYPE = 14418; + + public const int PHYS_PARAM_MAX = 14418; // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) [ScriptInvocation] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs index 5008ff7..7fcb75c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs @@ -59,9 +59,11 @@ public class BSConstraint6Dof : BSConstraint frame2, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); m_enabled = true; - world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", - BSScene.DetailLogZero, world.worldID, + PhysicsScene.DetailLog("{0},BS6DofConstraint,create,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", + m_body1.ID, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); + PhysicsScene.DetailLog("{0},BS6DofConstraint,create, f1Loc={1},f1Rot={2},f2Loc={3},f2Rot={4},usefA={5},disCol={6}", + m_body1.ID, frame1, frame1rot, frame2, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); } // 6 Dof constraint based on a midpoint between the two constrained bodies @@ -86,9 +88,11 @@ public class BSConstraint6Dof : BSConstraint m_constraint = PhysicsScene.PE.Create6DofConstraintToPoint(m_world, m_body1, m_body2, joinPoint, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); + PhysicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}", - BSScene.DetailLogZero, world.worldID, m_constraint.AddrString, + m_body1.ID, world.worldID, m_constraint.AddrString, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); + if (!m_constraint.HasPhysicalConstraint) { world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}", @@ -113,8 +117,10 @@ public class BSConstraint6Dof : BSConstraint frameInBloc, frameInBrot, useLinearReferenceFrameB, disableCollisionsBetweenLinkedBodies); m_enabled = true; - world.physicsScene.DetailLog("{0},BS6DofConstraint,createFixed,wID={1},rID={2},rBody={3}", - BSScene.DetailLogZero, world.worldID, obj1.ID, obj1.AddrString); + PhysicsScene.DetailLog("{0},BS6DofConstraint,createFixed,wID={1},rID={2},rBody={3}", + m_body1.ID, world.worldID, obj1.ID, obj1.AddrString); + PhysicsScene.DetailLog("{0},BS6DofConstraint,createFixed, fBLoc={1},fBRot={2},usefA={3},disCol={4}", + m_body1.ID, frameInBloc, frameInBrot, useLinearReferenceFrameB, disableCollisionsBetweenLinkedBodies); } public bool SetFrames(Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs index 01d67d4..410584d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs @@ -47,37 +47,42 @@ public sealed class BSConstraintSpring : BSConstraint6Dof useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); m_enabled = true; - world.physicsScene.DetailLog("{0},BSConstraintSpring,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", - BSScene.DetailLogZero, world.worldID, - obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); + PhysicsScene.DetailLog("{0},BSConstraintSpring,create,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", + obj1.ID, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); + PhysicsScene.DetailLog("{0},BSConstraintSpring,create, f1Loc={1},f1Rot={2},f2Loc={3},f2Rot={4},usefA={5},disCol={6}", + m_body1.ID, frame1Loc, frame1Rot, frame2Loc, frame2Rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); } - public bool SetEnable(int index, bool axisEnable) + public bool SetEnable(int pIndex, bool pAxisEnable) { - bool ret = false; - - return ret; + PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEnable,obj1ID={1},obj2ID={2},indx={3},enable={4}", + m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pAxisEnable); + PhysicsScene.PE.SpringEnable(m_constraint, pIndex, BSParam.NumericBool(pAxisEnable)); + return true; } - public bool SetStiffness(int index, float stiffness) + public bool SetStiffness(int pIndex, float pStiffness) { - bool ret = false; - - return ret; + PhysicsScene.DetailLog("{0},BSConstraintSpring.SetStiffness,obj1ID={1},obj2ID={2},indx={3},enable={4}", + m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pStiffness); + PhysicsScene.PE.SpringSetStiffness(m_constraint, pIndex, pStiffness); + return true; } - public bool SetDamping(int index, float damping) + public bool SetDamping(int pIndex, float pDamping) { - bool ret = false; - - return ret; + PhysicsScene.DetailLog("{0},BSConstraintSpring.SetDamping,obj1ID={1},obj2ID={2},indx={3},enable={4}", + m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pDamping); + PhysicsScene.PE.SpringSetDamping(m_constraint, pIndex, pDamping); + return true; } - public bool SetEquilibriumPoint(int index, float eqPoint) + public bool SetEquilibriumPoint(int pIndex, float pEqPoint) { - bool ret = false; - - return ret; + PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEquilibriumPoint,obj1ID={1},obj2ID={2},indx={3},enable={4}", + m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pEqPoint); + PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, pIndex, pEqPoint); + return true; } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index a9ae89d..be97c29 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -67,6 +67,7 @@ public sealed class BSLinksetConstraints : BSLinkset { constraint = null; ResetLink(); + member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.creation", member.LocalID); } // Set all the parameters for this constraint to a fixed, non-movable constraint. @@ -91,11 +92,13 @@ public sealed class BSLinksetConstraints : BSLinkset frameInBrot = OMV.Quaternion.Identity; springDamping = -1f; springStiffness = -1f; + member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID); } // Given a constraint, apply the current constraint parameters to same. public override void SetLinkParameters(BSConstraint constrain) { + member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.SetLinkParameters,type={1}", member.LocalID, constraintType); switch (constraintType) { case ConstraintType.FIXED_CONSTRAINT_TYPE: @@ -139,7 +142,7 @@ public sealed class BSLinksetConstraints : BSLinkset if (springDamping != -1) constrainSpring.SetDamping(ii, springDamping); if (springStiffness != -1) - constrainSpring.SetStiffness(ii, springStiffness); + constrainSpring.SetStiffness(ii, springStiffness); } } break; @@ -155,7 +158,6 @@ public sealed class BSLinksetConstraints : BSLinkset public override bool ShouldUpdateChildProperties() { bool ret = true; - if (constraintType == ConstraintType.FIXED_CONSTRAINT_TYPE) ret = false; @@ -193,10 +195,16 @@ public sealed class BSLinksetConstraints : BSLinkset { // Queue to happen after all the other taint processing m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() + { + if (HasAnyChildren) { - if (HasAnyChildren) - RecomputeLinksetConstraints(); - }); + // Constraints that have not been changed are not rebuild but make sure + // the constraint of the requestor is rebuilt. + PhysicallyUnlinkAChildFromRoot(LinksetRoot, requestor); + // Rebuild the linkset and all its constraints. + RecomputeLinksetConstraints(); + } + }); } } @@ -415,13 +423,22 @@ public sealed class BSLinksetConstraints : BSLinkset rootPrim.LocalID, rootPrim.PhysBody.AddrString, childPrim.LocalID, childPrim.PhysBody.AddrString); - // Find the constraint for this link and get rid of it from the overall collection and from my list - if (m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) + // If asked to unlink root from root, just remove all the constraints + if (rootPrim == childPrim || childPrim == LinksetRoot) { - // Make the child refresh its location - m_physicsScene.PE.PushUpdate(childPrim.PhysBody); + PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); ret = true; } + else + { + // Find the constraint for this link and get rid of it from the overall collection and from my list + if (m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) + { + // Make the child refresh its location + m_physicsScene.PE.PushUpdate(childPrim.PhysBody); + ret = true; + } + } return ret; } @@ -521,8 +538,6 @@ public sealed class BSLinksetConstraints : BSLinkset BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; if (linkInfoC != null) { - // Setting to fixed is easy. The reset state is the fixed link configuration. - linkInfoC.ResetLink(); linkInfoC.constraintType = (ConstraintType)requestedType; ret = (object)true; DetailLog("{0},BSLinksetConstraint.ChangeLinkType,link={1},type={2}", @@ -589,6 +604,7 @@ public sealed class BSLinksetConstraints : BSLinkset BSLinkInfoConstraint linkInfo = baseLinkInfo as BSLinkInfoConstraint; if (linkInfo != null) { + int valueInt; float valueFloat; bool valueBool; OMV.Vector3 valueVector; @@ -602,6 +618,20 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfo.member.LocalID, thisOp, pParams[opIndex+1]); switch (thisOp) { + case ExtendedPhysics.PHYS_PARAM_LINK_TYPE: + valueInt = (int)pParams[opIndex + 1]; + ConstraintType valueType = (ConstraintType)valueInt; + if (valueType == ConstraintType.FIXED_CONSTRAINT_TYPE + || valueType == ConstraintType.D6_CONSTRAINT_TYPE + || valueType == ConstraintType.D6_SPRING_CONSTRAINT_TYPE + || valueType == ConstraintType.HINGE_CONSTRAINT_TYPE + || valueType == ConstraintType.CONETWIST_CONSTRAINT_TYPE + || valueType == ConstraintType.SLIDER_CONSTRAINT_TYPE) + { + linkInfo.constraintType = valueType; + } + opIndex += 2; + break; case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.frameInAloc = valueVector; -- cgit v1.1 From 7c54630a2dde768e92b3034d76314cb1e061c348 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 22 Aug 2013 16:31:17 -0700 Subject: BulletSim: add axis parameter for specifying enable, damping, and stiffness for spring constraints. Renumber parameter ops since I can as no one is using them yet. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 10 +++-- .../Region/Physics/BulletSPlugin/BSApiTemplate.cs | 2 +- .../Physics/BulletSPlugin/BSConstraintSpring.cs | 2 +- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 51 +++++++++++++++------- 4 files changed, 44 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 2f88e2b..ef106bd 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -399,13 +399,15 @@ public class ExtendedPhysics : INonSharedRegionModule [ScriptConstant] public const int PHYS_PARAM_SOLVER_ITERATIONS = 14415; [ScriptConstant] - public const int PHYS_PARAM_SPRING_DAMPING = 14416; + public const int PHYS_PARAM_SPRING_AXIS_ENABLE = 14416; [ScriptConstant] - public const int PHYS_PARAM_SPRING_STIFFNESS = 14417; + public const int PHYS_PARAM_SPRING_DAMPING = 14417; [ScriptConstant] - public const int PHYS_PARAM_LINK_TYPE = 14418; + public const int PHYS_PARAM_SPRING_STIFFNESS = 14418; + [ScriptConstant] + public const int PHYS_PARAM_LINK_TYPE = 14419; - public const int PHYS_PARAM_MAX = 14418; + public const int PHYS_PARAM_MAX = 14419; // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) [ScriptInvocation] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs index 9d8838b..0b3f467 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs @@ -292,7 +292,7 @@ public enum ConstraintParamAxis : int AXIS_ANGULAR_X, AXIS_ANGULAR_Y, AXIS_ANGULAR_Z, - AXIS_LINEAR_ALL = 20, // these last three added by BulletSim so we don't have to do zillions of calls + AXIS_LINEAR_ALL = 20, // added by BulletSim so we don't have to do zillions of calls AXIS_ANGULAR_ALL, AXIS_ALL }; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs index 410584d..432e5b2 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs @@ -53,7 +53,7 @@ public sealed class BSConstraintSpring : BSConstraint6Dof m_body1.ID, frame1Loc, frame1Rot, frame2Loc, frame2Rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); } - public bool SetEnable(int pIndex, bool pAxisEnable) + public bool SetAxisEnable(int pIndex, bool pAxisEnable) { PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEnable,obj1ID={1},obj2ID={2},indx={3},enable={4}", m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pAxisEnable); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index be97c29..f623231 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -59,8 +59,9 @@ public sealed class BSLinksetConstraints : BSLinkset public OMV.Vector3 frameInBloc; public OMV.Quaternion frameInBrot; // Spring - public float springDamping; - public float springStiffness; + public bool[] springAxisEnable; + public float[] springDamping; + public float[] springStiffness; public BSLinkInfoConstraint(BSPrimLinkable pMember) : base(pMember) @@ -90,8 +91,15 @@ public sealed class BSLinksetConstraints : BSLinkset frameInArot = OMV.Quaternion.Identity; frameInBloc = OMV.Vector3.Zero; frameInBrot = OMV.Quaternion.Identity; - springDamping = -1f; - springStiffness = -1f; + springAxisEnable = new bool[6]; + springDamping = new float[6]; + springStiffness = new float[6]; + for (int ii = 0; ii < springAxisEnable.Length; ii++) + { + springAxisEnable[ii] = false; + springDamping[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; + springStiffness[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; + } member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID); } @@ -139,11 +147,13 @@ public sealed class BSLinksetConstraints : BSLinkset } for (int ii = 0; ii < 6; ii++) { - if (springDamping != -1) - constrainSpring.SetDamping(ii, springDamping); - if (springStiffness != -1) - constrainSpring.SetStiffness(ii, springStiffness); + constrainSpring.SetAxisEnable(ii, springAxisEnable[ii]); + if (springDamping[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) + constrainSpring.SetDamping(ii, springDamping[ii]); + if (springStiffness[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) + constrainSpring.SetStiffness(ii, springStiffness[ii]); } + constrainSpring.SetEquilibriumPoint(BSAPITemplate.SPRING_NOT_SPECIFIED, BSAPITemplate.SPRING_NOT_SPECIFIED); } break; default: @@ -707,15 +717,26 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfo.solverIterations = valueFloat; opIndex += 2; break; + case ExtendedPhysics.PHYS_PARAM_SPRING_AXIS_ENABLE: + valueInt = (int)pParams[opIndex + 1]; + valueBool = ((int)pParams[opIndex + 2] != 0); + if (valueInt >=0 && valueInt < linkInfo.springAxisEnable.Length) + linkInfo.springAxisEnable[valueInt] = valueBool; + opIndex += 3; + break; case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: - valueFloat = (float)pParams[opIndex + 1]; - linkInfo.springDamping = valueFloat; - opIndex += 2; + valueInt = (int)pParams[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 2]; + if (valueInt >=0 && valueInt < linkInfo.springDamping.Length) + linkInfo.springDamping[valueInt] = valueFloat; + opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: - valueFloat = (float)pParams[opIndex + 1]; - linkInfo.springStiffness = valueFloat; - opIndex += 2; + valueInt = (int)pParams[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 2]; + if (valueInt >=0 && valueInt < linkInfo.springStiffness.Length) + linkInfo.springStiffness[valueInt] = valueFloat; + opIndex += 3; break; default: break; -- cgit v1.1 From cf2cdc191d0a93860da1ff4c42d34138e8f369fb Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 24 Aug 2013 08:33:28 -0700 Subject: BulletSim: ability to specify groups of axis to modify in constraint parameters that control multiple axis. Add useLinearReferenceFrameA constraint parameter. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 12 ++++- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 53 ++++++++++++++++++---- 2 files changed, 56 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index ef106bd..94367f5 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -406,8 +406,18 @@ public class ExtendedPhysics : INonSharedRegionModule public const int PHYS_PARAM_SPRING_STIFFNESS = 14418; [ScriptConstant] public const int PHYS_PARAM_LINK_TYPE = 14419; + [ScriptConstant] + public const int PHYS_PARAM_USE_LINEAR_FRAMEA = 14420; + + public const int PHYS_PARAM_MAX = 14420; - public const int PHYS_PARAM_MAX = 14419; + // Used when specifying a parameter that has settings for the three linear and three angular axis + [ScriptConstant] + public const int PHYS_AXIS_ALL = -1; + [ScriptConstant] + public const int PHYS_AXIS_ALL_LINEAR = -2; + [ScriptConstant] + public const int PHYS_AXIS_ALL_ANGULAR = -3; // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) [ScriptInvocation] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index f623231..ff5ac0e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -58,6 +58,7 @@ public sealed class BSLinksetConstraints : BSLinkset public OMV.Quaternion frameInArot; public OMV.Vector3 frameInBloc; public OMV.Quaternion frameInBrot; + public bool useLinearReferenceFrameA; // Spring public bool[] springAxisEnable; public float[] springDamping; @@ -91,6 +92,7 @@ public sealed class BSLinksetConstraints : BSLinkset frameInArot = OMV.Quaternion.Identity; frameInBloc = OMV.Vector3.Zero; frameInBrot = OMV.Quaternion.Identity; + useLinearReferenceFrameA = true; springAxisEnable = new bool[6]; springDamping = new float[6]; springStiffness = new float[6]; @@ -145,7 +147,7 @@ public sealed class BSLinksetConstraints : BSLinkset { constrainSpring.SetSolverIterations(solverIterations); } - for (int ii = 0; ii < 6; ii++) + for (int ii = 0; ii < springAxisEnable.Length; ii++) { constrainSpring.SetAxisEnable(ii, springAxisEnable[ii]); if (springDamping[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) @@ -401,7 +403,7 @@ public sealed class BSLinksetConstraints : BSLinkset case ConstraintType.D6_SPRING_CONSTRAINT_TYPE: constrain = new BSConstraintSpring(m_physicsScene.World, rootPrim.PhysBody, linkInfo.member.PhysBody, linkInfo.frameInAloc, linkInfo.frameInArot, linkInfo.frameInBloc, linkInfo.frameInBrot, - true /*useLinearReferenceFrameA*/, + linkInfo.useLinearReferenceFrameA, true /*disableCollisionsBetweenLinkedBodies*/); DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6}", rootPrim.LocalID, @@ -619,6 +621,7 @@ public sealed class BSLinksetConstraints : BSLinkset bool valueBool; OMV.Vector3 valueVector; OMV.Quaternion valueQuaternion; + int axisLow, axisHigh; int opIndex = 2; while (opIndex < pParams.Length) @@ -720,24 +723,32 @@ public sealed class BSLinksetConstraints : BSLinkset case ExtendedPhysics.PHYS_PARAM_SPRING_AXIS_ENABLE: valueInt = (int)pParams[opIndex + 1]; valueBool = ((int)pParams[opIndex + 2] != 0); - if (valueInt >=0 && valueInt < linkInfo.springAxisEnable.Length) - linkInfo.springAxisEnable[valueInt] = valueBool; + GetAxisRange(valueInt, out axisLow, out axisHigh); + for (int ii = axisLow; ii <= axisHigh; ii++) + linkInfo.springAxisEnable[ii] = valueBool; opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: valueInt = (int)pParams[opIndex + 1]; valueFloat = (float)pParams[opIndex + 2]; - if (valueInt >=0 && valueInt < linkInfo.springDamping.Length) - linkInfo.springDamping[valueInt] = valueFloat; + GetAxisRange(valueInt, out axisLow, out axisHigh); + for (int ii = axisLow; ii <= axisHigh; ii++) + linkInfo.springDamping[ii] = valueFloat; opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: valueInt = (int)pParams[opIndex + 1]; valueFloat = (float)pParams[opIndex + 2]; - if (valueInt >=0 && valueInt < linkInfo.springStiffness.Length) - linkInfo.springStiffness[valueInt] = valueFloat; + GetAxisRange(valueInt, out axisLow, out axisHigh); + for (int ii = axisLow; ii <= axisHigh; ii++) + linkInfo.springStiffness[ii] = valueFloat; opIndex += 3; break; + case ExtendedPhysics.PHYS_PARAM_USE_LINEAR_FRAMEA: + valueBool = (bool)pParams[opIndex + 1]; + linkInfo.useLinearReferenceFrameA = valueBool; + opIndex += 2; + break; default: break; } @@ -760,6 +771,32 @@ public sealed class BSLinksetConstraints : BSLinkset } return ret; } + + // Bullet constraints keep some limit parameters for each linear and angular axis. + // Setting same is easier if there is an easy way to see all or types. + // This routine returns the array limits for the set of axis. + private void GetAxisRange(int rangeSpec, out int low, out int high) + { + switch (rangeSpec) + { + case ExtendedPhysics.PHYS_AXIS_ALL_LINEAR: + low = 0; + high = 2; + break; + case ExtendedPhysics.PHYS_AXIS_ALL_ANGULAR: + low = 3; + high = 5; + break; + case ExtendedPhysics.PHYS_AXIS_ALL: + low = 0; + high = 5; + break; + default: + low = high = rangeSpec; + break; + } + return; + } #endregion // Extension } -- cgit v1.1 From 5827b6e1aabf2e19624faf0141b9611917fb84c5 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 4 Sep 2013 07:56:59 -0700 Subject: BulletSim: add extended physics LSL constants for axis specification. Add specific error warnings for mis-matched parameter types in extended physics functions. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 16 +++- .../Physics/BulletSPlugin/BSConstraintSpring.cs | 6 +- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 89 ++++++++++++++-------- 3 files changed, 74 insertions(+), 37 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 94367f5..b0b0bc6 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -415,9 +415,21 @@ public class ExtendedPhysics : INonSharedRegionModule [ScriptConstant] public const int PHYS_AXIS_ALL = -1; [ScriptConstant] - public const int PHYS_AXIS_ALL_LINEAR = -2; + public const int PHYS_AXIS_LINEAR_ALL = -2; [ScriptConstant] - public const int PHYS_AXIS_ALL_ANGULAR = -3; + public const int PHYS_AXIS_ANGULAR_ALL = -3; + [ScriptConstant] + public const int PHYS_AXIS_LINEAR_X = 0; + [ScriptConstant] + public const int PHYS_AXIS_LINEAR_Y = 1; + [ScriptConstant] + public const int PHYS_AXIS_LINEAR_Z = 2; + [ScriptConstant] + public const int PHYS_AXIS_ANGULAR_X = 3; + [ScriptConstant] + public const int PHYS_AXIS_ANGULAR_Y = 4; + [ScriptConstant] + public const int PHYS_AXIS_ANGULAR_Z = 5; // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) [ScriptInvocation] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs index 432e5b2..652c94a 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs @@ -63,7 +63,7 @@ public sealed class BSConstraintSpring : BSConstraint6Dof public bool SetStiffness(int pIndex, float pStiffness) { - PhysicsScene.DetailLog("{0},BSConstraintSpring.SetStiffness,obj1ID={1},obj2ID={2},indx={3},enable={4}", + PhysicsScene.DetailLog("{0},BSConstraintSpring.SetStiffness,obj1ID={1},obj2ID={2},indx={3},stiff={4}", m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pStiffness); PhysicsScene.PE.SpringSetStiffness(m_constraint, pIndex, pStiffness); return true; @@ -71,7 +71,7 @@ public sealed class BSConstraintSpring : BSConstraint6Dof public bool SetDamping(int pIndex, float pDamping) { - PhysicsScene.DetailLog("{0},BSConstraintSpring.SetDamping,obj1ID={1},obj2ID={2},indx={3},enable={4}", + PhysicsScene.DetailLog("{0},BSConstraintSpring.SetDamping,obj1ID={1},obj2ID={2},indx={3},damp={4}", m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pDamping); PhysicsScene.PE.SpringSetDamping(m_constraint, pIndex, pDamping); return true; @@ -79,7 +79,7 @@ public sealed class BSConstraintSpring : BSConstraint6Dof public bool SetEquilibriumPoint(int pIndex, float pEqPoint) { - PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEquilibriumPoint,obj1ID={1},obj2ID={2},indx={3},enable={4}", + PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEquilibriumPoint,obj1ID={1},obj2ID={2},indx={3},eqPoint={4}", m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pEqPoint); PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, pIndex, pEqPoint); return true; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index ff5ac0e..b3347bf 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -605,30 +605,32 @@ public sealed class BSLinksetConstraints : BSLinkset // pParams = [ BSPhysObject root, BSPhysObject child, int op, object opParams, int op, object opParams, ... ] case ExtendedPhysics.PhysFunctChangeLinkParams: // There should be two parameters: the childActor and a list of parameters to set - try + if (pParams.Length > 2) { - if (pParams.Length > 2) + BSPrimLinkable child = pParams[1] as BSPrimLinkable; + BSLinkInfo baseLinkInfo = null; + if (TryGetLinkInfo(child, out baseLinkInfo)) { - BSPrimLinkable child = pParams[1] as BSPrimLinkable; - BSLinkInfo baseLinkInfo = null; - if (TryGetLinkInfo(child, out baseLinkInfo)) + BSLinkInfoConstraint linkInfo = baseLinkInfo as BSLinkInfoConstraint; + if (linkInfo != null) { - BSLinkInfoConstraint linkInfo = baseLinkInfo as BSLinkInfoConstraint; - if (linkInfo != null) + int valueInt; + float valueFloat; + bool valueBool; + OMV.Vector3 valueVector; + OMV.Quaternion valueQuaternion; + int axisLow, axisHigh; + + int opIndex = 2; + while (opIndex < pParams.Length) { - int valueInt; - float valueFloat; - bool valueBool; - OMV.Vector3 valueVector; - OMV.Quaternion valueQuaternion; - int axisLow, axisHigh; - - int opIndex = 2; - while (opIndex < pParams.Length) + int thisOp = 0; + string errMsg = ""; + try { - int thisOp = (int)pParams[opIndex]; + thisOp = (int)pParams[opIndex]; DetailLog("{0},BSLinksetConstraint.ChangeLinkParams2,op={1},val={2}", - linkInfo.member.LocalID, thisOp, pParams[opIndex+1]); + linkInfo.member.LocalID, thisOp, pParams[opIndex + 1]); switch (thisOp) { case ExtendedPhysics.PHYS_PARAM_LINK_TYPE: @@ -646,89 +648,106 @@ public sealed class BSLinksetConstraints : BSLinkset opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: + errMsg = "PHYS_PARAM_FRAMEINA_LOC takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.frameInAloc = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: + errMsg = "PHYS_PARAM_FRAMEINA_ROT takes one parameter of type rotation"; valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1]; linkInfo.frameInArot = valueQuaternion; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC: + errMsg = "PHYS_PARAM_FRAMEINB_LOC takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.frameInBloc = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT: + errMsg = "PHYS_PARAM_FRAMEINB_ROT takes one parameter of type rotation"; valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1]; linkInfo.frameInBrot = valueQuaternion; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW: + errMsg = "PHYS_PARAM_LINEAR_LIMIT_LOW takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.linearLimitLow = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH: + errMsg = "PHYS_PARAM_LINEAR_LIMIT_HIGH takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.linearLimitHigh = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW: + errMsg = "PHYS_PARAM_ANGULAR_LIMIT_LOW takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.angularLimitLow = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH: + errMsg = "PHYS_PARAM_ANGULAR_LIMIT_HIGH takes one parameter of type vector"; valueVector = (OMV.Vector3)pParams[opIndex + 1]; linkInfo.angularLimitHigh = valueVector; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET: - valueBool = (bool)pParams[opIndex + 1]; + errMsg = "PHYS_PARAM_USE_FRAME_OFFSET takes one parameter of type integer (bool)"; + valueBool = ((int)pParams[opIndex + 1]) != 0; linkInfo.useFrameOffset = valueBool; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR: - valueBool = (bool)pParams[opIndex + 1]; + errMsg = "PHYS_PARAM_ENABLE_TRANSMOTOR takes one parameter of type integer (bool)"; + valueBool = ((int)pParams[opIndex + 1]) != 0; linkInfo.enableTransMotor = valueBool; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL: + errMsg = "PHYS_PARAM_TRANSMOTOR_MAXVEL takes one parameter of type float"; valueFloat = (float)pParams[opIndex + 1]; linkInfo.transMotorMaxVel = valueFloat; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE: + errMsg = "PHYS_PARAM_TRANSMOTOR_MAXFORCE takes one parameter of type float"; valueFloat = (float)pParams[opIndex + 1]; linkInfo.transMotorMaxForce = valueFloat; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_CFM: + errMsg = "PHYS_PARAM_CFM takes one parameter of type float"; valueFloat = (float)pParams[opIndex + 1]; linkInfo.cfm = valueFloat; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_ERP: + errMsg = "PHYS_PARAM_ERP takes one parameter of type float"; valueFloat = (float)pParams[opIndex + 1]; linkInfo.erp = valueFloat; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS: + errMsg = "PHYS_PARAM_SOLVER_ITERATIONS takes one parameter of type float"; valueFloat = (float)pParams[opIndex + 1]; linkInfo.solverIterations = valueFloat; opIndex += 2; break; case ExtendedPhysics.PHYS_PARAM_SPRING_AXIS_ENABLE: + errMsg = "PHYS_PARAM_SPRING_AXIS_ENABLE takes two parameters of types integer and integer (bool)"; valueInt = (int)pParams[opIndex + 1]; - valueBool = ((int)pParams[opIndex + 2] != 0); + valueBool = ((int)pParams[opIndex + 2]) != 0; GetAxisRange(valueInt, out axisLow, out axisHigh); for (int ii = axisLow; ii <= axisHigh; ii++) linkInfo.springAxisEnable[ii] = valueBool; opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: + errMsg = "PHYS_PARAM_SPRING_DAMPING takes two parameters of types integer and float"; valueInt = (int)pParams[opIndex + 1]; valueFloat = (float)pParams[opIndex + 2]; GetAxisRange(valueInt, out axisLow, out axisHigh); @@ -737,6 +756,7 @@ public sealed class BSLinksetConstraints : BSLinkset opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: + errMsg = "PHYS_PARAM_SPRING_STIFFNESS takes two parameters of types integer and float"; valueInt = (int)pParams[opIndex + 1]; valueFloat = (float)pParams[opIndex + 2]; GetAxisRange(valueInt, out axisLow, out axisHigh); @@ -745,7 +765,8 @@ public sealed class BSLinksetConstraints : BSLinkset opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_USE_LINEAR_FRAMEA: - valueBool = (bool)pParams[opIndex + 1]; + errMsg = "PHYS_PARAM_USE_LINEAR_FRAMEA takes one parameter of type integer (bool)"; + valueBool = ((int)pParams[opIndex + 1]) != 0; linkInfo.useLinearReferenceFrameA = valueBool; opIndex += 2; break; @@ -753,18 +774,22 @@ public sealed class BSLinksetConstraints : BSLinkset break; } } + catch (InvalidCastException e) + { + m_physicsScene.Logger.WarnFormat("{0} value of wrong type in physSetLinksetParams: {1}, err={2}", + LogHeader, errMsg, e); + } + catch (Exception e) + { + m_physicsScene.Logger.WarnFormat("{0} bad parameters in physSetLinksetParams: {1}", LogHeader, e); + } } - // Something changed so a rebuild is in order - Refresh(child); } + // Something changed so a rebuild is in order + Refresh(child); } } - catch (Exception e) - { - // There are many ways to mess up the parameters. If not just right don't fail without some error. - m_physicsScene.Logger.WarnFormat("{0} bad parameters in physSetLinksetParams: {1}", LogHeader, e); - } - break; + break; default: ret = base.Extension(pFunct, pParams); break; @@ -779,11 +804,11 @@ public sealed class BSLinksetConstraints : BSLinkset { switch (rangeSpec) { - case ExtendedPhysics.PHYS_AXIS_ALL_LINEAR: + case ExtendedPhysics.PHYS_AXIS_LINEAR_ALL: low = 0; high = 2; break; - case ExtendedPhysics.PHYS_AXIS_ALL_ANGULAR: + case ExtendedPhysics.PHYS_AXIS_ANGULAR_ALL: low = 3; high = 5; break; -- cgit v1.1 From c5eabb28b4c933cfacefa85381e290372fbc094e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 9 Sep 2013 14:53:16 -0700 Subject: BulletSim: add LSL function and plumbing for setting a spring equilibrium point in the physics engine constraint. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 4 +++- OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs | 6 +++++- .../Physics/BulletSPlugin/BSConstraintSpring.cs | 13 +++++++++++++ .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 20 +++++++++++++++++++- 4 files changed, 40 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index b0b0bc6..9daf9d7 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -408,8 +408,10 @@ public class ExtendedPhysics : INonSharedRegionModule public const int PHYS_PARAM_LINK_TYPE = 14419; [ScriptConstant] public const int PHYS_PARAM_USE_LINEAR_FRAMEA = 14420; + [ScriptConstant] + public const int PHYS_PARAM_SPRING_EQUILIBRIUM_POINT = 14421; - public const int PHYS_PARAM_MAX = 14420; + public const int PHYS_PARAM_MAX = 14421; // Used when specifying a parameter that has settings for the three linear and three angular axis [ScriptConstant] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs index 42b5c49..b47e9a8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs @@ -64,7 +64,7 @@ public abstract class BSConstraint : IDisposable { bool success = PhysicsScene.PE.DestroyConstraint(m_world, m_constraint); m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}", - BSScene.DetailLogZero, + m_body1.ID, m_body1.ID, m_body1.AddrString, m_body2.ID, m_body2.AddrString, success); @@ -77,7 +77,10 @@ public abstract class BSConstraint : IDisposable { bool ret = false; if (m_enabled) + { + m_world.physicsScene.DetailLog("{0},BSConstraint.SetLinearLimits,taint,low={1},high={2}", m_body1.ID, low, high); ret = PhysicsScene.PE.SetLinearLimits(m_constraint, low, high); + } return ret; } @@ -86,6 +89,7 @@ public abstract class BSConstraint : IDisposable bool ret = false; if (m_enabled) { + m_world.physicsScene.DetailLog("{0},BSConstraint.SetAngularLimits,taint,low={1},high={2}", m_body1.ID, low, high); ret = PhysicsScene.PE.SetAngularLimits(m_constraint, low, high); } return ret; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs index 652c94a..8e7ddff 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs @@ -85,6 +85,19 @@ public sealed class BSConstraintSpring : BSConstraint6Dof return true; } + public bool SetEquilibriumPoint(Vector3 linearEq, Vector3 angularEq) + { + PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEquilibriumPoint,obj1ID={1},obj2ID={2},linearEq={3},angularEq={4}", + m_body1.ID, m_body1.ID, m_body2.ID, linearEq, angularEq); + PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 0, linearEq.X); + PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 1, linearEq.Y); + PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 2, linearEq.Z); + PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 3, angularEq.X); + PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 4, angularEq.Y); + PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 5, angularEq.Z); + return true; + } + } } \ No newline at end of file diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index b3347bf..aaf92c8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -63,6 +63,8 @@ public sealed class BSLinksetConstraints : BSLinkset public bool[] springAxisEnable; public float[] springDamping; public float[] springStiffness; + public OMV.Vector3 springLinearEquilibriumPoint; + public OMV.Vector3 springAngularEquilibriumPoint; public BSLinkInfoConstraint(BSPrimLinkable pMember) : base(pMember) @@ -102,6 +104,8 @@ public sealed class BSLinksetConstraints : BSLinkset springDamping[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; springStiffness[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; } + springLinearEquilibriumPoint = OMV.Vector3.Zero; + springAngularEquilibriumPoint = OMV.Vector3.Zero; member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID); } @@ -155,7 +159,12 @@ public sealed class BSLinksetConstraints : BSLinkset if (springStiffness[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) constrainSpring.SetStiffness(ii, springStiffness[ii]); } - constrainSpring.SetEquilibriumPoint(BSAPITemplate.SPRING_NOT_SPECIFIED, BSAPITemplate.SPRING_NOT_SPECIFIED); + constrainSpring.CalculateTransforms(); + + if (springLinearEquilibriumPoint != OMV.Vector3.Zero) + constrainSpring.SetEquilibriumPoint(springLinearEquilibriumPoint, springAngularEquilibriumPoint); + else + constrainSpring.SetEquilibriumPoint(BSAPITemplate.SPRING_NOT_SPECIFIED, BSAPITemplate.SPRING_NOT_SPECIFIED); } break; default: @@ -618,6 +627,7 @@ public sealed class BSLinksetConstraints : BSLinkset float valueFloat; bool valueBool; OMV.Vector3 valueVector; + OMV.Vector3 valueVector2; OMV.Quaternion valueQuaternion; int axisLow, axisHigh; @@ -764,6 +774,14 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfo.springStiffness[ii] = valueFloat; opIndex += 3; break; + case ExtendedPhysics.PHYS_PARAM_SPRING_EQUILIBRIUM_POINT: + errMsg = "PHYS_PARAM_SPRING_EQUILIBRIUM_POINT takes two parameters of type vector"; + valueVector = (OMV.Vector3)pParams[opIndex + 1]; + valueVector2 = (OMV.Vector3)pParams[opIndex + 2]; + linkInfo.springLinearEquilibriumPoint = valueVector; + linkInfo.springAngularEquilibriumPoint = valueVector2; + opIndex += 3; + break; case ExtendedPhysics.PHYS_PARAM_USE_LINEAR_FRAMEA: errMsg = "PHYS_PARAM_USE_LINEAR_FRAMEA takes one parameter of type integer (bool)"; valueBool = ((int)pParams[opIndex + 1]) != 0; -- cgit v1.1 From 6e39cc316f502855a89c51775e7394b73135ab86 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 10 Sep 2013 17:32:01 -0700 Subject: BulletSim: add ClearCollisionProxyCache function to API. Add proxy cache clearing when some properties are changed. This fixes a problem where objects would stop colliding of they were moved with setPosition mulitple times. --- OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs | 10 ++++++++++ OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs | 13 +++++++++++++ OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs | 2 ++ OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 12 ++++++++++-- 4 files changed, 35 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs index 8dfb01c..3bd81d4 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs @@ -725,6 +725,13 @@ public override bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj) return BSAPICPP.RemoveObjectFromWorld2(worldu.ptr, bodyu.ptr); } +public override bool ClearCollisionProxyCache(BulletWorld world, BulletBody obj) +{ + BulletWorldUnman worldu = world as BulletWorldUnman; + BulletBodyUnman bodyu = obj as BulletBodyUnman; + return BSAPICPP.ClearCollisionProxyCache2(worldu.ptr, bodyu.ptr); +} + public override bool AddConstraintToWorld(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects) { BulletWorldUnman worldu = world as BulletWorldUnman; @@ -1713,6 +1720,9 @@ public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj); public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool ClearCollisionProxyCache2(IntPtr world, IntPtr obj); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool AddConstraintToWorld2(IntPtr world, IntPtr constrain, bool disableCollisionsBetweenLinkedObjects); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs index ff2b497..17ebed2 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs @@ -169,6 +169,19 @@ private sealed class BulletConstraintXNA : BulletConstraint return true; } + public override bool ClearCollisionProxyCache(BulletWorld pWorld, BulletBody pBody) + { + DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world; + RigidBody body = ((BulletBodyXNA)pBody).rigidBody; + CollisionObject collisionObject = ((BulletBodyXNA)pBody).body; + if (body != null && collisionObject != null && collisionObject.GetBroadphaseHandle() != null) + { + world.RemoveCollisionObject(collisionObject); + world.AddCollisionObject(collisionObject); + } + return true; + } + public override bool AddConstraintToWorld(BulletWorld pWorld, BulletConstraint pConstraint, bool pDisableCollisionsBetweenLinkedObjects) { DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs index 0b3f467..f7dd158 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs @@ -498,6 +498,8 @@ public abstract bool AddObjectToWorld(BulletWorld world, BulletBody obj); public abstract bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj); +public abstract bool ClearCollisionProxyCache(BulletWorld world, BulletBody obj); + public abstract bool AddConstraintToWorld(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects); public abstract bool RemoveConstraintFromWorld(BulletWorld world, BulletConstraint constrain); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 2efb1a5..47df611 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -300,8 +300,16 @@ public abstract class BSPhysObject : PhysicsActor // Called in taint-time!! public void ActivateIfPhysical(bool forceIt) { - if (IsPhysical && PhysBody.HasPhysicalBody) - PhysScene.PE.Activate(PhysBody, forceIt); + if (PhysBody.HasPhysicalBody) + { + // Clear the collision cache since we've changed some properties. + PhysScene.PE.ClearCollisionProxyCache(PhysScene.World, PhysBody); + if (IsPhysical) + { + // Physical objects might need activating + PhysScene.PE.Activate(PhysBody, forceIt); + } + } } // 'actors' act on the physical object to change or constrain its motion. These can range from -- cgit v1.1 From b29e9d37e7705e461f71a3a599d95ad79b57e18a Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Wed, 11 Sep 2013 12:15:16 -0700 Subject: Change handling of the FetchInventoryDescendents2 capability configuration to allow for external handlers. --- .../Linden/Caps/WebFetchInvDescModule.cs | 59 +++++++++++++--------- 1 file changed, 36 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 164adeb..340d2e7 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -63,7 +63,7 @@ namespace OpenSim.Region.ClientStack.Linden public List folders; } -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; @@ -115,7 +115,7 @@ namespace OpenSim.Region.ClientStack.Linden m_scene.EventManager.OnRegisterCaps -= RegisterCaps; foreach (Thread t in m_workerThreads) - Watchdog.AbortThread(t.ManagedThreadId); + Watchdog.AbortThread(t.ManagedThreadId); m_scene = null; } @@ -296,36 +296,49 @@ namespace OpenSim.Region.ClientStack.Linden requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); lock (responses) - responses[requestID] = response; + responses[requestID] = response; } } private void RegisterCaps(UUID agentID, Caps caps) { - if (m_fetchInventoryDescendents2Url == "") + RegisterFetchDescendentsCap(agentID, caps, "FetchInventoryDescendents2", m_fetchInventoryDescendents2Url); + } + + private void RegisterFetchDescendentsCap(UUID agentID, Caps caps, string capName, string url) + { + string capUrl; + + // disable the cap clause + if (url == "") + { return; + } + // handled by the simulator + else if (url == "localhost") + { + capUrl = "/CAPS/" + UUID.Random() + "/"; - // Register this as a poll service - PollServiceInventoryEventArgs args - = new PollServiceInventoryEventArgs(m_scene, "/CAPS/" + UUID.Random() + "/", agentID); - args.Type = PollServiceEventArgs.EventType.Inventory; + // Register this as a poll service + PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(m_scene, capUrl, agentID); + args.Type = PollServiceEventArgs.EventType.Inventory; - caps.RegisterPollHandler("FetchInventoryDescendents2", args); + caps.RegisterPollHandler(capName, args); + } + // external handler + else + { + capUrl = url; + IExternalCapsModule handler = m_scene.RequestModuleInterface(); + if (handler != null) + handler.RegisterExternalUserCapsHandler(agentID,caps,capName,capUrl); + else + caps.RegisterHandler(capName, capUrl); + } -// MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); -// -// string hostName = m_scene.RegionInfo.ExternalHostName; -// uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; -// string protocol = "http"; -// -// if (MainServer.Instance.UseSSL) -// { -// hostName = MainServer.Instance.SSLCommonName; -// port = MainServer.Instance.SSLPort; -// protocol = "https"; -// } -// -// caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); + // m_log.DebugFormat( + // "[FETCH INVENTORY DESCENDENTS2 MODULE]: Registered capability {0} at {1} in region {2} for {3}", + // capName, capUrl, m_scene.RegionInfo.RegionName, agentID); } // private void DeregisterCaps(UUID agentID, Caps caps) -- cgit v1.1 From dacc20ee48883efe3702c284edff5ee3fa0e96b0 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 11 Sep 2013 16:48:15 -0700 Subject: BulletSim: remove collision cache clearing logic for physical objects. This fixes constraints from getting messed up when properties change. --- OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 47df611..f89b376 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -302,13 +302,16 @@ public abstract class BSPhysObject : PhysicsActor { if (PhysBody.HasPhysicalBody) { - // Clear the collision cache since we've changed some properties. - PhysScene.PE.ClearCollisionProxyCache(PhysScene.World, PhysBody); if (IsPhysical) { // Physical objects might need activating PhysScene.PE.Activate(PhysBody, forceIt); } + else + { + // Clear the collision cache since we've changed some properties. + PhysScene.PE.ClearCollisionProxyCache(PhysScene.World, PhysBody); + } } } -- cgit v1.1 From 3c85afbb431d14a676c00d20bfeeb5e2d13e8eaf Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 12 Sep 2013 11:46:12 -0400 Subject: Allow setting the EntityTransfer-max_distance to 0 to override distance checks. This is to facilitate current viewer work fixing the distance limitations for teleporting. --- .../CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 4219254..9302784 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -518,6 +518,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// private bool IsWithinMaxTeleportDistance(RegionInfo sourceRegion, GridRegion destRegion) { + if(MaxTransferDistance == 0) + return true; + // m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Source co-ords are x={0} y={1}", curRegionX, curRegionY); // // m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final dest is x={0} y={1} {2}@{3}", -- cgit v1.1 From 07d6a0385fdbb0559a878f0884505459e08e7867 Mon Sep 17 00:00:00 2001 From: Talun Date: Tue, 10 Sep 2013 10:56:34 +0100 Subject: 6762: llList2Key fails to convert a string in a list to a key llGetPrimitiveParams changed to return the sculpty key as an LSL_String so that type checking in llList2Key will work --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 34e2b4d..924f4d9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8483,7 +8483,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case ScriptBaseClass.PRIM_TYPE_SCULPT: - res.Add(Shape.SculptTexture.ToString()); + res.Add(new LSL_String(Shape.SculptTexture.ToString())); res.Add(new LSL_Integer(Shape.SculptType)); break; -- cgit v1.1 From 3f0fa9f707e7e09f6dd9ad0becad18d5ffa4cb7b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 16 Sep 2013 19:45:42 +0100 Subject: To avoid viewers (particularly on the Hypergrid) from permanently caching a UUID -> "Unknown User" binding, drop the binding request rather than replying with "Unknown User" By not binding UUID -> "Unknown User", we leave open the possibility that the binding may be correctly resolved at a later time, which can still happen in some Hypergrid situations. Observed behaviour of LL viewer 3.3.4 is that a dropped bind request is not retried until the next session. --- .../UserManagement/UserManagementModule.cs | 77 ++++++++++++---------- 1 file changed, 42 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 8c983e6..25e8d69 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -178,17 +178,20 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement m_ServiceThrottle.Enqueue("name", uuid.ToString(), delegate { //m_log.DebugFormat("[YYY]: Name request {0}", uuid); - bool foundRealName = TryGetUserNames(uuid, names); - - if (names.Length == 2) - { - if (!foundRealName) - m_log.DebugFormat("[USER MANAGEMENT MODULE]: Sending {0} {1} for {2} to {3} since no bound name found", names[0], names[1], uuid, client.Name); + // As least upto September 2013, clients permanently cache UUID -> Name bindings. Some clients + // appear to clear this when the user asks it to clear the cache, but others may not. + // + // So to avoid clients + // (particularly Hypergrid clients) permanently binding "Unknown User" to a given UUID, we will + // instead drop the request entirely. + if (TryGetUserNames(uuid, names)) client.SendNameReply(uuid, names[0], names[1]); - } +// else +// m_log.DebugFormat( +// "[USER MANAGEMENT MODULE]: No bound name for {0} found, ignoring request from {1}", +// uuid, client.Name); }); - } } @@ -391,7 +394,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement } names[0] = "Unknown"; - names[1] = "UserUMMTGUN8"; + names[1] = "UserUMMTGUN9"; return false; } @@ -539,7 +542,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement AddUser(uuid, homeURL + ";" + first + " " + last); } - public void AddUser (UUID id, string creatorData) + public void AddUser(UUID id, string creatorData) { //m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData); @@ -549,24 +552,24 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement if (oldUser != null) { - if (creatorData == null || creatorData == String.Empty) - { - //ignore updates without creator data - return; - } - - //try update unknown users, but don't update anyone else - if (oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) - { - lock (m_UserCache) - m_UserCache.Remove(id); - m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData, oldUser.HomeURL); - } - else - { +// if (creatorData == null || creatorData == String.Empty) +// { +// //ignore updates without creator data +// return; +// } +// +// //try update unknown users, but don't update anyone else +// if (oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) +// { +// lock (m_UserCache) +// m_UserCache.Remove(id); +// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData, oldUser.HomeURL); +// } +// else +// { //we have already a valid user within the cache return; - } +// } } UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); @@ -602,15 +605,19 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement if (parts.Length >= 2) user.FirstName = parts[1].Replace(' ', '.'); } - else - { - // Temporarily add unknown user entries of this type into the cache so that we can distinguish - // this source from other recent (hopefully resolved) bugs that fail to retrieve a user name binding - // TODO: Can be removed when GUN* unknown users have definitely dropped significantly or - // disappeared. - user.FirstName = "Unknown"; - user.LastName = "UserUMMAU4"; - } + + // To avoid issues with clients, particularly Hypergrid ones, permanently caching + // UUID -> "Unknown User" name bindings, elsewhere we will drop such requests rather than replying. + // This also means that we cannot add an unknown user binding to the cache here. +// else +// { +// // Temporarily add unknown user entries of this type into the cache so that we can distinguish +// // this source from other recent (hopefully resolved) bugs that fail to retrieve a user name binding +// // TODO: Can be removed when GUN* unknown users have definitely dropped significantly or +// // disappeared. +// user.FirstName = "Unknown"; +// user.LastName = "UserUMMAU4"; +// } AddUserInternal(user); } -- cgit v1.1 From 60cf42cb8dda3931c87267c989eb7bb9abe5da2f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 16 Sep 2013 22:56:08 +0100 Subject: Make llGetLinkPrimitiveParams() abort and return existing list of params when it encounters an invalid link number, rather than throwing an exception Addresses http://opensimulator.org/mantis/view.php?id=6768 Thanks to talun for the patch on that commit - in the end I took a different approach that also deals with invalid PRIM_LINK_TARGET However, not yet generating the same warning on invalid PRIM_LINK_TARGET as seen on LL grid This commit also adds regression tests for some cases of llGetLinkPrimitiveParams() --- .../Shared/Api/Implementation/LSL_Api.cs | 13 +- .../Shared/Tests/LSL_ApiObjectTests.cs | 385 +++++++++++++++++++++ .../ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 238 +------------ 3 files changed, 397 insertions(+), 239 deletions(-) create mode 100644 OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 924f4d9..bd451a5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8190,6 +8190,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api while (true) { +// m_log.DebugFormat( +// "[LSL API]: GetEntityParams has {0} rules with scene entity named {1}", +// rules.Length, entity != null ? entity.Name : "NULL"); + + if (entity == null) + return result; + if (entity is SceneObjectPart) remaining = GetPrimParams((SceneObjectPart)entity, rules, ref result); else @@ -8400,7 +8407,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api while (idx < rules.Length) { int code = (int)rules.GetLSLIntegerItem(idx++); - int remain = rules.Length-idx; + int remain = rules.Length - idx; switch (code) { @@ -8777,7 +8784,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api )); break; case (int)ScriptBaseClass.PRIM_LINK_TARGET: - if(remain < 3) + + // TODO: Should be issuing a runtime script warning in this case. + if (remain < 3) return null; return rules.GetSublist(idx, -1); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs new file mode 100644 index 0000000..ff87cc1 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs @@ -0,0 +1,385 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using log4net; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenMetaverse.Assets; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Region.CoreModules.Avatar.AvatarFactory; +using OpenSim.Region.OptionalModules.World.NPC; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.ScriptEngine.Shared; +using OpenSim.Region.ScriptEngine.Shared.Api; +using OpenSim.Region.ScriptEngine.Shared.Instance; +using OpenSim.Region.ScriptEngine.Shared.ScriptBase; +using OpenSim.Services.Interfaces; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; +using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; +using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; + +namespace OpenSim.Region.ScriptEngine.Shared.Tests +{ + [TestFixture] + public class LSL_ApiObjectTests : OpenSimTestCase + { + private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; + private const float FLOAT_ACCURACY = 0.00005f; + + protected Scene m_scene; + protected XEngine.XEngine m_engine; + + [SetUp] + public override void SetUp() + { + base.SetUp(); + + IConfigSource initConfigSource = new IniConfigSource(); + IConfig config = initConfigSource.AddConfig("XEngine"); + config.Set("Enabled", "true"); + + m_scene = new SceneHelpers().SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, initConfigSource); + + m_engine = new XEngine.XEngine(); + m_engine.Initialise(initConfigSource); + m_engine.AddRegion(m_scene); + } + + [Test] + public void TestllGetLinkPrimitiveParams() + { + TestHelpers.InMethod(); + TestHelpers.EnableLogging(); + + UUID ownerId = TestHelpers.ParseTail(0x1); + + SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); + grp1.AbsolutePosition = new Vector3(10, 11, 12); + m_scene.AddSceneObject(grp1); + + LSL_Api apiGrp1 = new LSL_Api(); + apiGrp1.Initialize(m_engine, grp1.RootPart, null, null); + + // Check simple 1 prim case + { + LSL_List resList + = apiGrp1.llGetLinkPrimitiveParams(1, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); + + Assert.That(resList.Length, Is.EqualTo(1)); + } + + // Check invalid parameters are ignored + { + LSL_List resList + = apiGrp1.llGetLinkPrimitiveParams(3, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); + + Assert.That(resList.Length, Is.EqualTo(0)); + } + + // Check all parameters are ignored if an initial bad link is given + { + LSL_List resList + = apiGrp1.llGetLinkPrimitiveParams( + 3, + new LSL_List( + new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), + new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), + new LSL_Integer(1), + new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); + + Assert.That(resList.Length, Is.EqualTo(0)); + } + + // Check only subsequent parameters are ignored when we hit the first bad link number + { + LSL_List resList + = apiGrp1.llGetLinkPrimitiveParams( + 1, + new LSL_List( + new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), + new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), + new LSL_Integer(3), + new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); + + Assert.That(resList.Length, Is.EqualTo(1)); + } + } + + [Test] + // llSetPrimitiveParams and llGetPrimitiveParams test. + public void TestllSetPrimitiveParams() + { + TestHelpers.InMethod(); + + // Create Prim1. + Scene scene = new SceneHelpers().SetupScene(); + string obj1Name = "Prim1"; + UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); + SceneObjectPart part1 = + new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, + Vector3.Zero, Quaternion.Identity, + Vector3.Zero) { Name = obj1Name, UUID = objUuid }; + Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); + + LSL_Api apiGrp1 = new LSL_Api(); + apiGrp1.Initialize(m_engine, part1, null, null); + + // Note that prim hollow check is passed with the other prim params in order to allow the + // specification of a different check value from the prim param. A cylinder, prism, sphere, + // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below + // specifies a value of 95% and checks to see if 70% was properly returned. + + // Test a sphere. + CheckllSetPrimitiveParams( + apiGrp1, + "test 1", // Prim test identification string + new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size + ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type + ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type + new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut + 0.80f, // Prim hollow + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist + new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple + 0.80f); // Prim hollow check + + // Test a prism. + CheckllSetPrimitiveParams( + apiGrp1, + "test 2", // Prim test identification string + new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size + ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type + ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type + new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut + 0.90f, // Prim hollow + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist + new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear + 0.90f); // Prim hollow check + + // Test a box. + CheckllSetPrimitiveParams( + apiGrp1, + "test 3", // Prim test identification string + new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size + ScriptBaseClass.PRIM_TYPE_BOX, // Prim type + ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type + new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut + 0.95f, // Prim hollow + new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist + new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear + 0.95f); // Prim hollow check + + // Test a tube. + CheckllSetPrimitiveParams( + apiGrp1, + "test 4", // Prim test identification string + new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size + ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type + ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type + new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut + 0.00f, // Prim hollow + new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist + new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size + // Expression for y selected to test precision problems during byte + // cast in SetPrimitiveShapeParams. + new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear + new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut + // Expression for y selected to test precision problems during sbyte + // cast in SetPrimitiveShapeParams. + new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper + 1.11f, // Prim revolutions + 0.88f, // Prim radius + 0.95f, // Prim skew + 0.00f); // Prim hollow check + + // Test a prism. + CheckllSetPrimitiveParams( + apiGrp1, + "test 5", // Prim test identification string + new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size + ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type + ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type + new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut + 0.95f, // Prim hollow + // Expression for x selected to test precision problems during sbyte + // cast in SetPrimitiveShapeBlockParams. + new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist + // Expression for y selected to test precision problems during sbyte + // cast in SetPrimitiveShapeParams. + new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear + 0.70f); // Prim hollow check + + // Test a sculpted prim. + CheckllSetPrimitiveParams( + apiGrp1, + "test 6", // Prim test identification string + new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size + ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type + "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map + ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type + } + + // Set prim params for a box, cylinder or prism and check results. + public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, + LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, + float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear, + float primHollowCheck) + { + // Set the prim params. + api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, + ScriptBaseClass.PRIM_TYPE, primType, primHoleType, + primCut, primHollow, primTwist, primTaper, primShear)); + + // Get params for prim to validate settings. + LSL_Types.list primParams = + api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); + + // Validate settings. + CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); + Assert.AreEqual(primType, api.llList2Integer(primParams, 1), + "TestllSetPrimitiveParams " + primTest + " prim type check fail"); + Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), + "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); + CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); + Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); + CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); + CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 6), primTest + " prim taper"); + CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear"); + } + + // Set prim params for a sphere and check results. + public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, + LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, + float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck) + { + // Set the prim params. + api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, + ScriptBaseClass.PRIM_TYPE, primType, primHoleType, + primCut, primHollow, primTwist, primDimple)); + + // Get params for prim to validate settings. + LSL_Types.list primParams = + api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); + + // Validate settings. + CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); + Assert.AreEqual(primType, api.llList2Integer(primParams, 1), + "TestllSetPrimitiveParams " + primTest + " prim type check fail"); + Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), + "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); + CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); + Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); + CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); + CheckllSetPrimitiveParamsVector(primDimple, api.llList2Vector(primParams, 6), primTest + " prim dimple"); + } + + // Set prim params for a torus, tube or ring and check results. + public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, + LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, + float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, + LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, + float primRev, float primRadius, float primSkew, float primHollowCheck) + { + // Set the prim params. + api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, + ScriptBaseClass.PRIM_TYPE, primType, primHoleType, + primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut, + primTaper, primRev, primRadius, primSkew)); + + // Get params for prim to validate settings. + LSL_Types.list primParams = + api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); + + // Valdate settings. + CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); + Assert.AreEqual(primType, api.llList2Integer(primParams, 1), + "TestllSetPrimitiveParams " + primTest + " prim type check fail"); + Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), + "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); + CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); + Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); + CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); + CheckllSetPrimitiveParamsVector(primHoleSize, api.llList2Vector(primParams, 6), primTest + " prim hole size"); + CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear"); + CheckllSetPrimitiveParamsVector(primProfCut, api.llList2Vector(primParams, 8), primTest + " prim profile cut"); + CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 9), primTest + " prim taper"); + Assert.AreEqual(primRev, api.llList2Float(primParams, 10), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim revolutions fail"); + Assert.AreEqual(primRadius, api.llList2Float(primParams, 11), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim radius fail"); + Assert.AreEqual(primSkew, api.llList2Float(primParams, 12), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim skew fail"); + } + + // Set prim params for a sculpted prim and check results. + public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, + LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType) + { + // Set the prim params. + api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, + ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType)); + + // Get params for prim to validate settings. + LSL_Types.list primParams = + api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); + + // Validate settings. + CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); + Assert.AreEqual(primType, api.llList2Integer(primParams, 1), + "TestllSetPrimitiveParams " + primTest + " prim type check fail"); + Assert.AreEqual(primMap, (string)api.llList2String(primParams, 2), + "TestllSetPrimitiveParams " + primTest + " prim map check fail"); + Assert.AreEqual(primSculptType, api.llList2Integer(primParams, 3), + "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail"); + } + + public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg) + { + // Check each vector component against expected result. + Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY, + "TestllSetPrimitiveParams " + msg + " vector check fail on x component"); + Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY, + "TestllSetPrimitiveParams " + msg + " vector check fail on y component"); + Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY, + "TestllSetPrimitiveParams " + msg + " vector check fail on z component"); + } + + } +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index e97ae06..7e3726a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -47,9 +47,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [TestFixture, LongRunning] public class LSL_ApiTest { - private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; - private const float FLOAT_ACCURACY = 0.00005f; + private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; private LSL_Api m_lslApi; [SetUp] @@ -255,241 +254,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests } [Test] - // llSetPrimitiveParams and llGetPrimitiveParams test. - public void TestllSetPrimitiveParams() - { - TestHelpers.InMethod(); - - // Create Prim1. - Scene scene = new SceneHelpers().SetupScene(); - string obj1Name = "Prim1"; - UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); - SceneObjectPart part1 = - new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, - Vector3.Zero, Quaternion.Identity, - Vector3.Zero) { Name = obj1Name, UUID = objUuid }; - Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); - - // Note that prim hollow check is passed with the other prim params in order to allow the - // specification of a different check value from the prim param. A cylinder, prism, sphere, - // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below - // specifies a value of 95% and checks to see if 70% was properly returned. - - // Test a sphere. - CheckllSetPrimitiveParams( - "test 1", // Prim test identification string - new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size - ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type - ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type - new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut - 0.80f, // Prim hollow - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple - 0.80f); // Prim hollow check - - // Test a prism. - CheckllSetPrimitiveParams( - "test 2", // Prim test identification string - new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size - ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type - ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type - new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut - 0.90f, // Prim hollow - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear - 0.90f); // Prim hollow check - - // Test a box. - CheckllSetPrimitiveParams( - "test 3", // Prim test identification string - new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size - ScriptBaseClass.PRIM_TYPE_BOX, // Prim type - ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type - new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut - 0.95f, // Prim hollow - new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear - 0.95f); // Prim hollow check - - // Test a tube. - CheckllSetPrimitiveParams( - "test 4", // Prim test identification string - new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size - ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type - ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type - new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut - 0.00f, // Prim hollow - new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size - // Expression for y selected to test precision problems during byte - // cast in SetPrimitiveShapeParams. - new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear - new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut - // Expression for y selected to test precision problems during sbyte - // cast in SetPrimitiveShapeParams. - new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper - 1.11f, // Prim revolutions - 0.88f, // Prim radius - 0.95f, // Prim skew - 0.00f); // Prim hollow check - - // Test a prism. - CheckllSetPrimitiveParams( - "test 5", // Prim test identification string - new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size - ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type - ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type - new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut - 0.95f, // Prim hollow - // Expression for x selected to test precision problems during sbyte - // cast in SetPrimitiveShapeBlockParams. - new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist - // Expression for y selected to test precision problems during sbyte - // cast in SetPrimitiveShapeParams. - new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear - 0.70f); // Prim hollow check - - // Test a sculpted prim. - CheckllSetPrimitiveParams( - "test 6", // Prim test identification string - new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size - ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type - "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map - ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type - } - - // Set prim params for a box, cylinder or prism and check results. - public void CheckllSetPrimitiveParams(string primTest, - LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, - float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear, - float primHollowCheck) - { - // Set the prim params. - m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, - ScriptBaseClass.PRIM_TYPE, primType, primHoleType, - primCut, primHollow, primTwist, primTaper, primShear)); - - // Get params for prim to validate settings. - LSL_Types.list primParams = - m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); - - // Validate settings. - CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); - Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), - "TestllSetPrimitiveParams " + primTest + " prim type check fail"); - Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), - "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); - CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); - CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); - CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper"); - CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear"); - } - - // Set prim params for a sphere and check results. - public void CheckllSetPrimitiveParams(string primTest, - LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, - float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck) - { - // Set the prim params. - m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, - ScriptBaseClass.PRIM_TYPE, primType, primHoleType, - primCut, primHollow, primTwist, primDimple)); - - // Get params for prim to validate settings. - LSL_Types.list primParams = - m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); - - // Validate settings. - CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); - Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), - "TestllSetPrimitiveParams " + primTest + " prim type check fail"); - Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), - "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); - CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); - CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); - CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple"); - } - - // Set prim params for a torus, tube or ring and check results. - public void CheckllSetPrimitiveParams(string primTest, - LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, - float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, - LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, - float primRev, float primRadius, float primSkew, float primHollowCheck) - { - // Set the prim params. - m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, - ScriptBaseClass.PRIM_TYPE, primType, primHoleType, - primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut, - primTaper, primRev, primRadius, primSkew)); - - // Get params for prim to validate settings. - LSL_Types.list primParams = - m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); - - // Valdate settings. - CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); - Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), - "TestllSetPrimitiveParams " + primTest + " prim type check fail"); - Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), - "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); - CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); - CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); - CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size"); - CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear"); - CheckllSetPrimitiveParamsVector(primProfCut, m_lslApi.llList2Vector(primParams, 8), primTest + " prim profile cut"); - CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 9), primTest + " prim taper"); - Assert.AreEqual(primRev, m_lslApi.llList2Float(primParams, 10), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim revolutions fail"); - Assert.AreEqual(primRadius, m_lslApi.llList2Float(primParams, 11), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim radius fail"); - Assert.AreEqual(primSkew, m_lslApi.llList2Float(primParams, 12), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim skew fail"); - } - - // Set prim params for a sculpted prim and check results. - public void CheckllSetPrimitiveParams(string primTest, - LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType) - { - // Set the prim params. - m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, - ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType)); - - // Get params for prim to validate settings. - LSL_Types.list primParams = - m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); - - // Validate settings. - CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); - Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), - "TestllSetPrimitiveParams " + primTest + " prim type check fail"); - Assert.AreEqual(primMap, (string)m_lslApi.llList2String(primParams, 2), - "TestllSetPrimitiveParams " + primTest + " prim map check fail"); - Assert.AreEqual(primSculptType, m_lslApi.llList2Integer(primParams, 3), - "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail"); - } - - public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg) - { - // Check each vector component against expected result. - Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY, - "TestllSetPrimitiveParams " + msg + " vector check fail on x component"); - Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY, - "TestllSetPrimitiveParams " + msg + " vector check fail on y component"); - Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY, - "TestllSetPrimitiveParams " + msg + " vector check fail on z component"); - } - - [Test] public void TestllVecNorm() { TestHelpers.InMethod(); -- cgit v1.1 From f99dae03cb1f5ab7215de1f7741befc3f0856840 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 16 Sep 2013 23:00:40 +0100 Subject: Fix bug where using PRIM_LINK_TARGET with only two remaining list items (e.g. link number then PRIM_ROTATION) would not return the parameter Extended regression test for this case --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++-- .../Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index bd451a5..975bf2d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8202,7 +8202,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else remaining = GetAgentParams((ScenePresence)entity, rules, ref result); - if (remaining == null || remaining.Length <= 2) + if (remaining == null || remaining.Length < 2) return result; int linknumber = remaining.GetLSLIntegerItem(0); @@ -8786,7 +8786,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_LINK_TARGET: // TODO: Should be issuing a runtime script warning in this case. - if (remain < 3) + if (remain < 2) return null; return rules.GetSublist(idx, -1); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs index ff87cc1..ed61dc0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs @@ -100,6 +100,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.That(resList.Length, Is.EqualTo(1)); } + // Check 2 prim case + { + LSL_List resList + = apiGrp1.llGetLinkPrimitiveParams( + 1, + new LSL_List( + new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), + new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), + new LSL_Integer(2), + new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); + + Assert.That(resList.Length, Is.EqualTo(2)); + } + // Check invalid parameters are ignored { LSL_List resList -- cgit v1.1 From 2603a2891bd6e4e20d9169c4a74eaabf9b44fba0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 16 Sep 2013 23:26:13 +0100 Subject: Reinsert comments about possible race conditions when sending bulk inventory updates on non-flag clothing editing --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index c4b07a5..69b5f43 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -512,6 +512,9 @@ namespace OpenSim.Region.Framework.Scenes // This MAY be problematic, if it is, another solution // needs to be found. If inventory item flags are updated // the viewer's notion of the item needs to be refreshed. + // + // In other situations we cannot send out a bulk update here, since this will cause editing of clothing to start + // failing frequently. Possibly this is a race with a separate transaction that uploads the asset. if (sendUpdate) remoteClient.SendBulkUpdateInventory(item); } -- cgit v1.1 From 69ec85f4911de3218e0efb910fdbb1725e81e4ae Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Sep 2013 00:02:36 +0100 Subject: Fix issue in recent 3f0fa9f7 where the code start adding unknown user cache entries with no name --- .../CoreModules/Framework/UserManagement/UserManagementModule.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 25e8d69..63f78ac 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -602,8 +602,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement user.LastName = "@unknown"; } } + if (parts.Length >= 2) user.FirstName = parts[1].Replace(' ', '.'); + + AddUserInternal(user); } // To avoid issues with clients, particularly Hypergrid ones, permanently caching @@ -618,8 +621,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement // user.FirstName = "Unknown"; // user.LastName = "UserUMMAU4"; // } - - AddUserInternal(user); } } -- cgit v1.1 From 845d2b193a2e2058cfe89e06e0589f38c8103eb3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Sep 2013 00:54:53 +0100 Subject: Comment out warning about no grid user found in UMM.TryGetUserNamesFromServices() for now --- .../CoreModules/Framework/UserManagement/UserManagementModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 63f78ac..80b6ac1 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -388,10 +388,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement else m_log.DebugFormat("[USER MANAGEMENT MODULE]: Unable to parse UUI {0}", uInfo.UserID); } - else - { - m_log.DebugFormat("[USER MANAGEMENT MODULE]: No grid user found for {0}", uuid); - } +// else +// { +// m_log.DebugFormat("[USER MANAGEMENT MODULE]: No grid user found for {0}", uuid); +// } names[0] = "Unknown"; names[1] = "UserUMMTGUN9"; -- cgit v1.1 From 1d2466889a3f184ff86d0d607ab3d2d10b1b4e16 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Sep 2013 01:20:55 +0100 Subject: Reinstate insertion of "Unknown UserUMMAU4" now, as naive removing may be generating too many repeating user requests from other sources. Leaves in the dropping of the client GUN8 (now 9) uuid binding message, since this was the much more common case from the viewer-side and this can only affect viewers. --- .../UserManagement/UserManagementModule.cs | 66 ++++++++++------------ 1 file changed, 31 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 80b6ac1..bb2bbe3 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -388,10 +388,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement else m_log.DebugFormat("[USER MANAGEMENT MODULE]: Unable to parse UUI {0}", uInfo.UserID); } -// else -// { -// m_log.DebugFormat("[USER MANAGEMENT MODULE]: No grid user found for {0}", uuid); -// } + else + { + m_log.DebugFormat("[USER MANAGEMENT MODULE]: No grid user found for {0}", uuid); + } names[0] = "Unknown"; names[1] = "UserUMMTGUN9"; @@ -552,24 +552,24 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement if (oldUser != null) { -// if (creatorData == null || creatorData == String.Empty) -// { -// //ignore updates without creator data -// return; -// } -// -// //try update unknown users, but don't update anyone else -// if (oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) -// { -// lock (m_UserCache) -// m_UserCache.Remove(id); -// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData, oldUser.HomeURL); -// } -// else -// { + if (creatorData == null || creatorData == String.Empty) + { + //ignore updates without creator data + return; + } + + //try update unknown users, but don't update anyone else + if (oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) + { + lock (m_UserCache) + m_UserCache.Remove(id); + m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData, oldUser.HomeURL); + } + else + { //we have already a valid user within the cache return; -// } + } } UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); @@ -605,22 +605,18 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement if (parts.Length >= 2) user.FirstName = parts[1].Replace(' ', '.'); - - AddUserInternal(user); } - - // To avoid issues with clients, particularly Hypergrid ones, permanently caching - // UUID -> "Unknown User" name bindings, elsewhere we will drop such requests rather than replying. - // This also means that we cannot add an unknown user binding to the cache here. -// else -// { -// // Temporarily add unknown user entries of this type into the cache so that we can distinguish -// // this source from other recent (hopefully resolved) bugs that fail to retrieve a user name binding -// // TODO: Can be removed when GUN* unknown users have definitely dropped significantly or -// // disappeared. -// user.FirstName = "Unknown"; -// user.LastName = "UserUMMAU4"; -// } + else + { + // Temporarily add unknown user entries of this type into the cache so that we can distinguish + // this source from other recent (hopefully resolved) bugs that fail to retrieve a user name binding + // TODO: Can be removed when GUN* unknown users have definitely dropped significantly or + // disappeared. + user.FirstName = "Unknown"; + user.LastName = "UserUMMAU4"; + } + + AddUserInternal(user); } } -- cgit v1.1 From 7dbc93c62a6803fbe201e933b8bc1374b48869ad Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Sep 2013 21:41:51 +0100 Subject: Change logging to provide more information on LLUDPServer.HandleCompleteMovementIntoRegion() Add more information on which endpoint sent the packet when we have to wait and if we end up dropping the packet Only check if the client is active - other checks are redundant since they can only failed if IsActve = false --- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 49 +++++++++++++++++----- 1 file changed, 39 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 102e581..cdc1668 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1693,31 +1693,60 @@ namespace OpenSim.Region.ClientStack.LindenUDP CompleteAgentMovementPacket packet = (CompleteAgentMovementPacket)array[1]; // Determine which agent this packet came from + // We need to wait here because in when using the OpenSimulator V2 teleport protocol to travel to a destination + // simulator with no existing child presence, the viewer (at least LL 3.3.4) will send UseCircuitCode + // and then CompleteAgentMovement immediately without waiting for an ack. As we are now handling these + // packets asynchronously, we need to account for this thread proceeding more quickly than the + // UseCircuitCode thread. int count = 20; - bool ready = false; - while (!ready && count-- > 0) + while (count-- > 0) { - if (m_scene.TryGetClient(endPoint, out client) && client.IsActive && client.SceneAgent != null) + if (m_scene.TryGetClient(endPoint, out client)) { - LLClientView llClientView = (LLClientView)client; - LLUDPClient udpClient = llClientView.UDPClient; - if (udpClient != null && udpClient.IsConnected) - ready = true; + if (client.IsActive) + { + break; + } else { - m_log.Debug("[LLUDPSERVER]: Received a CompleteMovementIntoRegion in " + m_scene.RegionInfo.RegionName + " (not ready yet)"); - Thread.Sleep(200); + // This check exists to catch a condition where the client has been closed by another thread + // but has not yet been removed from the client manager (and possibly a new connection has + // not yet been established). + m_log.DebugFormat( + "[LLUDPSERVER]: Received a CompleteMovementIntoRegion from {0} for {1} in {2} but client is not active. Waiting.", + endPoint, client.Name, m_scene.Name); } } else { - m_log.Debug("[LLUDPSERVER]: Received a CompleteMovementIntoRegion in " + m_scene.RegionInfo.RegionName + " (not ready yet)"); + m_log.DebugFormat( + "[LLUDPSERVER]: Received a CompleteMovementIntoRegion from {0} in {1} but no client exists. Waiting.", + endPoint, m_scene.Name); + Thread.Sleep(200); } } if (client == null) + { + m_log.DebugFormat( + "[LLUDPSERVER]: No client found for CompleteMovementIntoRegion from {0} in {1} after wait. Dropping.", + endPoint, m_scene.Name); + return; + } + else if (!client.IsActive) + { + // This check exists to catch a condition where the client has been closed by another thread + // but has not yet been removed from the client manager. + // The packet could be simply ignored but it is useful to know if this condition occurred for other debugging + // purposes. + m_log.DebugFormat( + "[LLUDPSERVER]: Received a CompleteMovementIntoRegion from {0} for {1} in {2} but client is not active after wait. Dropping.", + endPoint, client.Name, m_scene.Name); + + return; + } IncomingPacket incomingPacket1; -- cgit v1.1 From f4d82a56f4c13bd24305e008418819edcfdc549d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Sep 2013 22:09:46 +0100 Subject: Double the time spent waiting for a UseCircuitCode packet in LLUDPServer.HandleCompleteMovementIntoRegion() This is to deal with one aspect of http://opensimulator.org/mantis/view.php?id=6755 With the V2 teleport arrangements, viewers appear to send the single UseCircuitCode and CompleteAgentMovement packets immediately after each other Possibly, on occasion a poor network might drop the initial UseCircuitCode packet and by the time it retries, the CompleteAgementMovement has timed out and the teleport fails. There's no apparant harm in doubling the wait time (most times only one wait will be performed) so trying this. --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index cdc1668..b1752c1 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1698,7 +1698,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // and then CompleteAgentMovement immediately without waiting for an ack. As we are now handling these // packets asynchronously, we need to account for this thread proceeding more quickly than the // UseCircuitCode thread. - int count = 20; + int count = 40; while (count-- > 0) { if (m_scene.TryGetClient(endPoint, out client)) -- cgit v1.1 From 3ce46adb2a614dda85b8207bb327dae6024824d8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Sep 2013 22:56:00 +0100 Subject: minor: Make log message when Scene.IncomingChildAgentDateUpdate() more explicit that there is a problem if it still finds the agent to be a child if the sender wanted to wait till it became root Add some comments about the mssage sequence, though much more data is at http://opensimulator.org/wiki/Teleports --- OpenSim/Region/Framework/Scenes/Scene.cs | 11 ++++++++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e00206f..6c9a8df 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4338,9 +4338,14 @@ namespace OpenSim.Region.Framework.Scenes while (sp.IsChildAgent && ntimes-- > 0) Thread.Sleep(1000); - m_log.DebugFormat( - "[SCENE]: Found presence {0} {1} {2} in {3} after {4} waits", - sp.Name, sp.UUID, sp.IsChildAgent ? "child" : "root", Name, 20 - ntimes); + if (sp.IsChildAgent) + m_log.DebugFormat( + "[SCENE]: Found presence {0} {1} unexpectedly still child in {2}", + sp.Name, sp.UUID, Name); + else + m_log.DebugFormat( + "[SCENE]: Found presence {0} {1} as root in {2} after {3} waits", + sp.Name, sp.UUID, Name, 20 - ntimes); if (sp.IsChildAgent) return false; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b4e8f09..d542e47 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1354,7 +1354,10 @@ namespace OpenSim.Region.Framework.Scenes private bool WaitForUpdateAgent(IClientAPI client) { - // Before UpdateAgent, m_originRegionID is UUID.Zero; after, it's non-Zero + // Before the source region executes UpdateAgent + // (which triggers Scene.IncomingChildAgentDataUpdate(AgentData cAgentData) here in the destination, + // m_originRegionID is UUID.Zero; after, it's non-Zero. The CompleteMovement sequence initiated from the + // viewer (in turn triggered by the source region sending it a TeleportFinish event) waits until it's non-zero int count = 50; while (m_originRegionID.Equals(UUID.Zero) && count-- > 0) { -- cgit v1.1 From ddcbd4bb7d1518d0607d43e9d687faee186e9409 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Sep 2013 23:09:38 +0100 Subject: refactor: rename *ChildAgentDataUpdate() methods to *UpdateChildAgent() verb-noun is consistent with other similar methods --- .../ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | 6 +++--- OpenSim/Region/Framework/Scenes/Scene.cs | 8 ++++---- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index e86d186..8ec943d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -235,7 +235,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", // destination.RegionName, destination.RegionID); - return m_scenes[destination.RegionID].IncomingChildAgentDataUpdate(cAgentData); + return m_scenes[destination.RegionID].IncomingUpdateChildAgent(cAgentData); } // m_log.DebugFormat( @@ -245,7 +245,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) + public bool UpdateAgent(GridRegion destination, AgentPosition agentPosition) { if (destination == null) return false; @@ -257,7 +257,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation foreach (Scene s in m_scenes.Values) { // m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); - s.IncomingChildAgentDataUpdate(cAgentData); + s.IncomingUpdateChildAgent(agentPosition); } //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6c9a8df..758a012 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4296,7 +4296,7 @@ namespace OpenSim.Region.Framework.Scenes /// Agent that contains all of the relevant things about an agent. /// Appearance, animations, position, etc. /// true if we handled it. - public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) + public virtual bool IncomingUpdateChildAgent(AgentData cAgentData) { m_log.DebugFormat( "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); @@ -4330,7 +4330,7 @@ namespace OpenSim.Region.Framework.Scenes sp.UUID, sp.ControllingClient.SessionId, cAgentData.SessionID)); } - sp.ChildAgentDataUpdate(cAgentData); + sp.UpdateChildAgent(cAgentData); int ntimes = 20; if (cAgentData.SenderWantsToWaitForRoot) @@ -4363,7 +4363,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// AgentPosition that contains agent positional data so we can know what to send /// true if we handled it. - public virtual bool IncomingChildAgentDataUpdate(AgentPosition cAgentData) + public virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData) { //m_log.Debug(" XXX Scene IncomingChildAgentDataUpdate POSITION in " + RegionInfo.RegionName); ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID); @@ -4383,7 +4383,7 @@ namespace OpenSim.Region.Framework.Scenes uint tRegionX = RegionInfo.RegionLocX; uint tRegionY = RegionInfo.RegionLocY; //Send Data to ScenePresence - childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); + childAgentUpdate.UpdateChildAgent(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); // Not Implemented: //TODO: Do we need to pass the message on to one of our neighbors? } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d542e47..3e61713 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3341,7 +3341,7 @@ namespace OpenSim.Region.Framework.Scenes #region Child Agent Updates - public void ChildAgentDataUpdate(AgentData cAgentData) + public void UpdateChildAgent(AgentData cAgentData) { // m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); if (!IsChildAgent) @@ -3351,11 +3351,12 @@ namespace OpenSim.Region.Framework.Scenes } private static Vector3 marker = new Vector3(-1f, -1f, -1f); + /// /// This updates important decision making data about a child agent /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region /// - public void ChildAgentDataUpdate(AgentPosition cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) + public void UpdateChildAgent(AgentPosition cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) { if (!IsChildAgent) return; -- cgit v1.1 From 8999f0602535ee7066caee5774a6dae72a12a45b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Sep 2013 23:13:31 +0100 Subject: minor: correct method name in comment --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3e61713..52ea8fe 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1355,7 +1355,7 @@ namespace OpenSim.Region.Framework.Scenes private bool WaitForUpdateAgent(IClientAPI client) { // Before the source region executes UpdateAgent - // (which triggers Scene.IncomingChildAgentDataUpdate(AgentData cAgentData) here in the destination, + // (which triggers Scene.IncomingUpdateChildAgent(AgentData cAgentData) here in the destination, // m_originRegionID is UUID.Zero; after, it's non-Zero. The CompleteMovement sequence initiated from the // viewer (in turn triggered by the source region sending it a TeleportFinish event) waits until it's non-zero int count = 50; -- cgit v1.1 From 83c113896ec518cef98880195f81bc6fe2d6a63f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Sep 2013 20:24:08 +0100 Subject: Create regression TestCrossOnSameSimulatorNoRootDestPerm() to check that avatars are not allowed to cross into a neighbour where they are not authorized, even if a child agent was allowed. --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +- .../Scenes/Tests/ScenePresenceCrossingTests.cs | 86 ++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 758a012..4357b91 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -731,6 +731,7 @@ namespace OpenSim.Region.Framework.Scenes m_config = config; MinFrameTime = 0.089f; MinMaintenanceTime = 1; + SeeIntoRegion = true; Random random = new Random(); @@ -841,7 +842,7 @@ namespace OpenSim.Region.Framework.Scenes //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); - SeeIntoRegion = startupConfig.GetBoolean("see_into_region", true); + SeeIntoRegion = startupConfig.GetBoolean("see_into_region", SeeIntoRegion); MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs index 12a778b..cf211a1 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs @@ -38,6 +38,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.CoreModules.Framework; using OpenSim.Region.CoreModules.Framework.EntityTransfer; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; +using OpenSim.Region.CoreModules.World.Permissions; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; @@ -159,5 +160,90 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(agentMovementCompleteReceived, Is.EqualTo(1)); Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False); } + + /// + /// Test a cross attempt where the user can see into the neighbour but does not have permission to become + /// root there. + /// + [Test] + public void TestCrossOnSameSimulatorNoRootDestPerm() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + UUID userId = TestHelpers.ParseTail(0x1); + + EntityTransferModule etmA = new EntityTransferModule(); + EntityTransferModule etmB = new EntityTransferModule(); + LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); + + IConfigSource config = new IniConfigSource(); + IConfig modulesConfig = config.AddConfig("Modules"); + modulesConfig.Set("EntityTransferModule", etmA.Name); + modulesConfig.Set("SimulationServices", lscm.Name); + + SceneHelpers sh = new SceneHelpers(); + TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); + TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999); + + SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); + SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA); + + // We need to set up the permisions module on scene B so that our later use of agent limit to deny + // QueryAccess won't succeed anyway because administrators are always allowed in and the default + // IsAdministrator if no permissions module is present is true. + SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new PermissionsModule(), etmB); + + AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); + TestClient tc = new TestClient(acd, sceneA); + List destinationTestClients = new List(); + EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients); + + // Make sure sceneB will not accept this avatar. + sceneB.RegionInfo.EstateSettings.PublicAccess = false; + + ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd); + originalSp.AbsolutePosition = new Vector3(128, 32, 10); + + AgentUpdateArgs moveArgs = new AgentUpdateArgs(); + //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero); + moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2))); + moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; + moveArgs.SessionID = acd.SessionID; + + originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs); + + sceneA.Update(1); + +// Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition); + + // FIXME: This is a sufficient number of updates to for the presence to reach the northern border. + // But really we want to do this in a more robust way. + for (int i = 0; i < 100; i++) + { + sceneA.Update(1); +// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition); + } + + // sceneA agent should still be root + ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID); + Assert.That(spAfterCrossSceneA.IsChildAgent, Is.False); + + ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID); + + // sceneB agent should also still be root + Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True); + + // sceneB should ignore unauthorized attempt to upgrade agent to root + TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient); + + int agentMovementCompleteReceived = 0; + sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++; + + sceneBTc.CompleteMovement(); + + Assert.That(agentMovementCompleteReceived, Is.EqualTo(0)); + Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True); + } } } \ No newline at end of file -- cgit v1.1 From 3a9a8d2113cc6cc333edf7e813f881111f301378 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Sep 2013 20:26:26 +0100 Subject: Revert "Also check user authorization if looking to upgrade from a child to a root agent." This reverts commit c7ded0618c303f8c24a91c83c2129292beebe466. This proves not to be necessary - the necessary checks are already being done via QueryAccess() before cross or teleport --- OpenSim/Region/Framework/Scenes/Scene.cs | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4357b91..495491c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3861,19 +3861,6 @@ namespace OpenSim.Region.Framework.Scenes // Let the SP know how we got here. This has a lot of interesting // uses down the line. sp.TeleportFlags = (TPFlags)teleportFlags; - - // We must carry out a further authorization check if there's an - // attempt to make a child agent into a root agent, since SeeIntoRegion may have allowed a child - // agent to login to a region where a full avatar would not be allowed. - // - // We determine whether this is a CreateAgent for a future non-child agent by inspecting - // TeleportFlags, which will be default for a child connection. This relies on input from the source - // region. - if (sp.TeleportFlags != TPFlags.Default) - { - if (!AuthorizeUser(acd, false, out reason)) - return false; - } if (sp.IsChildAgent) { -- cgit v1.1 From 6bdef1f70b782b69090e5846f9463942857d97cd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Sep 2013 20:49:55 +0100 Subject: minor: Stop debug logging whenever an npc is moved, other npc log related formatting cleanups --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index c26fdfc..b863370 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -146,9 +146,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC int.MaxValue); m_log.DebugFormat( - "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", - firstname, lastname, npcAvatar.AgentId, owner, - senseAsAgent, position, scene.RegionInfo.RegionName); + "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", + firstname, lastname, npcAvatar.AgentId, owner, + senseAsAgent, position, scene.RegionInfo.RegionName); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = npcAvatar.AgentId; @@ -188,16 +188,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC sp.CompleteMovement(npcAvatar, false); m_avatars.Add(npcAvatar.AgentId, npcAvatar); - m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", - npcAvatar.AgentId, sp.Name); + m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); return npcAvatar.AgentId; } else { m_log.WarnFormat( - "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", - sp.Name, sp.UUID); + "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", + sp.Name, sp.UUID); + return UUID.Zero; } } @@ -213,10 +213,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC ScenePresence sp; if (scene.TryGetScenePresence(agentID, out sp)) { - m_log.DebugFormat( - "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", - sp.Name, pos, scene.RegionInfo.RegionName, - noFly, landAtTarget); +// m_log.DebugFormat( +// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", +// sp.Name, pos, scene.RegionInfo.RegionName, +// noFly, landAtTarget); sp.MoveToTarget(pos, noFly, landAtTarget); sp.SetAlwaysRun = running; @@ -293,9 +293,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC ScenePresence sp; if (scene.TryGetScenePresence(agentID, out sp)) { - sp.HandleAgentRequestSit(m_avatars[agentID], agentID, - partID, Vector3.Zero); - //sp.HandleAgentSit(m_avatars[agentID], agentID); + sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); return true; } @@ -387,8 +385,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC */ scene.IncomingCloseAgent(agentID, false); -// scene.RemoveClient(agentID, false); + m_avatars.Remove(agentID); + /* m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); @@ -427,4 +426,4 @@ namespace OpenSim.Region.OptionalModules.World.NPC av.OwnerID == callerID; } } -} +} \ No newline at end of file -- cgit v1.1 From 03b2b5b77bef684536143ed509df444b859c26c0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Sep 2013 20:59:27 +0100 Subject: minor: Make log message at top of ScenePresence.CompleteMovement info level and comment out later log message in ScenePresence.MakeRootAgent() Need an info message since this is currently important in detecting teleport issue when not at debug log level. CompleteMovement message occurs before MakeRootAgent() one did --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 52ea8fe..e247875 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -900,9 +900,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void MakeRootAgent(Vector3 pos, bool isFlying) { - m_log.InfoFormat( - "[SCENE]: Upgrading child to root agent for {0} in {1}", - Name, m_scene.RegionInfo.RegionName); +// m_log.InfoFormat( +// "[SCENE]: Upgrading child to root agent for {0} in {1}", +// Name, m_scene.RegionInfo.RegionName); //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); @@ -1388,9 +1388,9 @@ namespace OpenSim.Region.Framework.Scenes { // DateTime startTime = DateTime.Now; - m_log.DebugFormat( + m_log.InfoFormat( "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", - client.Name, Scene.RegionInfo.RegionName, AbsolutePosition); + client.Name, Scene.Name, AbsolutePosition); // Make sure it's not a login agent. We don't want to wait for updates during login if (PresenceType != PresenceType.Npc && (m_teleportFlags & TeleportFlags.ViaLogin) == 0) -- cgit v1.1 From b6f10780c25007032835c4247fbd51d695d348df Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Sep 2013 21:44:30 +0100 Subject: minor: Make SP.MakeRootAgent() private - no external code has any business calling this method --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e247875..f12d629 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -898,7 +898,7 @@ namespace OpenSim.Region.Framework.Scenes /// This method is on the critical path for transferring an avatar from one region to another. Delay here /// delays that crossing. /// - public void MakeRootAgent(Vector3 pos, bool isFlying) + private void MakeRootAgent(Vector3 pos, bool isFlying) { // m_log.InfoFormat( // "[SCENE]: Upgrading child to root agent for {0} in {1}", -- cgit v1.1 From 979b17165b7e504385187ab082ef0a8cd50605bd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Sep 2013 22:45:50 +0100 Subject: For debug purposes, allow simulators to force use of earlier SIMULATION/0.1 teleport protocol even if SIMULATION/0.2 is available. This is specified in the MaxOutgoingTransferVersion attribute of [EntityTransfer] in OpenSim.ini, see OpenSimDefaults.ini for more details. Default remains "SIMULATION/0.2" Primarily for http://opensimulator.org/mantis/view.php?id=6755 --- .../EntityTransfer/EntityTransferModule.cs | 53 ++++++++++++++++++++-- .../Scenes/Tests/ScenePresenceTeleportTests.cs | 2 +- 2 files changed, 50 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 9302784..c1c8672 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -56,6 +56,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public const int DefaultMaxTransferDistance = 4095; public const bool WaitForAgentArrivedAtDestinationDefault = true; + public string OutgoingTransferVersionName { get; set; } + + /// + /// Determine the maximum entity transfer version we will use for teleports. + /// + public float MaxOutgoingTransferVersion { get; set; } + /// /// The maximum distance, in standard region units (256m) that an agent is allowed to transfer. /// @@ -151,9 +158,35 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// protected virtual void InitialiseCommon(IConfigSource source) { + string transferVersionName = "SIMULATION"; + float maxTransferVersion = 0.2f; + IConfig transferConfig = source.Configs["EntityTransfer"]; if (transferConfig != null) { + string rawVersion + = transferConfig.GetString( + "MaxOutgoingTransferVersion", + string.Format("{0}/{1}", transferVersionName, maxTransferVersion)); + + string[] rawVersionComponents = rawVersion.Split(new char[] { '/' }); + + bool versionValid = false; + + if (rawVersionComponents.Length >= 2) + versionValid = float.TryParse(rawVersionComponents[1], out maxTransferVersion); + + if (!versionValid) + { + m_log.ErrorFormat( + "[ENTITY TRANSFER MODULE]: MaxOutgoingTransferVersion {0} is invalid, using {1}", + rawVersion, string.Format("{0}/{1}", transferVersionName, maxTransferVersion)); + } + else + { + transferVersionName = rawVersionComponents[0]; + } + DisableInterRegionTeleportCancellation = transferConfig.GetBoolean("DisableInterRegionTeleportCancellation", false); @@ -167,6 +200,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer MaxTransferDistance = DefaultMaxTransferDistance; } + OutgoingTransferVersionName = transferVersionName; + MaxOutgoingTransferVersion = maxTransferVersion; + m_entityTransferStateMachine = new EntityTransferStateMachine(this); m_Enabled = true; @@ -623,7 +659,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (!sp.ValidateAttachments()) m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for teleport of {0} from {1} to {2}. Continuing.", - sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName); + sp.Name, sp.Scene.Name, finalDestination.RegionName); string reason; string version; @@ -634,7 +670,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: {0} was stopped from teleporting from {1} to {2} because {3}", - sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName, reason); + sp.Name, sp.Scene.Name, finalDestination.RegionName, reason); return; } @@ -644,7 +680,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // as server attempts. m_interRegionTeleportAttempts.Value++; - m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Destination is running version {0}", version); + m_log.DebugFormat( + "[ENTITY TRANSFER MODULE]: {0} max transfer version is {1}/{2}, {3} max version is {4}", + sp.Scene.Name, OutgoingTransferVersionName, MaxOutgoingTransferVersion, finalDestination.RegionName, version); // Fixing a bug where teleporting while sitting results in the avatar ending up removed from // both regions @@ -689,7 +727,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); } - if (version.Equals("SIMULATION/0.2")) + // We're going to fallback to V1 if the destination gives us anything smaller than 0.2 or we're forcing + // use of the earlier protocol + float versionNumber = 0.1f; + string[] versionComponents = version.Split(new char[] { '/' }); + if (versionComponents.Length >= 2) + float.TryParse(versionComponents[1], out versionNumber); + + if (versionNumber == 0.2f && MaxOutgoingTransferVersion >= versionNumber) TransferAgent_V2(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason); else TransferAgent_V1(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason); diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index 8c25dbc..3ba34dd 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs @@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests public void TestSameSimulatorIsolatedRegionsV2() { TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); + TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); -- cgit v1.1 From f1267730ef7c4c91e189ad98eeda1bfa80aa106c Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 24 Apr 2013 11:42:27 +0300 Subject: UUID Gatherer: find assets used in Light Projection, Particle Systems, and Collision Sounds. --- OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 8f69ce3..502c748 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -172,7 +172,20 @@ namespace OpenSim.Region.Framework.Scenes // If the prim is a sculpt then preserve this information too if (part.Shape.SculptTexture != UUID.Zero) assetUuids[part.Shape.SculptTexture] = AssetType.Texture; - + + if (part.Shape.ProjectionTextureUUID != UUID.Zero) + assetUuids[part.Shape.ProjectionTextureUUID] = AssetType.Texture; + + if (part.CollisionSound != UUID.Zero) + assetUuids[part.CollisionSound] = AssetType.Sound; + + if (part.ParticleSystem.Length > 0) + { + Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0); + if (ps.Texture != UUID.Zero) + assetUuids[ps.Texture] = AssetType.Texture; + } + TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); // Now analyze this prim's inventory items to preserve all the uuids that they reference -- cgit v1.1 From 07d7a5fd76460a16b97d285a1b2c4a101e5543b6 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 20 Sep 2013 09:36:19 -0700 Subject: BulletSim: zero velocity when avatar not moving. This fixes a movement jitter that happens when an avatar is standing on a tilted surface. --- OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs index 04a4a32..8ca55e5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs @@ -278,6 +278,7 @@ public class BSActorAvatarMove : BSActor if (m_controllingPrim.IsStationary) { entprop.Position = m_controllingPrim.RawPosition; + entprop.Velocity = OMV.Vector3.Zero; m_physicsScene.PE.SetTranslation(m_controllingPrim.PhysBody, entprop.Position, entprop.Rotation); } -- cgit v1.1 From 35a6361b2431abf9d49b4413c5b9eaac51934134 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 20 Sep 2013 09:23:12 -0700 Subject: BulletSim: reduce avatar walking stopped threshold. Add parameter for setting the walking stopped threshold. This fixes the slight jump when an avatar stops walking. --- OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs | 1 + OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 3 +++ 2 files changed, 4 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs index 8ca55e5..1bcf879 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs @@ -128,6 +128,7 @@ public class BSActorAvatarMove : BSActor BSMotor.Infinite, // decay time scale 1f // efficiency ); + m_velocityMotor.ErrorZeroThreshold = BSParam.AvatarStopZeroThreshold; // _velocityMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG so motor will output detail log messages. SetVelocityAndTarget(m_controllingPrim.RawVelocity, m_controllingPrim.TargetVelocity, true /* inTaintTime */); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 2f1799b..43aa63e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -134,6 +134,7 @@ public static class BSParam public static float AvatarHeightMidFudge { get; private set; } public static float AvatarHeightHighFudge { get; private set; } public static float AvatarContactProcessingThreshold { get; private set; } + public static float AvatarStopZeroThreshold { get; private set; } public static int AvatarJumpFrames { get; private set; } public static float AvatarBelowGroundUpCorrectionMeters { get; private set; } public static float AvatarStepHeight { get; private set; } @@ -575,6 +576,8 @@ public static class BSParam 0.1f ), new ParameterDefn("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions", 0.1f ), + new ParameterDefn("AvatarStopZeroThreshold", "Movement velocity below which avatar is assumed to be stopped", + 0.1f ), new ParameterDefn("AvatarBelowGroundUpCorrectionMeters", "Meters to move avatar up if it seems to be below ground", 1.0f ), new ParameterDefn("AvatarJumpFrames", "Number of frames to allow jump forces. Changes jump height.", -- cgit v1.1 From c6dea6ee783b0d2f300ef34fb432fb7197a5dabb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Sep 2013 20:19:44 +0100 Subject: Change some message log levels in Scene.IncomingUpdateChildAgent() for debugging purposes --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 495491c..bc5a67f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4293,7 +4293,7 @@ namespace OpenSim.Region.Framework.Scenes ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); if (nearestParcel == null) { - m_log.DebugFormat( + m_log.InfoFormat( "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel", cAgentData.AgentID, RegionInfo.RegionName); @@ -4327,11 +4327,11 @@ namespace OpenSim.Region.Framework.Scenes Thread.Sleep(1000); if (sp.IsChildAgent) - m_log.DebugFormat( + m_log.WarnFormat( "[SCENE]: Found presence {0} {1} unexpectedly still child in {2}", sp.Name, sp.UUID, Name); else - m_log.DebugFormat( + m_log.InfoFormat( "[SCENE]: Found presence {0} {1} as root in {2} after {3} waits", sp.Name, sp.UUID, Name, 20 - ntimes); -- cgit v1.1 From c01db5fbdd982a9613d1d64e2ac54f1b5c73b63c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Sep 2013 22:41:53 +0100 Subject: Lock around read/write of ScenePresence.m_originRegionID to make sure that all threads are seeing the latest value and not a cached one. There is a possibilty that some V2 teleport failures are due to the viewer triggered CompleteMovement thread not seeing the change of m_originRegionID by the UpdateAgent thread. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 38 ++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f12d629..8d72e18 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -311,7 +311,21 @@ namespace OpenSim.Region.Framework.Scenes /// private string m_callbackURI; - public UUID m_originRegionID; + /// + /// Records the region from which this presence originated, if not from login. + /// + /// + /// Also acts as a signal in the teleport V2 process to release UpdateAgent after a viewer has triggered + /// CompleteMovement and made the previous child agent a root agent. + /// + private UUID m_originRegionID; + + /// + /// This object is used as a lock before accessing m_originRegionID to make sure that every thread is seeing + /// the very latest value and not using some cached version. Cannot make m_originRegionID itself volatite as + /// it is a value type. + /// + private object m_originRegionIDAccessLock = new object(); /// /// Used by the entity transfer module to signal when the presence should not be closed because a subsequent @@ -1359,13 +1373,21 @@ namespace OpenSim.Region.Framework.Scenes // m_originRegionID is UUID.Zero; after, it's non-Zero. The CompleteMovement sequence initiated from the // viewer (in turn triggered by the source region sending it a TeleportFinish event) waits until it's non-zero int count = 50; - while (m_originRegionID.Equals(UUID.Zero) && count-- > 0) + UUID originID; + + lock (m_originRegionIDAccessLock) + originID = m_originRegionID; + + while (originID.Equals(UUID.Zero) && count-- > 0) { + lock (m_originRegionIDAccessLock) + originID = m_originRegionID; + m_log.DebugFormat("[SCENE PRESENCE]: Agent {0} waiting for update in {1}", client.Name, Scene.Name); Thread.Sleep(200); } - if (m_originRegionID.Equals(UUID.Zero)) + if (originID.Equals(UUID.Zero)) { // Movement into region will fail m_log.WarnFormat("[SCENE PRESENCE]: Update agent {0} never arrived in {1}", client.Name, Scene.Name); @@ -1444,7 +1466,12 @@ namespace OpenSim.Region.Framework.Scenes "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}", client.Name, client.AgentId, m_callbackURI); - Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); + UUID originID; + + lock (m_originRegionIDAccessLock) + originID = m_originRegionID; + + Scene.SimulationService.ReleaseAgent(originID, UUID, m_callbackURI); m_callbackURI = null; } // else @@ -3461,7 +3488,8 @@ namespace OpenSim.Region.Framework.Scenes private void CopyFrom(AgentData cAgent) { - m_originRegionID = cAgent.RegionID; + lock (m_originRegionIDAccessLock) + m_originRegionID = cAgent.RegionID; m_callbackURI = cAgent.CallbackURI; // m_log.DebugFormat( -- cgit v1.1 From 8502517d8081366dfc63756ae07cfe64a27a1eb0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Sep 2013 23:07:24 +0100 Subject: Make UUID.Zero resolve to "Unknown User" in user cache. This is to avoid massive numbers of 'no user found' logs when user IDs are missing for some reason. UUID.Zero should not be used for any user ID. --- .../Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index bb2bbe3..96eb63f 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -73,6 +73,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement Init(); m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); } + + AddUser(UUID.Zero, "Unknown", "User"); } public bool IsSharedModule -- cgit v1.1 From e2b3b7a2ae01a82e7ca1ed7efd6237a5bf1c9811 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Sep 2013 23:42:55 +0100 Subject: minor: Correct minor spelling mistake Reseting -> Resetting in HG Map module log message --- OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs index 97227b3..79a409d 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs @@ -129,7 +129,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid b.Access = 254; // means 'simulator is offline'. We need this because the viewer ignores 255's } - m_log.DebugFormat("[HG MAP]: Reseting {0} blocks", mapBlocks.Count); + m_log.DebugFormat("[HG MAP]: Resetting {0} blocks", mapBlocks.Count); sp.ControllingClient.SendMapBlock(mapBlocks, 0); m_SeenMapBlocks.Remove(clientID); } -- cgit v1.1 From 4c0ec861769497b64b5ad71f712fb792564ebe4a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 Sep 2013 00:14:57 +0100 Subject: minor: Add prefix to log message in LureModule --- OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index 7f4606b..465ffbc 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs @@ -165,7 +165,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure (uint)presence.AbsolutePosition.Y, (uint)Math.Ceiling(presence.AbsolutePosition.Z)); - m_log.DebugFormat("TP invite with message {0}, type {1}", message, lureType); + m_log.DebugFormat("[LURE MODULE]: TP invite with message {0}, type {1}", message, lureType); GridInstantMessage m = new GridInstantMessage(scene, client.AgentId, client.FirstName+" "+client.LastName, targetid, -- cgit v1.1 From cbdfe96905da9d1386b572f89e8372bbdb3345e6 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 15 Jul 2013 15:26:18 +0300 Subject: When giving items between avatars in different simulators, only add the item to the receiving avatar's inventory once. When a user gives an item, the user's client sends an InventoryOffered IM message to its simulator. This adds the item to the receiver's inventory. If the receiver isn't in the same simulator then XMLRPC is used to forward the IM to the correct simulator. The bug was that the receiving simulator handled the message by calling OnInstantMessage() again, which added a second copy of the item to the inventory. Instead, the receiving simulator should only notify the avatar that the item was offered. --- .../Inventory/Transfer/InventoryTransferModule.cs | 53 ++++++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 1417a19..f52654f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -148,9 +148,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer private void OnInstantMessage(IClientAPI client, GridInstantMessage im) { -// m_log.DebugFormat( -// "[INVENTORY TRANSFER]: {0} IM type received from {1}", -// (InstantMessageDialog)im.dialog, client.Name); + m_log.DebugFormat( + "[INVENTORY TRANSFER]: {0} IM type received from client {1}. From={2} ({3}), To={4}", + (InstantMessageDialog)im.dialog, client.Name, + im.fromAgentID, im.fromAgentName, im.toAgentID); Scene scene = FindClientScene(client.AgentId); @@ -450,23 +451,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer /// /// /// - /// - private void OnGridInstantMessage(GridInstantMessage msg) + /// + private void OnGridInstantMessage(GridInstantMessage im) { + // Check if it's a type of message that we should handle + if (!((im.dialog == (byte) InstantMessageDialog.InventoryOffered) + || (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) + || (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) + || (im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined))) + return; + + m_log.DebugFormat( + "[INVENTORY TRANSFER]: {0} IM type received from grid. From={1} ({2}), To={3}", + (InstantMessageDialog)im.dialog, im.fromAgentID, im.fromAgentName, im.toAgentID); + // Check if this is ours to handle // - Scene scene = FindClientScene(new UUID(msg.toAgentID)); + Scene scene = FindClientScene(new UUID(im.toAgentID)); if (scene == null) return; // Find agent to deliver to // - ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); + ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); - // Just forward to local handling - OnInstantMessage(user.ControllingClient, msg); + if (user != null) + { + user.ControllingClient.SendInstantMessage(im); + if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) + { + AssetType assetType = (AssetType)im.binaryBucket[0]; + UUID inventoryID = new UUID(im.binaryBucket, 1); + + IInventoryService invService = scene.InventoryService; + InventoryNodeBase node = null; + if (AssetType.Folder == assetType) + { + InventoryFolderBase folder = new InventoryFolderBase(inventoryID, new UUID(im.toAgentID)); + node = invService.GetFolder(folder); + } + else + { + InventoryItemBase item = new InventoryItemBase(inventoryID, new UUID(im.toAgentID)); + node = invService.GetItem(item); + } + + if (node != null) + user.ControllingClient.SendBulkUpdateInventory(node); + } + } } } } -- cgit v1.1 From a37c59b43e34e1b3f279f7684a42a2c4a25f18c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 Sep 2013 00:40:23 +0100 Subject: minor: Recomment out log message uncommented in previous cbdfe969 --- .../Avatar/Inventory/Transfer/InventoryTransferModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index f52654f..0b10dd8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -148,10 +148,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer private void OnInstantMessage(IClientAPI client, GridInstantMessage im) { - m_log.DebugFormat( - "[INVENTORY TRANSFER]: {0} IM type received from client {1}. From={2} ({3}), To={4}", - (InstantMessageDialog)im.dialog, client.Name, - im.fromAgentID, im.fromAgentName, im.toAgentID); +// m_log.DebugFormat( +// "[INVENTORY TRANSFER]: {0} IM type received from client {1}. From={2} ({3}), To={4}", +// (InstantMessageDialog)im.dialog, client.Name, +// im.fromAgentID, im.fromAgentName, im.toAgentID); Scene scene = FindClientScene(client.AgentId); -- cgit v1.1 From 2dc92e7de11086c7649d3ee0f8adc974efce6805 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sun, 4 Aug 2013 19:19:11 +0200 Subject: Preserve attachment point & position when attachment is rezzed in world Patch taken from http://opensimulator.org/mantis/view.php?id=4905 originally by Greg C. Fixed to apply to r/23314 commit ba9daf849e7c8db48e7c03e7cdedb77776b2052f (cherry picked from commit 4ff9fbca441110cc2b93edc7286e0e9339e61cbe) --- .../ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs | 4 ++++ .../Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs | 1 + OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 1 + .../Avatar/Attachments/AttachmentsModule.cs | 18 +++++++++++++++++- .../Framework/InventoryAccess/InventoryAccessModule.cs | 8 ++++++++ OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 7 +++++++ .../Scenes/Serialization/SceneObjectSerializer.cs | 14 ++++++++++++++ 7 files changed, 52 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs index 92805e2..94f8bc1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs @@ -155,6 +155,7 @@ namespace OpenSim.Region.ClientStack.Linden Quaternion rotation = Quaternion.Identity; Vector3 scale = Vector3.Zero; int state = 0; + int lastattach = 0; if (r.Type != OSDType.Map) // not a proper req return responsedata; @@ -224,6 +225,7 @@ namespace OpenSim.Region.ClientStack.Linden ray_target_id = ObjMap["RayTargetId"].AsUUID(); state = ObjMap["State"].AsInteger(); + lastattach = ObjMap["LastAttachPoint"].AsInteger(); try { ray_end = ((OSDArray)ObjMap["RayEnd"]).AsVector3(); @@ -290,6 +292,7 @@ namespace OpenSim.Region.ClientStack.Linden //session_id = rm["session_id"].AsUUID(); state = rm["state"].AsInteger(); + lastattach = rm["last_attach_point"].AsInteger(); try { ray_end = ((OSDArray)rm["ray_end"]).AsVector3(); @@ -331,6 +334,7 @@ namespace OpenSim.Region.ClientStack.Linden pbs.ProfileEnd = (ushort)profile_end; pbs.Scale = scale; pbs.State = (byte)state; + pbs.LastAttachPoint = (byte)lastattach; SceneObjectGroup obj = null; ; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs index 55a503e..769fe28 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs @@ -277,6 +277,7 @@ namespace OpenSim.Region.ClientStack.Linden pbs.ProfileEnd = (ushort) obj.ProfileEnd; pbs.Scale = obj.Scale; pbs.State = (byte) 0; + pbs.LastAttachPoint = (byte) 0; SceneObjectPart prim = new SceneObjectPart(); prim.UUID = UUID.Random(); prim.CreatorID = AgentId; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 1b091bf..3609ec1 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -12188,6 +12188,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP shape.PCode = addPacket.ObjectData.PCode; shape.State = addPacket.ObjectData.State; + shape.LastAttachPoint = addPacket.ObjectData.State; shape.PathBegin = addPacket.ObjectData.PathBegin; shape.PathEnd = addPacket.ObjectData.PathEnd; shape.PathScaleX = addPacket.ObjectData.PathScaleX; diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2818712..d0e0b35 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -422,6 +422,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments attachPos = Vector3.Zero; } + // if the attachment point is the same as previous, make sure we get the saved + // position info. + if (attachmentPt != 0 && attachmentPt == group.RootPart.Shape.LastAttachPoint) + { + attachPos = group.RootPart.AttachedPos; + } + // AttachmentPt 0 means the client chose to 'wear' the attachment. if (attachmentPt == (uint)AttachmentPoint.Default) { @@ -429,6 +436,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments attachmentPt = group.AttachmentPoint; } + // if we didn't find an attach point, look for where it was last attached + if (attachmentPt == 0) + { + attachmentPt = (uint)group.RootPart.Shape.LastAttachPoint; + attachPos = group.RootPart.AttachedPos; + group.HasGroupChanged = true; + } + // if we still didn't find a suitable attachment point....... if (attachmentPt == 0) { @@ -619,6 +634,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments so.ClearPartAttachmentData(); rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive); so.HasGroupChanged = true; + so.RootPart.Shape.LastAttachPoint = (byte)so.AttachmentPoint; rootPart.Rezzed = DateTime.Now; rootPart.RemFlag(PrimFlags.TemporaryOnRez); so.AttachToBackup(); @@ -1210,4 +1226,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 68e4e26..0ec9575 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -836,6 +836,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_log.Debug("[INVENTORY ACCESS MODULE]: Object has UUID.Zero! Position 3"); } + // if this was previously an attachment and is now being rezzed, + // save the old attachment info. + if (group.IsAttachment == false && group.RootPart.Shape.State != 0) + { + group.RootPart.AttachedPos = group.AbsolutePosition; + group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; + } + foreach (SceneObjectPart part in group.Parts) { // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 69b5f43..4bebbe8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2230,6 +2230,13 @@ namespace OpenSim.Region.Framework.Scenes sourcePart.Inventory.RemoveInventoryItem(item.ItemID); } + + if (group.IsAttachment == false && group.RootPart.Shape.State != 0) + { + group.RootPart.AttachedPos = group.AbsolutePosition; + group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; + } + group.FromPartID = sourcePart.UUID; AddNewSceneObject(group, true, pos, rot, vel); diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 945745e..3ea936c 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -365,6 +365,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound); m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume); m_SOPXmlProcessors.Add("MediaUrl", ProcessMediaUrl); + m_SOPXmlProcessors.Add("AttachedPos", ProcessAttachedPos); m_SOPXmlProcessors.Add("DynAttrs", ProcessDynAttrs); m_SOPXmlProcessors.Add("TextureAnimation", ProcessTextureAnimation); m_SOPXmlProcessors.Add("ParticleSystem", ProcessParticleSystem); @@ -433,6 +434,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_ShapeXmlProcessors.Add("ProfileEnd", ProcessShpProfileEnd); m_ShapeXmlProcessors.Add("ProfileHollow", ProcessShpProfileHollow); m_ShapeXmlProcessors.Add("Scale", ProcessShpScale); + m_ShapeXmlProcessors.Add("LastAttachPoint", ProcessShpLastAttach); m_ShapeXmlProcessors.Add("State", ProcessShpState); m_ShapeXmlProcessors.Add("ProfileShape", ProcessShpProfileShape); m_ShapeXmlProcessors.Add("HollowShape", ProcessShpHollowShape); @@ -761,6 +763,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.MediaUrl = reader.ReadElementContentAsString("MediaUrl", String.Empty); } + private static void ProcessAttachedPos(SceneObjectPart obj, XmlTextReader reader) + { + obj.AttachedPos = Util.ReadVector(reader, "AttachedPos"); + } + private static void ProcessDynAttrs(SceneObjectPart obj, XmlTextReader reader) { obj.DynAttrs.ReadXml(reader); @@ -1043,6 +1050,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization shp.State = (byte)reader.ReadElementContentAsInt("State", String.Empty); } + private static void ProcessShpLastAttach(PrimitiveBaseShape shp, XmlTextReader reader) + { + shp.LastAttachPoint = (byte)reader.ReadElementContentAsInt("LastAttachPoint", String.Empty); + } + private static void ProcessShpProfileShape(PrimitiveBaseShape shp, XmlTextReader reader) { shp.ProfileShape = Util.ReadEnum(reader, "ProfileShape"); @@ -1289,6 +1301,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); if (sop.MediaUrl != null) writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); + WriteVector(writer, "AttachedPos", sop.AttachedPos); if (sop.DynAttrs.CountNamespaces > 0) { @@ -1471,6 +1484,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("ProfileEnd", shp.ProfileEnd.ToString()); writer.WriteElementString("ProfileHollow", shp.ProfileHollow.ToString()); writer.WriteElementString("State", shp.State.ToString()); + writer.WriteElementString("LastAttachPoint", shp.LastAttachPoint.ToString()); WriteFlags(writer, "ProfileShape", shp.ProfileShape.ToString(), options); WriteFlags(writer, "HollowShape", shp.HollowShape.ToString(), options); -- cgit v1.1 From f384a6291e6b03b451dd3e3fec7667bc8f53c296 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Sep 2013 00:02:17 +0100 Subject: Instead of swallowing any socket begin/end receive exceptions, log them for debugging purposes. This may reveal why on some teleports with current code, the UseCircuitCode message gets through but CompleteMovement disappears into the ether. --- .../ClientStack/Linden/UDP/OpenSimUDPBase.cs | 39 ++++++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index d0ed7e8..88494be 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs @@ -295,7 +295,16 @@ namespace OpenMetaverse m_log.Warn("[UDPBASE]: Salvaged the UDP listener on port " + m_udpPort); } } - catch (ObjectDisposedException) { } + catch (ObjectDisposedException e) + { + m_log.Error( + string.Format("[UDPBASE]: Error processing UDP begin receive {0}. Exception ", UdpReceives), e); + } + catch (Exception e) + { + m_log.Error( + string.Format("[UDPBASE]: Error processing UDP begin receive {0}. Exception ", UdpReceives), e); + } } } @@ -312,12 +321,12 @@ namespace OpenMetaverse if (m_asyncPacketHandling) AsyncBeginReceive(); - // get the buffer that was created in AsyncBeginReceive - // this is the received data - UDPPacketBuffer buffer = (UDPPacketBuffer)iar.AsyncState; - try { + // get the buffer that was created in AsyncBeginReceive + // this is the received data + UDPPacketBuffer buffer = (UDPPacketBuffer)iar.AsyncState; + int startTick = Util.EnvironmentTickCount(); // get the length of data actually read from the socket, store it with the @@ -345,8 +354,24 @@ namespace OpenMetaverse m_currentReceiveTimeSamples++; } } - catch (SocketException) { } - catch (ObjectDisposedException) { } + catch (SocketException se) + { + m_log.Error( + string.Format( + "[UDPBASE]: Error processing UDP end receive {0}, socket error code {1}. Exception ", + UdpReceives, se.ErrorCode), + se); + } + catch (ObjectDisposedException e) + { + m_log.Error( + string.Format("[UDPBASE]: Error processing UDP end receive {0}. Exception ", UdpReceives), e); + } + catch (Exception e) + { + m_log.Error( + string.Format("[UDPBASE]: Error processing UDP end receive {0}. Exception ", UdpReceives), e); + } finally { // if (UsePools) -- cgit v1.1 From 732554be0451b9e7fa5f96ffb8f9f347b964dd88 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Sep 2013 18:29:14 +0100 Subject: Reinsert 200ms sleep accidentally removed in commit 7dbc93c (Wed Sep 18 21:41:51 2013 +0100) --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index b1752c1..a130ffe 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1722,9 +1722,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_log.DebugFormat( "[LLUDPSERVER]: Received a CompleteMovementIntoRegion from {0} in {1} but no client exists. Waiting.", endPoint, m_scene.Name); - - Thread.Sleep(200); } + + Thread.Sleep(200); } if (client == null) -- cgit v1.1 From 32ddfc274056e68bfd9e7e6d3e7921c8062a59d1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Sep 2013 18:45:56 +0100 Subject: Reinsert client.SceneAgent checks into LLUDPServer.HandleCompleteMovementIntoRegion() to fix race condition regression in commit 7dbc93c (Wed Sep 18 21:41:51 2013 +0100) This check is necessary to close a race condition where the CompleteAgentMovement processing could proceed when the UseCircuitCode thread had added the client to the client manager but before the ScenePresence had registered to process the CompleteAgentMovement message. This is most probably why the message appeared to get lost on a proportion of entity transfers. A better long term solution may be to set the IClientAPI.SceneAgent property before the client is added to the manager. --- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 37 +++++++++++++++------- OpenSim/Region/Framework/Scenes/Scene.cs | 3 ++ 2 files changed, 29 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index a130ffe..9504f15 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1692,6 +1692,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP endPoint = (IPEndPoint)array[0]; CompleteAgentMovementPacket packet = (CompleteAgentMovementPacket)array[1]; + m_log.DebugFormat( + "[LLUDPSERVER]: Handling CompleteAgentMovement request from {0} in {1}", endPoint, m_scene.Name); + // Determine which agent this packet came from // We need to wait here because in when using the OpenSimulator V2 teleport protocol to travel to a destination // simulator with no existing child presence, the viewer (at least LL 3.3.4) will send UseCircuitCode @@ -1703,24 +1706,36 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (m_scene.TryGetClient(endPoint, out client)) { - if (client.IsActive) - { - break; - } - else + if (!client.IsActive) { // This check exists to catch a condition where the client has been closed by another thread // but has not yet been removed from the client manager (and possibly a new connection has // not yet been established). m_log.DebugFormat( - "[LLUDPSERVER]: Received a CompleteMovementIntoRegion from {0} for {1} in {2} but client is not active. Waiting.", + "[LLUDPSERVER]: Received a CompleteAgentMovement from {0} for {1} in {2} but client is not active yet. Waiting.", + endPoint, client.Name, m_scene.Name); + } + else if (client.SceneAgent == null) + { + // This check exists to catch a condition where the new client has been added to the client + // manager but the SceneAgent has not yet been set in Scene.AddNewClient(). If we are too + // eager, then the new ScenePresence may not have registered a listener for this messsage + // before we try to process it. + // XXX: A better long term fix may be to add the SceneAgent before the client is added to + // the client manager + m_log.DebugFormat( + "[LLUDPSERVER]: Received a CompleteAgentMovement from {0} for {1} in {2} but client SceneAgent not set yet. Waiting.", endPoint, client.Name, m_scene.Name); } + else + { + break; + } } else { m_log.DebugFormat( - "[LLUDPSERVER]: Received a CompleteMovementIntoRegion from {0} in {1} but no client exists. Waiting.", + "[LLUDPSERVER]: Received a CompleteAgentMovement from {0} in {1} but no client exists yet. Waiting.", endPoint, m_scene.Name); } @@ -1730,19 +1745,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (client == null) { m_log.DebugFormat( - "[LLUDPSERVER]: No client found for CompleteMovementIntoRegion from {0} in {1} after wait. Dropping.", + "[LLUDPSERVER]: No client found for CompleteAgentMovement from {0} in {1} after wait. Dropping.", endPoint, m_scene.Name); return; } - else if (!client.IsActive) + else if (!client.IsActive || client.SceneAgent == null) { // This check exists to catch a condition where the client has been closed by another thread // but has not yet been removed from the client manager. // The packet could be simply ignored but it is useful to know if this condition occurred for other debugging // purposes. m_log.DebugFormat( - "[LLUDPSERVER]: Received a CompleteMovementIntoRegion from {0} for {1} in {2} but client is not active after wait. Dropping.", + "[LLUDPSERVER]: Received a CompleteAgentMovement from {0} for {1} in {2} but client is not active after wait. Dropping.", endPoint, client.Name, m_scene.Name); return; @@ -1767,7 +1782,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP catch (Exception e) { m_log.ErrorFormat( - "[LLUDPSERVER]: CompleteMovementIntoRegion handling from endpoint {0}, client {1} {2} failed. Exception {3}{4}", + "[LLUDPSERVER]: CompleteAgentMovement handling from endpoint {0}, client {1} {2} failed. Exception {3}{4}", endPoint != null ? endPoint.ToString() : "n/a", client != null ? client.Name : "unknown", client != null ? client.AgentId.ToString() : "unknown", diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index bc5a67f..3dc509b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2863,6 +2863,9 @@ namespace OpenSim.Region.Framework.Scenes // We must set this here so that TriggerOnNewClient and TriggerOnClientLogin can determine whether the // client is for a root or child agent. + // XXX: This may be better set for a new client before that client is added to the client manager. + // But need to know what happens in the case where a ScenePresence is already present (and if this + // actually occurs). client.SceneAgent = sp; // This is currently also being done earlier in NewUserConnection for real users to see if this -- cgit v1.1 From b22c92368f8991c174897306334c523bac8a4099 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Sep 2013 21:53:38 +0100 Subject: Move adding UUID.Zero -> Unknown User binding to UMM.Init() so that it's also called by HGUserManagementModule --- .../CoreModules/Framework/UserManagement/UserManagementModule.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 96eb63f..d3926cc 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -73,8 +73,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement Init(); m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); } - - AddUser(UUID.Zero, "Unknown", "User"); } public bool IsSharedModule @@ -645,6 +643,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement protected void Init() { + AddUser(UUID.Zero, "Unknown", "User"); RegisterConsoleCmds(); } -- cgit v1.1 From 4664090b34dfa2e944204fb7b616a19fcb3eeddf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Sep 2013 22:59:57 +0100 Subject: minor: correct spelling of Initialized in LSC connector version message --- .../ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 8ec943d..5c098a8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -94,7 +94,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation throw new Exception(string.Format("Invalid ConnectorProtocolVersion {0}", ServiceVersion)); m_log.InfoFormat( - "[LOCAL SIMULATION CONNECTOR]: Initialzied with connector protocol version {0}", ServiceVersion); + "[LOCAL SIMULATION CONNECTOR]: Initialized with connector protocol version {0}", ServiceVersion); } } -- cgit v1.1 From babfbe8d6d29380e42242008b6a743bc895ddb96 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Sep 2013 00:31:33 +0100 Subject: minor: log MaxOutgoingTransferVersion at EntityTransferModule startup --- .../CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index c1c8672..8ae81ac 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -185,6 +185,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer else { transferVersionName = rawVersionComponents[0]; + + m_log.InfoFormat( + "[ENTITY TRANSFER MODULE]: MaxOutgoingTransferVersion set to {0}", + string.Format("{0}/{1}", transferVersionName, maxTransferVersion)); } DisableInterRegionTeleportCancellation -- cgit v1.1 From 253f8de8cddfc195c2e54ef328ac0c4cb371d199 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Sep 2013 00:33:50 +0100 Subject: minor: Add scene name to baked textures in cache log message --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8d72e18..7243db1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2909,7 +2909,7 @@ namespace OpenSim.Region.Framework.Scenes // If we are using the the cached appearance then send it out to everyone if (cachedappearance) { - m_log.DebugFormat("[SCENE PRESENCE]: baked textures are in the cache for {0}", Name); + m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); // If the avatars baked textures are all in the cache, then we have a // complete appearance... send it out, if not, then we'll send it when -- cgit v1.1 From e24edada2435f942575a5a7acb4568fe6c0e4e30 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Sep 2013 00:39:32 +0100 Subject: minor: Comment out windlight log message about sending scene data for now. --- OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs index 89f3280..0a4e83e 100644 --- a/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs +++ b/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs @@ -207,7 +207,8 @@ namespace OpenSim.Region.CoreModules.World.LightShare private void EventManager_OnMakeRootAgent(ScenePresence presence) { - m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); +// m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client {0}", presence.Name); + SendProfileToClient(presence.ControllingClient); } -- cgit v1.1 From d6d82dbd3c9d081209914351ff3cc18c349e362b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Sep 2013 20:13:29 +0100 Subject: minor: correct attachment spelling mistake in log message in HGEntityTransferModule.OnIncomingSceneObject() --- .../CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 76dbc72..04a0db6 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) { string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); - m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachement {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachment {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); Dictionary ids = new Dictionary(); HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url); uuidGatherer.GatherAssetUuids(so, ids); -- cgit v1.1 From b704de9bf82782c3e8e5ebbdf88d8dfcb26c1750 Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 26 Sep 2013 16:27:11 -0700 Subject: minor code formatting for the sake of consistency and readability --- OpenSim/Region/Application/OpenSim.cs | 54 +++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 1cdd868..a7fe226 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -237,27 +237,33 @@ namespace OpenSim m_console.Commands.AddCommand("General", false, "change region", "change region ", - "Change current console region", ChangeSelectedRegion); + "Change current console region", + ChangeSelectedRegion); m_console.Commands.AddCommand("Archiving", false, "save xml", "save xml", - "Save a region's data in XML format", SaveXml); + "Save a region's data in XML format", + SaveXml); m_console.Commands.AddCommand("Archiving", false, "save xml2", "save xml2", - "Save a region's data in XML2 format", SaveXml2); + "Save a region's data in XML2 format", + SaveXml2); m_console.Commands.AddCommand("Archiving", false, "load xml", "load xml [-newIDs [ ]]", - "Load a region's data from XML format", LoadXml); + "Load a region's data from XML format", + LoadXml); m_console.Commands.AddCommand("Archiving", false, "load xml2", "load xml2", - "Load a region's data from XML2 format", LoadXml2); + "Load a region's data from XML2 format", + LoadXml2); m_console.Commands.AddCommand("Archiving", false, "save prims xml2", "save prims xml2 [ ]", - "Save named prim to XML2", SavePrimsXml2); + "Save named prim to XML2", + SavePrimsXml2); m_console.Commands.AddCommand("Archiving", false, "load oar", "load oar [--merge] [--skip-assets] []", @@ -287,7 +293,8 @@ namespace OpenSim m_console.Commands.AddCommand("Objects", false, "edit scale", "edit scale ", - "Change the scale of a named prim", HandleEditScale); + "Change the scale of a named prim", + HandleEditScale); m_console.Commands.AddCommand("Users", false, "kick user", "kick user [--force] [message]", @@ -305,31 +312,38 @@ namespace OpenSim m_console.Commands.AddCommand("Comms", false, "show connections", "show connections", - "Show connection data", HandleShow); + "Show connection data", + HandleShow); m_console.Commands.AddCommand("Comms", false, "show circuits", "show circuits", - "Show agent circuit data", HandleShow); + "Show agent circuit data", + HandleShow); m_console.Commands.AddCommand("Comms", false, "show pending-objects", "show pending-objects", - "Show # of objects on the pending queues of all scene viewers", HandleShow); + "Show # of objects on the pending queues of all scene viewers", + HandleShow); m_console.Commands.AddCommand("General", false, "show modules", "show modules", - "Show module data", HandleShow); + "Show module data", + HandleShow); m_console.Commands.AddCommand("Regions", false, "show regions", "show regions", - "Show region data", HandleShow); + "Show region data", + HandleShow); m_console.Commands.AddCommand("Regions", false, "show ratings", "show ratings", - "Show rating data", HandleShow); + "Show rating data", + HandleShow); m_console.Commands.AddCommand("Objects", false, "backup", "backup", - "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.", RunCommand); + "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.", + RunCommand); m_console.Commands.AddCommand("Regions", false, "create region", "create region [\"region name\"] ", @@ -342,19 +356,23 @@ namespace OpenSim m_console.Commands.AddCommand("Regions", false, "restart", "restart", - "Restart all sims in this instance", RunCommand); + "Restart all sims in this instance", + RunCommand); m_console.Commands.AddCommand("General", false, "command-script", "command-script