diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs')
-rwxr-xr-x | OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs | 113 |
1 files changed, 103 insertions, 10 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 6009dc5..d1d318c 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs | |||
@@ -31,10 +31,10 @@ using System.Reflection; | |||
31 | using System.Text; | 31 | using System.Text; |
32 | 32 | ||
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Region.CoreModules; | ||
34 | using OpenSim.Region.Framework; | 35 | using OpenSim.Region.Framework; |
35 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Region.CoreModules; | ||
38 | 38 | ||
39 | using Mono.Addins; | 39 | using Mono.Addins; |
40 | using Nini.Config; | 40 | using Nini.Config; |
@@ -49,6 +49,20 @@ public class ExtendedPhysics : INonSharedRegionModule | |||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | private static string LogHeader = "[EXTENDED PHYSICS]"; | 50 | private static string LogHeader = "[EXTENDED PHYSICS]"; |
51 | 51 | ||
52 | // ============================================================= | ||
53 | // Since BulletSim is a plugin, this these values aren't defined easily in one place. | ||
54 | // This table must correspond to an identical table in BSScene. | ||
55 | |||
56 | // Per scene functions. See BSScene. | ||
57 | |||
58 | // Per avatar functions. See BSCharacter. | ||
59 | |||
60 | // Per prim functions. See BSPrim. | ||
61 | public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; | ||
62 | public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; | ||
63 | |||
64 | // ============================================================= | ||
65 | |||
52 | private IConfig Configuration { get; set; } | 66 | private IConfig Configuration { get; set; } |
53 | private bool Enabled { get; set; } | 67 | private bool Enabled { get; set; } |
54 | private Scene BaseScene { get; set; } | 68 | private Scene BaseScene { get; set; } |
@@ -119,6 +133,7 @@ public class ExtendedPhysics : INonSharedRegionModule | |||
119 | 133 | ||
120 | // Register as LSL functions all the [ScriptInvocation] marked methods. | 134 | // Register as LSL functions all the [ScriptInvocation] marked methods. |
121 | Comms.RegisterScriptInvocations(this); | 135 | Comms.RegisterScriptInvocations(this); |
136 | Comms.RegisterConstants(this); | ||
122 | 137 | ||
123 | // When an object is modified, we might need to update its extended physics parameters | 138 | // When an object is modified, we might need to update its extended physics parameters |
124 | BaseScene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; | 139 | BaseScene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; |
@@ -132,7 +147,6 @@ public class ExtendedPhysics : INonSharedRegionModule | |||
132 | 147 | ||
133 | private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) | 148 | private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) |
134 | { | 149 | { |
135 | throw new NotImplementedException(); | ||
136 | } | 150 | } |
137 | 151 | ||
138 | // Event generated when some property of a prim changes. | 152 | // Event generated when some property of a prim changes. |
@@ -143,13 +157,6 @@ public class ExtendedPhysics : INonSharedRegionModule | |||
143 | [ScriptConstant] | 157 | [ScriptConstant] |
144 | public static int PHYS_CENTER_OF_MASS = 1 << 0; | 158 | public static int PHYS_CENTER_OF_MASS = 1 << 0; |
145 | 159 | ||
146 | [ScriptConstant] | ||
147 | public static int PHYS_LINKSET_TYPE_CONSTRAINT = 1; | ||
148 | [ScriptConstant] | ||
149 | public static int PHYS_LINKSET_TYPE_COMPOUND = 2; | ||
150 | [ScriptConstant] | ||
151 | public static int PHYS_LINKSET_TYPE_MANUAL = 3; | ||
152 | |||
153 | [ScriptInvocation] | 160 | [ScriptInvocation] |
154 | public string physGetEngineType(UUID hostID, UUID scriptID) | 161 | public string physGetEngineType(UUID hostID, UUID scriptID) |
155 | { | 162 | { |
@@ -163,9 +170,95 @@ public class ExtendedPhysics : INonSharedRegionModule | |||
163 | return ret; | 170 | return ret; |
164 | } | 171 | } |
165 | 172 | ||
173 | [ScriptConstant] | ||
174 | public static int PHYS_LINKSET_TYPE_CONSTRAINT = 0; | ||
175 | [ScriptConstant] | ||
176 | public static int PHYS_LINKSET_TYPE_COMPOUND = 1; | ||
177 | [ScriptConstant] | ||
178 | public static int PHYS_LINKSET_TYPE_MANUAL = 2; | ||
179 | |||
166 | [ScriptInvocation] | 180 | [ScriptInvocation] |
167 | public void physSetLinksetType(UUID hostID, UUID scriptID, int linksetType) | 181 | public int physSetLinksetType(UUID hostID, UUID scriptID, int linksetType) |
168 | { | 182 | { |
183 | int ret = -1; | ||
184 | |||
185 | if (!Enabled) return ret; | ||
186 | |||
187 | // The part that is requesting the change. | ||
188 | SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); | ||
189 | |||
190 | if (requestingPart != null) | ||
191 | { | ||
192 | // The change is always made to the root of a linkset. | ||
193 | SceneObjectGroup containingGroup = requestingPart.ParentGroup; | ||
194 | SceneObjectPart rootPart = containingGroup.RootPart; | ||
195 | |||
196 | if (rootPart != null) | ||
197 | { | ||
198 | Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; | ||
199 | if (rootPhysActor != null) | ||
200 | { | ||
201 | ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); | ||
202 | } | ||
203 | else | ||
204 | { | ||
205 | m_log.WarnFormat("{0} physSetLinksetType: root part does not have a physics actor. rootName={1}, hostID={2}", | ||
206 | LogHeader, rootPart.Name, hostID); | ||
207 | } | ||
208 | } | ||
209 | else | ||
210 | { | ||
211 | m_log.WarnFormat("{0} physSetLinksetType: root part does not exist. RequestingPartName={1}, hostID={2}", | ||
212 | LogHeader, requestingPart.Name, hostID); | ||
213 | } | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | m_log.WarnFormat("{0} physSetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); | ||
218 | } | ||
219 | return ret; | ||
220 | } | ||
221 | |||
222 | [ScriptInvocation] | ||
223 | public int physGetLinksetType(UUID hostID, UUID scriptID) | ||
224 | { | ||
225 | int ret = -1; | ||
226 | |||
227 | if (!Enabled) return ret; | ||
228 | |||
229 | // The part that is requesting the change. | ||
230 | SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); | ||
231 | |||
232 | if (requestingPart != null) | ||
233 | { | ||
234 | // The type is is always on the root of a linkset. | ||
235 | SceneObjectGroup containingGroup = requestingPart.ParentGroup; | ||
236 | SceneObjectPart rootPart = containingGroup.RootPart; | ||
237 | |||
238 | if (rootPart != null) | ||
239 | { | ||
240 | Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; | ||
241 | if (rootPhysActor != null) | ||
242 | { | ||
243 | ret = (int)rootPhysActor.Extension(PhysFunctGetLinksetType); | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | m_log.WarnFormat("{0} physGetLinksetType: root part does not have a physics actor. rootName={1}, hostID={2}", | ||
248 | LogHeader, rootPart.Name, hostID); | ||
249 | } | ||
250 | } | ||
251 | else | ||
252 | { | ||
253 | m_log.WarnFormat("{0} physGetLinksetType: root part does not exist. RequestingPartName={1}, hostID={2}", | ||
254 | LogHeader, requestingPart.Name, hostID); | ||
255 | } | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); | ||
260 | } | ||
261 | return ret; | ||
169 | } | 262 | } |
170 | } | 263 | } |
171 | } | 264 | } |