diff options
author | Melanie Thielker | 2014-06-21 00:39:55 +0200 |
---|---|---|
committer | Melanie Thielker | 2014-06-21 00:39:55 +0200 |
commit | 159fcbf150b7da0e229b29aa7b94793484543d12 (patch) | |
tree | b8c0ff3b4c758a3fba8315b556c923ef4c02a185 /OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | |
parent | Merge commit '68c8633ba18f0a11cfc0ed04d1d0c7c59e6cec76' (diff) | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.zip opensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.tar.gz opensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.tar.bz2 opensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.tar.xz |
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster
Conflicts:
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSActors.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | 67 |
1 files changed, 46 insertions, 21 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs index 5a19ba4..e0ccc50 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | |||
@@ -32,56 +32,79 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
32 | { | 32 | { |
33 | public class BSActorCollection | 33 | public class BSActorCollection |
34 | { | 34 | { |
35 | private BSScene PhysicsScene { get; set; } | 35 | private BSScene m_physicsScene { get; set; } |
36 | private Dictionary<string, BSActor> m_actors; | 36 | private Dictionary<string, BSActor> m_actors; |
37 | 37 | ||
38 | public BSActorCollection(BSScene physicsScene) | 38 | public BSActorCollection(BSScene physicsScene) |
39 | { | 39 | { |
40 | PhysicsScene = physicsScene; | 40 | m_physicsScene = physicsScene; |
41 | m_actors = new Dictionary<string, BSActor>(); | 41 | m_actors = new Dictionary<string, BSActor>(); |
42 | } | 42 | } |
43 | public void Add(string name, BSActor actor) | 43 | public void Add(string name, BSActor actor) |
44 | { | 44 | { |
45 | m_actors[name] = actor; | 45 | lock (m_actors) |
46 | { | ||
47 | if (!m_actors.ContainsKey(name)) | ||
48 | { | ||
49 | m_actors[name] = actor; | ||
50 | } | ||
51 | } | ||
46 | } | 52 | } |
47 | public bool RemoveAndRelease(string name) | 53 | public bool RemoveAndRelease(string name) |
48 | { | 54 | { |
49 | bool ret = false; | 55 | bool ret = false; |
50 | if (m_actors.ContainsKey(name)) | 56 | lock (m_actors) |
51 | { | 57 | { |
52 | BSActor beingRemoved = m_actors[name]; | 58 | if (m_actors.ContainsKey(name)) |
53 | beingRemoved.Dispose(); | 59 | { |
54 | m_actors.Remove(name); | 60 | BSActor beingRemoved = m_actors[name]; |
55 | ret = true; | 61 | m_actors.Remove(name); |
62 | beingRemoved.Dispose(); | ||
63 | ret = true; | ||
64 | } | ||
56 | } | 65 | } |
57 | return ret; | 66 | return ret; |
58 | } | 67 | } |
59 | public void Clear() | 68 | public void Clear() |
60 | { | 69 | { |
61 | Release(); | 70 | lock (m_actors) |
62 | m_actors.Clear(); | 71 | { |
72 | ForEachActor(a => a.Dispose()); | ||
73 | m_actors.Clear(); | ||
74 | } | ||
75 | } | ||
76 | public void Dispose() | ||
77 | { | ||
78 | Clear(); | ||
63 | } | 79 | } |
64 | public bool HasActor(string name) | 80 | public bool HasActor(string name) |
65 | { | 81 | { |
66 | return m_actors.ContainsKey(name); | 82 | return m_actors.ContainsKey(name); |
67 | } | 83 | } |
84 | public bool TryGetActor(string actorName, out BSActor theActor) | ||
85 | { | ||
86 | return m_actors.TryGetValue(actorName, out theActor); | ||
87 | } | ||
68 | public void ForEachActor(Action<BSActor> act) | 88 | public void ForEachActor(Action<BSActor> act) |
69 | { | 89 | { |
70 | foreach (KeyValuePair<string, BSActor> kvp in m_actors) | 90 | lock (m_actors) |
71 | act(kvp.Value); | 91 | { |
92 | foreach (KeyValuePair<string, BSActor> kvp in m_actors) | ||
93 | act(kvp.Value); | ||
94 | } | ||
72 | } | 95 | } |
73 | 96 | ||
74 | public void Release() | 97 | public void Enable(bool enabl) |
75 | { | 98 | { |
76 | ForEachActor(a => a.Dispose()); | 99 | ForEachActor(a => a.SetEnabled(enabl)); |
77 | } | 100 | } |
78 | public void Refresh() | 101 | public void Refresh() |
79 | { | 102 | { |
80 | ForEachActor(a => a.Refresh()); | 103 | ForEachActor(a => a.Refresh()); |
81 | } | 104 | } |
82 | public void RemoveBodyDependencies() | 105 | public void RemoveDependencies() |
83 | { | 106 | { |
84 | ForEachActor(a => a.RemoveBodyDependencies()); | 107 | ForEachActor(a => a.RemoveDependencies()); |
85 | } | 108 | } |
86 | } | 109 | } |
87 | 110 | ||
@@ -90,7 +113,7 @@ public class BSActorCollection | |||
90 | /// Each physical object can have 'actors' who are pushing the object around. | 113 | /// Each physical object can have 'actors' who are pushing the object around. |
91 | /// This can be used for hover, locking axis, making vehicles, etc. | 114 | /// This can be used for hover, locking axis, making vehicles, etc. |
92 | /// Each physical object can have multiple actors acting on it. | 115 | /// Each physical object can have multiple actors acting on it. |
93 | /// | 116 | /// |
94 | /// An actor usually registers itself with physics scene events (pre-step action) | 117 | /// An actor usually registers itself with physics scene events (pre-step action) |
95 | /// and modifies the parameters on the host physical object. | 118 | /// and modifies the parameters on the host physical object. |
96 | /// </summary> | 119 | /// </summary> |
@@ -98,7 +121,7 @@ public abstract class BSActor | |||
98 | { | 121 | { |
99 | protected BSScene m_physicsScene { get; private set; } | 122 | protected BSScene m_physicsScene { get; private set; } |
100 | protected BSPhysObject m_controllingPrim { get; private set; } | 123 | protected BSPhysObject m_controllingPrim { get; private set; } |
101 | protected bool Enabled { get; set; } | 124 | public virtual bool Enabled { get; set; } |
102 | public string ActorName { get; private set; } | 125 | public string ActorName { get; private set; } |
103 | 126 | ||
104 | public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName) | 127 | public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName) |
@@ -114,8 +137,10 @@ public abstract class BSActor | |||
114 | { | 137 | { |
115 | get { return Enabled; } | 138 | get { return Enabled; } |
116 | } | 139 | } |
117 | // Turn the actor on an off. | 140 | |
118 | public virtual void Enable(bool setEnabled) | 141 | // Turn the actor on an off. Only used by ActorCollection to set all enabled/disabled. |
142 | // Anyone else should assign true/false to 'Enabled'. | ||
143 | public void SetEnabled(bool setEnabled) | ||
119 | { | 144 | { |
120 | Enabled = setEnabled; | 145 | Enabled = setEnabled; |
121 | } | 146 | } |
@@ -125,7 +150,7 @@ public abstract class BSActor | |||
125 | public abstract void Refresh(); | 150 | public abstract void Refresh(); |
126 | // The object's physical representation is being rebuilt so pick up any physical dependencies (constraints, ...). | 151 | // The object's physical representation is being rebuilt so pick up any physical dependencies (constraints, ...). |
127 | // Register a prestep action to restore physical requirements before the next simulation step. | 152 | // Register a prestep action to restore physical requirements before the next simulation step. |
128 | public abstract void RemoveBodyDependencies(); | 153 | public abstract void RemoveDependencies(); |
129 | 154 | ||
130 | } | 155 | } |
131 | } | 156 | } |