BulletSim: remove the trailing spaces from lines to make git happier

connector_plugin
Robert Adams 2012-09-27 09:31:33 -07:00
parent 5781d4d52d
commit 7b65985047
10 changed files with 275 additions and 276 deletions

View File

@ -122,7 +122,6 @@ public class BSCharacter : BSPhysObject
BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr, BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr,
(uint)CollisionFilterGroups.AvatarFilter, (uint)CollisionFilterGroups.AvatarMask); (uint)CollisionFilterGroups.AvatarFilter, (uint)CollisionFilterGroups.AvatarMask);
}); });
return; return;
} }
@ -141,8 +140,8 @@ public class BSCharacter : BSPhysObject
base.RequestPhysicsterseUpdate(); base.RequestPhysicsterseUpdate();
} }
// No one calls this method so I don't know what it could possibly mean // No one calls this method so I don't know what it could possibly mean
public override bool Stopped { public override bool Stopped {
get { return false; } get { return false; }
} }
public override OMV.Vector3 Size { public override OMV.Vector3 Size {
get get
@ -151,7 +150,7 @@ public class BSCharacter : BSPhysObject
return new OMV.Vector3(_scale.X * 2, _scale.Y * 2, _scale.Z); return new OMV.Vector3(_scale.X * 2, _scale.Y * 2, _scale.Z);
} }
set { set {
// When an avatar's size is set, only the height is changed // When an avatar's size is set, only the height is changed
// and that really only depends on the radius. // and that really only depends on the radius.
_size = value; _size = value;
@ -166,19 +165,19 @@ public class BSCharacter : BSPhysObject
BulletSimAPI.SetObjectScaleMass(PhysicsScene.WorldID, LocalID, _scale, _mass, true); BulletSimAPI.SetObjectScaleMass(PhysicsScene.WorldID, LocalID, _scale, _mass, true);
}); });
} }
} }
public override PrimitiveBaseShape Shape { public override PrimitiveBaseShape Shape {
set { _pbs = value; set { _pbs = value;
} }
} }
public override bool Grabbed { public override bool Grabbed {
set { _grabbed = value; set { _grabbed = value;
} }
} }
public override bool Selected { public override bool Selected {
set { _selected = value; set { _selected = value;
} }
} }
public override void CrossingFailure() { return; } public override void CrossingFailure() { return; }
public override void link(PhysicsActor obj) { return; } public override void link(PhysicsActor obj) { return; }
@ -203,11 +202,11 @@ public class BSCharacter : BSPhysObject
public override void LockAngularMotion(OMV.Vector3 axis) { return; } public override void LockAngularMotion(OMV.Vector3 axis) { return; }
public override OMV.Vector3 Position { public override OMV.Vector3 Position {
get { get {
// _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, _localID); // _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, _localID);
return _position; return _position;
} }
set { set {
_position = value; _position = value;
PositionSanityCheck(); PositionSanityCheck();
@ -217,7 +216,7 @@ public class BSCharacter : BSPhysObject
DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation);
}); });
} }
} }
// Check that the current position is sane and, if not, modify the position to make it so. // Check that the current position is sane and, if not, modify the position to make it so.
@ -226,7 +225,7 @@ public class BSCharacter : BSPhysObject
private bool PositionSanityCheck() private bool PositionSanityCheck()
{ {
bool ret = false; bool ret = false;
// If below the ground, move the avatar up // If below the ground, move the avatar up
float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position);
if (Position.Z < terrainHeight) if (Position.Z < terrainHeight)
@ -260,17 +259,17 @@ public class BSCharacter : BSPhysObject
return ret; return ret;
} }
public override float Mass { public override float Mass {
get { get {
return _mass; return _mass;
} }
} }
// used when we only want this prim's mass and not the linkset thing // used when we only want this prim's mass and not the linkset thing
public override float MassRaw { get {return _mass; } } public override float MassRaw { get {return _mass; } }
public override OMV.Vector3 Force { public override OMV.Vector3 Force {
get { return _force; } get { return _force; }
set { set {
_force = value; _force = value;
// m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force);
@ -279,12 +278,12 @@ public class BSCharacter : BSPhysObject
DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force); DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force);
BulletSimAPI.SetObjectForce(PhysicsScene.WorldID, LocalID, _force); BulletSimAPI.SetObjectForce(PhysicsScene.WorldID, LocalID, _force);
}); });
} }
} }
public override int VehicleType { public override int VehicleType {
get { return 0; } get { return 0; }
set { return; } set { return; }
} }
public override void VehicleFloatParam(int param, float value) { } public override void VehicleFloatParam(int param, float value) { }
public override void VehicleVectorParam(int param, OMV.Vector3 value) {} public override void VehicleVectorParam(int param, OMV.Vector3 value) {}
@ -296,8 +295,8 @@ public class BSCharacter : BSPhysObject
public override OMV.Vector3 GeometricCenter { get { return OMV.Vector3.Zero; } } public override OMV.Vector3 GeometricCenter { get { return OMV.Vector3.Zero; } }
public override OMV.Vector3 CenterOfMass { get { return OMV.Vector3.Zero; } } public override OMV.Vector3 CenterOfMass { get { return OMV.Vector3.Zero; } }
public override OMV.Vector3 Velocity { public override OMV.Vector3 Velocity {
get { return _velocity; } get { return _velocity; }
set { set {
_velocity = value; _velocity = value;
// m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity); // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity);
@ -306,24 +305,24 @@ public class BSCharacter : BSPhysObject
DetailLog("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, _velocity); DetailLog("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, _velocity);
BulletSimAPI.SetObjectVelocity(PhysicsScene.WorldID, LocalID, _velocity); BulletSimAPI.SetObjectVelocity(PhysicsScene.WorldID, LocalID, _velocity);
}); });
} }
} }
public override OMV.Vector3 Torque { public override OMV.Vector3 Torque {
get { return _torque; } get { return _torque; }
set { _torque = value; set { _torque = value;
} }
} }
public override float CollisionScore { public override float CollisionScore {
get { return _collisionScore; } get { return _collisionScore; }
set { _collisionScore = value; set { _collisionScore = value;
} }
} }
public override OMV.Vector3 Acceleration { public override OMV.Vector3 Acceleration {
get { return _acceleration; } get { return _acceleration; }
set { _acceleration = value; } set { _acceleration = value; }
} }
public override OMV.Quaternion Orientation { public override OMV.Quaternion Orientation {
get { return _orientation; } get { return _orientation; }
set { set {
_orientation = value; _orientation = value;
// m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation); // m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
@ -332,98 +331,98 @@ public class BSCharacter : BSPhysObject
// _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, _localID); // _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, _localID);
BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation);
}); });
} }
} }
public override int PhysicsActorType { public override int PhysicsActorType {
get { return _physicsActorType; } get { return _physicsActorType; }
set { _physicsActorType = value; set { _physicsActorType = value;
} }
} }
public override bool IsPhysical { public override bool IsPhysical {
get { return _isPhysical; } get { return _isPhysical; }
set { _isPhysical = value; set { _isPhysical = value;
} }
} }
public override bool Flying { public override bool Flying {
get { return _flying; } get { return _flying; }
set { set {
_flying = value; _flying = value;
// simulate flying by changing the effect of gravity // simulate flying by changing the effect of gravity
this.Buoyancy = ComputeBuoyancyFromFlying(_flying); this.Buoyancy = ComputeBuoyancyFromFlying(_flying);
} }
} }
// Flying is implimented by changing the avatar's buoyancy. // Flying is implimented by changing the avatar's buoyancy.
// Would this be done better with a vehicle type? // Would this be done better with a vehicle type?
private float ComputeBuoyancyFromFlying(bool ifFlying) { private float ComputeBuoyancyFromFlying(bool ifFlying) {
return ifFlying ? 1f : 0f; return ifFlying ? 1f : 0f;
} }
public override bool public override bool
SetAlwaysRun { SetAlwaysRun {
get { return _setAlwaysRun; } get { return _setAlwaysRun; }
set { _setAlwaysRun = value; } set { _setAlwaysRun = value; }
} }
public override bool ThrottleUpdates { public override bool ThrottleUpdates {
get { return _throttleUpdates; } get { return _throttleUpdates; }
set { _throttleUpdates = value; } set { _throttleUpdates = value; }
} }
public override bool IsColliding { public override bool IsColliding {
get { return (CollidingStep == PhysicsScene.SimulationStep); } get { return (CollidingStep == PhysicsScene.SimulationStep); }
set { _isColliding = value; } set { _isColliding = value; }
} }
public override bool CollidingGround { public override bool CollidingGround {
get { return (CollidingGroundStep == PhysicsScene.SimulationStep); } get { return (CollidingGroundStep == PhysicsScene.SimulationStep); }
set { CollidingGround = value; } set { CollidingGround = value; }
} }
public override bool CollidingObj { public override bool CollidingObj {
get { return _collidingObj; } get { return _collidingObj; }
set { _collidingObj = value; } set { _collidingObj = value; }
} }
public override bool FloatOnWater { public override bool FloatOnWater {
set { _floatOnWater = value; } set { _floatOnWater = value; }
} }
public override OMV.Vector3 RotationalVelocity { public override OMV.Vector3 RotationalVelocity {
get { return _rotationalVelocity; } get { return _rotationalVelocity; }
set { _rotationalVelocity = value; } set { _rotationalVelocity = value; }
} }
public override bool Kinematic { public override bool Kinematic {
get { return _kinematic; } get { return _kinematic; }
set { _kinematic = value; } set { _kinematic = value; }
} }
// neg=fall quickly, 0=1g, 1=0g, pos=float up // neg=fall quickly, 0=1g, 1=0g, pos=float up
public override float Buoyancy { public override float Buoyancy {
get { return _buoyancy; } get { return _buoyancy; }
set { _buoyancy = value; set { _buoyancy = value;
PhysicsScene.TaintedObject("BSCharacter.setBuoyancy", delegate() PhysicsScene.TaintedObject("BSCharacter.setBuoyancy", delegate()
{ {
DetailLog("{0},BSCharacter.setBuoyancy,taint,buoy={1}", LocalID, _buoyancy); DetailLog("{0},BSCharacter.setBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
BulletSimAPI.SetObjectBuoyancy(PhysicsScene.WorldID, LocalID, _buoyancy); BulletSimAPI.SetObjectBuoyancy(PhysicsScene.WorldID, LocalID, _buoyancy);
}); });
} }
} }
// Used for MoveTo // Used for MoveTo
public override OMV.Vector3 PIDTarget { public override OMV.Vector3 PIDTarget {
set { _PIDTarget = value; } set { _PIDTarget = value; }
} }
public override bool PIDActive { public override bool PIDActive {
set { _usePID = value; } set { _usePID = value; }
} }
public override float PIDTau { public override float PIDTau {
set { _PIDTau = value; } set { _PIDTau = value; }
} }
// Used for llSetHoverHeight and maybe vehicle height // Used for llSetHoverHeight and maybe vehicle height
// Hover Height will override MoveTo target's Z // Hover Height will override MoveTo target's Z
public override bool PIDHoverActive { public override bool PIDHoverActive {
set { _useHoverPID = value; } set { _useHoverPID = value; }
} }
public override float PIDHoverHeight { public override float PIDHoverHeight {
set { _PIDHoverHeight = value; } set { _PIDHoverHeight = value; }
} }
public override PIDHoverType PIDHoverType { public override PIDHoverType PIDHoverType {
set { _PIDHoverType = value; } set { _PIDHoverType = value; }
} }
public override float PIDHoverTau { public override float PIDHoverTau {
set { _PIDHoverTao = value; } set { _PIDHoverTao = value; }
} }
@ -433,7 +432,7 @@ public class BSCharacter : BSPhysObject
public override float APIDStrength { set { return; } } public override float APIDStrength { set { return; } }
public override float APIDDamping { set { return; } } public override float APIDDamping { set { return; } }
public override void AddForce(OMV.Vector3 force, bool pushforce) { public override void AddForce(OMV.Vector3 force, bool pushforce) {
if (force.IsFinite()) if (force.IsFinite())
{ {
_force.X += force.X; _force.X += force.X;
@ -453,9 +452,9 @@ public class BSCharacter : BSPhysObject
//m_lastUpdateSent = false; //m_lastUpdateSent = false;
} }
public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { public override void AddAngularForce(OMV.Vector3 force, bool pushforce) {
} }
public override void SetMomentum(OMV.Vector3 momentum) { public override void SetMomentum(OMV.Vector3 momentum) {
} }
private void ComputeAvatarScale(OMV.Vector3 size) private void ComputeAvatarScale(OMV.Vector3 size)

View File

@ -491,7 +491,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// remember the position so next step we can limit absolute movement effects // remember the position so next step we can limit absolute movement effects
m_lastPositionVector = Prim.Position; m_lastPositionVector = Prim.Position;
VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}",
Prim.LocalID, Prim.Position, Prim.Force, Prim.Velocity, Prim.RotationalVelocity); Prim.LocalID, Prim.Position, Prim.Force, Prim.Velocity, Prim.RotationalVelocity);
}// end Step }// end Step
@ -511,8 +511,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
Vector3 addAmount = (m_linearMotorDirection - m_lastLinearVelocityVector)/(m_linearMotorTimescale / pTimestep); Vector3 addAmount = (m_linearMotorDirection - m_lastLinearVelocityVector)/(m_linearMotorTimescale / pTimestep);
// lastLinearVelocityVector is the current body velocity vector // lastLinearVelocityVector is the current body velocity vector
// RA: Not sure what the *10 is for. A correction for pTimestep? // RA: Not sure what the *10 is for. A correction for pTimestep?
// m_lastLinearVelocityVector += (addAmount*10); // m_lastLinearVelocityVector += (addAmount*10);
m_lastLinearVelocityVector += addAmount; m_lastLinearVelocityVector += addAmount;
// Limit the velocity vector to less than the last set linear motor direction // Limit the velocity vector to less than the last set linear motor direction
if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X)) if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X))
@ -695,7 +695,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
Vector3 keepFraction = Vector3.One - (Vector3.One / (m_linearFrictionTimescale / pTimestep)); Vector3 keepFraction = Vector3.One - (Vector3.One / (m_linearFrictionTimescale / pTimestep));
m_lastLinearVelocityVector *= keepFraction; m_lastLinearVelocityVector *= keepFraction;
VDetailLog("{0},MoveLinear,done,lmDir={1},lmVel={2},newVel={3},grav={4},1Mdecay={5}", VDetailLog("{0},MoveLinear,done,lmDir={1},lmVel={2},newVel={3},grav={4},1Mdecay={5}",
Prim.LocalID, m_linearMotorDirection, m_lastLinearVelocityVector, m_newVelocity, grav, keepFraction); Prim.LocalID, m_linearMotorDirection, m_lastLinearVelocityVector, m_newVelocity, grav, keepFraction);
} // end MoveLinear() } // end MoveLinear()
@ -728,7 +728,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep);
m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep);
VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},angTScale={2},timeStep={3},origvel={4},dir={5},vel={6}", VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},angTScale={2},timeStep={3},origvel={4},dir={5},vel={6}",
Prim.LocalID, m_angularMotorApply, m_angularMotorTimescale, pTimestep, origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity); Prim.LocalID, m_angularMotorApply, m_angularMotorTimescale, pTimestep, origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity);
// This is done so that if script request rate is less than phys frame rate the expected // This is done so that if script request rate is less than phys frame rate the expected
@ -779,7 +779,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
vertattr.X += bounce * angularVelocity.X; vertattr.X += bounce * angularVelocity.X;
vertattr.Y += bounce * angularVelocity.Y; vertattr.Y += bounce * angularVelocity.Y;
VDetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}", VDetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}",
Prim.LocalID, verterr, bounce, vertattr); Prim.LocalID, verterr, bounce, vertattr);
} // else vertical attractor is off } // else vertical attractor is off
@ -792,7 +792,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// Sum velocities // Sum velocities
m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection
if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0) if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0)
{ {
m_lastAngularVelocity.X = 0; m_lastAngularVelocity.X = 0;

View File

@ -53,9 +53,9 @@ public class BSLinkset
// We keep the prim's mass in the linkset structure since it could be dependent on other prims // We keep the prim's mass in the linkset structure since it could be dependent on other prims
private float m_mass; private float m_mass;
public float LinksetMass public float LinksetMass
{ {
get get
{ {
m_mass = ComputeLinksetMass(); m_mass = ComputeLinksetMass();
return m_mass; return m_mass;
@ -77,7 +77,7 @@ public class BSLinkset
// A simple linkset of one (no children) // A simple linkset of one (no children)
LinksetID = m_nextLinksetID++; LinksetID = m_nextLinksetID++;
// We create LOTS of linksets. // We create LOTS of linksets.
if (m_nextLinksetID <= 0) if (m_nextLinksetID <= 0)
m_nextLinksetID = 1; m_nextLinksetID = 1;
PhysicsScene = scene; PhysicsScene = scene;
LinksetRoot = parent; LinksetRoot = parent;
@ -276,7 +276,7 @@ public class BSLinkset
BSConstraint constrain; BSConstraint constrain;
if (PhysicsScene.Constraints.TryGetConstraint(LinksetRoot.BSBody, child.BSBody, out constrain)) if (PhysicsScene.Constraints.TryGetConstraint(LinksetRoot.BSBody, child.BSBody, out constrain))
{ {
// DetailLog("{0},BSLinkset.RecomputeLinksetConstraintVariables,taint,child={1},mass={2},A={3},B={4}", // DetailLog("{0},BSLinkset.RecomputeLinksetConstraintVariables,taint,child={1},mass={2},A={3},B={4}",
// LinksetRoot.LocalID, child.LocalID, linksetMass, constrain.Body1.ID, constrain.Body2.ID); // LinksetRoot.LocalID, child.LocalID, linksetMass, constrain.Body1.ID, constrain.Body2.ID);
constrain.RecomputeConstraintVariables(linksetMass); constrain.RecomputeConstraintVariables(linksetMass);
} }
@ -392,14 +392,14 @@ public class BSLinkset
// create a constraint that allows no freedom of movement between the two objects // create a constraint that allows no freedom of movement between the two objects
// http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818
DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}",
rootPrim.LocalID, rootPrim.LocalID,
rootPrim.LocalID, rootBody.ptr.ToString("X"), rootPrim.LocalID, rootBody.ptr.ToString("X"),
childPrim.LocalID, childBody.ptr.ToString("X"), childPrim.LocalID, childBody.ptr.ToString("X"),
rootPrim.Position, childPrim.Position, midPoint); rootPrim.Position, childPrim.Position, midPoint);
// There is great subtlty in these paramters. Notice the check for a ptr of zero. // There is great subtlty in these paramters. Notice the check for a ptr of zero.
// We pass the BulletBody structure into the taint in order to capture the pointer // We pass the BulletBody structure into the taint in order to capture the pointer
// of the body at the time of constraint creation. This doesn't work for the very first // of the body at the time of constraint creation. This doesn't work for the very first
// construction because there is no body yet. The body // construction because there is no body yet. The body
// is constructed later at taint time. Thus we use the body address at time of the // is constructed later at taint time. Thus we use the body address at time of the
@ -409,8 +409,8 @@ public class BSLinkset
// to only change BSShape at taint time thus syncronizing these operations at // to only change BSShape at taint time thus syncronizing these operations at
// the cost of efficiency and lag. // the cost of efficiency and lag.
BS6DofConstraint constrain = new BS6DofConstraint( BS6DofConstraint constrain = new BS6DofConstraint(
PhysicsScene.World, PhysicsScene.World,
rootBody.ptr == IntPtr.Zero ? rootPrim.BSBody : rootBody, rootBody.ptr == IntPtr.Zero ? rootPrim.BSBody : rootBody,
childBody.ptr == IntPtr.Zero ? childPrim.BSBody : childBody, childBody.ptr == IntPtr.Zero ? childPrim.BSBody : childBody,
midPoint, midPoint,
true, true,
@ -473,11 +473,11 @@ public class BSLinkset
// The root and child bodies are passed in because we need to remove the constraint between // The root and child bodies are passed in because we need to remove the constraint between
// the bodies that were at unlink time. // the bodies that were at unlink time.
// Called at taint time! // Called at taint time!
private void PhysicallyUnlinkAChildFromRoot(BSPhysObject rootPrim, BulletBody rootBody, private void PhysicallyUnlinkAChildFromRoot(BSPhysObject rootPrim, BulletBody rootBody,
BSPhysObject childPrim, BulletBody childBody) BSPhysObject childPrim, BulletBody childBody)
{ {
DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},rBody={2},child={3},cBody={4}", DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},rBody={2},child={3},cBody={4}",
rootPrim.LocalID, rootPrim.LocalID,
rootPrim.LocalID, rootBody.ptr.ToString("X"), rootPrim.LocalID, rootBody.ptr.ToString("X"),
childPrim.LocalID, childBody.ptr.ToString("X")); childPrim.LocalID, childBody.ptr.ToString("X"));

View File

@ -100,7 +100,7 @@ public abstract class BSPhysObject : PhysicsActor
// The simulation step is telling this object about a collision. // The simulation step is telling this object about a collision.
// Return 'true' if a collision was processed and should be sent up. // Return 'true' if a collision was processed and should be sent up.
// Called at taint time from within the Step() function // Called at taint time from within the Step() function
public virtual bool Collide(uint collidingWith, BSPhysObject collidee, public virtual bool Collide(uint collidingWith, BSPhysObject collidee,
OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
{ {
bool ret = false; bool ret = false;

View File

@ -33,7 +33,7 @@ using OpenMetaverse;
namespace OpenSim.Region.Physics.BulletSPlugin namespace OpenSim.Region.Physics.BulletSPlugin
{ {
/// <summary> /// <summary>
/// Entry for a port of Bullet (http://bulletphysics.org/) to OpenSim. /// Entry for a port of Bullet (http://bulletphysics.org/) to OpenSim.
/// This module interfaces to an unmanaged C++ library which makes the /// This module interfaces to an unmanaged C++ library which makes the
/// actual calls into the Bullet physics engine. /// actual calls into the Bullet physics engine.
/// The unmanaged library is found in opensim-libs::trunk/unmanaged/BulletSim/. /// The unmanaged library is found in opensim-libs::trunk/unmanaged/BulletSim/.
@ -62,7 +62,7 @@ public class BSPlugin : IPhysicsPlugin
if (Util.IsWindows()) if (Util.IsWindows())
Util.LoadArchSpecificWindowsDll("BulletSim.dll"); Util.LoadArchSpecificWindowsDll("BulletSim.dll");
// If not Windows, loading is performed by the // If not Windows, loading is performed by the
// Mono loader as specified in // Mono loader as specified in
// "bin/Physics/OpenSim.Region.Physics.BulletSPlugin.dll.config". // "bin/Physics/OpenSim.Region.Physics.BulletSPlugin.dll.config".
_mScene = new BSScene(sceneIdentifier); _mScene = new BSScene(sceneIdentifier);

View File

@ -158,12 +158,12 @@ public sealed class BSPrim : BSPhysObject
BulletSimAPI.DestroyObject(PhysicsScene.WorldID, LocalID); BulletSimAPI.DestroyObject(PhysicsScene.WorldID, LocalID);
}); });
} }
public override bool Stopped { public override bool Stopped {
get { return _stopped; } get { return _stopped; }
} }
public override OMV.Vector3 Size { public override OMV.Vector3 Size {
get { return _size; } get { return _size; }
set { set {
_size = value; _size = value;
PhysicsScene.TaintedObject("BSPrim.setSize", delegate() PhysicsScene.TaintedObject("BSPrim.setSize", delegate()
@ -174,7 +174,7 @@ public sealed class BSPrim : BSPhysObject
CreateGeomAndObject(true); CreateGeomAndObject(true);
// DetailLog("{0},BSPrim.setSize,size={1},scale={2},mass={3},physical={4}", LocalID, _size, _scale, _mass, IsPhysical); // DetailLog("{0},BSPrim.setSize,size={1},scale={2},mass={3},physical={4}", LocalID, _size, _scale, _mass, IsPhysical);
}); });
} }
} }
// Scale is what we set in the physics engine. It is different than 'size' in that // Scale is what we set in the physics engine. It is different than 'size' in that
// 'size' can be encorporated into the mesh. In that case, the scale is <1,1,1>. // 'size' can be encorporated into the mesh. In that case, the scale is <1,1,1>.
@ -183,7 +183,7 @@ public sealed class BSPrim : BSPhysObject
get { return _scale; } get { return _scale; }
set { _scale = value; } set { _scale = value; }
} }
public override PrimitiveBaseShape Shape { public override PrimitiveBaseShape Shape {
set { set {
_pbs = value; _pbs = value;
PhysicsScene.TaintedObject("BSPrim.setShape", delegate() PhysicsScene.TaintedObject("BSPrim.setShape", delegate()
@ -191,13 +191,13 @@ public sealed class BSPrim : BSPhysObject
_mass = CalculateMass(); // changing the shape changes the mass _mass = CalculateMass(); // changing the shape changes the mass
CreateGeomAndObject(true); CreateGeomAndObject(true);
}); });
} }
} }
public override bool Grabbed { public override bool Grabbed {
set { _grabbed = value; set { _grabbed = value;
} }
} }
public override bool Selected { public override bool Selected {
set { set {
_isSelected = value; _isSelected = value;
PhysicsScene.TaintedObject("BSPrim.setSelected", delegate() PhysicsScene.TaintedObject("BSPrim.setSelected", delegate()
@ -205,7 +205,7 @@ public sealed class BSPrim : BSPhysObject
// DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected); // DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected);
SetObjectDynamic(false); SetObjectDynamic(false);
}); });
} }
} }
public override void CrossingFailure() { return; } public override void CrossingFailure() { return; }
@ -219,10 +219,10 @@ public sealed class BSPrim : BSPhysObject
Linkset = parent.Linkset.AddMeToLinkset(this); Linkset = parent.Linkset.AddMeToLinkset(this);
DetailLog("{0},BSPrim.link,call,parentBefore={1}, childrenBefore=={2}, parentAfter={3}, childrenAfter={4}", DetailLog("{0},BSPrim.link,call,parentBefore={1}, childrenBefore=={2}, parentAfter={3}, childrenAfter={4}",
LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren); LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren);
} }
return; return;
} }
// delink me from my linkset // delink me from my linkset
@ -232,12 +232,12 @@ public sealed class BSPrim : BSPhysObject
BSPhysObject parentBefore = Linkset.LinksetRoot; BSPhysObject parentBefore = Linkset.LinksetRoot;
int childrenBefore = Linkset.NumberOfChildren; int childrenBefore = Linkset.NumberOfChildren;
Linkset = Linkset.RemoveMeFromLinkset(this); Linkset = Linkset.RemoveMeFromLinkset(this);
DetailLog("{0},BSPrim.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ", DetailLog("{0},BSPrim.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ",
LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren); LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren);
return; return;
} }
// Set motion values to zero. // Set motion values to zero.
@ -258,21 +258,21 @@ public sealed class BSPrim : BSPhysObject
} }
public override void LockAngularMotion(OMV.Vector3 axis) public override void LockAngularMotion(OMV.Vector3 axis)
{ {
DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis);
return; return;
} }
public override OMV.Vector3 Position { public override OMV.Vector3 Position {
get { get {
if (!Linkset.IsRoot(this)) if (!Linkset.IsRoot(this))
// child prims move around based on their parent. Need to get the latest location // child prims move around based on their parent. Need to get the latest location
_position = BulletSimAPI.GetPosition2(BSBody.ptr); _position = BulletSimAPI.GetPosition2(BSBody.ptr);
// don't do the GetObjectPosition for root elements because this function is called a zillion times // don't do the GetObjectPosition for root elements because this function is called a zillion times
// _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr);
return _position; return _position;
} }
set { set {
_position = value; _position = value;
// TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint?
@ -281,13 +281,13 @@ public sealed class BSPrim : BSPhysObject
// DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); // DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation);
}); });
} }
} }
// Return the effective mass of the object. // Return the effective mass of the object.
// If there are multiple items in the linkset, add them together for the root // If there are multiple items in the linkset, add them together for the root
public override float Mass public override float Mass
{ {
get get
{ {
// return Linkset.LinksetMass; // return Linkset.LinksetMass;
@ -310,8 +310,8 @@ public sealed class BSPrim : BSPhysObject
get { return Linkset.GeometricCenter; } get { return Linkset.GeometricCenter; }
} }
public override OMV.Vector3 Force { public override OMV.Vector3 Force {
get { return _force; } get { return _force; }
set { set {
_force = value; _force = value;
PhysicsScene.TaintedObject("BSPrim.setForce", delegate() PhysicsScene.TaintedObject("BSPrim.setForce", delegate()
@ -319,13 +319,13 @@ public sealed class BSPrim : BSPhysObject
// DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force); // DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force);
BulletSimAPI.SetObjectForce2(BSBody.ptr, _force); BulletSimAPI.SetObjectForce2(BSBody.ptr, _force);
}); });
} }
} }
public override int VehicleType { public override int VehicleType {
get { get {
return (int)_vehicle.Type; // if we are a vehicle, return that type return (int)_vehicle.Type; // if we are a vehicle, return that type
} }
set { set {
Vehicle type = (Vehicle)value; Vehicle type = (Vehicle)value;
BSPrim vehiclePrim = this; BSPrim vehiclePrim = this;
@ -337,30 +337,30 @@ public sealed class BSPrim : BSPhysObject
// Tell the scene about the vehicle so it will get processing each frame. // Tell the scene about the vehicle so it will get processing each frame.
PhysicsScene.VehicleInSceneTypeChanged(this, type); PhysicsScene.VehicleInSceneTypeChanged(this, type);
}); });
} }
} }
public override void VehicleFloatParam(int param, float value) public override void VehicleFloatParam(int param, float value)
{ {
PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
{ {
_vehicle.ProcessFloatVehicleParam((Vehicle)param, value); _vehicle.ProcessFloatVehicleParam((Vehicle)param, value);
}); });
} }
public override void VehicleVectorParam(int param, OMV.Vector3 value) public override void VehicleVectorParam(int param, OMV.Vector3 value)
{ {
PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
{ {
_vehicle.ProcessVectorVehicleParam((Vehicle)param, value); _vehicle.ProcessVectorVehicleParam((Vehicle)param, value);
}); });
} }
public override void VehicleRotationParam(int param, OMV.Quaternion rotation) public override void VehicleRotationParam(int param, OMV.Quaternion rotation)
{ {
PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
{ {
_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); _vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation);
}); });
} }
public override void VehicleFlags(int param, bool remove) public override void VehicleFlags(int param, bool remove)
{ {
PhysicsScene.TaintedObject("BSPrim.VehicleFlags", delegate() PhysicsScene.TaintedObject("BSPrim.VehicleFlags", delegate()
{ {
@ -388,11 +388,11 @@ public sealed class BSPrim : BSPhysObject
SetObjectDynamic(true); SetObjectDynamic(true);
}); });
} }
return; return;
} }
public override OMV.Vector3 Velocity { public override OMV.Vector3 Velocity {
get { return _velocity; } get { return _velocity; }
set { set {
_velocity = value; _velocity = value;
PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate() PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate()
@ -400,24 +400,24 @@ public sealed class BSPrim : BSPhysObject
// DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity); // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity);
BulletSimAPI.SetLinearVelocity2(BSBody.ptr, _velocity); BulletSimAPI.SetLinearVelocity2(BSBody.ptr, _velocity);
}); });
} }
} }
public override OMV.Vector3 Torque { public override OMV.Vector3 Torque {
get { return _torque; } get { return _torque; }
set { _torque = value; set { _torque = value;
// DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque);
} }
} }
public override float CollisionScore { public override float CollisionScore {
get { return _collisionScore; } get { return _collisionScore; }
set { _collisionScore = value; set { _collisionScore = value;
} }
} }
public override OMV.Vector3 Acceleration { public override OMV.Vector3 Acceleration {
get { return _acceleration; } get { return _acceleration; }
set { _acceleration = value; } set { _acceleration = value; }
} }
public override OMV.Quaternion Orientation { public override OMV.Quaternion Orientation {
get { get {
if (!Linkset.IsRoot(this)) if (!Linkset.IsRoot(this))
{ {
@ -425,7 +425,7 @@ public sealed class BSPrim : BSPhysObject
_orientation = BulletSimAPI.GetOrientation2(BSBody.ptr); _orientation = BulletSimAPI.GetOrientation2(BSBody.ptr);
} }
return _orientation; return _orientation;
} }
set { set {
_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?
@ -435,14 +435,14 @@ public sealed class BSPrim : BSPhysObject
// 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(BSBody.ptr, _position, _orientation); BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation);
}); });
} }
} }
public override int PhysicsActorType { public override int PhysicsActorType {
get { return _physicsActorType; } get { return _physicsActorType; }
set { _physicsActorType = value; } set { _physicsActorType = value; }
} }
public override bool IsPhysical { public override bool IsPhysical {
get { return _isPhysical; } get { return _isPhysical; }
set { set {
if (_isPhysical != value) if (_isPhysical != value)
{ {
@ -453,7 +453,7 @@ public sealed class BSPrim : BSPhysObject
SetObjectDynamic(true); SetObjectDynamic(true);
}); });
} }
} }
} }
// An object is static (does not move) if selected or not physical // An object is static (does not move) if selected or not physical
@ -519,7 +519,7 @@ public sealed class BSPrim : BSPhysObject
// had been automatically disabled when the mass was set to zero. // had been automatically disabled when the mass was set to zero.
Linkset.Refresh(this); Linkset.Refresh(this);
DetailLog("{0},BSPrim.UpdatePhysicalParameters,exit,static={1},solid={2},mass={3},collide={4},cf={5:X},body={6},shape={7}", DetailLog("{0},BSPrim.UpdatePhysicalParameters,exit,static={1},solid={2},mass={3},collide={4},cf={5:X},body={6},shape={7}",
LocalID, IsStatic, IsSolid, _mass, SubscribedEvents(), CurrentCollisionFlags, BSBody, BSShape); LocalID, IsStatic, IsSolid, _mass, SubscribedEvents(), CurrentCollisionFlags, BSBody, BSShape);
} }
@ -630,31 +630,31 @@ public sealed class BSPrim : BSPhysObject
} }
// prims don't fly // prims don't fly
public override bool Flying { public override bool Flying {
get { return _flying; } get { return _flying; }
set { set {
_flying = value; _flying = value;
} }
} }
public override bool SetAlwaysRun { public override bool SetAlwaysRun {
get { return _setAlwaysRun; } get { return _setAlwaysRun; }
set { _setAlwaysRun = value; } set { _setAlwaysRun = value; }
} }
public override bool ThrottleUpdates { public override bool ThrottleUpdates {
get { return _throttleUpdates; } get { return _throttleUpdates; }
set { _throttleUpdates = value; } set { _throttleUpdates = value; }
} }
public override bool IsColliding { public override bool IsColliding {
get { return (CollidingStep == PhysicsScene.SimulationStep); } get { return (CollidingStep == PhysicsScene.SimulationStep); }
set { _isColliding = value; } set { _isColliding = value; }
} }
public override bool CollidingGround { public override bool CollidingGround {
get { return (CollidingGroundStep == PhysicsScene.SimulationStep); } get { return (CollidingGroundStep == PhysicsScene.SimulationStep); }
set { _collidingGround = value; } set { _collidingGround = value; }
} }
public override bool CollidingObj { public override bool CollidingObj {
get { return _collidingObj; } get { return _collidingObj; }
set { _collidingObj = value; } set { _collidingObj = value; }
} }
public bool IsPhantom { public bool IsPhantom {
get { get {
@ -664,10 +664,10 @@ public sealed class BSPrim : BSPhysObject
return false; return false;
} }
} }
public override bool FloatOnWater { public override bool FloatOnWater {
set { _floatOnWater = value; } set { _floatOnWater = value; }
} }
public override OMV.Vector3 RotationalVelocity { public override OMV.Vector3 RotationalVelocity {
get { get {
/* /*
OMV.Vector3 pv = OMV.Vector3.Zero; OMV.Vector3 pv = OMV.Vector3.Zero;
@ -679,7 +679,7 @@ public sealed class BSPrim : BSPhysObject
*/ */
return _rotationalVelocity; return _rotationalVelocity;
} }
set { set {
_rotationalVelocity = value; _rotationalVelocity = value;
// m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
@ -688,16 +688,16 @@ public sealed class BSPrim : BSPhysObject
// DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); // DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
BulletSimAPI.SetAngularVelocity2(BSBody.ptr, _rotationalVelocity); BulletSimAPI.SetAngularVelocity2(BSBody.ptr, _rotationalVelocity);
}); });
} }
} }
public override bool Kinematic { public override bool Kinematic {
get { return _kinematic; } get { return _kinematic; }
set { _kinematic = value; set { _kinematic = value;
// m_log.DebugFormat("{0}: Kinematic={1}", LogHeader, _kinematic); // m_log.DebugFormat("{0}: Kinematic={1}", LogHeader, _kinematic);
} }
} }
public override float Buoyancy { public override float Buoyancy {
get { return _buoyancy; } get { return _buoyancy; }
set { set {
_buoyancy = value; _buoyancy = value;
PhysicsScene.TaintedObject("BSPrim.setBuoyancy", delegate() PhysicsScene.TaintedObject("BSPrim.setBuoyancy", delegate()
@ -707,32 +707,32 @@ public sealed class BSPrim : BSPhysObject
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav)); BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav));
}); });
} }
} }
// Used for MoveTo // Used for MoveTo
public override OMV.Vector3 PIDTarget { public override OMV.Vector3 PIDTarget {
set { _PIDTarget = value; } set { _PIDTarget = value; }
} }
public override bool PIDActive { public override bool PIDActive {
set { _usePID = value; } set { _usePID = value; }
} }
public override float PIDTau { public override float PIDTau {
set { _PIDTau = value; } set { _PIDTau = value; }
} }
// Used for llSetHoverHeight and maybe vehicle height // Used for llSetHoverHeight and maybe vehicle height
// Hover Height will override MoveTo target's Z // Hover Height will override MoveTo target's Z
public override bool PIDHoverActive { public override bool PIDHoverActive {
set { _useHoverPID = value; } set { _useHoverPID = value; }
} }
public override float PIDHoverHeight { public override float PIDHoverHeight {
set { _PIDHoverHeight = value; } set { _PIDHoverHeight = value; }
} }
public override PIDHoverType PIDHoverType { public override PIDHoverType PIDHoverType {
set { _PIDHoverType = value; } set { _PIDHoverType = value; }
} }
public override float PIDHoverTau { public override float PIDHoverTau {
set { _PIDHoverTao = value; } set { _PIDHoverTao = value; }
} }
@ -773,11 +773,11 @@ public sealed class BSPrim : BSPhysObject
}); });
} }
public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { public override void AddAngularForce(OMV.Vector3 force, bool pushforce) {
// DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce); // DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce);
// m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce); // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce);
} }
public override void SetMomentum(OMV.Vector3 momentum) { public override void SetMomentum(OMV.Vector3 momentum) {
// DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum);
} }
#region Mass Calculation #region Mass Calculation
@ -789,8 +789,8 @@ public sealed class BSPrim : BSPhysObject
float returnMass = 0; float returnMass = 0;
float hollowAmount = (float)_pbs.ProfileHollow * 2.0e-5f; float hollowAmount = (float)_pbs.ProfileHollow * 2.0e-5f;
float hollowVolume = hollowAmount * hollowAmount; float hollowVolume = hollowAmount * hollowAmount;
switch (_pbs.ProfileShape) switch (_pbs.ProfileShape)
{ {
case ProfileShape.Square: case ProfileShape.Square:
@ -826,16 +826,16 @@ public sealed class BSPrim : BSPhysObject
else if (_pbs.PathCurve == (byte)Extrusion.Curve1) else if (_pbs.PathCurve == (byte)Extrusion.Curve1)
{ {
//a tube //a tube
volume *= 0.78539816339e-2f * (float)(200 - _pbs.PathScaleX); volume *= 0.78539816339e-2f * (float)(200 - _pbs.PathScaleX);
tmp= 1.0f -2.0e-2f * (float)(200 - _pbs.PathScaleY); tmp= 1.0f -2.0e-2f * (float)(200 - _pbs.PathScaleY);
volume -= volume*tmp*tmp; volume -= volume*tmp*tmp;
if (hollowAmount > 0.0) if (hollowAmount > 0.0)
{ {
hollowVolume *= hollowAmount; hollowVolume *= hollowAmount;
switch (_pbs.HollowShape) switch (_pbs.HollowShape)
{ {
case HollowShape.Square: case HollowShape.Square:
@ -894,7 +894,7 @@ public sealed class BSPrim : BSPhysObject
volume *= 0.61685027506808491367715568749226e-2f * (float)(200 - _pbs.PathScaleX); volume *= 0.61685027506808491367715568749226e-2f * (float)(200 - _pbs.PathScaleX);
tmp = 1.0f - .02f * (float)(200 - _pbs.PathScaleY); tmp = 1.0f - .02f * (float)(200 - _pbs.PathScaleY);
volume *= (1.0f - tmp * tmp); volume *= (1.0f - tmp * tmp);
if (hollowAmount > 0.0) if (hollowAmount > 0.0)
{ {
@ -1118,7 +1118,7 @@ public sealed class BSPrim : BSPhysObject
PhysicsScene.Shapes.GetBodyAndShape(forceRebuild, PhysicsScene.World, this, shapeData, _pbs); PhysicsScene.Shapes.GetBodyAndShape(forceRebuild, PhysicsScene.World, this, shapeData, _pbs);
Linkset = Linkset.AddMeToLinkset(this); Linkset = Linkset.AddMeToLinkset(this);
// Make sure the properties are set on the new object // Make sure the properties are set on the new object
UpdatePhysicalParameters(); UpdatePhysicalParameters();
return; return;
@ -1210,7 +1210,7 @@ public sealed class BSPrim : BSPhysObject
{ {
// For debugging, we can also report the movement of children // For debugging, we can also report the movement of children
DetailLog("{0},BSPrim.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}", DetailLog("{0},BSPrim.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, LocalID, entprop.Position, entprop.Rotation, entprop.Velocity,
entprop.Acceleration, entprop.RotationalVelocity); entprop.Acceleration, entprop.RotationalVelocity);
} }
*/ */

View File

@ -49,7 +49,7 @@ using OpenMetaverse;
// At the moment, physical and phantom causes object to drop through the terrain // At the moment, physical and phantom causes object to drop through the terrain
// Physical phantom objects and related typing (collision options ) // Physical phantom objects and related typing (collision options )
// Check out llVolumeDetect. Must do something for that. // Check out llVolumeDetect. Must do something for that.
// Use collision masks for collision with terrain and phantom objects // Use collision masks for collision with terrain and phantom objects
// More efficient memory usage when passing hull information from BSPrim to BulletSim // More efficient memory usage when passing hull information from BSPrim to BulletSim
// Should prim.link() and prim.delink() membership checking happen at taint time? // Should prim.link() and prim.delink() membership checking happen at taint time?
// Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once. // Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once.
@ -60,7 +60,7 @@ using OpenMetaverse;
// Add PID movement operations. What does ScenePresence.MoveToTarget do? // Add PID movement operations. What does ScenePresence.MoveToTarget do?
// Check terrain size. 128 or 127? // Check terrain size. 128 or 127?
// Raycast // Raycast
// //
namespace OpenSim.Region.Physics.BulletSPlugin namespace OpenSim.Region.Physics.BulletSPlugin
{ {
public class BSScene : PhysicsScene, IPhysicsParameters public class BSScene : PhysicsScene, IPhysicsParameters
@ -327,7 +327,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
{ {
m_log.Debug("[BULLETS UNMANAGED]:" + msg); m_log.Debug("[BULLETS UNMANAGED]:" + msg);
} }
// Called directly from unmanaged code so don't do much // Called directly from unmanaged code so don't do much
private void BulletLoggerPhysLog(string msg) private void BulletLoggerPhysLog(string msg)
{ {
@ -460,7 +460,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
} }
// This is a call from the simulator saying that some physical property has been updated. // This is a call from the simulator saying that some physical property has been updated.
// The BulletSim driver senses the changing of relevant properties so this taint // The BulletSim driver senses the changing of relevant properties so this taint
// information call is not needed. // information call is not needed.
public override void AddPhysicsActorTaint(PhysicsActor prim) { } public override void AddPhysicsActorTaint(PhysicsActor prim) { }
@ -501,14 +501,14 @@ public class BSScene : PhysicsScene, IPhysicsParameters
out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr); out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr);
if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime); if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime);
DetailLog("{0},Simulate,call, nTaints={1}, simTime={2}, substeps={3}, updates={4}, colliders={5}", DetailLog("{0},Simulate,call, nTaints={1}, simTime={2}, substeps={3}, updates={4}, colliders={5}",
DetailLogZero, numTaints, simTime, numSubSteps, updatedEntityCount, collidersCount); DetailLogZero, numTaints, simTime, numSubSteps, updatedEntityCount, collidersCount);
} }
catch (Exception e) catch (Exception e)
{ {
m_log.WarnFormat("{0},PhysicsStep Exception: nTaints={1}, substeps={2}, updates={3}, colliders={4}, e={5}", m_log.WarnFormat("{0},PhysicsStep Exception: nTaints={1}, substeps={2}, updates={3}, colliders={4}, e={5}",
LogHeader, numTaints, numSubSteps, updatedEntityCount, collidersCount, e); LogHeader, numTaints, numSubSteps, updatedEntityCount, collidersCount, e);
DetailLog("{0},PhysicsStepException,call, nTaints={1}, substeps={2}, updates={3}, colliders={4}", DetailLog("{0},PhysicsStepException,call, nTaints={1}, substeps={2}, updates={3}, colliders={4}",
DetailLogZero, numTaints, numSubSteps, updatedEntityCount, collidersCount); DetailLogZero, numTaints, numSubSteps, updatedEntityCount, collidersCount);
updatedEntityCount = 0; updatedEntityCount = 0;
collidersCount = 0; collidersCount = 0;
@ -535,7 +535,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
} }
} }
// This is a kludge to get avatar movement updates. // This is a kludge to get avatar movement updates.
// ODE sends collisions for avatars even if there are have been no collisions. This updates // ODE sends collisions for avatars even if there are have been no collisions. This updates
// avatar animations and stuff. // avatar animations and stuff.
// If you fix avatar animation updates, remove this overhead and let normal collision processing happen. // If you fix avatar animation updates, remove this overhead and let normal collision processing happen.
@ -634,7 +634,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
TerrainManager.SetTerrain(heightMap); TerrainManager.SetTerrain(heightMap);
} }
public override void SetWaterLevel(float baseheight) public override void SetWaterLevel(float baseheight)
{ {
m_waterLevel = baseheight; m_waterLevel = baseheight;
} }
@ -644,7 +644,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
return m_waterLevel; return m_waterLevel;
} }
public override void DeleteTerrain() public override void DeleteTerrain()
{ {
// m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader); // m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader);
} }
@ -806,7 +806,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
// getters and setters. // getters and setters.
// It is easiest to find an existing definition and copy it. // It is easiest to find an existing definition and copy it.
// Parameter values are floats. Booleans are converted to a floating value. // Parameter values are floats. Booleans are converted to a floating value.
// //
// A ParameterDefn() takes the following parameters: // A ParameterDefn() takes the following parameters:
// -- the text name of the parameter. This is used for console input and ini file. // -- the text name of the parameter. This is used for console input and ini file.
// -- a short text description of the parameter. This shows up in the console listing. // -- a short text description of the parameter. This shows up in the console listing.
@ -1228,7 +1228,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
} }
}); });
break; break;
default: default:
// setting only one localID // setting only one localID
TaintedUpdateParameter(parm, localID, val); TaintedUpdateParameter(parm, localID, val);
break; break;

View File

@ -102,7 +102,7 @@ public class BSShapeCollection : IDisposable
bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, prim.BSShape, shapeData); bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, prim.BSShape, shapeData);
ret = newGeom || newBody; ret = newGeom || newBody;
} }
DetailLog("{0},BSShapeCollection.GetBodyAndShape,force={1},ret={2},body={3},shape={4}", DetailLog("{0},BSShapeCollection.GetBodyAndShape,force={1},ret={2},body={3},shape={4}",
prim.LocalID, forceRebuild, ret, prim.BSBody, prim.BSShape); prim.LocalID, forceRebuild, ret, prim.BSBody, prim.BSShape);
return ret; return ret;
@ -149,14 +149,14 @@ public class BSShapeCollection : IDisposable
bodyDesc.lastReferenced = System.DateTime.Now; bodyDesc.lastReferenced = System.DateTime.Now;
Bodies[shape.ID] = bodyDesc; Bodies[shape.ID] = bodyDesc;
DetailLog("{0},BSShapeCollection.DereferenceBody,ref={1}", shape.ID, bodyDesc.referenceCount); DetailLog("{0},BSShapeCollection.DereferenceBody,ref={1}", shape.ID, bodyDesc.referenceCount);
// If body is no longer being used, free it -- bodies are never shared. // If body is no longer being used, free it -- bodies are never shared.
if (bodyDesc.referenceCount == 0) if (bodyDesc.referenceCount == 0)
{ {
Bodies.Remove(shape.ID); Bodies.Remove(shape.ID);
BSScene.TaintCallback removeOperation = delegate() BSScene.TaintCallback removeOperation = delegate()
{ {
DetailLog("{0},BSShapeCollection.DereferenceBody,DestroyingBody. ptr={1}", DetailLog("{0},BSShapeCollection.DereferenceBody,DestroyingBody. ptr={1}",
shape.ID, shape.ptr.ToString("X")); shape.ID, shape.ptr.ToString("X"));
// Zero any reference to the shape so it is not freed when the body is deleted. // Zero any reference to the shape so it is not freed when the body is deleted.
BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, shape.ptr, IntPtr.Zero); BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, shape.ptr, IntPtr.Zero);
@ -344,28 +344,28 @@ public class BSShapeCollection : IDisposable
if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1) if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1)
{ {
haveShape = true; haveShape = true;
if (forceRebuild if (forceRebuild
|| prim.Scale != shapeData.Size || prim.Scale != shapeData.Size
|| prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_SPHERE || prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_SPHERE
) )
{ {
ret = GetReferenceToNativeShape(prim, shapeData, ret = GetReferenceToNativeShape(prim, shapeData,
ShapeData.PhysicsShapeType.SHAPE_SPHERE, ShapeData.FixedShapeKey.KEY_SPHERE); ShapeData.PhysicsShapeType.SHAPE_SPHERE, ShapeData.FixedShapeKey.KEY_SPHERE);
DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},shape={2}", DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},shape={2}",
prim.LocalID, forceRebuild, prim.BSShape); prim.LocalID, forceRebuild, prim.BSShape);
} }
} }
else else
{ {
haveShape = true; haveShape = true;
if (forceRebuild if (forceRebuild
|| prim.Scale != shapeData.Size || prim.Scale != shapeData.Size
|| prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_BOX || prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_BOX
) )
{ {
ret = GetReferenceToNativeShape( ret = GetReferenceToNativeShape(
prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_BOX, ShapeData.FixedShapeKey.KEY_BOX); prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_BOX, ShapeData.FixedShapeKey.KEY_BOX);
DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},shape={2}", DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},shape={2}",
prim.LocalID, forceRebuild, prim.BSShape); prim.LocalID, forceRebuild, prim.BSShape);
} }
} }
@ -379,13 +379,13 @@ public class BSShapeCollection : IDisposable
{ {
// Update prim.BSShape to reference a hull of this shape. // Update prim.BSShape to reference a hull of this shape.
ret = GetReferenceToHull(prim, shapeData, pbs); ret = GetReferenceToHull(prim, shapeData, pbs);
DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1},key={2}", DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1},key={2}",
shapeData.ID, prim.BSShape, prim.BSShape.shapeKey.ToString("X")); shapeData.ID, prim.BSShape, prim.BSShape.shapeKey.ToString("X"));
} }
else else
{ {
ret = GetReferenceToMesh(prim, shapeData, pbs); ret = GetReferenceToMesh(prim, shapeData, pbs);
DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1},key={2}", DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1},key={2}",
shapeData.ID, prim.BSShape, prim.BSShape.shapeKey.ToString("X")); shapeData.ID, prim.BSShape, prim.BSShape.shapeKey.ToString("X"));
} }
} }
@ -393,7 +393,7 @@ public class BSShapeCollection : IDisposable
} }
// Creates a native shape and assignes it to prim.BSShape // Creates a native shape and assignes it to prim.BSShape
private bool GetReferenceToNativeShape( BSPrim prim, ShapeData shapeData, private bool GetReferenceToNativeShape( BSPrim prim, ShapeData shapeData,
ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey) ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey)
{ {
BulletShape newShape; BulletShape newShape;
@ -432,7 +432,7 @@ public class BSShapeCollection : IDisposable
// if this new shape is the same as last time, don't recreate the mesh // if this new shape is the same as last time, don't recreate the mesh
if (prim.BSShape.shapeKey == newMeshKey) return false; if (prim.BSShape.shapeKey == newMeshKey) return false;
DetailLog("{0},BSShapeCollection.CreateGeomMesh,create,oldKey={1},newKey={2}", DetailLog("{0},BSShapeCollection.CreateGeomMesh,create,oldKey={1},newKey={2}",
prim.LocalID, prim.BSShape.shapeKey.ToString("X"), newMeshKey.ToString("X")); prim.LocalID, prim.BSShape.shapeKey.ToString("X"), newMeshKey.ToString("X"));
// Since we're recreating new, get rid of the reference to the previous shape // Since we're recreating new, get rid of the reference to the previous shape
@ -476,10 +476,10 @@ public class BSShapeCollection : IDisposable
verticesAsFloats[vi++] = vv.Z; verticesAsFloats[vi++] = vv.Z;
} }
// m_log.DebugFormat("{0}: CreateGeomMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}", // m_log.DebugFormat("{0}: CreateGeomMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}",
// LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count); // LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count);
meshPtr = BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr, meshPtr = BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr,
indices.GetLength(0), indices, vertices.Count, verticesAsFloats); indices.GetLength(0), indices, vertices.Count, verticesAsFloats);
} }
BulletShape newShape = new BulletShape(meshPtr, ShapeData.PhysicsShapeType.SHAPE_MESH); BulletShape newShape = new BulletShape(meshPtr, ShapeData.PhysicsShapeType.SHAPE_MESH);
@ -501,14 +501,14 @@ public class BSShapeCollection : IDisposable
if (newHullKey == prim.BSShape.shapeKey && prim.BSShape.type == ShapeData.PhysicsShapeType.SHAPE_HULL) if (newHullKey == prim.BSShape.shapeKey && prim.BSShape.type == ShapeData.PhysicsShapeType.SHAPE_HULL)
return false; return false;
DetailLog("{0},BSShapeCollection.CreateGeomHull,create,oldKey={1},newKey={2}", DetailLog("{0},BSShapeCollection.CreateGeomHull,create,oldKey={1},newKey={2}",
prim.LocalID, prim.BSShape.shapeKey.ToString("X"), newHullKey.ToString("X")); prim.LocalID, prim.BSShape.shapeKey.ToString("X"), newHullKey.ToString("X"));
// Remove usage of the previous shape. Also removes reference to underlying mesh if it is a hull. // Remove usage of the previous shape. Also removes reference to underlying mesh if it is a hull.
DereferenceShape(prim.BSShape, true); DereferenceShape(prim.BSShape, true);
newShape = CreatePhysicalHull(prim.PhysObjectName, newHullKey, pbs, shapeData.Size, lod); newShape = CreatePhysicalHull(prim.PhysObjectName, newHullKey, pbs, shapeData.Size, lod);
ReferenceShape(newShape); ReferenceShape(newShape);
// hulls are already scaled by the meshmerizer // hulls are already scaled by the meshmerizer
@ -559,7 +559,7 @@ public class BSShapeCollection : IDisposable
convexBuilder.process(dcomp); convexBuilder.process(dcomp);
// Convert the vertices and indices for passing to unmanaged. // Convert the vertices and indices for passing to unmanaged.
// The hull information is passed as a large floating point array. // The hull information is passed as a large floating point array.
// The format is: // The format is:
// convHulls[0] = number of hulls // convHulls[0] = number of hulls
// convHulls[1] = number of vertices in first hull // convHulls[1] = number of vertices in first hull
@ -635,11 +635,11 @@ public class BSShapeCollection : IDisposable
{ {
// level of detail based on size and type of the object // level of detail based on size and type of the object
float lod = PhysicsScene.MeshLOD; float lod = PhysicsScene.MeshLOD;
if (pbs.SculptEntry) if (pbs.SculptEntry)
lod = PhysicsScene.SculptLOD; lod = PhysicsScene.SculptLOD;
float maxAxis = Math.Max(shapeData.Size.X, Math.Max(shapeData.Size.Y, shapeData.Size.Z)); float maxAxis = Math.Max(shapeData.Size.X, Math.Max(shapeData.Size.Y, shapeData.Size.Z));
if (maxAxis > PhysicsScene.MeshMegaPrimThreshold) if (maxAxis > PhysicsScene.MeshMegaPrimThreshold)
lod = PhysicsScene.MeshMegaPrimLOD; lod = PhysicsScene.MeshMegaPrimLOD;
retLod = lod; retLod = lod;
@ -685,13 +685,13 @@ public class BSShapeCollection : IDisposable
IntPtr bodyPtr = IntPtr.Zero; IntPtr bodyPtr = IntPtr.Zero;
if (prim.IsSolid) if (prim.IsSolid)
{ {
bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr, bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr,
shapeData.ID, shapeData.Position, shapeData.Rotation); shapeData.ID, shapeData.Position, shapeData.Rotation);
// DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); // DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X"));
} }
else else
{ {
bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr, bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr,
shapeData.ID, shapeData.Position, shapeData.Rotation); shapeData.ID, shapeData.Position, shapeData.Rotation);
// DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); // DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X"));
} }

View File

@ -64,7 +64,7 @@ public class BSTerrainManager
// The ground plane created to keep thing from falling to infinity. // The ground plane created to keep thing from falling to infinity.
private BulletBody m_groundPlane; private BulletBody m_groundPlane;
// If doing mega-regions, if we're region zero we will be managing multiple // If doing mega-regions, if we're region zero we will be managing multiple
// region terrains since region zero does the physics for the whole mega-region. // region terrains since region zero does the physics for the whole mega-region.
private Dictionary<Vector2, BulletHeightMapInfo> m_heightMaps; private Dictionary<Vector2, BulletHeightMapInfo> m_heightMaps;
@ -110,8 +110,8 @@ public class BSTerrainManager
BulletShape groundPlaneShape = new BulletShape( BulletShape groundPlaneShape = new BulletShape(
BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, TERRAIN_COLLISION_MARGIN), BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, TERRAIN_COLLISION_MARGIN),
ShapeData.PhysicsShapeType.SHAPE_GROUNDPLANE); ShapeData.PhysicsShapeType.SHAPE_GROUNDPLANE);
m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID, m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID,
BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, BSScene.GROUNDPLANE_ID, BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, BSScene.GROUNDPLANE_ID,
Vector3.Zero, Quaternion.Identity)); Vector3.Zero, Quaternion.Identity));
BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr); BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr);
// Everything collides with the ground plane. // Everything collides with the ground plane.
@ -182,7 +182,7 @@ public class BSTerrainManager
// If not doing the mega-prim thing, just change the terrain // If not doing the mega-prim thing, just change the terrain
DetailLog("{0},SetTerrain.Existing", BSScene.DetailLogZero); DetailLog("{0},SetTerrain.Existing", BSScene.DetailLogZero);
UpdateOrCreateTerrain(BSScene.TERRAIN_ID, localHeightMap, UpdateOrCreateTerrain(BSScene.TERRAIN_ID, localHeightMap,
m_worldOffset, m_worldOffset + DefaultRegionSize, true); m_worldOffset, m_worldOffset + DefaultRegionSize, true);
} }
}); });
@ -234,7 +234,7 @@ public class BSTerrainManager
mapInfo.maxZ = maxZ; mapInfo.maxZ = maxZ;
mapInfo.sizeX = maxCoords.X - minCoords.X; mapInfo.sizeX = maxCoords.X - minCoords.X;
mapInfo.sizeY = maxCoords.Y - minCoords.Y; mapInfo.sizeY = maxCoords.Y - minCoords.Y;
DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,call,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}", DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,call,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}",
BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY); BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY);
BSScene.TaintCallback rebuildOperation = delegate() BSScene.TaintCallback rebuildOperation = delegate()
@ -255,7 +255,7 @@ public class BSTerrainManager
if (mapInfo.terrainBody.ptr != IntPtr.Zero) if (mapInfo.terrainBody.ptr != IntPtr.Zero)
{ {
// Updating an existing terrain. // Updating an existing terrain.
DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,taint,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}", DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,taint,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}",
BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY); BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY);
// Remove from the dynamics world because we're going to mangle this object // Remove from the dynamics world because we're going to mangle this object
@ -289,7 +289,7 @@ public class BSTerrainManager
// else // else
{ {
// Creating a new terrain. // Creating a new terrain.
DetailLog("{0},UpdateOrCreateTerrain:CreateNewTerrain,taint,baseX={1},baseY={2},minZ={3},maxZ={4}", DetailLog("{0},UpdateOrCreateTerrain:CreateNewTerrain,taint,baseX={1},baseY={2},minZ={3},maxZ={4}",
BSScene.DetailLogZero, mapInfo.minCoords.X, mapInfo.minCoords.Y, minZ, maxZ); BSScene.DetailLogZero, mapInfo.minCoords.X, mapInfo.minCoords.Y, minZ, maxZ);
mapInfo.ID = id; mapInfo.ID = id;
@ -306,9 +306,9 @@ public class BSTerrainManager
mapInfo.terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr), mapInfo.terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr),
ShapeData.PhysicsShapeType.SHAPE_TERRAIN); ShapeData.PhysicsShapeType.SHAPE_TERRAIN);
mapInfo.terrainBody = new BulletBody(mapInfo.ID, mapInfo.terrainBody = new BulletBody(mapInfo.ID,
BulletSimAPI.CreateBodyWithDefaultMotionState2(mapInfo.terrainShape.ptr, BulletSimAPI.CreateBodyWithDefaultMotionState2(mapInfo.terrainShape.ptr,
id, centerPos, Quaternion.Identity)); id, centerPos, Quaternion.Identity));
} }
// Make sure the entry is in the heightmap table // Make sure the entry is in the heightmap table
@ -329,7 +329,7 @@ public class BSTerrainManager
// redo its bounding box now that it is in the world // redo its bounding box now that it is in the world
BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr);
BulletSimAPI.SetCollisionFilterMask2(mapInfo.terrainBody.ptr, BulletSimAPI.SetCollisionFilterMask2(mapInfo.terrainBody.ptr,
(uint)CollisionFilterGroups.TerrainFilter, (uint)CollisionFilterGroups.TerrainFilter,
(uint)CollisionFilterGroups.TerrainMask); (uint)CollisionFilterGroups.TerrainMask);
@ -361,7 +361,7 @@ public class BSTerrainManager
Vector3 minCoordsX = minCoords; Vector3 minCoordsX = minCoords;
Vector3 maxCoordsX = maxCoords; Vector3 maxCoordsX = maxCoords;
DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,call,id={1}, minC={2}, maxC={3}", DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,call,id={1}, minC={2}, maxC={3}",
BSScene.DetailLogZero, newTerrainID, minCoords, minCoords); BSScene.DetailLogZero, newTerrainID, minCoords, minCoords);
// Code that must happen at taint-time // Code that must happen at taint-time
@ -370,7 +370,7 @@ public class BSTerrainManager
DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,taint,baseX={1},baseY={2}", BSScene.DetailLogZero, minCoords.X, minCoords.Y); DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,taint,baseX={1},baseY={2}", BSScene.DetailLogZero, minCoords.X, minCoords.Y);
// Create a new mapInfo that will be filled with the new info // Create a new mapInfo that will be filled with the new info
mapInfo = new BulletHeightMapInfo(id, heightMapX, mapInfo = new BulletHeightMapInfo(id, heightMapX,
BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.ptr, newTerrainID, BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.ptr, newTerrainID,
minCoordsX, maxCoordsX, heightMapX, TERRAIN_COLLISION_MARGIN)); minCoordsX, maxCoordsX, heightMapX, TERRAIN_COLLISION_MARGIN));
// Put the unfilled heightmap info into the collection of same // Put the unfilled heightmap info into the collection of same
m_heightMaps.Add(terrainRegionBase, mapInfo); m_heightMaps.Add(terrainRegionBase, mapInfo);
@ -454,7 +454,7 @@ public class BSTerrainManager
{ {
return true; return true;
} }
// This routine is called two ways: // This routine is called two ways:
// One with 'offset' and 'pScene' zero and null but 'extents' giving the maximum // One with 'offset' and 'pScene' zero and null but 'extents' giving the maximum
// extent of the combined regions. This is to inform the parent of the size // extent of the combined regions. This is to inform the parent of the size
@ -469,11 +469,11 @@ public class BSTerrainManager
MegaRegionParentPhysicsScene = pScene; MegaRegionParentPhysicsScene = pScene;
if (pScene != null) if (pScene != null)
{ {
// We are a child. // We are a child.
// We want m_worldMax to be the highest coordinate of our piece of terrain. // We want m_worldMax to be the highest coordinate of our piece of terrain.
m_worldMax = offset + DefaultRegionSize; m_worldMax = offset + DefaultRegionSize;
} }
DetailLog("{0},BSTerrainManager.Combine,offset={1},extents={2},wOffset={3},wMax={4}", DetailLog("{0},BSTerrainManager.Combine,offset={1},extents={2},wOffset={3},wMax={4}",
BSScene.DetailLogZero, offset, extents, m_worldOffset, m_worldMax); BSScene.DetailLogZero, offset, extents, m_worldOffset, m_worldMax);
} }

View File

@ -41,8 +41,8 @@ public struct BulletSim
public BulletSim(uint worldId, BSScene bss, IntPtr xx) public BulletSim(uint worldId, BSScene bss, IntPtr xx)
{ {
ptr = xx; ptr = xx;
worldID = worldId; worldID = worldId;
scene = bss; scene = bss;
} }
public IntPtr ptr; public IntPtr ptr;
public uint worldID; public uint worldID;