BulletSim: Add one function that all actors who act on the physical

can use to know if the object is currently active.
Code cleaning including use of Util.ClampV function.
user_profiles
Robert Adams 2013-01-17 14:47:35 -08:00
parent caad1edabf
commit 75f710f1e7
5 changed files with 31 additions and 24 deletions

View File

@ -652,6 +652,9 @@ public sealed class BSCharacter : BSPhysObject
public override bool IsStatic { public override bool IsStatic {
get { return false; } get { return false; }
} }
public override bool IsPhysicallyActive {
get { return true; }
}
public override bool Flying { public override bool Flying {
get { return _flying; } get { return _flying; }
set { set {

View File

@ -35,6 +35,7 @@ using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
namespace OpenSim.Region.Physics.BulletSPlugin namespace OpenSim.Region.Physics.BulletSPlugin
@ -154,7 +155,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// Return 'true' if this vehicle is doing vehicle things // Return 'true' if this vehicle is doing vehicle things
public bool IsActive public bool IsActive
{ {
get { return (Type != Vehicle.TYPE_NONE && !Prim.IsStatic); } get { return (Type != Vehicle.TYPE_NONE && Prim.IsPhysicallyActive); }
} }
#region Vehicle parameter setting #region Vehicle parameter setting

View File

@ -139,6 +139,11 @@ public abstract class BSPhysObject : PhysicsActor
public abstract bool IsStatic { get; } public abstract bool IsStatic { get; }
public abstract bool IsSelected { get; } public abstract bool IsSelected { get; }
// It can be confusing for an actor to know if it should move or update an object
// depeneding on the setting of 'selected', 'physical, ...
// This flag is the true test -- if true, the object is being acted on in the physical world
public abstract bool IsPhysicallyActive { get; }
// Materialness // Materialness
public MaterialAttributes.Material Material { get; private set; } public MaterialAttributes.Material Material { get; private set; }
public override void SetMaterial(int material) public override void SetMaterial(int material)
@ -302,8 +307,9 @@ public abstract class BSPhysObject : PhysicsActor
public virtual bool SendCollisions() public virtual bool SendCollisions()
{ {
bool ret = true; bool ret = true;
// If the 'no collision' call, force it to happen right now so quick collision_end // If the 'no collision' call, force it to happen right now so quick collision_end
bool force = (CollisionCollection.Count == 0); bool force = (CollisionCollection.Count == 0 && CollisionsLastTick.Count != 0);
// throttle the collisions to the number of milliseconds specified in the subscription // throttle the collisions to the number of milliseconds specified in the subscription
if (force || (PhysicsScene.SimulationNowTime >= NextCollisionOkTime)) if (force || (PhysicsScene.SimulationNowTime >= NextCollisionOkTime))
@ -318,7 +324,7 @@ public abstract class BSPhysObject : PhysicsActor
ret = false; ret = false;
} }
// DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count);
base.SendCollisionUpdate(CollisionCollection); base.SendCollisionUpdate(CollisionCollection);
// Remember the collisions from this tick for some collision specific processing. // Remember the collisions from this tick for some collision specific processing.

View File

@ -132,8 +132,8 @@ public sealed class BSPrim : BSPhysObject
base.Destroy(); base.Destroy();
// Undo any links between me and any other object // Undo any links between me and any other object
BSPhysObject parentBefore = Linkset.LinksetRoot; BSPhysObject parentBefore = Linkset.LinksetRoot; // DEBUG DEBUG
int childrenBefore = Linkset.NumberOfChildren; int childrenBefore = Linkset.NumberOfChildren; // DEBUG DEBUG
Linkset = Linkset.RemoveMeFromLinkset(this); Linkset = Linkset.RemoveMeFromLinkset(this);
@ -727,6 +727,12 @@ public sealed class BSPrim : BSPhysObject
get { return !IsPhantom && !_isVolumeDetect; } get { return !IsPhantom && !_isVolumeDetect; }
} }
// The object is moving and is actively being dynamic in the physical world
public override bool IsPhysicallyActive
{
get { return !_isSelected && IsPhysical; }
}
// Make gravity work if the object is physical and not selected // Make gravity work if the object is physical and not selected
// Called at taint-time!! // Called at taint-time!!
private void SetObjectDynamic(bool forceRebuild) private void SetObjectDynamic(bool forceRebuild)
@ -1174,18 +1180,11 @@ public sealed class BSPrim : BSPhysObject
// This added force will only last the next simulation tick. // This added force will only last the next simulation tick.
public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
// for an object, doesn't matter if force is a pushforce or not // for an object, doesn't matter if force is a pushforce or not
if (!IsStatic) if (IsPhysicallyActive)
{ {
if (force.IsFinite()) if (force.IsFinite())
{ {
float magnitude = force.Length(); OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude);
if (magnitude > BSParam.MaxAddForceMagnitude)
{
// Force has a limit
force = force / magnitude * BSParam.MaxAddForceMagnitude;
}
OMV.Vector3 addForce = force;
// DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); // DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce);
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate()
@ -1209,19 +1208,13 @@ public sealed class BSPrim : BSPhysObject
public void AddForceImpulse(OMV.Vector3 impulse, bool pushforce, bool inTaintTime) { public void AddForceImpulse(OMV.Vector3 impulse, bool pushforce, bool inTaintTime) {
// for an object, doesn't matter if force is a pushforce or not // for an object, doesn't matter if force is a pushforce or not
if (!IsStatic) if (!IsPhysicallyActive)
{ {
if (impulse.IsFinite()) if (impulse.IsFinite())
{ {
float magnitude = impulse.Length(); OMV.Vector3 addImpulse = Util.ClampV(impulse, BSParam.MaxAddForceMagnitude);
if (magnitude > BSParam.MaxAddForceMagnitude)
{
// Force has a limit
impulse = impulse / magnitude * BSParam.MaxAddForceMagnitude;
}
// DetailLog("{0},BSPrim.addForceImpulse,call,impulse={1}", LocalID, impulse); // DetailLog("{0},BSPrim.addForceImpulse,call,impulse={1}", LocalID, impulse);
OMV.Vector3 addImpulse = impulse;
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddImpulse", delegate() PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddImpulse", delegate()
{ {
// Bullet adds this impulse immediately to the velocity // Bullet adds this impulse immediately to the velocity

View File

@ -16,6 +16,7 @@ vehicle angular banking
Avatars walking up stairs (HALF DONE) Avatars walking up stairs (HALF DONE)
Radius of the capsule affects ability to climb edges. Radius of the capsule affects ability to climb edges.
Vehicle movement on terrain smoothness Vehicle movement on terrain smoothness
When is force introduced by SetForce removed? The prestep action could go forever.
Boats float low in the water (DONE) Boats float low in the water (DONE)
Avatar movement Avatar movement
flying into a wall doesn't stop avatar who keeps appearing to move through the obstacle (DONE) flying into a wall doesn't stop avatar who keeps appearing to move through the obstacle (DONE)
@ -72,8 +73,11 @@ Incorporate inter-relationship of angular corrections. For instance, angularDefl
GENERAL TODO LIST: GENERAL TODO LIST:
================================================= =================================================
Implement llSetPhysicalMaterial.
Implement llSetForceAndTorque.
Implement an avatar mesh shape. The Bullet capsule is way too limited. Implement an avatar mesh shape. The Bullet capsule is way too limited.
Consider just hand creating a vertex/index array in a new BSShapeAvatar. Consider just hand creating a vertex/index array in a new BSShapeAvatar.
Verify/fix phantom, volume-detect objects do not fall to infinity. Should stop at terrain.
Revisit CollisionMargin. Builders notice the 0.04 spacing between prims. Revisit CollisionMargin. Builders notice the 0.04 spacing between prims.
Duplicating a physical prim causes old prim to jump away Duplicating a physical prim causes old prim to jump away
Dup a phys prim and the original become unselected and thus interacts w/ selected prim. Dup a phys prim and the original become unselected and thus interacts w/ selected prim.