diff options
author | lbsa71 | 2007-10-30 09:05:31 +0000 |
---|---|---|
committer | lbsa71 | 2007-10-30 09:05:31 +0000 |
commit | 67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch) | |
tree | 20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Region/Physics/Manager | |
parent | * Deleted .user file (diff) | |
download | opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2 opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz |
* Optimized usings
* Shortened type references
* Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Region/Physics/Manager')
-rw-r--r-- | OpenSim/Region/Physics/Manager/AssemblyInfo.cs | 22 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsActor.cs | 110 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs | 143 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsScene.cs | 26 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsVector.cs | 5 |
5 files changed, 119 insertions, 187 deletions
diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs index 2355e91..c213b64 100644 --- a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs | |||
@@ -27,24 +27,26 @@ | |||
27 | */ | 27 | */ |
28 | using System.Reflection; | 28 | using System.Reflection; |
29 | using System.Runtime.InteropServices; | 29 | using System.Runtime.InteropServices; |
30 | |||
30 | // Information about this assembly is defined by the following | 31 | // Information about this assembly is defined by the following |
31 | // attributes. | 32 | // attributes. |
32 | // | 33 | // |
33 | // change them to the information which is associated with the assembly | 34 | // change them to the information which is associated with the assembly |
34 | // you compile. | 35 | // you compile. |
35 | 36 | ||
36 | [assembly: AssemblyTitle("PhysicsManager")] | 37 | [assembly : AssemblyTitle("PhysicsManager")] |
37 | [assembly: AssemblyDescription("")] | 38 | [assembly : AssemblyDescription("")] |
38 | [assembly: AssemblyConfiguration("")] | 39 | [assembly : AssemblyConfiguration("")] |
39 | [assembly: AssemblyCompany("")] | 40 | [assembly : AssemblyCompany("")] |
40 | [assembly: AssemblyProduct("PhysicsManager")] | 41 | [assembly : AssemblyProduct("PhysicsManager")] |
41 | [assembly: AssemblyCopyright("")] | 42 | [assembly : AssemblyCopyright("")] |
42 | [assembly: AssemblyTrademark("")] | 43 | [assembly : AssemblyTrademark("")] |
43 | [assembly: AssemblyCulture("")] | 44 | [assembly : AssemblyCulture("")] |
44 | 45 | ||
45 | // This sets the default COM visibility of types in the assembly to invisible. | 46 | // This sets the default COM visibility of types in the assembly to invisible. |
46 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. | 47 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. |
47 | [assembly: ComVisible(false)] | 48 | |
49 | [assembly : ComVisible(false)] | ||
48 | 50 | ||
49 | // The assembly version has following format : | 51 | // The assembly version has following format : |
50 | // | 52 | // |
@@ -53,4 +55,4 @@ using System.Runtime.InteropServices; | |||
53 | // You can specify all values by your own or you can build default build and revision | 55 | // You can specify all values by your own or you can build default build and revision |
54 | // numbers with the '*' character (the default): | 56 | // numbers with the '*' character (the default): |
55 | 57 | ||
56 | [assembly: AssemblyVersion("1.0.*")] | 58 | [assembly : AssemblyVersion("1.0.*")] \ No newline at end of file |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 0fa7455..b59c13a 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -30,7 +30,9 @@ using Axiom.Math; | |||
30 | namespace OpenSim.Region.Physics.Manager | 30 | namespace OpenSim.Region.Physics.Manager |
31 | { | 31 | { |
32 | public delegate void PositionUpdate(PhysicsVector position); | 32 | public delegate void PositionUpdate(PhysicsVector position); |
33 | |||
33 | public delegate void VelocityUpdate(PhysicsVector velocity); | 34 | public delegate void VelocityUpdate(PhysicsVector velocity); |
35 | |||
34 | public delegate void OrientationUpdate(Quaternion orientation); | 36 | public delegate void OrientationUpdate(Quaternion orientation); |
35 | 37 | ||
36 | public abstract class PhysicsActor | 38 | public abstract class PhysicsActor |
@@ -43,52 +45,22 @@ namespace OpenSim.Region.Physics.Manager | |||
43 | 45 | ||
44 | public static PhysicsActor Null | 46 | public static PhysicsActor Null |
45 | { | 47 | { |
46 | get | 48 | get { return new NullPhysicsActor(); } |
47 | { | ||
48 | return new NullPhysicsActor(); | ||
49 | } | ||
50 | } | 49 | } |
51 | 50 | ||
52 | public abstract PhysicsVector Size | 51 | public abstract PhysicsVector Size { get; set; } |
53 | { | ||
54 | get; | ||
55 | set; | ||
56 | } | ||
57 | 52 | ||
58 | public abstract PhysicsVector Position | 53 | public abstract PhysicsVector Position { get; set; } |
59 | { | ||
60 | get; | ||
61 | set; | ||
62 | } | ||
63 | 54 | ||
64 | public abstract PhysicsVector Velocity | 55 | public abstract PhysicsVector Velocity { get; set; } |
65 | { | ||
66 | get; | ||
67 | set; | ||
68 | } | ||
69 | 56 | ||
70 | public abstract PhysicsVector Acceleration | 57 | public abstract PhysicsVector Acceleration { get; } |
71 | { | ||
72 | get; | ||
73 | } | ||
74 | 58 | ||
75 | public abstract Quaternion Orientation | 59 | public abstract Quaternion Orientation { get; set; } |
76 | { | ||
77 | get; | ||
78 | set; | ||
79 | } | ||
80 | 60 | ||
81 | public abstract bool Flying | 61 | public abstract bool Flying { get; set; } |
82 | { | ||
83 | get; | ||
84 | set; | ||
85 | } | ||
86 | 62 | ||
87 | public abstract bool Kinematic | 63 | public abstract bool Kinematic { get; set; } |
88 | { | ||
89 | get; | ||
90 | set; | ||
91 | } | ||
92 | 64 | ||
93 | public abstract void AddForce(PhysicsVector force); | 65 | public abstract void AddForce(PhysicsVector force); |
94 | 66 | ||
@@ -99,50 +71,26 @@ namespace OpenSim.Region.Physics.Manager | |||
99 | { | 71 | { |
100 | public override PhysicsVector Position | 72 | public override PhysicsVector Position |
101 | { | 73 | { |
102 | get | 74 | get { return PhysicsVector.Zero; } |
103 | { | 75 | set { return; } |
104 | return PhysicsVector.Zero; | ||
105 | } | ||
106 | set | ||
107 | { | ||
108 | return; | ||
109 | } | ||
110 | } | 76 | } |
111 | 77 | ||
112 | public override PhysicsVector Size | 78 | public override PhysicsVector Size |
113 | { | 79 | { |
114 | get | 80 | get { return PhysicsVector.Zero; } |
115 | { | 81 | set { return; } |
116 | return PhysicsVector.Zero; | ||
117 | } | ||
118 | set | ||
119 | { | ||
120 | return; | ||
121 | } | ||
122 | } | 82 | } |
123 | 83 | ||
124 | public override PhysicsVector Velocity | 84 | public override PhysicsVector Velocity |
125 | { | 85 | { |
126 | get | 86 | get { return PhysicsVector.Zero; } |
127 | { | 87 | set { return; } |
128 | return PhysicsVector.Zero; | ||
129 | } | ||
130 | set | ||
131 | { | ||
132 | return; | ||
133 | } | ||
134 | } | 88 | } |
135 | 89 | ||
136 | public override Quaternion Orientation | 90 | public override Quaternion Orientation |
137 | { | 91 | { |
138 | get | 92 | get { return Quaternion.Identity; } |
139 | { | 93 | set { } |
140 | return Quaternion.Identity; | ||
141 | } | ||
142 | set | ||
143 | { | ||
144 | |||
145 | } | ||
146 | } | 94 | } |
147 | 95 | ||
148 | public override PhysicsVector Acceleration | 96 | public override PhysicsVector Acceleration |
@@ -152,26 +100,14 @@ namespace OpenSim.Region.Physics.Manager | |||
152 | 100 | ||
153 | public override bool Flying | 101 | public override bool Flying |
154 | { | 102 | { |
155 | get | 103 | get { return false; } |
156 | { | 104 | set { return; } |
157 | return false; | ||
158 | } | ||
159 | set | ||
160 | { | ||
161 | return; | ||
162 | } | ||
163 | } | 105 | } |
164 | 106 | ||
165 | public override bool Kinematic | 107 | public override bool Kinematic |
166 | { | 108 | { |
167 | get | 109 | get { return true; } |
168 | { | 110 | set { return; } |
169 | return true; | ||
170 | } | ||
171 | set | ||
172 | { | ||
173 | return; | ||
174 | } | ||
175 | } | 111 | } |
176 | 112 | ||
177 | public override void AddForce(PhysicsVector force) | 113 | public override void AddForce(PhysicsVector force) |
@@ -184,4 +120,4 @@ namespace OpenSim.Region.Physics.Manager | |||
184 | return; | 120 | return; |
185 | } | 121 | } |
186 | } | 122 | } |
187 | } | 123 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs index 81bc938..09ebf29 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs | |||
@@ -33,77 +33,77 @@ using OpenSim.Framework.Console; | |||
33 | 33 | ||
34 | namespace OpenSim.Region.Physics.Manager | 34 | namespace OpenSim.Region.Physics.Manager |
35 | { | 35 | { |
36 | /// <summary> | 36 | /// <summary> |
37 | /// Description of MyClass. | 37 | /// Description of MyClass. |
38 | /// </summary> | 38 | /// </summary> |
39 | public class PhysicsPluginManager | 39 | public class PhysicsPluginManager |
40 | { | 40 | { |
41 | private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>(); | 41 | private Dictionary<string, IPhysicsPlugin> _plugins = new Dictionary<string, IPhysicsPlugin>(); |
42 | 42 | ||
43 | public PhysicsPluginManager() | 43 | public PhysicsPluginManager() |
44 | { | 44 | { |
45 | 45 | } | |
46 | } | 46 | |
47 | 47 | public PhysicsScene GetPhysicsScene(string engineName) | |
48 | public PhysicsScene GetPhysicsScene(string engineName) | 48 | { |
49 | { | ||
50 | if (String.IsNullOrEmpty(engineName)) | 49 | if (String.IsNullOrEmpty(engineName)) |
51 | { | 50 | { |
52 | return PhysicsScene.Null; | 51 | return PhysicsScene.Null; |
53 | } | 52 | } |
54 | 53 | ||
55 | if(_plugins.ContainsKey(engineName)) | 54 | if (_plugins.ContainsKey(engineName)) |
56 | { | 55 | { |
57 | MainLog.Instance.Verbose("PHYSICS","creating "+engineName); | 56 | MainLog.Instance.Verbose("PHYSICS", "creating " + engineName); |
58 | return _plugins[engineName].GetScene(); | 57 | return _plugins[engineName].GetScene(); |
59 | } | 58 | } |
60 | else | 59 | else |
61 | { | 60 | { |
62 | MainLog.Instance.Warn("PHYSICS", "couldn't find physicsEngine: {0}", engineName); | 61 | MainLog.Instance.Warn("PHYSICS", "couldn't find physicsEngine: {0}", engineName); |
63 | throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName)); | 62 | throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}", engineName)); |
64 | } | 63 | } |
65 | } | 64 | } |
66 | 65 | ||
67 | public void LoadPlugins() | 66 | public void LoadPlugins() |
68 | { | 67 | { |
69 | string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory ,"Physics"); | 68 | string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Physics"); |
70 | string[] pluginFiles = Directory.GetFiles(path, "*.dll"); | 69 | string[] pluginFiles = Directory.GetFiles(path, "*.dll"); |
71 | 70 | ||
72 | 71 | ||
73 | for(int i= 0; i<pluginFiles.Length; i++) | 72 | for (int i = 0; i < pluginFiles.Length; i++) |
74 | { | 73 | { |
75 | this.AddPlugin(pluginFiles[i]); | 74 | AddPlugin(pluginFiles[i]); |
76 | } | 75 | } |
77 | } | 76 | } |
78 | 77 | ||
79 | private void AddPlugin(string FileName) | 78 | private void AddPlugin(string FileName) |
80 | { | 79 | { |
81 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | 80 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); |
82 | 81 | ||
83 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 82 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
84 | { | 83 | { |
85 | if (pluginType.IsPublic) | 84 | if (pluginType.IsPublic) |
86 | { | 85 | { |
87 | if (!pluginType.IsAbstract) | 86 | if (!pluginType.IsAbstract) |
88 | { | 87 | { |
89 | Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true); | 88 | Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true); |
90 | 89 | ||
91 | if (typeInterface != null) | 90 | if (typeInterface != null) |
92 | { | 91 | { |
93 | IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | 92 | IPhysicsPlugin plug = |
94 | plug.Init(); | 93 | (IPhysicsPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); |
95 | this._plugins.Add(plug.GetName(),plug); | 94 | plug.Init(); |
96 | OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS","Added physics engine: " + plug.GetName()); | 95 | _plugins.Add(plug.GetName(), plug); |
97 | 96 | MainLog.Instance.Verbose("PHYSICS", "Added physics engine: " + plug.GetName()); | |
98 | } | 97 | } |
99 | 98 | ||
100 | typeInterface = null; | 99 | typeInterface = null; |
101 | } | 100 | } |
102 | } | 101 | } |
103 | } | 102 | } |
104 | 103 | ||
105 | pluginAssembly = null; | 104 | pluginAssembly = null; |
106 | } | 105 | } |
106 | |||
107 | //--- | 107 | //--- |
108 | public static void PhysicsPluginMessage(string message, bool isWarning) | 108 | public static void PhysicsPluginMessage(string message, bool isWarning) |
109 | { | 109 | { |
@@ -116,14 +116,15 @@ namespace OpenSim.Region.Physics.Manager | |||
116 | MainLog.Instance.Verbose("PHYSICS", message); | 116 | MainLog.Instance.Verbose("PHYSICS", message); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | |||
119 | //--- | 120 | //--- |
120 | } | 121 | } |
121 | 122 | ||
122 | public interface IPhysicsPlugin | 123 | public interface IPhysicsPlugin |
123 | { | 124 | { |
124 | bool Init(); | 125 | bool Init(); |
125 | PhysicsScene GetScene(); | 126 | PhysicsScene GetScene(); |
126 | string GetName(); | 127 | string GetName(); |
127 | void Dispose(); | 128 | void Dispose(); |
128 | } | 129 | } |
129 | } | 130 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index 9ab2997..3f08234 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs | |||
@@ -25,9 +25,9 @@ | |||
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 | */ |
28 | using Axiom.Math; | ||
28 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
29 | using OpenSim.Framework.Console; | 30 | using OpenSim.Framework.Console; |
30 | using Axiom.Math; | ||
31 | 31 | ||
32 | namespace OpenSim.Region.Physics.Manager | 32 | namespace OpenSim.Region.Physics.Manager |
33 | { | 33 | { |
@@ -35,10 +35,7 @@ namespace OpenSim.Region.Physics.Manager | |||
35 | { | 35 | { |
36 | public static PhysicsScene Null | 36 | public static PhysicsScene Null |
37 | { | 37 | { |
38 | get | 38 | get { return new NullPhysicsScene(); } |
39 | { | ||
40 | return new NullPhysicsScene(); | ||
41 | } | ||
42 | } | 39 | } |
43 | 40 | ||
44 | public abstract PhysicsActor AddAvatar(string avName, PhysicsVector position); | 41 | public abstract PhysicsActor AddAvatar(string avName, PhysicsVector position); |
@@ -47,7 +44,8 @@ namespace OpenSim.Region.Physics.Manager | |||
47 | 44 | ||
48 | public abstract void RemovePrim(PhysicsActor prim); | 45 | public abstract void RemovePrim(PhysicsActor prim); |
49 | 46 | ||
50 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation); | 47 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, |
48 | PhysicsVector size, Quaternion rotation); | ||
51 | 49 | ||
52 | public abstract void Simulate(float timeStep); | 50 | public abstract void Simulate(float timeStep); |
53 | 51 | ||
@@ -57,10 +55,7 @@ namespace OpenSim.Region.Physics.Manager | |||
57 | 55 | ||
58 | public abstract void DeleteTerrain(); | 56 | public abstract void DeleteTerrain(); |
59 | 57 | ||
60 | public abstract bool IsThreaded | 58 | public abstract bool IsThreaded { get; } |
61 | { | ||
62 | get; | ||
63 | } | ||
64 | 59 | ||
65 | private class NullPhysicsScene : PhysicsScene | 60 | private class NullPhysicsScene : PhysicsScene |
66 | { | 61 | { |
@@ -74,12 +69,10 @@ namespace OpenSim.Region.Physics.Manager | |||
74 | 69 | ||
75 | public override void RemoveAvatar(PhysicsActor actor) | 70 | public override void RemoveAvatar(PhysicsActor actor) |
76 | { | 71 | { |
77 | |||
78 | } | 72 | } |
79 | 73 | ||
80 | public override void RemovePrim(PhysicsActor prim) | 74 | public override void RemovePrim(PhysicsActor prim) |
81 | { | 75 | { |
82 | |||
83 | } | 76 | } |
84 | 77 | ||
85 | /* | 78 | /* |
@@ -89,7 +82,9 @@ namespace OpenSim.Region.Physics.Manager | |||
89 | return PhysicsActor.Null; | 82 | return PhysicsActor.Null; |
90 | } | 83 | } |
91 | */ | 84 | */ |
92 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) | 85 | |
86 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, | ||
87 | PhysicsVector size, Quaternion rotation) | ||
93 | { | 88 | { |
94 | MainLog.Instance.Verbose("NullPhysicsScene : AddPrim({0},{1})", position, size); | 89 | MainLog.Instance.Verbose("NullPhysicsScene : AddPrim({0},{1})", position, size); |
95 | return PhysicsActor.Null; | 90 | return PhysicsActor.Null; |
@@ -97,7 +92,7 @@ namespace OpenSim.Region.Physics.Manager | |||
97 | 92 | ||
98 | public override void Simulate(float timeStep) | 93 | public override void Simulate(float timeStep) |
99 | { | 94 | { |
100 | m_workIndicator = (m_workIndicator + 1) % 10; | 95 | m_workIndicator = (m_workIndicator + 1)%10; |
101 | 96 | ||
102 | //OpenSim.Framework.Console.MainLog.Instance.SetStatus(m_workIndicator.ToString()); | 97 | //OpenSim.Framework.Console.MainLog.Instance.SetStatus(m_workIndicator.ToString()); |
103 | } | 98 | } |
@@ -114,7 +109,6 @@ namespace OpenSim.Region.Physics.Manager | |||
114 | 109 | ||
115 | public override void DeleteTerrain() | 110 | public override void DeleteTerrain() |
116 | { | 111 | { |
117 | |||
118 | } | 112 | } |
119 | 113 | ||
120 | public override bool IsThreaded | 114 | public override bool IsThreaded |
@@ -123,4 +117,4 @@ namespace OpenSim.Region.Physics.Manager | |||
123 | } | 117 | } |
124 | } | 118 | } |
125 | } | 119 | } |
126 | } | 120 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs index 722c5dd..7de37e4 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsVector.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsVector.cs | |||
@@ -35,7 +35,6 @@ namespace OpenSim.Region.Physics.Manager | |||
35 | 35 | ||
36 | public PhysicsVector() | 36 | public PhysicsVector() |
37 | { | 37 | { |
38 | |||
39 | } | 38 | } |
40 | 39 | ||
41 | public PhysicsVector(float x, float y, float z) | 40 | public PhysicsVector(float x, float y, float z) |
@@ -49,7 +48,7 @@ namespace OpenSim.Region.Physics.Manager | |||
49 | 48 | ||
50 | public override string ToString() | 49 | public override string ToString() |
51 | { | 50 | { |
52 | return "<" + this.X + "," + this.Y + "," + this.Z + ">"; | 51 | return "<" + X + "," + Y + "," + Z + ">"; |
53 | } | 52 | } |
54 | } | 53 | } |
55 | } | 54 | } \ No newline at end of file |