diff options
Diffstat (limited to 'OpenSim/Region/Physics')
5 files changed, 73 insertions, 39 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 306928a..601c78c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | |||
@@ -220,7 +220,7 @@ public static class BSParam | |||
220 | (s) => { return BSParam.NumericBool(ShouldUseHullsForPhysicalObjects); }, | 220 | (s) => { return BSParam.NumericBool(ShouldUseHullsForPhysicalObjects); }, |
221 | (s,p,l,v) => { ShouldUseHullsForPhysicalObjects = BSParam.BoolNumeric(v); } ), | 221 | (s,p,l,v) => { ShouldUseHullsForPhysicalObjects = BSParam.BoolNumeric(v); } ), |
222 | new ParameterDefn("ShouldRemoveZeroWidthTriangles", "If true, remove degenerate triangles from meshes", | 222 | new ParameterDefn("ShouldRemoveZeroWidthTriangles", "If true, remove degenerate triangles from meshes", |
223 | ConfigurationParameters.numericFalse, | 223 | ConfigurationParameters.numericTrue, |
224 | (s,cf,p,v) => { ShouldRemoveZeroWidthTriangles = cf.GetBoolean(p, BSParam.BoolNumeric(v)); }, | 224 | (s,cf,p,v) => { ShouldRemoveZeroWidthTriangles = cf.GetBoolean(p, BSParam.BoolNumeric(v)); }, |
225 | (s) => { return BSParam.NumericBool(ShouldRemoveZeroWidthTriangles); }, | 225 | (s) => { return BSParam.NumericBool(ShouldRemoveZeroWidthTriangles); }, |
226 | (s,p,l,v) => { ShouldRemoveZeroWidthTriangles = BSParam.BoolNumeric(v); } ), | 226 | (s,p,l,v) => { ShouldRemoveZeroWidthTriangles = BSParam.BoolNumeric(v); } ), |
@@ -641,24 +641,6 @@ public static class BSParam | |||
641 | return (b == ConfigurationParameters.numericTrue ? true : false); | 641 | return (b == ConfigurationParameters.numericTrue ? true : false); |
642 | } | 642 | } |
643 | 643 | ||
644 | private static void ResetBroadphasePoolTainted(BSScene pPhysScene, float v) | ||
645 | { | ||
646 | BSScene physScene = pPhysScene; | ||
647 | physScene.TaintedObject("BSParam.ResetBroadphasePoolTainted", delegate() | ||
648 | { | ||
649 | physScene.PE.ResetBroadphasePool(physScene.World); | ||
650 | }); | ||
651 | } | ||
652 | |||
653 | private static void ResetConstraintSolverTainted(BSScene pPhysScene, float v) | ||
654 | { | ||
655 | BSScene physScene = pPhysScene; | ||
656 | physScene.TaintedObject("BSParam.ResetConstraintSolver", delegate() | ||
657 | { | ||
658 | physScene.PE.ResetConstraintSolver(physScene.World); | ||
659 | }); | ||
660 | } | ||
661 | |||
662 | // Search through the parameter definitions and return the matching | 644 | // Search through the parameter definitions and return the matching |
663 | // ParameterDefn structure. | 645 | // ParameterDefn structure. |
664 | // Case does not matter as names are compared after converting to lower case. | 646 | // Case does not matter as names are compared after converting to lower case. |
@@ -722,6 +704,22 @@ public static class BSParam | |||
722 | } | 704 | } |
723 | } | 705 | } |
724 | 706 | ||
707 | private static void ResetBroadphasePoolTainted(BSScene pPhysScene, float v) | ||
708 | { | ||
709 | BSScene physScene = pPhysScene; | ||
710 | physScene.TaintedObject("BSParam.ResetBroadphasePoolTainted", delegate() | ||
711 | { | ||
712 | physScene.PE.ResetBroadphasePool(physScene.World); | ||
713 | }); | ||
714 | } | ||
725 | 715 | ||
716 | private static void ResetConstraintSolverTainted(BSScene pPhysScene, float v) | ||
717 | { | ||
718 | BSScene physScene = pPhysScene; | ||
719 | physScene.TaintedObject("BSParam.ResetConstraintSolver", delegate() | ||
720 | { | ||
721 | physScene.PE.ResetConstraintSolver(physScene.World); | ||
722 | }); | ||
723 | } | ||
726 | } | 724 | } |
727 | } | 725 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 823402b..ec25aa9 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -75,6 +75,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
75 | PhysicsScene = parentScene; | 75 | PhysicsScene = parentScene; |
76 | LocalID = localID; | 76 | LocalID = localID; |
77 | PhysObjectName = name; | 77 | PhysObjectName = name; |
78 | Name = name; // PhysicsActor also has the name of the object. Someday consolidate. | ||
78 | TypeName = typeName; | 79 | TypeName = typeName; |
79 | 80 | ||
80 | // We don't have any physical representation yet. | 81 | // We don't have any physical representation yet. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 6cd72f2..f8a0c1e 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -876,14 +876,39 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
876 | // will use the next time since it's pinned and shared memory. | 876 | // will use the next time since it's pinned and shared memory. |
877 | // Some of the values require calling into the physics engine to get the new | 877 | // Some of the values require calling into the physics engine to get the new |
878 | // value activated ('terrainFriction' for instance). | 878 | // value activated ('terrainFriction' for instance). |
879 | public bool SetPhysicsParameter(string parm, float val, uint localID) | 879 | public bool SetPhysicsParameter(string parm, string val, uint localID) |
880 | { | 880 | { |
881 | bool ret = false; | 881 | bool ret = false; |
882 | |||
883 | float valf = 0f; | ||
884 | if (val.ToLower() == "true") | ||
885 | { | ||
886 | valf = PhysParameterEntry.NUMERIC_TRUE; | ||
887 | } | ||
888 | else | ||
889 | { | ||
890 | if (val.ToLower() == "false") | ||
891 | { | ||
892 | valf = PhysParameterEntry.NUMERIC_FALSE; | ||
893 | } | ||
894 | else | ||
895 | { | ||
896 | try | ||
897 | { | ||
898 | valf = float.Parse(val); | ||
899 | } | ||
900 | catch | ||
901 | { | ||
902 | valf = 0f; | ||
903 | } | ||
904 | } | ||
905 | } | ||
906 | |||
882 | BSParam.ParameterDefn theParam; | 907 | BSParam.ParameterDefn theParam; |
883 | if (BSParam.TryGetParameter(parm, out theParam)) | 908 | if (BSParam.TryGetParameter(parm, out theParam)) |
884 | { | 909 | { |
885 | // Set the value in the C# code | 910 | // Set the value in the C# code |
886 | theParam.setter(this, parm, localID, val); | 911 | theParam.setter(this, parm, localID, valf); |
887 | 912 | ||
888 | // Optionally set the parameter in the unmanaged code | 913 | // Optionally set the parameter in the unmanaged code |
889 | if (theParam.onObject != null) | 914 | if (theParam.onObject != null) |
@@ -898,16 +923,16 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
898 | case PhysParameterEntry.APPLY_TO_NONE: | 923 | case PhysParameterEntry.APPLY_TO_NONE: |
899 | // This will cause a call into the physical world if some operation is specified (SetOnObject). | 924 | // This will cause a call into the physical world if some operation is specified (SetOnObject). |
900 | objectIDs.Add(TERRAIN_ID); | 925 | objectIDs.Add(TERRAIN_ID); |
901 | TaintedUpdateParameter(parm, objectIDs, val); | 926 | TaintedUpdateParameter(parm, objectIDs, valf); |
902 | break; | 927 | break; |
903 | case PhysParameterEntry.APPLY_TO_ALL: | 928 | case PhysParameterEntry.APPLY_TO_ALL: |
904 | lock (PhysObjects) objectIDs = new List<uint>(PhysObjects.Keys); | 929 | lock (PhysObjects) objectIDs = new List<uint>(PhysObjects.Keys); |
905 | TaintedUpdateParameter(parm, objectIDs, val); | 930 | TaintedUpdateParameter(parm, objectIDs, valf); |
906 | break; | 931 | break; |
907 | default: | 932 | default: |
908 | // setting only one localID | 933 | // setting only one localID |
909 | objectIDs.Add(localID); | 934 | objectIDs.Add(localID); |
910 | TaintedUpdateParameter(parm, objectIDs, val); | 935 | TaintedUpdateParameter(parm, objectIDs, valf); |
911 | break; | 936 | break; |
912 | } | 937 | } |
913 | } | 938 | } |
@@ -942,14 +967,14 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
942 | 967 | ||
943 | // Get parameter. | 968 | // Get parameter. |
944 | // Return 'false' if not able to get the parameter. | 969 | // Return 'false' if not able to get the parameter. |
945 | public bool GetPhysicsParameter(string parm, out float value) | 970 | public bool GetPhysicsParameter(string parm, out string value) |
946 | { | 971 | { |
947 | float val = 0f; | 972 | string val = String.Empty; |
948 | bool ret = false; | 973 | bool ret = false; |
949 | BSParam.ParameterDefn theParam; | 974 | BSParam.ParameterDefn theParam; |
950 | if (BSParam.TryGetParameter(parm, out theParam)) | 975 | if (BSParam.TryGetParameter(parm, out theParam)) |
951 | { | 976 | { |
952 | val = theParam.getter(this); | 977 | val = theParam.getter(this).ToString(); |
953 | ret = true; | 978 | ret = true; |
954 | } | 979 | } |
955 | value = val; | 980 | value = val; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index fe0f984..15747c9 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -608,7 +608,7 @@ public sealed class BSShapeCollection : IDisposable | |||
608 | // Since we're recreating new, get rid of the reference to the previous shape | 608 | // Since we're recreating new, get rid of the reference to the previous shape |
609 | DereferenceShape(prim.PhysShape, shapeCallback); | 609 | DereferenceShape(prim.PhysShape, shapeCallback); |
610 | 610 | ||
611 | newShape = CreatePhysicalMesh(prim.PhysObjectName, newMeshKey, prim.BaseShape, prim.Size, lod); | 611 | newShape = CreatePhysicalMesh(prim, newMeshKey, prim.BaseShape, prim.Size, lod); |
612 | // Take evasive action if the mesh was not constructed. | 612 | // Take evasive action if the mesh was not constructed. |
613 | newShape = VerifyMeshCreated(newShape, prim); | 613 | newShape = VerifyMeshCreated(newShape, prim); |
614 | 614 | ||
@@ -619,7 +619,7 @@ public sealed class BSShapeCollection : IDisposable | |||
619 | return true; // 'true' means a new shape has been added to this prim | 619 | return true; // 'true' means a new shape has been added to this prim |
620 | } | 620 | } |
621 | 621 | ||
622 | private BulletShape CreatePhysicalMesh(string objName, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) | 622 | private BulletShape CreatePhysicalMesh(BSPhysObject prim, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) |
623 | { | 623 | { |
624 | BulletShape newShape = new BulletShape(); | 624 | BulletShape newShape = new BulletShape(); |
625 | 625 | ||
@@ -631,7 +631,7 @@ public sealed class BSShapeCollection : IDisposable | |||
631 | } | 631 | } |
632 | else | 632 | else |
633 | { | 633 | { |
634 | IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, | 634 | IMesh meshData = PhysicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, |
635 | false, // say it is not physical so a bounding box is not built | 635 | false, // say it is not physical so a bounding box is not built |
636 | false // do not cache the mesh and do not use previously built versions | 636 | false // do not cache the mesh and do not use previously built versions |
637 | ); | 637 | ); |
@@ -651,18 +651,20 @@ public sealed class BSShapeCollection : IDisposable | |||
651 | realIndicesIndex = 0; | 651 | realIndicesIndex = 0; |
652 | for (int tri = 0; tri < indices.Length; tri += 3) | 652 | for (int tri = 0; tri < indices.Length; tri += 3) |
653 | { | 653 | { |
654 | // Compute displacements into vertex array for each vertex of the triangle | ||
654 | int v1 = indices[tri + 0] * 3; | 655 | int v1 = indices[tri + 0] * 3; |
655 | int v2 = indices[tri + 1] * 3; | 656 | int v2 = indices[tri + 1] * 3; |
656 | int v3 = indices[tri + 2] * 3; | 657 | int v3 = indices[tri + 2] * 3; |
657 | if (!((verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0] | 658 | // Check to see if any two of the vertices are the same |
659 | if (!( ( verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0] | ||
658 | && verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1] | 660 | && verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1] |
659 | && verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2]) | 661 | && verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2]) |
660 | || (verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0] | 662 | || ( verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0] |
661 | && verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1] | 663 | && verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1] |
662 | && verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2]) | 664 | && verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2]) |
663 | || (verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0] | 665 | || ( verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0] |
664 | && verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1] | 666 | && verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1] |
665 | && verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2])) | 667 | && verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2]) ) |
666 | ) | 668 | ) |
667 | { | 669 | { |
668 | // None of the vertices of the triangles are the same. This is a good triangle; | 670 | // None of the vertices of the triangles are the same. This is a good triangle; |
@@ -676,8 +678,16 @@ public sealed class BSShapeCollection : IDisposable | |||
676 | DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}", | 678 | DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}", |
677 | BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3); | 679 | BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3); |
678 | 680 | ||
679 | newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, | 681 | if (realIndicesIndex != 0) |
680 | realIndicesIndex, indices, verticesAsFloats.Length/3, verticesAsFloats); | 682 | { |
683 | newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, | ||
684 | realIndicesIndex, indices, verticesAsFloats.Length / 3, verticesAsFloats); | ||
685 | } | ||
686 | else | ||
687 | { | ||
688 | PhysicsScene.Logger.ErrorFormat("{0} All mesh triangles degenerate. Prim {1} at {2} in {3}", | ||
689 | LogHeader, prim.PhysObjectName, prim.RawPosition, PhysicsScene.Name); | ||
690 | } | ||
681 | } | 691 | } |
682 | } | 692 | } |
683 | newShape.shapeKey = newMeshKey; | 693 | newShape.shapeKey = newMeshKey; |
diff --git a/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs b/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs index b8676ba..31a397c 100755 --- a/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs +++ b/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs | |||
@@ -60,14 +60,14 @@ namespace OpenSim.Region.Physics.Manager | |||
60 | 60 | ||
61 | // Set parameter on a specific or all instances. | 61 | // Set parameter on a specific or all instances. |
62 | // Return 'false' if not able to set the parameter. | 62 | // Return 'false' if not able to set the parameter. |
63 | bool SetPhysicsParameter(string parm, float value, uint localID); | 63 | bool SetPhysicsParameter(string parm, string value, uint localID); |
64 | 64 | ||
65 | // Get parameter. | 65 | // Get parameter. |
66 | // Return 'false' if not able to get the parameter. | 66 | // Return 'false' if not able to get the parameter. |
67 | bool GetPhysicsParameter(string parm, out float value); | 67 | bool GetPhysicsParameter(string parm, out string value); |
68 | 68 | ||
69 | // Get parameter from a particular object | 69 | // Get parameter from a particular object |
70 | // TODO: | 70 | // TODO: |
71 | // bool GetPhysicsParameter(string parm, out float value, uint localID); | 71 | // bool GetPhysicsParameter(string parm, out string value, uint localID); |
72 | } | 72 | } |
73 | } | 73 | } |