aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Manager/PhysicsActor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/Manager/PhysicsActor.cs')
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs110
1 files changed, 77 insertions, 33 deletions
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 880c3ea..c2acf97 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -25,8 +25,10 @@
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 27
28using log4net;
28using System; 29using System;
29using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection;
30using OpenSim.Framework; 32using OpenSim.Framework;
31using OpenMetaverse; 33using OpenMetaverse;
32 34
@@ -46,10 +48,10 @@ namespace OpenSim.Region.Physics.Manager
46 48
47 public enum PIDHoverType 49 public enum PIDHoverType
48 { 50 {
49 Ground 51 Ground,
50 , GroundAndWater 52 GroundAndWater,
51 , Water 53 Water,
52 , Absolute 54 Absolute
53 } 55 }
54 56
55 public struct ContactPoint 57 public struct ContactPoint
@@ -66,42 +68,31 @@ namespace OpenSim.Region.Physics.Manager
66 } 68 }
67 } 69 }
68 70
71 /// <summary>
72 /// Used to pass collision information to OnCollisionUpdate listeners.
73 /// </summary>
69 public class CollisionEventUpdate : EventArgs 74 public class CollisionEventUpdate : EventArgs
70 { 75 {
71 // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. 76 /// <summary>
77 /// Number of collision events in this update.
78 /// </summary>
79 public int Count { get { return m_objCollisionList.Count; } }
72 80
73 public int m_colliderType; 81 public bool CollisionsOnPreviousFrame { get; private set; }
74 public int m_GenericStartEnd;
75 //public uint m_LocalID;
76 public Dictionary<uint, ContactPoint> m_objCollisionList = new Dictionary<uint, ContactPoint>();
77 82
78 public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, Dictionary<uint, ContactPoint> objCollisionList) 83 public Dictionary<uint, ContactPoint> m_objCollisionList;
84
85 public CollisionEventUpdate(Dictionary<uint, ContactPoint> objCollisionList)
79 { 86 {
80 m_colliderType = colliderType;
81 m_GenericStartEnd = GenericStartEnd;
82 m_objCollisionList = objCollisionList; 87 m_objCollisionList = objCollisionList;
83 } 88 }
84 89
85 public CollisionEventUpdate() 90 public CollisionEventUpdate()
86 { 91 {
87 m_colliderType = (int) ActorTypes.Unknown;
88 m_GenericStartEnd = 1;
89 m_objCollisionList = new Dictionary<uint, ContactPoint>(); 92 m_objCollisionList = new Dictionary<uint, ContactPoint>();
90 } 93 }
91 94
92 public int collidertype 95 public void AddCollider(uint localID, ContactPoint contact)
93 {
94 get { return m_colliderType; }
95 set { m_colliderType = value; }
96 }
97
98 public int GenericStartEnd
99 {
100 get { return m_GenericStartEnd; }
101 set { m_GenericStartEnd = value; }
102 }
103
104 public void addCollider(uint localID, ContactPoint contact)
105 { 96 {
106 if (!m_objCollisionList.ContainsKey(localID)) 97 if (!m_objCollisionList.ContainsKey(localID))
107 { 98 {
@@ -113,10 +104,20 @@ namespace OpenSim.Region.Physics.Manager
113 m_objCollisionList[localID] = contact; 104 m_objCollisionList[localID] = contact;
114 } 105 }
115 } 106 }
107
108 /// <summary>
109 /// Clear added collision events.
110 /// </summary>
111 public void Clear()
112 {
113 m_objCollisionList.Clear();
114 }
116 } 115 }
117 116
118 public abstract class PhysicsActor 117 public abstract class PhysicsActor
119 { 118 {
119// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
120
120 public delegate void RequestTerseUpdate(); 121 public delegate void RequestTerseUpdate();
121 public delegate void CollisionUpdate(EventArgs e); 122 public delegate void CollisionUpdate(EventArgs e);
122 public delegate void OutOfBounds(Vector3 pos); 123 public delegate void OutOfBounds(Vector3 pos);
@@ -127,7 +128,13 @@ namespace OpenSim.Region.Physics.Manager
127 public event VelocityUpdate OnVelocityUpdate; 128 public event VelocityUpdate OnVelocityUpdate;
128 public event OrientationUpdate OnOrientationUpdate; 129 public event OrientationUpdate OnOrientationUpdate;
129 public event RequestTerseUpdate OnRequestTerseUpdate; 130 public event RequestTerseUpdate OnRequestTerseUpdate;
131
132 /// <summary>
133 /// Subscribers to this event must synchronously handle the dictionary of collisions received, since the event
134 /// object is reused in subsequent physics frames.
135 /// </summary>
130 public event CollisionUpdate OnCollisionUpdate; 136 public event CollisionUpdate OnCollisionUpdate;
137
131 public event OutOfBounds OnOutOfBounds; 138 public event OutOfBounds OnOutOfBounds;
132#pragma warning restore 67 139#pragma warning restore 67
133 140
@@ -142,14 +149,30 @@ namespace OpenSim.Region.Physics.Manager
142 149
143 public abstract PrimitiveBaseShape Shape { set; } 150 public abstract PrimitiveBaseShape Shape { set; }
144 151
145 public abstract uint LocalID { set; } 152 uint m_baseLocalID;
153 public virtual uint LocalID
154 {
155 set { m_baseLocalID = value; }
156 get { return m_baseLocalID; }
157 }
146 158
147 public abstract bool Grabbed { set; } 159 public abstract bool Grabbed { set; }
148 160
149 public abstract bool Selected { set; } 161 public abstract bool Selected { set; }
150 162
163 /// <summary>
164 /// Name of this actor.
165 /// </summary>
166 /// <remarks>
167 /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or
168 /// water. This is not a problem due to the formatting of names given by prims and avatars.
169 /// </remarks>
170 public string Name { get; protected set; }
171
172 /// <summary>
173 /// This is being used by ODE joint code.
174 /// </summary>
151 public string SOPName; 175 public string SOPName;
152 public string SOPDescription;
153 176
154 public abstract void CrossingFailure(); 177 public abstract void CrossingFailure();
155 178
@@ -189,18 +212,26 @@ namespace OpenSim.Region.Physics.Manager
189 { 212 {
190 CollisionUpdate handler = OnCollisionUpdate; 213 CollisionUpdate handler = OnCollisionUpdate;
191 214
215// m_log.DebugFormat("[PHYSICS ACTOR]: Sending collision for {0}", LocalID);
216
192 if (handler != null) 217 if (handler != null)
193 {
194 handler(e); 218 handler(e);
195 }
196 } 219 }
197 220
198 public virtual void SetMaterial (int material) 221 public virtual void SetMaterial (int material)
199 { 222 {
200
201 } 223 }
202 224
225 /// <summary>
226 /// Position of this actor.
227 /// </summary>
228 /// <remarks>
229 /// Setting this directly moves the actor to a given position.
230 /// Getting this retrieves the position calculated by physics scene updates, using factors such as velocity and
231 /// collisions.
232 /// </remarks>
203 public abstract Vector3 Position { get; set; } 233 public abstract Vector3 Position { get; set; }
234
204 public abstract float Mass { get; } 235 public abstract float Mass { get; }
205 public abstract Vector3 Force { get; set; } 236 public abstract Vector3 Force { get; set; }
206 237
@@ -210,11 +241,24 @@ namespace OpenSim.Region.Physics.Manager
210 public abstract void VehicleRotationParam(int param, Quaternion rotation); 241 public abstract void VehicleRotationParam(int param, Quaternion rotation);
211 public abstract void VehicleFlags(int param, bool remove); 242 public abstract void VehicleFlags(int param, bool remove);
212 243
213 public abstract void SetVolumeDetect(int param); // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more 244 /// <summary>
245 /// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
246 /// </summary>
247 public abstract void SetVolumeDetect(int param);
214 248
215 public abstract Vector3 GeometricCenter { get; } 249 public abstract Vector3 GeometricCenter { get; }
216 public abstract Vector3 CenterOfMass { get; } 250 public abstract Vector3 CenterOfMass { get; }
251
252 /// <summary>
253 /// Velocity of this actor.
254 /// </summary>
255 /// <remarks>
256 /// Setting this provides a target velocity for physics scene updates.
257 /// Getting this returns the velocity calculated by physics scene updates, using factors such as target velocity,
258 /// time to accelerate and collisions.
259 /// </remarks>
217 public abstract Vector3 Velocity { get; set; } 260 public abstract Vector3 Velocity { get; set; }
261
218 public abstract Vector3 Torque { get; set; } 262 public abstract Vector3 Torque { get; set; }
219 public abstract float CollisionScore { get; set;} 263 public abstract float CollisionScore { get; set;}
220 public abstract Vector3 Acceleration { get; } 264 public abstract Vector3 Acceleration { get; }