From 8b5e2f2cd28510fc249bade0ca0d71e02b6b5f34 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 11 Oct 2013 13:29:43 -0700 Subject: BulletSim: Fix snap back from edge of region problem. Mantis 6794. --- OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index c4807c4..c016eed 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs @@ -354,6 +354,8 @@ public sealed class BSTerrainManager : IDisposable // Return a new position that is over known terrain if the position is outside our terrain. public Vector3 ClampPositionIntoKnownTerrain(Vector3 pPos) { + float edgeEpsilon = 0.1f; + Vector3 ret = pPos; // First, base addresses are never negative so correct for that possible problem. @@ -378,10 +380,19 @@ public sealed class BSTerrainManager : IDisposable // NOTE that GetTerrainPhysicalAtXYZ will set 'terrainBaseXYZ' to the base of the unfound region. // Must be off the top of a region. Find an adjacent region to move into. + // The returned terrain is always 'lower'. That is, closer to <0,0>. Vector3 adjacentTerrainBase = FindAdjacentTerrainBase(terrainBaseXYZ); - ret.X = Math.Min(ret.X, adjacentTerrainBase.X + (ret.X % DefaultRegionSize.X)); - ret.Y = Math.Min(ret.Y, adjacentTerrainBase.Y + (ret.X % DefaultRegionSize.Y)); + if (adjacentTerrainBase.X < terrainBaseXYZ.X) + { + // moving down into a new region in the X dimension. New position will be the max in the new base. + ret.X = adjacentTerrainBase.X + DefaultRegionSize.X - edgeEpsilon; + } + if (adjacentTerrainBase.Y < terrainBaseXYZ.Y) + { + // moving down into a new region in the X dimension. New position will be the max in the new base. + ret.Y = adjacentTerrainBase.Y + DefaultRegionSize.Y - edgeEpsilon; + } DetailLog("{0},BSTerrainManager.ClampPositionToKnownTerrain,findingAdjacentRegion,adjacentRegBase={1},oldPos={2},newPos={3}", BSScene.DetailLogZero, adjacentTerrainBase, pPos, ret); -- cgit v1.1 From 766a31431e41033b9cddf5759e9b6e1b4c77682a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 15 Oct 2013 17:02:22 -0700 Subject: BulletSim: implement the SL bug where VEHICLE_HOVER_UP_ONLY disables the vehicle buoyancy if the vehicle is above its hover height. This is a known misfeature of this vehicle flag which has been accepted since it would break too many implementations. The problem is noticed when creating a jetski-like vehicle that jumps over sand bars. A boat normally is configured with neutral buoyancy and hovering at water height. When it jumps the sandbar, it needs to have gravity applied to get back to water level. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index f0d17d3..7b98f9d 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1125,7 +1125,19 @@ namespace OpenSim.Region.Physics.BulletSPlugin { // If body is already heigher, use its height as target height if (VehiclePosition.Z > m_VhoverTargetHeight) + { m_VhoverTargetHeight = VehiclePosition.Z; + + // A 'misfeature' of this flag is that if the vehicle is above it's hover height, + // the vehicle's buoyancy goes away. This is an SL bug that got used by so many + // scripts that it could not be changed. + // So, if above the height, reapply gravity if buoyancy had it turned off. + if (m_VehicleBuoyancy != 0) + { + Vector3 appliedGravity = ControllingPrim.ComputeGravity(ControllingPrim.Buoyancy) * m_vehicleMass; + VehicleAddForce(appliedGravity); + } + } } if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) -- cgit v1.1