diff options
author | Teravus Ovares | 2008-02-15 21:35:52 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-02-15 21:35:52 +0000 |
commit | be6edefcfb6574c1d011809315bfc464c479844c (patch) | |
tree | 23140c1fc6e72f20289c3ea975b9b70aa8277662 /OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |
parent | Resolve mantis #572 - terrain help printed multiple times when change-region ... (diff) | |
download | opensim-SC_OLD-be6edefcfb6574c1d011809315bfc464c479844c.zip opensim-SC_OLD-be6edefcfb6574c1d011809315bfc464c479844c.tar.gz opensim-SC_OLD-be6edefcfb6574c1d011809315bfc464c479844c.tar.bz2 opensim-SC_OLD-be6edefcfb6574c1d011809315bfc464c479844c.tar.xz |
* ODE Stability update 4 :D
* Changed the way meshing requests get sent to the ODEPlugin
* Numerous other fixes
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODEPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 160 |
1 files changed, 141 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 59c1f87..fae5316 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -682,6 +682,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
682 | 682 | ||
683 | public void changePhysicsStatus(float timestap) | 683 | public void changePhysicsStatus(float timestap) |
684 | { | 684 | { |
685 | while (ode.lockquery()) | ||
686 | { | ||
687 | } | ||
688 | ode.dlock(_parent_scene.world); | ||
689 | |||
685 | if (m_isphysical == true) | 690 | if (m_isphysical == true) |
686 | { | 691 | { |
687 | if (Body == (IntPtr) 0) | 692 | if (Body == (IntPtr) 0) |
@@ -696,6 +701,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
696 | disableBody(); | 701 | disableBody(); |
697 | } | 702 | } |
698 | } | 703 | } |
704 | |||
705 | ode.dunlock(_parent_scene.world); | ||
706 | |||
699 | resetCollisionAccounting(); | 707 | resetCollisionAccounting(); |
700 | m_taintPhysics = m_isphysical; | 708 | m_taintPhysics = m_isphysical; |
701 | } | 709 | } |
@@ -730,7 +738,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
730 | d.SpaceRemove(m_targetSpace, prim_geom); | 738 | d.SpaceRemove(m_targetSpace, prim_geom); |
731 | } | 739 | } |
732 | d.GeomDestroy(prim_geom); | 740 | d.GeomDestroy(prim_geom); |
733 | 741 | prim_geom = (IntPtr)0; | |
734 | // we don't need to do space calculation because the client sends a position update also. | 742 | // we don't need to do space calculation because the client sends a position update also. |
735 | 743 | ||
736 | // Construction of new prim | 744 | // Construction of new prim |
@@ -742,6 +750,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
742 | if (mesh != null) | 750 | if (mesh != null) |
743 | { | 751 | { |
744 | setMesh(_parent_scene, mesh); | 752 | setMesh(_parent_scene, mesh); |
753 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
754 | d.Quaternion myrot = new d.Quaternion(); | ||
755 | myrot.W = _orientation.w; | ||
756 | myrot.X = _orientation.x; | ||
757 | myrot.Y = _orientation.y; | ||
758 | myrot.Z = _orientation.z; | ||
759 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
760 | |||
761 | |||
762 | //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); | ||
763 | if (IsPhysical && Body == (IntPtr)0) | ||
764 | { | ||
765 | // Re creates body on size. | ||
766 | // EnableBody also does setMass() | ||
767 | enableBody(); | ||
768 | d.BodyEnable(Body); | ||
769 | } | ||
745 | } | 770 | } |
746 | else | 771 | else |
747 | { | 772 | { |
@@ -870,37 +895,120 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
870 | disableBody(); | 895 | disableBody(); |
871 | } | 896 | } |
872 | d.GeomDestroy(prim_geom); | 897 | d.GeomDestroy(prim_geom); |
873 | if (_mesh != null) | 898 | prim_geom = (IntPtr) 0; |
874 | { | 899 | // we don't need to do space calculation because the client sends a position update also. |
875 | d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); | ||
876 | } | ||
877 | 900 | ||
878 | // Construction of new prim | 901 | // Construction of new prim |
879 | if (_parent_scene.needsMeshing(_pbs)) | 902 | if (_parent_scene.needsMeshing(_pbs)) |
880 | { | 903 | { |
904 | // Don't need to re-enable body.. it's done in SetMesh | ||
881 | IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); | 905 | IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); |
906 | // createmesh returns null when it's a shape that isn't a cube. | ||
882 | if (mesh != null) | 907 | if (mesh != null) |
883 | { | 908 | { |
884 | setMesh(_parent_scene, mesh); | 909 | setMesh(_parent_scene, mesh); |
910 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
911 | d.Quaternion myrot = new d.Quaternion(); | ||
912 | myrot.W = _orientation.w; | ||
913 | myrot.X = _orientation.x; | ||
914 | myrot.Y = _orientation.y; | ||
915 | myrot.Z = _orientation.z; | ||
916 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
917 | |||
918 | |||
919 | //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); | ||
920 | if (IsPhysical && Body == (IntPtr)0) | ||
921 | { | ||
922 | // Re creates body on size. | ||
923 | // EnableBody also does setMass() | ||
924 | enableBody(); | ||
925 | d.BodyEnable(Body); | ||
926 | } | ||
885 | } | 927 | } |
886 | else | 928 | else |
887 | { | 929 | { |
888 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 930 | if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) |
889 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | 931 | { |
932 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) | ||
933 | { | ||
934 | if (((_size.X / 2f) > 0f) && ((_size.X / 2f) < 1000)) | ||
935 | { | ||
936 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
937 | SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); | ||
938 | } | ||
939 | else | ||
940 | { | ||
941 | m_log.Info("[PHYSICS]: Failed to load a sphere bad size"); | ||
942 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
943 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
944 | } | ||
945 | |||
946 | } | ||
947 | else | ||
948 | { | ||
949 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
950 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
951 | } | ||
952 | } | ||
953 | //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight) | ||
954 | //{ | ||
955 | //Cyllinder | ||
956 | //if (_size.X == _size.Y) | ||
957 | //{ | ||
958 | // prim_geom = d.CreateCylinder(m_targetSpace, _size.X / 2, _size.Z); | ||
959 | //} | ||
960 | //else | ||
961 | //{ | ||
962 | //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | ||
963 | //} | ||
964 | //} | ||
965 | else | ||
966 | { | ||
967 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
968 | SetGeom(prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
969 | } | ||
970 | //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | ||
971 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
972 | d.Quaternion myrot = new d.Quaternion(); | ||
973 | myrot.W = _orientation.w; | ||
974 | myrot.X = _orientation.x; | ||
975 | myrot.Y = _orientation.y; | ||
976 | myrot.Z = _orientation.z; | ||
977 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
890 | } | 978 | } |
891 | } | 979 | } |
892 | else | 980 | else |
893 | { | 981 | { |
894 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 982 | if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) |
895 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | 983 | { |
896 | } | 984 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) |
897 | if (IsPhysical && Body == (IntPtr) 0) | 985 | { |
898 | { | 986 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
899 | //re-create new body | 987 | SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); |
900 | enableBody(); | 988 | } |
901 | } | 989 | else |
902 | else | 990 | { |
903 | { | 991 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
992 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
993 | } | ||
994 | } | ||
995 | //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight) | ||
996 | //{ | ||
997 | //Cyllinder | ||
998 | //if (_size.X == _size.Y) | ||
999 | //{ | ||
1000 | //prim_geom = d.CreateCylinder(m_targetSpace, _size.X / 2, _size.Z); | ||
1001 | //} | ||
1002 | //else | ||
1003 | //{ | ||
1004 | //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | ||
1005 | //} | ||
1006 | //} | ||
1007 | else | ||
1008 | { | ||
1009 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1010 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
1011 | } | ||
904 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | 1012 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); |
905 | d.Quaternion myrot = new d.Quaternion(); | 1013 | d.Quaternion myrot = new d.Quaternion(); |
906 | myrot.W = _orientation.w; | 1014 | myrot.W = _orientation.w; |
@@ -908,6 +1016,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
908 | myrot.Y = _orientation.y; | 1016 | myrot.Y = _orientation.y; |
909 | myrot.Z = _orientation.z; | 1017 | myrot.Z = _orientation.z; |
910 | d.GeomSetQuaternion(prim_geom, ref myrot); | 1018 | d.GeomSetQuaternion(prim_geom, ref myrot); |
1019 | |||
1020 | |||
1021 | //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); | ||
1022 | if (IsPhysical && Body == (IntPtr)0) | ||
1023 | { | ||
1024 | // Re creates body on size. | ||
1025 | // EnableBody also does setMass() | ||
1026 | enableBody(); | ||
1027 | d.BodyEnable(Body); | ||
1028 | } | ||
911 | } | 1029 | } |
912 | _parent_scene.geom_name_map[prim_geom] = oldname; | 1030 | _parent_scene.geom_name_map[prim_geom] = oldname; |
913 | 1031 | ||
@@ -924,7 +1042,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
924 | } | 1042 | } |
925 | ode.dlock(_parent_scene.world); | 1043 | ode.dlock(_parent_scene.world); |
926 | 1044 | ||
927 | System.Threading.Thread.Sleep(2); | 1045 | |
928 | lock (m_forcelist) | 1046 | lock (m_forcelist) |
929 | { | 1047 | { |
930 | //m_log.Info("[PHYSICS]: dequeing forcelist"); | 1048 | //m_log.Info("[PHYSICS]: dequeing forcelist"); |
@@ -1048,7 +1166,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1048 | 1166 | ||
1049 | public override PrimitiveBaseShape Shape | 1167 | public override PrimitiveBaseShape Shape |
1050 | { | 1168 | { |
1051 | set { _pbs = value; } | 1169 | set { |
1170 | |||
1171 | _pbs = value; | ||
1172 | m_taintshape = true; | ||
1173 | } | ||
1052 | } | 1174 | } |
1053 | 1175 | ||
1054 | public override PhysicsVector Velocity | 1176 | public override PhysicsVector Velocity |