aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs
diff options
context:
space:
mode:
authorRobert Adams2013-03-31 09:12:18 -0700
committerRobert Adams2013-03-31 22:19:41 -0700
commit2c581cae2a77628704ae7ae2f9f0f0a87cbb0072 (patch)
tree2095b9afd1a0c984119fcac98e3dfd94ab99aabb /OpenSim/Region/Physics/BulletSPlugin/BSActors.cs
parentExport permission, part two. Setting export perms for textures and clothing w... (diff)
downloadopensim-SC_OLD-2c581cae2a77628704ae7ae2f9f0f0a87cbb0072.zip
opensim-SC_OLD-2c581cae2a77628704ae7ae2f9f0f0a87cbb0072.tar.gz
opensim-SC_OLD-2c581cae2a77628704ae7ae2f9f0f0a87cbb0072.tar.bz2
opensim-SC_OLD-2c581cae2a77628704ae7ae2f9f0f0a87cbb0072.tar.xz
BulletSim: Add physical 'actors' that operate on the physical object.
Add first 'actor' for locked axis.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSActors.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSActors.cs123
1 files changed, 123 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs
new file mode 100755
index 0000000..b9b5ce1
--- /dev/null
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs
@@ -0,0 +1,123 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyrightD
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30
31namespace OpenSim.Region.Physics.BulletSPlugin
32{
33public class BSActorCollection
34{
35 private BSScene PhysicsScene { get; set; }
36 private Dictionary<string, BSActor> m_actors;
37
38 public BSActorCollection(BSScene physicsScene)
39 {
40 PhysicsScene = physicsScene;
41 m_actors = new Dictionary<string, BSActor>();
42 }
43 public void Add(string name, BSActor actor)
44 {
45 m_actors[name] = actor;
46 }
47 public bool RemoveAndRelease(string name)
48 {
49 bool ret = false;
50 if (m_actors.ContainsKey(name))
51 {
52 BSActor beingRemoved = m_actors[name];
53 beingRemoved.Release();
54 m_actors.Remove(name);
55 ret = true;
56 }
57 return ret;
58 }
59 public void Clear()
60 {
61 Release();
62 m_actors.Clear();
63 }
64 public bool HasActor(string name)
65 {
66 return m_actors.ContainsKey(name);
67 }
68 public void ForEachActor(Action<BSActor> act)
69 {
70 foreach (KeyValuePair<string, BSActor> kvp in m_actors)
71 act(kvp.Value);
72 }
73
74 public void Release()
75 {
76 ForEachActor(a => a.Release());
77 }
78 public void Refresh()
79 {
80 ForEachActor(a => a.Refresh());
81 }
82 public void RemoveBodyDependencies()
83 {
84 ForEachActor(a => a.RemoveBodyDependencies());
85 }
86}
87
88// =============================================================================
89public abstract class BSActor
90{
91 protected BSScene PhysicsScene { get; private set; }
92 protected BSPhysObject Prim { get; private set; }
93 protected bool Enabled { get; set; }
94 public string ActorName { get; private set; }
95
96 public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName)
97 {
98 PhysicsScene = physicsScene;
99 Prim = pObj;
100 ActorName = actorName;
101 Enabled = true;
102 }
103
104 // Return 'true' if activily updating the prim
105 public virtual bool isActive
106 {
107 get { return Enabled; }
108 }
109 // Turn the actor on an off.
110 public virtual void Enable(bool setEnabled)
111 {
112 Enabled = setEnabled;
113 }
114 // Release any connections and resources used by the actor.
115 public abstract void Release();
116 // Called when physical parameters (properties set in Bullet) need to be re-applied.
117 public abstract void Refresh();
118 // The object's physical representation is being rebuilt so pick up any physical dependencies (constraints, ...).
119 // Register a prestep action to restore physical requirements before the next simulation step.
120 public abstract void RemoveBodyDependencies();
121
122}
123}