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
parent
caad1edabf
commit
75f710f1e7
|
@ -652,6 +652,9 @@ public sealed class BSCharacter : BSPhysObject
|
|||
public override bool IsStatic {
|
||||
get { return false; }
|
||||
}
|
||||
public override bool IsPhysicallyActive {
|
||||
get { return true; }
|
||||
}
|
||||
public override bool Flying {
|
||||
get { return _flying; }
|
||||
set {
|
||||
|
|
|
@ -35,6 +35,7 @@ using System.Collections.Generic;
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
|
||||
namespace OpenSim.Region.Physics.BulletSPlugin
|
||||
|
@ -154,7 +155,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
// Return 'true' if this vehicle is doing vehicle things
|
||||
public bool IsActive
|
||||
{
|
||||
get { return (Type != Vehicle.TYPE_NONE && !Prim.IsStatic); }
|
||||
get { return (Type != Vehicle.TYPE_NONE && Prim.IsPhysicallyActive); }
|
||||
}
|
||||
|
||||
#region Vehicle parameter setting
|
||||
|
|
|
@ -139,6 +139,11 @@ public abstract class BSPhysObject : PhysicsActor
|
|||
public abstract bool IsStatic { 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
|
||||
public MaterialAttributes.Material Material { get; private set; }
|
||||
public override void SetMaterial(int material)
|
||||
|
@ -302,8 +307,9 @@ public abstract class BSPhysObject : PhysicsActor
|
|||
public virtual bool SendCollisions()
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
// 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
|
||||
if (force || (PhysicsScene.SimulationNowTime >= NextCollisionOkTime))
|
||||
|
@ -318,7 +324,7 @@ public abstract class BSPhysObject : PhysicsActor
|
|||
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);
|
||||
|
||||
// Remember the collisions from this tick for some collision specific processing.
|
||||
|
|
|
@ -132,8 +132,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
base.Destroy();
|
||||
|
||||
// Undo any links between me and any other object
|
||||
BSPhysObject parentBefore = Linkset.LinksetRoot;
|
||||
int childrenBefore = Linkset.NumberOfChildren;
|
||||
BSPhysObject parentBefore = Linkset.LinksetRoot; // DEBUG DEBUG
|
||||
int childrenBefore = Linkset.NumberOfChildren; // DEBUG DEBUG
|
||||
|
||||
Linkset = Linkset.RemoveMeFromLinkset(this);
|
||||
|
||||
|
@ -727,6 +727,12 @@ public sealed class BSPrim : BSPhysObject
|
|||
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
|
||||
// Called at taint-time!!
|
||||
private void SetObjectDynamic(bool forceRebuild)
|
||||
|
@ -1174,18 +1180,11 @@ public sealed class BSPrim : BSPhysObject
|
|||
// This added force will only last the next simulation tick.
|
||||
public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
|
||||
// for an object, doesn't matter if force is a pushforce or not
|
||||
if (!IsStatic)
|
||||
if (IsPhysicallyActive)
|
||||
{
|
||||
if (force.IsFinite())
|
||||
{
|
||||
float magnitude = force.Length();
|
||||
if (magnitude > BSParam.MaxAddForceMagnitude)
|
||||
{
|
||||
// Force has a limit
|
||||
force = force / magnitude * BSParam.MaxAddForceMagnitude;
|
||||
}
|
||||
|
||||
OMV.Vector3 addForce = force;
|
||||
OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude);
|
||||
// DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce);
|
||||
|
||||
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) {
|
||||
// for an object, doesn't matter if force is a pushforce or not
|
||||
if (!IsStatic)
|
||||
if (!IsPhysicallyActive)
|
||||
{
|
||||
if (impulse.IsFinite())
|
||||
{
|
||||
float magnitude = impulse.Length();
|
||||
if (magnitude > BSParam.MaxAddForceMagnitude)
|
||||
{
|
||||
// Force has a limit
|
||||
impulse = impulse / magnitude * BSParam.MaxAddForceMagnitude;
|
||||
}
|
||||
|
||||
OMV.Vector3 addImpulse = Util.ClampV(impulse, BSParam.MaxAddForceMagnitude);
|
||||
// DetailLog("{0},BSPrim.addForceImpulse,call,impulse={1}", LocalID, impulse);
|
||||
OMV.Vector3 addImpulse = impulse;
|
||||
|
||||
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddImpulse", delegate()
|
||||
{
|
||||
// Bullet adds this impulse immediately to the velocity
|
||||
|
|
|
@ -16,6 +16,7 @@ vehicle angular banking
|
|||
Avatars walking up stairs (HALF DONE)
|
||||
Radius of the capsule affects ability to climb edges.
|
||||
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)
|
||||
Avatar movement
|
||||
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:
|
||||
=================================================
|
||||
Implement llSetPhysicalMaterial.
|
||||
Implement llSetForceAndTorque.
|
||||
Implement an avatar mesh shape. The Bullet capsule is way too limited.
|
||||
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.
|
||||
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.
|
||||
|
@ -121,7 +125,7 @@ Physical and phantom will drop through the terrain
|
|||
LINKSETS
|
||||
======================================================
|
||||
Editing a child of a linkset causes the child to go phantom
|
||||
Move a child prim once when it is physical and can never move it again without it going phantom
|
||||
Move a child prim once when it is physical and can never move it again without it going phantom
|
||||
Offset the center of the linkset to be the geometric center of all the prims
|
||||
Not quite the same as the center-of-gravity
|
||||
Linksets should allow collisions to individual children
|
||||
|
|
Loading…
Reference in New Issue