BulletSim: fix crash caused by the creation of a linkset child that is under the terrain. Users can sure find some interesting corner conditions.
parent
d4e0e98c00
commit
a082ce9da7
|
@ -332,12 +332,12 @@ public sealed class BSPrim : BSPhysObject
|
||||||
|
|
||||||
float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position);
|
float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position);
|
||||||
OMV.Vector3 upForce = OMV.Vector3.Zero;
|
OMV.Vector3 upForce = OMV.Vector3.Zero;
|
||||||
if (Position.Z < terrainHeight)
|
if (RawPosition.Z < terrainHeight)
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight);
|
DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight);
|
||||||
float targetHeight = terrainHeight + (Size.Z / 2f);
|
float targetHeight = terrainHeight + (Size.Z / 2f);
|
||||||
// Upforce proportional to the distance away from the terrain. Correct the error in 1 sec.
|
// Upforce proportional to the distance away from the terrain. Correct the error in 1 sec.
|
||||||
upForce.Z = (terrainHeight - Position.Z) * 1f;
|
upForce.Z = (terrainHeight - RawPosition.Z) * 1f;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,10 +345,10 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
float waterHeight = PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(_position);
|
float waterHeight = PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(_position);
|
||||||
// TODO: a floating motor so object will bob in the water
|
// TODO: a floating motor so object will bob in the water
|
||||||
if (Math.Abs(Position.Z - waterHeight) > 0.1f)
|
if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f)
|
||||||
{
|
{
|
||||||
// Upforce proportional to the distance away from the water. Correct the error in 1 sec.
|
// Upforce proportional to the distance away from the water. Correct the error in 1 sec.
|
||||||
upForce.Z = (waterHeight - Position.Z) * 1f;
|
upForce.Z = (waterHeight - RawPosition.Z) * 1f;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue