aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs
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/ODESitAvatar.cs
parentcheck land permitions on sit target for unscripted sits (diff)
downloadopensim-SC-c961cfe19e6dfaf26a0117748edbd66fc2d92823.zip
opensim-SC-c961cfe19e6dfaf26a0117748edbd66fc2d92823.tar.gz
opensim-SC-c961cfe19e6dfaf26a0117748edbd66fc2d92823.tar.bz2
opensim-SC-c961cfe19e6dfaf26a0117748edbd66fc2d92823.tar.xz
bug fix, cleanup...
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs51
1 files changed, 18 insertions, 33 deletions
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;