aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin
diff options
context:
space:
mode:
authorUbitUmarov2013-01-03 21:53:21 +0000
committerUbitUmarov2013-01-03 21:53:21 +0000
commitc961cfe19e6dfaf26a0117748edbd66fc2d92823 (patch)
treede465063c1de64e786bc9ffcdb1eba9038d6fe2f /OpenSim/Region/Physics/UbitOdePlugin
parentcheck land permitions on sit target for unscripted sits (diff)
downloadopensim-SC_OLD-c961cfe19e6dfaf26a0117748edbd66fc2d92823.zip
opensim-SC_OLD-c961cfe19e6dfaf26a0117748edbd66fc2d92823.tar.gz
opensim-SC_OLD-c961cfe19e6dfaf26a0117748edbd66fc2d92823.tar.bz2
opensim-SC_OLD-c961cfe19e6dfaf26a0117748edbd66fc2d92823.tar.xz
bug fix, cleanup...
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs6
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs51
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs15
3 files changed, 34 insertions, 38 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
index 31757a9..6e9281b 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
@@ -144,7 +144,7 @@ namespace OpenSim.Region.Physics.OdePlugin
144 qtmp.Y = req.orientation.Y; 144 qtmp.Y = req.orientation.Y;
145 qtmp.Z = req.orientation.Z; 145 qtmp.Z = req.orientation.Z;
146 qtmp.W = req.orientation.W; 146 qtmp.W = req.orientation.W;
147 d.GeomSetOffsetWorldQuaternion(Box, ref qtmp); 147 d.GeomSetQuaternion(Box, ref qtmp);
148 } 148 }
149 else if (req.callbackMethod is ProbeSphereCallback) 149 else if (req.callbackMethod is ProbeSphereCallback)
150 { 150 {
@@ -480,12 +480,12 @@ namespace OpenSim.Region.Physics.OdePlugin
480 480
481 if (count == 0) 481 if (count == 0)
482 return; 482 return;
483 483/*
484 uint cat1 = d.GeomGetCategoryBits(g1); 484 uint cat1 = d.GeomGetCategoryBits(g1);
485 uint cat2 = d.GeomGetCategoryBits(g2); 485 uint cat2 = d.GeomGetCategoryBits(g2);
486 uint col1 = d.GeomGetCollideBits(g1); 486 uint col1 = d.GeomGetCollideBits(g1);
487 uint col2 = d.GeomGetCollideBits(g2); 487 uint col2 = d.GeomGetCollideBits(g2);
488 488*/
489 489
490 uint ID = 0; 490 uint ID = 0;
491 PhysicsActor p2 = null; 491 PhysicsActor p2 = null;
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs
index d6f6681..ecc732a 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs
@@ -78,36 +78,20 @@ namespace OpenSim.Region.Physics.OdePlugin
78 78
79 IntPtr geom = ((OdePrim)actor).prim_geom; 79 IntPtr geom = ((OdePrim)actor).prim_geom;
80 80
81 d.Vector3 dtmp = d.GeomGetPosition(geom); 81 Vector3 geopos = d.GeomGetPositionOMV(geom);
82 Vector3 geopos; 82 Quaternion geomOri = d.GeomGetQuaternionOMV(geom);
83 geopos.X = dtmp.X; 83 Quaternion geomInvOri = Quaternion.Conjugate(geomOri);
84 geopos.Y = dtmp.Y;
85 geopos.Z = dtmp.Z;
86 84
87
88 d.AABB aabb;
89 Quaternion ori = Quaternion.Identity; 85 Quaternion ori = Quaternion.Identity;
90 d.Quaternion qtmp;
91 d.GeomCopyQuaternion(geom, out qtmp);
92 Quaternion geomOri;
93 geomOri.X = qtmp.X;
94 geomOri.Y = qtmp.Y;
95 geomOri.Z = qtmp.Z;
96 geomOri.W = qtmp.W;
97 Quaternion geomInvOri;
98 geomInvOri.X = -qtmp.X;
99 geomInvOri.Y = -qtmp.Y;
100 geomInvOri.Z = -qtmp.Z;
101 geomInvOri.W = qtmp.W;
102 86
103 Vector3 rayDir = geopos + offset - avCameraPosition; 87 Vector3 rayDir = geopos + offset - avCameraPosition;
88
104 float raylen = rayDir.Length(); 89 float raylen = rayDir.Length();
105 if (raylen < 0.001f) 90 if (raylen < 0.001f)
106 { 91 {
107 PhysicsSitResponse(-1, actor.LocalID, offset, Quaternion.Identity); 92 PhysicsSitResponse(-1, actor.LocalID, offset, Quaternion.Identity);
108 return; 93 return;
109 } 94 }
110
111 float t = 1 / raylen; 95 float t = 1 / raylen;
112 rayDir.X *= t; 96 rayDir.X *= t;
113 rayDir.Y *= t; 97 rayDir.Y *= t;
@@ -119,22 +103,25 @@ namespace OpenSim.Region.Physics.OdePlugin
119 rayResults = m_scene.RaycastActor(actor, avCameraPosition, rayDir, raylen, 1, RaySitFlags); 103 rayResults = m_scene.RaycastActor(actor, avCameraPosition, rayDir, raylen, 1, RaySitFlags);
120 if (rayResults.Count == 0) 104 if (rayResults.Count == 0)
121 { 105 {
106/* if this fundamental ray failed, then just fail so user can try another spot and not be sitted far on a big prim
107 d.AABB aabb;
122 d.GeomGetAABB(geom, out aabb); 108 d.GeomGetAABB(geom, out aabb);
123 offset = new Vector3(avOffset.X, 0, aabb.MaxZ + avOffset.Z - geopos.Z); 109 offset = new Vector3(avOffset.X, 0, aabb.MaxZ + avOffset.Z - geopos.Z);
124 ori = geomInvOri; 110 ori = geomInvOri;
125 offset *= geomInvOri; 111 offset *= geomInvOri;
126
127 PhysicsSitResponse(1, actor.LocalID, offset, ori); 112 PhysicsSitResponse(1, actor.LocalID, offset, ori);
113*/
114 PhysicsSitResponse(0, actor.LocalID, offset, ori);
128 return; 115 return;
129 } 116 }
130 117
118 int status = 1;
131 offset = rayResults[0].Pos - geopos; 119 offset = rayResults[0].Pos - geopos;
132 120
133 d.GeomClassID geoclass = d.GeomGetClass(geom); 121 d.GeomClassID geoclass = d.GeomGetClass(geom);
134 122
135 if (geoclass == d.GeomClassID.SphereClass) 123 if (geoclass == d.GeomClassID.SphereClass)
136 { 124 {
137 int status = 1;
138 float r = d.GeomSphereGetRadius(geom); 125 float r = d.GeomSphereGetRadius(geom);
139 126
140 offset.Normalize(); 127 offset.Normalize();
@@ -165,7 +152,7 @@ namespace OpenSim.Region.Physics.OdePlugin
165 { 152 {
166 status = 3; 153 status = 3;
167 avOffset.X = -avOffset.X; 154 avOffset.X = -avOffset.X;
168 avOffset.Z += 0.4f; 155 avOffset.Z *= 1.6f;
169 } 156 }
170 } 157 }
171 158
@@ -186,6 +173,7 @@ namespace OpenSim.Region.Physics.OdePlugin
186 return; 173 return;
187 } 174 }
188 175
176
189 float SitNormX = -rayDir.X; 177 float SitNormX = -rayDir.X;
190 float SitNormY = -rayDir.Y; 178 float SitNormY = -rayDir.Y;
191 179
@@ -204,7 +192,6 @@ namespace OpenSim.Region.Physics.OdePlugin
204 { 192 {
205 float rayDist = 4.0f; 193 float rayDist = 4.0f;
206 float curEdgeDist = 0.0f; 194 float curEdgeDist = 0.0f;
207 pivot = geopos + offset;
208 195
209 for (int i = 0; i < 6; i++) 196 for (int i = 0; i < 6; i++)
210 { 197 {
@@ -239,11 +226,8 @@ namespace OpenSim.Region.Physics.OdePlugin
239 else 226 else
240 { 227 {
241 foundEdge = true; 228 foundEdge = true;
242 if (curEdgeDist < edgeDist) 229 edgeDist = curEdgeDist;
243 { 230 edgePos = rayResults[0].Pos;
244 edgeDist = curEdgeDist;
245 edgePos = rayResults[0].Pos;
246 }
247 break; 231 break;
248 } 232 }
249 } 233 }
@@ -267,7 +251,6 @@ namespace OpenSim.Region.Physics.OdePlugin
267 { 251 {
268 float rayDist = 1.0f; 252 float rayDist = 1.0f;
269 float curEdgeDist = 0.0f; 253 float curEdgeDist = 0.0f;
270 pivot = geopos + offset;
271 254
272 for (int i = 0; i < 3; i++) 255 for (int i = 0; i < 3; i++)
273 { 256 {
@@ -310,6 +293,8 @@ namespace OpenSim.Region.Physics.OdePlugin
310 if (foundEdge && edgeDist < 0.2f) 293 if (foundEdge && edgeDist < 0.2f)
311 break; 294 break;
312 295
296 pivot = geopos + offset;
297
313 switch (j) 298 switch (j)
314 { 299 {
315 case 0: 300 case 0:
@@ -332,7 +317,7 @@ namespace OpenSim.Region.Physics.OdePlugin
332 if (!foundEdge) 317 if (!foundEdge)
333 { 318 {
334 avOffset.X = -avOffset.X; 319 avOffset.X = -avOffset.X;
335 avOffset.Z += 0.4f; 320 avOffset.Z *= 1.6f;
336 321
337 RotAroundZ(SitNormX, SitNormY, ref ori); 322 RotAroundZ(SitNormX, SitNormY, ref ori);
338 323
@@ -349,7 +334,6 @@ namespace OpenSim.Region.Physics.OdePlugin
349 334
350 SitNormX = edgeNormalX; 335 SitNormX = edgeNormalX;
351 SitNormY = edgeNormalY; 336 SitNormY = edgeNormalY;
352 offset = edgePos - geopos;
353 if (edgeDirX * SitNormX + edgeDirY * SitNormY < 0) 337 if (edgeDirX * SitNormX + edgeDirY * SitNormY < 0)
354 { 338 {
355 SitNormX = -SitNormX; 339 SitNormX = -SitNormX;
@@ -358,7 +342,8 @@ namespace OpenSim.Region.Physics.OdePlugin
358 342
359 RotAroundZ(SitNormX, SitNormY, ref ori); 343 RotAroundZ(SitNormX, SitNormY, ref ori);
360 344
361 offset += avOffset * ori; 345 offset = edgePos + avOffset * ori;
346 offset -= geopos;
362 347
363 ori = geomInvOri * ori; 348 ori = geomInvOri * ori;
364 offset *= geomInvOri; 349 offset *= geomInvOri;
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
index 403a4ce..10d7d50 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
@@ -44,7 +44,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44using System; 44using System;
45using System.Runtime.InteropServices; 45using System.Runtime.InteropServices;
46using System.Security; 46using System.Security;
47 47using OMV = OpenMetaverse;
48namespace OdeAPI 48namespace OdeAPI
49{ 49{
50//#if dDOUBLE 50//#if dDOUBLE
@@ -925,9 +925,20 @@ namespace OdeAPI
925 { 925 {
926 unsafe { return *(GeomGetPositionUnsafe(geom)); } 926 unsafe { return *(GeomGetPositionUnsafe(geom)); }
927 } 927 }
928 public static OMV.Vector3 GeomGetPositionOMV(IntPtr geom)
929 {
930 Vector3 vtmp = GeomGetPosition(geom);
931 return new OMV.Vector3(vtmp.X, vtmp.Y, vtmp.Z);
932 }
928 933
929 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetQuaternion"), SuppressUnmanagedCodeSecurity] 934 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetQuaternion"), SuppressUnmanagedCodeSecurity]
930 public static extern void GeomCopyQuaternion(IntPtr geom, out Quaternion q); 935 public static extern void GeomCopyQuaternion(IntPtr geom, out Quaternion q);
936 public static OMV.Quaternion GeomGetQuaternionOMV(IntPtr geom)
937 {
938 Quaternion qtmp;
939 GeomCopyQuaternion(geom, out qtmp);
940 return new OMV.Quaternion(qtmp.X, qtmp.Y, qtmp.Z, qtmp.W);
941 }
931 942
932 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetQuaternion"), SuppressUnmanagedCodeSecurity] 943 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetQuaternion"), SuppressUnmanagedCodeSecurity]
933 public static extern void GeomCopyQuaternion(IntPtr geom, out dReal X); 944 public static extern void GeomCopyQuaternion(IntPtr geom, out dReal X);