aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2012-12-03 16:25:51 -0800
committerRobert Adams2012-12-03 16:25:51 -0800
commit787636b97ac242c3a903664a2fe1f26ea8c0130a (patch)
treeaee245069b829730b85f2f56005a7da029596bd8 /OpenSim/Region
parentBulletSim: rework angular corrections to remove any hybrid code and compute a... (diff)
downloadopensim-SC-787636b97ac242c3a903664a2fe1f26ea8c0130a.zip
opensim-SC-787636b97ac242c3a903664a2fe1f26ea8c0130a.tar.gz
opensim-SC-787636b97ac242c3a903664a2fe1f26ea8c0130a.tar.bz2
opensim-SC-787636b97ac242c3a903664a2fe1f26ea8c0130a.tar.xz
BulletSim: Reduce idle region physics overhead where there are MANY
static objects by more restrictive selection of objects that collide with static objects. Rename collision mask fuctions from 'filter' to 'group' so it is clear what is being set. Rename BulletSimAPI.SetCollisionFilterMask() to SetCollisionGroupMask to match above. Restore passing of time step to linear and angular motion component routines. Use buffering vehicle physical parameter get/set routines consistantly. Make range enforcement clearer by using ClampInRange() function for parameter setting. Remove commented out experimental vehicle calculations.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs4
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs81
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs14
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs4
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs4
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs4
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs64
7 files changed, 95 insertions, 80 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 1dfc420..21aa9be 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -165,8 +165,8 @@ public sealed class BSCharacter : BSPhysObject
165 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr); 165 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr);
166 166
167 // Do this after the object has been added to the world 167 // Do this after the object has been added to the world
168 BulletSimAPI.SetCollisionFilterMask2(PhysBody.ptr, 168 BulletSimAPI.SetCollisionGroupMask2(PhysBody.ptr,
169 (uint)CollisionFilterGroups.AvatarFilter, 169 (uint)CollisionFilterGroups.AvatarGroup,
170 (uint)CollisionFilterGroups.AvatarMask); 170 (uint)CollisionFilterGroups.AvatarMask);
171 } 171 }
172 172
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 525aac4..be8a502 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -161,7 +161,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
161 m_angularMotor.TimeScale = m_angularMotorTimescale; 161 m_angularMotor.TimeScale = m_angularMotorTimescale;
162 break; 162 break;
163 case Vehicle.BANKING_EFFICIENCY: 163 case Vehicle.BANKING_EFFICIENCY:
164 m_bankingEfficiency = Math.Max(-1f, Math.Min(pValue, 1f)); 164 m_bankingEfficiency = ClampInRange(-1f, pValue, 1f);
165 break; 165 break;
166 case Vehicle.BANKING_MIX: 166 case Vehicle.BANKING_MIX:
167 m_bankingMix = Math.Max(pValue, 0.01f); 167 m_bankingMix = Math.Max(pValue, 0.01f);
@@ -170,10 +170,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
170 m_bankingTimescale = Math.Max(pValue, 0.01f); 170 m_bankingTimescale = Math.Max(pValue, 0.01f);
171 break; 171 break;
172 case Vehicle.BUOYANCY: 172 case Vehicle.BUOYANCY:
173 m_VehicleBuoyancy = Math.Max(-1f, Math.Min(pValue, 1f)); 173 m_VehicleBuoyancy = ClampInRange(-1f, pValue, 1f);
174 break; 174 break;
175 case Vehicle.HOVER_EFFICIENCY: 175 case Vehicle.HOVER_EFFICIENCY:
176 m_VhoverEfficiency = Math.Max(0f, Math.Min(pValue, 1f)); 176 m_VhoverEfficiency = ClampInRange(0f, pValue, 1f);
177 break; 177 break;
178 case Vehicle.HOVER_HEIGHT: 178 case Vehicle.HOVER_HEIGHT:
179 m_VhoverHeight = pValue; 179 m_VhoverHeight = pValue;
@@ -188,7 +188,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
188 m_linearDeflectionTimescale = Math.Max(pValue, 0.01f); 188 m_linearDeflectionTimescale = Math.Max(pValue, 0.01f);
189 break; 189 break;
190 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: 190 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
191 m_linearMotorDecayTimescale = Math.Max(0.01f, Math.Min(pValue,120)); 191 m_linearMotorDecayTimescale = ClampInRange(0.01f, pValue, 120);
192 m_linearMotor.TargetValueDecayTimeScale = m_linearMotorDecayTimescale; 192 m_linearMotor.TargetValueDecayTimeScale = m_linearMotorDecayTimescale;
193 break; 193 break;
194 case Vehicle.LINEAR_MOTOR_TIMESCALE: 194 case Vehicle.LINEAR_MOTOR_TIMESCALE:
@@ -196,7 +196,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
196 m_linearMotor.TimeScale = m_linearMotorTimescale; 196 m_linearMotor.TimeScale = m_linearMotorTimescale;
197 break; 197 break;
198 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: 198 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY:
199 m_verticalAttractionEfficiency = Math.Max(0.1f, Math.Min(pValue, 1f)); 199 m_verticalAttractionEfficiency = ClampInRange(0.1f, pValue, 1f);
200 m_verticalAttractionMotor.Efficiency = m_verticalAttractionEfficiency; 200 m_verticalAttractionMotor.Efficiency = m_verticalAttractionEfficiency;
201 break; 201 break;
202 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: 202 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE:
@@ -607,10 +607,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin
607 } 607 }
608 608
609 #region Known vehicle value functions 609 #region Known vehicle value functions
610 // Vehicle physical parameters that we buffer from constant getting and setting.
611 // The "m_known*" variables are initialized to 'null', fetched only if referenced
612 // and stored back into the physics engine only if updated.
613 // This does two things: 1) saves continuious calls into unmanaged code, and
614 // 2) signals when a physics property update must happen back to the simulator
615 // to update values modified for the vehicle.
610 private int m_knownChanged; 616 private int m_knownChanged;
611 private float? m_knownTerrainHeight; 617 private float? m_knownTerrainHeight;
612 private float? m_knownWaterLevel; 618 private float? m_knownWaterLevel;
613
614 private Vector3? m_knownPosition; 619 private Vector3? m_knownPosition;
615 private Vector3? m_knownVelocity; 620 private Vector3? m_knownVelocity;
616 private Quaternion? m_knownOrientation; 621 private Quaternion? m_knownOrientation;
@@ -642,7 +647,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
642 if ((m_knownChanged & m_knownChangedVelocity) != 0) 647 if ((m_knownChanged & m_knownChangedVelocity) != 0)
643 Prim.ForceVelocity = VehicleVelocity; 648 Prim.ForceVelocity = VehicleVelocity;
644 if ((m_knownChanged & m_knownChangedRotationalVelocity) != 0) 649 if ((m_knownChanged & m_knownChangedRotationalVelocity) != 0)
650 {
645 Prim.ForceRotationalVelocity = VehicleRotationalVelocity; 651 Prim.ForceRotationalVelocity = VehicleRotationalVelocity;
652 BulletSimAPI.SetInterpolationAngularVelocity2(Prim.PhysBody.ptr, VehicleRotationalVelocity);
653 }
646 // If we set one of the values (ie, the physics engine didn't do it) we must force 654 // If we set one of the values (ie, the physics engine didn't do it) we must force
647 // an UpdateProperties event to send the changes up to the simulator. 655 // an UpdateProperties event to send the changes up to the simulator.
648 BulletSimAPI.PushUpdate2(Prim.PhysBody.ptr); 656 BulletSimAPI.PushUpdate2(Prim.PhysBody.ptr);
@@ -766,15 +774,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
766 // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; 774 // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g;
767 Vector3 grav = Prim.PhysicsScene.DefaultGravity * (1f - m_VehicleBuoyancy); 775 Vector3 grav = Prim.PhysicsScene.DefaultGravity * (1f - m_VehicleBuoyancy);
768 776
769 Vector3 pos = VehiclePosition; 777 Vector3 terrainHeightContribution = ComputeLinearTerrainHeightCorrection(pTimestep);
770
771 Vector3 terrainHeightContribution = ComputeLinearTerrainHeightCorrection(ref pos);
772 778
773 Vector3 hoverContribution = ComputeLinearHover(ref pos); 779 Vector3 hoverContribution = ComputeLinearHover(pTimestep);
774 780
775 ComputeLinearBlockingEndPoint(ref pos); 781 ComputeLinearBlockingEndPoint(pTimestep);
776 782
777 Vector3 limitMotorUpContribution = ComputeLinearMotorUp(pos); 783 Vector3 limitMotorUpContribution = ComputeLinearMotorUp(pTimestep);
778 784
779 // ================================================================== 785 // ==================================================================
780 Vector3 newVelocity = linearMotorContribution 786 Vector3 newVelocity = linearMotorContribution
@@ -820,22 +826,21 @@ namespace OpenSim.Region.Physics.BulletSPlugin
820 826
821 } // end MoveLinear() 827 } // end MoveLinear()
822 828
823 public Vector3 ComputeLinearTerrainHeightCorrection(ref Vector3 pos) 829 public Vector3 ComputeLinearTerrainHeightCorrection(float pTimestep)
824 { 830 {
825 Vector3 ret = Vector3.Zero; 831 Vector3 ret = Vector3.Zero;
826 // If below the terrain, move us above the ground a little. 832 // If below the terrain, move us above the ground a little.
827 // TODO: Consider taking the rotated size of the object or possibly casting a ray. 833 // TODO: Consider taking the rotated size of the object or possibly casting a ray.
828 if (pos.Z < GetTerrainHeight(pos)) 834 if (VehiclePosition.Z < GetTerrainHeight(VehiclePosition))
829 { 835 {
830 // TODO: correct position by applying force rather than forcing position. 836 // TODO: correct position by applying force rather than forcing position.
831 pos.Z = GetTerrainHeight(pos) + 2; 837 VehiclePosition += new Vector3(0f, 0f, GetTerrainHeight(VehiclePosition) + 2f);
832 VehiclePosition = pos; 838 VDetailLog("{0}, MoveLinear,terrainHeight,terrainHeight={1},pos={2}", Prim.LocalID, GetTerrainHeight(VehiclePosition), VehiclePosition);
833 VDetailLog("{0}, MoveLinear,terrainHeight,terrainHeight={1},pos={2}", Prim.LocalID, GetTerrainHeight(pos), pos);
834 } 839 }
835 return ret; 840 return ret;
836 } 841 }
837 842
838 public Vector3 ComputeLinearHover(ref Vector3 pos) 843 public Vector3 ComputeLinearHover(float pTimestep)
839 { 844 {
840 Vector3 ret = Vector3.Zero; 845 Vector3 ret = Vector3.Zero;
841 846
@@ -846,11 +851,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
846 // We should hover, get the target height 851 // We should hover, get the target height
847 if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0) 852 if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0)
848 { 853 {
849 m_VhoverTargetHeight = GetWaterLevel(pos) + m_VhoverHeight; 854 m_VhoverTargetHeight = GetWaterLevel(VehiclePosition) + m_VhoverHeight;
850 } 855 }
851 if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) 856 if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0)
852 { 857 {
853 m_VhoverTargetHeight = GetTerrainHeight(pos) + m_VhoverHeight; 858 m_VhoverTargetHeight = GetTerrainHeight(VehiclePosition) + m_VhoverHeight;
854 } 859 }
855 if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0) 860 if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0)
856 { 861 {
@@ -860,14 +865,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin
860 if ((m_flags & VehicleFlag.HOVER_UP_ONLY) != 0) 865 if ((m_flags & VehicleFlag.HOVER_UP_ONLY) != 0)
861 { 866 {
862 // If body is already heigher, use its height as target height 867 // If body is already heigher, use its height as target height
863 if (pos.Z > m_VhoverTargetHeight) 868 if (VehiclePosition.Z > m_VhoverTargetHeight)
864 m_VhoverTargetHeight = pos.Z; 869 m_VhoverTargetHeight = VehiclePosition.Z;
865 } 870 }
866 871
867 if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) 872 if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0)
868 { 873 {
869 if (Math.Abs(pos.Z - m_VhoverTargetHeight) > 0.2f) 874 if (Math.Abs(VehiclePosition.Z - m_VhoverTargetHeight) > 0.2f)
870 { 875 {
876 Vector3 pos = VehiclePosition;
871 pos.Z = m_VhoverTargetHeight; 877 pos.Z = m_VhoverTargetHeight;
872 VehiclePosition = pos; 878 VehiclePosition = pos;
873 } 879 }
@@ -875,7 +881,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
875 else 881 else
876 { 882 {
877 // Error is positive if below the target and negative if above. 883 // Error is positive if below the target and negative if above.
878 float verticalError = m_VhoverTargetHeight - pos.Z; 884 float verticalError = m_VhoverTargetHeight - VehiclePosition.Z;
879 float verticalCorrectionVelocity = verticalError / m_VhoverTimescale; 885 float verticalCorrectionVelocity = verticalError / m_VhoverTimescale;
880 886
881 // TODO: implement m_VhoverEfficiency correctly 887 // TODO: implement m_VhoverEfficiency correctly
@@ -886,16 +892,17 @@ namespace OpenSim.Region.Physics.BulletSPlugin
886 } 892 }
887 893
888 VDetailLog("{0}, MoveLinear,hover,pos={1},ret={2},hoverTS={3},height={4},target={5}", 894 VDetailLog("{0}, MoveLinear,hover,pos={1},ret={2},hoverTS={3},height={4},target={5}",
889 Prim.LocalID, pos, ret, m_VhoverTimescale, m_VhoverHeight, m_VhoverTargetHeight); 895 Prim.LocalID, VehiclePosition, ret, m_VhoverTimescale, m_VhoverHeight, m_VhoverTargetHeight);
890 } 896 }
891 897
892 return ret; 898 return ret;
893 } 899 }
894 900
895 public bool ComputeLinearBlockingEndPoint(ref Vector3 pos) 901 public bool ComputeLinearBlockingEndPoint(float pTimestep)
896 { 902 {
897 bool changed = false; 903 bool changed = false;
898 904
905 Vector3 pos = VehiclePosition;
899 Vector3 posChange = pos - m_lastPositionVector; 906 Vector3 posChange = pos - m_lastPositionVector;
900 if (m_BlockingEndPoint != Vector3.Zero) 907 if (m_BlockingEndPoint != Vector3.Zero)
901 { 908 {
@@ -941,14 +948,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin
941 // VEHICLE_BANKING_TIMESCALE. This is to help prevent ground vehicles from steering 948 // VEHICLE_BANKING_TIMESCALE. This is to help prevent ground vehicles from steering
942 // when they are in mid jump. 949 // when they are in mid jump.
943 // TODO: this code is wrong. Also, what should it do for boats? 950 // TODO: this code is wrong. Also, what should it do for boats?
944 public Vector3 ComputeLinearMotorUp(Vector3 pos) 951 public Vector3 ComputeLinearMotorUp(float pTimestep)
945 { 952 {
946 Vector3 ret = Vector3.Zero; 953 Vector3 ret = Vector3.Zero;
947 if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) 954 if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0)
948 { 955 {
949 // If the vehicle is motoring into the sky, get it going back down. 956 // If the vehicle is motoring into the sky, get it going back down.
950 // float distanceAboveGround = pos.Z - Math.Max(GetTerrainHeight(pos), GetWaterLevel(pos)); 957 // float distanceAboveGround = pos.Z - Math.Max(GetTerrainHeight(pos), GetWaterLevel(pos));
951 float distanceAboveGround = pos.Z - GetTerrainHeight(pos); 958 float distanceAboveGround = VehiclePosition.Z - GetTerrainHeight(VehiclePosition);
952 if (distanceAboveGround > 1f) 959 if (distanceAboveGround > 1f)
953 { 960 {
954 // downForce = new Vector3(0, 0, (-distanceAboveGround / m_bankingTimescale) * pTimestep); 961 // downForce = new Vector3(0, 0, (-distanceAboveGround / m_bankingTimescale) * pTimestep);
@@ -969,12 +976,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
969 // ======================================================================= 976 // =======================================================================
970 // ======================================================================= 977 // =======================================================================
971 // Apply the effect of the angular motor. 978 // Apply the effect of the angular motor.
972 // The 'contribution' is how much angular correction each function wants. 979 // The 'contribution' is how much angular correction velocity each function wants.
973 // All the contributions are added together and the orientation of the vehicle 980 // All the contributions are added together and the orientation of the vehicle
974 // is changed by all the contributed corrections. 981 // is changed by all the contributed corrections.
975 private void MoveAngular(float pTimestep) 982 private void MoveAngular(float pTimestep)
976 { 983 {
977 Vector3 angularMotorContribution = m_angularMotor.Step(); 984 // The user wants how many radians per second angular change?
985 Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep);
978 986
979 // ================================================================== 987 // ==================================================================
980 // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags : 988 // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags :
@@ -1006,14 +1014,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1006 1014
1007 // ================================================================== 1015 // ==================================================================
1008 // The correction is applied to the current orientation. 1016 // The correction is applied to the current orientation.
1009 // Any angular velocity on the vehicle is not us so zero the current value.
1010 VehicleRotationalVelocity = Vector3.Zero;
1011 if (!m_lastAngularCorrection.ApproxEquals(Vector3.Zero, 0.01f)) 1017 if (!m_lastAngularCorrection.ApproxEquals(Vector3.Zero, 0.01f))
1012 { 1018 {
1013 Vector3 scaledCorrection = m_lastAngularCorrection * pTimestep; 1019 Vector3 scaledCorrection = m_lastAngularCorrection * pTimestep;
1014 Quaternion quatCorrection = Quaternion.CreateFromEulers(scaledCorrection);
1015 1020
1016 VehicleOrientation = Quaternion.Add(VehicleOrientation, quatCorrection); 1021 VehicleRotationalVelocity = scaledCorrection;
1017 1022
1018 VDetailLog("{0}, MoveAngular,done,nonZero,angMotorContrib={1},vertAttrContrib={2},bankContrib={3},deflectContrib={4},totalContrib={5},scaledCorr={6}", 1023 VDetailLog("{0}, MoveAngular,done,nonZero,angMotorContrib={1},vertAttrContrib={2},bankContrib={3},deflectContrib={4},totalContrib={5},scaledCorr={6}",
1019 Prim.LocalID, 1024 Prim.LocalID,
@@ -1022,6 +1027,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1022 m_lastAngularCorrection, scaledCorrection 1027 m_lastAngularCorrection, scaledCorrection
1023 ); 1028 );
1024 } 1029 }
1030 else
1031 {
1032 // The vehicle is not adding anything velocity wise.
1033 VehicleRotationalVelocity = Vector3.Zero;
1034 VDetailLog("{0}, MoveAngular,done,zero", Prim.LocalID);
1035 }
1025 1036
1026 // ================================================================== 1037 // ==================================================================
1027 //Offset section 1038 //Offset section
@@ -1065,7 +1076,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1065 { 1076 {
1066 // Take a vector pointing up and convert it from world to vehicle relative coords. 1077 // Take a vector pointing up and convert it from world to vehicle relative coords.
1067 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation; 1078 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation;
1068 // verticalError.Normalize(); 1079 verticalError.Normalize();
1069 1080
1070 // If vertical attraction correction is needed, the vector that was pointing up (UnitZ) 1081 // If vertical attraction correction is needed, the vector that was pointing up (UnitZ)
1071 // is now leaning to one side (rotated around the X axis) and the Y value will 1082 // is now leaning to one side (rotated around the X axis) and the Y value will
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 42a362f..ea1f71a 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -646,9 +646,13 @@ public sealed class BSPrim : BSPhysObject
646 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr); 646 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr);
647 647
648 // Collision filter can be set only when the object is in the world 648 // Collision filter can be set only when the object is in the world
649 if (PhysBody.collisionFilter != 0 || PhysBody.collisionMask != 0) 649 if (PhysBody.collisionGroup != 0 || PhysBody.collisionMask != 0)
650 { 650 {
651 BulletSimAPI.SetCollisionFilterMask2(PhysBody.ptr, (uint)PhysBody.collisionFilter, (uint)PhysBody.collisionMask); 651 if (!BulletSimAPI.SetCollisionGroupMask2(PhysBody.ptr, (uint)PhysBody.collisionGroup, (uint)PhysBody.collisionMask))
652 {
653 PhysicsScene.Logger.ErrorFormat("{0} Failure setting prim collision mask. localID={1}, grp={2:X}, mask={3:X}",
654 LogHeader, LocalID, PhysBody.collisionGroup, PhysBody.collisionMask);
655 }
652 } 656 }
653 657
654 // Recompute any linkset parameters. 658 // Recompute any linkset parameters.
@@ -691,7 +695,7 @@ public sealed class BSPrim : BSPhysObject
691 // Start it out sleeping and physical actions could wake it up. 695 // Start it out sleeping and physical actions could wake it up.
692 BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ISLAND_SLEEPING); 696 BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ISLAND_SLEEPING);
693 697
694 PhysBody.collisionFilter = CollisionFilterGroups.StaticObjectFilter; 698 PhysBody.collisionGroup = CollisionFilterGroups.StaticObjectGroup;
695 PhysBody.collisionMask = CollisionFilterGroups.StaticObjectMask; 699 PhysBody.collisionMask = CollisionFilterGroups.StaticObjectMask;
696 } 700 }
697 else 701 else
@@ -737,7 +741,7 @@ public sealed class BSPrim : BSPhysObject
737 BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ACTIVE_TAG); 741 BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ACTIVE_TAG);
738 // BulletSimAPI.Activate2(BSBody.ptr, true); 742 // BulletSimAPI.Activate2(BSBody.ptr, true);
739 743
740 PhysBody.collisionFilter = CollisionFilterGroups.ObjectFilter; 744 PhysBody.collisionGroup = CollisionFilterGroups.ObjectGroup;
741 PhysBody.collisionMask = CollisionFilterGroups.ObjectMask; 745 PhysBody.collisionMask = CollisionFilterGroups.ObjectMask;
742 } 746 }
743 } 747 }
@@ -765,7 +769,7 @@ public sealed class BSPrim : BSPhysObject
765 m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); 769 m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType);
766 } 770 }
767 CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); 771 CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
768 PhysBody.collisionFilter = CollisionFilterGroups.VolumeDetectFilter; 772 PhysBody.collisionGroup = CollisionFilterGroups.VolumeDetectGroup;
769 PhysBody.collisionMask = CollisionFilterGroups.VolumeDetectMask; 773 PhysBody.collisionMask = CollisionFilterGroups.VolumeDetectMask;
770 } 774 }
771 } 775 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
index 0cb151e..83b9c37 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
@@ -121,8 +121,8 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
121 // redo its bounding box now that it is in the world 121 // redo its bounding box now that it is in the world
122 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); 122 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
123 123
124 BulletSimAPI.SetCollisionFilterMask2(m_mapInfo.terrainBody.ptr, 124 BulletSimAPI.SetCollisionGroupMask2(m_mapInfo.terrainBody.ptr,
125 (uint)CollisionFilterGroups.TerrainFilter, 125 (uint)CollisionFilterGroups.TerrainGroup,
126 (uint)CollisionFilterGroups.TerrainMask); 126 (uint)CollisionFilterGroups.TerrainMask);
127 127
128 // Make it so the terrain will not move or be considered for movement. 128 // Make it so the terrain will not move or be considered for movement.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
index 17d9536..83df360 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
@@ -140,8 +140,8 @@ public sealed class BSTerrainManager
140 // Ground plane does not move 140 // Ground plane does not move
141 BulletSimAPI.ForceActivationState2(m_groundPlane.ptr, ActivationState.DISABLE_SIMULATION); 141 BulletSimAPI.ForceActivationState2(m_groundPlane.ptr, ActivationState.DISABLE_SIMULATION);
142 // Everything collides with the ground plane. 142 // Everything collides with the ground plane.
143 BulletSimAPI.SetCollisionFilterMask2(m_groundPlane.ptr, 143 BulletSimAPI.SetCollisionGroupMask2(m_groundPlane.ptr,
144 (uint)CollisionFilterGroups.GroundPlaneFilter, (uint)CollisionFilterGroups.GroundPlaneMask); 144 (uint)CollisionFilterGroups.GroundPlaneGroup, (uint)CollisionFilterGroups.GroundPlaneMask);
145 145
146 // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain. 146 // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain.
147 BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize); 147 BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
index 7e93ab4..6ce767d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
@@ -130,8 +130,8 @@ public sealed class BSTerrainMesh : BSTerrainPhys
130 // Redo its bounding box now that it is in the world 130 // Redo its bounding box now that it is in the world
131 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_terrainBody.ptr); 131 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_terrainBody.ptr);
132 132
133 BulletSimAPI.SetCollisionFilterMask2(m_terrainBody.ptr, 133 BulletSimAPI.SetCollisionGroupMask2(m_terrainBody.ptr,
134 (uint)CollisionFilterGroups.TerrainFilter, 134 (uint)CollisionFilterGroups.TerrainGroup,
135 (uint)CollisionFilterGroups.TerrainMask); 135 (uint)CollisionFilterGroups.TerrainMask);
136 136
137 // Make it so the terrain will not move or be considered for movement. 137 // Make it so the terrain will not move or be considered for movement.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 21bc6a3..a5acfd1 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -57,12 +57,12 @@ public struct BulletBody
57 { 57 {
58 ID = id; 58 ID = id;
59 ptr = xx; 59 ptr = xx;
60 collisionFilter = 0; 60 collisionGroup = 0;
61 collisionMask = 0; 61 collisionMask = 0;
62 } 62 }
63 public IntPtr ptr; 63 public IntPtr ptr;
64 public uint ID; 64 public uint ID;
65 public CollisionFilterGroups collisionFilter; 65 public CollisionFilterGroups collisionGroup;
66 public CollisionFilterGroups collisionMask; 66 public CollisionFilterGroups collisionMask;
67 public override string ToString() 67 public override string ToString()
68 { 68 {
@@ -71,10 +71,10 @@ public struct BulletBody
71 buff.Append(ID.ToString()); 71 buff.Append(ID.ToString());
72 buff.Append(",p="); 72 buff.Append(",p=");
73 buff.Append(ptr.ToString("X")); 73 buff.Append(ptr.ToString("X"));
74 if (collisionFilter != 0 || collisionMask != 0) 74 if (collisionGroup != 0 || collisionMask != 0)
75 { 75 {
76 buff.Append(",f="); 76 buff.Append(",g=");
77 buff.Append(collisionFilter.ToString("X")); 77 buff.Append(collisionGroup.ToString("X"));
78 buff.Append(",m="); 78 buff.Append(",m=");
79 buff.Append(collisionMask.ToString("X")); 79 buff.Append(collisionMask.ToString("X"));
80 } 80 }
@@ -376,36 +376,36 @@ public enum CollisionFilterGroups : uint
376 // Don't use the bit definitions!! Define the use in a 376 // Don't use the bit definitions!! Define the use in a
377 // filter/mask definition below. This way collision interactions 377 // filter/mask definition below. This way collision interactions
378 // are more easily debugged. 378 // are more easily debugged.
379 BNoneFilter = 0, 379 BNoneGroup = 0,
380 BDefaultFilter = 1 << 0, 380 BDefaultGroup = 1 << 0,
381 BStaticFilter = 1 << 1, 381 BStaticGroup = 1 << 1,
382 BKinematicFilter = 1 << 2, 382 BKinematicGroup = 1 << 2,
383 BDebrisFilter = 1 << 3, 383 BDebrisGroup = 1 << 3,
384 BSensorTrigger = 1 << 4, 384 BSensorTrigger = 1 << 4,
385 BCharacterFilter = 1 << 5, 385 BCharacterGroup = 1 << 5,
386 BAllFilter = 0xFFFFFFFF, 386 BAllGroup = 0xFFFFFFFF,
387 // Filter groups defined by BulletSim 387 // Filter groups defined by BulletSim
388 BGroundPlaneFilter = 1 << 10, 388 BGroundPlaneGroup = 1 << 10,
389 BTerrainFilter = 1 << 11, 389 BTerrainGroup = 1 << 11,
390 BRaycastFilter = 1 << 12, 390 BRaycastGroup = 1 << 12,
391 BSolidFilter = 1 << 13, 391 BSolidGroup = 1 << 13,
392 BLinksetFilter = 1 << 14, 392 BLinksetGroup = 1 << 14,
393 393
394 // The collsion filters and masked are defined in one place -- don't want them scattered 394 // The collsion filters and masked are defined in one place -- don't want them scattered
395 AvatarFilter = BCharacterFilter, 395 AvatarGroup = BCharacterGroup,
396 AvatarMask = BAllFilter, 396 AvatarMask = BAllGroup,
397 ObjectFilter = BSolidFilter, 397 ObjectGroup = BSolidGroup,
398 ObjectMask = BAllFilter, 398 ObjectMask = BAllGroup,
399 StaticObjectFilter = BStaticFilter, 399 StaticObjectGroup = BStaticGroup,
400 StaticObjectMask = BAllFilter & ~BStaticFilter, // static objects don't collide with each other 400 StaticObjectMask = AvatarGroup | ObjectGroup, // static things don't interact with much
401 LinksetFilter = BLinksetFilter, 401 LinksetGroup = BLinksetGroup,
402 LinksetMask = BAllFilter & ~BLinksetFilter, // linkset objects don't collide with each other 402 LinksetMask = BAllGroup & ~BLinksetGroup, // linkset objects don't collide with each other
403 VolumeDetectFilter = BSensorTrigger, 403 VolumeDetectGroup = BSensorTrigger,
404 VolumeDetectMask = ~BSensorTrigger, 404 VolumeDetectMask = ~BSensorTrigger,
405 TerrainFilter = BTerrainFilter, 405 TerrainGroup = BTerrainGroup,
406 TerrainMask = BAllFilter & ~BStaticFilter, // static objects on the ground don't collide 406 TerrainMask = BAllGroup & ~BStaticGroup, // static objects on the ground don't collide
407 GroundPlaneFilter = BGroundPlaneFilter, 407 GroundPlaneGroup = BGroundPlaneGroup,
408 GroundPlaneMask = BAllFilter 408 GroundPlaneMask = BAllGroup
409 409
410}; 410};
411 411
@@ -945,7 +945,7 @@ public static extern IntPtr GetConstraintRef2(IntPtr obj, int index);
945public static extern int GetNumConstraintRefs2(IntPtr obj); 945public static extern int GetNumConstraintRefs2(IntPtr obj);
946 946
947[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 947[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
948public static extern void SetCollisionFilterMask2(IntPtr body, uint filter, uint mask); 948public static extern bool SetCollisionGroupMask2(IntPtr body, uint filter, uint mask);
949 949
950// ===================================================================================== 950// =====================================================================================
951// btCollisionShape entries 951// btCollisionShape entries