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.cs40
1 files changed, 30 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index e8575f6..821f470 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -73,6 +73,8 @@ public abstract class BSPhysObject : PhysicsActor
73 73
74 // A linkset of just me 74 // A linkset of just me
75 Linkset = BSLinkset.Factory(PhysicsScene, this); 75 Linkset = BSLinkset.Factory(PhysicsScene, this);
76 PositionDisplacement = OMV.Vector3.Zero;
77
76 LastAssetBuildFailed = false; 78 LastAssetBuildFailed = false;
77 79
78 // Default material type 80 // Default material type
@@ -135,6 +137,7 @@ public abstract class BSPhysObject : PhysicsActor
135 public virtual OMV.Vector3 Scale { get; set; } 137 public virtual OMV.Vector3 Scale { get; set; }
136 public abstract bool IsSolid { get; } 138 public abstract bool IsSolid { get; }
137 public abstract bool IsStatic { get; } 139 public abstract bool IsStatic { get; }
140 public abstract bool IsSelected { get; }
138 141
139 // Materialness 142 // Materialness
140 public MaterialAttributes.Material Material { get; private set; } 143 public MaterialAttributes.Material Material { get; private set; }
@@ -156,6 +159,14 @@ public abstract class BSPhysObject : PhysicsActor
156 public abstract OMV.Vector3 RawPosition { get; set; } 159 public abstract OMV.Vector3 RawPosition { get; set; }
157 public abstract OMV.Vector3 ForcePosition { get; set; } 160 public abstract OMV.Vector3 ForcePosition { get; set; }
158 161
162 // Position is what the simulator thinks the positions of the prim is.
163 // Because Bullet needs the zero coordinate to be the center of mass of the linkset,
164 // sometimes it is necessary to displace the position the physics engine thinks
165 // the position is. PositionDisplacement must be added and removed from the
166 // position as the simulator position is stored and fetched from the physics
167 // engine.
168 public virtual OMV.Vector3 PositionDisplacement { get; set; }
169
159 public abstract OMV.Quaternion RawOrientation { get; set; } 170 public abstract OMV.Quaternion RawOrientation { get; set; }
160 public abstract OMV.Quaternion ForceOrientation { get; set; } 171 public abstract OMV.Quaternion ForceOrientation { get; set; }
161 172
@@ -371,10 +382,13 @@ public abstract class BSPhysObject : PhysicsActor
371 { 382 {
372 string identifier = op + "-" + id.ToString(); 383 string identifier = op + "-" + id.ToString();
373 384
374 // Clean out any existing action 385 lock (RegisteredActions)
375 UnRegisterPreStepAction(op, id); 386 {
387 // Clean out any existing action
388 UnRegisterPreStepAction(op, id);
376 389
377 RegisteredActions[identifier] = actn; 390 RegisteredActions[identifier] = actn;
391 }
378 PhysicsScene.BeforeStep += actn; 392 PhysicsScene.BeforeStep += actn;
379 DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier); 393 DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier);
380 } 394 }
@@ -384,22 +398,28 @@ public abstract class BSPhysObject : PhysicsActor
384 { 398 {
385 string identifier = op + "-" + id.ToString(); 399 string identifier = op + "-" + id.ToString();
386 bool removed = false; 400 bool removed = false;
387 if (RegisteredActions.ContainsKey(identifier)) 401 lock (RegisteredActions)
388 { 402 {
389 PhysicsScene.BeforeStep -= RegisteredActions[identifier]; 403 if (RegisteredActions.ContainsKey(identifier))
390 RegisteredActions.Remove(identifier); 404 {
391 removed = true; 405 PhysicsScene.BeforeStep -= RegisteredActions[identifier];
406 RegisteredActions.Remove(identifier);
407 removed = true;
408 }
392 } 409 }
393 DetailLog("{0},BSPhysObject.UnRegisterPreStepAction,id={1},removed={2}", LocalID, identifier, removed); 410 DetailLog("{0},BSPhysObject.UnRegisterPreStepAction,id={1},removed={2}", LocalID, identifier, removed);
394 } 411 }
395 412
396 protected void UnRegisterAllPreStepActions() 413 protected void UnRegisterAllPreStepActions()
397 { 414 {
398 foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredActions) 415 lock (RegisteredActions)
399 { 416 {
400 PhysicsScene.BeforeStep -= kvp.Value; 417 foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredActions)
418 {
419 PhysicsScene.BeforeStep -= kvp.Value;
420 }
421 RegisteredActions.Clear();
401 } 422 }
402 RegisteredActions.Clear();
403 DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID); 423 DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID);
404 } 424 }
405 425