diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSActors.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs index 5a19ba4..12a8817 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | |||
@@ -32,45 +32,72 @@ 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 | Release(); | ||
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 | ||
97 | public void Enable(bool enabl) | ||
98 | { | ||
99 | ForEachActor(a => a.SetEnabled(enabl)); | ||
100 | } | ||
74 | public void Release() | 101 | public void Release() |
75 | { | 102 | { |
76 | ForEachActor(a => a.Dispose()); | 103 | ForEachActor(a => a.Dispose()); |
@@ -98,7 +125,7 @@ public abstract class BSActor | |||
98 | { | 125 | { |
99 | protected BSScene m_physicsScene { get; private set; } | 126 | protected BSScene m_physicsScene { get; private set; } |
100 | protected BSPhysObject m_controllingPrim { get; private set; } | 127 | protected BSPhysObject m_controllingPrim { get; private set; } |
101 | protected bool Enabled { get; set; } | 128 | public virtual bool Enabled { get; set; } |
102 | public string ActorName { get; private set; } | 129 | public string ActorName { get; private set; } |
103 | 130 | ||
104 | public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName) | 131 | public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName) |
@@ -114,8 +141,10 @@ public abstract class BSActor | |||
114 | { | 141 | { |
115 | get { return Enabled; } | 142 | get { return Enabled; } |
116 | } | 143 | } |
117 | // Turn the actor on an off. | 144 | |
118 | public virtual void Enable(bool setEnabled) | 145 | // Turn the actor on an off. Only used by ActorCollection to set all enabled/disabled. |
146 | // Anyone else should assign true/false to 'Enabled'. | ||
147 | public void SetEnabled(bool setEnabled) | ||
119 | { | 148 | { |
120 | Enabled = setEnabled; | 149 | Enabled = setEnabled; |
121 | } | 150 | } |