aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs
diff options
context:
space:
mode:
authorRobert Adams2013-04-07 14:05:35 -0700
committerRobert Adams2013-04-08 06:27:44 -0700
commita7a1b8b7e9269b446e3396a35153b00942c1e35b (patch)
treedf4c7041eb9a2819dd6e17aa2f95768a552f31e3 /OpenSim/Region/Physics/BulletSPlugin/BSActors.cs
parentBulletSim: complete movement of physical object action code out of the (diff)
downloadopensim-SC-a7a1b8b7e9269b446e3396a35153b00942c1e35b.zip
opensim-SC-a7a1b8b7e9269b446e3396a35153b00942c1e35b.tar.gz
opensim-SC-a7a1b8b7e9269b446e3396a35153b00942c1e35b.tar.bz2
opensim-SC-a7a1b8b7e9269b446e3396a35153b00942c1e35b.tar.xz
BulletSim: clean up actor code so routines use the same coding pattern.
Fix a few enabling problems.
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSActors.cs49
1 files changed, 35 insertions, 14 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs
index fb4d452..12a8817 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs
@@ -42,24 +42,36 @@ public class BSActorCollection
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 }
63 } 75 }
64 public void Dispose() 76 public void Dispose()
65 { 77 {
@@ -69,15 +81,22 @@ public class BSActorCollection
69 { 81 {
70 return m_actors.ContainsKey(name); 82 return m_actors.ContainsKey(name);
71 } 83 }
84 public bool TryGetActor(string actorName, out BSActor theActor)
85 {
86 return m_actors.TryGetValue(actorName, out theActor);
87 }
72 public void ForEachActor(Action<BSActor> act) 88 public void ForEachActor(Action<BSActor> act)
73 { 89 {
74 foreach (KeyValuePair<string, BSActor> kvp in m_actors) 90 lock (m_actors)
75 act(kvp.Value); 91 {
92 foreach (KeyValuePair<string, BSActor> kvp in m_actors)
93 act(kvp.Value);
94 }
76 } 95 }
77 96
78 public void Enable(bool enabl) 97 public void Enable(bool enabl)
79 { 98 {
80 ForEachActor(a => a.Enable(enabl)); 99 ForEachActor(a => a.SetEnabled(enabl));
81 } 100 }
82 public void Release() 101 public void Release()
83 { 102 {
@@ -106,7 +125,7 @@ public abstract class BSActor
106{ 125{
107 protected BSScene m_physicsScene { get; private set; } 126 protected BSScene m_physicsScene { get; private set; }
108 protected BSPhysObject m_controllingPrim { get; private set; } 127 protected BSPhysObject m_controllingPrim { get; private set; }
109 protected bool Enabled { get; set; } 128 public virtual bool Enabled { get; set; }
110 public string ActorName { get; private set; } 129 public string ActorName { get; private set; }
111 130
112 public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName) 131 public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName)
@@ -122,8 +141,10 @@ public abstract class BSActor
122 { 141 {
123 get { return Enabled; } 142 get { return Enabled; }
124 } 143 }
125 // Turn the actor on an off. 144
126 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)
127 { 148 {
128 Enabled = setEnabled; 149 Enabled = setEnabled;
129 } 150 }