Merge branch 'master' of opensimulator.org:/var/git/opensim

LSLKeyTest
UbitUmarov 2015-12-01 09:43:05 +00:00
commit 193b3079e4
9 changed files with 27 additions and 20 deletions

View File

@ -257,7 +257,7 @@ public abstract class BSLinkset
// Return 'true' if linkset processed the collision. 'false' says the linkset didn't have // Return 'true' if linkset processed the collision. 'false' says the linkset didn't have
// anything to add for the collision and it should be passed through normal processing. // anything to add for the collision and it should be passed through normal processing.
// Default processing for a linkset. // Default processing for a linkset.
public virtual bool HandleCollide(uint collidingWith, BSPhysObject collidee, public virtual bool HandleCollide(BSPhysObject collider, 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

@ -452,18 +452,20 @@ public abstract class BSPhysObject : PhysicsActor
private long CollisionsLastTickStep = -1; private long CollisionsLastTickStep = -1;
// The simulation step is telling this object about a collision. // The simulation step is telling this object about a collision.
// I'm the 'collider', the thing I'm colliding with is the 'collidee'.
// Return 'true' if a collision was processed and should be sent up. // Return 'true' if a collision was processed and should be sent up.
// Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision. // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision.
// Called at taint time from within the Step() function // Called at taint time from within the Step() function
public delegate bool CollideCall(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth); public virtual bool Collide(BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
public virtual bool Collide(uint collidingWith, BSPhysObject collidee,
OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
{ {
bool ret = false; bool ret = false;
// if 'collidee' is null, that means it is terrain
uint collideeLocalID = (collidee == null) ? PhysScene.TerrainManager.HighestTerrainID : collidee.LocalID;
// The following lines make IsColliding(), CollidingGround() and CollidingObj work // The following lines make IsColliding(), CollidingGround() and CollidingObj work
CollidingStep = PhysScene.SimulationStep; CollidingStep = PhysScene.SimulationStep;
if (collidingWith <= PhysScene.TerrainManager.HighestTerrainID) if (collideeLocalID <= PhysScene.TerrainManager.HighestTerrainID)
{ {
CollidingGroundStep = PhysScene.SimulationStep; CollidingGroundStep = PhysScene.SimulationStep;
} }
@ -474,10 +476,13 @@ public abstract class BSPhysObject : PhysicsActor
CollisionAccumulation++; CollisionAccumulation++;
// For movement tests, remember if we are colliding with an object that is moving. // For movement tests, if the collider is me, remember if we are colliding with an object that is moving.
ColliderIsMoving = collidee != null ? (collidee.RawVelocity != OMV.Vector3.Zero) : false; // Here the 'collider'/'collidee' thing gets messed up. In the larger context, when something is checking
// if the thing it is colliding with is moving, for instance, it asks if the its collider is moving.
ColliderIsMoving = collidee != null ? (collidee.RawVelocity != OMV.Vector3.Zero || collidee.RotationalVelocity != OMV.Vector3.Zero) : false;
ColliderIsVolumeDetect = collidee != null ? (collidee.IsVolumeDetect) : false; ColliderIsVolumeDetect = collidee != null ? (collidee.IsVolumeDetect) : false;
// Make a collection of the collisions that happened the last simulation tick. // Make a collection of the collisions that happened the last simulation tick.
// This is different than the collection created for sending up to the simulator as it is cleared every tick. // This is different than the collection created for sending up to the simulator as it is cleared every tick.
if (CollisionsLastTickStep != PhysScene.SimulationStep) if (CollisionsLastTickStep != PhysScene.SimulationStep)
@ -485,23 +490,26 @@ public abstract class BSPhysObject : PhysicsActor
CollisionsLastTick = new CollisionEventUpdate(); CollisionsLastTick = new CollisionEventUpdate();
CollisionsLastTickStep = PhysScene.SimulationStep; CollisionsLastTickStep = PhysScene.SimulationStep;
} }
CollisionsLastTick.AddCollider(collideeLocalID, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
CollisionsLastTick.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
// If someone has subscribed for collision events log the collision so it will be reported up // If someone has subscribed for collision events log the collision so it will be reported up
if (SubscribedEvents()) { if (SubscribedEvents()) {
ContactPoint newContact = new ContactPoint(contactPoint, contactNormal, pentrationDepth); ContactPoint newContact = new ContactPoint(contactPoint, contactNormal, pentrationDepth);
// make collision sound work just setting a speed // Collision sound requires a velocity to know it should happen. This is a lot of computation for a little used feature.
// see ubOde OMV.Vector3 relvel = OMV.Vector3.Zero;
newContact.RelativeSpeed = 2.0f; if (IsPhysical)
relvel = Velocity;
if (collidee != null && collidee.IsPhysical)
relvel -= collidee.Velocity;
newContact.RelativeSpeed = OMV.Vector3.Dot(relvel, contactNormal);
lock (PhysScene.CollisionLock) lock (PhysScene.CollisionLock)
{ {
CollisionCollection.AddCollider(collidingWith, newContact); CollisionCollection.AddCollider(collideeLocalID, newContact);
} }
DetailLog("{0},{1}.Collision.AddCollider,call,with={2},point={3},normal={4},depth={5},colliderMoving={6}", DetailLog("{0},{1}.Collision.AddCollider,call,with={2},point={3},normal={4},depth={5},colliderMoving={6}",
LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth, ColliderIsMoving); LocalID, TypeName, collideeLocalID, contactPoint, contactNormal, pentrationDepth, ColliderIsMoving);
ret = true; ret = true;
} }

View File

@ -203,15 +203,14 @@ public class BSPrimLinkable : BSPrimDisplaced
// Called after a simulation step to post a collision with this object. // Called after a simulation step to post a collision with this object.
// This returns 'true' if the collision has been queued and the SendCollisions call must // This returns 'true' if the collision has been queued and the SendCollisions call must
// be made at the end of the simulation step. // be made at the end of the simulation step.
public override bool Collide(uint collidingWith, BSPhysObject collidee, public override bool Collide(BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
{ {
bool ret = false; bool ret = false;
// Ask the linkset if it wants to handle the collision // Ask the linkset if it wants to handle the collision
if (!Linkset.HandleCollide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth)) if (!Linkset.HandleCollide(this, collidee, contactPoint, contactNormal, pentrationDepth))
{ {
// The linkset didn't handle it so pass the collision through normal processing // The linkset didn't handle it so pass the collision through normal processing
ret = base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); ret = base.Collide(collidee, contactPoint, contactNormal, pentrationDepth);
} }
return ret; return ret;
} }

View File

@ -880,7 +880,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS
if (collider.IsInitialized) if (collider.IsInitialized)
{ {
if (collider.Collide(collidingWith, collidee, collidePoint, collideNormal, penetration)) if (collider.Collide(collidee, collidePoint, collideNormal, penetration))
{ {
// If a collision was 'good', remember to send it to the simulator // If a collision was 'good', remember to send it to the simulator
lock (CollisionLock) lock (CollisionLock)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.