aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
diff options
context:
space:
mode:
authorBlueWall2011-11-23 10:50:29 -0500
committerBlueWall2011-11-23 10:50:29 -0500
commit0738fc43e46bd12343c4e43ea19affe65514521a (patch)
tree607b0dcb20f1f05675a00af00ab94fe2f86c5a1e /OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
parentShell Environment Variables in config (diff)
parentLog error if we attempt to add/remove an OdeCharacter from the _characters li... (diff)
downloadopensim-SC-0738fc43e46bd12343c4e43ea19affe65514521a.zip
opensim-SC-0738fc43e46bd12343c4e43ea19affe65514521a.tar.gz
opensim-SC-0738fc43e46bd12343c4e43ea19affe65514521a.tar.bz2
opensim-SC-0738fc43e46bd12343c4e43ea19affe65514521a.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODECharacter.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs234
1 files changed, 117 insertions, 117 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index cfe64f2..489a23a 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -542,123 +542,6 @@ namespace OpenSim.Region.Physics.OdePlugin
542 } 542 }
543 543
544 /// <summary> 544 /// <summary>
545 /// This creates the Avatar's physical Surrogate in ODE at the position supplied
546 /// </summary>
547 /// <remarks>
548 /// WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
549 /// to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
550 /// place that is safe to call this routine AvatarGeomAndBodyCreation.
551 /// </remarks>
552 /// <param name="npositionX"></param>
553 /// <param name="npositionY"></param>
554 /// <param name="npositionZ"></param>
555 /// <param name="tensor"></param>
556 private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor)
557 {
558 int dAMotorEuler = 1;
559// _parent_scene.waitForSpaceUnlock(_parent_scene.space);
560 if (CAPSULE_LENGTH <= 0)
561 {
562 m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
563 CAPSULE_LENGTH = 0.01f;
564 }
565
566 if (CAPSULE_RADIUS <= 0)
567 {
568 m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
569 CAPSULE_RADIUS = 0.01f;
570 }
571
572 Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
573
574 d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
575 d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
576
577 d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
578 Body = d.BodyCreate(_parent_scene.world);
579 d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
580
581 _position.X = npositionX;
582 _position.Y = npositionY;
583 _position.Z = npositionZ;
584
585 m_taintPosition = _position;
586
587 d.BodySetMass(Body, ref ShellMass);
588 d.Matrix3 m_caprot;
589 // 90 Stand up on the cap of the capped cyllinder
590 if (_parent_scene.IsAvCapsuleTilted)
591 {
592 d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2));
593 }
594 else
595 {
596 d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2));
597 }
598
599 d.GeomSetRotation(Shell, ref m_caprot);
600 d.BodySetRotation(Body, ref m_caprot);
601
602 d.GeomSetBody(Shell, Body);
603
604 // The purpose of the AMotor here is to keep the avatar's physical
605 // surrogate from rotating while moving
606 Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
607 d.JointAttach(Amotor, Body, IntPtr.Zero);
608 d.JointSetAMotorMode(Amotor, dAMotorEuler);
609 d.JointSetAMotorNumAxes(Amotor, 3);
610 d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0);
611 d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0);
612 d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1);
613 d.JointSetAMotorAngle(Amotor, 0, 0);
614 d.JointSetAMotorAngle(Amotor, 1, 0);
615 d.JointSetAMotorAngle(Amotor, 2, 0);
616
617 // These lowstops and high stops are effectively (no wiggle room)
618 if (_parent_scene.IsAvCapsuleTilted)
619 {
620 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f);
621 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f);
622 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f);
623 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f);
624 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f);
625 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f);
626 }
627 else
628 {
629 #region Documentation of capsule motor LowStop and HighStop parameters
630 // Intentionally introduce some tilt into the capsule by setting
631 // the motor stops to small epsilon values. This small tilt prevents
632 // the capsule from falling into the terrain; a straight-up capsule
633 // (with -0..0 motor stops) falls into the terrain for reasons yet
634 // to be comprehended in their entirety.
635 #endregion
636 AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero);
637 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f);
638 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
639 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f);
640 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.08f); // must be same as lowstop, else a different, spurious tilt is introduced
641 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop
642 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.08f); // same as lowstop
643 }
644
645 // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the
646 // capped cyllinder will fall over
647 d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
648 d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor);
649
650 //d.Matrix3 bodyrotation = d.BodyGetRotation(Body);
651 //d.QfromR(
652 //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068,
653 //
654 //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
655 //standupStraight();
656
657 _parent_scene.geom_name_map[Shell] = Name;
658 _parent_scene.actor_name_map[Shell] = this;
659 }
660
661 /// <summary>
662 /// Uses the capped cyllinder volume formula to calculate the avatar's mass. 545 /// Uses the capped cyllinder volume formula to calculate the avatar's mass.
663 /// This may be used in calculations in the scene/scenepresence 546 /// This may be used in calculations in the scene/scenepresence
664 /// </summary> 547 /// </summary>
@@ -1126,6 +1009,123 @@ namespace OpenSim.Region.Physics.OdePlugin
1126 } 1009 }
1127 1010
1128 /// <summary> 1011 /// <summary>
1012 /// This creates the Avatar's physical Surrogate in ODE at the position supplied
1013 /// </summary>
1014 /// <remarks>
1015 /// WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
1016 /// to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
1017 /// place that is safe to call this routine AvatarGeomAndBodyCreation.
1018 /// </remarks>
1019 /// <param name="npositionX"></param>
1020 /// <param name="npositionY"></param>
1021 /// <param name="npositionZ"></param>
1022 /// <param name="tensor"></param>
1023 private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor)
1024 {
1025 int dAMotorEuler = 1;
1026// _parent_scene.waitForSpaceUnlock(_parent_scene.space);
1027 if (CAPSULE_LENGTH <= 0)
1028 {
1029 m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
1030 CAPSULE_LENGTH = 0.01f;
1031 }
1032
1033 if (CAPSULE_RADIUS <= 0)
1034 {
1035 m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
1036 CAPSULE_RADIUS = 0.01f;
1037 }
1038
1039 Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
1040
1041 d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
1042 d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
1043
1044 d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
1045 Body = d.BodyCreate(_parent_scene.world);
1046 d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
1047
1048 _position.X = npositionX;
1049 _position.Y = npositionY;
1050 _position.Z = npositionZ;
1051
1052 m_taintPosition = _position;
1053
1054 d.BodySetMass(Body, ref ShellMass);
1055 d.Matrix3 m_caprot;
1056 // 90 Stand up on the cap of the capped cyllinder
1057 if (_parent_scene.IsAvCapsuleTilted)
1058 {
1059 d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2));
1060 }
1061 else
1062 {
1063 d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2));
1064 }
1065
1066 d.GeomSetRotation(Shell, ref m_caprot);
1067 d.BodySetRotation(Body, ref m_caprot);
1068
1069 d.GeomSetBody(Shell, Body);
1070
1071 // The purpose of the AMotor here is to keep the avatar's physical
1072 // surrogate from rotating while moving
1073 Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
1074 d.JointAttach(Amotor, Body, IntPtr.Zero);
1075 d.JointSetAMotorMode(Amotor, dAMotorEuler);
1076 d.JointSetAMotorNumAxes(Amotor, 3);
1077 d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0);
1078 d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0);
1079 d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1);
1080 d.JointSetAMotorAngle(Amotor, 0, 0);
1081 d.JointSetAMotorAngle(Amotor, 1, 0);
1082 d.JointSetAMotorAngle(Amotor, 2, 0);
1083
1084 // These lowstops and high stops are effectively (no wiggle room)
1085 if (_parent_scene.IsAvCapsuleTilted)
1086 {
1087 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f);
1088 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f);
1089 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f);
1090 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f);
1091 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f);
1092 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f);
1093 }
1094 else
1095 {
1096 #region Documentation of capsule motor LowStop and HighStop parameters
1097 // Intentionally introduce some tilt into the capsule by setting
1098 // the motor stops to small epsilon values. This small tilt prevents
1099 // the capsule from falling into the terrain; a straight-up capsule
1100 // (with -0..0 motor stops) falls into the terrain for reasons yet
1101 // to be comprehended in their entirety.
1102 #endregion
1103 AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero);
1104 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f);
1105 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
1106 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f);
1107 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.08f); // must be same as lowstop, else a different, spurious tilt is introduced
1108 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop
1109 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.08f); // same as lowstop
1110 }
1111
1112 // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the
1113 // capped cyllinder will fall over
1114 d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
1115 d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor);
1116
1117 //d.Matrix3 bodyrotation = d.BodyGetRotation(Body);
1118 //d.QfromR(
1119 //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068,
1120 //
1121 //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
1122 //standupStraight();
1123
1124 _parent_scene.geom_name_map[Shell] = Name;
1125 _parent_scene.actor_name_map[Shell] = this;
1126 }
1127
1128 /// <summary>
1129 /// Cleanup the things we use in the scene. 1129 /// Cleanup the things we use in the scene.
1130 /// </summary> 1130 /// </summary>
1131 internal void Destroy() 1131 internal void Destroy()