aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
diff options
context:
space:
mode:
authordarok2007-11-03 19:33:00 +0000
committerdarok2007-11-03 19:33:00 +0000
commitfbf3c6a768274cfdb1e91e73758f9ee893094153 (patch)
tree6b6bd68b1061fa3ca4df20a044b55a50e0d354e2 /OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
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 'OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs')
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs75
1 files changed, 24 insertions, 51 deletions
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