diff options
Merge branch 'master' into newmultiattach
Conflicts:
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
Diffstat (limited to '')
5 files changed, 140 insertions, 40 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index f442ca2..e208d3a 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -205,7 +205,7 @@ public sealed class BSCharacter : BSPhysObject | |||
205 | // errors can creap in and the avatar will slowly float off in some direction. | 205 | // errors can creap in and the avatar will slowly float off in some direction. |
206 | // So, the problem is that, when an avatar is standing, we cannot tell creaping error | 206 | // So, the problem is that, when an avatar is standing, we cannot tell creaping error |
207 | // from real pushing. | 207 | // from real pushing. |
208 | // The code below keeps setting the velocity to zero hoping the world will keep pushing. | 208 | // The code below uses whether the collider is static or moving to decide whether to zero motion. |
209 | 209 | ||
210 | _velocityMotor.Step(timeStep); | 210 | _velocityMotor.Step(timeStep); |
211 | 211 | ||
@@ -244,6 +244,7 @@ public sealed class BSCharacter : BSPhysObject | |||
244 | } | 244 | } |
245 | else | 245 | else |
246 | { | 246 | { |
247 | // Supposed to be moving. | ||
247 | OMV.Vector3 stepVelocity = _velocityMotor.CurrentValue; | 248 | OMV.Vector3 stepVelocity = _velocityMotor.CurrentValue; |
248 | 249 | ||
249 | if (Friction != BSParam.AvatarFriction) | 250 | if (Friction != BSParam.AvatarFriction) |
@@ -276,8 +277,8 @@ public sealed class BSCharacter : BSPhysObject | |||
276 | }); | 277 | }); |
277 | } | 278 | } |
278 | 279 | ||
279 | // Decide of the character is colliding with a low object and compute a force to pop the | 280 | // Decide if the character is colliding with a low object and compute a force to pop the |
280 | // avatar up so it has a chance of walking up and over the low object. | 281 | // avatar up so it can walk up and over the low objects. |
281 | private OMV.Vector3 WalkUpStairs() | 282 | private OMV.Vector3 WalkUpStairs() |
282 | { | 283 | { |
283 | OMV.Vector3 ret = OMV.Vector3.Zero; | 284 | OMV.Vector3 ret = OMV.Vector3.Zero; |
@@ -476,17 +477,19 @@ public sealed class BSCharacter : BSPhysObject | |||
476 | if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition)) | 477 | if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition)) |
477 | { | 478 | { |
478 | // The character is out of the known/simulated area. | 479 | // The character is out of the known/simulated area. |
479 | // Upper levels of code will handle the transition to other areas so, for | 480 | // Force the avatar position to be within known. ScenePresence will use the position |
480 | // the time, we just ignore the position. | 481 | // plus the velocity to decide if the avatar is moving out of the region. |
481 | return ret; | 482 | RawPosition = PhysicsScene.TerrainManager.ClampPositionIntoKnownTerrain(RawPosition); |
483 | DetailLog("{0},BSCharacter.PositionSanityCheck,notWithinKnownTerrain,clampedPos={1}", LocalID, RawPosition); | ||
484 | return true; | ||
482 | } | 485 | } |
483 | 486 | ||
484 | // If below the ground, move the avatar up | 487 | // If below the ground, move the avatar up |
485 | float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); | 488 | float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); |
486 | if (Position.Z < terrainHeight) | 489 | if (Position.Z < terrainHeight) |
487 | { | 490 | { |
488 | DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight); | 491 | DetailLog("{0},BSCharacter.PositionSanityCheck,adjustForUnderGround,pos={1},terrain={2}", LocalID, _position, terrainHeight); |
489 | _position.Z = terrainHeight + 2.0f; | 492 | _position.Z = terrainHeight + BSParam.AvatarBelowGroundUpCorrectionMeters; |
490 | ret = true; | 493 | ret = true; |
491 | } | 494 | } |
492 | if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) | 495 | if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) |
@@ -806,14 +809,7 @@ public sealed class BSCharacter : BSPhysObject | |||
806 | private void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { | 809 | private void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { |
807 | if (force.IsFinite()) | 810 | if (force.IsFinite()) |
808 | { | 811 | { |
809 | float magnitude = force.Length(); | 812 | OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); |
810 | if (magnitude > BSParam.MaxAddForceMagnitude) | ||
811 | { | ||
812 | // Force has a limit | ||
813 | force = force / magnitude * BSParam.MaxAddForceMagnitude; | ||
814 | } | ||
815 | |||
816 | OMV.Vector3 addForce = force; | ||
817 | // DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce); | 813 | // DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce); |
818 | 814 | ||
819 | PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate() | 815 | PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate() |
@@ -902,6 +898,7 @@ public sealed class BSCharacter : BSPhysObject | |||
902 | // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. | 898 | // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. |
903 | if (PositionSanityCheck(true)) | 899 | if (PositionSanityCheck(true)) |
904 | { | 900 | { |
901 | DetailLog("{0},BSCharacter.UpdateProperties,updatePosForSanity,pos={1}", LocalID, _position); | ||
905 | entprop.Position = _position; | 902 | entprop.Position = _position; |
906 | } | 903 | } |
907 | 904 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 235cefc..38596fa 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -143,7 +143,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
143 | { | 143 | { |
144 | enableAngularVerticalAttraction = true; | 144 | enableAngularVerticalAttraction = true; |
145 | enableAngularDeflection = false; | 145 | enableAngularDeflection = false; |
146 | enableAngularBanking = false; | 146 | enableAngularBanking = true; |
147 | if (BSParam.VehicleDebuggingEnabled) | 147 | if (BSParam.VehicleDebuggingEnabled) |
148 | { | 148 | { |
149 | enableAngularVerticalAttraction = true; | 149 | enableAngularVerticalAttraction = true; |
@@ -1280,11 +1280,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1280 | // That is, NO_DEFLECTION_UP says angular motion should not add any pitch or roll movement | 1280 | // That is, NO_DEFLECTION_UP says angular motion should not add any pitch or roll movement |
1281 | // TODO: This is here because this is where ODE put it but documentation says it | 1281 | // TODO: This is here because this is where ODE put it but documentation says it |
1282 | // is a linear effect. Where should this check go? | 1282 | // is a linear effect. Where should this check go? |
1283 | if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0) | 1283 | //if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0) |
1284 | { | 1284 | // { |
1285 | angularMotorContributionV.X = 0f; | 1285 | // angularMotorContributionV.X = 0f; |
1286 | angularMotorContributionV.Y = 0f; | 1286 | // angularMotorContributionV.Y = 0f; |
1287 | } | 1287 | // } |
1288 | 1288 | ||
1289 | VehicleRotationalVelocity += angularMotorContributionV * VehicleOrientation; | 1289 | VehicleRotationalVelocity += angularMotorContributionV * VehicleOrientation; |
1290 | VDetailLog("{0}, MoveAngular,angularTurning,angularMotorContrib={1}", Prim.LocalID, angularMotorContributionV); | 1290 | VDetailLog("{0}, MoveAngular,angularTurning,angularMotorContrib={1}", Prim.LocalID, angularMotorContributionV); |
@@ -1335,7 +1335,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1335 | Vector3 unscaledContribVerticalErrorV = vertContributionV; // DEBUG DEBUG | 1335 | Vector3 unscaledContribVerticalErrorV = vertContributionV; // DEBUG DEBUG |
1336 | vertContributionV /= m_verticalAttractionTimescale; | 1336 | vertContributionV /= m_verticalAttractionTimescale; |
1337 | 1337 | ||
1338 | VehicleRotationalVelocity += vertContributionV * VehicleOrientation; | 1338 | VehicleRotationalVelocity += vertContributionV; |
1339 | 1339 | ||
1340 | VDetailLog("{0}, MoveAngular,verticalAttraction,,origRotVW={1},vertError={2},unscaledV={3},eff={4},ts={5},vertContribV={6}", | 1340 | VDetailLog("{0}, MoveAngular,verticalAttraction,,origRotVW={1},vertError={2},unscaledV={3},eff={4},ts={5},vertContribV={6}", |
1341 | Prim.LocalID, origRotVelW, verticalError, unscaledContribVerticalErrorV, | 1341 | Prim.LocalID, origRotVelW, verticalError, unscaledContribVerticalErrorV, |
@@ -1437,24 +1437,25 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1437 | // As the vehicle rolls to the right or left, the Y value will increase from | 1437 | // As the vehicle rolls to the right or left, the Y value will increase from |
1438 | // zero (straight up) to 1 or -1 (full tilt right or left) | 1438 | // zero (straight up) to 1 or -1 (full tilt right or left) |
1439 | Vector3 rollComponents = Vector3.UnitZ * VehicleOrientation; | 1439 | Vector3 rollComponents = Vector3.UnitZ * VehicleOrientation; |
1440 | |||
1441 | // Figure out the yaw value for this much roll. | ||
1442 | // Squared because that seems to give a good value | ||
1443 | float yawAngle = (float)Math.Asin(rollComponents.Y * rollComponents.Y) * m_bankingEfficiency; | ||
1444 | 1440 | ||
1441 | // Figure out the yaw value for this much roll. | ||
1442 | float yawAngle = m_angularMotorDirection.X * m_bankingEfficiency; | ||
1445 | // actual error = static turn error + dynamic turn error | 1443 | // actual error = static turn error + dynamic turn error |
1446 | float mixedYawAngle = yawAngle * (1f - m_bankingMix) + yawAngle * m_bankingMix * VehicleForwardSpeed; | 1444 | float mixedYawAngle =(yawAngle * (1f - m_bankingMix)) + ((yawAngle * m_bankingMix) * VehicleForwardSpeed); |
1447 | 1445 | ||
1448 | // TODO: the banking effect should not go to infinity but what to limit it to? | 1446 | // TODO: the banking effect should not go to infinity but what to limit it to? |
1449 | mixedYawAngle = ClampInRange(-20f, mixedYawAngle, 20f); | 1447 | // And what should happen when this is being added to a user defined yaw that is already PI*4? |
1448 | mixedYawAngle = ClampInRange(-12, mixedYawAngle, 12); | ||
1450 | 1449 | ||
1451 | // Build the force vector to change rotation from what it is to what it should be | 1450 | // Build the force vector to change rotation from what it is to what it should be |
1452 | bankingContributionV.Z = -mixedYawAngle; | 1451 | bankingContributionV.Z = -mixedYawAngle; |
1453 | 1452 | ||
1454 | // Don't do it all at once. | 1453 | // Don't do it all at once. Fudge because 1 second is too fast with most user defined roll as PI*4. |
1455 | bankingContributionV /= m_bankingTimescale; | 1454 | bankingContributionV /= m_bankingTimescale * BSParam.VehicleAngularBankingTimescaleFudge; |
1456 | 1455 | ||
1457 | VehicleRotationalVelocity += bankingContributionV * VehicleOrientation; | 1456 | //VehicleRotationalVelocity += bankingContributionV * VehicleOrientation; |
1457 | VehicleRotationalVelocity += bankingContributionV; | ||
1458 | |||
1458 | 1459 | ||
1459 | VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}", | 1460 | VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}", |
1460 | Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContributionV); | 1461 | Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContributionV); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index fa58109..77bdacb 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | |||
@@ -107,6 +107,7 @@ public static class BSParam | |||
107 | public static float AvatarCapsuleDepth { get; private set; } | 107 | public static float AvatarCapsuleDepth { get; private set; } |
108 | public static float AvatarCapsuleHeight { get; private set; } | 108 | public static float AvatarCapsuleHeight { get; private set; } |
109 | public static float AvatarContactProcessingThreshold { get; private set; } | 109 | public static float AvatarContactProcessingThreshold { get; private set; } |
110 | public static float AvatarBelowGroundUpCorrectionMeters { get; private set; } | ||
110 | public static float AvatarStepHeight { get; private set; } | 111 | public static float AvatarStepHeight { get; private set; } |
111 | public static float AvatarStepApproachFactor { get; private set; } | 112 | public static float AvatarStepApproachFactor { get; private set; } |
112 | public static float AvatarStepForceFactor { get; private set; } | 113 | public static float AvatarStepForceFactor { get; private set; } |
@@ -122,6 +123,7 @@ public static class BSParam | |||
122 | public static Vector3 VehicleLinearFactor { get; private set; } | 123 | public static Vector3 VehicleLinearFactor { get; private set; } |
123 | public static Vector3 VehicleAngularFactor { get; private set; } | 124 | public static Vector3 VehicleAngularFactor { get; private set; } |
124 | public static float VehicleGroundGravityFudge { get; private set; } | 125 | public static float VehicleGroundGravityFudge { get; private set; } |
126 | public static float VehicleAngularBankingTimescaleFudge { get; private set; } | ||
125 | public static bool VehicleDebuggingEnabled { get; private set; } | 127 | public static bool VehicleDebuggingEnabled { get; private set; } |
126 | 128 | ||
127 | // Linkset implementation parameters | 129 | // Linkset implementation parameters |
@@ -497,6 +499,10 @@ public static class BSParam | |||
497 | 0.1f, | 499 | 0.1f, |
498 | (s) => { return AvatarContactProcessingThreshold; }, | 500 | (s) => { return AvatarContactProcessingThreshold; }, |
499 | (s,v) => { AvatarContactProcessingThreshold = v; } ), | 501 | (s,v) => { AvatarContactProcessingThreshold = v; } ), |
502 | new ParameterDefn<float>("AvatarBelowGroundUpCorrectionMeters", "Meters to move avatar up if it seems to be below ground", | ||
503 | 1.0f, | ||
504 | (s) => { return AvatarBelowGroundUpCorrectionMeters; }, | ||
505 | (s,v) => { AvatarBelowGroundUpCorrectionMeters = v; } ), | ||
500 | new ParameterDefn<float>("AvatarStepHeight", "Height of a step obstacle to consider step correction", | 506 | new ParameterDefn<float>("AvatarStepHeight", "Height of a step obstacle to consider step correction", |
501 | 0.3f, | 507 | 0.3f, |
502 | (s) => { return AvatarStepHeight; }, | 508 | (s) => { return AvatarStepHeight; }, |
@@ -538,10 +544,14 @@ public static class BSParam | |||
538 | 0.0f, | 544 | 0.0f, |
539 | (s) => { return VehicleRestitution; }, | 545 | (s) => { return VehicleRestitution; }, |
540 | (s,v) => { VehicleRestitution = v; } ), | 546 | (s,v) => { VehicleRestitution = v; } ), |
541 | new ParameterDefn<float>("VehicleGroundGravityFudge", "Factor to multiple gravity if a ground vehicle is probably on the ground (0.0 - 1.0)", | 547 | new ParameterDefn<float>("VehicleGroundGravityFudge", "Factor to multiply gravity if a ground vehicle is probably on the ground (0.0 - 1.0)", |
542 | 0.2f, | 548 | 0.2f, |
543 | (s) => { return VehicleGroundGravityFudge; }, | 549 | (s) => { return VehicleGroundGravityFudge; }, |
544 | (s,v) => { VehicleGroundGravityFudge = v; } ), | 550 | (s,v) => { VehicleGroundGravityFudge = v; } ), |
551 | new ParameterDefn<float>("VehicleAngularBankingTimescaleFudge", "Factor to multiple angular banking timescale. Tune to increase realism.", | ||
552 | 60.0f, | ||
553 | (s) => { return VehicleAngularBankingTimescaleFudge; }, | ||
554 | (s,v) => { VehicleAngularBankingTimescaleFudge = v; } ), | ||
545 | new ParameterDefn<bool>("VehicleDebuggingEnable", "Turn on/off vehicle debugging", | 555 | new ParameterDefn<bool>("VehicleDebuggingEnable", "Turn on/off vehicle debugging", |
546 | false, | 556 | false, |
547 | (s) => { return VehicleDebuggingEnabled; }, | 557 | (s) => { return VehicleDebuggingEnabled; }, |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index 2e9db39..e8040d8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -337,6 +337,54 @@ public sealed class BSTerrainManager : IDisposable | |||
337 | return GetTerrainPhysicalAtXYZ(pos, out physTerrain, out terrainBaseXYZ); | 337 | return GetTerrainPhysicalAtXYZ(pos, out physTerrain, out terrainBaseXYZ); |
338 | } | 338 | } |
339 | 339 | ||
340 | // Return a new position that is over known terrain if the position is outside our terrain. | ||
341 | public Vector3 ClampPositionIntoKnownTerrain(Vector3 pPos) | ||
342 | { | ||
343 | Vector3 ret = pPos; | ||
344 | |||
345 | // Can't do this function if we don't know about any terrain. | ||
346 | if (m_terrains.Count == 0) | ||
347 | return ret; | ||
348 | |||
349 | int loopPrevention = 5; | ||
350 | Vector3 terrainBaseXYZ; | ||
351 | BSTerrainPhys physTerrain; | ||
352 | while (!GetTerrainPhysicalAtXYZ(ret, out physTerrain, out terrainBaseXYZ)) | ||
353 | { | ||
354 | // The passed position is not within a known terrain area. | ||
355 | |||
356 | // First, base addresses are never negative so correct for that possible problem. | ||
357 | if (ret.X < 0f || ret.Y < 0f) | ||
358 | { | ||
359 | if (ret.X < 0f) | ||
360 | ret.X = 0f; | ||
361 | if (ret.Y < 0f) | ||
362 | ret.Y = 0f; | ||
363 | DetailLog("{0},BSTerrainManager.ClampPositionToKnownTerrain,zeroingNegXorY,oldPos={1},newPos={2}", | ||
364 | BSScene.DetailLogZero, pPos, ret); | ||
365 | } | ||
366 | else | ||
367 | { | ||
368 | // Must be off the top of a region. Find an adjacent region to move into. | ||
369 | Vector3 adjacentTerrainBase = FindAdjacentTerrainBase(terrainBaseXYZ); | ||
370 | |||
371 | ret.X = Math.Min(ret.X, adjacentTerrainBase.X + DefaultRegionSize.X); | ||
372 | ret.Y = Math.Min(ret.Y, adjacentTerrainBase.Y + DefaultRegionSize.Y); | ||
373 | DetailLog("{0},BSTerrainManager.ClampPositionToKnownTerrain,findingAdjacentRegion,adjacentRegBase={1},oldPos={2},newPos={3}", | ||
374 | BSScene.DetailLogZero, adjacentTerrainBase, pPos, ret); | ||
375 | } | ||
376 | if (loopPrevention-- < 0f) | ||
377 | { | ||
378 | // The 'while' is a little dangerous so this prevents looping forever if the | ||
379 | // mapping of the terrains ever gets messed up (like nothing at <0,0>) or | ||
380 | // the list of terrains is in transition. | ||
381 | DetailLog("{0},BSTerrainManager.ClampPositionToKnownTerrain,suppressingFindAdjacentRegionLoop", BSScene.DetailLogZero); | ||
382 | break; | ||
383 | } | ||
384 | } | ||
385 | return ret; | ||
386 | } | ||
387 | |||
340 | // Given an X and Y, find the height of the terrain. | 388 | // Given an X and Y, find the height of the terrain. |
341 | // Since we could be handling multiple terrains for a mega-region, | 389 | // Since we could be handling multiple terrains for a mega-region, |
342 | // the base of the region is calcuated assuming all regions are | 390 | // the base of the region is calcuated assuming all regions are |
@@ -400,18 +448,60 @@ public sealed class BSTerrainManager : IDisposable | |||
400 | // the descriptor class and the 'base' fo the addresses therein. | 448 | // the descriptor class and the 'base' fo the addresses therein. |
401 | private bool GetTerrainPhysicalAtXYZ(Vector3 pos, out BSTerrainPhys outPhysTerrain, out Vector3 outTerrainBase) | 449 | private bool GetTerrainPhysicalAtXYZ(Vector3 pos, out BSTerrainPhys outPhysTerrain, out Vector3 outTerrainBase) |
402 | { | 450 | { |
403 | int offsetX = ((int)(pos.X / (int)DefaultRegionSize.X)) * (int)DefaultRegionSize.X; | 451 | bool ret = false; |
404 | int offsetY = ((int)(pos.Y / (int)DefaultRegionSize.Y)) * (int)DefaultRegionSize.Y; | 452 | |
405 | Vector3 terrainBaseXYZ = new Vector3(offsetX, offsetY, 0f); | 453 | Vector3 terrainBaseXYZ = Vector3.Zero; |
454 | if (pos.X < 0f || pos.Y < 0f) | ||
455 | { | ||
456 | // We don't handle negative addresses so just make up a base that will not be found. | ||
457 | terrainBaseXYZ = new Vector3(-DefaultRegionSize.X, -DefaultRegionSize.Y, 0f); | ||
458 | } | ||
459 | else | ||
460 | { | ||
461 | int offsetX = ((int)(pos.X / (int)DefaultRegionSize.X)) * (int)DefaultRegionSize.X; | ||
462 | int offsetY = ((int)(pos.Y / (int)DefaultRegionSize.Y)) * (int)DefaultRegionSize.Y; | ||
463 | terrainBaseXYZ = new Vector3(offsetX, offsetY, 0f); | ||
464 | } | ||
406 | 465 | ||
407 | BSTerrainPhys physTerrain = null; | 466 | BSTerrainPhys physTerrain = null; |
408 | lock (m_terrains) | 467 | lock (m_terrains) |
409 | { | 468 | { |
410 | m_terrains.TryGetValue(terrainBaseXYZ, out physTerrain); | 469 | ret = m_terrains.TryGetValue(terrainBaseXYZ, out physTerrain); |
411 | } | 470 | } |
412 | outTerrainBase = terrainBaseXYZ; | 471 | outTerrainBase = terrainBaseXYZ; |
413 | outPhysTerrain = physTerrain; | 472 | outPhysTerrain = physTerrain; |
414 | return (physTerrain != null); | 473 | return ret; |
474 | } | ||
475 | |||
476 | // Given a terrain base, return a terrain base for a terrain that is closer to <0,0> than | ||
477 | // this one. Usually used to return an out of bounds object to a known place. | ||
478 | private Vector3 FindAdjacentTerrainBase(Vector3 pTerrainBase) | ||
479 | { | ||
480 | Vector3 ret = pTerrainBase; | ||
481 | ret.Z = 0f; | ||
482 | lock (m_terrains) | ||
483 | { | ||
484 | // Once down to the <0,0> region, we have to be done. | ||
485 | while (ret.X > 0f && ret.Y > 0f) | ||
486 | { | ||
487 | if (ret.X > 0f) | ||
488 | { | ||
489 | ret.X = Math.Max(0f, ret.X - DefaultRegionSize.X); | ||
490 | DetailLog("{0},BSTerrainManager.FindAdjacentTerrainBase,reducingX,terrainBase={1}", BSScene.DetailLogZero, ret); | ||
491 | if (m_terrains.ContainsKey(ret)) | ||
492 | break; | ||
493 | } | ||
494 | if (ret.Y > 0f) | ||
495 | { | ||
496 | ret.Y = Math.Max(0f, ret.Y - DefaultRegionSize.Y); | ||
497 | DetailLog("{0},BSTerrainManager.FindAdjacentTerrainBase,reducingY,terrainBase={1}", BSScene.DetailLogZero, ret); | ||
498 | if (m_terrains.ContainsKey(ret)) | ||
499 | break; | ||
500 | } | ||
501 | } | ||
502 | } | ||
503 | |||
504 | return ret; | ||
415 | } | 505 | } |
416 | 506 | ||
417 | // Although no one seems to check this, I do support combining. | 507 | // Although no one seems to check this, I do support combining. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs index d7e800d..57a5ff2 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs | |||
@@ -215,7 +215,8 @@ public sealed class BSTerrainMesh : BSTerrainPhys | |||
215 | 215 | ||
216 | float magX = (float)sizeX / extentX; | 216 | float magX = (float)sizeX / extentX; |
217 | float magY = (float)sizeY / extentY; | 217 | float magY = (float)sizeY / extentY; |
218 | physicsScene.DetailLog("{0},BSTerrainMesh.ConvertHeightMapToMesh,totVert={1},totInd={2},extentBase={3},magX={4},magY={5}", | 218 | if (physicsScene != null) |
219 | physicsScene.DetailLog("{0},BSTerrainMesh.ConvertHeightMapToMesh,totVert={1},totInd={2},extentBase={3},magX={4},magY={5}", | ||
219 | BSScene.DetailLogZero, totalVertices, totalIndices, extentBase, magX, magY); | 220 | BSScene.DetailLogZero, totalVertices, totalIndices, extentBase, magX, magY); |
220 | float minHeight = float.MaxValue; | 221 | float minHeight = float.MaxValue; |
221 | // Note that sizeX+1 vertices are created since there is land between this and the next region. | 222 | // Note that sizeX+1 vertices are created since there is land between this and the next region. |
@@ -257,7 +258,8 @@ public sealed class BSTerrainMesh : BSTerrainPhys | |||
257 | } | 258 | } |
258 | catch (Exception e) | 259 | catch (Exception e) |
259 | { | 260 | { |
260 | physicsScene.Logger.ErrorFormat("{0} Failed conversion of heightmap to mesh. For={1}/{2}, e={3}", | 261 | if (physicsScene != null) |
262 | physicsScene.Logger.ErrorFormat("{0} Failed conversion of heightmap to mesh. For={1}/{2}, e={3}", | ||
261 | LogHeader, physicsScene.RegionName, extentBase, e); | 263 | LogHeader, physicsScene.RegionName, extentBase, e); |
262 | } | 264 | } |
263 | 265 | ||