aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs10
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs7
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs260
3 files changed, 258 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index c4bb889..4a4c294 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -182,6 +182,11 @@ namespace OpenSim.Region.Physics.Manager
182 } 182 }
183 } 183 }
184 184
185 public virtual void SetMaterial (int material)
186 {
187
188 }
189
185 public abstract PhysicsVector Position { get; set; } 190 public abstract PhysicsVector Position { get; set; }
186 public abstract float Mass { get; } 191 public abstract float Mass { get; }
187 public abstract PhysicsVector Force { get; set; } 192 public abstract PhysicsVector Force { get; set; }
@@ -334,6 +339,11 @@ namespace OpenSim.Region.Physics.Manager
334 339
335 } 340 }
336 341
342 public override void SetMaterial(int material)
343 {
344
345 }
346
337 public override PhysicsVector CenterOfMass 347 public override PhysicsVector CenterOfMass
338 { 348 {
339 get { return PhysicsVector.Zero; } 349 get { return PhysicsVector.Zero; }
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index adb559a..7b3d18f 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -169,6 +169,8 @@ namespace OpenSim.Region.Physics.OdePlugin
169 169
170 private ODEVehicleSettings m_vehicle; 170 private ODEVehicleSettings m_vehicle;
171 171
172 internal int m_material = (int)Material.Wood;
173
172 public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, 174 public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size,
173 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) 175 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
174 { 176 {
@@ -3096,5 +3098,10 @@ namespace OpenSim.Region.Physics.OdePlugin
3096 dst.I.M22 = src.I.M22; 3098 dst.I.M22 = src.I.M22;
3097 } 3099 }
3098 3100
3101 public override void SetMaterial(int pMaterial)
3102 {
3103 m_material = pMaterial;
3104 }
3105
3099 } 3106 }
3100} 3107}
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 1abedf5..178e6fd 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -123,6 +123,28 @@ namespace OpenSim.Region.Physics.OdePlugin
123 Selected = 0x00000100 123 Selected = 0x00000100
124 } 124 }
125 125
126 /// <summary>
127 /// Material type for a primitive
128 /// </summary>
129 public enum Material : int
130 {
131 /// <summary></summary>
132 Stone = 0,
133 /// <summary></summary>
134 Metal = 1,
135 /// <summary></summary>
136 Glass = 2,
137 /// <summary></summary>
138 Wood = 3,
139 /// <summary></summary>
140 Flesh = 4,
141 /// <summary></summary>
142 Plastic = 5,
143 /// <summary></summary>
144 Rubber = 6
145
146 }
147
126 public sealed class OdeScene : PhysicsScene 148 public sealed class OdeScene : PhysicsScene
127 { 149 {
128 private readonly ILog m_log; 150 private readonly ILog m_log;
@@ -239,6 +261,7 @@ namespace OpenSim.Region.Physics.OdePlugin
239 private d.Contact AvatarMovementprimContact; 261 private d.Contact AvatarMovementprimContact;
240 private d.Contact AvatarMovementTerrainContact; 262 private d.Contact AvatarMovementTerrainContact;
241 private d.Contact WaterContact; 263 private d.Contact WaterContact;
264 private d.Contact[,] m_materialContacts;
242 265
243//Ckrinke: Comment out until used. We declare it, initialize it, but do not use it 266//Ckrinke: Comment out until used. We declare it, initialize it, but do not use it
244//Ckrinke private int m_randomizeWater = 200; 267//Ckrinke private int m_randomizeWater = 200;
@@ -319,6 +342,11 @@ namespace OpenSim.Region.Physics.OdePlugin
319 _heightmap = new float[514*514]; 342 _heightmap = new float[514*514];
320 _watermap = new float[258 * 258]; 343 _watermap = new float[258 * 258];
321 344
345
346
347
348
349
322 // Zero out the prim spaces array (we split our space into smaller spaces so 350 // Zero out the prim spaces array (we split our space into smaller spaces so
323 // we can hit test less. 351 // we can hit test less.
324 } 352 }
@@ -479,6 +507,131 @@ namespace OpenSim.Region.Physics.OdePlugin
479 AvatarMovementTerrainContact.surface.bounce = mTerrainContactBounce; 507 AvatarMovementTerrainContact.surface.bounce = mTerrainContactBounce;
480 AvatarMovementTerrainContact.surface.soft_erp = mTerrainContactERP; 508 AvatarMovementTerrainContact.surface.soft_erp = mTerrainContactERP;
481 509
510
511 /*
512 <summary></summary>
513 Stone = 0,
514 /// <summary></summary>
515 Metal = 1,
516 /// <summary></summary>
517 Glass = 2,
518 /// <summary></summary>
519 Wood = 3,
520 /// <summary></summary>
521 Flesh = 4,
522 /// <summary></summary>
523 Plastic = 5,
524 /// <summary></summary>
525 Rubber = 6
526 */
527
528 m_materialContacts = new d.Contact[7,2];
529
530 m_materialContacts[(int)Material.Stone, 0] = new d.Contact();
531 m_materialContacts[(int)Material.Stone, 0].surface.mode |= d.ContactFlags.SoftERP;
532 m_materialContacts[(int)Material.Stone, 0].surface.mu = nmAvatarObjectContactFriction;
533 m_materialContacts[(int)Material.Stone, 0].surface.bounce = nmAvatarObjectContactBounce;
534 m_materialContacts[(int)Material.Stone, 0].surface.soft_cfm = 0.010f;
535 m_materialContacts[(int)Material.Stone, 0].surface.soft_erp = 0.010f;
536
537 m_materialContacts[(int)Material.Stone, 1] = new d.Contact();
538 m_materialContacts[(int)Material.Stone, 1].surface.mode |= d.ContactFlags.SoftERP;
539 m_materialContacts[(int)Material.Stone, 1].surface.mu = mAvatarObjectContactFriction;
540 m_materialContacts[(int)Material.Stone, 1].surface.bounce = mAvatarObjectContactBounce;
541 m_materialContacts[(int)Material.Stone, 1].surface.soft_cfm = 0.010f;
542 m_materialContacts[(int)Material.Stone, 1].surface.soft_erp = 0.010f;
543
544 m_materialContacts[(int)Material.Metal, 0] = new d.Contact();
545 m_materialContacts[(int)Material.Metal, 0].surface.mode |= d.ContactFlags.SoftERP;
546 m_materialContacts[(int)Material.Metal, 0].surface.mu = nmAvatarObjectContactFriction;
547 m_materialContacts[(int)Material.Metal, 0].surface.bounce = nmAvatarObjectContactBounce;
548 m_materialContacts[(int)Material.Metal, 0].surface.soft_cfm = 0.010f;
549 m_materialContacts[(int)Material.Metal, 0].surface.soft_erp = 0.010f;
550
551 m_materialContacts[(int)Material.Metal, 1] = new d.Contact();
552 m_materialContacts[(int)Material.Metal, 1].surface.mode |= d.ContactFlags.SoftERP;
553 m_materialContacts[(int)Material.Metal, 1].surface.mu = mAvatarObjectContactFriction;
554 m_materialContacts[(int)Material.Metal, 1].surface.bounce = mAvatarObjectContactBounce;
555 m_materialContacts[(int)Material.Metal, 1].surface.soft_cfm = 0.010f;
556 m_materialContacts[(int)Material.Metal, 1].surface.soft_erp = 0.010f;
557
558 m_materialContacts[(int)Material.Glass, 0] = new d.Contact();
559 m_materialContacts[(int)Material.Glass, 0].surface.mode |= d.ContactFlags.SoftERP;
560 m_materialContacts[(int)Material.Glass, 0].surface.mu = 1f;
561 m_materialContacts[(int)Material.Glass, 0].surface.bounce = 0.5f;
562 m_materialContacts[(int)Material.Glass, 0].surface.soft_cfm = 0.010f;
563 m_materialContacts[(int)Material.Glass, 0].surface.soft_erp = 0.010f;
564
565 /*
566 private float nmAvatarObjectContactFriction = 250f;
567 private float nmAvatarObjectContactBounce = 0.1f;
568
569 private float mAvatarObjectContactFriction = 75f;
570 private float mAvatarObjectContactBounce = 0.1f;
571 */
572 m_materialContacts[(int)Material.Glass, 1] = new d.Contact();
573 m_materialContacts[(int)Material.Glass, 1].surface.mode |= d.ContactFlags.SoftERP;
574 m_materialContacts[(int)Material.Glass, 1].surface.mu = 1f;
575 m_materialContacts[(int)Material.Glass, 1].surface.bounce = 0.5f;
576 m_materialContacts[(int)Material.Glass, 1].surface.soft_cfm = 0.010f;
577 m_materialContacts[(int)Material.Glass, 1].surface.soft_erp = 0.010f;
578
579 m_materialContacts[(int)Material.Wood, 0] = new d.Contact();
580 m_materialContacts[(int)Material.Wood, 0].surface.mode |= d.ContactFlags.SoftERP;
581 m_materialContacts[(int)Material.Wood, 0].surface.mu = nmAvatarObjectContactFriction;
582 m_materialContacts[(int)Material.Wood, 0].surface.bounce = nmAvatarObjectContactBounce;
583 m_materialContacts[(int)Material.Wood, 0].surface.soft_cfm = 0.010f;
584 m_materialContacts[(int)Material.Wood, 0].surface.soft_erp = 0.010f;
585
586 m_materialContacts[(int)Material.Wood, 1] = new d.Contact();
587 m_materialContacts[(int)Material.Wood, 1].surface.mode |= d.ContactFlags.SoftERP;
588 m_materialContacts[(int)Material.Wood, 1].surface.mu = mAvatarObjectContactFriction;
589 m_materialContacts[(int)Material.Wood, 1].surface.bounce = mAvatarObjectContactBounce;
590 m_materialContacts[(int)Material.Wood, 1].surface.soft_cfm = 0.010f;
591 m_materialContacts[(int)Material.Wood, 1].surface.soft_erp = 0.010f;
592
593 m_materialContacts[(int)Material.Flesh, 0] = new d.Contact();
594 m_materialContacts[(int)Material.Flesh, 0].surface.mode |= d.ContactFlags.SoftERP;
595 m_materialContacts[(int)Material.Flesh, 0].surface.mu = nmAvatarObjectContactFriction;
596 m_materialContacts[(int)Material.Flesh, 0].surface.bounce = nmAvatarObjectContactBounce;
597 m_materialContacts[(int)Material.Flesh, 0].surface.soft_cfm = 0.010f;
598 m_materialContacts[(int)Material.Flesh, 0].surface.soft_erp = 0.010f;
599
600 m_materialContacts[(int)Material.Flesh, 1] = new d.Contact();
601 m_materialContacts[(int)Material.Flesh, 1].surface.mode |= d.ContactFlags.SoftERP;
602 m_materialContacts[(int)Material.Flesh, 1].surface.mu = mAvatarObjectContactFriction;
603 m_materialContacts[(int)Material.Flesh, 1].surface.bounce = mAvatarObjectContactBounce;
604 m_materialContacts[(int)Material.Flesh, 1].surface.soft_cfm = 0.010f;
605 m_materialContacts[(int)Material.Flesh, 1].surface.soft_erp = 0.010f;
606
607 m_materialContacts[(int)Material.Plastic, 0] = new d.Contact();
608 m_materialContacts[(int)Material.Plastic, 0].surface.mode |= d.ContactFlags.SoftERP;
609 m_materialContacts[(int)Material.Plastic, 0].surface.mu = nmAvatarObjectContactFriction;
610 m_materialContacts[(int)Material.Plastic, 0].surface.bounce = nmAvatarObjectContactBounce;
611 m_materialContacts[(int)Material.Plastic, 0].surface.soft_cfm = 0.010f;
612 m_materialContacts[(int)Material.Plastic, 0].surface.soft_erp = 0.010f;
613
614 m_materialContacts[(int)Material.Plastic, 1] = new d.Contact();
615 m_materialContacts[(int)Material.Plastic, 1].surface.mode |= d.ContactFlags.SoftERP;
616 m_materialContacts[(int)Material.Plastic, 1].surface.mu = mAvatarObjectContactFriction;
617 m_materialContacts[(int)Material.Plastic, 1].surface.bounce = mAvatarObjectContactBounce;
618 m_materialContacts[(int)Material.Plastic, 1].surface.soft_cfm = 0.010f;
619 m_materialContacts[(int)Material.Plastic, 1].surface.soft_erp = 0.010f;
620
621 m_materialContacts[(int)Material.Rubber, 0] = new d.Contact();
622 m_materialContacts[(int)Material.Rubber, 0].surface.mode |= d.ContactFlags.SoftERP;
623 m_materialContacts[(int)Material.Rubber, 0].surface.mu = nmAvatarObjectContactFriction;
624 m_materialContacts[(int)Material.Rubber, 0].surface.bounce = nmAvatarObjectContactBounce;
625 m_materialContacts[(int)Material.Rubber, 0].surface.soft_cfm = 0.010f;
626 m_materialContacts[(int)Material.Rubber, 0].surface.soft_erp = 0.010f;
627
628 m_materialContacts[(int)Material.Rubber, 1] = new d.Contact();
629 m_materialContacts[(int)Material.Rubber, 1].surface.mode |= d.ContactFlags.SoftERP;
630 m_materialContacts[(int)Material.Rubber, 1].surface.mu = mAvatarObjectContactFriction;
631 m_materialContacts[(int)Material.Rubber, 1].surface.bounce = mAvatarObjectContactBounce;
632 m_materialContacts[(int)Material.Rubber, 1].surface.soft_cfm = 0.010f;
633 m_materialContacts[(int)Material.Rubber, 1].surface.soft_erp = 0.010f;
634
482 d.HashSpaceSetLevels(space, worldHashspaceLow, worldHashspaceHigh); 635 d.HashSpaceSetLevels(space, worldHashspaceLow, worldHashspaceHigh);
483 636
484 // Set the gravity,, don't disable things automatically (we set it explicitly on some things) 637 // Set the gravity,, don't disable things automatically (we set it explicitly on some things)
@@ -869,13 +1022,63 @@ namespace OpenSim.Region.Physics.OdePlugin
869 } 1022 }
870 else 1023 else
871 { 1024 {
872 // Use the non moving terrain contact 1025 if (p2.PhysicsActorType == (int)ActorTypes.Agent)
873 TerrainContact.geom = contacts[i];
874 _perloopContact.Add(contacts[i]);
875 if (m_global_contactcount < maxContactsbeforedeath)
876 { 1026 {
877 joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); 1027 // Use the non moving terrain contact
878 m_global_contactcount++; 1028 TerrainContact.geom = contacts[i];
1029 _perloopContact.Add(contacts[i]);
1030 if (m_global_contactcount < maxContactsbeforedeath)
1031 {
1032 joint = d.JointCreateContact(world, contactgroup, ref TerrainContact);
1033 m_global_contactcount++;
1034 }
1035 }
1036 else
1037 {
1038 if (p2.PhysicsActorType == (int)ActorTypes.Prim && p1.PhysicsActorType == (int)ActorTypes.Prim)
1039 {
1040 // prim prim contact
1041 int pj294950 = 0;
1042 int movintYN = 0;
1043 // prim terrain contact
1044 if (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)
1045 {
1046 movintYN = 1;
1047 }
1048 int material = ((OdePrim)p2).m_material;
1049 //m_log.DebugFormat("Material: {0}", material);
1050 m_materialContacts[material, movintYN].geom = contacts[i];
1051 _perloopContact.Add(contacts[i]);
1052
1053 if (m_global_contactcount < maxContactsbeforedeath)
1054 {
1055 joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, movintYN]);
1056 m_global_contactcount++;
1057
1058 }
1059
1060 }
1061 else
1062 {
1063
1064 int movintYN = 0;
1065 // prim terrain contact
1066 if (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)
1067 {
1068 movintYN = 1;
1069 }
1070 int material = ((OdePrim)p2).m_material;
1071 //m_log.DebugFormat("Material: {0}", material);
1072 m_materialContacts[material, movintYN].geom = contacts[i];
1073 _perloopContact.Add(contacts[i]);
1074
1075 if (m_global_contactcount < maxContactsbeforedeath)
1076 {
1077 joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, movintYN]);
1078 m_global_contactcount++;
1079
1080 }
1081 }
879 } 1082 }
880 } 1083 }
881 //if (p2.PhysicsActorType == (int)ActorTypes.Prim) 1084 //if (p2.PhysicsActorType == (int)ActorTypes.Prim)
@@ -885,13 +1088,14 @@ namespace OpenSim.Region.Physics.OdePlugin
885 } 1088 }
886 else if (name1 == "Water" || name2 == "Water") 1089 else if (name1 == "Water" || name2 == "Water")
887 { 1090 {
1091 /*
888 if ((p2.PhysicsActorType == (int) ActorTypes.Prim)) 1092 if ((p2.PhysicsActorType == (int) ActorTypes.Prim))
889 { 1093 {
890 } 1094 }
891 else 1095 else
892 { 1096 {
893 } 1097 }
894 1098 */
895 //WaterContact.surface.soft_cfm = 0.0000f; 1099 //WaterContact.surface.soft_cfm = 0.0000f;
896 //WaterContact.surface.soft_erp = 0.00000f; 1100 //WaterContact.surface.soft_erp = 0.00000f;
897 if (contacts[i].depth > 0.1f) 1101 if (contacts[i].depth > 0.1f)
@@ -913,28 +1117,46 @@ namespace OpenSim.Region.Physics.OdePlugin
913 { 1117 {
914 // we're colliding with prim or avatar 1118 // we're colliding with prim or avatar
915 // check if we're moving 1119 // check if we're moving
916 if ((p2.PhysicsActorType == (int) ActorTypes.Agent) && 1120 if ((p2.PhysicsActorType == (int)ActorTypes.Agent))
917 (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f))
918 { 1121 {
919 // Use the Movement prim contact 1122 if ((Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f))
920 AvatarMovementprimContact.geom = contacts[i];
921 _perloopContact.Add(contacts[i]);
922 if (m_global_contactcount < maxContactsbeforedeath)
923 { 1123 {
924 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); 1124 // Use the Movement prim contact
925 m_global_contactcount++; 1125 AvatarMovementprimContact.geom = contacts[i];
1126 _perloopContact.Add(contacts[i]);
1127 if (m_global_contactcount < maxContactsbeforedeath)
1128 {
1129 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact);
1130 m_global_contactcount++;
1131 }
1132 }
1133 else
1134 {
1135 // Use the non movement contact
1136 contact.geom = contacts[i];
1137 _perloopContact.Add(contacts[i]);
1138
1139 if (m_global_contactcount < maxContactsbeforedeath)
1140 {
1141 joint = d.JointCreateContact(world, contactgroup, ref contact);
1142 m_global_contactcount++;
1143 }
926 } 1144 }
927 } 1145 }
928 else 1146 else if (p2.PhysicsActorType == (int)ActorTypes.Prim)
929 { 1147 {
930 // Use the non movement contact 1148 //p1.PhysicsActorType
931 contact.geom = contacts[i]; 1149 int material = ((OdePrim)p2).m_material;
1150
1151 //m_log.DebugFormat("Material: {0}", material);
1152 m_materialContacts[material, 0].geom = contacts[i];
932 _perloopContact.Add(contacts[i]); 1153 _perloopContact.Add(contacts[i]);
933 1154
934 if (m_global_contactcount < maxContactsbeforedeath) 1155 if (m_global_contactcount < maxContactsbeforedeath)
935 { 1156 {
936 joint = d.JointCreateContact(world, contactgroup, ref contact); 1157 joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, 0]);
937 m_global_contactcount++; 1158 m_global_contactcount++;
1159
938 } 1160 }
939 } 1161 }
940 } 1162 }