aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authordarok2007-11-03 19:33:00 +0000
committerdarok2007-11-03 19:33:00 +0000
commitfbf3c6a768274cfdb1e91e73758f9ee893094153 (patch)
tree6b6bd68b1061fa3ca4df20a044b55a50e0d354e2
parentFirst part of Scene refactoring: (diff)
downloadopensim-SC_OLD-fbf3c6a768274cfdb1e91e73758f9ee893094153.zip
opensim-SC_OLD-fbf3c6a768274cfdb1e91e73758f9ee893094153.tar.gz
opensim-SC_OLD-fbf3c6a768274cfdb1e91e73758f9ee893094153.tar.bz2
opensim-SC_OLD-fbf3c6a768274cfdb1e91e73758f9ee893094153.tar.xz
Modifications for prim movement. For now only in Mod. BulletX, but i think it can be easy to add to ODE. Enjoy kick the prims and be careful with the falling ones ;D
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs22
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs73
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs75
3 files changed, 114 insertions, 56 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 39f4e5c..b00d465 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -55,6 +55,9 @@ namespace OpenSim.Region.Environment.Scenes
55 55
56 public bool HasChanged = false; 56 public bool HasChanged = false;
57 57
58 private LLVector3 lastPhysGroupPos;
59 private LLQuaternion lastPhysGroupRot;
60
58 #region Properties 61 #region Properties
59 62
60 /// <summary> 63 /// <summary>
@@ -490,6 +493,25 @@ namespace OpenSim.Region.Environment.Scenes
490 /// </summary> 493 /// </summary>
491 public override void Update() 494 public override void Update()
492 { 495 {
496 if (lastPhysGroupPos.GetDistanceTo(AbsolutePosition) > 0.02)
497 {
498 foreach (SceneObjectPart part in m_parts.Values)
499 {
500 if (part.UpdateFlag == 0) part.UpdateFlag = 1;
501 }
502 lastPhysGroupPos = AbsolutePosition;
503 }
504 if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1)
505 || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1)
506 || (Math.Abs(lastPhysGroupRot.Y - GroupRotation.Y) > 0.1)
507 || (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1))
508 {
509 foreach (SceneObjectPart part in m_parts.Values)
510 {
511 if (part.UpdateFlag == 0) part.UpdateFlag = 1;
512 }
513 lastPhysGroupRot = GroupRotation;
514 }
493 foreach (SceneObjectPart part in m_parts.Values) 515 foreach (SceneObjectPart part in m_parts.Values)
494 { 516 {
495 part.SendScheduledUpdates(); 517 part.SendScheduledUpdates();
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 637e090..b558bb2 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -148,8 +148,34 @@ namespace OpenSim.Region.Environment.Scenes
148 148
149 public LLVector3 GroupPosition 149 public LLVector3 GroupPosition
150 { 150 {
151 get { return m_groupPosition; } 151 get
152 set { m_groupPosition = value; } 152 {
153 if (PhysActor != null)
154 {
155 m_groupPosition.X = PhysActor.Position.X;
156 m_groupPosition.Y = PhysActor.Position.Y;
157 m_groupPosition.Z = PhysActor.Position.Z;
158 }
159 return m_groupPosition;
160 }
161 set
162 {
163 if (PhysActor != null)
164 {
165 try
166 {
167 //lock (m_scene.SyncRoot)
168 //{
169 PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
170 //}
171 }
172 catch (Exception e)
173 {
174 Console.WriteLine(e.Message);
175 }
176 }
177 m_groupPosition = value;
178 }
153 } 179 }
154 180
155 protected LLVector3 m_offsetPosition; 181 protected LLVector3 m_offsetPosition;
@@ -169,8 +195,35 @@ namespace OpenSim.Region.Environment.Scenes
169 195
170 public LLQuaternion RotationOffset 196 public LLQuaternion RotationOffset
171 { 197 {
172 get { return m_rotationOffset; } 198 get
173 set { m_rotationOffset = value; } 199 {
200 if (PhysActor != null)
201 {
202 m_rotationOffset.X = PhysActor.Orientation.x;
203 m_rotationOffset.Y = PhysActor.Orientation.y;
204 m_rotationOffset.Z = PhysActor.Orientation.z;
205 m_rotationOffset.W = PhysActor.Orientation.w;
206 }
207 return m_rotationOffset;
208 }
209 set
210 {
211 if (PhysActor != null)
212 {
213 try
214 {
215 //lock (m_scene.SyncRoot)
216 //{
217 PhysActor.Orientation = new Quaternion(value.W, value.X, value.Y, value.Z);
218 //}
219 }
220 catch (Exception ex)
221 {
222 Console.WriteLine(ex.Message);
223 }
224 }
225 m_rotationOffset = value;
226 }
174 } 227 }
175 228
176 protected LLVector3 m_velocity; 229 protected LLVector3 m_velocity;
@@ -260,7 +313,12 @@ namespace OpenSim.Region.Environment.Scenes
260 public SceneObjectGroup ParentGroup 313 public SceneObjectGroup ParentGroup
261 { 314 {
262 get { return m_parentGroup; } 315 get { return m_parentGroup; }
263 316 }
317
318 public byte UpdateFlag
319 {
320 get { return m_updateFlag; }
321 set { m_updateFlag = value; }
264 } 322 }
265 323
266 #region Constructors 324 #region Constructors
@@ -502,6 +560,7 @@ namespace OpenSim.Region.Environment.Scenes
502 { 560 {
503 AddTerseUpdateToAllAvatars(); 561 AddTerseUpdateToAllAvatars();
504 ClearUpdateSchedule(); 562 ClearUpdateSchedule();
563 ScheduleTerseUpdate();
505 } 564 }
506 else 565 else
507 { 566 {
@@ -706,6 +765,10 @@ namespace OpenSim.Region.Environment.Scenes
706 new Quaternion(RotationOffset.W, RotationOffset.X, 765 new Quaternion(RotationOffset.W, RotationOffset.X,
707 RotationOffset.Y, RotationOffset.Z), UsePhysics); 766 RotationOffset.Y, RotationOffset.Z), UsePhysics);
708 } 767 }
768 else
769 {
770 PhysActor.IsPhysical = UsePhysics;
771 }
709 } 772 }
710 773
711 if (IsTemporary) 774 if (IsTemporary)
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 5a2b22c..5b8b0e8 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -400,35 +400,30 @@ namespace OpenSim.Region.Physics.BulletXPlugin
400 /// support simple box & hollow box now; later, more shapes 400 /// support simple box & hollow box now; later, more shapes
401 if (pbs.ProfileHollow == 0) 401 if (pbs.ProfileHollow == 0)
402 { 402 {
403 result = AddPrim(primName, position, size, rotation, null, null); 403 result = AddPrim(primName, position, size, rotation, null, null, isPhysical);
404 } 404 }
405 else 405 else
406 { 406 {
407 Mesh mesh = null; 407 Mesh mesh = null;
408 result = AddPrim(primName, position, size, rotation, mesh, pbs); 408 result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical);
409 } 409 }
410 break; 410 break;
411 411
412 default: 412 default:
413 result = AddPrim(primName, position, size, rotation, null, null); 413 result = AddPrim(primName, position, size, rotation, null, null, isPhysical);
414 break; 414 break;
415 } 415 }
416 416
417 return result; 417 return result;
418 } 418 }
419 419
420 public PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation)
421 {
422 return AddPrim("", position, size, rotation, null, null);
423 }
424
425 public PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation, 420 public PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation,
426 Mesh mesh, PrimitiveBaseShape pbs) 421 Mesh mesh, PrimitiveBaseShape pbs, bool isPhysical)
427 { 422 {
428 BulletXPrim newPrim = null; 423 BulletXPrim newPrim = null;
429 lock (BulletXLock) 424 lock (BulletXLock)
430 { 425 {
431 newPrim = new BulletXPrim(name, this, position, size, rotation, mesh, pbs); 426 newPrim = new BulletXPrim(name, this, position, size, rotation, mesh, pbs, isPhysical);
432 _prims.Add(newPrim); 427 _prims.Add(newPrim);
433 } 428 }
434 return newPrim; 429 return newPrim;
@@ -641,7 +636,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
641 public class BulletXActor : PhysicsActor 636 public class BulletXActor : PhysicsActor
642 { 637 {
643 protected bool flying = false; 638 protected bool flying = false;
644 protected bool _physical = true; 639 protected bool _physical = false;
645 protected PhysicsVector _position; 640 protected PhysicsVector _position;
646 protected PhysicsVector _velocity; 641 protected PhysicsVector _velocity;
647 protected PhysicsVector _size; 642 protected PhysicsVector _size;
@@ -722,8 +717,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin
722 717
723 public override bool IsPhysical 718 public override bool IsPhysical
724 { 719 {
725 get { return false; } 720 get { return _physical; }
726 set { return; } 721 set { _physical = value; }
727 } 722 }
728 723
729 public override bool Flying 724 public override bool Flying
@@ -736,17 +731,6 @@ namespace OpenSim.Region.Physics.BulletXPlugin
736 get { return iscolliding; } 731 get { return iscolliding; }
737 set { iscolliding = value; } 732 set { iscolliding = value; }
738 } 733 }
739 /*public override bool Physical
740 {
741 get
742 {
743 return _physical;
744 }
745 set
746 {
747 _physical = value;
748 }
749 }*/
750 public virtual void SetAcceleration(PhysicsVector accel) 734 public virtual void SetAcceleration(PhysicsVector accel)
751 { 735 {
752 lock (BulletXScene.BulletXLock) 736 lock (BulletXScene.BulletXLock)
@@ -854,6 +838,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin
854 //. 838 //.
855 _acceleration = acceleration; 839 _acceleration = acceleration;
856 _orientation = orientation; 840 _orientation = orientation;
841 _physical = true;
842
857 float _mass = 50.0f; //This depends of avatar's dimensions 843 float _mass = 50.0f; //This depends of avatar's dimensions
858 //For RigidBody Constructor. The next values might change 844 //For RigidBody Constructor. The next values might change
859 float _linearDamping = 0.0f; 845 float _linearDamping = 0.0f;
@@ -1003,25 +989,23 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1003 private BulletXScene _parent_scene; 989 private BulletXScene _parent_scene;
1004 990
1005 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, 991 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size,
1006 AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs) 992 AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs, bool isPhysical)
1007 : this(primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs) 993 : this(primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs, isPhysical)
1008 { 994 {
1009 } 995 }
1010 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, 996 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity,
1011 PhysicsVector size, 997 PhysicsVector size,
1012 PhysicsVector aceleration, AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs) 998 PhysicsVector acceleration, AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs,
999 bool isPhysical)
1013 { 1000 {
1014 if ((size.X == 0) || (size.Y == 0) || (size.Z == 0)) throw new Exception("Size 0"); 1001 if ((size.X == 0) || (size.Y == 0) || (size.Z == 0)) throw new Exception("Size 0");
1015 if (rotation.Norm == 0f) rotation = AxiomQuaternion.Identity; 1002 if (rotation.Norm == 0f) rotation = AxiomQuaternion.Identity;
1016 1003
1017 _position = pos; 1004 _position = pos;
1018 //ZZZ 1005 _physical = isPhysical;
1019 _physical = false; 1006 _velocity = _physical ? velocity : new PhysicsVector();
1020 //zzz
1021 if (_physical) _velocity = velocity;
1022 else _velocity = new PhysicsVector();
1023 _size = size; 1007 _size = size;
1024 _acceleration = aceleration; 1008 _acceleration = acceleration;
1025 _orientation = rotation; 1009 _orientation = rotation;
1026 1010
1027 _parent_scene = parent_scene; 1011 _parent_scene = parent_scene;
@@ -1068,26 +1052,18 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1068 get 1052 get
1069 { 1053 {
1070 //For now all prims are boxes 1054 //For now all prims are boxes
1071 //ZZZ 1055 return (_physical ? 1 : 0) * _density * _size.X * _size.Y * _size.Z;
1072 return _density * _size.X * _size.Y * _size.Z;
1073 //return (_physical ? 1 : 0) * _density * _size.X * _size.Y * _size.Z;
1074 //zzz
1075 } 1056 }
1076 } 1057 }
1077 public Boolean Physical 1058 public override bool IsPhysical
1078 {
1079 get { return _physical; }
1080 set { _physical = value; }
1081 }
1082 /*public override bool Physical
1083 { 1059 {
1084 get 1060 get
1085 { 1061 {
1086 return base.Physical; 1062 return base.IsPhysical;
1087 } 1063 }
1088 set 1064 set
1089 { 1065 {
1090 base.Physical = value; 1066 base.IsPhysical = value;
1091 if (value) 1067 if (value)
1092 { 1068 {
1093 //--- 1069 //---
@@ -1100,10 +1076,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1100 //--- 1076 //---
1101 PhysicsPluginManager.PhysicsPluginMessage("Physical - SetMassProps", true); 1077 PhysicsPluginManager.PhysicsPluginMessage("Physical - SetMassProps", true);
1102 //--- 1078 //---
1103 this.rigidBody.SetMassProps(Mass, new MonoXnaCompactMaths.Vector3()); 1079 this.rigidBody.SetMassProps(Mass, new Vector3());
1104 } 1080 }
1105 } 1081 }
1106 }*/ 1082 }
1107 public override bool Flying 1083 public override bool Flying
1108 { 1084 {
1109 get { return base.Flying; } 1085 get { return base.Flying; }
@@ -1184,10 +1160,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1184 CollisionShape _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size) / 2.0f); 1160 CollisionShape _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size) / 2.0f);
1185 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); 1161 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
1186 Vector3 _localInertia = new Vector3(); 1162 Vector3 _localInertia = new Vector3();
1187 //ZZZ 1163 if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
1188 if (Mass > 0) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
1189 //if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
1190 //zzz
1191 rigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution); 1164 rigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution);
1192 //rigidBody.ActivationState = ActivationState.DisableDeactivation; 1165 //rigidBody.ActivationState = ActivationState.DisableDeactivation;
1193 //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition 1166 //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition