Merge branch 'master' of /home/opensim/var/repo/opensim
commit
c5d333c16c
|
@ -71,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
|||
|
||||
#region Internal functions
|
||||
|
||||
public AssetMetadata FetchMetadata(string url, UUID assetID)
|
||||
private AssetMetadata FetchMetadata(string url, UUID assetID)
|
||||
{
|
||||
if (!url.EndsWith("/") && !url.EndsWith("="))
|
||||
url = url + "/";
|
||||
|
@ -86,6 +86,27 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
|||
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)
|
||||
{
|
||||
if (asset != null)
|
||||
|
@ -228,11 +249,22 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
|||
if (meta == null)
|
||||
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>();
|
||||
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL);
|
||||
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.SaleType = item.SaleType;
|
||||
|
||||
if (AddInventoryItem(itemCopy))
|
||||
{
|
||||
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
|
||||
if (invAccess != null)
|
||||
invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
|
||||
}
|
||||
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
|
||||
if (invAccess != null)
|
||||
invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
|
||||
AddInventoryItem(itemCopy);
|
||||
|
||||
if (!Permissions.BypassPermissions())
|
||||
{
|
||||
|
|
|
@ -124,7 +124,9 @@ public sealed class BSCharacter : BSPhysObject
|
|||
PhysicsScene.TaintedObject("BSCharacter.destroy", delegate()
|
||||
{
|
||||
PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null);
|
||||
PhysBody.Clear();
|
||||
PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null);
|
||||
PhysShape.Clear();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -194,8 +196,11 @@ public sealed class BSCharacter : BSPhysObject
|
|||
|
||||
PhysicsScene.TaintedObject("BSCharacter.setSize", delegate()
|
||||
{
|
||||
BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
|
||||
UpdatePhysicalMassProperties(RawMass);
|
||||
if (PhysShape.HasPhysicalShape)
|
||||
{
|
||||
BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
|
||||
UpdatePhysicalMassProperties(RawMass);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -236,7 +241,8 @@ public sealed class BSCharacter : BSPhysObject
|
|||
// Zero some other properties directly into the physics engine
|
||||
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
|
||||
{
|
||||
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
||||
});
|
||||
}
|
||||
public override void ZeroAngularMotion(bool inTaintTime)
|
||||
|
@ -245,10 +251,13 @@ public sealed class BSCharacter : BSPhysObject
|
|||
|
||||
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
|
||||
{
|
||||
BulletSimAPI.SetInterpolationAngularVelocity2(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.
|
||||
BulletSimAPI.ClearForces2(PhysBody.ptr);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.SetInterpolationAngularVelocity2(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.
|
||||
BulletSimAPI.ClearForces2(PhysBody.ptr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -273,7 +282,8 @@ public sealed class BSCharacter : BSPhysObject
|
|||
PhysicsScene.TaintedObject("BSCharacter.setPosition", delegate()
|
||||
{
|
||||
DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -332,7 +342,8 @@ public sealed class BSCharacter : BSPhysObject
|
|||
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate()
|
||||
{
|
||||
DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||
});
|
||||
ret = true;
|
||||
}
|
||||
|
@ -359,7 +370,8 @@ public sealed class BSCharacter : BSPhysObject
|
|||
PhysicsScene.TaintedObject("BSCharacter.SetForce", delegate()
|
||||
{
|
||||
DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force);
|
||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -398,7 +410,8 @@ public sealed class BSCharacter : BSPhysObject
|
|||
if (_currentFriction != PhysicsScene.Params.avatarStandingFriction)
|
||||
{
|
||||
_currentFriction = PhysicsScene.Params.avatarStandingFriction;
|
||||
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -406,7 +419,8 @@ public sealed class BSCharacter : BSPhysObject
|
|||
if (_currentFriction != PhysicsScene.Params.avatarFriction)
|
||||
{
|
||||
_currentFriction = PhysicsScene.Params.avatarFriction;
|
||||
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
||||
}
|
||||
}
|
||||
_velocity = value;
|
||||
|
@ -443,8 +457,11 @@ public sealed class BSCharacter : BSPhysObject
|
|||
// m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
|
||||
PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate()
|
||||
{
|
||||
// _position = BulletSimAPI.GetPosition2(BSBody.ptr);
|
||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
// _position = BulletSimAPI.GetPosition2(BSBody.ptr);
|
||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -517,10 +534,13 @@ public sealed class BSCharacter : BSPhysObject
|
|||
_floatOnWater = value;
|
||||
PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate()
|
||||
{
|
||||
if (_floatOnWater)
|
||||
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||
else
|
||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
if (_floatOnWater)
|
||||
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||
else
|
||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -553,7 +573,8 @@ public sealed class BSCharacter : BSPhysObject
|
|||
DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
||||
// Buoyancy is faked by changing the gravity applied to the object
|
||||
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
|
||||
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,7 +620,8 @@ public sealed class BSCharacter : BSPhysObject
|
|||
PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate()
|
||||
{
|
||||
DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force);
|
||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||
});
|
||||
}
|
||||
else
|
||||
|
|
|
@ -57,7 +57,7 @@ public abstract class BSConstraint : IDisposable
|
|||
if (m_enabled)
|
||||
{
|
||||
m_enabled = false;
|
||||
if (m_constraint.ptr != IntPtr.Zero)
|
||||
if (m_constraint.HasPhysicalConstraint)
|
||||
{
|
||||
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}",
|
||||
|
@ -65,7 +65,7 @@ public abstract class BSConstraint : IDisposable
|
|||
m_body1.ID, m_body1.ptr.ToString("X"),
|
||||
m_body2.ID, m_body2.ptr.ToString("X"),
|
||||
success);
|
||||
m_constraint.ptr = System.IntPtr.Zero;
|
||||
m_constraint.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public sealed class BSConstraint6Dof : BSConstraint
|
|||
m_world = world;
|
||||
m_body1 = obj1;
|
||||
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}",
|
||||
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}",
|
||||
BSScene.DetailLogZero, world.worldID, m_constraint.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}",
|
||||
LogHeader, obj1.ID, obj2.ID);
|
||||
|
|
|
@ -570,8 +570,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia);
|
||||
BulletSimAPI.UpdateInertiaTensor2(Prim.PhysBody.ptr);
|
||||
|
||||
VDetailLog("{0},BSDynamics.Refresh,frict={1},inert={2},aDamp={3}",
|
||||
Prim.LocalID, friction, localInertia, angularDamping);
|
||||
VDetailLog("{0},BSDynamics.Refresh,mass={1},frict={2},inert={3},aDamp={4}",
|
||||
Prim.LocalID, m_vehicleMass, friction, localInertia, angularDamping);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -818,6 +818,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
+ hoverContribution
|
||||
+ limitMotorUpContribution;
|
||||
|
||||
Vector3 newForce = buoyancyContribution;
|
||||
|
||||
// If not changing some axis, reduce out velocity
|
||||
if ((m_flags & (VehicleFlag.NO_X)) != 0)
|
||||
newVelocity.X = 0;
|
||||
|
@ -845,7 +847,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
VehicleVelocity = newVelocity;
|
||||
|
||||
// Other linear forces are applied as forces.
|
||||
Vector3 totalDownForce = buoyancyContribution * m_vehicleMass;
|
||||
Vector3 totalDownForce = newForce * m_vehicleMass;
|
||||
if (!totalDownForce.ApproxEquals(Vector3.Zero, 0.01f))
|
||||
{
|
||||
VehicleAddForce(totalDownForce);
|
||||
|
@ -991,8 +993,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
|
||||
if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0)
|
||||
{
|
||||
// If the vehicle is motoring into the sky, get it going back down.
|
||||
float distanceAboveGround = VehiclePosition.Z - GetTerrainHeight(VehiclePosition);
|
||||
float targetHeight = Type == Vehicle.TYPE_BOAT ? GetWaterLevel(VehiclePosition) : GetTerrainHeight(VehiclePosition);
|
||||
float distanceAboveGround = VehiclePosition.Z - targetHeight;
|
||||
// Not colliding if the vehicle is off the ground
|
||||
if (!Prim.IsColliding)
|
||||
{
|
||||
|
@ -1005,8 +1007,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
// has a decay factor. This says this force should
|
||||
// be computed with a motor.
|
||||
// TODO: add interaction with banking.
|
||||
VDetailLog("{0}, MoveLinear,limitMotorUp,distAbove={1},downForce={2}",
|
||||
Prim.LocalID, distanceAboveGround, ret);
|
||||
VDetailLog("{0}, MoveLinear,limitMotorUp,distAbove={1},colliding={2},ret={3}",
|
||||
Prim.LocalID, distanceAboveGround, Prim.IsColliding, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1055,7 +1057,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
// TODO: Should this be applied as an angular force (torque)?
|
||||
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;
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
// 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
|
||||
{
|
||||
// private static string LogHeader = "[BULLETSIM LINKSET]";
|
||||
|
|
|
@ -32,6 +32,31 @@ using OMV = OpenMetaverse;
|
|||
|
||||
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
|
||||
{
|
||||
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.
|
||||
public override BSPhysicsShapeType PreferredPhysicalShape(BSPhysObject requestor)
|
||||
{
|
||||
// Returning 'unknown' means we don't have a preference.
|
||||
BSPhysicsShapeType ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
|
||||
if (IsRoot(requestor) && HasAnyChildren)
|
||||
{
|
||||
|
@ -63,10 +89,10 @@ public sealed class BSLinksetCompound : BSLinkset
|
|||
// InternalRefresh(requestor);
|
||||
}
|
||||
|
||||
// Schedule a refresh to happen after all the other taint processing.
|
||||
private void InternalRefresh(BSPhysObject requestor)
|
||||
{
|
||||
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()
|
||||
{
|
||||
if (IsRoot(requestor) && HasAnyChildren)
|
||||
|
@ -84,12 +110,19 @@ public sealed class BSLinksetCompound : BSLinkset
|
|||
{
|
||||
bool ret = false;
|
||||
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
|
||||
// shape takes over.
|
||||
BulletSimAPI.AddToCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
|
||||
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;
|
||||
}
|
||||
return ret;
|
||||
|
@ -108,7 +141,7 @@ public sealed class BSLinksetCompound : BSLinkset
|
|||
{
|
||||
// The non-physical children can come back to life.
|
||||
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);
|
||||
ret = true;
|
||||
}
|
||||
|
@ -146,6 +179,10 @@ public sealed class BSLinksetCompound : BSLinkset
|
|||
|
||||
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.
|
||||
InternalRefresh(LinksetRoot);
|
||||
ret = true;
|
||||
|
@ -154,6 +191,42 @@ public sealed class BSLinksetCompound : BSLinkset
|
|||
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',
|
||||
// this routine will restore the removed constraints.
|
||||
// Called at taint-time!!
|
||||
|
@ -192,6 +265,7 @@ public sealed class BSLinksetCompound : BSLinkset
|
|||
child.LocalID, child.PhysBody.ptr.ToString("X"));
|
||||
|
||||
// Cause the child's body to be rebuilt and thus restored to normal operation
|
||||
RecomputeChildWorldPosition(child, false);
|
||||
child.ForceBodyShapeRebuild(false);
|
||||
|
||||
if (!HasAnyChildren)
|
||||
|
@ -226,42 +300,57 @@ public sealed class BSLinksetCompound : BSLinkset
|
|||
{
|
||||
if (!IsRoot(cPrim))
|
||||
{
|
||||
// Each child position and rotation is given relative to the root.
|
||||
OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(LinksetRoot.RawOrientation);
|
||||
OMV.Vector3 displacementPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation;
|
||||
OMV.Quaternion displacementRot = cPrim.RawOrientation * invRootOrientation;
|
||||
// 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.
|
||||
OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(LinksetRoot.RawOrientation);
|
||||
OMV.Vector3 displacementPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * 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}",
|
||||
LinksetRoot.LocalID, cPrim.LocalID, cPrim.PhysShape, displacementPos, displacementRot);
|
||||
LinksetRoot.LocalID, cPrim.LocalID, cPrim.PhysShape, lci.OffsetPos, lci.OffsetRot);
|
||||
|
||||
if (cPrim.PhysShape.isNativeShape)
|
||||
{
|
||||
// Native shapes are not shared so we need to create a new one.
|
||||
// A mesh or hull is created because scale is not available on a native shape.
|
||||
// (TODO: Bullet does have a btScaledCollisionShape. Can that be used?)
|
||||
// A native shape is turning into a hull collision shape because native
|
||||
// shapes are not shared so we have to hullify it so it will be tracked
|
||||
// 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;
|
||||
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);
|
||||
BulletShape newShape = cPrim.PhysShape;
|
||||
cPrim.PhysShape = saveShape;
|
||||
BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, newShape.ptr, displacementPos, displacementRot);
|
||||
BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, newShape.ptr, lci.OffsetPos , lci.OffsetRot);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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))
|
||||
{
|
||||
PhysicsScene.Logger.ErrorFormat("{0} Rebuilt sharable shape when building linkset! Region={1}, primID={2}, shape={3}",
|
||||
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
|
||||
});
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public abstract class BSMotor
|
|||
// Can all the incremental stepping be replaced with motor classes?
|
||||
|
||||
// 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.
|
||||
// TimeScale and TargetDelayTimeScale may be 'infinite' which means go decay.
|
||||
|
||||
|
|
|
@ -60,6 +60,9 @@ public abstract class BSPhysObject : PhysicsActor
|
|||
Linkset = BSLinkset.Factory(PhysicsScene, this);
|
||||
LastAssetBuildFailed = false;
|
||||
|
||||
// Default material type
|
||||
Material = MaterialAttributes.Material.Wood;
|
||||
|
||||
CollisionCollection = new CollisionEventUpdate();
|
||||
SubscribedEventsMs = 0;
|
||||
CollidingStep = 0;
|
||||
|
@ -72,6 +75,7 @@ public abstract class BSPhysObject : PhysicsActor
|
|||
public string TypeName { get; protected set; }
|
||||
|
||||
public BSLinkset Linkset { get; set; }
|
||||
public BSLinksetInfo LinksetInfo { get; set; }
|
||||
|
||||
// Return the object mass without calculating it or having side effects
|
||||
public abstract float RawMass { get; }
|
||||
|
@ -109,6 +113,13 @@ public abstract class BSPhysObject : PhysicsActor
|
|||
public abstract bool IsSolid { 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.
|
||||
public abstract void ZeroMotion(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 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 ForceRotationalVelocity { get; set; }
|
||||
|
@ -243,7 +265,9 @@ public abstract class BSPhysObject : PhysicsActor
|
|||
SubscribedEventsMs = 0;
|
||||
PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate()
|
||||
{
|
||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||
// 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);
|
||||
});
|
||||
}
|
||||
// Return 'true' if the simulator wants collision events
|
||||
|
|
|
@ -108,8 +108,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
_mass = CalculateMass();
|
||||
|
||||
// No body or shape yet
|
||||
PhysBody = new BulletBody(LocalID, IntPtr.Zero);
|
||||
PhysShape = new BulletShape(IntPtr.Zero);
|
||||
PhysBody = new BulletBody(LocalID);
|
||||
PhysShape = new BulletShape();
|
||||
|
||||
DetailLog("{0},BSPrim.constructor,call", LocalID);
|
||||
// do the actual object creation at taint time
|
||||
|
@ -143,7 +143,9 @@ public sealed class BSPrim : BSPhysObject
|
|||
DetailLog("{0},BSPrim.Destroy,taint,", LocalID);
|
||||
// If there are physical body and shape, release my use of same.
|
||||
PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null);
|
||||
PhysBody.Clear();
|
||||
PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null);
|
||||
PhysShape.Clear();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -189,7 +191,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
}
|
||||
}
|
||||
public override bool Selected {
|
||||
set {
|
||||
set
|
||||
{
|
||||
if (value != _isSelected)
|
||||
{
|
||||
_isSelected = value;
|
||||
|
@ -247,7 +250,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
// Zero some other properties in the physics engine
|
||||
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
|
||||
{
|
||||
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
||||
});
|
||||
}
|
||||
public override void ZeroAngularMotion(bool inTaintTime)
|
||||
|
@ -257,8 +261,11 @@ public sealed class BSPrim : BSPhysObject
|
|||
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
|
||||
{
|
||||
// DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity);
|
||||
BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -295,8 +302,11 @@ public sealed class BSPrim : BSPhysObject
|
|||
PhysicsScene.TaintedObject("BSPrim.setPosition", delegate()
|
||||
{
|
||||
// DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||
ActivateIfPhysical(false);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||
ActivateIfPhysical(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -322,12 +332,12 @@ public sealed class BSPrim : BSPhysObject
|
|||
|
||||
float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position);
|
||||
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);
|
||||
float targetHeight = terrainHeight + (Size.Z / 2f);
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -335,10 +345,10 @@ public sealed class BSPrim : BSPhysObject
|
|||
{
|
||||
float waterHeight = PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(_position);
|
||||
// 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.Z = (waterHeight - Position.Z) * 1f;
|
||||
upForce.Z = (waterHeight - RawPosition.Z) * 1f;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
@ -413,7 +423,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
PhysicsScene.TaintedObject("BSPrim.setForce", delegate()
|
||||
{
|
||||
// DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force);
|
||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -507,7 +518,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate()
|
||||
{
|
||||
// DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity);
|
||||
BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -556,9 +568,12 @@ public sealed class BSPrim : BSPhysObject
|
|||
// TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint?
|
||||
PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate()
|
||||
{
|
||||
// _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr);
|
||||
// DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
// _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr);
|
||||
// DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -683,8 +698,9 @@ public sealed class BSPrim : BSPhysObject
|
|||
ZeroMotion(true);
|
||||
|
||||
// Set various physical properties so other object interact properly
|
||||
BulletSimAPI.SetFriction2(PhysBody.ptr, PhysicsScene.Params.defaultFriction);
|
||||
BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.defaultRestitution);
|
||||
MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false);
|
||||
BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction);
|
||||
BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution);
|
||||
|
||||
// Mass is zero which disables a bunch of physics stuff in Bullet
|
||||
UpdatePhysicalMassProperties(0f);
|
||||
|
@ -711,9 +727,10 @@ public sealed class BSPrim : BSPhysObject
|
|||
// Not a Bullet 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
|
||||
BulletSimAPI.SetFriction2(PhysBody.ptr, PhysicsScene.Params.defaultFriction);
|
||||
BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.defaultRestitution);
|
||||
// Set various physical properties so other object interact properly
|
||||
MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true);
|
||||
BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction);
|
||||
BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution);
|
||||
|
||||
// per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382
|
||||
// Since this can be called multiple times, only zero forces when becoming physical
|
||||
|
@ -861,7 +878,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate()
|
||||
{
|
||||
DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
|
||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -896,8 +914,11 @@ public sealed class BSPrim : BSPhysObject
|
|||
_buoyancy = value;
|
||||
// DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
||||
// Buoyancy is faked by changing the gravity applied to the object
|
||||
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
|
||||
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
{
|
||||
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
|
||||
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -965,7 +986,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
}
|
||||
DetailLog("{0},BSPrim.AddForce,taint,force={1}", LocalID, fSum);
|
||||
if (fSum != OMV.Vector3.Zero)
|
||||
BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, fSum);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, fSum);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -976,7 +998,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyForceImpulse", delegate()
|
||||
{
|
||||
DetailLog("{0},BSPrim.ApplyForceImpulse,taint,tImpulse={1}", LocalID, applyImpulse);
|
||||
BulletSimAPI.ApplyCentralImpulse2(PhysBody.ptr, applyImpulse);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.ApplyCentralImpulse2(PhysBody.ptr, applyImpulse);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1012,7 +1035,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
DetailLog("{0},BSPrim.AddAngularForce,taint,aForce={1}", LocalID, fSum);
|
||||
if (fSum != OMV.Vector3.Zero)
|
||||
{
|
||||
BulletSimAPI.ApplyTorque2(PhysBody.ptr, fSum);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.ApplyTorque2(PhysBody.ptr, fSum);
|
||||
_torque = fSum;
|
||||
}
|
||||
});
|
||||
|
@ -1026,7 +1050,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
OMV.Vector3 applyImpulse = impulse;
|
||||
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate()
|
||||
{
|
||||
BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse);
|
||||
if (PhysBody.HasPhysicalBody)
|
||||
BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -188,6 +188,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
|||
private bool m_physicsLoggingDoFlush;
|
||||
// 'true' of the vehicle code is to log lots of details
|
||||
public bool VehicleLoggingEnabled { get; private set; }
|
||||
public bool VehiclePhysicalLoggingEnabled { get; private set; }
|
||||
public bool VehicleScaleAngularVelocityByTimestep { get; private set; }
|
||||
|
||||
#region Construction and Initialization
|
||||
public BSScene(string identifier)
|
||||
|
@ -297,6 +299,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
|||
m_physicsLoggingDoFlush = pConfig.GetBoolean("PhysicsLoggingDoFlush", false);
|
||||
// Very detailed logging for vehicle debugging
|
||||
VehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
|
||||
VehiclePhysicalLoggingEnabled = pConfig.GetBoolean("VehiclePhysicalLoggingEnabled", false);
|
||||
|
||||
// Do any replacements in the parameters
|
||||
m_physicsLoggingPrefix = m_physicsLoggingPrefix.Replace("%REGIONNAME%", RegionName);
|
||||
|
@ -501,7 +504,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
|||
|
||||
try
|
||||
{
|
||||
if (VehicleLoggingEnabled) DumpVehicles(); // DEBUG
|
||||
if (VehiclePhysicalLoggingEnabled) DumpVehicles(); // DEBUG
|
||||
if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount();
|
||||
|
||||
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);
|
||||
DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}",
|
||||
DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, updatedEntityCount, collidersCount);
|
||||
if (VehicleLoggingEnabled) DumpVehicles(); // DEBUG
|
||||
if (VehiclePhysicalLoggingEnabled) DumpVehicles(); // DEBUG
|
||||
}
|
||||
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) => { return s.m_params[0].vehicleAngularDamping; },
|
||||
(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)",
|
||||
0f,
|
||||
|
|
|
@ -149,7 +149,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
// Called when releasing use of a BSBody. BSShape is handled separately.
|
||||
public void DereferenceBody(BulletBody body, bool inTaintTime, BodyDestructionCallback bodyCallback )
|
||||
{
|
||||
if (body.ptr == IntPtr.Zero)
|
||||
if (!body.HasPhysicalBody)
|
||||
return;
|
||||
|
||||
lock (m_collectionActivityLock)
|
||||
|
@ -243,12 +243,12 @@ public sealed class BSShapeCollection : IDisposable
|
|||
// Release the usage of a shape.
|
||||
public void DereferenceShape(BulletShape shape, bool inTaintTime, ShapeDestructionCallback shapeCallback)
|
||||
{
|
||||
if (shape.ptr == IntPtr.Zero)
|
||||
if (!shape.HasPhysicalShape)
|
||||
return;
|
||||
|
||||
PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.DereferenceShape", delegate()
|
||||
{
|
||||
if (shape.ptr != IntPtr.Zero)
|
||||
if (shape.HasPhysicalShape)
|
||||
{
|
||||
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'.
|
||||
private bool CreateGeomNonSpecial(bool forceRebuild, BSPhysObject prim, ShapeDestructionCallback shapeCallback)
|
||||
public bool CreateGeomNonSpecial(bool forceRebuild, BSPhysObject prim, ShapeDestructionCallback shapeCallback)
|
||||
{
|
||||
bool ret = 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
|
||||
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}",
|
||||
LogHeader, prim.LocalID, shapeType);
|
||||
|
@ -590,7 +590,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
// Called at taint-time!
|
||||
private bool GetReferenceToMesh(BSPhysObject prim, ShapeDestructionCallback shapeCallback)
|
||||
{
|
||||
BulletShape newShape = new BulletShape(IntPtr.Zero);
|
||||
BulletShape newShape = new BulletShape();
|
||||
|
||||
float 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);
|
||||
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.
|
||||
|
@ -860,7 +860,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
private BulletShape VerifyMeshCreated(BulletShape newShape, BSPhysObject prim)
|
||||
{
|
||||
// If the shape was successfully created, nothing more to do
|
||||
if (newShape.ptr != IntPtr.Zero)
|
||||
if (newShape.HasPhysicalShape)
|
||||
return newShape;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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 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.terrainBody.ptr != IntPtr.Zero)
|
||||
if (m_mapInfo.terrainBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr);
|
||||
// Frees both the body and the shape.
|
||||
|
|
|
@ -151,13 +151,13 @@ public sealed class BSTerrainManager
|
|||
// Release all the terrain structures we might have allocated
|
||||
public void ReleaseGroundPlaneAndTerrain()
|
||||
{
|
||||
if (m_groundPlane.ptr != IntPtr.Zero)
|
||||
if (m_groundPlane.HasPhysicalBody)
|
||||
{
|
||||
if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr))
|
||||
{
|
||||
BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_groundPlane.ptr);
|
||||
}
|
||||
m_groundPlane.ptr = IntPtr.Zero;
|
||||
m_groundPlane.Clear();
|
||||
}
|
||||
|
||||
ReleaseTerrain();
|
||||
|
|
|
@ -94,7 +94,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
|
|||
m_terrainShape = new BulletShape(BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr,
|
||||
indicesCount, indices, verticesCount, vertices),
|
||||
BSPhysicsShapeType.SHAPE_MESH);
|
||||
if (m_terrainShape.ptr == IntPtr.Zero)
|
||||
if (!m_terrainShape.HasPhysicalShape)
|
||||
{
|
||||
// DISASTER!!
|
||||
PhysicsScene.DetailLog("{0},BSTerrainMesh.create,failedCreationOfShape", ID);
|
||||
|
@ -107,7 +107,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
|
|||
Quaternion rot = Quaternion.Identity;
|
||||
|
||||
m_terrainBody = new BulletBody(id, BulletSimAPI.CreateBodyWithDefaultMotionState2( m_terrainShape.ptr, ID, pos, rot));
|
||||
if (m_terrainBody.ptr == IntPtr.Zero)
|
||||
if (!m_terrainBody.HasPhysicalBody)
|
||||
{
|
||||
// DISASTER!!
|
||||
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()
|
||||
{
|
||||
if (m_terrainBody.ptr != IntPtr.Zero)
|
||||
if (m_terrainBody.HasPhysicalBody)
|
||||
{
|
||||
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_terrainBody.ptr);
|
||||
// Frees both the body and the shape.
|
||||
|
|
|
@ -53,6 +53,9 @@ public struct BulletSim
|
|||
// An allocated Bullet btRigidBody
|
||||
public struct BulletBody
|
||||
{
|
||||
public BulletBody(uint id) : this(id, IntPtr.Zero)
|
||||
{
|
||||
}
|
||||
public BulletBody(uint id, IntPtr xx)
|
||||
{
|
||||
ID = id;
|
||||
|
@ -64,6 +67,13 @@ public struct BulletBody
|
|||
public uint ID;
|
||||
public CollisionFilterGroups collisionGroup;
|
||||
public CollisionFilterGroups collisionMask;
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
ptr = IntPtr.Zero;
|
||||
}
|
||||
public bool HasPhysicalBody { get { return ptr != IntPtr.Zero; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder buff = new StringBuilder();
|
||||
|
@ -103,6 +113,13 @@ public struct BulletShape
|
|||
public BSPhysicsShapeType type;
|
||||
public System.UInt64 shapeKey;
|
||||
public bool isNativeShape;
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
ptr = IntPtr.Zero;
|
||||
}
|
||||
public bool HasPhysicalShape { get { return ptr != IntPtr.Zero; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder buff = new StringBuilder();
|
||||
|
@ -140,6 +157,12 @@ public struct BulletConstraint
|
|||
ptr = xx;
|
||||
}
|
||||
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.
|
||||
|
|
|
@ -11,12 +11,14 @@ CRASHES
|
|||
|
||||
VEHICLES TODO LIST:
|
||||
=================================================
|
||||
Neb car jiggling left and right
|
||||
Happens on terrain and any other mesh object. Flat cubes are much smoother.
|
||||
Neb vehicle taking > 25ms of physics time!!
|
||||
Vehicles (Move smoothly)
|
||||
Add vehicle collisions so IsColliding is properly reported.
|
||||
Needed for banking, limitMotorUp, movementLimiting, ...
|
||||
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.
|
||||
Implement function efficiency for lineaar and angular motion.
|
||||
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:
|
||||
=================================================
|
||||
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
|
||||
Dup a phys prim and the original become unselected and thus interacts w/ selected prim.
|
||||
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.
|
||||
BSPrim.Force should set a continious force on the prim. The force should be
|
||||
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.
|
||||
Collision margin (gap between physical objects lying on each other)
|
||||
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.)
|
||||
Package Bullet source mods for Bullet internal stats output
|
||||
(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