diff options
author | Robert Adams | 2013-02-07 21:57:46 -0800 |
---|---|---|
committer | Robert Adams | 2013-02-08 16:29:35 -0800 |
commit | d92eb803734956c1e0b260eb7740910e1fa3b891 (patch) | |
tree | b0a309c81b4a4f62e8ae369a306ab8ba1694d089 /OpenSim/Region/OptionalModules/Scripting | |
parent | BulletSim: include the linkage to the layered prim implementation. Separate l... (diff) | |
download | opensim-SC_OLD-d92eb803734956c1e0b260eb7740910e1fa3b891.zip opensim-SC_OLD-d92eb803734956c1e0b260eb7740910e1fa3b891.tar.gz opensim-SC_OLD-d92eb803734956c1e0b260eb7740910e1fa3b891.tar.bz2 opensim-SC_OLD-d92eb803734956c1e0b260eb7740910e1fa3b891.tar.xz |
BulletSim: add initial instance of the ExtendedPhysics region module which adds new LSL commands for extended physics functions. Uses the modInvoke system. Disabled by default.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting')
-rwxr-xr-x | OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs new file mode 100755 index 0000000..aaa349f --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs | |||
@@ -0,0 +1,163 @@ | |||
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Linq; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | |||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | using OpenSim.Region.CoreModules; | ||
38 | |||
39 | using Mono.Addins; | ||
40 | using Nini.Config; | ||
41 | using log4net; | ||
42 | using OpenMetaverse; | ||
43 | |||
44 | namespace OpenSim.Region.OptionalModules.Scripting | ||
45 | { | ||
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
47 | public class ExtendedPhysics : INonSharedRegionModule | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | private static string LogHeader = "[EXTENDED PHYSICS]"; | ||
51 | |||
52 | private IConfig Configuration { get; set; } | ||
53 | private bool Enabled { get; set; } | ||
54 | private Scene BaseScene { get; set; } | ||
55 | private IScriptModuleComms Comms { get; set; } | ||
56 | |||
57 | #region INonSharedRegionModule | ||
58 | |||
59 | public string Name { get { return this.GetType().Name; } } | ||
60 | |||
61 | public void Initialise(IConfigSource config) | ||
62 | { | ||
63 | BaseScene = null; | ||
64 | Enabled = false; | ||
65 | Configuration = null; | ||
66 | Comms = null; | ||
67 | |||
68 | try | ||
69 | { | ||
70 | if ((Configuration = config.Configs["ExtendedPhysics"]) != null) | ||
71 | { | ||
72 | Enabled = Configuration.GetBoolean("Enabled", Enabled); | ||
73 | } | ||
74 | } | ||
75 | catch (Exception e) | ||
76 | { | ||
77 | m_log.ErrorFormat("{0} Initialization error: {0}", LogHeader, e); | ||
78 | } | ||
79 | |||
80 | m_log.ErrorFormat("{0} module {1} enabled", LogHeader, (Enabled ? "is" : "is not")); | ||
81 | } | ||
82 | |||
83 | public void Close() | ||
84 | { | ||
85 | if (BaseScene != null) | ||
86 | { | ||
87 | BaseScene.EventManager.OnSceneObjectPartUpdated -= EventManager_OnSceneObjectPartUpdated; | ||
88 | BaseScene = null; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | public void AddRegion(Scene scene) | ||
93 | { | ||
94 | } | ||
95 | |||
96 | public void RemoveRegion(Scene scene) | ||
97 | { | ||
98 | if (BaseScene != null && BaseScene == scene) | ||
99 | { | ||
100 | Close(); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | public void RegionLoaded(Scene scene) | ||
105 | { | ||
106 | if (!Enabled) return; | ||
107 | |||
108 | BaseScene = scene; | ||
109 | |||
110 | Comms = BaseScene.RequestModuleInterface<IScriptModuleComms>(); | ||
111 | if (Comms == null) | ||
112 | { | ||
113 | m_log.WarnFormat("{0} ScriptModuleComms interface not defined", LogHeader); | ||
114 | Enabled = false; | ||
115 | |||
116 | return; | ||
117 | } | ||
118 | |||
119 | // Register as LSL functions all the [ScriptInvocation] marked methods. | ||
120 | Comms.RegisterScriptInvocations(this); | ||
121 | |||
122 | // When an object is modified, we might need to update its extended physics parameters | ||
123 | BaseScene.EventManager.OnSceneObjectPartUpdated += EventManager_OnSceneObjectPartUpdated; | ||
124 | } | ||
125 | |||
126 | public Type ReplaceableInterface { get { return null; } } | ||
127 | |||
128 | #endregion // INonSharedRegionModule | ||
129 | |||
130 | // Event generated when some property of a prim changes. | ||
131 | private void EventManager_OnSceneObjectPartUpdated(SceneObjectPart sop, bool isFullUpdate) | ||
132 | { | ||
133 | } | ||
134 | |||
135 | [ScriptConstant] | ||
136 | public static int PHYS_CENTER_OF_MASS = 1 << 0; | ||
137 | |||
138 | [ScriptConstant] | ||
139 | public static int PHYS_LINKSET_TYPE_CONSTRAINT = 1; | ||
140 | [ScriptConstant] | ||
141 | public static int PHYS_LINKSET_TYPE_COMPOUND = 2; | ||
142 | [ScriptConstant] | ||
143 | public static int PHYS_LINKSET_TYPE_MANUAL = 3; | ||
144 | |||
145 | [ScriptInvocation] | ||
146 | public string physGetEngineType(UUID hostID, UUID scriptID) | ||
147 | { | ||
148 | string ret = string.Empty; | ||
149 | |||
150 | if (BaseScene.PhysicsScene != null) | ||
151 | { | ||
152 | ret = BaseScene.PhysicsScene.EngineType; | ||
153 | } | ||
154 | |||
155 | return ret; | ||
156 | } | ||
157 | |||
158 | [ScriptInvocation] | ||
159 | public void physSetLinksetType(UUID hostID, UUID scriptID, int linksetType) | ||
160 | { | ||
161 | } | ||
162 | } | ||
163 | } | ||