diff options
author | Melanie | 2010-09-25 05:57:08 +0200 |
---|---|---|
committer | Melanie | 2010-09-25 05:57:08 +0200 |
commit | 83b16612ce13ee89f139df8fdc78ded14cb6a69e (patch) | |
tree | 7bdecc0785d1db19fa042df0b7536545ea70db03 /OpenSim/Region/Physics | |
parent | if you can't edit a prim's inventory, you don't need to see the asset ids. (diff) | |
download | opensim-SC-83b16612ce13ee89f139df8fdc78ded14cb6a69e.zip opensim-SC-83b16612ce13ee89f139df8fdc78ded14cb6a69e.tar.gz opensim-SC-83b16612ce13ee89f139df8fdc78ded14cb6a69e.tar.bz2 opensim-SC-83b16612ce13ee89f139df8fdc78ded14cb6a69e.tar.xz |
Experimental locking of taint processing
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r-- | OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs | 156 |
1 files changed, 80 insertions, 76 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs index ae63cfa..505d455 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs | |||
@@ -143,6 +143,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
143 | // unique UUID of this character object | 143 | // unique UUID of this character object |
144 | public UUID m_uuid; | 144 | public UUID m_uuid; |
145 | public bool bad = false; | 145 | public bool bad = false; |
146 | private Object m_syncRoot = new Object(); | ||
146 | 147 | ||
147 | public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, CollisionLocker dode, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) | 148 | public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, CollisionLocker dode, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) |
148 | { | 149 | { |
@@ -1323,103 +1324,106 @@ Console.WriteLine("**** Create {2} Dicts: actor={0} name={1} height={3} ra | |||
1323 | 1324 | ||
1324 | public void ProcessTaints(float timestep) | 1325 | public void ProcessTaints(float timestep) |
1325 | { | 1326 | { |
1326 | 1327 | lock (m_syncRoot) | |
1327 | if (m_tainted_isPhysical != m_isPhysical) | ||
1328 | { | 1328 | { |
1329 | if (m_tainted_isPhysical) | ||
1330 | { | ||
1331 | // Create avatar capsule and related ODE data | ||
1332 | if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero)) | ||
1333 | { | ||
1334 | m_log.Warn("[PHYSICS]: re-creating the following avatar ODE data, even though it already exists - " | ||
1335 | + (Shell!=IntPtr.Zero ? "Shell ":"") | ||
1336 | + (Body!=IntPtr.Zero ? "Body ":"") | ||
1337 | + (Amotor!=IntPtr.Zero ? "Amotor ":"")); | ||
1338 | } | ||
1339 | AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor); | ||
1340 | _parent_scene.AddCharacter(this); | ||
1341 | } | ||
1342 | else | ||
1343 | { | ||
1344 | _parent_scene.RemoveCharacter(this); | ||
1345 | // destroy avatar capsule and related ODE data | ||
1346 | if (Amotor != IntPtr.Zero) | ||
1347 | { | ||
1348 | // Kill the Amotor | ||
1349 | d.JointDestroy(Amotor); | ||
1350 | Amotor = IntPtr.Zero; | ||
1351 | } | ||
1352 | //kill the Geometry | ||
1353 | _parent_scene.waitForSpaceUnlock(_parent_scene.space); | ||
1354 | 1329 | ||
1355 | if (Body != IntPtr.Zero) | 1330 | if (m_tainted_isPhysical != m_isPhysical) |
1331 | { | ||
1332 | if (m_tainted_isPhysical) | ||
1356 | { | 1333 | { |
1357 | //kill the body | 1334 | // Create avatar capsule and related ODE data |
1358 | d.BodyDestroy(Body); | 1335 | if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero)) |
1359 | Body = IntPtr.Zero; | 1336 | { |
1337 | m_log.Warn("[PHYSICS]: re-creating the following avatar ODE data, even though it already exists - " | ||
1338 | + (Shell!=IntPtr.Zero ? "Shell ":"") | ||
1339 | + (Body!=IntPtr.Zero ? "Body ":"") | ||
1340 | + (Amotor!=IntPtr.Zero ? "Amotor ":"")); | ||
1341 | } | ||
1342 | AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor); | ||
1343 | _parent_scene.AddCharacter(this); | ||
1360 | } | 1344 | } |
1361 | 1345 | else | |
1362 | if(Shell != IntPtr.Zero) | ||
1363 | { | 1346 | { |
1364 | try | 1347 | _parent_scene.RemoveCharacter(this); |
1348 | // destroy avatar capsule and related ODE data | ||
1349 | if (Amotor != IntPtr.Zero) | ||
1365 | { | 1350 | { |
1366 | d.GeomDestroy(Shell); | 1351 | // Kill the Amotor |
1352 | d.JointDestroy(Amotor); | ||
1353 | Amotor = IntPtr.Zero; | ||
1367 | } | 1354 | } |
1368 | catch (System.AccessViolationException) | 1355 | //kill the Geometry |
1356 | _parent_scene.waitForSpaceUnlock(_parent_scene.space); | ||
1357 | |||
1358 | if (Body != IntPtr.Zero) | ||
1369 | { | 1359 | { |
1370 | m_log.Error("[PHYSICS]: PrimGeom dead"); | 1360 | //kill the body |
1361 | d.BodyDestroy(Body); | ||
1362 | Body = IntPtr.Zero; | ||
1371 | } | 1363 | } |
1372 | // Remove any old entries | ||
1373 | //string tShell; | ||
1374 | //_parent_scene.geom_name_map.TryGetValue(Shell, out tShell); | ||
1375 | //Console.WriteLine("**** Remove {0}", tShell); | ||
1376 | 1364 | ||
1377 | if(_parent_scene.geom_name_map.ContainsKey(Shell)) _parent_scene.geom_name_map.Remove(Shell); | 1365 | if(Shell != IntPtr.Zero) |
1378 | if(_parent_scene.actor_name_map.ContainsKey(Shell)) _parent_scene.actor_name_map.Remove(Shell); | 1366 | { |
1379 | Shell = IntPtr.Zero; | 1367 | try |
1368 | { | ||
1369 | d.GeomDestroy(Shell); | ||
1370 | } | ||
1371 | catch (System.AccessViolationException) | ||
1372 | { | ||
1373 | m_log.Error("[PHYSICS]: PrimGeom dead"); | ||
1374 | } | ||
1375 | // Remove any old entries | ||
1376 | //string tShell; | ||
1377 | //_parent_scene.geom_name_map.TryGetValue(Shell, out tShell); | ||
1378 | //Console.WriteLine("**** Remove {0}", tShell); | ||
1379 | |||
1380 | if(_parent_scene.geom_name_map.ContainsKey(Shell)) _parent_scene.geom_name_map.Remove(Shell); | ||
1381 | if(_parent_scene.actor_name_map.ContainsKey(Shell)) _parent_scene.actor_name_map.Remove(Shell); | ||
1382 | Shell = IntPtr.Zero; | ||
1383 | } | ||
1380 | } | 1384 | } |
1381 | } | ||
1382 | 1385 | ||
1383 | m_isPhysical = m_tainted_isPhysical; | 1386 | m_isPhysical = m_tainted_isPhysical; |
1384 | } | 1387 | } |
1385 | 1388 | ||
1386 | if (m_tainted_CAPSULE_LENGTH != CAPSULE_LENGTH) | 1389 | if (m_tainted_CAPSULE_LENGTH != CAPSULE_LENGTH) |
1387 | { | ||
1388 | if (Shell != IntPtr.Zero && Body != IntPtr.Zero && Amotor != IntPtr.Zero) | ||
1389 | { | 1390 | { |
1391 | if (Shell != IntPtr.Zero && Body != IntPtr.Zero && Amotor != IntPtr.Zero) | ||
1392 | { | ||
1390 | 1393 | ||
1391 | m_pidControllerActive = true; | 1394 | m_pidControllerActive = true; |
1392 | // no lock needed on _parent_scene.OdeLock because we are called from within the thread lock in OdePlugin's simulate() | 1395 | // no lock needed on _parent_scene.OdeLock because we are called from within the thread lock in OdePlugin's simulate() |
1393 | d.JointDestroy(Amotor); | 1396 | d.JointDestroy(Amotor); |
1394 | float prevCapsule = CAPSULE_LENGTH; | 1397 | float prevCapsule = CAPSULE_LENGTH; |
1395 | CAPSULE_LENGTH = m_tainted_CAPSULE_LENGTH; | 1398 | CAPSULE_LENGTH = m_tainted_CAPSULE_LENGTH; |
1396 | //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); | 1399 | //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); |
1397 | d.BodyDestroy(Body); | 1400 | d.BodyDestroy(Body); |
1398 | AvatarGeomAndBodyCreation(_position.X, _position.Y, | 1401 | AvatarGeomAndBodyCreation(_position.X, _position.Y, |
1399 | _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); | 1402 | _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); |
1400 | Velocity = Vector3.Zero; | 1403 | Velocity = Vector3.Zero; |
1401 | } | 1404 | } |
1402 | else | 1405 | else |
1403 | { | 1406 | { |
1404 | m_log.Warn("[PHYSICS]: trying to change capsule size, but the following ODE data is missing - " | 1407 | m_log.Warn("[PHYSICS]: trying to change capsule size, but the following ODE data is missing - " |
1405 | + (Shell==IntPtr.Zero ? "Shell ":"") | 1408 | + (Shell==IntPtr.Zero ? "Shell ":"") |
1406 | + (Body==IntPtr.Zero ? "Body ":"") | 1409 | + (Body==IntPtr.Zero ? "Body ":"") |
1407 | + (Amotor==IntPtr.Zero ? "Amotor ":"")); | 1410 | + (Amotor==IntPtr.Zero ? "Amotor ":"")); |
1411 | } | ||
1408 | } | 1412 | } |
1409 | } | ||
1410 | 1413 | ||
1411 | if (!m_taintPosition.ApproxEquals(_position, 0.05f)) | 1414 | if (!m_taintPosition.ApproxEquals(_position, 0.05f)) |
1412 | { | ||
1413 | if (Body != IntPtr.Zero) | ||
1414 | { | 1415 | { |
1415 | d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z); | 1416 | if (Body != IntPtr.Zero) |
1417 | { | ||
1418 | d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z); | ||
1416 | 1419 | ||
1417 | _position.X = m_taintPosition.X; | 1420 | _position.X = m_taintPosition.X; |
1418 | _position.Y = m_taintPosition.Y; | 1421 | _position.Y = m_taintPosition.Y; |
1419 | _position.Z = m_taintPosition.Z; | 1422 | _position.Z = m_taintPosition.Z; |
1423 | } | ||
1420 | } | 1424 | } |
1421 | } | ||
1422 | 1425 | ||
1426 | } | ||
1423 | } | 1427 | } |
1424 | 1428 | ||
1425 | internal void AddCollisionFrameTime(int p) | 1429 | internal void AddCollisionFrameTime(int p) |