diff options
author | Robert Adams | 2015-08-09 15:34:06 -0700 |
---|---|---|
committer | Robert Adams | 2015-08-09 15:34:06 -0700 |
commit | fe86df0ec9582c61ad3a50b53a73398393b13c87 (patch) | |
tree | 007e1af42f2cb1f885fa00b32dda004312e38dee /OpenSim | |
parent | Corrected spelling of SQLITE. Fixes mantis #7675. (diff) | |
download | opensim-SC_OLD-fe86df0ec9582c61ad3a50b53a73398393b13c87.zip opensim-SC_OLD-fe86df0ec9582c61ad3a50b53a73398393b13c87.tar.gz opensim-SC_OLD-fe86df0ec9582c61ad3a50b53a73398393b13c87.tar.bz2 opensim-SC_OLD-fe86df0ec9582c61ad3a50b53a73398393b13c87.tar.xz |
BulletSim: update the motion actors so they completely clean themselves
when Dispose() is called. This reduces chance of object leakage when
destroying objects.
Rearrange initialization and shut down of BSActorLockAxis so it is
consistant with other actors.
Diffstat (limited to 'OpenSim')
7 files changed, 41 insertions, 29 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs index c0d65be..bde4557 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs | |||
@@ -71,8 +71,7 @@ public class BSActorAvatarMove : BSActor | |||
71 | public override void Dispose() | 71 | public override void Dispose() |
72 | { | 72 | { |
73 | base.SetEnabled(false); | 73 | base.SetEnabled(false); |
74 | // Now that turned off, remove any state we have in the scene. | 74 | DeactivateAvatarMove(); |
75 | Refresh(); | ||
76 | } | 75 | } |
77 | 76 | ||
78 | // Called when physical parameters (properties set in Bullet) need to be re-applied. | 77 | // Called when physical parameters (properties set in Bullet) need to be re-applied. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorHover.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorHover.cs index 8a79809..e54c27b 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorHover.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorHover.cs | |||
@@ -58,6 +58,7 @@ public class BSActorHover : BSActor | |||
58 | public override void Dispose() | 58 | public override void Dispose() |
59 | { | 59 | { |
60 | Enabled = false; | 60 | Enabled = false; |
61 | DeactivateHover(); | ||
61 | } | 62 | } |
62 | 63 | ||
63 | // Called when physical parameters (properties set in Bullet) need to be re-applied. | 64 | // Called when physical parameters (properties set in Bullet) need to be re-applied. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorLockAxis.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorLockAxis.cs index 48cab64..3b3c161 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorLockAxis.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorLockAxis.cs | |||
@@ -36,7 +36,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
36 | { | 36 | { |
37 | public class BSActorLockAxis : BSActor | 37 | public class BSActorLockAxis : BSActor |
38 | { | 38 | { |
39 | BSConstraint LockAxisConstraint = null; | 39 | private BSConstraint LockAxisConstraint = null; |
40 | private bool HaveRegisteredForBeforeStepCallback = false; | ||
41 | |||
40 | // The lock access flags (which axises were locked) when the contraint was built. | 42 | // The lock access flags (which axises were locked) when the contraint was built. |
41 | // Used to see if locking has changed since when the constraint was built. | 43 | // Used to see if locking has changed since when the constraint was built. |
42 | OMV.Vector3 LockAxisLinearFlags; | 44 | OMV.Vector3 LockAxisLinearFlags; |
@@ -47,9 +49,7 @@ public class BSActorLockAxis : BSActor | |||
47 | { | 49 | { |
48 | m_physicsScene.DetailLog("{0},BSActorLockAxis,constructor", m_controllingPrim.LocalID); | 50 | m_physicsScene.DetailLog("{0},BSActorLockAxis,constructor", m_controllingPrim.LocalID); |
49 | LockAxisConstraint = null; | 51 | LockAxisConstraint = null; |
50 | 52 | HaveRegisteredForBeforeStepCallback = false; | |
51 | // we place our constraint just before the simulation step to make sure the linkset is complete | ||
52 | m_physicsScene.BeforeStep += PhysicsScene_BeforeStep; | ||
53 | } | 53 | } |
54 | 54 | ||
55 | // BSActor.isActive | 55 | // BSActor.isActive |
@@ -62,7 +62,8 @@ public class BSActorLockAxis : BSActor | |||
62 | // BSActor.Dispose() | 62 | // BSActor.Dispose() |
63 | public override void Dispose() | 63 | public override void Dispose() |
64 | { | 64 | { |
65 | m_physicsScene.BeforeStep -= PhysicsScene_BeforeStep; | 65 | Enabled = false; |
66 | UnRegisterForBeforeStepCallback(); | ||
66 | RemoveAxisLockConstraint(); | 67 | RemoveAxisLockConstraint(); |
67 | } | 68 | } |
68 | 69 | ||
@@ -74,37 +75,26 @@ public class BSActorLockAxis : BSActor | |||
74 | // Since the axis logging is done with a constraint, Refresh() time is good for | 75 | // Since the axis logging is done with a constraint, Refresh() time is good for |
75 | // changing parameters but this needs to wait until the prim/linkset is physically | 76 | // changing parameters but this needs to wait until the prim/linkset is physically |
76 | // constructed. Therefore, the constraint itself is placed at pre-step time. | 77 | // constructed. Therefore, the constraint itself is placed at pre-step time. |
77 | /* | 78 | |
78 | m_physicsScene.DetailLog("{0},BSActorLockAxis,refresh,lockedLinear={1},lockedAngular={2},enabled={3},pActive={4}", | ||
79 | m_controllingPrim.LocalID, | ||
80 | m_controllingPrim.LockedLinearAxis, | ||
81 | m_controllingPrim.LockedAngularAxis, | ||
82 | Enabled, m_controllingPrim.IsPhysicallyActive); | ||
83 | // If all the axis are free, we don't need to exist | 79 | // If all the axis are free, we don't need to exist |
80 | // Refresh() only turns off. Enabling is done by InitializeAxisActor() | ||
81 | // whenever parameters are changed. | ||
82 | // This leaves 'enable' free to turn off an actor when it is not wanted to run. | ||
84 | if (m_controllingPrim.LockedAngularAxis == m_controllingPrim.LockedAxisFree | 83 | if (m_controllingPrim.LockedAngularAxis == m_controllingPrim.LockedAxisFree |
85 | && m_controllingPrim.LockedLinearAxis == m_controllingPrim.LockedAxisFree) | 84 | && m_controllingPrim.LockedLinearAxis == m_controllingPrim.LockedAxisFree) |
86 | { | 85 | { |
87 | Enabled = false; | 86 | Enabled = false; |
88 | } | 87 | } |
89 | 88 | ||
90 | // If the object is physically active, add the axis locking constraint | ||
91 | if (isActive) | 89 | if (isActive) |
92 | { | 90 | { |
93 | // Check to see if the locking parameters have changed | 91 | RegisterForBeforeStepCallback(); |
94 | if (m_controllingPrim.LockedLinearAxis != this.LockAxisLinearFlags | ||
95 | || m_controllingPrim.LockedAngularAxis != this.LockAxisAngularFlags) | ||
96 | { | ||
97 | // The locking has changed. Remove the old constraint and build a new one | ||
98 | RemoveAxisLockConstraint(); | ||
99 | } | ||
100 | |||
101 | AddAxisLockConstraint(); | ||
102 | } | 92 | } |
103 | else | 93 | else |
104 | { | 94 | { |
105 | RemoveAxisLockConstraint(); | 95 | RemoveDependencies(); |
96 | UnRegisterForBeforeStepCallback(); | ||
106 | } | 97 | } |
107 | */ | ||
108 | } | 98 | } |
109 | 99 | ||
110 | // The object's physical representation is being rebuilt so pick up any physical dependencies (constraints, ...). | 100 | // The object's physical representation is being rebuilt so pick up any physical dependencies (constraints, ...). |
@@ -114,7 +104,24 @@ public class BSActorLockAxis : BSActor | |||
114 | public override void RemoveDependencies() | 104 | public override void RemoveDependencies() |
115 | { | 105 | { |
116 | RemoveAxisLockConstraint(); | 106 | RemoveAxisLockConstraint(); |
117 | // The pre-step action will restore the constraint of needed | 107 | } |
108 | |||
109 | private void RegisterForBeforeStepCallback() | ||
110 | { | ||
111 | if (!HaveRegisteredForBeforeStepCallback) | ||
112 | { | ||
113 | m_physicsScene.BeforeStep += PhysicsScene_BeforeStep; | ||
114 | HaveRegisteredForBeforeStepCallback = true; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | private void UnRegisterForBeforeStepCallback() | ||
119 | { | ||
120 | if (HaveRegisteredForBeforeStepCallback) | ||
121 | { | ||
122 | m_physicsScene.BeforeStep -= PhysicsScene_BeforeStep; | ||
123 | HaveRegisteredForBeforeStepCallback = false; | ||
124 | } | ||
118 | } | 125 | } |
119 | 126 | ||
120 | private void PhysicsScene_BeforeStep(float timestep) | 127 | private void PhysicsScene_BeforeStep(float timestep) |
@@ -145,6 +152,7 @@ public class BSActorLockAxis : BSActor | |||
145 | } | 152 | } |
146 | } | 153 | } |
147 | 154 | ||
155 | // Note that this relies on being called at TaintTime | ||
148 | private void AddAxisLockConstraint() | 156 | private void AddAxisLockConstraint() |
149 | { | 157 | { |
150 | if (LockAxisConstraint == null) | 158 | if (LockAxisConstraint == null) |
@@ -192,11 +200,14 @@ public class BSActorLockAxis : BSActor | |||
192 | axisConstrainer.TranslationalLimitMotor(true /* enable */, 5.0f, 0.1f); | 200 | axisConstrainer.TranslationalLimitMotor(true /* enable */, 5.0f, 0.1f); |
193 | 201 | ||
194 | axisConstrainer.RecomputeConstraintVariables(m_controllingPrim.RawMass); | 202 | axisConstrainer.RecomputeConstraintVariables(m_controllingPrim.RawMass); |
203 | |||
204 | RegisterForBeforeStepCallback(); | ||
195 | } | 205 | } |
196 | } | 206 | } |
197 | 207 | ||
198 | private void RemoveAxisLockConstraint() | 208 | private void RemoveAxisLockConstraint() |
199 | { | 209 | { |
210 | UnRegisterForBeforeStepCallback(); | ||
200 | if (LockAxisConstraint != null) | 211 | if (LockAxisConstraint != null) |
201 | { | 212 | { |
202 | m_physicsScene.Constraints.RemoveAndDestroyConstraint(LockAxisConstraint); | 213 | m_physicsScene.Constraints.RemoveAndDestroyConstraint(LockAxisConstraint); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs index bdf4bc0..1145006 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs | |||
@@ -59,6 +59,7 @@ public class BSActorMoveToTarget : BSActor | |||
59 | public override void Dispose() | 59 | public override void Dispose() |
60 | { | 60 | { |
61 | Enabled = false; | 61 | Enabled = false; |
62 | DeactivateMoveToTarget(); | ||
62 | } | 63 | } |
63 | 64 | ||
64 | // Called when physical parameters (properties set in Bullet) need to be re-applied. | 65 | // Called when physical parameters (properties set in Bullet) need to be re-applied. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorSetForce.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorSetForce.cs index 96fa0b6..4e81363 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorSetForce.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorSetForce.cs | |||
@@ -58,6 +58,7 @@ public class BSActorSetForce : BSActor | |||
58 | public override void Dispose() | 58 | public override void Dispose() |
59 | { | 59 | { |
60 | Enabled = false; | 60 | Enabled = false; |
61 | DeactivateSetForce(); | ||
61 | } | 62 | } |
62 | 63 | ||
63 | // Called when physical parameters (properties set in Bullet) need to be re-applied. | 64 | // Called when physical parameters (properties set in Bullet) need to be re-applied. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorSetTorque.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorSetTorque.cs index 65098e1..79e1d38 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorSetTorque.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorSetTorque.cs | |||
@@ -58,6 +58,7 @@ public class BSActorSetTorque : BSActor | |||
58 | public override void Dispose() | 58 | public override void Dispose() |
59 | { | 59 | { |
60 | Enabled = false; | 60 | Enabled = false; |
61 | DeactivateSetTorque(); | ||
61 | } | 62 | } |
62 | 63 | ||
63 | // Called when physical parameters (properties set in Bullet) need to be re-applied. | 64 | // Called when physical parameters (properties set in Bullet) need to be re-applied. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs index e0ccc50..7f45e2c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | |||
@@ -32,12 +32,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
32 | { | 32 | { |
33 | public class BSActorCollection | 33 | public class BSActorCollection |
34 | { | 34 | { |
35 | private BSScene m_physicsScene { get; set; } | ||
36 | private Dictionary<string, BSActor> m_actors; | 35 | private Dictionary<string, BSActor> m_actors; |
37 | 36 | ||
38 | public BSActorCollection(BSScene physicsScene) | 37 | public BSActorCollection() |
39 | { | 38 | { |
40 | m_physicsScene = physicsScene; | ||
41 | m_actors = new Dictionary<string, BSActor>(); | 39 | m_actors = new Dictionary<string, BSActor>(); |
42 | } | 40 | } |
43 | public void Add(string name, BSActor actor) | 41 | public void Add(string name, BSActor actor) |