aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs53
1 files changed, 39 insertions, 14 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index ead6a08..f6a890e 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -34,19 +34,30 @@ using OpenSim.Region.Physics.Manager;
34 34
35namespace OpenSim.Region.Physics.BulletSPlugin 35namespace OpenSim.Region.Physics.BulletSPlugin
36{ 36{
37// Class to wrap all objects. 37/*
38// The rest of BulletSim doesn't need to keep checking for avatars or prims 38 * Class to wrap all objects.
39// unless the difference is significant. 39 * The rest of BulletSim doesn't need to keep checking for avatars or prims
40 * unless the difference is significant.
41 *
42 * Variables in the physicsl objects are in three forms:
43 * VariableName: used by the simulator and performs taint operations, etc
44 * RawVariableName: direct reference to the BulletSim storage for the variable value
45 * ForceVariableName: direct reference (store and fetch) to the value in the physics engine.
46 * The last two (and certainly the last one) should be referenced only in taint-time.
47 */
40public abstract class BSPhysObject : PhysicsActor 48public abstract class BSPhysObject : PhysicsActor
41{ 49{
42 protected void BaseInitialize(BSScene parentScene, uint localID, string name, string typeName) 50 protected BSPhysObject()
51 {
52 }
53 protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName)
43 { 54 {
44 PhysicsScene = parentScene; 55 PhysicsScene = parentScene;
45 LocalID = localID; 56 LocalID = localID;
46 PhysObjectName = name; 57 PhysObjectName = name;
47 TypeName = typeName; 58 TypeName = typeName;
48 59
49 Linkset = new BSLinkset(PhysicsScene, this); 60 Linkset = BSLinkset.Factory(PhysicsScene, this);
50 LastAssetBuildFailed = false; 61 LastAssetBuildFailed = false;
51 62
52 CollisionCollection = new CollisionEventUpdate(); 63 CollisionCollection = new CollisionEventUpdate();
@@ -63,12 +74,17 @@ public abstract class BSPhysObject : PhysicsActor
63 public BSLinkset Linkset { get; set; } 74 public BSLinkset Linkset { get; set; }
64 75
65 // Return the object mass without calculating it or having side effects 76 // Return the object mass without calculating it or having side effects
66 public abstract float MassRaw { get; } 77 public abstract float RawMass { get; }
78 // Set the raw mass but also update physical mass properties (inertia, ...)
79 public abstract void UpdatePhysicalMassProperties(float mass);
80
81 // The last value calculated for the prim's inertia
82 public OMV.Vector3 Inertia { get; set; }
67 83
68 // Reference to the physical body (btCollisionObject) of this object 84 // Reference to the physical body (btCollisionObject) of this object
69 public BulletBody BSBody; 85 public BulletBody PhysBody;
70 // Reference to the physical shape (btCollisionShape) of this object 86 // Reference to the physical shape (btCollisionShape) of this object
71 public BulletShape BSShape; 87 public BulletShape PhysShape;
72 88
73 // 'true' if the mesh's underlying asset failed to build. 89 // 'true' if the mesh's underlying asset failed to build.
74 // This will keep us from looping after the first time the build failed. 90 // This will keep us from looping after the first time the build failed.
@@ -76,9 +92,15 @@ public abstract class BSPhysObject : PhysicsActor
76 92
77 // The objects base shape information. Null if not a prim type shape. 93 // The objects base shape information. Null if not a prim type shape.
78 public PrimitiveBaseShape BaseShape { get; protected set; } 94 public PrimitiveBaseShape BaseShape { get; protected set; }
95 // Some types of objects have preferred physical representations.
96 // Returns SHAPE_UNKNOWN if there is no preference.
97 public virtual BSPhysicsShapeType PreferredPhysicalShape
98 {
99 get { return BSPhysicsShapeType.SHAPE_UNKNOWN; }
100 }
79 101
80 // When the physical properties are updated, an EntityProperty holds the update values. 102 // When the physical properties are updated, an EntityProperty holds the update values.
81 // Keep the current and last EntityProperties to enable computation of differences 103 // Keep the current and last EntityProperties to enable computation of differences
82 // between the current update and the previous values. 104 // between the current update and the previous values.
83 public EntityProperties CurrentEntityProperties { get; set; } 105 public EntityProperties CurrentEntityProperties { get; set; }
84 public EntityProperties LastEntityProperties { get; set; } 106 public EntityProperties LastEntityProperties { get; set; }
@@ -88,7 +110,8 @@ public abstract class BSPhysObject : PhysicsActor
88 public abstract bool IsStatic { get; } 110 public abstract bool IsStatic { get; }
89 111
90 // Stop all physical motion. 112 // Stop all physical motion.
91 public abstract void ZeroMotion(); 113 public abstract void ZeroMotion(bool inTaintTime);
114 public abstract void ZeroAngularMotion(bool inTaintTime);
92 115
93 // Step the vehicle simulation for this object. A NOOP if the vehicle was not configured. 116 // Step the vehicle simulation for this object. A NOOP if the vehicle was not configured.
94 public virtual void StepVehicle(float timeStep) { } 117 public virtual void StepVehicle(float timeStep) { }
@@ -99,8 +122,10 @@ public abstract class BSPhysObject : PhysicsActor
99 // Tell the object to clean up. 122 // Tell the object to clean up.
100 public abstract void Destroy(); 123 public abstract void Destroy();
101 124
125 public abstract OMV.Vector3 RawPosition { get; set; }
102 public abstract OMV.Vector3 ForcePosition { get; set; } 126 public abstract OMV.Vector3 ForcePosition { get; set; }
103 127
128 public abstract OMV.Quaternion RawOrientation { get; set; }
104 public abstract OMV.Quaternion ForceOrientation { get; set; } 129 public abstract OMV.Quaternion ForceOrientation { get; set; }
105 130
106 public abstract OMV.Vector3 ForceVelocity { get; set; } 131 public abstract OMV.Vector3 ForceVelocity { get; set; }
@@ -204,7 +229,7 @@ public abstract class BSPhysObject : PhysicsActor
204 229
205 PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate() 230 PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate()
206 { 231 {
207 CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 232 CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
208 }); 233 });
209 } 234 }
210 else 235 else
@@ -213,16 +238,16 @@ public abstract class BSPhysObject : PhysicsActor
213 UnSubscribeEvents(); 238 UnSubscribeEvents();
214 } 239 }
215 } 240 }
216 public override void UnSubscribeEvents() { 241 public override void UnSubscribeEvents() {
217 // DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName); 242 // DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName);
218 SubscribedEventsMs = 0; 243 SubscribedEventsMs = 0;
219 PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() 244 PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate()
220 { 245 {
221 CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 246 CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
222 }); 247 });
223 } 248 }
224 // Return 'true' if the simulator wants collision events 249 // Return 'true' if the simulator wants collision events
225 public override bool SubscribedEvents() { 250 public override bool SubscribedEvents() {
226 return (SubscribedEventsMs > 0); 251 return (SubscribedEventsMs > 0);
227 } 252 }
228 253