aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2015-12-22 00:06:17 +0000
committerUbitUmarov2015-12-22 00:06:17 +0000
commit6437a94388193968a3f248a03e1063e56ac3ae44 (patch)
tree22b986d2b7de8c07bc193c716d8582afcdd7dd69 /OpenSim
parentdrop attachments to ground a bit in front of the avatar, not on his location (diff)
downloadopensim-SC-6437a94388193968a3f248a03e1063e56ac3ae44.zip
opensim-SC-6437a94388193968a3f248a03e1063e56ac3ae44.tar.gz
opensim-SC-6437a94388193968a3f248a03e1063e56ac3ae44.tar.bz2
opensim-SC-6437a94388193968a3f248a03e1063e56ac3ae44.tar.xz
a few changes to physics new root avatar position height estimation
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs79
1 files changed, 61 insertions, 18 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index ec96519..4236195 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1123,6 +1123,10 @@ namespace OpenSim.Region.Framework.Scenes
1123 /// delays that crossing. 1123 /// delays that crossing.
1124 /// </remarks> 1124 /// </remarks>
1125 1125
1126 // constants for physics position search
1127 const float PhysSearchHeight = 600f;
1128 const float PhysMinSkipGap = 50f;
1129 const int PhysNumberCollisions = 30;
1126 1130
1127 // only in use as part of completemovement 1131 // only in use as part of completemovement
1128 // other uses need fix 1132 // other uses need fix
@@ -1198,7 +1202,7 @@ namespace OpenSim.Region.Framework.Scenes
1198 bool positionChanged = false; 1202 bool positionChanged = false;
1199 if(!CheckAndAdjustLandingPoint(ref pos, ref lookat, ref positionChanged )) 1203 if(!CheckAndAdjustLandingPoint(ref pos, ref lookat, ref positionChanged ))
1200 { 1204 {
1201 m_log.DebugFormat("[SCENE PRESENCE MakeRootAgent]: houston we have a problem.. {0}({1} got here banned",Name, UUID); 1205 m_log.DebugFormat("[SCENE PRESENCE MakeRootAgent]: houston we have a problem.. {0}({1} got here banned",Name, UUID);
1202 } 1206 }
1203 1207
1204 if (pos.X < 0f || pos.Y < 0f 1208 if (pos.X < 0f || pos.Y < 0f
@@ -1219,42 +1223,81 @@ namespace OpenSim.Region.Framework.Scenes
1219 pos.Y = m_scene.RegionInfo.RegionSizeY - 0.5f; 1223 pos.Y = m_scene.RegionInfo.RegionSizeY - 0.5f;
1220 } 1224 }
1221 1225
1226 float groundHeight = m_scene.GetGroundHeight(pos.X, pos.Y) + .01f;
1227 float physTestHeight;
1228
1229 if(PhysSearchHeight < groundHeight + 100f)
1230 physTestHeight = groundHeight + 100f;
1231 else
1232 physTestHeight = PhysSearchHeight;
1233
1234 float localAVHalfHeight = 0.8f;
1235 if (Appearance != null && Appearance.AvatarHeight > 0)
1236 localAVHalfHeight = 0.5f * Appearance.AvatarHeight;
1237
1238 groundHeight += localAVHalfHeight;
1239 if (groundHeight > pos.Z)
1240 pos.Z = groundHeight;
1241
1222 bool checkPhysics = !positionChanged && 1242 bool checkPhysics = !positionChanged &&
1223 m_scene.SupportsRayCastFiltered() && 1243 m_scene.SupportsRayCastFiltered() &&
1244 pos.Z < physTestHeight &&
1224 ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == 1245 ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) ==
1225 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) 1246 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)
1226 || (m_teleportFlags & TeleportFlags.ViaLocation) != 0 1247 || (m_teleportFlags & TeleportFlags.ViaLocation) != 0
1227 || (m_teleportFlags & TeleportFlags.ViaHGLogin) != 0); 1248 || (m_teleportFlags & TeleportFlags.ViaHGLogin) != 0);
1228 1249
1229 float localAVHeight = 1.56f;
1230 if (Appearance.AvatarHeight > 0)
1231 localAVHeight = Appearance.AvatarHeight;
1232
1233 float newPosZ = m_scene.GetGroundHeight(pos.X, pos.Y) + .01f;
1234 newPosZ += 0.5f * localAVHeight;
1235 if (newPosZ > pos.Z)
1236 pos.Z = newPosZ;
1237
1238 if(checkPhysics) 1250 if(checkPhysics)
1239 { 1251 {
1240 // land check was done above 1252 // land check was done above
1241 RayFilterFlags rayfilter = RayFilterFlags.ClosestAndBackCull; 1253 RayFilterFlags rayfilter = RayFilterFlags.BackFaceCull;
1242 rayfilter |= RayFilterFlags.physical; 1254 rayfilter |= RayFilterFlags.physical;
1243 rayfilter |= RayFilterFlags.nonphysical; 1255 rayfilter |= RayFilterFlags.nonphysical;
1244 rayfilter |= RayFilterFlags.LSLPhantom; // ubODE will only see volume detectors 1256 rayfilter |= RayFilterFlags.LSLPhantom; // ubODE will only see volume detectors
1245 int physcount = 25; 1257
1246 float dist = 1024f; 1258 int physcount = PhysNumberCollisions;
1247 Vector3 direction = new Vector3(0f,0f,-1f); 1259
1260 float dist = physTestHeight - groundHeight + localAVHalfHeight;
1261
1262 Vector3 direction = new Vector3(0f, 0f, -1f);
1248 Vector3 RayStart = pos; 1263 Vector3 RayStart = pos;
1249 RayStart.Z += dist; 1264 RayStart.Z = physTestHeight;
1250 1265
1251 List<ContactResult> physresults = 1266 List<ContactResult> physresults =
1252 (List<ContactResult>)m_scene.RayCastFiltered(RayStart, direction, dist, physcount, rayfilter); 1267 (List<ContactResult>)m_scene.RayCastFiltered(RayStart, direction, dist, physcount, rayfilter);
1253 if (physresults != null && physresults.Count > 0) 1268 if (physresults != null && physresults.Count > 0)
1254 { 1269 {
1255 float d = physresults[0].Pos.Z + 0.5f * localAVHeight; 1270 float dest = physresults[0].Pos.Z;
1256 if(d > pos.Z) 1271
1257 pos.Z = d; 1272 if(physresults.Count > 1)
1273 {
1274 physresults.Sort(delegate(ContactResult a, ContactResult b)
1275 {
1276 return a.Depth.CompareTo(b.Depth);
1277 });
1278
1279 int sel = 0;
1280 int count = physresults.Count;
1281 float curd = physresults[0].Depth;
1282 float nextd = curd + PhysMinSkipGap;
1283 float maxDepth = dist - pos.Z;
1284 for(int i = 1; i < count; i++)
1285 {
1286 curd = physresults[i].Depth;
1287 if(curd >= nextd)
1288 {
1289 sel = i;
1290 if(curd >= maxDepth)
1291 break;
1292 }
1293 nextd = curd + PhysMinSkipGap;
1294 }
1295 dest = physresults[sel].Pos.Z;
1296 }
1297
1298 dest += localAVHalfHeight;
1299 if(dest > pos.Z)
1300 pos.Z = dest;
1258 } 1301 }
1259 } 1302 }
1260 1303