aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2013-08-09 10:59:10 -0700
committerRobert Adams2013-09-11 09:11:52 -0700
commit455d36c4c70a55c5d48dc1410b8729929fafedf6 (patch)
tree2dad264f9a7c319cba213cfe486b38c6b0dca182 /OpenSim
parentBulletSim: update C++ HACD parameters to values that handle enclosed hollow s... (diff)
downloadopensim-SC-455d36c4c70a55c5d48dc1410b8729929fafedf6.zip
opensim-SC-455d36c4c70a55c5d48dc1410b8729929fafedf6.tar.gz
opensim-SC-455d36c4c70a55c5d48dc1410b8729929fafedf6.tar.bz2
opensim-SC-455d36c4c70a55c5d48dc1410b8729929fafedf6.tar.xz
BulletSim: add physChangeLinkParams to set individual parameters on link constraints. Not fully functional. Remove double definition of ExtendedPhysics parameters by having BulletSim reference the optional module (addition to prebuild.xml and usings).
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs265
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs54
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs55
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs85
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs18
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs14
6 files changed, 324 insertions, 167 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
index 278e9e7..baf5a5b 100755
--- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
@@ -36,6 +36,7 @@ using OpenSim.Region.CoreModules;
36using OpenSim.Region.Framework; 36using OpenSim.Region.Framework;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Physics.Manager;
39 40
40using Mono.Addins; 41using Mono.Addins;
41using Nini.Config; 42using Nini.Config;
@@ -62,9 +63,8 @@ public class ExtendedPhysics : INonSharedRegionModule
62 public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; 63 public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType";
63 public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; 64 public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType";
64 public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; 65 public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed";
65 public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge"; 66 public const string PhysFunctChangeLinkType = "BulletSim.ChangeLinkType";
66 public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring"; 67 public const string PhysFunctChangeLinkParams = "BulletSim.ChangeLinkParams";
67 public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider";
68 68
69 // ============================================================= 69 // =============================================================
70 70
@@ -200,7 +200,7 @@ public class ExtendedPhysics : INonSharedRegionModule
200 200
201 if (rootPart != null) 201 if (rootPart != null)
202 { 202 {
203 Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; 203 PhysicsActor rootPhysActor = rootPart.PhysActor;
204 if (rootPhysActor != null) 204 if (rootPhysActor != null)
205 { 205 {
206 if (rootPhysActor.IsPhysical) 206 if (rootPhysActor.IsPhysical)
@@ -219,7 +219,7 @@ public class ExtendedPhysics : INonSharedRegionModule
219 containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition); 219 containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition);
220 containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation); 220 containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation);
221 221
222 ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); 222 ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType));
223 Thread.Sleep(150); // longer than one heartbeat tick 223 Thread.Sleep(150); // longer than one heartbeat tick
224 224
225 containingGroup.ScriptSetPhysicsStatus(true); 225 containingGroup.ScriptSetPhysicsStatus(true);
@@ -228,7 +228,7 @@ public class ExtendedPhysics : INonSharedRegionModule
228 { 228 {
229 // Non-physical linksets don't have a physical instantiation so there is no state to 229 // Non-physical linksets don't have a physical instantiation so there is no state to
230 // worry about being updated. 230 // worry about being updated.
231 ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); 231 ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType));
232 } 232 }
233 } 233 }
234 else 234 else
@@ -267,10 +267,10 @@ public class ExtendedPhysics : INonSharedRegionModule
267 267
268 if (rootPart != null) 268 if (rootPart != null)
269 { 269 {
270 Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; 270 PhysicsActor rootPhysActor = rootPart.PhysActor;
271 if (rootPhysActor != null) 271 if (rootPhysActor != null)
272 { 272 {
273 ret = (int)rootPhysActor.Extension(PhysFunctGetLinksetType); 273 ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType));
274 } 274 }
275 else 275 else
276 { 276 {
@@ -291,148 +291,225 @@ public class ExtendedPhysics : INonSharedRegionModule
291 return ret; 291 return ret;
292 } 292 }
293 293
294 [ScriptConstant]
295 public static int PHYS_LINK_TYPE_FIXED = 1234;
296 [ScriptConstant]
297 public static int PHYS_LINK_TYPE_HINGE = 4;
298 [ScriptConstant]
299 public static int PHYS_LINK_TYPE_SPRING = 9;
300 [ScriptConstant]
301 public static int PHYS_LINK_TYPE_6DOF = 6;
302 [ScriptConstant]
303 public static int PHYS_LINK_TYPE_SLIDER = 7;
304
305 // physChangeLinkType(integer linkNum, integer typeCode)
306 [ScriptInvocation]
307 public int physChangeLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode)
308 {
309 int ret = -1;
310 if (!Enabled) return ret;
311
312 PhysicsActor rootPhysActor;
313 PhysicsActor childPhysActor;
314
315 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
316 {
317 ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, typeCode));
318 }
319
320 return ret;
321 }
322
294 // physChangeLinkFixed(integer linkNum) 323 // physChangeLinkFixed(integer linkNum)
295 // Change the link between the root and the linkNum into a fixed, static physical connection. 324 // Change the link between the root and the linkNum into a fixed, static physical connection.
296 // This needs to change 'linkNum' into the physical object because lower level code has
297 // no access to the link numbers.
298 [ScriptInvocation] 325 [ScriptInvocation]
299 public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum) 326 public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum)
300 { 327 {
301 int ret = -1; 328 int ret = -1;
302 if (!Enabled) return ret; 329 if (!Enabled) return ret;
303 330
304 // The part that is requesting the change. 331 PhysicsActor rootPhysActor;
305 SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); 332 PhysicsActor childPhysActor;
333
334 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
335 {
336 ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, PHYS_LINK_TYPE_FIXED));
337 }
338
339 return ret;
340 }
341
342 // Code for specifying params.
343 // The choice if 14400 is arbitrary and only serves to catch parameter code misuse.
344 public static int PHYS_PARAM_MIN = 14401;
345 [ScriptConstant]
346 public static int PHYS_PARAM_FRAMEINA_LOC = 14401;
347 [ScriptConstant]
348 public static int PHYS_PARAM_FRAMEINA_ROT = 14402;
349 [ScriptConstant]
350 public static int PHYS_PARAM_FRAMEINB_LOC = 14403;
351 [ScriptConstant]
352 public static int PHYS_PARAM_FRAMEINB_ROT = 14404;
353 [ScriptConstant]
354 public static int PHYS_PARAM_LINEAR_LIMIT_LOW = 14405;
355 [ScriptConstant]
356 public static int PHYS_PARAM_LINEAR_LIMIT_HIGH = 14406;
357 [ScriptConstant]
358 public static int PHYS_PARAM_ANGULAR_LIMIT_LOW = 14407;
359 [ScriptConstant]
360 public static int PHYS_PARAM_ANGULAR_LIMIT_HIGH = 14408;
361 [ScriptConstant]
362 public static int PHYS_PARAM_USE_FRAME_OFFSET = 14409;
363 [ScriptConstant]
364 public static int PHYS_PARAM_ENABLE_TRANSMOTOR = 14410;
365 [ScriptConstant]
366 public static int PHYS_PARAM_TRANSMOTOR_MAXVEL = 14411;
367 [ScriptConstant]
368 public static int PHYS_PARAM_TRANSMOTOR_MAXFORCE = 14412;
369 [ScriptConstant]
370 public static int PHYS_PARAM_CFM = 14413;
371 [ScriptConstant]
372 public static int PHYS_PARAM_ERP = 14414;
373 [ScriptConstant]
374 public static int PHYS_PARAM_SOLVER_ITERATIONS = 14415;
375 [ScriptConstant]
376 public static int PHYS_PARAM_SPRING_DAMPING = 14416;
377 [ScriptConstant]
378 public static int PHYS_PARAM_SPRING_STIFFNESS = 14417;
379 public static int PHYS_PARAM_MAX = 14417;
306 380
381 // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...])
382 [ScriptInvocation]
383 public int physChangeLinkParams(UUID hostID, UUID scriptID, int linkNum, object[] parms)
384 {
385 int ret = -1;
386 if (!Enabled) return ret;
387
388 PhysicsActor rootPhysActor;
389 PhysicsActor childPhysActor;
390
391 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
392 {
393 ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, childPhysActor, parms));
394 }
395
396 return ret;
397 }
398
399 private bool GetRootPhysActor(UUID hostID, out PhysicsActor rootPhysActor)
400 {
401 SceneObjectGroup containingGroup;
402 SceneObjectPart rootPart;
403 return GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor);
404 }
405
406 private bool GetRootPhysActor(UUID hostID, out SceneObjectGroup containingGroup, out SceneObjectPart rootPart, out PhysicsActor rootPhysActor)
407 {
408 bool ret = false;
409 rootPhysActor = null;
410 containingGroup = null;
411 rootPart = null;
412
413 SceneObjectPart requestingPart;
414
415 requestingPart = BaseScene.GetSceneObjectPart(hostID);
307 if (requestingPart != null) 416 if (requestingPart != null)
308 { 417 {
309 // The type is is always on the root of a linkset. 418 // The type is is always on the root of a linkset.
310 SceneObjectGroup containingGroup = requestingPart.ParentGroup; 419 containingGroup = requestingPart.ParentGroup;
311 SceneObjectPart rootPart = containingGroup.RootPart; 420 if (containingGroup != null && !containingGroup.IsDeleted)
312
313 if (rootPart != null)
314 { 421 {
315 Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; 422 rootPart = containingGroup.RootPart;
316 if (rootPhysActor != null) 423 if (rootPart != null)
317 { 424 {
318 SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); 425 rootPhysActor = rootPart.PhysActor;
319 if (linkPart != null) 426 if (rootPhysActor != null)
320 { 427 {
321 Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor; 428 ret = true;
322 if (linkPhysActor != null)
323 {
324 ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkFixed, linkNum, linkPhysActor);
325 }
326 else
327 {
328 m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}",
329 LogHeader, rootPart.Name, hostID, linkNum);
330 }
331 } 429 }
332 else 430 else
333 { 431 {
334 m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", 432 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}",
335 LogHeader, rootPart.Name, hostID, linkNum); 433 LogHeader, rootPart.Name, hostID);
336 } 434 }
337 } 435 }
338 else 436 else
339 { 437 {
340 m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}", 438 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not exist. RequestingPartName={1}, hostID={2}",
341 LogHeader, rootPart.Name, hostID); 439 LogHeader, requestingPart.Name, hostID);
342 } 440 }
343 } 441 }
344 else 442 else
345 { 443 {
346 m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}", 444 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Containing group missing or deleted. hostID={1}", LogHeader, hostID);
347 LogHeader, requestingPart.Name, hostID);
348 } 445 }
349 } 446 }
350 else 447 else
351 { 448 {
352 m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); 449 m_log.WarnFormat("{0} GetRootAndChildPhysActors: cannot find script object in scene. hostID={1}", LogHeader, hostID);
353 } 450 }
451
354 return ret; 452 return ret;
355 } 453 }
356 454
357 [ScriptInvocation] 455 // Find the root and child PhysActors based on the linkNum.
358 public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum) 456 // Return 'true' if both are found and returned.
457 private bool GetRootAndChildPhysActors(UUID hostID, int linkNum, out PhysicsActor rootPhysActor, out PhysicsActor childPhysActor)
359 { 458 {
360 return -1; 459 bool ret = false;
361 } 460 rootPhysActor = null;
461 childPhysActor = null;
362 462
363 [ScriptInvocation] 463 SceneObjectGroup containingGroup;
364 public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum, 464 SceneObjectPart rootPart;
365 Vector3 frameInAloc, Quaternion frameInArot,
366 Vector3 frameInBloc, Quaternion frameInBrot,
367 Vector3 linearLimitLow, Vector3 linearLimitHigh,
368 Vector3 angularLimitLow, Vector3 angularLimitHigh
369 )
370 {
371 int ret = -1;
372 if (!Enabled) return ret;
373 465
374 // The part that is requesting the change. 466 if (GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor))
375 SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID);
376
377 if (requestingPart != null)
378 { 467 {
379 // The type is is always on the root of a linkset. 468 SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum);
380 SceneObjectGroup containingGroup = requestingPart.ParentGroup; 469 if (linkPart != null)
381 SceneObjectPart rootPart = containingGroup.RootPart;
382
383 if (rootPart != null)
384 { 470 {
385 Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; 471 childPhysActor = linkPart.PhysActor;
386 if (rootPhysActor != null) 472 if (childPhysActor != null)
387 { 473 {
388 SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); 474 ret = true;
389 if (linkPart != null)
390 {
391 Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor;
392 if (linkPhysActor != null)
393 {
394 ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkSpring, linkNum, linkPhysActor,
395 frameInAloc, frameInArot,
396 frameInBloc, frameInBrot,
397 linearLimitLow, linearLimitHigh,
398 angularLimitLow, angularLimitHigh
399 );
400 }
401 else
402 {
403 m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}",
404 LogHeader, rootPart.Name, hostID, linkNum);
405 }
406 }
407 else
408 {
409 m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}",
410 LogHeader, rootPart.Name, hostID, linkNum);
411 }
412 } 475 }
413 else 476 else
414 { 477 {
415 m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}", 478 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}",
416 LogHeader, rootPart.Name, hostID); 479 LogHeader, rootPart.Name, hostID, linkNum);
417 } 480 }
418 } 481 }
419 else 482 else
420 { 483 {
421 m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}", 484 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}",
422 LogHeader, requestingPart.Name, hostID); 485 LogHeader, rootPart.Name, hostID, linkNum);
423 } 486 }
424 } 487 }
425 else 488 else
426 { 489 {
427 m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); 490 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}",
491 LogHeader, rootPart.Name, hostID);
428 } 492 }
493
429 return ret; 494 return ret;
430 } 495 }
431 496
432 [ScriptInvocation] 497 // Extension() returns an object. Convert that object into the integer error we expect to return.
433 public int physChangeLinkSlider(UUID hostID, UUID scriptID, int linkNum) 498 private int MakeIntError(object extensionRet)
434 { 499 {
435 return 0; 500 int ret = -1;
501 if (extensionRet != null)
502 {
503 try
504 {
505 ret = (int)extensionRet;
506 }
507 catch
508 {
509 ret = -1;
510 }
511 }
512 return ret;
436 } 513 }
437} 514}
438} 515}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs
new file mode 100755
index 0000000..7a76a9a
--- /dev/null
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs
@@ -0,0 +1,54 @@
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;
30using OpenMetaverse;
31
32namespace OpenSim.Region.Physics.BulletSPlugin
33{
34
35public sealed class BSConstraintConeTwist : BSConstraint
36{
37 public override ConstraintType Type { get { return ConstraintType.CONETWIST_CONSTRAINT_TYPE; } }
38
39 public BSConstraintConeTwist(BulletWorld world, BulletBody obj1, BulletBody obj2,
40 Vector3 frameInAloc, Quaternion frameInArot,
41 Vector3 frameInBloc, Quaternion frameInBrot,
42 bool disableCollisionsBetweenLinkedBodies)
43 : base(world)
44 {
45 m_body1 = obj1;
46 m_body2 = obj2;
47 m_constraint = PhysicsScene.PE.CreateConeTwistConstraint(world, obj1, obj2,
48 frameInAloc, frameInArot, frameInBloc, frameInBrot,
49 disableCollisionsBetweenLinkedBodies);
50 m_enabled = true;
51 }
52}
53
54}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs
new file mode 100755
index 0000000..37cfa07
--- /dev/null
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs
@@ -0,0 +1,55 @@
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;
30using OpenMetaverse;
31
32namespace OpenSim.Region.Physics.BulletSPlugin
33{
34
35public sealed class BSConstraintSlider : BSConstraint
36{
37 public override ConstraintType Type { get { return ConstraintType.SLIDER_CONSTRAINT_TYPE; } }
38
39 public BSConstraintSlider(BulletWorld world, BulletBody obj1, BulletBody obj2,
40 Vector3 frameInAloc, Quaternion frameInArot,
41 Vector3 frameInBloc, Quaternion frameInBrot,
42 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
43 : base(world)
44 {
45 m_body1 = obj1;
46 m_body2 = obj2;
47 m_constraint = PhysicsScene.PE.CreateSliderConstraint(world, obj1, obj2,
48 frameInAloc, frameInArot, frameInBloc, frameInBrot,
49 useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
50 m_enabled = true;
51 }
52
53}
54
55}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
index 17fec9d..c09dd42 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
@@ -28,6 +28,8 @@ using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Text; 29using System.Text;
30 30
31using OpenSim.Region.OptionalModules.Scripting;
32
31using OMV = OpenMetaverse; 33using OMV = OpenMetaverse;
32 34
33namespace OpenSim.Region.Physics.BulletSPlugin 35namespace OpenSim.Region.Physics.BulletSPlugin
@@ -489,71 +491,46 @@ public sealed class BSLinksetConstraints : BSLinkset
489 switch (pFunct) 491 switch (pFunct)
490 { 492 {
491 // pParams = (int linkNUm, PhysActor linkChild) 493 // pParams = (int linkNUm, PhysActor linkChild)
492 case BSScene.PhysFunctChangeLinkFixed: 494 case ExtendedPhysics.PhysFunctChangeLinkType:
493 if (pParams.Length > 1) 495 if (pParams.Length > 1)
494 { 496 {
495 BSPrimLinkable child = pParams[1] as BSPrimLinkable; 497 int requestedType = (int)pParams[1];
496 if (child != null) 498 if (requestedType == (int)ConstraintType.FIXED_CONSTRAINT_TYPE
499 || requestedType == (int)ConstraintType.D6_CONSTRAINT_TYPE
500 || requestedType == (int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE
501 || requestedType == (int)ConstraintType.HINGE_CONSTRAINT_TYPE
502 || requestedType == (int)ConstraintType.CONETWIST_CONSTRAINT_TYPE
503 || requestedType == (int)ConstraintType.SLIDER_CONSTRAINT_TYPE)
497 { 504 {
498 m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() 505 BSPrimLinkable child = pParams[0] as BSPrimLinkable;
506 if (child != null)
499 { 507 {
500 // Pick up all the constraints currently created. 508 m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate()
501 RemoveDependencies(child);
502
503 BSLinkInfo linkInfo = null;
504 if (m_children.TryGetValue(child, out linkInfo))
505 { 509 {
506 BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; 510 // Pick up all the constraints currently created.
507 if (linkInfoC != null) 511 RemoveDependencies(child);
508 {
509 // Setting to fixed is easy. The reset state is the fixed link configuration.
510 linkInfoC.ResetLink();
511 ret = (object)true;
512 }
513 }
514 // Cause the whole linkset to be rebuilt in post-taint time.
515 Refresh(child);
516 });
517 }
518 }
519 break;
520 case BSScene.PhysFunctChangeLinkSpring:
521 if (pParams.Length > 11)
522 {
523 BSPrimLinkable child = pParams[1] as BSPrimLinkable;
524 if (child != null)
525 {
526 m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate()
527 {
528 // Pick up all the constraints currently created.
529 RemoveDependencies(child);
530 512
531 BSLinkInfo linkInfo = null; 513 BSLinkInfo linkInfo = null;
532 if (m_children.TryGetValue(child, out linkInfo)) 514 if (m_children.TryGetValue(child, out linkInfo))
533 {
534 BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint;
535 if (linkInfoC != null)
536 { 515 {
537 // Start with a reset link definition 516 BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint;
538 linkInfoC.ResetLink(); 517 if (linkInfoC != null)
539 linkInfoC.constraintType = ConstraintType.D6_SPRING_CONSTRAINT_TYPE; 518 {
540 linkInfoC.frameInAloc = (OMV.Vector3)pParams[2]; 519 // Setting to fixed is easy. The reset state is the fixed link configuration.
541 linkInfoC.frameInArot = (OMV.Quaternion)pParams[3]; 520 linkInfoC.ResetLink();
542 linkInfoC.frameInBloc = (OMV.Vector3)pParams[4]; 521 linkInfoC.constraintType = (ConstraintType)requestedType;
543 linkInfoC.frameInBrot = (OMV.Quaternion)pParams[5]; 522 ret = (object)true;
544 linkInfoC.linearLimitLow = (OMV.Vector3)pParams[6]; 523 }
545 linkInfoC.linearLimitHigh = (OMV.Vector3)pParams[7];
546 linkInfoC.angularLimitLow = (OMV.Vector3)pParams[8];
547 linkInfoC.angularLimitHigh = (OMV.Vector3)pParams[9];
548 ret = (object)true;
549 } 524 }
550 } 525 // Cause the whole linkset to be rebuilt in post-taint time.
551 // Cause the whole linkset to be rebuilt in post-taint time. 526 Refresh(child);
552 Refresh(child); 527 });
553 }); 528 }
554 } 529 }
555 } 530 }
556 break; 531 break;
532 case ExtendedPhysics.PhysFunctChangeLinkParams:
533 break;
557 default: 534 default:
558 ret = base.Extension(pFunct, pParams); 535 ret = base.Extension(pFunct, pParams);
559 break; 536 break;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
index 4c384a6..6136257 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
@@ -30,6 +30,7 @@ using System.Linq;
30using System.Text; 30using System.Text;
31 31
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.OptionalModules.Scripting;
33 34
34using OMV = OpenMetaverse; 35using OMV = OpenMetaverse;
35 36
@@ -286,14 +287,14 @@ public class BSPrimLinkable : BSPrimDisplaced
286 switch (pFunct) 287 switch (pFunct)
287 { 288 {
288 // physGetLinksetType(); 289 // physGetLinksetType();
289 case BSScene.PhysFunctGetLinksetType: 290 case ExtendedPhysics.PhysFunctGetLinksetType:
290 { 291 {
291 ret = (object)LinksetType; 292 ret = (object)LinksetType;
292 m_log.DebugFormat("{0} Extension.physGetLinksetType, type={1}", LogHeader, ret); 293 m_log.DebugFormat("{0} Extension.physGetLinksetType, type={1}", LogHeader, ret);
293 break; 294 break;
294 } 295 }
295 // physSetLinksetType(type); 296 // physSetLinksetType(type);
296 case BSScene.PhysFunctSetLinksetType: 297 case ExtendedPhysics.PhysFunctSetLinksetType:
297 { 298 {
298 if (pParams.Length > 0) 299 if (pParams.Length > 0)
299 { 300 {
@@ -312,9 +313,16 @@ public class BSPrimLinkable : BSPrimDisplaced
312 } 313 }
313 break; 314 break;
314 } 315 }
315 // physChangeLinkFixed(linknum); 316 // physChangeLinkType(linknum, typeCode);
316 // Params: int linkNum, PhysActor linkedPrim 317 // Params: PhysActor linkedPrim, int typeCode
317 case BSScene.PhysFunctChangeLinkFixed: 318 case ExtendedPhysics.PhysFunctChangeLinkType:
319 {
320 Linkset.Extension(pFunct, pParams);
321 break;
322 }
323 // physChangeLinkParams(linknum, [code, value, code, value, ...]);
324 // Params: PhysActor linkedPrim, object[] params
325 case ExtendedPhysics.PhysFunctChangeLinkParams:
318 { 326 {
319 Linkset.Extension(pFunct, pParams); 327 Linkset.Extension(pFunct, pParams);
320 break; 328 break;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 571db86..7440468 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -867,20 +867,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
867 public override bool IsThreaded { get { return false; } } 867 public override bool IsThreaded { get { return false; } }
868 868
869 #region Extensions 869 #region Extensions
870 // =============================================================
871 // Per scene functions. See below.
872
873 // Per avatar functions. See BSCharacter.
874
875 // Per prim functions. See BSPrim.
876 public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType";
877 public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType";
878 public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed";
879 public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge";
880 public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring";
881 public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider";
882 // =============================================================
883
884 public override object Extension(string pFunct, params object[] pParams) 870 public override object Extension(string pFunct, params object[] pParams)
885 { 871 {
886 return base.Extension(pFunct, pParams); 872 return base.Extension(pFunct, pParams);