Merge branch 'master' of /home/opensim/var/repo/opensim
commit
c5d333c16c
|
@ -71,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
|
|
||||||
#region Internal functions
|
#region Internal functions
|
||||||
|
|
||||||
public AssetMetadata FetchMetadata(string url, UUID assetID)
|
private AssetMetadata FetchMetadata(string url, UUID assetID)
|
||||||
{
|
{
|
||||||
if (!url.EndsWith("/") && !url.EndsWith("="))
|
if (!url.EndsWith("/") && !url.EndsWith("="))
|
||||||
url = url + "/";
|
url = url + "/";
|
||||||
|
@ -86,6 +86,27 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AssetBase FetchAsset(string url, UUID assetID)
|
||||||
|
{
|
||||||
|
// Test if it's already here
|
||||||
|
AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
|
||||||
|
if (asset == null)
|
||||||
|
{
|
||||||
|
if (!url.EndsWith("/") && !url.EndsWith("="))
|
||||||
|
url = url + "/";
|
||||||
|
|
||||||
|
asset = m_scene.AssetService.Get(url + assetID.ToString());
|
||||||
|
|
||||||
|
//if (asset != null)
|
||||||
|
// m_log.DebugFormat("[HG ASSET MAPPER]: Fetched asset {0} of type {1} from {2} ", assetID, asset.Metadata.Type, url);
|
||||||
|
//else
|
||||||
|
// m_log.DebugFormat("[HG ASSET MAPPER]: Unable to fetch asset {0} from {1} ", assetID, url);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return asset;
|
||||||
|
}
|
||||||
|
|
||||||
public bool PostAsset(string url, AssetBase asset)
|
public bool PostAsset(string url, AssetBase asset)
|
||||||
{
|
{
|
||||||
if (asset != null)
|
if (asset != null)
|
||||||
|
@ -228,11 +249,22 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
if (meta == null)
|
if (meta == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// The act of gathering UUIDs downloads the assets from the remote server
|
// The act of gathering UUIDs downloads some assets from the remote server
|
||||||
|
// but not all...
|
||||||
Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>();
|
Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>();
|
||||||
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL);
|
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL);
|
||||||
uuidGatherer.GatherAssetUuids(assetID, (AssetType)meta.Type, ids);
|
uuidGatherer.GatherAssetUuids(assetID, (AssetType)meta.Type, ids);
|
||||||
|
m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", ids.Count);
|
||||||
|
bool success = true;
|
||||||
|
foreach (UUID uuid in ids.Keys)
|
||||||
|
if (FetchAsset(userAssetURL, uuid) == null)
|
||||||
|
success = false;
|
||||||
|
|
||||||
|
// maybe all pieces got here...
|
||||||
|
if (!success)
|
||||||
|
m_log.DebugFormat("[HG ASSET MAPPER]: Problems getting item {0} from asset server {1}", assetID, userAssetURL);
|
||||||
|
else
|
||||||
|
m_log.DebugFormat("[HG ASSET MAPPER]: Successfully got item {0} from asset server {1}", assetID, userAssetURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -688,12 +688,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
itemCopy.SalePrice = item.SalePrice;
|
itemCopy.SalePrice = item.SalePrice;
|
||||||
itemCopy.SaleType = item.SaleType;
|
itemCopy.SaleType = item.SaleType;
|
||||||
|
|
||||||
if (AddInventoryItem(itemCopy))
|
|
||||||
{
|
|
||||||
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
|
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
|
||||||
if (invAccess != null)
|
if (invAccess != null)
|
||||||
invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
|
invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
|
||||||
}
|
AddInventoryItem(itemCopy);
|
||||||
|
|
||||||
if (!Permissions.BypassPermissions())
|
if (!Permissions.BypassPermissions())
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,7 +124,9 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSCharacter.destroy", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.destroy", delegate()
|
||||||
{
|
{
|
||||||
PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null);
|
PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null);
|
||||||
|
PhysBody.Clear();
|
||||||
PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null);
|
PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null);
|
||||||
|
PhysShape.Clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,9 +195,12 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass);
|
LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass);
|
||||||
|
|
||||||
PhysicsScene.TaintedObject("BSCharacter.setSize", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.setSize", delegate()
|
||||||
|
{
|
||||||
|
if (PhysShape.HasPhysicalShape)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
|
BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
|
||||||
UpdatePhysicalMassProperties(RawMass);
|
UpdatePhysicalMassProperties(RawMass);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -236,6 +241,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
// Zero some other properties directly into the physics engine
|
// Zero some other properties directly into the physics engine
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
|
||||||
{
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -244,11 +250,14 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
_rotationalVelocity = OMV.Vector3.Zero;
|
_rotationalVelocity = OMV.Vector3.Zero;
|
||||||
|
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
|
||||||
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
||||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
||||||
// The next also get rid of applied linear force but the linear velocity is untouched.
|
// The next also get rid of applied linear force but the linear velocity is untouched.
|
||||||
BulletSimAPI.ClearForces2(PhysBody.ptr);
|
BulletSimAPI.ClearForces2(PhysBody.ptr);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +282,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSCharacter.setPosition", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.setPosition", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -332,6 +342,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||||
});
|
});
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -359,6 +370,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSCharacter.SetForce", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.SetForce", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force);
|
DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -398,6 +410,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
if (_currentFriction != PhysicsScene.Params.avatarStandingFriction)
|
if (_currentFriction != PhysicsScene.Params.avatarStandingFriction)
|
||||||
{
|
{
|
||||||
_currentFriction = PhysicsScene.Params.avatarStandingFriction;
|
_currentFriction = PhysicsScene.Params.avatarStandingFriction;
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,6 +419,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
if (_currentFriction != PhysicsScene.Params.avatarFriction)
|
if (_currentFriction != PhysicsScene.Params.avatarFriction)
|
||||||
{
|
{
|
||||||
_currentFriction = PhysicsScene.Params.avatarFriction;
|
_currentFriction = PhysicsScene.Params.avatarFriction;
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,9 +456,12 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
_orientation = value;
|
_orientation = value;
|
||||||
// m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
|
// m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
|
||||||
PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate()
|
||||||
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
// _position = BulletSimAPI.GetPosition2(BSBody.ptr);
|
// _position = BulletSimAPI.GetPosition2(BSBody.ptr);
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -516,11 +533,14 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
set {
|
set {
|
||||||
_floatOnWater = value;
|
_floatOnWater = value;
|
||||||
PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate()
|
||||||
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
if (_floatOnWater)
|
if (_floatOnWater)
|
||||||
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||||
else
|
else
|
||||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,6 +573,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
||||||
// Buoyancy is faked by changing the gravity applied to the object
|
// Buoyancy is faked by changing the gravity applied to the object
|
||||||
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
|
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
|
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -599,6 +620,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force);
|
DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public abstract class BSConstraint : IDisposable
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
{
|
{
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
if (m_constraint.ptr != IntPtr.Zero)
|
if (m_constraint.HasPhysicalConstraint)
|
||||||
{
|
{
|
||||||
bool success = BulletSimAPI.DestroyConstraint2(m_world.ptr, m_constraint.ptr);
|
bool success = BulletSimAPI.DestroyConstraint2(m_world.ptr, m_constraint.ptr);
|
||||||
m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}",
|
m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}",
|
||||||
|
@ -65,7 +65,7 @@ public abstract class BSConstraint : IDisposable
|
||||||
m_body1.ID, m_body1.ptr.ToString("X"),
|
m_body1.ID, m_body1.ptr.ToString("X"),
|
||||||
m_body2.ID, m_body2.ptr.ToString("X"),
|
m_body2.ID, m_body2.ptr.ToString("X"),
|
||||||
success);
|
success);
|
||||||
m_constraint.ptr = System.IntPtr.Zero;
|
m_constraint.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public sealed class BSConstraint6Dof : BSConstraint
|
||||||
m_world = world;
|
m_world = world;
|
||||||
m_body1 = obj1;
|
m_body1 = obj1;
|
||||||
m_body2 = obj2;
|
m_body2 = obj2;
|
||||||
if (obj1.ptr == IntPtr.Zero || obj2.ptr == IntPtr.Zero)
|
if (!obj1.HasPhysicalBody || !obj2.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
world.physicsScene.DetailLog("{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
|
world.physicsScene.DetailLog("{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
|
||||||
BSScene.DetailLogZero, world.worldID,
|
BSScene.DetailLogZero, world.worldID,
|
||||||
|
@ -83,7 +83,7 @@ public sealed class BSConstraint6Dof : BSConstraint
|
||||||
world.physicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}",
|
world.physicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}",
|
||||||
BSScene.DetailLogZero, world.worldID, m_constraint.ptr.ToString("X"),
|
BSScene.DetailLogZero, world.worldID, m_constraint.ptr.ToString("X"),
|
||||||
obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X"));
|
obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X"));
|
||||||
if (m_constraint.ptr == IntPtr.Zero)
|
if (!m_constraint.HasPhysicalConstraint)
|
||||||
{
|
{
|
||||||
world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}",
|
world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}",
|
||||||
LogHeader, obj1.ID, obj2.ID);
|
LogHeader, obj1.ID, obj2.ID);
|
||||||
|
|
|
@ -570,8 +570,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia);
|
BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia);
|
||||||
BulletSimAPI.UpdateInertiaTensor2(Prim.PhysBody.ptr);
|
BulletSimAPI.UpdateInertiaTensor2(Prim.PhysBody.ptr);
|
||||||
|
|
||||||
VDetailLog("{0},BSDynamics.Refresh,frict={1},inert={2},aDamp={3}",
|
VDetailLog("{0},BSDynamics.Refresh,mass={1},frict={2},inert={3},aDamp={4}",
|
||||||
Prim.LocalID, friction, localInertia, angularDamping);
|
Prim.LocalID, m_vehicleMass, friction, localInertia, angularDamping);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -818,6 +818,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
+ hoverContribution
|
+ hoverContribution
|
||||||
+ limitMotorUpContribution;
|
+ limitMotorUpContribution;
|
||||||
|
|
||||||
|
Vector3 newForce = buoyancyContribution;
|
||||||
|
|
||||||
// If not changing some axis, reduce out velocity
|
// If not changing some axis, reduce out velocity
|
||||||
if ((m_flags & (VehicleFlag.NO_X)) != 0)
|
if ((m_flags & (VehicleFlag.NO_X)) != 0)
|
||||||
newVelocity.X = 0;
|
newVelocity.X = 0;
|
||||||
|
@ -845,7 +847,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
VehicleVelocity = newVelocity;
|
VehicleVelocity = newVelocity;
|
||||||
|
|
||||||
// Other linear forces are applied as forces.
|
// Other linear forces are applied as forces.
|
||||||
Vector3 totalDownForce = buoyancyContribution * m_vehicleMass;
|
Vector3 totalDownForce = newForce * m_vehicleMass;
|
||||||
if (!totalDownForce.ApproxEquals(Vector3.Zero, 0.01f))
|
if (!totalDownForce.ApproxEquals(Vector3.Zero, 0.01f))
|
||||||
{
|
{
|
||||||
VehicleAddForce(totalDownForce);
|
VehicleAddForce(totalDownForce);
|
||||||
|
@ -991,8 +993,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
|
|
||||||
if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0)
|
if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0)
|
||||||
{
|
{
|
||||||
// If the vehicle is motoring into the sky, get it going back down.
|
float targetHeight = Type == Vehicle.TYPE_BOAT ? GetWaterLevel(VehiclePosition) : GetTerrainHeight(VehiclePosition);
|
||||||
float distanceAboveGround = VehiclePosition.Z - GetTerrainHeight(VehiclePosition);
|
float distanceAboveGround = VehiclePosition.Z - targetHeight;
|
||||||
// Not colliding if the vehicle is off the ground
|
// Not colliding if the vehicle is off the ground
|
||||||
if (!Prim.IsColliding)
|
if (!Prim.IsColliding)
|
||||||
{
|
{
|
||||||
|
@ -1005,8 +1007,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
// has a decay factor. This says this force should
|
// has a decay factor. This says this force should
|
||||||
// be computed with a motor.
|
// be computed with a motor.
|
||||||
// TODO: add interaction with banking.
|
// TODO: add interaction with banking.
|
||||||
VDetailLog("{0}, MoveLinear,limitMotorUp,distAbove={1},downForce={2}",
|
VDetailLog("{0}, MoveLinear,limitMotorUp,distAbove={1},colliding={2},ret={3}",
|
||||||
Prim.LocalID, distanceAboveGround, ret);
|
Prim.LocalID, distanceAboveGround, Prim.IsColliding, ret);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1055,7 +1057,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
// TODO: Should this be applied as an angular force (torque)?
|
// TODO: Should this be applied as an angular force (torque)?
|
||||||
if (!m_lastAngularCorrection.ApproxEquals(Vector3.Zero, 0.01f))
|
if (!m_lastAngularCorrection.ApproxEquals(Vector3.Zero, 0.01f))
|
||||||
{
|
{
|
||||||
Vector3 scaledCorrection = m_lastAngularCorrection * pTimestep;
|
// DEBUG DEBUG DEBUG: optionally scale the angular velocity. Debugging SL vs ODE turning functions.
|
||||||
|
Vector3 scaledCorrection = m_lastAngularCorrection;
|
||||||
|
if (PhysicsScene.VehicleScaleAngularVelocityByTimestep)
|
||||||
|
scaledCorrection *= pTimestep;
|
||||||
VehicleRotationalVelocity = scaledCorrection;
|
VehicleRotationalVelocity = scaledCorrection;
|
||||||
|
|
||||||
VDetailLog("{0}, MoveAngular,done,nonZero,angMotorContrib={1},vertAttrContrib={2},bankContrib={3},deflectContrib={4},totalContrib={5},scaledCorr={6}",
|
VDetailLog("{0}, MoveAngular,done,nonZero,angMotorContrib={1},vertAttrContrib={2},bankContrib={3},deflectContrib={4},totalContrib={5},scaledCorr={6}",
|
||||||
|
|
|
@ -32,6 +32,14 @@ using OMV = OpenMetaverse;
|
||||||
|
|
||||||
namespace OpenSim.Region.Physics.BulletSPlugin
|
namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// A BSPrim can get individual information about its linkedness attached
|
||||||
|
// to it through an instance of a subclass of LinksetInfo.
|
||||||
|
// Each type of linkset will define the information needed for its type.
|
||||||
|
public abstract class BSLinksetInfo
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public abstract class BSLinkset
|
public abstract class BSLinkset
|
||||||
{
|
{
|
||||||
// private static string LogHeader = "[BULLETSIM LINKSET]";
|
// private static string LogHeader = "[BULLETSIM LINKSET]";
|
||||||
|
|
|
@ -32,6 +32,31 @@ using OMV = OpenMetaverse;
|
||||||
|
|
||||||
namespace OpenSim.Region.Physics.BulletSPlugin
|
namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// When a child is linked, the relationship position of the child to the parent
|
||||||
|
// is remembered so the child's world position can be recomputed when it is
|
||||||
|
// removed from the linkset.
|
||||||
|
sealed class BSLinksetCompoundInfo : BSLinksetInfo
|
||||||
|
{
|
||||||
|
public OMV.Vector3 OffsetPos;
|
||||||
|
public OMV.Quaternion OffsetRot;
|
||||||
|
public BSLinksetCompoundInfo(OMV.Vector3 p, OMV.Quaternion r)
|
||||||
|
{
|
||||||
|
OffsetPos = p;
|
||||||
|
OffsetRot = r;
|
||||||
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder buff = new StringBuilder();
|
||||||
|
buff.Append("<p=");
|
||||||
|
buff.Append(OffsetPos.ToString());
|
||||||
|
buff.Append(",r=");
|
||||||
|
buff.Append(OffsetRot.ToString());
|
||||||
|
buff.Append(">");
|
||||||
|
return buff.ToString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public sealed class BSLinksetCompound : BSLinkset
|
public sealed class BSLinksetCompound : BSLinkset
|
||||||
{
|
{
|
||||||
private static string LogHeader = "[BULLETSIM LINKSET COMPOUND]";
|
private static string LogHeader = "[BULLETSIM LINKSET COMPOUND]";
|
||||||
|
@ -44,6 +69,7 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
// For compound implimented linksets, if there are children, use compound shape for the root.
|
// For compound implimented linksets, if there are children, use compound shape for the root.
|
||||||
public override BSPhysicsShapeType PreferredPhysicalShape(BSPhysObject requestor)
|
public override BSPhysicsShapeType PreferredPhysicalShape(BSPhysObject requestor)
|
||||||
{
|
{
|
||||||
|
// Returning 'unknown' means we don't have a preference.
|
||||||
BSPhysicsShapeType ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
|
BSPhysicsShapeType ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
|
||||||
if (IsRoot(requestor) && HasAnyChildren)
|
if (IsRoot(requestor) && HasAnyChildren)
|
||||||
{
|
{
|
||||||
|
@ -63,10 +89,10 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
// InternalRefresh(requestor);
|
// InternalRefresh(requestor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Schedule a refresh to happen after all the other taint processing.
|
||||||
private void InternalRefresh(BSPhysObject requestor)
|
private void InternalRefresh(BSPhysObject requestor)
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSLinksetCompound.Refresh,schedulingRefresh,requestor={1}", LinksetRoot.LocalID, requestor.LocalID);
|
DetailLog("{0},BSLinksetCompound.Refresh,schedulingRefresh,requestor={1}", LinksetRoot.LocalID, requestor.LocalID);
|
||||||
// Queue to happen after all the other taint processing
|
|
||||||
PhysicsScene.PostTaintObject("BSLinksetCompound.Refresh", requestor.LocalID, delegate()
|
PhysicsScene.PostTaintObject("BSLinksetCompound.Refresh", requestor.LocalID, delegate()
|
||||||
{
|
{
|
||||||
if (IsRoot(requestor) && HasAnyChildren)
|
if (IsRoot(requestor) && HasAnyChildren)
|
||||||
|
@ -84,12 +110,19 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
DetailLog("{0},BSLinksetCompound.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child));
|
DetailLog("{0},BSLinksetCompound.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child));
|
||||||
if (!IsRoot(child))
|
if (IsRoot(child))
|
||||||
|
{
|
||||||
|
// The root is going dynamic. Make sure mass is properly set.
|
||||||
|
m_mass = ComputeLinksetMass();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// The origional prims are removed from the world as the shape of the root compound
|
// The origional prims are removed from the world as the shape of the root compound
|
||||||
// shape takes over.
|
// shape takes over.
|
||||||
BulletSimAPI.AddToCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
BulletSimAPI.AddToCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
||||||
BulletSimAPI.ForceActivationState2(child.PhysBody.ptr, ActivationState.DISABLE_SIMULATION);
|
BulletSimAPI.ForceActivationState2(child.PhysBody.ptr, ActivationState.DISABLE_SIMULATION);
|
||||||
|
// We don't want collisions from the old linkset children.
|
||||||
|
BulletSimAPI.RemoveFromCollisionFlags2(child.PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -108,7 +141,7 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
{
|
{
|
||||||
// The non-physical children can come back to life.
|
// The non-physical children can come back to life.
|
||||||
BulletSimAPI.RemoveFromCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
BulletSimAPI.RemoveFromCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
||||||
// Don't force activation so setting of DISABLE_SIMULATION can stay.
|
// Don't force activation so setting of DISABLE_SIMULATION can stay if used.
|
||||||
BulletSimAPI.Activate2(child.PhysBody.ptr, false);
|
BulletSimAPI.Activate2(child.PhysBody.ptr, false);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
@ -146,6 +179,10 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
|
|
||||||
if (!IsRoot(child))
|
if (!IsRoot(child))
|
||||||
{
|
{
|
||||||
|
// Because it is a convenient time, recompute child world position and rotation based on
|
||||||
|
// its position in the linkset.
|
||||||
|
RecomputeChildWorldPosition(child, true);
|
||||||
|
|
||||||
// Cause the current shape to be freed and the new one to be built.
|
// Cause the current shape to be freed and the new one to be built.
|
||||||
InternalRefresh(LinksetRoot);
|
InternalRefresh(LinksetRoot);
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -154,6 +191,42 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When the linkset is built, the child shape is added
|
||||||
|
// to the compound shape relative to the root shape. The linkset then moves around but
|
||||||
|
// this does not move the actual child prim. The child prim's location must be recomputed
|
||||||
|
// based on the location of the root shape.
|
||||||
|
private void RecomputeChildWorldPosition(BSPhysObject child, bool inTaintTime)
|
||||||
|
{
|
||||||
|
BSLinksetCompoundInfo lci = child.LinksetInfo as BSLinksetCompoundInfo;
|
||||||
|
if (lci != null)
|
||||||
|
{
|
||||||
|
if (inTaintTime)
|
||||||
|
{
|
||||||
|
OMV.Vector3 oldPos = child.RawPosition;
|
||||||
|
child.ForcePosition = LinksetRoot.RawPosition + lci.OffsetPos;
|
||||||
|
child.ForceOrientation = LinksetRoot.RawOrientation * lci.OffsetRot;
|
||||||
|
DetailLog("{0},BSLinksetCompound.RecomputeChildWorldPosition,oldPos={1},lci={2},newPos={3}",
|
||||||
|
child.LocalID, oldPos, lci, child.RawPosition);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TaintedObject is not used here so the raw position is set now and not at taint-time.
|
||||||
|
child.Position = LinksetRoot.RawPosition + lci.OffsetPos;
|
||||||
|
child.Orientation = LinksetRoot.RawOrientation * lci.OffsetRot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// This happens when children have been added to the linkset but the linkset
|
||||||
|
// has not been constructed yet. So like, at taint time, adding children to a linkset
|
||||||
|
// and then changing properties of the children (makePhysical, for instance)
|
||||||
|
// but the post-print action of actually rebuilding the linkset has not yet happened.
|
||||||
|
// PhysicsScene.Logger.WarnFormat("{0} Restoring linkset child position failed because of no relative position computed. ID={1}",
|
||||||
|
// LogHeader, child.LocalID);
|
||||||
|
DetailLog("{0},BSLinksetCompound.recomputeChildWorldPosition,noRelativePositonInfo", child.LocalID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true',
|
// Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true',
|
||||||
// this routine will restore the removed constraints.
|
// this routine will restore the removed constraints.
|
||||||
// Called at taint-time!!
|
// Called at taint-time!!
|
||||||
|
@ -192,6 +265,7 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
child.LocalID, child.PhysBody.ptr.ToString("X"));
|
child.LocalID, child.PhysBody.ptr.ToString("X"));
|
||||||
|
|
||||||
// Cause the child's body to be rebuilt and thus restored to normal operation
|
// Cause the child's body to be rebuilt and thus restored to normal operation
|
||||||
|
RecomputeChildWorldPosition(child, false);
|
||||||
child.ForceBodyShapeRebuild(false);
|
child.ForceBodyShapeRebuild(false);
|
||||||
|
|
||||||
if (!HasAnyChildren)
|
if (!HasAnyChildren)
|
||||||
|
@ -225,43 +299,58 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
ForEachMember(delegate(BSPhysObject cPrim)
|
ForEachMember(delegate(BSPhysObject cPrim)
|
||||||
{
|
{
|
||||||
if (!IsRoot(cPrim))
|
if (!IsRoot(cPrim))
|
||||||
|
{
|
||||||
|
// Compute the displacement of the child from the root of the linkset.
|
||||||
|
// This info is saved in the child prim so the relationship does not
|
||||||
|
// change over time and the new child position can be computed
|
||||||
|
// when the linkset is being disassembled (the linkset may have moved).
|
||||||
|
BSLinksetCompoundInfo lci = cPrim.LinksetInfo as BSLinksetCompoundInfo;
|
||||||
|
if (lci == null)
|
||||||
{
|
{
|
||||||
// Each child position and rotation is given relative to the root.
|
// Each child position and rotation is given relative to the root.
|
||||||
OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(LinksetRoot.RawOrientation);
|
OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(LinksetRoot.RawOrientation);
|
||||||
OMV.Vector3 displacementPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation;
|
OMV.Vector3 displacementPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation;
|
||||||
OMV.Quaternion displacementRot = cPrim.RawOrientation * invRootOrientation;
|
OMV.Quaternion displacementRot = cPrim.RawOrientation * invRootOrientation;
|
||||||
|
|
||||||
|
// Save relative position for recomputing child's world position after moving linkset.
|
||||||
|
lci = new BSLinksetCompoundInfo(displacementPos, displacementRot);
|
||||||
|
cPrim.LinksetInfo = lci;
|
||||||
|
DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,creatingRelPos,lci={1}", cPrim.LocalID, lci);
|
||||||
|
}
|
||||||
|
|
||||||
DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addMemberToShape,mID={1},mShape={2},dispPos={3},dispRot={4}",
|
DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addMemberToShape,mID={1},mShape={2},dispPos={3},dispRot={4}",
|
||||||
LinksetRoot.LocalID, cPrim.LocalID, cPrim.PhysShape, displacementPos, displacementRot);
|
LinksetRoot.LocalID, cPrim.LocalID, cPrim.PhysShape, lci.OffsetPos, lci.OffsetRot);
|
||||||
|
|
||||||
if (cPrim.PhysShape.isNativeShape)
|
if (cPrim.PhysShape.isNativeShape)
|
||||||
{
|
{
|
||||||
// Native shapes are not shared so we need to create a new one.
|
// A native shape is turning into a hull collision shape because native
|
||||||
// A mesh or hull is created because scale is not available on a native shape.
|
// shapes are not shared so we have to hullify it so it will be tracked
|
||||||
// (TODO: Bullet does have a btScaledCollisionShape. Can that be used?)
|
// and freed at the correct time. This also solves the scaling problem
|
||||||
|
// (native shapes scaled but hull/meshes are assumed to not be).
|
||||||
|
// TODO: decide of the native shape can just be used in the compound shape.
|
||||||
|
// Use call to CreateGeomNonSpecial().
|
||||||
BulletShape saveShape = cPrim.PhysShape;
|
BulletShape saveShape = cPrim.PhysShape;
|
||||||
cPrim.PhysShape.ptr = IntPtr.Zero; // Don't let the create free the child's shape
|
cPrim.PhysShape.Clear(); // Don't let the create free the child's shape
|
||||||
|
// PhysicsScene.Shapes.CreateGeomNonSpecial(true, cPrim, null);
|
||||||
PhysicsScene.Shapes.CreateGeomMeshOrHull(cPrim, null);
|
PhysicsScene.Shapes.CreateGeomMeshOrHull(cPrim, null);
|
||||||
BulletShape newShape = cPrim.PhysShape;
|
BulletShape newShape = cPrim.PhysShape;
|
||||||
cPrim.PhysShape = saveShape;
|
cPrim.PhysShape = saveShape;
|
||||||
BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, newShape.ptr, displacementPos, displacementRot);
|
BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, newShape.ptr, lci.OffsetPos , lci.OffsetRot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// For the shared shapes (meshes and hulls), just use the shape in the child.
|
// For the shared shapes (meshes and hulls), just use the shape in the child.
|
||||||
|
// The reference count added here will be decremented when the compound shape
|
||||||
|
// is destroyed in BSShapeCollection (the child shapes are looped over and dereferenced).
|
||||||
if (PhysicsScene.Shapes.ReferenceShape(cPrim.PhysShape))
|
if (PhysicsScene.Shapes.ReferenceShape(cPrim.PhysShape))
|
||||||
{
|
{
|
||||||
PhysicsScene.Logger.ErrorFormat("{0} Rebuilt sharable shape when building linkset! Region={1}, primID={2}, shape={3}",
|
PhysicsScene.Logger.ErrorFormat("{0} Rebuilt sharable shape when building linkset! Region={1}, primID={2}, shape={3}",
|
||||||
LogHeader, PhysicsScene.RegionName, cPrim.LocalID, cPrim.PhysShape);
|
LogHeader, PhysicsScene.RegionName, cPrim.LocalID, cPrim.PhysShape);
|
||||||
}
|
}
|
||||||
BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, cPrim.PhysShape.ptr, displacementPos, displacementRot);
|
BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, cPrim.PhysShape.ptr, lci.OffsetPos , lci.OffsetRot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: need to phantomize the child prims left behind.
|
|
||||||
// Maybe just destroy the children bodies and shapes and have them rebuild on unlink.
|
|
||||||
// Selection/deselection might cause way too many build/destructions esp. for LARGE linksets.
|
|
||||||
|
|
||||||
return false; // 'false' says to move onto the next child in the list
|
return false; // 'false' says to move onto the next child in the list
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public abstract class BSMotor
|
||||||
// Can all the incremental stepping be replaced with motor classes?
|
// Can all the incremental stepping be replaced with motor classes?
|
||||||
|
|
||||||
// Motor which moves CurrentValue to TargetValue over TimeScale seconds.
|
// Motor which moves CurrentValue to TargetValue over TimeScale seconds.
|
||||||
// The TargetValue is decays in TargetValueDecayTimeScale and
|
// The TargetValue decays in TargetValueDecayTimeScale and
|
||||||
// the CurrentValue will be held back by FrictionTimeScale.
|
// the CurrentValue will be held back by FrictionTimeScale.
|
||||||
// TimeScale and TargetDelayTimeScale may be 'infinite' which means go decay.
|
// TimeScale and TargetDelayTimeScale may be 'infinite' which means go decay.
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,9 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
Linkset = BSLinkset.Factory(PhysicsScene, this);
|
Linkset = BSLinkset.Factory(PhysicsScene, this);
|
||||||
LastAssetBuildFailed = false;
|
LastAssetBuildFailed = false;
|
||||||
|
|
||||||
|
// Default material type
|
||||||
|
Material = MaterialAttributes.Material.Wood;
|
||||||
|
|
||||||
CollisionCollection = new CollisionEventUpdate();
|
CollisionCollection = new CollisionEventUpdate();
|
||||||
SubscribedEventsMs = 0;
|
SubscribedEventsMs = 0;
|
||||||
CollidingStep = 0;
|
CollidingStep = 0;
|
||||||
|
@ -72,6 +75,7 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
public string TypeName { get; protected set; }
|
public string TypeName { get; protected set; }
|
||||||
|
|
||||||
public BSLinkset Linkset { get; set; }
|
public BSLinkset Linkset { get; set; }
|
||||||
|
public BSLinksetInfo LinksetInfo { get; set; }
|
||||||
|
|
||||||
// Return the object mass without calculating it or having side effects
|
// Return the object mass without calculating it or having side effects
|
||||||
public abstract float RawMass { get; }
|
public abstract float RawMass { get; }
|
||||||
|
@ -109,6 +113,13 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
public abstract bool IsSolid { get; }
|
public abstract bool IsSolid { get; }
|
||||||
public abstract bool IsStatic { get; }
|
public abstract bool IsStatic { get; }
|
||||||
|
|
||||||
|
// Materialness
|
||||||
|
public MaterialAttributes.Material Material { get; private set; }
|
||||||
|
public override void SetMaterial(int material)
|
||||||
|
{
|
||||||
|
Material = (MaterialAttributes.Material)material;
|
||||||
|
}
|
||||||
|
|
||||||
// Stop all physical motion.
|
// Stop all physical motion.
|
||||||
public abstract void ZeroMotion(bool inTaintTime);
|
public abstract void ZeroMotion(bool inTaintTime);
|
||||||
public abstract void ZeroAngularMotion(bool inTaintTime);
|
public abstract void ZeroAngularMotion(bool inTaintTime);
|
||||||
|
@ -128,6 +139,17 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
public abstract OMV.Quaternion RawOrientation { get; set; }
|
public abstract OMV.Quaternion RawOrientation { get; set; }
|
||||||
public abstract OMV.Quaternion ForceOrientation { get; set; }
|
public abstract OMV.Quaternion ForceOrientation { get; set; }
|
||||||
|
|
||||||
|
// The system is telling us the velocity it wants to move at.
|
||||||
|
protected OMV.Vector3 m_targetVelocity;
|
||||||
|
public override OMV.Vector3 TargetVelocity
|
||||||
|
{
|
||||||
|
get { return m_targetVelocity; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_targetVelocity = value;
|
||||||
|
Velocity = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
public abstract OMV.Vector3 ForceVelocity { get; set; }
|
public abstract OMV.Vector3 ForceVelocity { get; set; }
|
||||||
|
|
||||||
public abstract OMV.Vector3 ForceRotationalVelocity { get; set; }
|
public abstract OMV.Vector3 ForceRotationalVelocity { get; set; }
|
||||||
|
@ -243,6 +265,8 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
SubscribedEventsMs = 0;
|
SubscribedEventsMs = 0;
|
||||||
PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate()
|
PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate()
|
||||||
{
|
{
|
||||||
|
// Make sure there is a body there because sometimes destruction happens in an un-ideal order.
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,8 +108,8 @@ public sealed class BSPrim : BSPhysObject
|
||||||
_mass = CalculateMass();
|
_mass = CalculateMass();
|
||||||
|
|
||||||
// No body or shape yet
|
// No body or shape yet
|
||||||
PhysBody = new BulletBody(LocalID, IntPtr.Zero);
|
PhysBody = new BulletBody(LocalID);
|
||||||
PhysShape = new BulletShape(IntPtr.Zero);
|
PhysShape = new BulletShape();
|
||||||
|
|
||||||
DetailLog("{0},BSPrim.constructor,call", LocalID);
|
DetailLog("{0},BSPrim.constructor,call", LocalID);
|
||||||
// do the actual object creation at taint time
|
// do the actual object creation at taint time
|
||||||
|
@ -143,7 +143,9 @@ public sealed class BSPrim : BSPhysObject
|
||||||
DetailLog("{0},BSPrim.Destroy,taint,", LocalID);
|
DetailLog("{0},BSPrim.Destroy,taint,", LocalID);
|
||||||
// If there are physical body and shape, release my use of same.
|
// If there are physical body and shape, release my use of same.
|
||||||
PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null);
|
PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null);
|
||||||
|
PhysBody.Clear();
|
||||||
PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null);
|
PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null);
|
||||||
|
PhysShape.Clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +191,8 @@ public sealed class BSPrim : BSPhysObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override bool Selected {
|
public override bool Selected {
|
||||||
set {
|
set
|
||||||
|
{
|
||||||
if (value != _isSelected)
|
if (value != _isSelected)
|
||||||
{
|
{
|
||||||
_isSelected = value;
|
_isSelected = value;
|
||||||
|
@ -247,6 +250,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
// Zero some other properties in the physics engine
|
// Zero some other properties in the physics engine
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
|
||||||
{
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -257,8 +261,11 @@ public sealed class BSPrim : BSPhysObject
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
|
||||||
{
|
{
|
||||||
// DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity);
|
// DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
|
{
|
||||||
BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,8 +302,11 @@ public sealed class BSPrim : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSPrim.setPosition", delegate()
|
PhysicsScene.TaintedObject("BSPrim.setPosition", delegate()
|
||||||
{
|
{
|
||||||
// DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
// DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
|
{
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||||
ActivateIfPhysical(false);
|
ActivateIfPhysical(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,6 +423,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSPrim.setForce", delegate()
|
PhysicsScene.TaintedObject("BSPrim.setForce", delegate()
|
||||||
{
|
{
|
||||||
// DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force);
|
// DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -507,6 +518,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate()
|
PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate()
|
||||||
{
|
{
|
||||||
// DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity);
|
// DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity);
|
BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -555,10 +567,13 @@ public sealed class BSPrim : BSPhysObject
|
||||||
_orientation = value;
|
_orientation = value;
|
||||||
// TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint?
|
// TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint?
|
||||||
PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate()
|
PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate()
|
||||||
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
// _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr);
|
// _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr);
|
||||||
// DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
// DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -683,8 +698,9 @@ public sealed class BSPrim : BSPhysObject
|
||||||
ZeroMotion(true);
|
ZeroMotion(true);
|
||||||
|
|
||||||
// Set various physical properties so other object interact properly
|
// Set various physical properties so other object interact properly
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, PhysicsScene.Params.defaultFriction);
|
MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false);
|
||||||
BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.defaultRestitution);
|
BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction);
|
||||||
|
BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution);
|
||||||
|
|
||||||
// Mass is zero which disables a bunch of physics stuff in Bullet
|
// Mass is zero which disables a bunch of physics stuff in Bullet
|
||||||
UpdatePhysicalMassProperties(0f);
|
UpdatePhysicalMassProperties(0f);
|
||||||
|
@ -711,9 +727,10 @@ public sealed class BSPrim : BSPhysObject
|
||||||
// Not a Bullet static object
|
// Not a Bullet static object
|
||||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT);
|
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT);
|
||||||
|
|
||||||
// Set various physical properties so internal dynamic properties will get computed correctly as they are set
|
// Set various physical properties so other object interact properly
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, PhysicsScene.Params.defaultFriction);
|
MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true);
|
||||||
BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.defaultRestitution);
|
BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction);
|
||||||
|
BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution);
|
||||||
|
|
||||||
// per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382
|
// per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382
|
||||||
// Since this can be called multiple times, only zero forces when becoming physical
|
// Since this can be called multiple times, only zero forces when becoming physical
|
||||||
|
@ -861,6 +878,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate()
|
PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
|
DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -896,10 +914,13 @@ public sealed class BSPrim : BSPhysObject
|
||||||
_buoyancy = value;
|
_buoyancy = value;
|
||||||
// DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
// DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
||||||
// Buoyancy is faked by changing the gravity applied to the object
|
// Buoyancy is faked by changing the gravity applied to the object
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
|
{
|
||||||
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
|
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
|
||||||
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
|
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Used for MoveTo
|
// Used for MoveTo
|
||||||
public override OMV.Vector3 PIDTarget {
|
public override OMV.Vector3 PIDTarget {
|
||||||
|
@ -965,6 +986,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
}
|
}
|
||||||
DetailLog("{0},BSPrim.AddForce,taint,force={1}", LocalID, fSum);
|
DetailLog("{0},BSPrim.AddForce,taint,force={1}", LocalID, fSum);
|
||||||
if (fSum != OMV.Vector3.Zero)
|
if (fSum != OMV.Vector3.Zero)
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, fSum);
|
BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, fSum);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -976,6 +998,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyForceImpulse", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyForceImpulse", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSPrim.ApplyForceImpulse,taint,tImpulse={1}", LocalID, applyImpulse);
|
DetailLog("{0},BSPrim.ApplyForceImpulse,taint,tImpulse={1}", LocalID, applyImpulse);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.ApplyCentralImpulse2(PhysBody.ptr, applyImpulse);
|
BulletSimAPI.ApplyCentralImpulse2(PhysBody.ptr, applyImpulse);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1012,6 +1035,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
DetailLog("{0},BSPrim.AddAngularForce,taint,aForce={1}", LocalID, fSum);
|
DetailLog("{0},BSPrim.AddAngularForce,taint,aForce={1}", LocalID, fSum);
|
||||||
if (fSum != OMV.Vector3.Zero)
|
if (fSum != OMV.Vector3.Zero)
|
||||||
{
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.ApplyTorque2(PhysBody.ptr, fSum);
|
BulletSimAPI.ApplyTorque2(PhysBody.ptr, fSum);
|
||||||
_torque = fSum;
|
_torque = fSum;
|
||||||
}
|
}
|
||||||
|
@ -1026,6 +1050,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
OMV.Vector3 applyImpulse = impulse;
|
OMV.Vector3 applyImpulse = impulse;
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate()
|
||||||
{
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse);
|
BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,6 +188,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
private bool m_physicsLoggingDoFlush;
|
private bool m_physicsLoggingDoFlush;
|
||||||
// 'true' of the vehicle code is to log lots of details
|
// 'true' of the vehicle code is to log lots of details
|
||||||
public bool VehicleLoggingEnabled { get; private set; }
|
public bool VehicleLoggingEnabled { get; private set; }
|
||||||
|
public bool VehiclePhysicalLoggingEnabled { get; private set; }
|
||||||
|
public bool VehicleScaleAngularVelocityByTimestep { get; private set; }
|
||||||
|
|
||||||
#region Construction and Initialization
|
#region Construction and Initialization
|
||||||
public BSScene(string identifier)
|
public BSScene(string identifier)
|
||||||
|
@ -297,6 +299,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
m_physicsLoggingDoFlush = pConfig.GetBoolean("PhysicsLoggingDoFlush", false);
|
m_physicsLoggingDoFlush = pConfig.GetBoolean("PhysicsLoggingDoFlush", false);
|
||||||
// Very detailed logging for vehicle debugging
|
// Very detailed logging for vehicle debugging
|
||||||
VehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
|
VehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
|
||||||
|
VehiclePhysicalLoggingEnabled = pConfig.GetBoolean("VehiclePhysicalLoggingEnabled", false);
|
||||||
|
|
||||||
// Do any replacements in the parameters
|
// Do any replacements in the parameters
|
||||||
m_physicsLoggingPrefix = m_physicsLoggingPrefix.Replace("%REGIONNAME%", RegionName);
|
m_physicsLoggingPrefix = m_physicsLoggingPrefix.Replace("%REGIONNAME%", RegionName);
|
||||||
|
@ -501,7 +504,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (VehicleLoggingEnabled) DumpVehicles(); // DEBUG
|
if (VehiclePhysicalLoggingEnabled) DumpVehicles(); // DEBUG
|
||||||
if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount();
|
if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount();
|
||||||
|
|
||||||
numSubSteps = BulletSimAPI.PhysicsStep2(World.ptr, timeStep, m_maxSubSteps, m_fixedTimeStep,
|
numSubSteps = BulletSimAPI.PhysicsStep2(World.ptr, timeStep, m_maxSubSteps, m_fixedTimeStep,
|
||||||
|
@ -510,7 +513,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime);
|
if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime);
|
||||||
DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}",
|
DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}",
|
||||||
DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, updatedEntityCount, collidersCount);
|
DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, updatedEntityCount, collidersCount);
|
||||||
if (VehicleLoggingEnabled) DumpVehicles(); // DEBUG
|
if (VehiclePhysicalLoggingEnabled) DumpVehicles(); // DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1226,6 +1229,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
(s,cf,p,v) => { s.m_params[0].vehicleAngularDamping = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { s.m_params[0].vehicleAngularDamping = cf.GetFloat(p, v); },
|
||||||
(s) => { return s.m_params[0].vehicleAngularDamping; },
|
(s) => { return s.m_params[0].vehicleAngularDamping; },
|
||||||
(s,p,l,v) => { s.m_params[0].vehicleAngularDamping = v; } ),
|
(s,p,l,v) => { s.m_params[0].vehicleAngularDamping = v; } ),
|
||||||
|
new ParameterDefn("VehicleScaleAngularVelocityByTimestep", "If true, scale angular turning by timestep",
|
||||||
|
ConfigurationParameters.numericFalse,
|
||||||
|
(s,cf,p,v) => { s.VehicleScaleAngularVelocityByTimestep = cf.GetBoolean(p, s.BoolNumeric(v)); },
|
||||||
|
(s) => { return s.NumericBool(s.VehicleScaleAngularVelocityByTimestep); },
|
||||||
|
(s,p,l,v) => { s.VehicleScaleAngularVelocityByTimestep = s.BoolNumeric(v); } ),
|
||||||
|
|
||||||
new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)",
|
new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)",
|
||||||
0f,
|
0f,
|
||||||
|
|
|
@ -149,7 +149,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
// Called when releasing use of a BSBody. BSShape is handled separately.
|
// Called when releasing use of a BSBody. BSShape is handled separately.
|
||||||
public void DereferenceBody(BulletBody body, bool inTaintTime, BodyDestructionCallback bodyCallback )
|
public void DereferenceBody(BulletBody body, bool inTaintTime, BodyDestructionCallback bodyCallback )
|
||||||
{
|
{
|
||||||
if (body.ptr == IntPtr.Zero)
|
if (!body.HasPhysicalBody)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (m_collectionActivityLock)
|
lock (m_collectionActivityLock)
|
||||||
|
@ -243,12 +243,12 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
// Release the usage of a shape.
|
// Release the usage of a shape.
|
||||||
public void DereferenceShape(BulletShape shape, bool inTaintTime, ShapeDestructionCallback shapeCallback)
|
public void DereferenceShape(BulletShape shape, bool inTaintTime, ShapeDestructionCallback shapeCallback)
|
||||||
{
|
{
|
||||||
if (shape.ptr == IntPtr.Zero)
|
if (!shape.HasPhysicalShape)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.DereferenceShape", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.DereferenceShape", delegate()
|
||||||
{
|
{
|
||||||
if (shape.ptr != IntPtr.Zero)
|
if (shape.HasPhysicalShape)
|
||||||
{
|
{
|
||||||
if (shape.isNativeShape)
|
if (shape.isNativeShape)
|
||||||
{
|
{
|
||||||
|
@ -440,7 +440,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a mesh/hull shape or a native shape if 'nativeShapePossible' is 'true'.
|
// Create a mesh/hull shape or a native shape if 'nativeShapePossible' is 'true'.
|
||||||
private bool CreateGeomNonSpecial(bool forceRebuild, BSPhysObject prim, ShapeDestructionCallback shapeCallback)
|
public bool CreateGeomNonSpecial(bool forceRebuild, BSPhysObject prim, ShapeDestructionCallback shapeCallback)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
bool haveShape = false;
|
bool haveShape = false;
|
||||||
|
@ -573,7 +573,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
// Native shapes are scaled in Bullet so set the scaling to the size
|
// Native shapes are scaled in Bullet so set the scaling to the size
|
||||||
newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType);
|
newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType);
|
||||||
}
|
}
|
||||||
if (newShape.ptr == IntPtr.Zero)
|
if (!newShape.HasPhysicalShape)
|
||||||
{
|
{
|
||||||
PhysicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}",
|
PhysicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}",
|
||||||
LogHeader, prim.LocalID, shapeType);
|
LogHeader, prim.LocalID, shapeType);
|
||||||
|
@ -590,7 +590,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
// Called at taint-time!
|
// Called at taint-time!
|
||||||
private bool GetReferenceToMesh(BSPhysObject prim, ShapeDestructionCallback shapeCallback)
|
private bool GetReferenceToMesh(BSPhysObject prim, ShapeDestructionCallback shapeCallback)
|
||||||
{
|
{
|
||||||
BulletShape newShape = new BulletShape(IntPtr.Zero);
|
BulletShape newShape = new BulletShape();
|
||||||
|
|
||||||
float lod;
|
float lod;
|
||||||
System.UInt64 newMeshKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod);
|
System.UInt64 newMeshKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod);
|
||||||
|
@ -793,7 +793,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
BulletShape newShape = new BulletShape(hullPtr, BSPhysicsShapeType.SHAPE_HULL);
|
BulletShape newShape = new BulletShape(hullPtr, BSPhysicsShapeType.SHAPE_HULL);
|
||||||
newShape.shapeKey = newHullKey;
|
newShape.shapeKey = newHullKey;
|
||||||
|
|
||||||
return newShape; // 'true' means a new shape has been added to this prim
|
return newShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback from convex hull creater with a newly created hull.
|
// Callback from convex hull creater with a newly created hull.
|
||||||
|
@ -860,7 +860,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
private BulletShape VerifyMeshCreated(BulletShape newShape, BSPhysObject prim)
|
private BulletShape VerifyMeshCreated(BulletShape newShape, BSPhysObject prim)
|
||||||
{
|
{
|
||||||
// If the shape was successfully created, nothing more to do
|
// If the shape was successfully created, nothing more to do
|
||||||
if (newShape.ptr != IntPtr.Zero)
|
if (newShape.HasPhysicalShape)
|
||||||
return newShape;
|
return newShape;
|
||||||
|
|
||||||
// If this mesh has an underlying asset and we have not failed getting it before, fetch the asset
|
// If this mesh has an underlying asset and we have not failed getting it before, fetch the asset
|
||||||
|
@ -919,7 +919,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
// the mesh, hull or native shape must have already been created in Bullet
|
// the mesh, hull or native shape must have already been created in Bullet
|
||||||
bool mustRebuild = (prim.PhysBody.ptr == IntPtr.Zero);
|
bool mustRebuild = !prim.PhysBody.HasPhysicalBody;
|
||||||
|
|
||||||
// If there is an existing body, verify it's of an acceptable type.
|
// If there is an existing body, verify it's of an acceptable type.
|
||||||
// If not a solid object, body is a GhostObject. Otherwise a RigidBody.
|
// If not a solid object, body is a GhostObject. Otherwise a RigidBody.
|
||||||
|
|
|
@ -136,7 +136,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
|
||||||
{
|
{
|
||||||
if (m_mapInfo != null)
|
if (m_mapInfo != null)
|
||||||
{
|
{
|
||||||
if (m_mapInfo.terrainBody.ptr != IntPtr.Zero)
|
if (m_mapInfo.terrainBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
|
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
|
||||||
// Frees both the body and the shape.
|
// Frees both the body and the shape.
|
||||||
|
|
|
@ -151,13 +151,13 @@ public sealed class BSTerrainManager
|
||||||
// Release all the terrain structures we might have allocated
|
// Release all the terrain structures we might have allocated
|
||||||
public void ReleaseGroundPlaneAndTerrain()
|
public void ReleaseGroundPlaneAndTerrain()
|
||||||
{
|
{
|
||||||
if (m_groundPlane.ptr != IntPtr.Zero)
|
if (m_groundPlane.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr))
|
if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr))
|
||||||
{
|
{
|
||||||
BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_groundPlane.ptr);
|
BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_groundPlane.ptr);
|
||||||
}
|
}
|
||||||
m_groundPlane.ptr = IntPtr.Zero;
|
m_groundPlane.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseTerrain();
|
ReleaseTerrain();
|
||||||
|
|
|
@ -94,7 +94,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
|
||||||
m_terrainShape = new BulletShape(BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr,
|
m_terrainShape = new BulletShape(BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr,
|
||||||
indicesCount, indices, verticesCount, vertices),
|
indicesCount, indices, verticesCount, vertices),
|
||||||
BSPhysicsShapeType.SHAPE_MESH);
|
BSPhysicsShapeType.SHAPE_MESH);
|
||||||
if (m_terrainShape.ptr == IntPtr.Zero)
|
if (!m_terrainShape.HasPhysicalShape)
|
||||||
{
|
{
|
||||||
// DISASTER!!
|
// DISASTER!!
|
||||||
PhysicsScene.DetailLog("{0},BSTerrainMesh.create,failedCreationOfShape", ID);
|
PhysicsScene.DetailLog("{0},BSTerrainMesh.create,failedCreationOfShape", ID);
|
||||||
|
@ -107,7 +107,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
|
||||||
Quaternion rot = Quaternion.Identity;
|
Quaternion rot = Quaternion.Identity;
|
||||||
|
|
||||||
m_terrainBody = new BulletBody(id, BulletSimAPI.CreateBodyWithDefaultMotionState2( m_terrainShape.ptr, ID, pos, rot));
|
m_terrainBody = new BulletBody(id, BulletSimAPI.CreateBodyWithDefaultMotionState2( m_terrainShape.ptr, ID, pos, rot));
|
||||||
if (m_terrainBody.ptr == IntPtr.Zero)
|
if (!m_terrainBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
// DISASTER!!
|
// DISASTER!!
|
||||||
physicsScene.Logger.ErrorFormat("{0} Failed creation of terrain body! base={1}", LogHeader, TerrainBase);
|
physicsScene.Logger.ErrorFormat("{0} Failed creation of terrain body! base={1}", LogHeader, TerrainBase);
|
||||||
|
@ -140,7 +140,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
if (m_terrainBody.ptr != IntPtr.Zero)
|
if (m_terrainBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_terrainBody.ptr);
|
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_terrainBody.ptr);
|
||||||
// Frees both the body and the shape.
|
// Frees both the body and the shape.
|
||||||
|
|
|
@ -53,6 +53,9 @@ public struct BulletSim
|
||||||
// An allocated Bullet btRigidBody
|
// An allocated Bullet btRigidBody
|
||||||
public struct BulletBody
|
public struct BulletBody
|
||||||
{
|
{
|
||||||
|
public BulletBody(uint id) : this(id, IntPtr.Zero)
|
||||||
|
{
|
||||||
|
}
|
||||||
public BulletBody(uint id, IntPtr xx)
|
public BulletBody(uint id, IntPtr xx)
|
||||||
{
|
{
|
||||||
ID = id;
|
ID = id;
|
||||||
|
@ -64,6 +67,13 @@ public struct BulletBody
|
||||||
public uint ID;
|
public uint ID;
|
||||||
public CollisionFilterGroups collisionGroup;
|
public CollisionFilterGroups collisionGroup;
|
||||||
public CollisionFilterGroups collisionMask;
|
public CollisionFilterGroups collisionMask;
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
ptr = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
public bool HasPhysicalBody { get { return ptr != IntPtr.Zero; } }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
StringBuilder buff = new StringBuilder();
|
StringBuilder buff = new StringBuilder();
|
||||||
|
@ -103,6 +113,13 @@ public struct BulletShape
|
||||||
public BSPhysicsShapeType type;
|
public BSPhysicsShapeType type;
|
||||||
public System.UInt64 shapeKey;
|
public System.UInt64 shapeKey;
|
||||||
public bool isNativeShape;
|
public bool isNativeShape;
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
ptr = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
public bool HasPhysicalShape { get { return ptr != IntPtr.Zero; } }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
StringBuilder buff = new StringBuilder();
|
StringBuilder buff = new StringBuilder();
|
||||||
|
@ -140,6 +157,12 @@ public struct BulletConstraint
|
||||||
ptr = xx;
|
ptr = xx;
|
||||||
}
|
}
|
||||||
public IntPtr ptr;
|
public IntPtr ptr;
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
ptr = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
public bool HasPhysicalConstraint { get { return ptr != IntPtr.Zero; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
// An allocated HeightMapThing which holds various heightmap info.
|
// An allocated HeightMapThing which holds various heightmap info.
|
||||||
|
|
|
@ -11,12 +11,14 @@ CRASHES
|
||||||
|
|
||||||
VEHICLES TODO LIST:
|
VEHICLES TODO LIST:
|
||||||
=================================================
|
=================================================
|
||||||
Neb car jiggling left and right
|
Neb vehicle taking > 25ms of physics time!!
|
||||||
Happens on terrain and any other mesh object. Flat cubes are much smoother.
|
|
||||||
Vehicles (Move smoothly)
|
Vehicles (Move smoothly)
|
||||||
Add vehicle collisions so IsColliding is properly reported.
|
Add vehicle collisions so IsColliding is properly reported.
|
||||||
Needed for banking, limitMotorUp, movementLimiting, ...
|
Needed for banking, limitMotorUp, movementLimiting, ...
|
||||||
Some vehicles should not be able to turn if no speed or off ground.
|
Some vehicles should not be able to turn if no speed or off ground.
|
||||||
|
Neb car jiggling left and right
|
||||||
|
Happens on terrain and any other mesh object. Flat cubes are much smoother.
|
||||||
|
This has been reduced but not eliminated.
|
||||||
For limitMotorUp, use raycast down to find if vehicle is in the air.
|
For limitMotorUp, use raycast down to find if vehicle is in the air.
|
||||||
Implement function efficiency for lineaar and angular motion.
|
Implement function efficiency for lineaar and angular motion.
|
||||||
Should vehicle angular/linear movement friction happen after all the components
|
Should vehicle angular/linear movement friction happen after all the components
|
||||||
|
@ -30,6 +32,9 @@ Border crossing with linked vehicle causes crash
|
||||||
|
|
||||||
BULLETSIM TODO LIST:
|
BULLETSIM TODO LIST:
|
||||||
=================================================
|
=================================================
|
||||||
|
Avatar height off after unsitting (float off ground)
|
||||||
|
Editting appearance then moving restores.
|
||||||
|
Must not be initializing height when recreating capsule after unsit.
|
||||||
Duplicating a physical prim causes old prim to jump away
|
Duplicating a physical prim causes old prim to jump away
|
||||||
Dup a phys prim and the original become unselected and thus interacts w/ selected prim.
|
Dup a phys prim and the original become unselected and thus interacts w/ selected prim.
|
||||||
Disable activity of passive linkset children.
|
Disable activity of passive linkset children.
|
||||||
|
@ -38,7 +43,8 @@ Disable activity of passive linkset children.
|
||||||
Scenes with hundred of thousands of static objects take a lot of physics CPU time.
|
Scenes with hundred of thousands of static objects take a lot of physics CPU time.
|
||||||
BSPrim.Force should set a continious force on the prim. The force should be
|
BSPrim.Force should set a continious force on the prim. The force should be
|
||||||
applied each tick. Some limits?
|
applied each tick. Some limits?
|
||||||
Single prim vehicles don't seem to properly vehiclize.
|
Linksets should allow collisions to individual children
|
||||||
|
Add LocalID to children shapes in LinksetCompound and create events for individuals
|
||||||
Gun sending shooter flying.
|
Gun sending shooter flying.
|
||||||
Collision margin (gap between physical objects lying on each other)
|
Collision margin (gap between physical objects lying on each other)
|
||||||
Boundry checking (crashes related to crossing boundry)
|
Boundry checking (crashes related to crossing boundry)
|
||||||
|
@ -146,3 +152,5 @@ Light cycle falling over when driving (Resolution: implemented VerticalAttractor
|
||||||
Light cycle not banking (Resolution: It doesn't. Banking is roll adding yaw.)
|
Light cycle not banking (Resolution: It doesn't. Banking is roll adding yaw.)
|
||||||
Package Bullet source mods for Bullet internal stats output
|
Package Bullet source mods for Bullet internal stats output
|
||||||
(Resolution: move code into WorldData.h rather than relying on patches)
|
(Resolution: move code into WorldData.h rather than relying on patches)
|
||||||
|
Single prim vehicles don't seem to properly vehiclize.
|
||||||
|
(Resolution: mass was not getting set properly for single prim linksets)
|
||||||
|
|
Loading…
Reference in New Issue