diff options
author | Robert Adams | 2013-03-31 17:38:13 -0700 |
---|---|---|
committer | Robert Adams | 2013-03-31 22:19:42 -0700 |
commit | 75b8cf428e352b8939bb5e49f583d45dd226cf66 (patch) | |
tree | fd0091addd643abe1690645a879cddeb90bdd0d6 /OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | |
parent | BulletSim: convert BSDynamic to a BSActor and change BSPrim to set (diff) | |
download | opensim-SC-75b8cf428e352b8939bb5e49f583d45dd226cf66.zip opensim-SC-75b8cf428e352b8939bb5e49f583d45dd226cf66.tar.gz opensim-SC-75b8cf428e352b8939bb5e49f583d45dd226cf66.tar.bz2 opensim-SC-75b8cf428e352b8939bb5e49f583d45dd226cf66.tar.xz |
BulletSim: fix line endings in BSActor*
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | 254 |
1 files changed, 131 insertions, 123 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs index b9b5ce1..3163440 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | |||
@@ -1,123 +1,131 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyrightD | 9 | * * Redistributions in binary form must reproduce the above copyrightD |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Text; | 29 | using System.Text; |
30 | 30 | ||
31 | namespace OpenSim.Region.Physics.BulletSPlugin | 31 | 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 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 | 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 | m_actors[name] = actor; |
46 | } | 46 | } |
47 | public bool RemoveAndRelease(string name) | 47 | public bool RemoveAndRelease(string name) |
48 | { | 48 | { |
49 | bool ret = false; | 49 | bool ret = false; |
50 | if (m_actors.ContainsKey(name)) | 50 | if (m_actors.ContainsKey(name)) |
51 | { | 51 | { |
52 | BSActor beingRemoved = m_actors[name]; | 52 | BSActor beingRemoved = m_actors[name]; |
53 | beingRemoved.Release(); | 53 | beingRemoved.Dispose(); |
54 | m_actors.Remove(name); | 54 | m_actors.Remove(name); |
55 | ret = true; | 55 | ret = true; |
56 | } | 56 | } |
57 | return ret; | 57 | return ret; |
58 | } | 58 | } |
59 | public void Clear() | 59 | public void Clear() |
60 | { | 60 | { |
61 | Release(); | 61 | Release(); |
62 | m_actors.Clear(); | 62 | m_actors.Clear(); |
63 | } | 63 | } |
64 | public bool HasActor(string name) | 64 | public bool HasActor(string name) |
65 | { | 65 | { |
66 | return m_actors.ContainsKey(name); | 66 | return m_actors.ContainsKey(name); |
67 | } | 67 | } |
68 | public void ForEachActor(Action<BSActor> act) | 68 | public void ForEachActor(Action<BSActor> act) |
69 | { | 69 | { |
70 | foreach (KeyValuePair<string, BSActor> kvp in m_actors) | 70 | foreach (KeyValuePair<string, BSActor> kvp in m_actors) |
71 | act(kvp.Value); | 71 | act(kvp.Value); |
72 | } | 72 | } |
73 | 73 | ||
74 | public void Release() | 74 | public void Release() |
75 | { | 75 | { |
76 | ForEachActor(a => a.Release()); | 76 | ForEachActor(a => a.Dispose()); |
77 | } | 77 | } |
78 | public void Refresh() | 78 | public void Refresh() |
79 | { | 79 | { |
80 | ForEachActor(a => a.Refresh()); | 80 | ForEachActor(a => a.Refresh()); |
81 | } | 81 | } |
82 | public void RemoveBodyDependencies() | 82 | public void RemoveBodyDependencies() |
83 | { | 83 | { |
84 | ForEachActor(a => a.RemoveBodyDependencies()); | 84 | ForEachActor(a => a.RemoveBodyDependencies()); |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | // ============================================================================= | 88 | // ============================================================================= |
89 | public abstract class BSActor | 89 | /// <summary> |
90 | { | 90 | /// Each physical object can have 'actors' who are pushing the object around. |
91 | protected BSScene PhysicsScene { get; private set; } | 91 | /// This can be used for hover, locking axis, making vehicles, etc. |
92 | protected BSPhysObject Prim { get; private set; } | 92 | /// Each physical object can have multiple actors acting on it. |
93 | protected bool Enabled { get; set; } | 93 | /// |
94 | public string ActorName { get; private set; } | 94 | /// An actor usually registers itself with physics scene events (pre-step action) |
95 | 95 | /// and modifies the parameters on the host physical object. | |
96 | public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName) | 96 | /// </summary> |
97 | { | 97 | public abstract class BSActor |
98 | PhysicsScene = physicsScene; | 98 | { |
99 | Prim = pObj; | 99 | protected BSScene PhysicsScene { get; private set; } |
100 | ActorName = actorName; | 100 | protected BSPhysObject Prim { get; private set; } |
101 | Enabled = true; | 101 | protected bool Enabled { get; set; } |
102 | } | 102 | public string ActorName { get; private set; } |
103 | 103 | ||
104 | // Return 'true' if activily updating the prim | 104 | public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName) |
105 | public virtual bool isActive | 105 | { |
106 | { | 106 | PhysicsScene = physicsScene; |
107 | get { return Enabled; } | 107 | Prim = pObj; |
108 | } | 108 | ActorName = actorName; |
109 | // Turn the actor on an off. | 109 | Enabled = true; |
110 | public virtual void Enable(bool setEnabled) | 110 | } |
111 | { | 111 | |
112 | Enabled = setEnabled; | 112 | // Return 'true' if activily updating the prim |
113 | } | 113 | public virtual bool isActive |
114 | // Release any connections and resources used by the actor. | 114 | { |
115 | public abstract void Release(); | 115 | get { return Enabled; } |
116 | // Called when physical parameters (properties set in Bullet) need to be re-applied. | 116 | } |
117 | public abstract void Refresh(); | 117 | // Turn the actor on an off. |
118 | // The object's physical representation is being rebuilt so pick up any physical dependencies (constraints, ...). | 118 | public virtual void Enable(bool setEnabled) |
119 | // Register a prestep action to restore physical requirements before the next simulation step. | 119 | { |
120 | public abstract void RemoveBodyDependencies(); | 120 | Enabled = setEnabled; |
121 | 121 | } | |
122 | } | 122 | // Release any connections and resources used by the actor. |
123 | } | 123 | public abstract void Dispose(); |
124 | // Called when physical parameters (properties set in Bullet) need to be re-applied. | ||
125 | public abstract void Refresh(); | ||
126 | // 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. | ||
128 | public abstract void RemoveBodyDependencies(); | ||
129 | |||
130 | } | ||
131 | } | ||