diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index beaea1f..a31c578 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -362,7 +362,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
362 | BSPrim bsprim = prim as BSPrim; | 362 | BSPrim bsprim = prim as BSPrim; |
363 | if (bsprim != null) | 363 | if (bsprim != null) |
364 | { | 364 | { |
365 | DetailLog("{0},RemovePrim,call", bsprim.LocalID); | 365 | // DetailLog("{0},RemovePrim,call", bsprim.LocalID); |
366 | // m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID); | 366 | // m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID); |
367 | try | 367 | try |
368 | { | 368 | { |
@@ -388,7 +388,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
388 | 388 | ||
389 | if (!m_initialized) return null; | 389 | if (!m_initialized) return null; |
390 | 390 | ||
391 | DetailLog("{0},AddPrimShape,call", localID); | 391 | // DetailLog("{0},AddPrimShape,call", localID); |
392 | 392 | ||
393 | BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical); | 393 | BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical); |
394 | lock (m_prims) m_prims.Add(localID, prim); | 394 | lock (m_prims) m_prims.Add(localID, prim); |
@@ -413,7 +413,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
413 | // prevent simulation until we've been initialized | 413 | // prevent simulation until we've been initialized |
414 | if (!m_initialized) return 10.0f; | 414 | if (!m_initialized) return 10.0f; |
415 | 415 | ||
416 | long simulateStartTime = Util.EnvironmentTickCount(); | 416 | int simulateStartTime = Util.EnvironmentTickCount(); |
417 | 417 | ||
418 | // update the prim states while we know the physics engine is not busy | 418 | // update the prim states while we know the physics engine is not busy |
419 | ProcessTaints(); | 419 | ProcessTaints(); |
@@ -429,12 +429,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
429 | { | 429 | { |
430 | numSubSteps = BulletSimAPI.PhysicsStep(m_worldID, timeStep, m_maxSubSteps, m_fixedTimeStep, | 430 | numSubSteps = BulletSimAPI.PhysicsStep(m_worldID, timeStep, m_maxSubSteps, m_fixedTimeStep, |
431 | out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr); | 431 | out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr); |
432 | DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); | 432 | // DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); |
433 | } | 433 | } |
434 | catch (Exception e) | 434 | catch (Exception e) |
435 | { | 435 | { |
436 | m_log.WarnFormat("{0},PhysicsStep Exception: substeps={1}, updates={2}, colliders={3}, e={4}", LogHeader, numSubSteps, updatedEntityCount, collidersCount, e); | 436 | m_log.WarnFormat("{0},PhysicsStep Exception: substeps={1}, updates={2}, colliders={3}, e={4}", LogHeader, numSubSteps, updatedEntityCount, collidersCount, e); |
437 | DetailLog("{0},PhysicsStepException,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); | 437 | // DetailLog("{0},PhysicsStepException,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); |
438 | // updatedEntityCount = 0; | 438 | // updatedEntityCount = 0; |
439 | collidersCount = 0; | 439 | collidersCount = 0; |
440 | } | 440 | } |
@@ -511,8 +511,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
511 | // long simulateTotalTime = Util.EnvironmentTickCountSubtract(simulateStartTime); | 511 | // long simulateTotalTime = Util.EnvironmentTickCountSubtract(simulateStartTime); |
512 | // return (timeStep * (float)simulateTotalTime); | 512 | // return (timeStep * (float)simulateTotalTime); |
513 | 513 | ||
514 | // TODO: FIX THIS: fps calculation wrong. This calculation always returns about 1 in normal operation. | 514 | // TODO: FIX THIS: fps calculation possibly wrong. |
515 | return timeStep / (numSubSteps * m_fixedTimeStep) * 1000f; | 515 | // This calculation says 1/timeStep is the ideal frame rate. Any time added to |
516 | // that by the physics simulation gives a slower frame rate. | ||
517 | long totalSimulationTime = Util.EnvironmentTickCountSubtract(simulateStartTime); | ||
518 | if (totalSimulationTime >= timeStep) | ||
519 | return 0; | ||
520 | return 1f / (timeStep + totalSimulationTime); | ||
516 | } | 521 | } |
517 | 522 | ||
518 | // Something has collided | 523 | // Something has collided |
@@ -590,12 +595,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
590 | // make sure no stepping happens while we're deleting stuff | 595 | // make sure no stepping happens while we're deleting stuff |
591 | m_initialized = false; | 596 | m_initialized = false; |
592 | 597 | ||
593 | if (m_constraintCollection != null) | ||
594 | { | ||
595 | m_constraintCollection.Dispose(); | ||
596 | m_constraintCollection = null; | ||
597 | } | ||
598 | |||
599 | foreach (KeyValuePair<uint, BSCharacter> kvp in m_avatars) | 598 | foreach (KeyValuePair<uint, BSCharacter> kvp in m_avatars) |
600 | { | 599 | { |
601 | kvp.Value.Destroy(); | 600 | kvp.Value.Destroy(); |
@@ -608,6 +607,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
608 | } | 607 | } |
609 | m_prims.Clear(); | 608 | m_prims.Clear(); |
610 | 609 | ||
610 | // Now that the prims are all cleaned up, there should be no constraints left | ||
611 | if (m_constraintCollection != null) | ||
612 | { | ||
613 | m_constraintCollection.Dispose(); | ||
614 | m_constraintCollection = null; | ||
615 | } | ||
616 | |||
611 | // Anything left in the unmanaged code should be cleaned out | 617 | // Anything left in the unmanaged code should be cleaned out |
612 | BulletSimAPI.Shutdown(WorldID); | 618 | BulletSimAPI.Shutdown(WorldID); |
613 | 619 | ||