aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorRobert Adams2015-09-08 04:54:16 -0700
committerRobert Adams2015-09-08 04:54:16 -0700
commite5367d822be9b05e74c859afe2d2956a3e95aa33 (patch)
treee904050a30715df587aa527d7f313755177726a7 /OpenSim/Region/Physics
parentadd lost admin_reset_land method (diff)
parentDeleted access control spec from [LoginService] section of standalone config.... (diff)
downloadopensim-SC-e5367d822be9b05e74c859afe2d2956a3e95aa33.zip
opensim-SC-e5367d822be9b05e74c859afe2d2956a3e95aa33.tar.gz
opensim-SC-e5367d822be9b05e74c859afe2d2956a3e95aa33.tar.bz2
opensim-SC-e5367d822be9b05e74c859afe2d2956a3e95aa33.tar.xz
Merge of ubitworkvarnew with opensim/master as of 20150905.
This integrates the OpenSim refactoring to make physics, etc into modules. AVN physics hasn't been moved to new location. Does not compile yet. Merge branch 'osmaster' into mbworknew1
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs64
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPlugin.cs76
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs1283
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs250
-rw-r--r--OpenSim/Region/Physics/Meshing/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs90
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSPlugin.cs64
-rw-r--r--OpenSim/Region/PhysicsModules/BasicPhysics/AssemblyInfo.cs (renamed from OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs)8
-rw-r--r--OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsActor.cs (renamed from OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs)4
-rw-r--r--OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPrim.cs (renamed from OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs)4
-rw-r--r--OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs (renamed from OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs)72
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSAPIUnman.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSAPIXNA.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs)4
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSActorHover.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSActorHover.cs)4
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSActorLockAxis.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSActorLockAxis.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSActorMoveToTarget.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs)4
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSActorSetForce.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSActorSetForce.cs)4
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSActorSetTorque.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSActorSetTorque.cs)4
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSActors.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSActors.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSApiTemplate.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs)4
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSConstraint.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSConstraint6Dof.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSConstraintCollection.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSConstraintConeTwist.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSConstraintHinge.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSConstraintHinge.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSConstraintSlider.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSConstraintSpring.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSDynamics.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs)4
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSLinkset.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSLinksetCompound.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSLinksetConstraints.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs)4
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSMaterials.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSMaterials.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSMotors.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSParam.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSParam.cs)4
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs)4
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs)7
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSPrimDisplaced.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs)4
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSPrimLinkable.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs)5
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSScene.cs1333
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSShapeCollection.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs)6
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSShapes.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs)12
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs)5
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSTerrainManager.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs)5
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSTerrainMesh.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs)5
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BulletSimData.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BulletSimTODO.txt (renamed from OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt)0
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/ExtendedPhysics.cs622
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/Properties/AssemblyInfo.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/Properties/AssemblyInfo.cs)3
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/Tests/BasicVehicles.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs)6
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTests.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTestsUtil.cs)31
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/Tests/HullCreation.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/Tests/HullCreation.cs)6
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/CTri.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/CTri.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Concavity.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/Concavity.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/ConvexBuilder.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/ConvexBuilder.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/ConvexDecomposition.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/ConvexDecomposition.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/ConvexResult.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/ConvexResult.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullClasses.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/HullClasses.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullTriangle.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/HullTriangle.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/HullUtils.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/LICENSE.txt (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/LICENSE.txt)0
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Plane.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/Plane.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/PlaneTri.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/PlaneTri.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Properties/AssemblyInfo.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/Properties/AssemblyInfo.cs)0
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Quaternion.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/Quaternion.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/README.txt (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/README.txt)0
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/SplitPlane.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/SplitPlane.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/VertexLookup.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/VertexLookup.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float2.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/float2.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float3.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/float3.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float3x3.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/float3x3.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float4.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/float4.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float4x4.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/float4x4.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/int3.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/int3.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/int4.cs (renamed from OpenSim/Region/Physics/ConvexDecompositionDotNet/int4.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/HelperTypes.cs (renamed from OpenSim/Region/Physics/Meshing/HelperTypes.cs)4
-rw-r--r--OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Mesh.cs (renamed from OpenSim/Region/Physics/Meshing/Mesh.cs)4
-rw-r--r--OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs (renamed from OpenSim/Region/Physics/Meshing/Meshmerizer.cs)116
-rw-r--r--OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/PrimMesher.cs (renamed from OpenSim/Region/Physics/Meshing/PrimMesher.cs)0
-rw-r--r--OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/SculptMap.cs (renamed from OpenSim/Region/Physics/Meshing/SculptMap.cs)0
-rw-r--r--OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/SculptMesh.cs (renamed from OpenSim/Region/Physics/Meshing/SculptMesh.cs)0
-rw-r--r--OpenSim/Region/PhysicsModules/Meshing/Properties/AssemblyInfo.cs (renamed from OpenSim/Region/RegionCombinerModule/Properties/AssemblyInfo.cs)6
-rw-r--r--OpenSim/Region/PhysicsModules/Meshing/ZeroMesher.cs (renamed from OpenSim/Region/Physics/Manager/ZeroMesher.cs)68
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/AssemblyInfo.cs (renamed from OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs)4
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs (renamed from OpenSim/Region/Physics/OdePlugin/ODECharacter.cs)6
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/ODEDynamics.c_comments (renamed from OpenSim/Region/Physics/OdePlugin/ODEDynamics.c_comments)0
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs (renamed from OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs)4
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs (renamed from OpenSim/Region/Physics/OdePlugin/ODEPrim.cs)6
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs (renamed from OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs)10
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/OdePhysicsJoint.cs (renamed from OpenSim/Region/Physics/OdePlugin/OdePhysicsJoint.cs)6
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/OdeScene.cs (renamed from OpenSim/Region/Physics/OdePlugin/OdeScene.cs)141
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs (renamed from OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs)67
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/drawstuff.cs (renamed from OpenSim/Region/Physics/OdePlugin/drawstuff.cs)0
-rw-r--r--OpenSim/Region/PhysicsModules/POS/AssemblyInfo.cs (renamed from OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs)4
-rw-r--r--OpenSim/Region/PhysicsModules/POS/POSCharacter.cs (renamed from OpenSim/Region/Physics/POSPlugin/POSCharacter.cs)4
-rw-r--r--OpenSim/Region/PhysicsModules/POS/POSPrim.cs (renamed from OpenSim/Region/Physics/POSPlugin/POSPrim.cs)4
-rw-r--r--OpenSim/Region/PhysicsModules/POS/POSScene.cs (renamed from OpenSim/Region/Physics/POSPlugin/POSScene.cs)66
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs (renamed from OpenSim/Region/Physics/Manager/AssemblyInfo.cs)0
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs (renamed from OpenSim/Region/Physics/Manager/CollisionLocker.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs (renamed from OpenSim/Region/Physics/Manager/IMesher.cs)2
-rwxr-xr-xOpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs (renamed from OpenSim/Region/Physics/Manager/IPhysicsParameters.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs (renamed from OpenSim/Region/Physics/Manager/NullPhysicsScene.cs)7
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs (renamed from OpenSim/Region/Physics/Manager/PhysicsActor.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs (renamed from OpenSim/Region/Physics/Manager/PhysicsJoint.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs (renamed from OpenSim/Region/Physics/Manager/PhysicsScene.cs)23
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs (renamed from OpenSim/Region/Physics/Manager/PhysicsSensor.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs (renamed from OpenSim/Region/Physics/Manager/PhysicsVector.cs)2
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs (renamed from OpenSim/Region/Physics/Manager/VehicleConstants.cs)2
110 files changed, 2540 insertions, 2140 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
deleted file mode 100644
index 373c7e0..0000000
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ /dev/null
@@ -1,64 +0,0 @@
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 copyright
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
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager;
33
34namespace OpenSim.Region.Physics.BasicPhysicsPlugin
35{
36 /// <summary>
37 /// Effectively a physics plugin that simulates no physics at all.
38 /// </summary>
39 public class BasicPhysicsPlugin : IPhysicsPlugin
40 {
41 public BasicPhysicsPlugin()
42 {
43 }
44
45 public bool Init()
46 {
47 return true;
48 }
49
50 public PhysicsScene GetScene(string sceneIdentifier)
51 {
52 return new BasicScene(GetName(), sceneIdentifier);
53 }
54
55 public string GetName()
56 {
57 return ("basicphysics");
58 }
59
60 public void Dispose()
61 {
62 }
63 }
64}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPlugin.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPlugin.cs
deleted file mode 100644
index 9442854..0000000
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPlugin.cs
+++ /dev/null
@@ -1,76 +0,0 @@
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 OpenSim.Framework;
30using OpenSim.Region.Physics.Manager;
31using OpenMetaverse;
32
33namespace OpenSim.Region.Physics.BulletSPlugin
34{
35 /// <summary>
36 /// Entry for a port of Bullet (http://bulletphysics.org/) to OpenSim.
37 /// This module interfaces to an unmanaged C++ library which makes the
38 /// actual calls into the Bullet physics engine.
39 /// The unmanaged library is found in opensim-libs::trunk/unmanaged/BulletSim/.
40 /// The unmanaged library is compiled and linked statically with Bullet
41 /// to create BulletSim.dll and libBulletSim.so (for both 32 and 64 bit).
42 /// </summary>
43public class BSPlugin : IPhysicsPlugin
44{
45 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
46
47 private BSScene _mScene;
48
49 public BSPlugin()
50 {
51 }
52
53 public bool Init()
54 {
55 return true;
56 }
57
58 public PhysicsScene GetScene(String sceneIdentifier)
59 {
60 if (_mScene == null)
61 {
62 _mScene = new BSScene(GetName(), sceneIdentifier);
63 }
64 return (_mScene);
65 }
66
67 public string GetName()
68 {
69 return ("BulletSim");
70 }
71
72 public void Dispose()
73 {
74 }
75}
76}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
deleted file mode 100644
index 0bace14..0000000
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ /dev/null
@@ -1,1283 +0,0 @@
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.Linq;
30using System.Reflection;
31using System.Runtime.InteropServices;
32using System.Text;
33using System.Threading;
34using OpenSim.Framework;
35using OpenSim.Framework.Monitoring;
36using OpenSim.Region.Framework;
37using OpenSim.Region.CoreModules;
38using Logging = OpenSim.Region.CoreModules.Framework.Statistics.Logging;
39using OpenSim.Region.Physics.Manager;
40using Nini.Config;
41using log4net;
42using OpenMetaverse;
43
44namespace OpenSim.Region.Physics.BulletSPlugin
45{
46public sealed class BSScene : PhysicsScene, IPhysicsParameters
47{
48 internal static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
49 internal static readonly string LogHeader = "[BULLETS SCENE]";
50
51 // The name of the region we're working for.
52 public string RegionName { get; private set; }
53
54 public string BulletSimVersion = "?";
55
56 // The handle to the underlying managed or unmanaged version of Bullet being used.
57 public string BulletEngineName { get; private set; }
58 public BSAPITemplate PE;
59
60 // If the physics engine is running on a separate thread
61 public Thread m_physicsThread;
62
63 public Dictionary<uint, BSPhysObject> PhysObjects;
64 public BSShapeCollection Shapes;
65
66 // Keeping track of the objects with collisions so we can report begin and end of a collision
67 public HashSet<BSPhysObject> ObjectsWithCollisions = new HashSet<BSPhysObject>();
68 public HashSet<BSPhysObject> ObjectsWithNoMoreCollisions = new HashSet<BSPhysObject>();
69
70 // All the collision processing is protected with this lock object
71 public Object CollisionLock = new Object();
72
73 // Properties are updated here
74 public Object UpdateLock = new Object();
75 public HashSet<BSPhysObject> ObjectsWithUpdates = new HashSet<BSPhysObject>();
76
77 // Keep track of all the avatars so we can send them a collision event
78 // every tick so OpenSim will update its animation.
79 private HashSet<BSPhysObject> AvatarsInScene = new HashSet<BSPhysObject>();
80 private Object AvatarsInSceneLock = new Object();
81
82 // let my minuions use my logger
83 public ILog Logger { get { return m_log; } }
84
85 public IMesher mesher;
86 public uint WorldID { get; private set; }
87 public BulletWorld World { get; private set; }
88
89 // All the constraints that have been allocated in this instance.
90 public BSConstraintCollection Constraints { get; private set; }
91
92 // Simulation parameters
93 //internal float m_physicsStepTime; // if running independently, the interval simulated by default
94
95 internal int m_maxSubSteps;
96 internal float m_fixedTimeStep;
97
98 internal float m_simulatedTime; // the time simulated previously. Used for physics framerate calc.
99
100 internal long m_simulationStep = 0; // The current simulation step.
101 public long SimulationStep { get { return m_simulationStep; } }
102 // A number to use for SimulationStep that is probably not any step value
103 // Used by the collision code (which remembers the step when a collision happens) to remember not any simulation step.
104 public static long NotASimulationStep = -1234;
105
106 internal float LastTimeStep { get; private set; } // The simulation time from the last invocation of Simulate()
107
108 internal float NominalFrameRate { get; set; } // Parameterized ideal frame rate that simulation is scaled to
109
110 // Physical objects can register for prestep or poststep events
111 public delegate void PreStepAction(float timeStep);
112 public delegate void PostStepAction(float timeStep);
113 public event PreStepAction BeforeStep;
114 public event PostStepAction AfterStep;
115
116 // A value of the time 'now' so all the collision and update routines do not have to get their own
117 // Set to 'now' just before all the prims and actors are called for collisions and updates
118 public int SimulationNowTime { get; private set; }
119
120 // True if initialized and ready to do simulation steps
121 private bool m_initialized = false;
122
123 // Flag which is true when processing taints.
124 // Not guaranteed to be correct all the time (don't depend on this) but good for debugging.
125 public bool InTaintTime { get; private set; }
126
127 // Pinned memory used to pass step information between managed and unmanaged
128 internal int m_maxCollisionsPerFrame;
129 internal CollisionDesc[] m_collisionArray;
130
131 internal int m_maxUpdatesPerFrame;
132 internal EntityProperties[] m_updateArray;
133
134 /// <summary>
135 /// Used to control physics simulation timing if Bullet is running on its own thread.
136 /// </summary>
137 private ManualResetEvent m_updateWaitEvent;
138
139 public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero
140 public const uint GROUNDPLANE_ID = 1;
141 public const uint CHILDTERRAIN_ID = 2; // Terrain allocated based on our mega-prim childre start here
142
143 public float SimpleWaterLevel { get; set; }
144 public BSTerrainManager TerrainManager { get; private set; }
145
146 public ConfigurationParameters Params
147 {
148 get { return UnmanagedParams[0]; }
149 }
150 public Vector3 DefaultGravity
151 {
152 get { return new Vector3(0f, 0f, Params.gravity); }
153 }
154 // Just the Z value of the gravity
155 public float DefaultGravityZ
156 {
157 get { return Params.gravity; }
158 }
159
160 // When functions in the unmanaged code must be called, it is only
161 // done at a known time just before the simulation step. The taint
162 // system saves all these function calls and executes them in
163 // order before the simulation.
164 public delegate void TaintCallback();
165 private struct TaintCallbackEntry
166 {
167 public String originator;
168 public String ident;
169 public TaintCallback callback;
170 public TaintCallbackEntry(string pIdent, TaintCallback pCallBack)
171 {
172 originator = BSScene.DetailLogZero;
173 ident = pIdent;
174 callback = pCallBack;
175 }
176 public TaintCallbackEntry(string pOrigin, string pIdent, TaintCallback pCallBack)
177 {
178 originator = pOrigin;
179 ident = pIdent;
180 callback = pCallBack;
181 }
182 }
183 private Object _taintLock = new Object(); // lock for using the next object
184 private List<TaintCallbackEntry> _taintOperations;
185 private Dictionary<string, TaintCallbackEntry> _postTaintOperations;
186 private List<TaintCallbackEntry> _postStepOperations;
187
188 // A pointer to an instance if this structure is passed to the C++ code
189 // Used to pass basic configuration values to the unmanaged code.
190 internal ConfigurationParameters[] UnmanagedParams;
191
192 // Sometimes you just have to log everything.
193 public Logging.LogWriter PhysicsLogging;
194 private bool m_physicsLoggingEnabled;
195 private string m_physicsLoggingDir;
196 private string m_physicsLoggingPrefix;
197 private int m_physicsLoggingFileMinutes;
198 private bool m_physicsLoggingDoFlush;
199 private bool m_physicsPhysicalDumpEnabled;
200 public int PhysicsMetricDumpFrames { get; set; }
201 // 'true' of the vehicle code is to log lots of details
202 public bool VehicleLoggingEnabled { get; private set; }
203 public bool VehiclePhysicalLoggingEnabled { get; private set; }
204
205 #region Construction and Initialization
206 public BSScene(string engineType, string identifier)
207 {
208 m_initialized = false;
209
210 // The name of the region we're working for is passed to us. Keep for identification.
211 RegionName = identifier;
212
213 // Set identifying variables in the PhysicsScene interface.
214 EngineType = engineType;
215 Name = EngineType + "/" + RegionName;
216 }
217
218 // Old version of initialization that assumes legacy sized regions (256x256)
219 public override void Initialise(IMesher meshmerizer, IConfigSource config)
220 {
221 m_log.ErrorFormat("{0} WARNING WARNING WARNING! BulletSim initialized without region extent specification. Terrain will be messed up.");
222 Vector3 regionExtent = new Vector3( Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
223 Initialise(meshmerizer, config, regionExtent);
224
225 }
226
227 public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
228 {
229 mesher = meshmerizer;
230 _taintOperations = new List<TaintCallbackEntry>();
231 _postTaintOperations = new Dictionary<string, TaintCallbackEntry>();
232 _postStepOperations = new List<TaintCallbackEntry>();
233 PhysObjects = new Dictionary<uint, BSPhysObject>();
234 Shapes = new BSShapeCollection(this);
235
236 m_simulatedTime = 0f;
237 LastTimeStep = 0.1f;
238
239 // Allocate pinned memory to pass parameters.
240 UnmanagedParams = new ConfigurationParameters[1];
241
242 // Set default values for physics parameters plus any overrides from the ini file
243 GetInitialParameterValues(config);
244
245 // Force some parameters to values depending on other configurations
246 // Only use heightmap terrain implementation if terrain larger than legacy size
247 if ((uint)regionExtent.X > Constants.RegionSize || (uint)regionExtent.Y > Constants.RegionSize)
248 {
249 m_log.WarnFormat("{0} Forcing terrain implementation to heightmap for large region", LogHeader);
250 BSParam.TerrainImplementation = (float)BSTerrainPhys.TerrainImplementation.Heightmap;
251 }
252
253 // Get the connection to the physics engine (could be native or one of many DLLs)
254 PE = SelectUnderlyingBulletEngine(BulletEngineName);
255
256 // Enable very detailed logging.
257 // By creating an empty logger when not logging, the log message invocation code
258 // can be left in and every call doesn't have to check for null.
259 if (m_physicsLoggingEnabled)
260 {
261 PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes, m_physicsLoggingDoFlush);
262 PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output its own error messages.
263 }
264 else
265 {
266 PhysicsLogging = new Logging.LogWriter();
267 }
268
269 // Allocate memory for returning of the updates and collisions from the physics engine
270 m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame];
271 m_updateArray = new EntityProperties[m_maxUpdatesPerFrame];
272
273 // The bounding box for the simulated world. The origin is 0,0,0 unless we're
274 // a child in a mega-region.
275 // Bullet actually doesn't care about the extents of the simulated
276 // area. It tracks active objects no matter where they are.
277 Vector3 worldExtent = regionExtent;
278
279 World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray, m_maxUpdatesPerFrame, ref m_updateArray);
280
281 Constraints = new BSConstraintCollection(World);
282
283 TerrainManager = new BSTerrainManager(this, worldExtent);
284 TerrainManager.CreateInitialGroundPlaneAndTerrain();
285
286 // Put some informational messages into the log file.
287 m_log.InfoFormat("{0} Linksets implemented with {1}", LogHeader, (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation);
288
289 InTaintTime = false;
290 m_initialized = true;
291
292 // If the physics engine runs on its own thread, start same.
293 if (BSParam.UseSeparatePhysicsThread)
294 {
295 // The physics simulation should happen independently of the heartbeat loop
296 m_physicsThread
297 = WorkManager.StartThread(
298 BulletSPluginPhysicsThread,
299 string.Format("{0} ({1})", BulletEngineName, RegionName),
300 ThreadPriority.Normal,
301 true,
302 true);
303 }
304 }
305
306 // All default parameter values are set here. There should be no values set in the
307 // variable definitions.
308 private void GetInitialParameterValues(IConfigSource config)
309 {
310 ConfigurationParameters parms = new ConfigurationParameters();
311 UnmanagedParams[0] = parms;
312
313 BSParam.SetParameterDefaultValues(this);
314
315 if (config != null)
316 {
317 // If there are specifications in the ini file, use those values
318 IConfig pConfig = config.Configs["BulletSim"];
319 if (pConfig != null)
320 {
321 BSParam.SetParameterConfigurationValues(this, pConfig);
322
323 // There are two Bullet implementations to choose from
324 BulletEngineName = pConfig.GetString("BulletEngine", "BulletUnmanaged");
325
326 // Very detailed logging for physics debugging
327 // TODO: the boolean values can be moved to the normal parameter processing.
328 m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false);
329 m_physicsLoggingDir = pConfig.GetString("PhysicsLoggingDir", ".");
330 m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-%REGIONNAME%-");
331 m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5);
332 m_physicsLoggingDoFlush = pConfig.GetBoolean("PhysicsLoggingDoFlush", false);
333 m_physicsPhysicalDumpEnabled = pConfig.GetBoolean("PhysicsPhysicalDumpEnabled", false);
334 // Very detailed logging for vehicle debugging
335 VehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
336 VehiclePhysicalLoggingEnabled = pConfig.GetBoolean("VehiclePhysicalLoggingEnabled", false);
337
338 // Do any replacements in the parameters
339 m_physicsLoggingPrefix = m_physicsLoggingPrefix.Replace("%REGIONNAME%", RegionName);
340 }
341 else
342 {
343 // Nothing in the configuration INI file so assume unmanaged and other defaults.
344 BulletEngineName = "BulletUnmanaged";
345 m_physicsLoggingEnabled = false;
346 VehicleLoggingEnabled = false;
347 }
348
349 // The material characteristics.
350 BSMaterials.InitializeFromDefaults(Params);
351 if (pConfig != null)
352 {
353 // Let the user add new and interesting material property values.
354 BSMaterials.InitializefromParameters(pConfig);
355 }
356 }
357 }
358
359 // A helper function that handles a true/false parameter and returns the proper float number encoding
360 float ParamBoolean(IConfig config, string parmName, float deflt)
361 {
362 float ret = deflt;
363 if (config.Contains(parmName))
364 {
365 ret = ConfigurationParameters.numericFalse;
366 if (config.GetBoolean(parmName, false))
367 {
368 ret = ConfigurationParameters.numericTrue;
369 }
370 }
371 return ret;
372 }
373
374 // Select the connection to the actual Bullet implementation.
375 // The main engine selection is the engineName up to the first hypen.
376 // So "Bullet-2.80-OpenCL-Intel" specifies the 'bullet' class here and the whole name
377 // is passed to the engine to do its special selection, etc.
378 private BSAPITemplate SelectUnderlyingBulletEngine(string engineName)
379 {
380 // For the moment, do a simple switch statement.
381 // Someday do fancyness with looking up the interfaces in the assembly.
382 BSAPITemplate ret = null;
383
384 string selectionName = engineName.ToLower();
385 int hyphenIndex = engineName.IndexOf("-");
386 if (hyphenIndex > 0)
387 selectionName = engineName.ToLower().Substring(0, hyphenIndex - 1);
388
389 switch (selectionName)
390 {
391 case "bullet":
392 case "bulletunmanaged":
393 ret = new BSAPIUnman(engineName, this);
394 break;
395 case "bulletxna":
396 ret = new BSAPIXNA(engineName, this);
397 // Disable some features that are not implemented in BulletXNA
398 m_log.InfoFormat("{0} Disabling some physics features not implemented by BulletXNA", LogHeader);
399 m_log.InfoFormat("{0} Disabling ShouldUseBulletHACD", LogHeader);
400 BSParam.ShouldUseBulletHACD = false;
401 m_log.InfoFormat("{0} Disabling ShouldUseSingleConvexHullForPrims", LogHeader);
402 BSParam.ShouldUseSingleConvexHullForPrims = false;
403 m_log.InfoFormat("{0} Disabling ShouldUseGImpactShapeForPrims", LogHeader);
404 BSParam.ShouldUseGImpactShapeForPrims = false;
405 m_log.InfoFormat("{0} Setting terrain implimentation to Heightmap", LogHeader);
406 BSParam.TerrainImplementation = (float)BSTerrainPhys.TerrainImplementation.Heightmap;
407 break;
408 }
409
410 if (ret == null)
411 {
412 m_log.ErrorFormat("{0} COULD NOT SELECT BULLET ENGINE: '[BulletSim]PhysicsEngine' must be either 'BulletUnmanaged-*' or 'BulletXNA-*'", LogHeader);
413 }
414 else
415 {
416 m_log.InfoFormat("{0} Selected bullet engine {1} -> {2}/{3}", LogHeader, engineName, ret.BulletEngineName, ret.BulletEngineVersion);
417 }
418
419 return ret;
420 }
421
422 public override void Dispose()
423 {
424 // m_log.DebugFormat("{0}: Dispose()", LogHeader);
425
426 // make sure no stepping happens while we're deleting stuff
427 m_initialized = false;
428
429 lock (PhysObjects)
430 {
431 foreach (KeyValuePair<uint, BSPhysObject> kvp in PhysObjects)
432 {
433 kvp.Value.Destroy();
434 }
435 PhysObjects.Clear();
436 }
437
438 // Now that the prims are all cleaned up, there should be no constraints left
439 if (Constraints != null)
440 {
441 Constraints.Dispose();
442 Constraints = null;
443 }
444
445 if (Shapes != null)
446 {
447 Shapes.Dispose();
448 Shapes = null;
449 }
450
451 if (TerrainManager != null)
452 {
453 TerrainManager.ReleaseGroundPlaneAndTerrain();
454 TerrainManager.Dispose();
455 TerrainManager = null;
456 }
457
458 // Anything left in the unmanaged code should be cleaned out
459 PE.Shutdown(World);
460
461 // Not logging any more
462 PhysicsLogging.Close();
463 }
464 #endregion // Construction and Initialization
465
466 #region Prim and Avatar addition and removal
467
468 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
469 {
470 m_log.ErrorFormat("{0}: CALL TO AddAvatar in BSScene. NOT IMPLEMENTED", LogHeader);
471 return null;
472 }
473
474 public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
475 {
476 // m_log.DebugFormat("{0}: AddAvatar: {1}", LogHeader, avName);
477
478 if (!m_initialized) return null;
479
480 BSCharacter actor = new BSCharacter(localID, avName, this, position, velocity, size, isFlying);
481 lock (PhysObjects)
482 PhysObjects.Add(localID, actor);
483
484 // TODO: Remove kludge someday.
485 // We must generate a collision for avatars whether they collide or not.
486 // This is required by OpenSim to update avatar animations, etc.
487 lock (AvatarsInSceneLock)
488 AvatarsInScene.Add(actor);
489
490 return actor;
491 }
492
493 public override void RemoveAvatar(PhysicsActor actor)
494 {
495 // m_log.DebugFormat("{0}: RemoveAvatar", LogHeader);
496
497 if (!m_initialized) return;
498
499 BSCharacter bsactor = actor as BSCharacter;
500 if (bsactor != null)
501 {
502 try
503 {
504 lock (PhysObjects)
505 PhysObjects.Remove(bsactor.LocalID);
506 // Remove kludge someday
507 lock (AvatarsInSceneLock)
508 AvatarsInScene.Remove(bsactor);
509 }
510 catch (Exception e)
511 {
512 m_log.WarnFormat("{0}: Attempt to remove avatar that is not in physics scene: {1}", LogHeader, e);
513 }
514 bsactor.Destroy();
515 // bsactor.dispose();
516 }
517 else
518 {
519 m_log.ErrorFormat("{0}: Requested to remove avatar that is not a BSCharacter. ID={1}, type={2}",
520 LogHeader, actor.LocalID, actor.GetType().Name);
521 }
522 }
523
524 public override void RemovePrim(PhysicsActor prim)
525 {
526 if (!m_initialized) return;
527
528 BSPhysObject bsprim = prim as BSPhysObject;
529 if (bsprim != null)
530 {
531 DetailLog("{0},RemovePrim,call", bsprim.LocalID);
532 // m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID);
533 try
534 {
535 lock (PhysObjects) PhysObjects.Remove(bsprim.LocalID);
536 }
537 catch (Exception e)
538 {
539 m_log.ErrorFormat("{0}: Attempt to remove prim that is not in physics scene: {1}", LogHeader, e);
540 }
541 bsprim.Destroy();
542 // bsprim.dispose();
543 }
544 else
545 {
546 m_log.ErrorFormat("{0}: Attempt to remove prim that is not a BSPrim type.", LogHeader);
547 }
548 }
549
550 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
551 Vector3 size, Quaternion rotation, bool isPhysical, uint localID)
552 {
553 // m_log.DebugFormat("{0}: AddPrimShape2: {1}", LogHeader, primName);
554
555 if (!m_initialized) return null;
556
557 // DetailLog("{0},BSScene.AddPrimShape,call", localID);
558
559 BSPhysObject prim = new BSPrimLinkable(localID, primName, this, position, size, rotation, pbs, isPhysical);
560 lock (PhysObjects) PhysObjects.Add(localID, prim);
561 return prim;
562 }
563
564 // This is a call from the simulator saying that some physical property has been updated.
565 // The BulletSim driver senses the changing of relevant properties so this taint
566 // information call is not needed.
567 public override void AddPhysicsActorTaint(PhysicsActor prim) { }
568
569 #endregion // Prim and Avatar addition and removal
570
571 #region Simulation
572
573 // Call from the simulator to send physics information to the simulator objects.
574 // This pushes all the collision and property update events into the objects in
575 // the simulator and, since it is on the heartbeat thread, there is an implicit
576 // locking of those data structures from other heartbeat events.
577 // If the physics engine is running on a separate thread, the update information
578 // will be in the ObjectsWithCollions and ObjectsWithUpdates structures.
579 public override float Simulate(float timeStep)
580 {
581 if (!BSParam.UseSeparatePhysicsThread)
582 {
583 DoPhysicsStep(timeStep);
584 }
585 return SendUpdatesToSimulator(timeStep);
586 }
587
588 // Call the physics engine to do one 'timeStep' and collect collisions and updates
589 // into ObjectsWithCollisions and ObjectsWithUpdates data structures.
590 private void DoPhysicsStep(float timeStep)
591 {
592 // prevent simulation until we've been initialized
593 if (!m_initialized) return;
594
595 LastTimeStep = timeStep;
596
597 int updatedEntityCount = 0;
598 int collidersCount = 0;
599
600 int beforeTime = Util.EnvironmentTickCount();
601 int simTime = 0;
602
603 int numTaints = _taintOperations.Count;
604 InTaintTime = true; // Only used for debugging so locking is not necessary.
605
606 // update the prim states while we know the physics engine is not busy
607 ProcessTaints();
608
609 // Some of the physical objects requre individual, pre-step calls
610 // (vehicles and avatar movement, in particular)
611 TriggerPreStepEvent(timeStep);
612
613 // the prestep actions might have added taints
614 numTaints += _taintOperations.Count;
615 ProcessTaints();
616
617 InTaintTime = false; // Only used for debugging so locking is not necessary.
618
619 // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world.
620 // Only enable this in a limited test world with few objects.
621 if (m_physicsPhysicalDumpEnabled)
622 PE.DumpAllInfo(World);
623
624 // step the physical world one interval
625 m_simulationStep++;
626 int numSubSteps = 0;
627 try
628 {
629 numSubSteps = PE.PhysicsStep(World, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out collidersCount);
630
631 }
632 catch (Exception e)
633 {
634 m_log.WarnFormat("{0},PhysicsStep Exception: nTaints={1}, substeps={2}, updates={3}, colliders={4}, e={5}",
635 LogHeader, numTaints, numSubSteps, updatedEntityCount, collidersCount, e);
636 DetailLog("{0},PhysicsStepException,call, nTaints={1}, substeps={2}, updates={3}, colliders={4}",
637 DetailLogZero, numTaints, numSubSteps, updatedEntityCount, collidersCount);
638 updatedEntityCount = 0;
639 collidersCount = 0;
640 }
641
642 // Make the physics engine dump useful statistics periodically
643 if (PhysicsMetricDumpFrames != 0 && ((m_simulationStep % PhysicsMetricDumpFrames) == 0))
644 PE.DumpPhysicsStatistics(World);
645
646 // Get a value for 'now' so all the collision and update routines don't have to get their own.
647 SimulationNowTime = Util.EnvironmentTickCount();
648
649 // Send collision information to the colliding objects. The objects decide if the collision
650 // is 'real' (like linksets don't collide with themselves) and the individual objects
651 // know if the simulator has subscribed to collisions.
652 lock (CollisionLock)
653 {
654 if (collidersCount > 0)
655 {
656 lock (PhysObjects)
657 {
658 for (int ii = 0; ii < collidersCount; ii++)
659 {
660 uint cA = m_collisionArray[ii].aID;
661 uint cB = m_collisionArray[ii].bID;
662 Vector3 point = m_collisionArray[ii].point;
663 Vector3 normal = m_collisionArray[ii].normal;
664 float penetration = m_collisionArray[ii].penetration;
665 SendCollision(cA, cB, point, normal, penetration);
666 SendCollision(cB, cA, point, -normal, penetration);
667 }
668 }
669 }
670 }
671
672 // If any of the objects had updated properties, tell the managed objects about the update
673 // and remember that there was a change so it will be passed to the simulator.
674 lock (UpdateLock)
675 {
676 if (updatedEntityCount > 0)
677 {
678 lock (PhysObjects)
679 {
680 for (int ii = 0; ii < updatedEntityCount; ii++)
681 {
682 EntityProperties entprop = m_updateArray[ii];
683 BSPhysObject pobj;
684 if (PhysObjects.TryGetValue(entprop.ID, out pobj))
685 {
686 if (pobj.IsInitialized)
687 pobj.UpdateProperties(entprop);
688 }
689 }
690 }
691 }
692 }
693
694 // Some actors want to know when the simulation step is complete.
695 TriggerPostStepEvent(timeStep);
696
697 simTime = Util.EnvironmentTickCountSubtract(beforeTime);
698 if (PhysicsLogging.Enabled)
699 {
700 DetailLog("{0},DoPhysicsStep,complete,frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}",
701 DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps,
702 updatedEntityCount, collidersCount, ObjectsWithCollisions.Count);
703 }
704
705 // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world.
706 // Only enable this in a limited test world with few objects.
707 if (m_physicsPhysicalDumpEnabled)
708 PE.DumpAllInfo(World);
709
710 // The physics engine returns the number of milliseconds it simulated this call.
711 // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS.
712 // Multiply by a fixed nominal frame rate to give a rate similar to the simulator (usually 55).
713// m_simulatedTime += (float)numSubSteps * m_fixedTimeStep * 1000f * NominalFrameRate;
714 m_simulatedTime += (float)numSubSteps * m_fixedTimeStep;
715 }
716
717 // Called by a BSPhysObject to note that it has changed properties and this information
718 // should be passed up to the simulator at the proper time.
719 // Note: this is called by the BSPhysObject from invocation via DoPhysicsStep() above so
720 // this is is under UpdateLock.
721 public void PostUpdate(BSPhysObject updatee)
722 {
723 lock (UpdateLock)
724 {
725 ObjectsWithUpdates.Add(updatee);
726 }
727 }
728
729 // The simulator thinks it is physics time so return all the collisions and position
730 // updates that were collected in actual physics simulation.
731 private float SendUpdatesToSimulator(float timeStep)
732 {
733 if (!m_initialized) return 5.0f;
734
735 DetailLog("{0},SendUpdatesToSimulator,collisions={1},updates={2},simedTime={3}",
736 BSScene.DetailLogZero, ObjectsWithCollisions.Count, ObjectsWithUpdates.Count, m_simulatedTime);
737 // Push the collisions into the simulator.
738 lock (CollisionLock)
739 {
740 if (ObjectsWithCollisions.Count > 0)
741 {
742 foreach (BSPhysObject bsp in ObjectsWithCollisions)
743 if (!bsp.SendCollisions())
744 {
745 // If the object is done colliding, see that it's removed from the colliding list
746 ObjectsWithNoMoreCollisions.Add(bsp);
747 }
748 }
749
750 // This is a kludge to get avatar movement updates.
751 // The simulator expects collisions for avatars even if there are have been no collisions.
752 // The event updates avatar animations and stuff.
753 // If you fix avatar animation updates, remove this overhead and let normal collision processing happen.
754 // Note that we get a copy of the list to search because SendCollision() can take a while.
755 HashSet<BSPhysObject> tempAvatarsInScene;
756 lock (AvatarsInSceneLock)
757 {
758 tempAvatarsInScene = new HashSet<BSPhysObject>(AvatarsInScene);
759 }
760 foreach (BSPhysObject actor in tempAvatarsInScene)
761 {
762 if (!ObjectsWithCollisions.Contains(actor)) // don't call avatars twice
763 actor.SendCollisions();
764 }
765 tempAvatarsInScene = null;
766
767 // Objects that are done colliding are removed from the ObjectsWithCollisions list.
768 // Not done above because it is inside an iteration of ObjectWithCollisions.
769 // This complex collision processing is required to create an empty collision
770 // event call after all real collisions have happened on an object. This allows
771 // the simulator to generate the 'collision end' event.
772 if (ObjectsWithNoMoreCollisions.Count > 0)
773 {
774 foreach (BSPhysObject po in ObjectsWithNoMoreCollisions)
775 ObjectsWithCollisions.Remove(po);
776 ObjectsWithNoMoreCollisions.Clear();
777 }
778 }
779
780 // Call the simulator for each object that has physics property updates.
781 HashSet<BSPhysObject> updatedObjects = null;
782 lock (UpdateLock)
783 {
784 if (ObjectsWithUpdates.Count > 0)
785 {
786 updatedObjects = ObjectsWithUpdates;
787 ObjectsWithUpdates = new HashSet<BSPhysObject>();
788 }
789 }
790 if (updatedObjects != null)
791 {
792 foreach (BSPhysObject obj in updatedObjects)
793 {
794 obj.RequestPhysicsterseUpdate();
795 }
796 updatedObjects.Clear();
797 }
798
799 // Return the framerate simulated to give the above returned results.
800 // (Race condition here but this is just bookkeeping so rare mistakes do not merit a lock).
801 // undo math above
802 float simTime = m_simulatedTime / timeStep;
803 m_simulatedTime = 0f;
804 return simTime;
805 }
806
807 // Something has collided
808 private void SendCollision(uint localID, uint collidingWith, Vector3 collidePoint, Vector3 collideNormal, float penetration)
809 {
810 if (localID <= TerrainManager.HighestTerrainID)
811 {
812 return; // don't send collisions to the terrain
813 }
814
815 BSPhysObject collider;
816 // NOTE that PhysObjects was locked before the call to SendCollision().
817 if (!PhysObjects.TryGetValue(localID, out collider))
818 {
819 // If the object that is colliding cannot be found, just ignore the collision.
820 DetailLog("{0},BSScene.SendCollision,colliderNotInObjectList,id={1},with={2}", DetailLogZero, localID, collidingWith);
821 return;
822 }
823
824 // Note: the terrain is not in the physical object list so 'collidee' can be null when Collide() is called.
825 BSPhysObject collidee = null;
826 PhysObjects.TryGetValue(collidingWith, out collidee);
827
828 // DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith);
829
830 if (collider.IsInitialized)
831 {
832 if (collider.Collide(collidingWith, collidee, collidePoint, collideNormal, penetration))
833 {
834 // If a collision was 'good', remember to send it to the simulator
835 lock (CollisionLock)
836 {
837 ObjectsWithCollisions.Add(collider);
838 }
839 }
840 }
841
842 return;
843 }
844
845 public void BulletSPluginPhysicsThread()
846 {
847 Thread.CurrentThread.Priority = ThreadPriority.Highest;
848 m_updateWaitEvent = new ManualResetEvent(false);
849
850 while (m_initialized)
851 {
852 int beginSimulationRealtimeMS = Util.EnvironmentTickCount();
853
854 if (BSParam.Active)
855 DoPhysicsStep(BSParam.PhysicsTimeStep);
856
857 int simulationRealtimeMS = Util.EnvironmentTickCountSubtract(beginSimulationRealtimeMS);
858 int simulationTimeVsRealtimeDifferenceMS = ((int)(BSParam.PhysicsTimeStep*1000f)) - simulationRealtimeMS;
859
860 if (simulationTimeVsRealtimeDifferenceMS > 0)
861 {
862 // The simulation of the time interval took less than realtime.
863 // Do a wait for the rest of realtime.
864 m_updateWaitEvent.WaitOne(simulationTimeVsRealtimeDifferenceMS);
865 //Thread.Sleep(simulationTimeVsRealtimeDifferenceMS);
866 }
867 else
868 {
869 // The simulation took longer than realtime.
870 // Do some scaling of simulation time.
871 // TODO.
872 DetailLog("{0},BulletSPluginPhysicsThread,longerThanRealtime={1}", BSScene.DetailLogZero, simulationTimeVsRealtimeDifferenceMS);
873 }
874
875 Watchdog.UpdateThread();
876 }
877
878 Watchdog.RemoveThread();
879 }
880
881 #endregion // Simulation
882
883 public override void GetResults() { }
884
885 #region Terrain
886
887 public override void SetTerrain(float[] heightMap) {
888 TerrainManager.SetTerrain(heightMap);
889 }
890
891 public override void SetWaterLevel(float baseheight)
892 {
893 SimpleWaterLevel = baseheight;
894 }
895
896 public override void DeleteTerrain()
897 {
898 // m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader);
899 }
900
901 // Although no one seems to check this, I do support combining.
902 public override bool SupportsCombining()
903 {
904 return TerrainManager.SupportsCombining();
905 }
906 // This call says I am a child to region zero in a mega-region. 'pScene' is that
907 // of region zero, 'offset' is my offset from regions zero's origin, and
908 // 'extents' is the largest XY that is handled in my region.
909 public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
910 {
911 TerrainManager.Combine(pScene, offset, extents);
912 }
913
914 // Unhook all the combining that I know about.
915 public override void UnCombine(PhysicsScene pScene)
916 {
917 TerrainManager.UnCombine(pScene);
918 }
919
920 #endregion // Terrain
921
922 public override Dictionary<uint, float> GetTopColliders()
923 {
924 Dictionary<uint, float> topColliders;
925
926 lock (PhysObjects)
927 {
928 foreach (KeyValuePair<uint, BSPhysObject> kvp in PhysObjects)
929 {
930 kvp.Value.ComputeCollisionScore();
931 }
932
933 List<BSPhysObject> orderedPrims = new List<BSPhysObject>(PhysObjects.Values);
934 orderedPrims.OrderByDescending(p => p.CollisionScore);
935 topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore);
936 }
937
938 return topColliders;
939 }
940
941 public override bool IsThreaded { get { return false; } }
942
943 #region Extensions
944 public override object Extension(string pFunct, params object[] pParams)
945 {
946 DetailLog("{0} BSScene.Extension,op={1}", DetailLogZero, pFunct);
947 return base.Extension(pFunct, pParams);
948 }
949 #endregion // Extensions
950
951 public static string PrimitiveBaseShapeToString(PrimitiveBaseShape pbs)
952 {
953 float pathShearX = pbs.PathShearX < 128 ? (float)pbs.PathShearX * 0.01f : (float)(pbs.PathShearX - 256) * 0.01f;
954 float pathShearY = pbs.PathShearY < 128 ? (float)pbs.PathShearY * 0.01f : (float)(pbs.PathShearY - 256) * 0.01f;
955 float pathBegin = (float)pbs.PathBegin * 2.0e-5f;
956 float pathEnd = 1.0f - (float)pbs.PathEnd * 2.0e-5f;
957 float pathScaleX = (float)(200 - pbs.PathScaleX) * 0.01f;
958 float pathScaleY = (float)(200 - pbs.PathScaleY) * 0.01f;
959 float pathTaperX = pbs.PathTaperX * 0.01f;
960 float pathTaperY = pbs.PathTaperY * 0.01f;
961
962 float profileBegin = (float)pbs.ProfileBegin * 2.0e-5f;
963 float profileEnd = 1.0f - (float)pbs.ProfileEnd * 2.0e-5f;
964 float profileHollow = (float)pbs.ProfileHollow * 2.0e-5f;
965 if (profileHollow > 0.95f)
966 profileHollow = 0.95f;
967
968 StringBuilder buff = new StringBuilder();
969 buff.Append("shape=");
970 buff.Append(((ProfileShape)pbs.ProfileShape).ToString());
971 buff.Append(",");
972 buff.Append("hollow=");
973 buff.Append(((HollowShape)pbs.HollowShape).ToString());
974 buff.Append(",");
975 buff.Append("pathCurve=");
976 buff.Append(((Extrusion)pbs.PathCurve).ToString());
977 buff.Append(",");
978 buff.Append("profCurve=");
979 buff.Append(((Extrusion)pbs.ProfileCurve).ToString());
980 buff.Append(",");
981 buff.Append("profHollow=");
982 buff.Append(profileHollow.ToString());
983 buff.Append(",");
984 buff.Append("pathBegEnd=");
985 buff.Append(pathBegin.ToString());
986 buff.Append("/");
987 buff.Append(pathEnd.ToString());
988 buff.Append(",");
989 buff.Append("profileBegEnd=");
990 buff.Append(profileBegin.ToString());
991 buff.Append("/");
992 buff.Append(profileEnd.ToString());
993 buff.Append(",");
994 buff.Append("scaleXY=");
995 buff.Append(pathScaleX.ToString());
996 buff.Append("/");
997 buff.Append(pathScaleY.ToString());
998 buff.Append(",");
999 buff.Append("shearXY=");
1000 buff.Append(pathShearX.ToString());
1001 buff.Append("/");
1002 buff.Append(pathShearY.ToString());
1003 buff.Append(",");
1004 buff.Append("taperXY=");
1005 buff.Append(pbs.PathTaperX.ToString());
1006 buff.Append("/");
1007 buff.Append(pbs.PathTaperY.ToString());
1008 buff.Append(",");
1009 buff.Append("skew=");
1010 buff.Append(pbs.PathSkew.ToString());
1011 buff.Append(",");
1012 buff.Append("twist/Beg=");
1013 buff.Append(pbs.PathTwist.ToString());
1014 buff.Append("/");
1015 buff.Append(pbs.PathTwistBegin.ToString());
1016
1017 return buff.ToString();
1018 }
1019
1020 #region Taints
1021 // The simulation execution order is:
1022 // Simulate()
1023 // DoOneTimeTaints
1024 // TriggerPreStepEvent
1025 // DoOneTimeTaints
1026 // Step()
1027 // ProcessAndSendToSimulatorCollisions
1028 // ProcessAndSendToSimulatorPropertyUpdates
1029 // TriggerPostStepEvent
1030
1031 // Calls to the PhysicsActors can't directly call into the physics engine
1032 // because it might be busy. We delay changes to a known time.
1033 // We rely on C#'s closure to save and restore the context for the delegate.
1034 public void TaintedObject(string pOriginator, string pIdent, TaintCallback pCallback)
1035 {
1036 TaintedObject(false /*inTaintTime*/, pOriginator, pIdent, pCallback);
1037 }
1038 public void TaintedObject(uint pOriginator, String pIdent, TaintCallback pCallback)
1039 {
1040 TaintedObject(false /*inTaintTime*/, m_physicsLoggingEnabled ? pOriginator.ToString() : BSScene.DetailLogZero, pIdent, pCallback);
1041 }
1042 public void TaintedObject(bool inTaintTime, String pIdent, TaintCallback pCallback)
1043 {
1044 TaintedObject(inTaintTime, BSScene.DetailLogZero, pIdent, pCallback);
1045 }
1046 public void TaintedObject(bool inTaintTime, uint pOriginator, String pIdent, TaintCallback pCallback)
1047 {
1048 TaintedObject(inTaintTime, m_physicsLoggingEnabled ? pOriginator.ToString() : BSScene.DetailLogZero, pIdent, pCallback);
1049 }
1050 // Sometimes a potentially tainted operation can be used in and out of taint time.
1051 // This routine executes the command immediately if in taint-time otherwise it is queued.
1052 public void TaintedObject(bool inTaintTime, string pOriginator, string pIdent, TaintCallback pCallback)
1053 {
1054 if (!m_initialized) return;
1055
1056 if (inTaintTime)
1057 pCallback();
1058 else
1059 {
1060 lock (_taintLock)
1061 {
1062 _taintOperations.Add(new TaintCallbackEntry(pOriginator, pIdent, pCallback));
1063 }
1064 }
1065 }
1066
1067 private void TriggerPreStepEvent(float timeStep)
1068 {
1069 PreStepAction actions = BeforeStep;
1070 if (actions != null)
1071 actions(timeStep);
1072
1073 }
1074
1075 private void TriggerPostStepEvent(float timeStep)
1076 {
1077 PostStepAction actions = AfterStep;
1078 if (actions != null)
1079 actions(timeStep);
1080
1081 }
1082
1083 // When someone tries to change a property on a BSPrim or BSCharacter, the object queues
1084 // a callback into itself to do the actual property change. That callback is called
1085 // here just before the physics engine is called to step the simulation.
1086 public void ProcessTaints()
1087 {
1088 ProcessRegularTaints();
1089 ProcessPostTaintTaints();
1090 }
1091
1092 private void ProcessRegularTaints()
1093 {
1094 if (m_initialized && _taintOperations.Count > 0) // save allocating new list if there is nothing to process
1095 {
1096 // swizzle a new list into the list location so we can process what's there
1097 List<TaintCallbackEntry> oldList;
1098 lock (_taintLock)
1099 {
1100 oldList = _taintOperations;
1101 _taintOperations = new List<TaintCallbackEntry>();
1102 }
1103
1104 foreach (TaintCallbackEntry tcbe in oldList)
1105 {
1106 try
1107 {
1108 DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", tcbe.originator, tcbe.ident); // DEBUG DEBUG DEBUG
1109 tcbe.callback();
1110 }
1111 catch (Exception e)
1112 {
1113 m_log.ErrorFormat("{0}: ProcessTaints: {1}: Exception: {2}", LogHeader, tcbe.ident, e);
1114 }
1115 }
1116 oldList.Clear();
1117 }
1118 }
1119
1120 // Schedule an update to happen after all the regular taints are processed.
1121 // Note that new requests for the same operation ("ident") for the same object ("ID")
1122 // will replace any previous operation by the same object.
1123 public void PostTaintObject(String ident, uint ID, TaintCallback callback)
1124 {
1125 string IDAsString = ID.ToString();
1126 string uniqueIdent = ident + "-" + IDAsString;
1127 lock (_taintLock)
1128 {
1129 _postTaintOperations[uniqueIdent] = new TaintCallbackEntry(IDAsString, uniqueIdent, callback);
1130 }
1131
1132 return;
1133 }
1134
1135 // Taints that happen after the normal taint processing but before the simulation step.
1136 private void ProcessPostTaintTaints()
1137 {
1138 if (m_initialized && _postTaintOperations.Count > 0)
1139 {
1140 Dictionary<string, TaintCallbackEntry> oldList;
1141 lock (_taintLock)
1142 {
1143 oldList = _postTaintOperations;
1144 _postTaintOperations = new Dictionary<string, TaintCallbackEntry>();
1145 }
1146
1147 foreach (KeyValuePair<string,TaintCallbackEntry> kvp in oldList)
1148 {
1149 try
1150 {
1151 DetailLog("{0},BSScene.ProcessPostTaintTaints,doTaint,id={1}", DetailLogZero, kvp.Key); // DEBUG DEBUG DEBUG
1152 kvp.Value.callback();
1153 }
1154 catch (Exception e)
1155 {
1156 m_log.ErrorFormat("{0}: ProcessPostTaintTaints: {1}: Exception: {2}", LogHeader, kvp.Key, e);
1157 }
1158 }
1159 oldList.Clear();
1160 }
1161 }
1162
1163 // Only used for debugging. Does not change state of anything so locking is not necessary.
1164 public bool AssertInTaintTime(string whereFrom)
1165 {
1166 if (!InTaintTime)
1167 {
1168 DetailLog("{0},BSScene.AssertInTaintTime,NOT IN TAINT TIME,Region={1},Where={2}", DetailLogZero, RegionName, whereFrom);
1169 m_log.ErrorFormat("{0} NOT IN TAINT TIME!! Region={1}, Where={2}", LogHeader, RegionName, whereFrom);
1170 // Util.PrintCallStack(DetailLog);
1171 }
1172 return InTaintTime;
1173 }
1174
1175 #endregion // Taints
1176
1177 #region IPhysicsParameters
1178 // Get the list of parameters this physics engine supports
1179 public PhysParameterEntry[] GetParameterList()
1180 {
1181 BSParam.BuildParameterTable();
1182 return BSParam.SettableParameters;
1183 }
1184
1185 // Set parameter on a specific or all instances.
1186 // Return 'false' if not able to set the parameter.
1187 // Setting the value in the m_params block will change the value the physics engine
1188 // will use the next time since it's pinned and shared memory.
1189 // Some of the values require calling into the physics engine to get the new
1190 // value activated ('terrainFriction' for instance).
1191 public bool SetPhysicsParameter(string parm, string val, uint localID)
1192 {
1193 bool ret = false;
1194
1195 BSParam.ParameterDefnBase theParam;
1196 if (BSParam.TryGetParameter(parm, out theParam))
1197 {
1198 // Set the value in the C# code
1199 theParam.SetValue(this, val);
1200
1201 // Optionally set the parameter in the unmanaged code
1202 if (theParam.HasSetOnObject)
1203 {
1204 // update all the localIDs specified
1205 // If the local ID is APPLY_TO_NONE, just change the default value
1206 // If the localID is APPLY_TO_ALL change the default value and apply the new value to all the lIDs
1207 // If the localID is a specific object, apply the parameter change to only that object
1208 List<uint> objectIDs = new List<uint>();
1209 switch (localID)
1210 {
1211 case PhysParameterEntry.APPLY_TO_NONE:
1212 // This will cause a call into the physical world if some operation is specified (SetOnObject).
1213 objectIDs.Add(TERRAIN_ID);
1214 TaintedUpdateParameter(parm, objectIDs, val);
1215 break;
1216 case PhysParameterEntry.APPLY_TO_ALL:
1217 lock (PhysObjects) objectIDs = new List<uint>(PhysObjects.Keys);
1218 TaintedUpdateParameter(parm, objectIDs, val);
1219 break;
1220 default:
1221 // setting only one localID
1222 objectIDs.Add(localID);
1223 TaintedUpdateParameter(parm, objectIDs, val);
1224 break;
1225 }
1226 }
1227
1228 ret = true;
1229 }
1230 return ret;
1231 }
1232
1233 // schedule the actual updating of the paramter to when the phys engine is not busy
1234 private void TaintedUpdateParameter(string parm, List<uint> lIDs, string val)
1235 {
1236 string xval = val;
1237 List<uint> xlIDs = lIDs;
1238 string xparm = parm;
1239 TaintedObject(DetailLogZero, "BSScene.UpdateParameterSet", delegate() {
1240 BSParam.ParameterDefnBase thisParam;
1241 if (BSParam.TryGetParameter(xparm, out thisParam))
1242 {
1243 if (thisParam.HasSetOnObject)
1244 {
1245 foreach (uint lID in xlIDs)
1246 {
1247 BSPhysObject theObject = null;
1248 if (PhysObjects.TryGetValue(lID, out theObject))
1249 thisParam.SetOnObject(this, theObject);
1250 }
1251 }
1252 }
1253 });
1254 }
1255
1256 // Get parameter.
1257 // Return 'false' if not able to get the parameter.
1258 public bool GetPhysicsParameter(string parm, out string value)
1259 {
1260 string val = String.Empty;
1261 bool ret = false;
1262 BSParam.ParameterDefnBase theParam;
1263 if (BSParam.TryGetParameter(parm, out theParam))
1264 {
1265 val = theParam.GetValue(this);
1266 ret = true;
1267 }
1268 value = val;
1269 return ret;
1270 }
1271
1272 #endregion IPhysicsParameters
1273
1274 // Invoke the detailed logger and output something if it's enabled.
1275 public void DetailLog(string msg, params Object[] args)
1276 {
1277 PhysicsLogging.Write(msg, args);
1278 }
1279 // Used to fill in the LocalID when there isn't one. It's the correct number of characters.
1280 public const string DetailLogZero = "0000000000";
1281
1282}
1283}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
deleted file mode 100644
index ddbe80b..0000000
--- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
+++ /dev/null
@@ -1,250 +0,0 @@
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 copyright
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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using Nini.Config;
33using log4net;
34using OpenSim.Framework;
35using OpenMetaverse;
36
37namespace OpenSim.Region.Physics.Manager
38{
39 /// <summary>
40 /// Description of MyClass.
41 /// </summary>
42 public class PhysicsPluginManager
43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45
46 private Dictionary<string, IPhysicsPlugin> _PhysPlugins = new Dictionary<string, IPhysicsPlugin>();
47 private Dictionary<string, IMeshingPlugin> _MeshPlugins = new Dictionary<string, IMeshingPlugin>();
48
49 /// <summary>
50 /// Constructor.
51 /// </summary>
52 public PhysicsPluginManager()
53 {
54 // Load "plugins", that are hard coded and not existing in form of an external lib, and hence always
55 // available
56 IMeshingPlugin plugHard;
57 plugHard = new ZeroMesherPlugin();
58 _MeshPlugins.Add(plugHard.GetName(), plugHard);
59
60 m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName());
61 }
62
63 // Legacy method for simulators before extent was passed
64 public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName,
65 IConfigSource config, string regionName)
66 {
67 Vector3 extent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
68 return GetPhysicsScene(physEngineName, meshEngineName, config, regionName, extent);
69 }
70
71 /// <summary>
72 /// Get a physics scene for the given physics engine and mesher.
73 /// </summary>
74 /// <param name="physEngineName"></param>
75 /// <param name="meshEngineName"></param>
76 /// <param name="config"></param>
77 /// <returns></returns>
78 public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName,
79 IConfigSource config, string regionName, Vector3 regionExtent)
80 {
81 if (String.IsNullOrEmpty(physEngineName))
82 {
83 return PhysicsScene.Null;
84 }
85
86 if (String.IsNullOrEmpty(meshEngineName))
87 {
88 return PhysicsScene.Null;
89 }
90
91 IMesher meshEngine = null;
92 if (_MeshPlugins.ContainsKey(meshEngineName))
93 {
94 m_log.Info("[PHYSICS]: creating meshing engine " + meshEngineName);
95 meshEngine = _MeshPlugins[meshEngineName].GetMesher(config);
96 }
97 else
98 {
99 m_log.WarnFormat("[PHYSICS]: couldn't find meshingEngine: {0}", meshEngineName);
100 throw new ArgumentException(String.Format("couldn't find meshingEngine: {0}", meshEngineName));
101 }
102
103 if (_PhysPlugins.ContainsKey(physEngineName))
104 {
105 m_log.Info("[PHYSICS]: creating " + physEngineName);
106 PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName);
107 result.Initialise(meshEngine, config, regionExtent);
108 return result;
109 }
110 else
111 {
112 m_log.WarnFormat("[PHYSICS]: couldn't find physicsEngine: {0}", physEngineName);
113 throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}", physEngineName));
114 }
115 }
116
117 /// <summary>
118 /// Load all plugins in assemblies at the given path
119 /// </summary>
120 /// <param name="pluginsPath"></param>
121 public void LoadPluginsFromAssemblies(string assembliesPath)
122 {
123 // Walk all assemblies (DLLs effectively) and see if they are home
124 // of a plugin that is of interest for us
125 string[] pluginFiles = Directory.GetFiles(assembliesPath, "*.dll");
126
127 for (int i = 0; i < pluginFiles.Length; i++)
128 {
129 LoadPluginsFromAssembly(pluginFiles[i]);
130 }
131 }
132
133 /// <summary>
134 /// Load plugins from an assembly at the given path
135 /// </summary>
136 /// <param name="assemblyPath"></param>
137 public void LoadPluginsFromAssembly(string assemblyPath)
138 {
139 // TODO / NOTE
140 // The assembly named 'OpenSim.Region.Physics.BasicPhysicsPlugin' was loaded from
141 // 'file:///C:/OpenSim/trunk2/bin/Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll'
142 // using the LoadFrom context. The use of this context can result in unexpected behavior
143 // for serialization, casting and dependency resolution. In almost all cases, it is recommended
144 // that the LoadFrom context be avoided. This can be done by installing assemblies in the
145 // Global Assembly Cache or in the ApplicationBase directory and using Assembly.
146 // Load when explicitly loading assemblies.
147 Assembly pluginAssembly = null;
148 Type[] types = null;
149
150 try
151 {
152 pluginAssembly = Assembly.LoadFrom(assemblyPath);
153 }
154 catch (Exception ex)
155 {
156 m_log.Error("[PHYSICS]: Failed to load plugin from " + assemblyPath, ex);
157 }
158
159 if (pluginAssembly != null)
160 {
161 try
162 {
163 types = pluginAssembly.GetTypes();
164 }
165 catch (ReflectionTypeLoadException ex)
166 {
167 m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath + ": " +
168 ex.LoaderExceptions[0].Message, ex);
169 }
170 catch (Exception ex)
171 {
172 m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath, ex);
173 }
174
175 if (types != null)
176 {
177 foreach (Type pluginType in types)
178 {
179 if (pluginType.IsPublic)
180 {
181 if (!pluginType.IsAbstract)
182 {
183 Type physTypeInterface = pluginType.GetInterface("IPhysicsPlugin");
184
185 if (physTypeInterface != null)
186 {
187 IPhysicsPlugin plug =
188 (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
189 plug.Init();
190 if (!_PhysPlugins.ContainsKey(plug.GetName()))
191 {
192 _PhysPlugins.Add(plug.GetName(), plug);
193 m_log.Info("[PHYSICS]: Added physics engine: " + plug.GetName());
194 }
195 }
196
197 Type meshTypeInterface = pluginType.GetInterface("IMeshingPlugin");
198
199 if (meshTypeInterface != null)
200 {
201 IMeshingPlugin plug =
202 (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
203 if (!_MeshPlugins.ContainsKey(plug.GetName()))
204 {
205 _MeshPlugins.Add(plug.GetName(), plug);
206 m_log.Info("[PHYSICS]: Added meshing engine: " + plug.GetName());
207 }
208 }
209
210 physTypeInterface = null;
211 meshTypeInterface = null;
212 }
213 }
214 }
215 }
216 }
217
218 pluginAssembly = null;
219 }
220
221 //---
222 public static void PhysicsPluginMessage(string message, bool isWarning)
223 {
224 if (isWarning)
225 {
226 m_log.Warn("[PHYSICS]: " + message);
227 }
228 else
229 {
230 m_log.Info("[PHYSICS]: " + message);
231 }
232 }
233
234 //---
235 }
236
237 public interface IPhysicsPlugin
238 {
239 bool Init();
240 PhysicsScene GetScene(String sceneIdentifier);
241 string GetName();
242 void Dispose();
243 }
244
245 public interface IMeshingPlugin
246 {
247 string GetName();
248 IMesher GetMesher(IConfigSource config);
249 }
250}
diff --git a/OpenSim/Region/Physics/Meshing/Properties/AssemblyInfo.cs b/OpenSim/Region/Physics/Meshing/Properties/AssemblyInfo.cs
deleted file mode 100644
index ec968c0..0000000
--- a/OpenSim/Region/Physics/Meshing/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Region.Physics.Meshing")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("http://opensimulator.org")]
12[assembly: AssemblyProduct("OpenSim")]
13[assembly: AssemblyCopyright("OpenSimulator developers")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("4b7e35c2-a9dd-4b10-b778-eb417f4f6884")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32[assembly: AssemblyVersion("0.8.2.*")]
33
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
deleted file mode 100644
index 7e652fc..0000000
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ /dev/null
@@ -1,90 +0,0 @@
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 copyright
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Runtime.InteropServices;
32using System.Threading;
33using System.IO;
34using System.Diagnostics;
35using log4net;
36using Nini.Config;
37using Ode.NET;
38using OpenSim.Framework;
39using OpenSim.Region.Physics.Manager;
40using OpenMetaverse;
41
42namespace OpenSim.Region.Physics.OdePlugin
43{
44 /// <summary>
45 /// ODE plugin
46 /// </summary>
47 public class OdePlugin : IPhysicsPlugin
48 {
49// private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
50
51 private OdeScene m_scene;
52
53 public bool Init()
54 {
55 return true;
56 }
57
58 public PhysicsScene GetScene(String sceneIdentifier)
59 {
60 if (m_scene == null)
61 {
62 // We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether
63 // it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports
64 // will find it already loaded later on.
65 //
66 // This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be
67 // controlled in Ode.NET.dll.config
68 if (Util.IsWindows())
69 Util.LoadArchSpecificWindowsDll("ode.dll");
70
71 // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
72 // http://opensimulator.org/mantis/view.php?id=2750).
73 d.InitODE();
74
75 m_scene = new OdeScene(GetName(), sceneIdentifier);
76 }
77
78 return m_scene;
79 }
80
81 public string GetName()
82 {
83 return ("OpenDynamicsEngine");
84 }
85
86 public void Dispose()
87 {
88 }
89 }
90} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
deleted file mode 100644
index ed086dd..0000000
--- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
+++ /dev/null
@@ -1,64 +0,0 @@
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 copyright
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
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager;
33
34namespace OpenSim.Region.Physics.POSPlugin
35{
36 /// <summary>
37 /// for now will be a very POS physics engine
38 /// </summary>
39 public class POSPlugin : IPhysicsPlugin
40 {
41 public POSPlugin()
42 {
43 }
44
45 public bool Init()
46 {
47 return true;
48 }
49
50 public PhysicsScene GetScene(string sceneIdentifier)
51 {
52 return new POSScene(GetName(), sceneIdentifier);
53 }
54
55 public string GetName()
56 {
57 return ("POS");
58 }
59
60 public void Dispose()
61 {
62 }
63 }
64}
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/AssemblyInfo.cs
index 7d054dd..1765ae0 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/PhysicsModules/BasicPhysics/AssemblyInfo.cs
@@ -27,6 +27,7 @@
27 27
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30using Mono.Addins;
30 31
31// Information about this assembly is defined by the following 32// Information about this assembly is defined by the following
32// attributes. 33// attributes.
@@ -34,11 +35,11 @@ using System.Runtime.InteropServices;
34// change them to the information which is associated with the assembly 35// change them to the information which is associated with the assembly
35// you compile. 36// you compile.
36 37
37[assembly : AssemblyTitle("BasicPhysicsPlugin")] 38[assembly : AssemblyTitle("BasicPhysicsModule")]
38[assembly : AssemblyDescription("")] 39[assembly : AssemblyDescription("")]
39[assembly : AssemblyConfiguration("")] 40[assembly : AssemblyConfiguration("")]
40[assembly : AssemblyCompany("http://opensimulator.org")] 41[assembly : AssemblyCompany("http://opensimulator.org")]
41[assembly : AssemblyProduct("BasicPhysicsPlugin")] 42[assembly : AssemblyProduct("BasicPhysicsModule")]
42[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] 43[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")]
43[assembly : AssemblyTrademark("")] 44[assembly : AssemblyTrademark("")]
44[assembly : AssemblyCulture("")] 45[assembly : AssemblyCulture("")]
@@ -56,3 +57,6 @@ using System.Runtime.InteropServices;
56// numbers with the '*' character (the default): 57// numbers with the '*' character (the default):
57 58
58[assembly : AssemblyVersion("0.8.2.*")] 59[assembly : AssemblyVersion("0.8.2.*")]
60
61[assembly: Addin("OpenSim.Region.PhysicsModule.BasicPhysics", OpenSim.VersionInfo.VersionNumber)]
62[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsActor.cs
index 43fba7b..e7b30ba 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
+++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsActor.cs
@@ -30,9 +30,9 @@ using System.Collections.Generic;
30using Nini.Config; 30using Nini.Config;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34 34
35namespace OpenSim.Region.Physics.BasicPhysicsPlugin 35namespace OpenSim.Region.PhysicsModule.BasicPhysics
36{ 36{
37 public class BasicActor : PhysicsActor 37 public class BasicActor : PhysicsActor
38 { 38 {
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPrim.cs
index dfe4c19..5383f1b 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs
+++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPrim.cs
@@ -30,9 +30,9 @@ using System.Collections.Generic;
30using Nini.Config; 30using Nini.Config;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34 34
35namespace OpenSim.Region.Physics.BasicPhysicsPlugin 35namespace OpenSim.Region.PhysicsModule.BasicPhysics
36{ 36{
37 public class BasicPhysicsPrim : PhysicsActor 37 public class BasicPhysicsPrim : PhysicsActor
38 { 38 {
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs
index 0d28c8e..ac2c1f3 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
+++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs
@@ -28,11 +28,14 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using Nini.Config; 30using Nini.Config;
31using Mono.Addins;
31using OpenMetaverse; 32using OpenMetaverse;
32using OpenSim.Framework; 33using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.PhysicsModules.SharedBase;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces;
34 37
35namespace OpenSim.Region.Physics.BasicPhysicsPlugin 38namespace OpenSim.Region.PhysicsModule.BasicPhysics
36{ 39{
37 /// <summary> 40 /// <summary>
38 /// This is an incomplete extremely basic physics implementation 41 /// This is an incomplete extremely basic physics implementation
@@ -41,32 +44,74 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
41 /// Not useful for anything at the moment apart from some regression testing in other components where some form 44 /// Not useful for anything at the moment apart from some regression testing in other components where some form
42 /// of physics plugin is needed. 45 /// of physics plugin is needed.
43 /// </remarks> 46 /// </remarks>
44 public class BasicScene : PhysicsScene 47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BasicPhysicsScene")]
48 public class BasicScene : PhysicsScene, INonSharedRegionModule
45 { 49 {
46 private List<BasicActor> _actors = new List<BasicActor>(); 50 private List<BasicActor> _actors = new List<BasicActor>();
47 private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>(); 51 private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>();
48 private float[] _heightMap; 52 private float[] _heightMap;
49 private Vector3 m_regionExtent; 53 private Vector3 m_regionExtent;
50 54
55 private bool m_Enabled = false;
56
51 //protected internal string sceneIdentifier; 57 //protected internal string sceneIdentifier;
58 #region INonSharedRegionModule
59 public string Name
60 {
61 get { return "basicphysics"; }
62 }
52 63
53 public BasicScene(string engineType, string _sceneIdentifier) 64 public Type ReplaceableInterface
54 { 65 {
55 EngineType = engineType; 66 get { return null; }
56 Name = EngineType + "/" + _sceneIdentifier;
57 //sceneIdentifier = _sceneIdentifier;
58 } 67 }
59 68
60 public override void Initialise(IMesher meshmerizer, IConfigSource config) 69 public void Initialise(IConfigSource source)
61 { 70 {
62 throw new Exception("Should not be called."); 71 // TODO: Move this out of Startup
72 IConfig config = source.Configs["Startup"];
73 if (config != null)
74 {
75 string physics = config.GetString("physics", string.Empty);
76 if (physics == Name)
77 m_Enabled = true;
78 }
79
63 } 80 }
64 81
65 public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) 82 public void Close()
66 { 83 {
67 m_regionExtent = regionExtent;
68 } 84 }
69 85
86 public void AddRegion(Scene scene)
87 {
88 if (!m_Enabled)
89 return;
90
91 EngineType = Name;
92 PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName;
93
94 scene.RegisterModuleInterface<PhysicsScene>(this);
95 m_regionExtent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
96 base.Initialise(scene.PhysicsRequestAsset,
97 (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[scene.RegionInfo.RegionSizeX * scene.RegionInfo.RegionSizeY]),
98 (float)scene.RegionInfo.RegionSettings.WaterHeight);
99
100 }
101
102 public void RemoveRegion(Scene scene)
103 {
104 if (!m_Enabled)
105 return;
106 }
107
108 public void RegionLoaded(Scene scene)
109 {
110 if (!m_Enabled)
111 return;
112 }
113 #endregion
114
70 public override void Dispose() {} 115 public override void Dispose() {}
71 116
72 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 117 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
@@ -119,8 +164,8 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
119 Vector3 actorPosition = actor.Position; 164 Vector3 actorPosition = actor.Position;
120 Vector3 actorVelocity = actor.Velocity; 165 Vector3 actorVelocity = actor.Velocity;
121 166
122// Console.WriteLine( 167 //Console.WriteLine(
123// "Processing actor {0}, starting pos {1}, starting vel {2}", i, actorPosition, actorVelocity); 168 // "Processing actor {0}, starting pos {1}, starting vel {2}", i, actorPosition, actorVelocity);
124 169
125 actorPosition.X += actor.Velocity.X * timeStep; 170 actorPosition.X += actor.Velocity.X * timeStep;
126 actorPosition.Y += actor.Velocity.Y * timeStep; 171 actorPosition.Y += actor.Velocity.Y * timeStep;
@@ -206,5 +251,6 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
206 Dictionary<uint, float> returncolliders = new Dictionary<uint, float>(); 251 Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
207 return returncolliders; 252 return returncolliders;
208 } 253 }
254
209 } 255 }
210} 256}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/PhysicsModules/BulletS/BSAPIUnman.cs
index 3bd81d4..c4a923c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSAPIUnman.cs
@@ -35,7 +35,7 @@ using OpenSim.Framework;
35 35
36using OpenMetaverse; 36using OpenMetaverse;
37 37
38namespace OpenSim.Region.Physics.BulletSPlugin 38namespace OpenSim.Region.PhysicsModule.BulletS
39{ 39{
40public sealed class BSAPIUnman : BSAPITemplate 40public sealed class BSAPIUnman : BSAPITemplate
41{ 41{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/PhysicsModules/BulletS/BSAPIXNA.cs
index 741f8db..887311d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSAPIXNA.cs
@@ -40,7 +40,7 @@ using BulletXNA.BulletCollision;
40using BulletXNA.BulletDynamics; 40using BulletXNA.BulletDynamics;
41using BulletXNA.BulletCollision.CollisionDispatch; 41using BulletXNA.BulletCollision.CollisionDispatch;
42 42
43namespace OpenSim.Region.Physics.BulletSPlugin 43namespace OpenSim.Region.PhysicsModule.BulletS
44{ 44{
45public sealed class BSAPIXNA : BSAPITemplate 45public sealed class BSAPIXNA : BSAPITemplate
46{ 46{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs
index bde4557..0191893 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs
@@ -31,11 +31,11 @@ using System.Linq;
31using System.Text; 31using System.Text;
32 32
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.PhysicsModules.SharedBase;
35 35
36using OMV = OpenMetaverse; 36using OMV = OpenMetaverse;
37 37
38namespace OpenSim.Region.Physics.BulletSPlugin 38namespace OpenSim.Region.PhysicsModule.BulletS
39{ 39{
40public class BSActorAvatarMove : BSActor 40public class BSActorAvatarMove : BSActor
41{ 41{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorHover.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorHover.cs
index e54c27b..7ff171e 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSActorHover.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorHover.cs
@@ -30,11 +30,11 @@ using System.Collections.Generic;
30using System.Linq; 30using System.Linq;
31using System.Text; 31using System.Text;
32 32
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34 34
35using OMV = OpenMetaverse; 35using OMV = OpenMetaverse;
36 36
37namespace OpenSim.Region.Physics.BulletSPlugin 37namespace OpenSim.Region.PhysicsModule.BulletS
38{ 38{
39public class BSActorHover : BSActor 39public class BSActorHover : BSActor
40{ 40{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorLockAxis.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorLockAxis.cs
index 3b3c161..78c1b6a 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSActorLockAxis.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorLockAxis.cs
@@ -32,7 +32,7 @@ using System.Text;
32 32
33using OMV = OpenMetaverse; 33using OMV = OpenMetaverse;
34 34
35namespace OpenSim.Region.Physics.BulletSPlugin 35namespace OpenSim.Region.PhysicsModule.BulletS
36{ 36{
37public class BSActorLockAxis : BSActor 37public class BSActorLockAxis : BSActor
38{ 38{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorMoveToTarget.cs
index 1145006..3db8f2c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorMoveToTarget.cs
@@ -30,11 +30,11 @@ using System.Collections.Generic;
30using System.Linq; 30using System.Linq;
31using System.Text; 31using System.Text;
32 32
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34 34
35using OMV = OpenMetaverse; 35using OMV = OpenMetaverse;
36 36
37namespace OpenSim.Region.Physics.BulletSPlugin 37namespace OpenSim.Region.PhysicsModule.BulletS
38{ 38{
39public class BSActorMoveToTarget : BSActor 39public class BSActorMoveToTarget : BSActor
40{ 40{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorSetForce.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorSetForce.cs
index 4e81363..ecb4b7f 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSActorSetForce.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorSetForce.cs
@@ -30,11 +30,11 @@ using System.Collections.Generic;
30using System.Linq; 30using System.Linq;
31using System.Text; 31using System.Text;
32 32
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34 34
35using OMV = OpenMetaverse; 35using OMV = OpenMetaverse;
36 36
37namespace OpenSim.Region.Physics.BulletSPlugin 37namespace OpenSim.Region.PhysicsModule.BulletS
38{ 38{
39public class BSActorSetForce : BSActor 39public class BSActorSetForce : BSActor
40{ 40{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorSetTorque.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorSetTorque.cs
index 79e1d38..a1cf4db 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSActorSetTorque.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorSetTorque.cs
@@ -30,11 +30,11 @@ using System.Collections.Generic;
30using System.Linq; 30using System.Linq;
31using System.Text; 31using System.Text;
32 32
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34 34
35using OMV = OpenMetaverse; 35using OMV = OpenMetaverse;
36 36
37namespace OpenSim.Region.Physics.BulletSPlugin 37namespace OpenSim.Region.PhysicsModule.BulletS
38{ 38{
39public class BSActorSetTorque : BSActor 39public class BSActorSetTorque : BSActor
40{ 40{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActors.cs
index 7f45e2c..851347b 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSActors.cs
@@ -28,7 +28,7 @@ using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Text; 29using System.Text;
30 30
31namespace OpenSim.Region.Physics.BulletSPlugin 31namespace OpenSim.Region.PhysicsModule.BulletS
32{ 32{
33public class BSActorCollection 33public class BSActorCollection
34{ 34{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/PhysicsModules/BulletS/BSApiTemplate.cs
index 8491c0f..7756b10 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSApiTemplate.cs
@@ -31,7 +31,7 @@ using System.Security;
31using System.Text; 31using System.Text;
32using OpenMetaverse; 32using OpenMetaverse;
33 33
34namespace OpenSim.Region.Physics.BulletSPlugin { 34namespace OpenSim.Region.PhysicsModule.BulletS {
35 35
36 // Constraint type values as defined by Bullet 36 // Constraint type values as defined by Bullet
37public enum ConstraintType : int 37public enum ConstraintType : int
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs
index 9c3f160..83fc3a6 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs
@@ -30,9 +30,9 @@ using System.Reflection;
30using log4net; 30using log4net;
31using OMV = OpenMetaverse; 31using OMV = OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34 34
35namespace OpenSim.Region.Physics.BulletSPlugin 35namespace OpenSim.Region.PhysicsModule.BulletS
36{ 36{
37public sealed class BSCharacter : BSPhysObject 37public sealed class BSCharacter : BSPhysObject
38{ 38{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/PhysicsModules/BulletS/BSConstraint.cs
index b47e9a8..e42e868 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSConstraint.cs
@@ -29,7 +29,7 @@ using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32namespace OpenSim.Region.Physics.BulletSPlugin 32namespace OpenSim.Region.PhysicsModule.BulletS
33{ 33{
34 34
35public abstract class BSConstraint : IDisposable 35public abstract class BSConstraint : IDisposable
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs b/OpenSim/Region/PhysicsModules/BulletS/BSConstraint6Dof.cs
index 7fcb75c..4bcde2b 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSConstraint6Dof.cs
@@ -29,7 +29,7 @@ using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32namespace OpenSim.Region.Physics.BulletSPlugin 32namespace OpenSim.Region.PhysicsModule.BulletS
33{ 33{
34 34
35public class BSConstraint6Dof : BSConstraint 35public class BSConstraint6Dof : BSConstraint
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs b/OpenSim/Region/PhysicsModules/BulletS/BSConstraintCollection.cs
index 5c8d94e..5746ac1 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSConstraintCollection.cs
@@ -30,7 +30,7 @@ using System.Text;
30using log4net; 30using log4net;
31using OpenMetaverse; 31using OpenMetaverse;
32 32
33namespace OpenSim.Region.Physics.BulletSPlugin 33namespace OpenSim.Region.PhysicsModule.BulletS
34{ 34{
35 35
36public sealed class BSConstraintCollection : IDisposable 36public sealed class BSConstraintCollection : IDisposable
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs b/OpenSim/Region/PhysicsModules/BulletS/BSConstraintConeTwist.cs
index 7a76a9a..e7566a8 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintConeTwist.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSConstraintConeTwist.cs
@@ -29,7 +29,7 @@ using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32namespace OpenSim.Region.Physics.BulletSPlugin 32namespace OpenSim.Region.PhysicsModule.BulletS
33{ 33{
34 34
35public sealed class BSConstraintConeTwist : BSConstraint 35public sealed class BSConstraintConeTwist : BSConstraint
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintHinge.cs b/OpenSim/Region/PhysicsModules/BulletS/BSConstraintHinge.cs
index ed89f63..d20538d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintHinge.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSConstraintHinge.cs
@@ -29,7 +29,7 @@ using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32namespace OpenSim.Region.Physics.BulletSPlugin 32namespace OpenSim.Region.PhysicsModule.BulletS
33{ 33{
34 34
35public sealed class BSConstraintHinge : BSConstraint 35public sealed class BSConstraintHinge : BSConstraint
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs b/OpenSim/Region/PhysicsModules/BulletS/BSConstraintSlider.cs
index 37cfa07..83d42af 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSlider.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSConstraintSlider.cs
@@ -29,7 +29,7 @@ using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32namespace OpenSim.Region.Physics.BulletSPlugin 32namespace OpenSim.Region.PhysicsModule.BulletS
33{ 33{
34 34
35public sealed class BSConstraintSlider : BSConstraint 35public sealed class BSConstraintSlider : BSConstraint
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs b/OpenSim/Region/PhysicsModules/BulletS/BSConstraintSpring.cs
index 8e7ddff..563a1b1 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSConstraintSpring.cs
@@ -29,7 +29,7 @@ using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32namespace OpenSim.Region.Physics.BulletSPlugin 32namespace OpenSim.Region.PhysicsModule.BulletS
33{ 33{
34 34
35public sealed class BSConstraintSpring : BSConstraint6Dof 35public sealed class BSConstraintSpring : BSConstraint6Dof
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/PhysicsModules/BulletS/BSDynamics.cs
index c6d6331..0fc5577 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSDynamics.cs
@@ -36,9 +36,9 @@ using System.Reflection;
36using System.Runtime.InteropServices; 36using System.Runtime.InteropServices;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.PhysicsModules.SharedBase;
40 40
41namespace OpenSim.Region.Physics.BulletSPlugin 41namespace OpenSim.Region.PhysicsModule.BulletS
42{ 42{
43 public sealed class BSDynamics : BSActor 43 public sealed class BSDynamics : BSActor
44 { 44 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/PhysicsModules/BulletS/BSLinkset.cs
index 87eba33..8312239 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSLinkset.cs
@@ -30,7 +30,7 @@ using System.Text;
30 30
31using OMV = OpenMetaverse; 31using OMV = OpenMetaverse;
32 32
33namespace OpenSim.Region.Physics.BulletSPlugin 33namespace OpenSim.Region.PhysicsModule.BulletS
34{ 34{
35 35
36public abstract class BSLinkset 36public abstract class BSLinkset
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/PhysicsModules/BulletS/BSLinksetCompound.cs
index cae9efa..953ddee 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSLinksetCompound.cs
@@ -32,7 +32,7 @@ using OpenSim.Framework;
32 32
33using OMV = OpenMetaverse; 33using OMV = OpenMetaverse;
34 34
35namespace OpenSim.Region.Physics.BulletSPlugin 35namespace OpenSim.Region.PhysicsModule.BulletS
36{ 36{
37 37
38public sealed class BSLinksetCompound : BSLinkset 38public sealed class BSLinksetCompound : BSLinkset
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/PhysicsModules/BulletS/BSLinksetConstraints.cs
index 4384cdc..c4b4c86 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSLinksetConstraints.cs
@@ -28,11 +28,9 @@ using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Text; 29using System.Text;
30 30
31using OpenSim.Region.OptionalModules.Scripting;
32
33using OMV = OpenMetaverse; 31using OMV = OpenMetaverse;
34 32
35namespace OpenSim.Region.Physics.BulletSPlugin 33namespace OpenSim.Region.PhysicsModule.BulletS
36{ 34{
37public sealed class BSLinksetConstraints : BSLinkset 35public sealed class BSLinksetConstraints : BSLinkset
38{ 36{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMaterials.cs b/OpenSim/Region/PhysicsModules/BulletS/BSMaterials.cs
index ee77d6e..0e44d03 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSMaterials.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSMaterials.cs
@@ -30,7 +30,7 @@ using System.Text;
30using System.Reflection; 30using System.Reflection;
31using Nini.Config; 31using Nini.Config;
32 32
33namespace OpenSim.Region.Physics.BulletSPlugin 33namespace OpenSim.Region.PhysicsModule.BulletS
34{ 34{
35 35
36public struct MaterialAttributes 36public struct MaterialAttributes
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/PhysicsModules/BulletS/BSMotors.cs
index 7693195..2faf2d4 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSMotors.cs
@@ -31,7 +31,7 @@ using System.Text;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33 33
34namespace OpenSim.Region.Physics.BulletSPlugin 34namespace OpenSim.Region.PhysicsModule.BulletS
35{ 35{
36public abstract class BSMotor 36public abstract class BSMotor
37{ 37{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/PhysicsModules/BulletS/BSParam.cs
index 6d46fe6..c296008 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSParam.cs
@@ -29,12 +29,12 @@ using System.Collections.Generic;
29using System.Reflection; 29using System.Reflection;
30using System.Text; 30using System.Text;
31 31
32using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.PhysicsModules.SharedBase;
33 33
34using OpenMetaverse; 34using OpenMetaverse;
35using Nini.Config; 35using Nini.Config;
36 36
37namespace OpenSim.Region.Physics.BulletSPlugin 37namespace OpenSim.Region.PhysicsModule.BulletS
38{ 38{
39public static class BSParam 39public static class BSParam
40{ 40{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs
index 90da7a6..da3fc18 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs
@@ -30,9 +30,9 @@ using System.Text;
30 30
31using OMV = OpenMetaverse; 31using OMV = OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34 34
35namespace OpenSim.Region.Physics.BulletSPlugin 35namespace OpenSim.Region.PhysicsModule.BulletS
36{ 36{
37/* 37/*
38 * Class to wrap all objects. 38 * Class to wrap all objects.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
index a00991f..6f27ac7 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
@@ -32,11 +32,10 @@ using System.Xml;
32using log4net; 32using log4net;
33using OMV = OpenMetaverse; 33using OMV = OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Physics.Manager; 35using OpenSim.Region.PhysicsModules.SharedBase;
36using OpenSim.Region.Physics.ConvexDecompositionDotNet; 36using OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet;
37using OpenSim.Region.OptionalModules.Scripting; // for ExtendedPhysics
38 37
39namespace OpenSim.Region.Physics.BulletSPlugin 38namespace OpenSim.Region.PhysicsModule.BulletS
40{ 39{
41 40
42 [Serializable] 41 [Serializable]
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPrimDisplaced.cs
index 2eb1440..d8ed56b 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSPrimDisplaced.cs
@@ -31,11 +31,11 @@ using System.Reflection;
31using System.Runtime.InteropServices; 31using System.Runtime.InteropServices;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.PhysicsModules.SharedBase;
35 35
36using OMV = OpenMetaverse; 36using OMV = OpenMetaverse;
37 37
38namespace OpenSim.Region.Physics.BulletSPlugin 38namespace OpenSim.Region.PhysicsModule.BulletS
39{ 39{
40public class BSPrimDisplaced : BSPrim 40public class BSPrimDisplaced : BSPrim
41{ 41{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPrimLinkable.cs
index 430d645..55b5da0 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSPrimLinkable.cs
@@ -30,11 +30,10 @@ using System.Linq;
30using System.Text; 30using System.Text;
31 31
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.OptionalModules.Scripting;
34 33
35using OMV = OpenMetaverse; 34using OMV = OpenMetaverse;
36 35
37namespace OpenSim.Region.Physics.BulletSPlugin 36namespace OpenSim.Region.PhysicsModule.BulletS
38{ 37{
39public class BSPrimLinkable : BSPrimDisplaced 38public class BSPrimLinkable : BSPrimDisplaced
40{ 39{
@@ -72,7 +71,7 @@ public class BSPrimLinkable : BSPrimDisplaced
72 base.Destroy(); 71 base.Destroy();
73 } 72 }
74 73
75 public override void link(Manager.PhysicsActor obj) 74 public override void link(OpenSim.Region.PhysicsModules.SharedBase.PhysicsActor obj)
76 { 75 {
77 BSPrimLinkable parent = obj as BSPrimLinkable; 76 BSPrimLinkable parent = obj as BSPrimLinkable;
78 if (parent != null) 77 if (parent != null)
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs b/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs
new file mode 100644
index 0000000..452ce55
--- /dev/null
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs
@@ -0,0 +1,1333 @@
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.Linq;
30using System.Reflection;
31using System.Runtime.InteropServices;
32using System.Text;
33using System.Threading;
34using OpenSim.Framework;
35using OpenSim.Framework.Monitoring;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.PhysicsModules.SharedBase;
39using Nini.Config;
40using log4net;
41using OpenMetaverse;
42using Mono.Addins;
43
44namespace OpenSim.Region.PhysicsModule.BulletS
45{
46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BulletSPhysicsScene")]
47 public sealed class BSScene : PhysicsScene, IPhysicsParameters, INonSharedRegionModule
48 {
49 internal static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
50 internal static readonly string LogHeader = "[BULLETS SCENE]";
51
52 private bool m_Enabled = false;
53 private IConfigSource m_Config;
54
55 // The name of the region we're working for.
56 public string RegionName { get; private set; }
57
58 public string BulletSimVersion = "?";
59
60 // The handle to the underlying managed or unmanaged version of Bullet being used.
61 public string BulletEngineName { get; private set; }
62 public BSAPITemplate PE;
63
64 // If the physics engine is running on a separate thread
65 public Thread m_physicsThread;
66
67 public Dictionary<uint, BSPhysObject> PhysObjects;
68 public BSShapeCollection Shapes;
69
70 // Keeping track of the objects with collisions so we can report begin and end of a collision
71 public HashSet<BSPhysObject> ObjectsWithCollisions = new HashSet<BSPhysObject>();
72 public HashSet<BSPhysObject> ObjectsWithNoMoreCollisions = new HashSet<BSPhysObject>();
73
74 // All the collision processing is protected with this lock object
75 public Object CollisionLock = new Object();
76
77 // Properties are updated here
78 public Object UpdateLock = new Object();
79 public HashSet<BSPhysObject> ObjectsWithUpdates = new HashSet<BSPhysObject>();
80
81 // Keep track of all the avatars so we can send them a collision event
82 // every tick so OpenSim will update its animation.
83 private HashSet<BSPhysObject> AvatarsInScene = new HashSet<BSPhysObject>();
84 private Object AvatarsInSceneLock = new Object();
85
86 // let my minuions use my logger
87 public ILog Logger { get { return m_log; } }
88
89 public IMesher mesher;
90 public uint WorldID { get; private set; }
91 public BulletWorld World { get; private set; }
92
93 // All the constraints that have been allocated in this instance.
94 public BSConstraintCollection Constraints { get; private set; }
95
96 // Simulation parameters
97 //internal float m_physicsStepTime; // if running independently, the interval simulated by default
98
99 internal int m_maxSubSteps;
100 internal float m_fixedTimeStep;
101
102 internal float m_simulatedTime; // the time simulated previously. Used for physics framerate calc.
103
104 internal long m_simulationStep = 0; // The current simulation step.
105 public long SimulationStep { get { return m_simulationStep; } }
106 // A number to use for SimulationStep that is probably not any step value
107 // Used by the collision code (which remembers the step when a collision happens) to remember not any simulation step.
108 public static long NotASimulationStep = -1234;
109
110 internal float LastTimeStep { get; private set; } // The simulation time from the last invocation of Simulate()
111
112 internal float NominalFrameRate { get; set; } // Parameterized ideal frame rate that simulation is scaled to
113
114 // Physical objects can register for prestep or poststep events
115 public delegate void PreStepAction(float timeStep);
116 public delegate void PostStepAction(float timeStep);
117 public event PreStepAction BeforeStep;
118 public event PostStepAction AfterStep;
119
120 // A value of the time 'now' so all the collision and update routines do not have to get their own
121 // Set to 'now' just before all the prims and actors are called for collisions and updates
122 public int SimulationNowTime { get; private set; }
123
124 // True if initialized and ready to do simulation steps
125 private bool m_initialized = false;
126
127 // Flag which is true when processing taints.
128 // Not guaranteed to be correct all the time (don't depend on this) but good for debugging.
129 public bool InTaintTime { get; private set; }
130
131 // Pinned memory used to pass step information between managed and unmanaged
132 internal int m_maxCollisionsPerFrame;
133 internal CollisionDesc[] m_collisionArray;
134
135 internal int m_maxUpdatesPerFrame;
136 internal EntityProperties[] m_updateArray;
137
138 /// <summary>
139 /// Used to control physics simulation timing if Bullet is running on its own thread.
140 /// </summary>
141 private ManualResetEvent m_updateWaitEvent;
142
143 public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero
144 public const uint GROUNDPLANE_ID = 1;
145 public const uint CHILDTERRAIN_ID = 2; // Terrain allocated based on our mega-prim childre start here
146
147 public float SimpleWaterLevel { get; set; }
148 public BSTerrainManager TerrainManager { get; private set; }
149
150 public ConfigurationParameters Params
151 {
152 get { return UnmanagedParams[0]; }
153 }
154 public Vector3 DefaultGravity
155 {
156 get { return new Vector3(0f, 0f, Params.gravity); }
157 }
158 // Just the Z value of the gravity
159 public float DefaultGravityZ
160 {
161 get { return Params.gravity; }
162 }
163
164 // When functions in the unmanaged code must be called, it is only
165 // done at a known time just before the simulation step. The taint
166 // system saves all these function calls and executes them in
167 // order before the simulation.
168 public delegate void TaintCallback();
169 private struct TaintCallbackEntry
170 {
171 public String originator;
172 public String ident;
173 public TaintCallback callback;
174 public TaintCallbackEntry(string pIdent, TaintCallback pCallBack)
175 {
176 originator = BSScene.DetailLogZero;
177 ident = pIdent;
178 callback = pCallBack;
179 }
180 public TaintCallbackEntry(string pOrigin, string pIdent, TaintCallback pCallBack)
181 {
182 originator = pOrigin;
183 ident = pIdent;
184 callback = pCallBack;
185 }
186 }
187 private Object _taintLock = new Object(); // lock for using the next object
188 private List<TaintCallbackEntry> _taintOperations;
189 private Dictionary<string, TaintCallbackEntry> _postTaintOperations;
190 private List<TaintCallbackEntry> _postStepOperations;
191
192 // A pointer to an instance if this structure is passed to the C++ code
193 // Used to pass basic configuration values to the unmanaged code.
194 internal ConfigurationParameters[] UnmanagedParams;
195
196 // Sometimes you just have to log everything.
197 public LogWriter PhysicsLogging;
198 private bool m_physicsLoggingEnabled;
199 private string m_physicsLoggingDir;
200 private string m_physicsLoggingPrefix;
201 private int m_physicsLoggingFileMinutes;
202 private bool m_physicsLoggingDoFlush;
203 private bool m_physicsPhysicalDumpEnabled;
204 public int PhysicsMetricDumpFrames { get; set; }
205 // 'true' of the vehicle code is to log lots of details
206 public bool VehicleLoggingEnabled { get; private set; }
207 public bool VehiclePhysicalLoggingEnabled { get; private set; }
208
209 #region INonSharedRegionModule
210 public string Name
211 {
212 get { return "BulletSim"; }
213 }
214
215 public Type ReplaceableInterface
216 {
217 get { return null; }
218 }
219
220 public void Initialise(IConfigSource source)
221 {
222 // TODO: Move this out of Startup
223 IConfig config = source.Configs["Startup"];
224 if (config != null)
225 {
226 string physics = config.GetString("physics", string.Empty);
227 if (physics == Name)
228 {
229 m_Enabled = true;
230 m_Config = source;
231 }
232 }
233
234 }
235
236 public void Close()
237 {
238 }
239
240 public void AddRegion(Scene scene)
241 {
242 if (!m_Enabled)
243 return;
244
245 EngineType = Name;
246 RegionName = scene.RegionInfo.RegionName;
247 PhysicsSceneName = EngineType + "/" + RegionName;
248
249 scene.RegisterModuleInterface<PhysicsScene>(this);
250 Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
251 Initialise(m_Config, extent);
252
253 base.Initialise(scene.PhysicsRequestAsset,
254 (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[scene.RegionInfo.RegionSizeX * scene.RegionInfo.RegionSizeY]),
255 (float)scene.RegionInfo.RegionSettings.WaterHeight);
256
257 }
258
259 public void RemoveRegion(Scene scene)
260 {
261 if (!m_Enabled)
262 return;
263 }
264
265 public void RegionLoaded(Scene scene)
266 {
267 if (!m_Enabled)
268 return;
269
270 mesher = scene.RequestModuleInterface<IMesher>();
271 if (mesher == null)
272 m_log.WarnFormat("{0} No mesher. Things will not work well.", LogHeader);
273
274 scene.PhysicsEnabled = true;
275 }
276 #endregion
277
278 #region Initialization
279
280 private void Initialise(IConfigSource config, Vector3 regionExtent)
281 {
282 _taintOperations = new List<TaintCallbackEntry>();
283 _postTaintOperations = new Dictionary<string, TaintCallbackEntry>();
284 _postStepOperations = new List<TaintCallbackEntry>();
285 PhysObjects = new Dictionary<uint, BSPhysObject>();
286 Shapes = new BSShapeCollection(this);
287
288 m_simulatedTime = 0f;
289 LastTimeStep = 0.1f;
290
291 // Allocate pinned memory to pass parameters.
292 UnmanagedParams = new ConfigurationParameters[1];
293
294 // Set default values for physics parameters plus any overrides from the ini file
295 GetInitialParameterValues(config);
296
297 // Force some parameters to values depending on other configurations
298 // Only use heightmap terrain implementation if terrain larger than legacy size
299 if ((uint)regionExtent.X > Constants.RegionSize || (uint)regionExtent.Y > Constants.RegionSize)
300 {
301 m_log.WarnFormat("{0} Forcing terrain implementation to heightmap for large region", LogHeader);
302 BSParam.TerrainImplementation = (float)BSTerrainPhys.TerrainImplementation.Heightmap;
303 }
304
305 // Get the connection to the physics engine (could be native or one of many DLLs)
306 PE = SelectUnderlyingBulletEngine(BulletEngineName);
307
308 // Enable very detailed logging.
309 // By creating an empty logger when not logging, the log message invocation code
310 // can be left in and every call doesn't have to check for null.
311 if (m_physicsLoggingEnabled)
312 {
313 PhysicsLogging = new LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes, m_physicsLoggingDoFlush);
314 PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output its own error messages.
315 }
316 else
317 {
318 PhysicsLogging = new LogWriter();
319 }
320
321 // Allocate memory for returning of the updates and collisions from the physics engine
322 m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame];
323 m_updateArray = new EntityProperties[m_maxUpdatesPerFrame];
324
325 // The bounding box for the simulated world. The origin is 0,0,0 unless we're
326 // a child in a mega-region.
327 // Bullet actually doesn't care about the extents of the simulated
328 // area. It tracks active objects no matter where they are.
329 Vector3 worldExtent = regionExtent;
330
331 World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray, m_maxUpdatesPerFrame, ref m_updateArray);
332
333 Constraints = new BSConstraintCollection(World);
334
335 TerrainManager = new BSTerrainManager(this, worldExtent);
336 TerrainManager.CreateInitialGroundPlaneAndTerrain();
337
338 // Put some informational messages into the log file.
339 m_log.InfoFormat("{0} Linksets implemented with {1}", LogHeader, (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation);
340
341 InTaintTime = false;
342 m_initialized = true;
343
344 // If the physics engine runs on its own thread, start same.
345 if (BSParam.UseSeparatePhysicsThread)
346 {
347 // The physics simulation should happen independently of the heartbeat loop
348 m_physicsThread
349 = WorkManager.StartThread(
350 BulletSPluginPhysicsThread,
351 string.Format("{0} ({1})", BulletEngineName, RegionName),
352 ThreadPriority.Normal,
353 true,
354 true);
355 }
356 }
357
358 // All default parameter values are set here. There should be no values set in the
359 // variable definitions.
360 private void GetInitialParameterValues(IConfigSource config)
361 {
362 ConfigurationParameters parms = new ConfigurationParameters();
363 UnmanagedParams[0] = parms;
364
365 BSParam.SetParameterDefaultValues(this);
366
367 if (config != null)
368 {
369 // If there are specifications in the ini file, use those values
370 IConfig pConfig = config.Configs["BulletSim"];
371 if (pConfig != null)
372 {
373 BSParam.SetParameterConfigurationValues(this, pConfig);
374
375 // There are two Bullet implementations to choose from
376 BulletEngineName = pConfig.GetString("BulletEngine", "BulletUnmanaged");
377
378 // Very detailed logging for physics debugging
379 // TODO: the boolean values can be moved to the normal parameter processing.
380 m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false);
381 m_physicsLoggingDir = pConfig.GetString("PhysicsLoggingDir", ".");
382 m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-%REGIONNAME%-");
383 m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5);
384 m_physicsLoggingDoFlush = pConfig.GetBoolean("PhysicsLoggingDoFlush", false);
385 m_physicsPhysicalDumpEnabled = pConfig.GetBoolean("PhysicsPhysicalDumpEnabled", false);
386 // Very detailed logging for vehicle debugging
387 VehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
388 VehiclePhysicalLoggingEnabled = pConfig.GetBoolean("VehiclePhysicalLoggingEnabled", false);
389
390 // Do any replacements in the parameters
391 m_physicsLoggingPrefix = m_physicsLoggingPrefix.Replace("%REGIONNAME%", RegionName);
392 }
393 else
394 {
395 // Nothing in the configuration INI file so assume unmanaged and other defaults.
396 BulletEngineName = "BulletUnmanaged";
397 m_physicsLoggingEnabled = false;
398 VehicleLoggingEnabled = false;
399 }
400
401 // The material characteristics.
402 BSMaterials.InitializeFromDefaults(Params);
403 if (pConfig != null)
404 {
405 // Let the user add new and interesting material property values.
406 BSMaterials.InitializefromParameters(pConfig);
407 }
408 }
409 }
410
411 // A helper function that handles a true/false parameter and returns the proper float number encoding
412 float ParamBoolean(IConfig config, string parmName, float deflt)
413 {
414 float ret = deflt;
415 if (config.Contains(parmName))
416 {
417 ret = ConfigurationParameters.numericFalse;
418 if (config.GetBoolean(parmName, false))
419 {
420 ret = ConfigurationParameters.numericTrue;
421 }
422 }
423 return ret;
424 }
425
426 // Select the connection to the actual Bullet implementation.
427 // The main engine selection is the engineName up to the first hypen.
428 // So "Bullet-2.80-OpenCL-Intel" specifies the 'bullet' class here and the whole name
429 // is passed to the engine to do its special selection, etc.
430 private BSAPITemplate SelectUnderlyingBulletEngine(string engineName)
431 {
432 // For the moment, do a simple switch statement.
433 // Someday do fancyness with looking up the interfaces in the assembly.
434 BSAPITemplate ret = null;
435
436 string selectionName = engineName.ToLower();
437 int hyphenIndex = engineName.IndexOf("-");
438 if (hyphenIndex > 0)
439 selectionName = engineName.ToLower().Substring(0, hyphenIndex - 1);
440
441 switch (selectionName)
442 {
443 case "bullet":
444 case "bulletunmanaged":
445 ret = new BSAPIUnman(engineName, this);
446 break;
447 case "bulletxna":
448 ret = new BSAPIXNA(engineName, this);
449 // Disable some features that are not implemented in BulletXNA
450 m_log.InfoFormat("{0} Disabling some physics features not implemented by BulletXNA", LogHeader);
451 m_log.InfoFormat("{0} Disabling ShouldUseBulletHACD", LogHeader);
452 BSParam.ShouldUseBulletHACD = false;
453 m_log.InfoFormat("{0} Disabling ShouldUseSingleConvexHullForPrims", LogHeader);
454 BSParam.ShouldUseSingleConvexHullForPrims = false;
455 m_log.InfoFormat("{0} Disabling ShouldUseGImpactShapeForPrims", LogHeader);
456 BSParam.ShouldUseGImpactShapeForPrims = false;
457 m_log.InfoFormat("{0} Setting terrain implimentation to Heightmap", LogHeader);
458 BSParam.TerrainImplementation = (float)BSTerrainPhys.TerrainImplementation.Heightmap;
459 break;
460 }
461
462 if (ret == null)
463 {
464 m_log.ErrorFormat("{0} COULD NOT SELECT BULLET ENGINE: '[BulletSim]PhysicsEngine' must be either 'BulletUnmanaged-*' or 'BulletXNA-*'", LogHeader);
465 }
466 else
467 {
468 m_log.InfoFormat("{0} Selected bullet engine {1} -> {2}/{3}", LogHeader, engineName, ret.BulletEngineName, ret.BulletEngineVersion);
469 }
470
471 return ret;
472 }
473
474 public override void Dispose()
475 {
476 // m_log.DebugFormat("{0}: Dispose()", LogHeader);
477
478 // make sure no stepping happens while we're deleting stuff
479 m_initialized = false;
480
481 lock (PhysObjects)
482 {
483 foreach (KeyValuePair<uint, BSPhysObject> kvp in PhysObjects)
484 {
485 kvp.Value.Destroy();
486 }
487 PhysObjects.Clear();
488 }
489
490 // Now that the prims are all cleaned up, there should be no constraints left
491 if (Constraints != null)
492 {
493 Constraints.Dispose();
494 Constraints = null;
495 }
496
497 if (Shapes != null)
498 {
499 Shapes.Dispose();
500 Shapes = null;
501 }
502
503 if (TerrainManager != null)
504 {
505 TerrainManager.ReleaseGroundPlaneAndTerrain();
506 TerrainManager.Dispose();
507 TerrainManager = null;
508 }
509
510 // Anything left in the unmanaged code should be cleaned out
511 PE.Shutdown(World);
512
513 // Not logging any more
514 PhysicsLogging.Close();
515 }
516 #endregion // Construction and Initialization
517
518 #region Prim and Avatar addition and removal
519
520 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
521 {
522 m_log.ErrorFormat("{0}: CALL TO AddAvatar in BSScene. NOT IMPLEMENTED", LogHeader);
523 return null;
524 }
525
526 public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
527 {
528 // m_log.DebugFormat("{0}: AddAvatar: {1}", LogHeader, avName);
529
530 if (!m_initialized) return null;
531
532 BSCharacter actor = new BSCharacter(localID, avName, this, position, velocity, size, isFlying);
533 lock (PhysObjects)
534 PhysObjects.Add(localID, actor);
535
536 // TODO: Remove kludge someday.
537 // We must generate a collision for avatars whether they collide or not.
538 // This is required by OpenSim to update avatar animations, etc.
539 lock (AvatarsInSceneLock)
540 AvatarsInScene.Add(actor);
541
542 return actor;
543 }
544
545 public override void RemoveAvatar(PhysicsActor actor)
546 {
547 // m_log.DebugFormat("{0}: RemoveAvatar", LogHeader);
548
549 if (!m_initialized) return;
550
551 BSCharacter bsactor = actor as BSCharacter;
552 if (bsactor != null)
553 {
554 try
555 {
556 lock (PhysObjects)
557 PhysObjects.Remove(bsactor.LocalID);
558 // Remove kludge someday
559 lock (AvatarsInSceneLock)
560 AvatarsInScene.Remove(bsactor);
561 }
562 catch (Exception e)
563 {
564 m_log.WarnFormat("{0}: Attempt to remove avatar that is not in physics scene: {1}", LogHeader, e);
565 }
566 bsactor.Destroy();
567 // bsactor.dispose();
568 }
569 else
570 {
571 m_log.ErrorFormat("{0}: Requested to remove avatar that is not a BSCharacter. ID={1}, type={2}",
572 LogHeader, actor.LocalID, actor.GetType().Name);
573 }
574 }
575
576 public override void RemovePrim(PhysicsActor prim)
577 {
578 if (!m_initialized) return;
579
580 BSPhysObject bsprim = prim as BSPhysObject;
581 if (bsprim != null)
582 {
583 DetailLog("{0},RemovePrim,call", bsprim.LocalID);
584 // m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID);
585 try
586 {
587 lock (PhysObjects) PhysObjects.Remove(bsprim.LocalID);
588 }
589 catch (Exception e)
590 {
591 m_log.ErrorFormat("{0}: Attempt to remove prim that is not in physics scene: {1}", LogHeader, e);
592 }
593 bsprim.Destroy();
594 // bsprim.dispose();
595 }
596 else
597 {
598 m_log.ErrorFormat("{0}: Attempt to remove prim that is not a BSPrim type.", LogHeader);
599 }
600 }
601
602 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
603 Vector3 size, Quaternion rotation, bool isPhysical, uint localID)
604 {
605 // m_log.DebugFormat("{0}: AddPrimShape2: {1}", LogHeader, primName);
606
607 if (!m_initialized) return null;
608
609 // DetailLog("{0},BSScene.AddPrimShape,call", localID);
610
611 BSPhysObject prim = new BSPrimLinkable(localID, primName, this, position, size, rotation, pbs, isPhysical);
612 lock (PhysObjects) PhysObjects.Add(localID, prim);
613 return prim;
614 }
615
616 // This is a call from the simulator saying that some physical property has been updated.
617 // The BulletSim driver senses the changing of relevant properties so this taint
618 // information call is not needed.
619 public override void AddPhysicsActorTaint(PhysicsActor prim) { }
620
621 #endregion // Prim and Avatar addition and removal
622
623 #region Simulation
624
625 // Call from the simulator to send physics information to the simulator objects.
626 // This pushes all the collision and property update events into the objects in
627 // the simulator and, since it is on the heartbeat thread, there is an implicit
628 // locking of those data structures from other heartbeat events.
629 // If the physics engine is running on a separate thread, the update information
630 // will be in the ObjectsWithCollions and ObjectsWithUpdates structures.
631 public override float Simulate(float timeStep)
632 {
633 if (!BSParam.UseSeparatePhysicsThread)
634 {
635 DoPhysicsStep(timeStep);
636 }
637 return SendUpdatesToSimulator(timeStep);
638 }
639
640 // Call the physics engine to do one 'timeStep' and collect collisions and updates
641 // into ObjectsWithCollisions and ObjectsWithUpdates data structures.
642 private void DoPhysicsStep(float timeStep)
643 {
644 // prevent simulation until we've been initialized
645 if (!m_initialized) return;
646
647 LastTimeStep = timeStep;
648
649 int updatedEntityCount = 0;
650 int collidersCount = 0;
651
652 int beforeTime = Util.EnvironmentTickCount();
653 int simTime = 0;
654
655 int numTaints = _taintOperations.Count;
656 InTaintTime = true; // Only used for debugging so locking is not necessary.
657
658 // update the prim states while we know the physics engine is not busy
659 ProcessTaints();
660
661 // Some of the physical objects requre individual, pre-step calls
662 // (vehicles and avatar movement, in particular)
663 TriggerPreStepEvent(timeStep);
664
665 // the prestep actions might have added taints
666 numTaints += _taintOperations.Count;
667 ProcessTaints();
668
669 InTaintTime = false; // Only used for debugging so locking is not necessary.
670
671 // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world.
672 // Only enable this in a limited test world with few objects.
673 if (m_physicsPhysicalDumpEnabled)
674 PE.DumpAllInfo(World);
675
676 // step the physical world one interval
677 m_simulationStep++;
678 int numSubSteps = 0;
679 try
680 {
681 numSubSteps = PE.PhysicsStep(World, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out collidersCount);
682
683 }
684 catch (Exception e)
685 {
686 m_log.WarnFormat("{0},PhysicsStep Exception: nTaints={1}, substeps={2}, updates={3}, colliders={4}, e={5}",
687 LogHeader, numTaints, numSubSteps, updatedEntityCount, collidersCount, e);
688 DetailLog("{0},PhysicsStepException,call, nTaints={1}, substeps={2}, updates={3}, colliders={4}",
689 DetailLogZero, numTaints, numSubSteps, updatedEntityCount, collidersCount);
690 updatedEntityCount = 0;
691 collidersCount = 0;
692 }
693
694 // Make the physics engine dump useful statistics periodically
695 if (PhysicsMetricDumpFrames != 0 && ((m_simulationStep % PhysicsMetricDumpFrames) == 0))
696 PE.DumpPhysicsStatistics(World);
697
698 // Get a value for 'now' so all the collision and update routines don't have to get their own.
699 SimulationNowTime = Util.EnvironmentTickCount();
700
701 // Send collision information to the colliding objects. The objects decide if the collision
702 // is 'real' (like linksets don't collide with themselves) and the individual objects
703 // know if the simulator has subscribed to collisions.
704 lock (CollisionLock)
705 {
706 if (collidersCount > 0)
707 {
708 lock (PhysObjects)
709 {
710 for (int ii = 0; ii < collidersCount; ii++)
711 {
712 uint cA = m_collisionArray[ii].aID;
713 uint cB = m_collisionArray[ii].bID;
714 Vector3 point = m_collisionArray[ii].point;
715 Vector3 normal = m_collisionArray[ii].normal;
716 float penetration = m_collisionArray[ii].penetration;
717 SendCollision(cA, cB, point, normal, penetration);
718 SendCollision(cB, cA, point, -normal, penetration);
719 }
720 }
721 }
722 }
723
724 // If any of the objects had updated properties, tell the managed objects about the update
725 // and remember that there was a change so it will be passed to the simulator.
726 lock (UpdateLock)
727 {
728 if (updatedEntityCount > 0)
729 {
730 lock (PhysObjects)
731 {
732 for (int ii = 0; ii < updatedEntityCount; ii++)
733 {
734 EntityProperties entprop = m_updateArray[ii];
735 BSPhysObject pobj;
736 if (PhysObjects.TryGetValue(entprop.ID, out pobj))
737 {
738 if (pobj.IsInitialized)
739 pobj.UpdateProperties(entprop);
740 }
741 }
742 }
743 }
744 }
745
746 // Some actors want to know when the simulation step is complete.
747 TriggerPostStepEvent(timeStep);
748
749 simTime = Util.EnvironmentTickCountSubtract(beforeTime);
750 if (PhysicsLogging.Enabled)
751 {
752 DetailLog("{0},DoPhysicsStep,complete,frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}",
753 DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps,
754 updatedEntityCount, collidersCount, ObjectsWithCollisions.Count);
755 }
756
757 // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world.
758 // Only enable this in a limited test world with few objects.
759 if (m_physicsPhysicalDumpEnabled)
760 PE.DumpAllInfo(World);
761
762 // The physics engine returns the number of milliseconds it simulated this call.
763 // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS.
764 // Multiply by a fixed nominal frame rate to give a rate similar to the simulator (usually 55).
765 m_simulatedTime += (float)numSubSteps * m_fixedTimeStep * 1000f * NominalFrameRate;
766 }
767
768 // Called by a BSPhysObject to note that it has changed properties and this information
769 // should be passed up to the simulator at the proper time.
770 // Note: this is called by the BSPhysObject from invocation via DoPhysicsStep() above so
771 // this is is under UpdateLock.
772 public void PostUpdate(BSPhysObject updatee)
773 {
774 lock (UpdateLock)
775 {
776 ObjectsWithUpdates.Add(updatee);
777 }
778 }
779
780 // The simulator thinks it is physics time so return all the collisions and position
781 // updates that were collected in actual physics simulation.
782 private float SendUpdatesToSimulator(float timeStep)
783 {
784 if (!m_initialized) return 5.0f;
785
786 DetailLog("{0},SendUpdatesToSimulator,collisions={1},updates={2},simedTime={3}",
787 BSScene.DetailLogZero, ObjectsWithCollisions.Count, ObjectsWithUpdates.Count, m_simulatedTime);
788 // Push the collisions into the simulator.
789 lock (CollisionLock)
790 {
791 if (ObjectsWithCollisions.Count > 0)
792 {
793 foreach (BSPhysObject bsp in ObjectsWithCollisions)
794 if (!bsp.SendCollisions())
795 {
796 // If the object is done colliding, see that it's removed from the colliding list
797 ObjectsWithNoMoreCollisions.Add(bsp);
798 }
799 }
800
801 // This is a kludge to get avatar movement updates.
802 // The simulator expects collisions for avatars even if there are have been no collisions.
803 // The event updates avatar animations and stuff.
804 // If you fix avatar animation updates, remove this overhead and let normal collision processing happen.
805 // Note that we get a copy of the list to search because SendCollision() can take a while.
806 HashSet<BSPhysObject> tempAvatarsInScene;
807 lock (AvatarsInSceneLock)
808 {
809 tempAvatarsInScene = new HashSet<BSPhysObject>(AvatarsInScene);
810 }
811 foreach (BSPhysObject actor in tempAvatarsInScene)
812 {
813 if (!ObjectsWithCollisions.Contains(actor)) // don't call avatars twice
814 actor.SendCollisions();
815 }
816 tempAvatarsInScene = null;
817
818 // Objects that are done colliding are removed from the ObjectsWithCollisions list.
819 // Not done above because it is inside an iteration of ObjectWithCollisions.
820 // This complex collision processing is required to create an empty collision
821 // event call after all real collisions have happened on an object. This allows
822 // the simulator to generate the 'collision end' event.
823 if (ObjectsWithNoMoreCollisions.Count > 0)
824 {
825 foreach (BSPhysObject po in ObjectsWithNoMoreCollisions)
826 ObjectsWithCollisions.Remove(po);
827 ObjectsWithNoMoreCollisions.Clear();
828 }
829 }
830
831 // Call the simulator for each object that has physics property updates.
832 HashSet<BSPhysObject> updatedObjects = null;
833 lock (UpdateLock)
834 {
835 if (ObjectsWithUpdates.Count > 0)
836 {
837 updatedObjects = ObjectsWithUpdates;
838 ObjectsWithUpdates = new HashSet<BSPhysObject>();
839 }
840 }
841 if (updatedObjects != null)
842 {
843 foreach (BSPhysObject obj in updatedObjects)
844 {
845 obj.RequestPhysicsterseUpdate();
846 }
847 updatedObjects.Clear();
848 }
849
850 // Return the framerate simulated to give the above returned results.
851 // (Race condition here but this is just bookkeeping so rare mistakes do not merit a lock).
852 float simTime = m_simulatedTime;
853 m_simulatedTime = 0f;
854 return simTime;
855 }
856
857 // Something has collided
858 private void SendCollision(uint localID, uint collidingWith, Vector3 collidePoint, Vector3 collideNormal, float penetration)
859 {
860 if (localID <= TerrainManager.HighestTerrainID)
861 {
862 return; // don't send collisions to the terrain
863 }
864
865 BSPhysObject collider;
866 // NOTE that PhysObjects was locked before the call to SendCollision().
867 if (!PhysObjects.TryGetValue(localID, out collider))
868 {
869 // If the object that is colliding cannot be found, just ignore the collision.
870 DetailLog("{0},BSScene.SendCollision,colliderNotInObjectList,id={1},with={2}", DetailLogZero, localID, collidingWith);
871 return;
872 }
873
874 // Note: the terrain is not in the physical object list so 'collidee' can be null when Collide() is called.
875 BSPhysObject collidee = null;
876 PhysObjects.TryGetValue(collidingWith, out collidee);
877
878 // DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith);
879
880 if (collider.IsInitialized)
881 {
882 if (collider.Collide(collidingWith, collidee, collidePoint, collideNormal, penetration))
883 {
884 // If a collision was 'good', remember to send it to the simulator
885 lock (CollisionLock)
886 {
887 ObjectsWithCollisions.Add(collider);
888 }
889 }
890 }
891
892 return;
893 }
894
895 public void BulletSPluginPhysicsThread()
896 {
897 Thread.CurrentThread.Priority = ThreadPriority.Highest;
898 m_updateWaitEvent = new ManualResetEvent(false);
899
900 while (m_initialized)
901 {
902 int beginSimulationRealtimeMS = Util.EnvironmentTickCount();
903
904 if (BSParam.Active)
905 DoPhysicsStep(BSParam.PhysicsTimeStep);
906
907 int simulationRealtimeMS = Util.EnvironmentTickCountSubtract(beginSimulationRealtimeMS);
908 int simulationTimeVsRealtimeDifferenceMS = ((int)(BSParam.PhysicsTimeStep*1000f)) - simulationRealtimeMS;
909
910 if (simulationTimeVsRealtimeDifferenceMS > 0)
911 {
912 // The simulation of the time interval took less than realtime.
913 // Do a wait for the rest of realtime.
914 m_updateWaitEvent.WaitOne(simulationTimeVsRealtimeDifferenceMS);
915 //Thread.Sleep(simulationTimeVsRealtimeDifferenceMS);
916 }
917 else
918 {
919 // The simulation took longer than realtime.
920 // Do some scaling of simulation time.
921 // TODO.
922 DetailLog("{0},BulletSPluginPhysicsThread,longerThanRealtime={1}", BSScene.DetailLogZero, simulationTimeVsRealtimeDifferenceMS);
923 }
924
925 Watchdog.UpdateThread();
926 }
927
928 Watchdog.RemoveThread();
929 }
930
931 #endregion // Simulation
932
933 public override void GetResults() { }
934
935 #region Terrain
936
937 public override void SetTerrain(float[] heightMap) {
938 TerrainManager.SetTerrain(heightMap);
939 }
940
941 public override void SetWaterLevel(float baseheight)
942 {
943 SimpleWaterLevel = baseheight;
944 }
945
946 public override void DeleteTerrain()
947 {
948 // m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader);
949 }
950
951 // Although no one seems to check this, I do support combining.
952 public override bool SupportsCombining()
953 {
954 return TerrainManager.SupportsCombining();
955 }
956 // This call says I am a child to region zero in a mega-region. 'pScene' is that
957 // of region zero, 'offset' is my offset from regions zero's origin, and
958 // 'extents' is the largest XY that is handled in my region.
959 public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
960 {
961 TerrainManager.Combine(pScene, offset, extents);
962 }
963
964 // Unhook all the combining that I know about.
965 public override void UnCombine(PhysicsScene pScene)
966 {
967 TerrainManager.UnCombine(pScene);
968 }
969
970 #endregion // Terrain
971
972 public override Dictionary<uint, float> GetTopColliders()
973 {
974 Dictionary<uint, float> topColliders;
975
976 lock (PhysObjects)
977 {
978 foreach (KeyValuePair<uint, BSPhysObject> kvp in PhysObjects)
979 {
980 kvp.Value.ComputeCollisionScore();
981 }
982
983 List<BSPhysObject> orderedPrims = new List<BSPhysObject>(PhysObjects.Values);
984 orderedPrims.OrderByDescending(p => p.CollisionScore);
985 topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore);
986 }
987
988 return topColliders;
989 }
990
991 public override bool IsThreaded { get { return false; } }
992
993 #region Extensions
994 public override object Extension(string pFunct, params object[] pParams)
995 {
996 DetailLog("{0} BSScene.Extension,op={1}", DetailLogZero, pFunct);
997 return base.Extension(pFunct, pParams);
998 }
999 #endregion // Extensions
1000
1001 public static string PrimitiveBaseShapeToString(PrimitiveBaseShape pbs)
1002 {
1003 float pathShearX = pbs.PathShearX < 128 ? (float)pbs.PathShearX * 0.01f : (float)(pbs.PathShearX - 256) * 0.01f;
1004 float pathShearY = pbs.PathShearY < 128 ? (float)pbs.PathShearY * 0.01f : (float)(pbs.PathShearY - 256) * 0.01f;
1005 float pathBegin = (float)pbs.PathBegin * 2.0e-5f;
1006 float pathEnd = 1.0f - (float)pbs.PathEnd * 2.0e-5f;
1007 float pathScaleX = (float)(200 - pbs.PathScaleX) * 0.01f;
1008 float pathScaleY = (float)(200 - pbs.PathScaleY) * 0.01f;
1009 float pathTaperX = pbs.PathTaperX * 0.01f;
1010 float pathTaperY = pbs.PathTaperY * 0.01f;
1011
1012 float profileBegin = (float)pbs.ProfileBegin * 2.0e-5f;
1013 float profileEnd = 1.0f - (float)pbs.ProfileEnd * 2.0e-5f;
1014 float profileHollow = (float)pbs.ProfileHollow * 2.0e-5f;
1015 if (profileHollow > 0.95f)
1016 profileHollow = 0.95f;
1017
1018 StringBuilder buff = new StringBuilder();
1019 buff.Append("shape=");
1020 buff.Append(((ProfileShape)pbs.ProfileShape).ToString());
1021 buff.Append(",");
1022 buff.Append("hollow=");
1023 buff.Append(((HollowShape)pbs.HollowShape).ToString());
1024 buff.Append(",");
1025 buff.Append("pathCurve=");
1026 buff.Append(((Extrusion)pbs.PathCurve).ToString());
1027 buff.Append(",");
1028 buff.Append("profCurve=");
1029 buff.Append(((Extrusion)pbs.ProfileCurve).ToString());
1030 buff.Append(",");
1031 buff.Append("profHollow=");
1032 buff.Append(profileHollow.ToString());
1033 buff.Append(",");
1034 buff.Append("pathBegEnd=");
1035 buff.Append(pathBegin.ToString());
1036 buff.Append("/");
1037 buff.Append(pathEnd.ToString());
1038 buff.Append(",");
1039 buff.Append("profileBegEnd=");
1040 buff.Append(profileBegin.ToString());
1041 buff.Append("/");
1042 buff.Append(profileEnd.ToString());
1043 buff.Append(",");
1044 buff.Append("scaleXY=");
1045 buff.Append(pathScaleX.ToString());
1046 buff.Append("/");
1047 buff.Append(pathScaleY.ToString());
1048 buff.Append(",");
1049 buff.Append("shearXY=");
1050 buff.Append(pathShearX.ToString());
1051 buff.Append("/");
1052 buff.Append(pathShearY.ToString());
1053 buff.Append(",");
1054 buff.Append("taperXY=");
1055 buff.Append(pbs.PathTaperX.ToString());
1056 buff.Append("/");
1057 buff.Append(pbs.PathTaperY.ToString());
1058 buff.Append(",");
1059 buff.Append("skew=");
1060 buff.Append(pbs.PathSkew.ToString());
1061 buff.Append(",");
1062 buff.Append("twist/Beg=");
1063 buff.Append(pbs.PathTwist.ToString());
1064 buff.Append("/");
1065 buff.Append(pbs.PathTwistBegin.ToString());
1066
1067 return buff.ToString();
1068 }
1069
1070 #region Taints
1071 // The simulation execution order is:
1072 // Simulate()
1073 // DoOneTimeTaints
1074 // TriggerPreStepEvent
1075 // DoOneTimeTaints
1076 // Step()
1077 // ProcessAndSendToSimulatorCollisions
1078 // ProcessAndSendToSimulatorPropertyUpdates
1079 // TriggerPostStepEvent
1080
1081 // Calls to the PhysicsActors can't directly call into the physics engine
1082 // because it might be busy. We delay changes to a known time.
1083 // We rely on C#'s closure to save and restore the context for the delegate.
1084 public void TaintedObject(string pOriginator, string pIdent, TaintCallback pCallback)
1085 {
1086 TaintedObject(false /*inTaintTime*/, pOriginator, pIdent, pCallback);
1087 }
1088 public void TaintedObject(uint pOriginator, String pIdent, TaintCallback pCallback)
1089 {
1090 TaintedObject(false /*inTaintTime*/, m_physicsLoggingEnabled ? pOriginator.ToString() : BSScene.DetailLogZero, pIdent, pCallback);
1091 }
1092 public void TaintedObject(bool inTaintTime, String pIdent, TaintCallback pCallback)
1093 {
1094 TaintedObject(inTaintTime, BSScene.DetailLogZero, pIdent, pCallback);
1095 }
1096 public void TaintedObject(bool inTaintTime, uint pOriginator, String pIdent, TaintCallback pCallback)
1097 {
1098 TaintedObject(inTaintTime, m_physicsLoggingEnabled ? pOriginator.ToString() : BSScene.DetailLogZero, pIdent, pCallback);
1099 }
1100 // Sometimes a potentially tainted operation can be used in and out of taint time.
1101 // This routine executes the command immediately if in taint-time otherwise it is queued.
1102 public void TaintedObject(bool inTaintTime, string pOriginator, string pIdent, TaintCallback pCallback)
1103 {
1104 if (!m_initialized) return;
1105
1106 if (inTaintTime)
1107 pCallback();
1108 else
1109 {
1110 lock (_taintLock)
1111 {
1112 _taintOperations.Add(new TaintCallbackEntry(pOriginator, pIdent, pCallback));
1113 }
1114 }
1115 }
1116
1117 private void TriggerPreStepEvent(float timeStep)
1118 {
1119 PreStepAction actions = BeforeStep;
1120 if (actions != null)
1121 actions(timeStep);
1122
1123 }
1124
1125 private void TriggerPostStepEvent(float timeStep)
1126 {
1127 PostStepAction actions = AfterStep;
1128 if (actions != null)
1129 actions(timeStep);
1130
1131 }
1132
1133 // When someone tries to change a property on a BSPrim or BSCharacter, the object queues
1134 // a callback into itself to do the actual property change. That callback is called
1135 // here just before the physics engine is called to step the simulation.
1136 public void ProcessTaints()
1137 {
1138 ProcessRegularTaints();
1139 ProcessPostTaintTaints();
1140 }
1141
1142 private void ProcessRegularTaints()
1143 {
1144 if (m_initialized && _taintOperations.Count > 0) // save allocating new list if there is nothing to process
1145 {
1146 // swizzle a new list into the list location so we can process what's there
1147 List<TaintCallbackEntry> oldList;
1148 lock (_taintLock)
1149 {
1150 oldList = _taintOperations;
1151 _taintOperations = new List<TaintCallbackEntry>();
1152 }
1153
1154 foreach (TaintCallbackEntry tcbe in oldList)
1155 {
1156 try
1157 {
1158 DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", tcbe.originator, tcbe.ident); // DEBUG DEBUG DEBUG
1159 tcbe.callback();
1160 }
1161 catch (Exception e)
1162 {
1163 m_log.ErrorFormat("{0}: ProcessTaints: {1}: Exception: {2}", LogHeader, tcbe.ident, e);
1164 }
1165 }
1166 oldList.Clear();
1167 }
1168 }
1169
1170 // Schedule an update to happen after all the regular taints are processed.
1171 // Note that new requests for the same operation ("ident") for the same object ("ID")
1172 // will replace any previous operation by the same object.
1173 public void PostTaintObject(String ident, uint ID, TaintCallback callback)
1174 {
1175 string IDAsString = ID.ToString();
1176 string uniqueIdent = ident + "-" + IDAsString;
1177 lock (_taintLock)
1178 {
1179 _postTaintOperations[uniqueIdent] = new TaintCallbackEntry(IDAsString, uniqueIdent, callback);
1180 }
1181
1182 return;
1183 }
1184
1185 // Taints that happen after the normal taint processing but before the simulation step.
1186 private void ProcessPostTaintTaints()
1187 {
1188 if (m_initialized && _postTaintOperations.Count > 0)
1189 {
1190 Dictionary<string, TaintCallbackEntry> oldList;
1191 lock (_taintLock)
1192 {
1193 oldList = _postTaintOperations;
1194 _postTaintOperations = new Dictionary<string, TaintCallbackEntry>();
1195 }
1196
1197 foreach (KeyValuePair<string,TaintCallbackEntry> kvp in oldList)
1198 {
1199 try
1200 {
1201 DetailLog("{0},BSScene.ProcessPostTaintTaints,doTaint,id={1}", DetailLogZero, kvp.Key); // DEBUG DEBUG DEBUG
1202 kvp.Value.callback();
1203 }
1204 catch (Exception e)
1205 {
1206 m_log.ErrorFormat("{0}: ProcessPostTaintTaints: {1}: Exception: {2}", LogHeader, kvp.Key, e);
1207 }
1208 }
1209 oldList.Clear();
1210 }
1211 }
1212
1213 // Only used for debugging. Does not change state of anything so locking is not necessary.
1214 public bool AssertInTaintTime(string whereFrom)
1215 {
1216 if (!InTaintTime)
1217 {
1218 DetailLog("{0},BSScene.AssertInTaintTime,NOT IN TAINT TIME,Region={1},Where={2}", DetailLogZero, RegionName, whereFrom);
1219 m_log.ErrorFormat("{0} NOT IN TAINT TIME!! Region={1}, Where={2}", LogHeader, RegionName, whereFrom);
1220 // Util.PrintCallStack(DetailLog);
1221 }
1222 return InTaintTime;
1223 }
1224
1225 #endregion // Taints
1226
1227 #region IPhysicsParameters
1228 // Get the list of parameters this physics engine supports
1229 public PhysParameterEntry[] GetParameterList()
1230 {
1231 BSParam.BuildParameterTable();
1232 return BSParam.SettableParameters;
1233 }
1234
1235 // Set parameter on a specific or all instances.
1236 // Return 'false' if not able to set the parameter.
1237 // Setting the value in the m_params block will change the value the physics engine
1238 // will use the next time since it's pinned and shared memory.
1239 // Some of the values require calling into the physics engine to get the new
1240 // value activated ('terrainFriction' for instance).
1241 public bool SetPhysicsParameter(string parm, string val, uint localID)
1242 {
1243 bool ret = false;
1244
1245 BSParam.ParameterDefnBase theParam;
1246 if (BSParam.TryGetParameter(parm, out theParam))
1247 {
1248 // Set the value in the C# code
1249 theParam.SetValue(this, val);
1250
1251 // Optionally set the parameter in the unmanaged code
1252 if (theParam.HasSetOnObject)
1253 {
1254 // update all the localIDs specified
1255 // If the local ID is APPLY_TO_NONE, just change the default value
1256 // If the localID is APPLY_TO_ALL change the default value and apply the new value to all the lIDs
1257 // If the localID is a specific object, apply the parameter change to only that object
1258 List<uint> objectIDs = new List<uint>();
1259 switch (localID)
1260 {
1261 case PhysParameterEntry.APPLY_TO_NONE:
1262 // This will cause a call into the physical world if some operation is specified (SetOnObject).
1263 objectIDs.Add(TERRAIN_ID);
1264 TaintedUpdateParameter(parm, objectIDs, val);
1265 break;
1266 case PhysParameterEntry.APPLY_TO_ALL:
1267 lock (PhysObjects) objectIDs = new List<uint>(PhysObjects.Keys);
1268 TaintedUpdateParameter(parm, objectIDs, val);
1269 break;
1270 default:
1271 // setting only one localID
1272 objectIDs.Add(localID);
1273 TaintedUpdateParameter(parm, objectIDs, val);
1274 break;
1275 }
1276 }
1277
1278 ret = true;
1279 }
1280 return ret;
1281 }
1282
1283 // schedule the actual updating of the paramter to when the phys engine is not busy
1284 private void TaintedUpdateParameter(string parm, List<uint> lIDs, string val)
1285 {
1286 string xval = val;
1287 List<uint> xlIDs = lIDs;
1288 string xparm = parm;
1289 TaintedObject(DetailLogZero, "BSScene.UpdateParameterSet", delegate() {
1290 BSParam.ParameterDefnBase thisParam;
1291 if (BSParam.TryGetParameter(xparm, out thisParam))
1292 {
1293 if (thisParam.HasSetOnObject)
1294 {
1295 foreach (uint lID in xlIDs)
1296 {
1297 BSPhysObject theObject = null;
1298 if (PhysObjects.TryGetValue(lID, out theObject))
1299 thisParam.SetOnObject(this, theObject);
1300 }
1301 }
1302 }
1303 });
1304 }
1305
1306 // Get parameter.
1307 // Return 'false' if not able to get the parameter.
1308 public bool GetPhysicsParameter(string parm, out string value)
1309 {
1310 string val = String.Empty;
1311 bool ret = false;
1312 BSParam.ParameterDefnBase theParam;
1313 if (BSParam.TryGetParameter(parm, out theParam))
1314 {
1315 val = theParam.GetValue(this);
1316 ret = true;
1317 }
1318 value = val;
1319 return ret;
1320 }
1321
1322 #endregion IPhysicsParameters
1323
1324 // Invoke the detailed logger and output something if it's enabled.
1325 public void DetailLog(string msg, params Object[] args)
1326 {
1327 PhysicsLogging.Write(msg, args);
1328 }
1329 // Used to fill in the LocalID when there isn't one. It's the correct number of characters.
1330 public const string DetailLogZero = "0000000000";
1331
1332 }
1333}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/PhysicsModules/BulletS/BSShapeCollection.cs
index d1de844..b100273 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSShapeCollection.cs
@@ -29,10 +29,10 @@ using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using OMV = OpenMetaverse; 30using OMV = OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.PhysicsModules.SharedBase;
33using OpenSim.Region.Physics.ConvexDecompositionDotNet; 33using OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet;
34 34
35namespace OpenSim.Region.Physics.BulletSPlugin 35namespace OpenSim.Region.PhysicsModule.BulletS
36{ 36{
37public sealed class BSShapeCollection : IDisposable 37public sealed class BSShapeCollection : IDisposable
38{ 38{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/PhysicsModules/BulletS/BSShapes.cs
index 03a9ddc..79f1a89 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSShapes.cs
@@ -30,13 +30,13 @@ using System.Collections.Generic;
30using System.Text; 30using System.Text;
31 31
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34using OpenSim.Region.Physics.Meshing; 34using OpenSim.Region.PhysicsModules.Meshing;
35using OpenSim.Region.Physics.ConvexDecompositionDotNet; 35using OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet;
36 36
37using OMV = OpenMetaverse; 37using OMV = OpenMetaverse;
38 38
39namespace OpenSim.Region.Physics.BulletSPlugin 39namespace OpenSim.Region.PhysicsModule.BulletS
40{ 40{
41// Information class that holds stats for the shape. Which values mean 41// Information class that holds stats for the shape. Which values mean
42// something depends on the type of shape. 42// something depends on the type of shape.
@@ -299,7 +299,7 @@ public abstract class BSShape
299 { 299 {
300 xprim.PrimAssetState = BSPhysObject.PrimAssetCondition.FailedAssetFetch; 300 xprim.PrimAssetState = BSPhysObject.PrimAssetCondition.FailedAssetFetch;
301 physicsScene.Logger.ErrorFormat("{0} Physical object requires asset but no asset provider. Name={1}", 301 physicsScene.Logger.ErrorFormat("{0} Physical object requires asset but no asset provider. Name={1}",
302 LogHeader, physicsScene.Name); 302 LogHeader, physicsScene.PhysicsSceneName);
303 } 303 }
304 } 304 }
305 else 305 else
@@ -336,7 +336,7 @@ public abstract class BSShape
336 if (pScene != null) 336 if (pScene != null)
337 { 337 {
338 buff.Append("/rgn="); 338 buff.Append("/rgn=");
339 buff.Append(pScene.Name); 339 buff.Append(pScene.PhysicsSceneName);
340 } 340 }
341 return buff.ToString(); 341 return buff.ToString();
342 } 342 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs
index d70b2fb..42fc11b 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs
@@ -30,15 +30,14 @@ using System.Text;
30 30
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework; 32using OpenSim.Region.Framework;
33using OpenSim.Region.CoreModules; 33using OpenSim.Region.PhysicsModules.SharedBase;
34using OpenSim.Region.Physics.Manager;
35 34
36using Nini.Config; 35using Nini.Config;
37using log4net; 36using log4net;
38 37
39using OpenMetaverse; 38using OpenMetaverse;
40 39
41namespace OpenSim.Region.Physics.BulletSPlugin 40namespace OpenSim.Region.PhysicsModule.BulletS
42{ 41{
43public sealed class BSTerrainHeightmap : BSTerrainPhys 42public sealed class BSTerrainHeightmap : BSTerrainPhys
44{ 43{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/PhysicsModules/BulletS/BSTerrainManager.cs
index 50f917a..d11baa6 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSTerrainManager.cs
@@ -30,15 +30,14 @@ using System.Text;
30 30
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework; 32using OpenSim.Region.Framework;
33using OpenSim.Region.CoreModules; 33using OpenSim.Region.PhysicsModules.SharedBase;
34using OpenSim.Region.Physics.Manager;
35 34
36using Nini.Config; 35using Nini.Config;
37using log4net; 36using log4net;
38 37
39using OpenMetaverse; 38using OpenMetaverse;
40 39
41namespace OpenSim.Region.Physics.BulletSPlugin 40namespace OpenSim.Region.PhysicsModule.BulletS
42{ 41{
43 42
44// The physical implementation of the terrain is wrapped in this class. 43// The physical implementation of the terrain is wrapped in this class.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs b/OpenSim/Region/PhysicsModules/BulletS/BSTerrainMesh.cs
index e4ca098..cd59b65 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSTerrainMesh.cs
@@ -30,15 +30,14 @@ using System.Text;
30 30
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework; 32using OpenSim.Region.Framework;
33using OpenSim.Region.CoreModules; 33using OpenSim.Region.PhysicsModules.SharedBase;
34using OpenSim.Region.Physics.Manager;
35 34
36using Nini.Config; 35using Nini.Config;
37using log4net; 36using log4net;
38 37
39using OpenMetaverse; 38using OpenMetaverse;
40 39
41namespace OpenSim.Region.Physics.BulletSPlugin 40namespace OpenSim.Region.PhysicsModule.BulletS
42{ 41{
43public sealed class BSTerrainMesh : BSTerrainPhys 42public sealed class BSTerrainMesh : BSTerrainPhys
44{ 43{
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/PhysicsModules/BulletS/BulletSimData.cs
index 5932461..3329395 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BulletSimData.cs
@@ -29,7 +29,7 @@ using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using OMV = OpenMetaverse; 30using OMV = OpenMetaverse;
31 31
32namespace OpenSim.Region.Physics.BulletSPlugin 32namespace OpenSim.Region.PhysicsModule.BulletS
33{ 33{
34// Classes to allow some type checking for the API 34// Classes to allow some type checking for the API
35// These hold pointers to allocated objects in the unmanaged space. 35// These hold pointers to allocated objects in the unmanaged space.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/PhysicsModules/BulletS/BulletSimTODO.txt
index 0453376..0453376 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
+++ b/OpenSim/Region/PhysicsModules/BulletS/BulletSimTODO.txt
diff --git a/OpenSim/Region/PhysicsModules/BulletS/ExtendedPhysics.cs b/OpenSim/Region/PhysicsModules/BulletS/ExtendedPhysics.cs
new file mode 100755
index 0000000..2ba3c5a
--- /dev/null
+++ b/OpenSim/Region/PhysicsModules/BulletS/ExtendedPhysics.cs
@@ -0,0 +1,622 @@
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.Linq;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33
34using OpenSim.Framework;
35using OpenSim.Region.Framework;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Region.PhysicsModules.SharedBase;
39
40using Mono.Addins;
41using Nini.Config;
42using log4net;
43using OpenMetaverse;
44
45namespace OpenSim.Region.PhysicsModule.BulletS
46{
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
48 public class ExtendedPhysics : INonSharedRegionModule
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 private static string LogHeader = "[EXTENDED PHYSICS]";
52
53 // =============================================================
54 // Since BulletSim is a plugin, this these values aren't defined easily in one place.
55 // This table must correspond to an identical table in BSScene.
56
57 // Per scene functions. See BSScene.
58
59 // Per avatar functions. See BSCharacter.
60
61 // Per prim functions. See BSPrim.
62 public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType";
63 public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType";
64 public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed";
65 public const string PhysFunctChangeLinkType = "BulletSim.ChangeLinkType";
66 public const string PhysFunctGetLinkType = "BulletSim.GetLinkType";
67 public const string PhysFunctChangeLinkParams = "BulletSim.ChangeLinkParams";
68 public const string PhysFunctAxisLockLimits = "BulletSim.AxisLockLimits";
69
70 // =============================================================
71
72 private IConfig Configuration { get; set; }
73 private bool Enabled { get; set; }
74 private Scene BaseScene { get; set; }
75 private IScriptModuleComms Comms { get; set; }
76
77 #region INonSharedRegionModule
78
79 public string Name { get { return this.GetType().Name; } }
80
81 public void Initialise(IConfigSource config)
82 {
83 BaseScene = null;
84 Enabled = false;
85 Configuration = null;
86 Comms = null;
87
88 try
89 {
90 if ((Configuration = config.Configs["ExtendedPhysics"]) != null)
91 {
92 Enabled = Configuration.GetBoolean("Enabled", Enabled);
93 }
94 }
95 catch (Exception e)
96 {
97 m_log.ErrorFormat("{0} Initialization error: {0}", LogHeader, e);
98 }
99
100 m_log.InfoFormat("{0} module {1} enabled", LogHeader, (Enabled ? "is" : "is not"));
101 }
102
103 public void Close()
104 {
105 if (BaseScene != null)
106 {
107 BaseScene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene;
108 BaseScene.EventManager.OnSceneObjectPartUpdated -= EventManager_OnSceneObjectPartUpdated;
109 BaseScene = null;
110 }
111 }
112
113 public void AddRegion(Scene scene)
114 {
115 }
116
117 public void RemoveRegion(Scene scene)
118 {
119 if (BaseScene != null && BaseScene == scene)
120 {
121 Close();
122 }
123 }
124
125 public void RegionLoaded(Scene scene)
126 {
127 if (!Enabled) return;
128
129 BaseScene = scene;
130
131 Comms = BaseScene.RequestModuleInterface<IScriptModuleComms>();
132 if (Comms == null)
133 {
134 m_log.WarnFormat("{0} ScriptModuleComms interface not defined", LogHeader);
135 Enabled = false;
136
137 return;
138 }
139
140 // Register as LSL functions all the [ScriptInvocation] marked methods.
141 Comms.RegisterScriptInvocations(this);
142 Comms.RegisterConstants(this);
143
144 // When an object is modified, we might need to update its extended physics parameters
145 BaseScene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene;
146 BaseScene.EventManager.OnSceneObjectPartUpdated += EventManager_OnSceneObjectPartUpdated;
147
148 }
149
150 public Type ReplaceableInterface { get { return null; } }
151
152 #endregion // INonSharedRegionModule
153
154 private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj)
155 {
156 }
157
158 // Event generated when some property of a prim changes.
159 private void EventManager_OnSceneObjectPartUpdated(SceneObjectPart sop, bool isFullUpdate)
160 {
161 }
162
163 [ScriptConstant]
164 public const int PHYS_CENTER_OF_MASS = 1 << 0;
165
166 [ScriptInvocation]
167 public string physGetEngineType(UUID hostID, UUID scriptID)
168 {
169 string ret = string.Empty;
170
171 if (BaseScene.PhysicsScene != null)
172 {
173 ret = BaseScene.PhysicsScene.EngineType;
174 }
175
176 return ret;
177 }
178
179 // Code for specifying params.
180 // The choice if 14700 is arbitrary and only serves to catch parameter code misuse.
181 [ScriptConstant]
182 public const int PHYS_AXIS_LOCK_LINEAR = 14700;
183 [ScriptConstant]
184 public const int PHYS_AXIS_LOCK_LINEAR_X = 14701;
185 [ScriptConstant]
186 public const int PHYS_AXIS_LIMIT_LINEAR_X = 14702;
187 [ScriptConstant]
188 public const int PHYS_AXIS_LOCK_LINEAR_Y = 14703;
189 [ScriptConstant]
190 public const int PHYS_AXIS_LIMIT_LINEAR_Y = 14704;
191 [ScriptConstant]
192 public const int PHYS_AXIS_LOCK_LINEAR_Z = 14705;
193 [ScriptConstant]
194 public const int PHYS_AXIS_LIMIT_LINEAR_Z = 14706;
195 [ScriptConstant]
196 public const int PHYS_AXIS_LOCK_ANGULAR = 14707;
197 [ScriptConstant]
198 public const int PHYS_AXIS_LOCK_ANGULAR_X = 14708;
199 [ScriptConstant]
200 public const int PHYS_AXIS_LIMIT_ANGULAR_X = 14709;
201 [ScriptConstant]
202 public const int PHYS_AXIS_LOCK_ANGULAR_Y = 14710;
203 [ScriptConstant]
204 public const int PHYS_AXIS_LIMIT_ANGULAR_Y = 14711;
205 [ScriptConstant]
206 public const int PHYS_AXIS_LOCK_ANGULAR_Z = 14712;
207 [ScriptConstant]
208 public const int PHYS_AXIS_LIMIT_ANGULAR_Z = 14713;
209 [ScriptConstant]
210 public const int PHYS_AXIS_UNLOCK_LINEAR = 14714;
211 [ScriptConstant]
212 public const int PHYS_AXIS_UNLOCK_LINEAR_X = 14715;
213 [ScriptConstant]
214 public const int PHYS_AXIS_UNLOCK_LINEAR_Y = 14716;
215 [ScriptConstant]
216 public const int PHYS_AXIS_UNLOCK_LINEAR_Z = 14717;
217 [ScriptConstant]
218 public const int PHYS_AXIS_UNLOCK_ANGULAR = 14718;
219 [ScriptConstant]
220 public const int PHYS_AXIS_UNLOCK_ANGULAR_X = 14719;
221 [ScriptConstant]
222 public const int PHYS_AXIS_UNLOCK_ANGULAR_Y = 14720;
223 [ScriptConstant]
224 public const int PHYS_AXIS_UNLOCK_ANGULAR_Z = 14721;
225 [ScriptConstant]
226 public const int PHYS_AXIS_UNLOCK = 14722;
227 // physAxisLockLimits()
228 [ScriptInvocation]
229 public int physAxisLock(UUID hostID, UUID scriptID, object[] parms)
230 {
231 int ret = -1;
232 if (!Enabled) return ret;
233
234 PhysicsActor rootPhysActor;
235 if (GetRootPhysActor(hostID, out rootPhysActor))
236 {
237 object[] parms2 = AddToBeginningOfArray(rootPhysActor, null, parms);
238 ret = MakeIntError(rootPhysActor.Extension(PhysFunctAxisLockLimits, parms2));
239 }
240
241 return ret;
242 }
243
244 [ScriptConstant]
245 public const int PHYS_LINKSET_TYPE_CONSTRAINT = 0;
246 [ScriptConstant]
247 public const int PHYS_LINKSET_TYPE_COMPOUND = 1;
248 [ScriptConstant]
249 public const int PHYS_LINKSET_TYPE_MANUAL = 2;
250
251 [ScriptInvocation]
252 public int physSetLinksetType(UUID hostID, UUID scriptID, int linksetType)
253 {
254 int ret = -1;
255 if (!Enabled) return ret;
256
257 // The part that is requesting the change.
258 SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID);
259
260 if (requestingPart != null)
261 {
262 // The change is always made to the root of a linkset.
263 SceneObjectGroup containingGroup = requestingPart.ParentGroup;
264 SceneObjectPart rootPart = containingGroup.RootPart;
265
266 if (rootPart != null)
267 {
268 PhysicsActor rootPhysActor = rootPart.PhysActor;
269 if (rootPhysActor != null)
270 {
271 if (rootPhysActor.IsPhysical)
272 {
273 // Change a physical linkset by making non-physical, waiting for one heartbeat so all
274 // the prim and linkset state is updated, changing the type and making the
275 // linkset physical again.
276 containingGroup.ScriptSetPhysicsStatus(false);
277 Thread.Sleep(150); // longer than one heartbeat tick
278
279 // A kludge for the moment.
280 // Since compound linksets move the children but don't generate position updates to the
281 // simulator, it is possible for compound linkset children to have out-of-sync simulator
282 // and physical positions. The following causes the simulator to push the real child positions
283 // down into the physics engine to get everything synced.
284 containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition);
285 containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation);
286
287 object[] parms2 = { rootPhysActor, null, linksetType };
288 ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, parms2));
289 Thread.Sleep(150); // longer than one heartbeat tick
290
291 containingGroup.ScriptSetPhysicsStatus(true);
292 }
293 else
294 {
295 // Non-physical linksets don't have a physical instantiation so there is no state to
296 // worry about being updated.
297 object[] parms2 = { rootPhysActor, null, linksetType };
298 ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, parms2));
299 }
300 }
301 else
302 {
303 m_log.WarnFormat("{0} physSetLinksetType: root part does not have a physics actor. rootName={1}, hostID={2}",
304 LogHeader, rootPart.Name, hostID);
305 }
306 }
307 else
308 {
309 m_log.WarnFormat("{0} physSetLinksetType: root part does not exist. RequestingPartName={1}, hostID={2}",
310 LogHeader, requestingPart.Name, hostID);
311 }
312 }
313 else
314 {
315 m_log.WarnFormat("{0} physSetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID);
316 }
317 return ret;
318 }
319
320 [ScriptInvocation]
321 public int physGetLinksetType(UUID hostID, UUID scriptID)
322 {
323 int ret = -1;
324 if (!Enabled) return ret;
325
326 PhysicsActor rootPhysActor;
327 if (GetRootPhysActor(hostID, out rootPhysActor))
328 {
329 object[] parms2 = { rootPhysActor, null };
330 ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType, parms2));
331 }
332 else
333 {
334 m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID);
335 }
336 return ret;
337 }
338
339 [ScriptConstant]
340 public const int PHYS_LINK_TYPE_FIXED = 1234;
341 [ScriptConstant]
342 public const int PHYS_LINK_TYPE_HINGE = 4;
343 [ScriptConstant]
344 public const int PHYS_LINK_TYPE_SPRING = 9;
345 [ScriptConstant]
346 public const int PHYS_LINK_TYPE_6DOF = 6;
347 [ScriptConstant]
348 public const int PHYS_LINK_TYPE_SLIDER = 7;
349
350 // physChangeLinkType(integer linkNum, integer typeCode)
351 [ScriptInvocation]
352 public int physChangeLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode)
353 {
354 int ret = -1;
355 if (!Enabled) return ret;
356
357 PhysicsActor rootPhysActor;
358 PhysicsActor childPhysActor;
359
360 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
361 {
362 object[] parms2 = { rootPhysActor, childPhysActor, typeCode };
363 ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2));
364 }
365
366 return ret;
367 }
368
369 // physGetLinkType(integer linkNum)
370 [ScriptInvocation]
371 public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum)
372 {
373 int ret = -1;
374 if (!Enabled) return ret;
375
376 PhysicsActor rootPhysActor;
377 PhysicsActor childPhysActor;
378
379 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
380 {
381 object[] parms2 = { rootPhysActor, childPhysActor };
382 ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms2));
383 }
384
385 return ret;
386 }
387
388 // physChangeLinkFixed(integer linkNum)
389 // Change the link between the root and the linkNum into a fixed, static physical connection.
390 [ScriptInvocation]
391 public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum)
392 {
393 int ret = -1;
394 if (!Enabled) return ret;
395
396 PhysicsActor rootPhysActor;
397 PhysicsActor childPhysActor;
398
399 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
400 {
401 object[] parms2 = { rootPhysActor, childPhysActor , PHYS_LINK_TYPE_FIXED };
402 ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2));
403 }
404
405 return ret;
406 }
407
408 // Code for specifying params.
409 // The choice if 14400 is arbitrary and only serves to catch parameter code misuse.
410 public const int PHYS_PARAM_MIN = 14401;
411
412 [ScriptConstant]
413 public const int PHYS_PARAM_FRAMEINA_LOC = 14401;
414 [ScriptConstant]
415 public const int PHYS_PARAM_FRAMEINA_ROT = 14402;
416 [ScriptConstant]
417 public const int PHYS_PARAM_FRAMEINB_LOC = 14403;
418 [ScriptConstant]
419 public const int PHYS_PARAM_FRAMEINB_ROT = 14404;
420 [ScriptConstant]
421 public const int PHYS_PARAM_LINEAR_LIMIT_LOW = 14405;
422 [ScriptConstant]
423 public const int PHYS_PARAM_LINEAR_LIMIT_HIGH = 14406;
424 [ScriptConstant]
425 public const int PHYS_PARAM_ANGULAR_LIMIT_LOW = 14407;
426 [ScriptConstant]
427 public const int PHYS_PARAM_ANGULAR_LIMIT_HIGH = 14408;
428 [ScriptConstant]
429 public const int PHYS_PARAM_USE_FRAME_OFFSET = 14409;
430 [ScriptConstant]
431 public const int PHYS_PARAM_ENABLE_TRANSMOTOR = 14410;
432 [ScriptConstant]
433 public const int PHYS_PARAM_TRANSMOTOR_MAXVEL = 14411;
434 [ScriptConstant]
435 public const int PHYS_PARAM_TRANSMOTOR_MAXFORCE = 14412;
436 [ScriptConstant]
437 public const int PHYS_PARAM_CFM = 14413;
438 [ScriptConstant]
439 public const int PHYS_PARAM_ERP = 14414;
440 [ScriptConstant]
441 public const int PHYS_PARAM_SOLVER_ITERATIONS = 14415;
442 [ScriptConstant]
443 public const int PHYS_PARAM_SPRING_AXIS_ENABLE = 14416;
444 [ScriptConstant]
445 public const int PHYS_PARAM_SPRING_DAMPING = 14417;
446 [ScriptConstant]
447 public const int PHYS_PARAM_SPRING_STIFFNESS = 14418;
448 [ScriptConstant]
449 public const int PHYS_PARAM_LINK_TYPE = 14419;
450 [ScriptConstant]
451 public const int PHYS_PARAM_USE_LINEAR_FRAMEA = 14420;
452 [ScriptConstant]
453 public const int PHYS_PARAM_SPRING_EQUILIBRIUM_POINT = 14421;
454
455 public const int PHYS_PARAM_MAX = 14421;
456
457 // Used when specifying a parameter that has settings for the three linear and three angular axis
458 [ScriptConstant]
459 public const int PHYS_AXIS_ALL = -1;
460 [ScriptConstant]
461 public const int PHYS_AXIS_LINEAR_ALL = -2;
462 [ScriptConstant]
463 public const int PHYS_AXIS_ANGULAR_ALL = -3;
464 [ScriptConstant]
465 public const int PHYS_AXIS_LINEAR_X = 0;
466 [ScriptConstant]
467 public const int PHYS_AXIS_LINEAR_Y = 1;
468 [ScriptConstant]
469 public const int PHYS_AXIS_LINEAR_Z = 2;
470 [ScriptConstant]
471 public const int PHYS_AXIS_ANGULAR_X = 3;
472 [ScriptConstant]
473 public const int PHYS_AXIS_ANGULAR_Y = 4;
474 [ScriptConstant]
475 public const int PHYS_AXIS_ANGULAR_Z = 5;
476
477 // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...])
478 [ScriptInvocation]
479 public int physChangeLinkParams(UUID hostID, UUID scriptID, int linkNum, object[] parms)
480 {
481 int ret = -1;
482 if (!Enabled) return ret;
483
484 PhysicsActor rootPhysActor;
485 PhysicsActor childPhysActor;
486
487 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
488 {
489 object[] parms2 = AddToBeginningOfArray(rootPhysActor, childPhysActor, parms);
490 ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, parms2));
491 }
492
493 return ret;
494 }
495
496 private bool GetRootPhysActor(UUID hostID, out PhysicsActor rootPhysActor)
497 {
498 SceneObjectGroup containingGroup;
499 SceneObjectPart rootPart;
500 return GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor);
501 }
502
503 private bool GetRootPhysActor(UUID hostID, out SceneObjectGroup containingGroup, out SceneObjectPart rootPart, out PhysicsActor rootPhysActor)
504 {
505 bool ret = false;
506 rootPhysActor = null;
507 containingGroup = null;
508 rootPart = null;
509
510 SceneObjectPart requestingPart;
511
512 requestingPart = BaseScene.GetSceneObjectPart(hostID);
513 if (requestingPart != null)
514 {
515 // The type is is always on the root of a linkset.
516 containingGroup = requestingPart.ParentGroup;
517 if (containingGroup != null && !containingGroup.IsDeleted)
518 {
519 rootPart = containingGroup.RootPart;
520 if (rootPart != null)
521 {
522 rootPhysActor = rootPart.PhysActor;
523 if (rootPhysActor != null)
524 {
525 ret = true;
526 }
527 else
528 {
529 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}",
530 LogHeader, rootPart.Name, hostID);
531 }
532 }
533 else
534 {
535 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not exist. RequestingPartName={1}, hostID={2}",
536 LogHeader, requestingPart.Name, hostID);
537 }
538 }
539 else
540 {
541 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Containing group missing or deleted. hostID={1}", LogHeader, hostID);
542 }
543 }
544 else
545 {
546 m_log.WarnFormat("{0} GetRootAndChildPhysActors: cannot find script object in scene. hostID={1}", LogHeader, hostID);
547 }
548
549 return ret;
550 }
551
552 // Find the root and child PhysActors based on the linkNum.
553 // Return 'true' if both are found and returned.
554 private bool GetRootAndChildPhysActors(UUID hostID, int linkNum, out PhysicsActor rootPhysActor, out PhysicsActor childPhysActor)
555 {
556 bool ret = false;
557 rootPhysActor = null;
558 childPhysActor = null;
559
560 SceneObjectGroup containingGroup;
561 SceneObjectPart rootPart;
562
563 if (GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor))
564 {
565 SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum);
566 if (linkPart != null)
567 {
568 childPhysActor = linkPart.PhysActor;
569 if (childPhysActor != null)
570 {
571 ret = true;
572 }
573 else
574 {
575 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}",
576 LogHeader, rootPart.Name, hostID, linkNum);
577 }
578 }
579 else
580 {
581 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}",
582 LogHeader, rootPart.Name, hostID, linkNum);
583 }
584 }
585 else
586 {
587 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}",
588 LogHeader, rootPart.Name, hostID);
589 }
590
591 return ret;
592 }
593
594 // Return an array of objects with the passed object as the first object of a new array
595 private object[] AddToBeginningOfArray(object firstOne, object secondOne, object[] prevArray)
596 {
597 object[] newArray = new object[2 + prevArray.Length];
598 newArray[0] = firstOne;
599 newArray[1] = secondOne;
600 prevArray.CopyTo(newArray, 2);
601 return newArray;
602 }
603
604 // Extension() returns an object. Convert that object into the integer error we expect to return.
605 private int MakeIntError(object extensionRet)
606 {
607 int ret = -1;
608 if (extensionRet != null)
609 {
610 try
611 {
612 ret = (int)extensionRet;
613 }
614 catch
615 {
616 ret = -1;
617 }
618 }
619 return ret;
620 }
621 }
622}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Properties/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/BulletS/Properties/AssemblyInfo.cs
index 4f90eee..5a33bdf 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/Properties/AssemblyInfo.cs
@@ -1,6 +1,7 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4using Mono.Addins;
4 5
5// General Information about an assembly is controlled through the following 6// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 7// set of attributes. Change these attribute values to modify the information
@@ -31,3 +32,5 @@ using System.Runtime.InteropServices;
31// 32//
32[assembly: AssemblyVersion("0.8.2.*")] 33[assembly: AssemblyVersion("0.8.2.*")]
33 34
35[assembly: Addin("OpenSim.Region.PhysicsModule.BulletS", OpenSim.VersionInfo.VersionNumber)]
36[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs b/OpenSim/Region/PhysicsModules/BulletS/Tests/BasicVehicles.cs
index 48e74eb..35eba29 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/Tests/BasicVehicles.cs
@@ -34,13 +34,13 @@ using NUnit.Framework;
34using log4net; 34using log4net;
35 35
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Region.Physics.BulletSPlugin; 37using OpenSim.Region.PhysicsModule.BulletS;
38using OpenSim.Region.Physics.Manager; 38using OpenSim.Region.PhysicsModules.SharedBase;
39using OpenSim.Tests.Common; 39using OpenSim.Tests.Common;
40 40
41using OpenMetaverse; 41using OpenMetaverse;
42 42
43namespace OpenSim.Region.Physics.BulletSPlugin.Tests 43namespace OpenSim.Region.PhysicsModule.BulletS.Tests
44{ 44{
45[TestFixture] 45[TestFixture]
46public class BasicVehicles : OpenSimTestCase 46public class BasicVehicles : OpenSimTestCase
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTests.cs b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs
index 35cbc1d..0be1f4c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTests.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs
@@ -35,7 +35,7 @@ using log4net;
35 35
36using OpenSim.Tests.Common; 36using OpenSim.Tests.Common;
37 37
38namespace OpenSim.Region.Physics.BulletSPlugin.Tests 38namespace OpenSim.Region.PhysicsModule.BulletS.Tests
39{ 39{
40[TestFixture] 40[TestFixture]
41public class BulletSimTests : OpenSimTestCase 41public class BulletSimTests : OpenSimTestCase
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTestsUtil.cs b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs
index 775bca2..4eeea4d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTestsUtil.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs
@@ -33,12 +33,13 @@ using System.Text;
33using Nini.Config; 33using Nini.Config;
34 34
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Physics.Manager; 36using OpenSim.Region.PhysicsModules.SharedBase;
37using OpenSim.Region.Physics.Meshing; 37using OpenSim.Region.PhysicsModules.Meshing;
38using OpenSim.Region.Framework.Interfaces;
38 39
39using OpenMetaverse; 40using OpenMetaverse;
40 41
41namespace OpenSim.Region.Physics.BulletSPlugin.Tests 42namespace OpenSim.Region.PhysicsModule.BulletS.Tests
42{ 43{
43// Utility functions for building up and tearing down the sample physics environments 44// Utility functions for building up and tearing down the sample physics environments
44public static class BulletSimTestsUtil 45public static class BulletSimTestsUtil
@@ -78,22 +79,30 @@ public static class BulletSimTestsUtil
78 bulletSimConfig.Set("VehicleLoggingEnabled","True"); 79 bulletSimConfig.Set("VehicleLoggingEnabled","True");
79 } 80 }
80 81
81 PhysicsPluginManager physicsPluginManager;
82 physicsPluginManager = new PhysicsPluginManager();
83 physicsPluginManager.LoadPluginsFromAssemblies("Physics");
84
85 Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); 82 Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
86 83
87 PhysicsScene pScene = physicsPluginManager.GetPhysicsScene( 84 RegionInfo info = new RegionInfo();
88 "BulletSim", "Meshmerizer", openSimINI, "BSTestRegion", regionExtent); 85 info.RegionName = "BSTestRegion";
86 info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize;
87 OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info);
88
89 IMesher mesher = new OpenSim.Region.PhysicsModules.Meshing.Meshmerizer();
90 INonSharedRegionModule mod = mesher as INonSharedRegionModule;
91 mod.Initialise(openSimINI);
92 mod.AddRegion(scene);
93 mod.RegionLoaded(scene);
89 94
90 BSScene bsScene = pScene as BSScene; 95 BSScene pScene = new BSScene();
96 mod = (pScene as INonSharedRegionModule);
97 mod.Initialise(openSimINI);
98 mod.AddRegion(scene);
99 mod.RegionLoaded(scene);
91 100
92 // Since the asset requestor is not initialized, any mesh or sculptie will be a cube. 101 // Since the asset requestor is not initialized, any mesh or sculptie will be a cube.
93 // In the future, add a fake asset fetcher to get meshes and sculpts. 102 // In the future, add a fake asset fetcher to get meshes and sculpts.
94 // bsScene.RequestAssetMethod = ???; 103 // bsScene.RequestAssetMethod = ???;
95 104
96 return bsScene; 105 return pScene;
97 } 106 }
98 107
99} 108}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/HullCreation.cs b/OpenSim/Region/PhysicsModules/BulletS/Tests/HullCreation.cs
index 5a5de11..c0cf19a 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/Tests/HullCreation.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/Tests/HullCreation.cs
@@ -34,13 +34,13 @@ using NUnit.Framework;
34using log4net; 34using log4net;
35 35
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Region.Physics.BulletSPlugin; 37using OpenSim.Region.PhysicsModule.BulletS;
38using OpenSim.Region.Physics.Manager; 38using OpenSim.Region.PhysicsModules.SharedBase;
39using OpenSim.Tests.Common; 39using OpenSim.Tests.Common;
40 40
41using OpenMetaverse; 41using OpenMetaverse;
42 42
43namespace OpenSim.Region.Physics.BulletSPlugin.Tests 43namespace OpenSim.Region.PhysicsModule.BulletS.Tests
44{ 44{
45[TestFixture] 45[TestFixture]
46public class HullCreation : OpenSimTestCase 46public class HullCreation : OpenSimTestCase
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/CTri.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/CTri.cs
index 4d84c44..7ad689e 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/CTri.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/CTri.cs
@@ -28,7 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 31namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
32{ 32{
33 public class Wpoint 33 public class Wpoint
34 { 34 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/Concavity.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Concavity.cs
index cc6383a..4140d25 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/Concavity.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Concavity.cs
@@ -29,7 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31 31
32namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 32namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
33{ 33{
34 public static class Concavity 34 public static class Concavity
35 { 35 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/ConvexBuilder.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/ConvexBuilder.cs
index dfaede1..70c3a2b 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/ConvexBuilder.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/ConvexBuilder.cs
@@ -29,7 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics; 30using System.Diagnostics;
31 31
32namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 32namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
33{ 33{
34 public class DecompDesc 34 public class DecompDesc
35 { 35 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/ConvexDecomposition.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/ConvexDecomposition.cs
index 2e2bb70..5046bce 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/ConvexDecomposition.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/ConvexDecomposition.cs
@@ -29,7 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics; 30using System.Diagnostics;
31 31
32namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 32namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
33{ 33{
34 public delegate void ConvexDecompositionCallback(ConvexResult result); 34 public delegate void ConvexDecompositionCallback(ConvexResult result);
35 35
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/ConvexResult.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/ConvexResult.cs
index 87758b5..44e3e50 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/ConvexResult.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/ConvexResult.cs
@@ -28,7 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 31namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
32{ 32{
33 public class ConvexResult 33 public class ConvexResult
34 { 34 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/HullClasses.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullClasses.cs
index d81df26..8a0164e 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/HullClasses.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullClasses.cs
@@ -28,7 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 31namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
32{ 32{
33 public class HullResult 33 public class HullResult
34 { 34 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/HullTriangle.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullTriangle.cs
index 1119a75..d3f0052 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/HullTriangle.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullTriangle.cs
@@ -29,7 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics; 30using System.Diagnostics;
31 31
32namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 32namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
33{ 33{
34 public class HullTriangle : int3 34 public class HullTriangle : int3
35 { 35 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/HullUtils.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs
index c9ccfe2..3903254 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/HullUtils.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs
@@ -29,7 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics; 30using System.Diagnostics;
31 31
32namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 32namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
33{ 33{
34 public static class HullUtils 34 public static class HullUtils
35 { 35 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/LICENSE.txt b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/LICENSE.txt
index 714ae89..714ae89 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/LICENSE.txt
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/LICENSE.txt
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/Plane.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Plane.cs
index d099676..da9ae0c 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/Plane.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Plane.cs
@@ -27,7 +27,7 @@
27 27
28using System; 28using System;
29 29
30namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 30namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
31{ 31{
32 public class Plane 32 public class Plane
33 { 33 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/PlaneTri.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/PlaneTri.cs
index 31f0182..42f7a22 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/PlaneTri.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/PlaneTri.cs
@@ -29,7 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics; 30using System.Diagnostics;
31 31
32namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 32namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
33{ 33{
34 public enum PlaneTriResult : int 34 public enum PlaneTriResult : int
35 { 35 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/Properties/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Properties/AssemblyInfo.cs
index c5867b2..c5867b2 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Properties/AssemblyInfo.cs
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/Quaternion.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Quaternion.cs
index 0ba8f17..045f620 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/Quaternion.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/Quaternion.cs
@@ -27,7 +27,7 @@
27 27
28using System; 28using System;
29 29
30namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 30namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
31{ 31{
32 public class Quaternion : float4 32 public class Quaternion : float4
33 { 33 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/README.txt b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/README.txt
index fc53ae7..fc53ae7 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/README.txt
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/README.txt
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/SplitPlane.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/SplitPlane.cs
index 9f06a9a..9f56bc5 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/SplitPlane.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/SplitPlane.cs
@@ -28,7 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 31namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
32{ 32{
33 public class Rect3d 33 public class Rect3d
34 { 34 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/VertexLookup.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/VertexLookup.cs
index 6f17c9f..bfe11e5 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/VertexLookup.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/VertexLookup.cs
@@ -28,7 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 31namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
32{ 32{
33 public class VertexPool 33 public class VertexPool
34 { 34 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/float2.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float2.cs
index ce88fc8..e7358c1 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/float2.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float2.cs
@@ -27,7 +27,7 @@
27 27
28using System; 28using System;
29 29
30namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 30namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
31{ 31{
32 public class float2 32 public class float2
33 { 33 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/float3.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float3.cs
index 4389114..fde9b32 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/float3.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float3.cs
@@ -27,7 +27,7 @@
27 27
28using System; 28using System;
29 29
30namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 30namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
31{ 31{
32 public class float3 : IEquatable<float3> 32 public class float3 : IEquatable<float3>
33 { 33 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/float3x3.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float3x3.cs
index 76cf063..c420fde 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/float3x3.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float3x3.cs
@@ -29,7 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics; 30using System.Diagnostics;
31 31
32namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 32namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
33{ 33{
34 public class float3x3 34 public class float3x3
35 { 35 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/float4.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float4.cs
index fa60876..b2b6fd3 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/float4.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float4.cs
@@ -27,7 +27,7 @@
27 27
28using System; 28using System;
29 29
30namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 30namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
31{ 31{
32 public class float4 32 public class float4
33 { 33 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/float4x4.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float4x4.cs
index 7d1592f..087eba7 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/float4x4.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float4x4.cs
@@ -30,7 +30,7 @@ using System.Collections.Generic;
30using System.Linq; 30using System.Linq;
31using System.Text; 31using System.Text;
32 32
33namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 33namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
34{ 34{
35 public class float4x4 35 public class float4x4
36 { 36 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/int3.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/int3.cs
index 9c5760d..90624eb 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/int3.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/int3.cs
@@ -27,7 +27,7 @@
27 27
28using System; 28using System;
29 29
30namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 30namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
31{ 31{
32 public class int3 32 public class int3
33 { 33 {
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/int4.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/int4.cs
index c2b32e5..e9320c0 100644
--- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/int4.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/int4.cs
@@ -27,7 +27,7 @@
27 27
28using System; 28using System;
29 29
30namespace OpenSim.Region.Physics.ConvexDecompositionDotNet 30namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet
31{ 31{
32 public class int4 32 public class int4
33 { 33 {
diff --git a/OpenSim/Region/Physics/Meshing/HelperTypes.cs b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/HelperTypes.cs
index 8cd8dcf..34a925d 100644
--- a/OpenSim/Region/Physics/Meshing/HelperTypes.cs
+++ b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/HelperTypes.cs
@@ -30,8 +30,8 @@ using System.Collections.Generic;
30using System.Diagnostics; 30using System.Diagnostics;
31using System.Globalization; 31using System.Globalization;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34using OpenSim.Region.Physics.Meshing; 34using OpenSim.Region.PhysicsModules.Meshing;
35 35
36public class Vertex : IComparable<Vertex> 36public class Vertex : IComparable<Vertex>
37{ 37{
diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Mesh.cs
index e6b32e7..8c97f2f 100644
--- a/OpenSim/Region/Physics/Meshing/Mesh.cs
+++ b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Mesh.cs
@@ -29,11 +29,11 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Runtime.InteropServices; 31using System.Runtime.InteropServices;
32using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.PhysicsModules.SharedBase;
33using PrimMesher; 33using PrimMesher;
34using OpenMetaverse; 34using OpenMetaverse;
35 35
36namespace OpenSim.Region.Physics.Meshing 36namespace OpenSim.Region.PhysicsModules.Meshing
37{ 37{
38 public class Mesh : IMesh 38 public class Mesh : IMesh
39 { 39 {
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs
index ef6482a..bae3449 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs
@@ -28,8 +28,12 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection;
32using System.IO;
31using OpenSim.Framework; 33using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.PhysicsModules.SharedBase;
33using OpenMetaverse; 37using OpenMetaverse;
34using OpenMetaverse.StructuredData; 38using OpenMetaverse.StructuredData;
35using System.Drawing; 39using System.Drawing;
@@ -38,29 +42,12 @@ using System.IO.Compression;
38using PrimMesher; 42using PrimMesher;
39using log4net; 43using log4net;
40using Nini.Config; 44using Nini.Config;
41using System.Reflection; 45using Mono.Addins;
42using System.IO;
43 46
44namespace OpenSim.Region.Physics.Meshing 47namespace OpenSim.Region.PhysicsModules.Meshing
45{ 48{
46 public class MeshmerizerPlugin : IMeshingPlugin 49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "Meshmerizer")]
47 { 50 public class Meshmerizer : IMesher, INonSharedRegionModule
48 public MeshmerizerPlugin()
49 {
50 }
51
52 public string GetName()
53 {
54 return "Meshmerizer";
55 }
56
57 public IMesher GetMesher(IConfigSource config)
58 {
59 return new Meshmerizer(config);
60 }
61 }
62
63 public class Meshmerizer : IMesher
64 { 51 {
65 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
66 private static string LogHeader = "[MESH]"; 53 private static string LogHeader = "[MESH]";
@@ -72,6 +59,8 @@ namespace OpenSim.Region.Physics.Meshing
72#else 59#else
73 private const string baseDir = null; //"rawFiles"; 60 private const string baseDir = null; //"rawFiles";
74#endif 61#endif
62 private bool m_Enabled = false;
63
75 // If 'true', lots of DEBUG logging of asset parsing details 64 // If 'true', lots of DEBUG logging of asset parsing details
76 private bool debugDetail = false; 65 private bool debugDetail = false;
77 66
@@ -87,30 +76,79 @@ namespace OpenSim.Region.Physics.Meshing
87 // Mesh cache. Static so it can be shared across instances of this class 76 // Mesh cache. Static so it can be shared across instances of this class
88 private static Dictionary<ulong, Mesh> m_uniqueMeshes = new Dictionary<ulong, Mesh>(); 77 private static Dictionary<ulong, Mesh> m_uniqueMeshes = new Dictionary<ulong, Mesh>();
89 78
90 public Meshmerizer(IConfigSource config) 79 #region INonSharedRegionModule
80 public string Name
91 { 81 {
92 IConfig start_config = config.Configs["Startup"]; 82 get { return "Meshmerizer"; }
93 IConfig mesh_config = config.Configs["Mesh"]; 83 }
94 84
95 decodedSculptMapPath = start_config.GetString("DecodedSculptMapPath","j2kDecodeCache"); 85 public Type ReplaceableInterface
96 cacheSculptMaps = start_config.GetBoolean("CacheSculptMaps", cacheSculptMaps); 86 {
97 if (mesh_config != null) 87 get { return null; }
98 { 88 }
99 useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh);
100 debugDetail = mesh_config.GetBoolean("LogMeshDetails", debugDetail);
101 }
102 89
103 try 90 public void Initialise(IConfigSource source)
104 { 91 {
105 if (!Directory.Exists(decodedSculptMapPath)) 92 IConfig config = source.Configs["Startup"];
106 Directory.CreateDirectory(decodedSculptMapPath); 93 if (config != null)
107 }
108 catch (Exception e)
109 { 94 {
110 m_log.WarnFormat("[SCULPT]: Unable to create {0} directory: ", decodedSculptMapPath, e.Message); 95 string mesher = config.GetString("meshing", string.Empty);
96 if (mesher == Name)
97 {
98 m_Enabled = true;
99
100 IConfig mesh_config = source.Configs["Mesh"];
101
102 decodedSculptMapPath = config.GetString("DecodedSculptMapPath", "j2kDecodeCache");
103 cacheSculptMaps = config.GetBoolean("CacheSculptMaps", cacheSculptMaps);
104 if (mesh_config != null)
105 {
106 useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh);
107 debugDetail = mesh_config.GetBoolean("LogMeshDetails", debugDetail);
108 }
109
110 try
111 {
112 if (!Directory.Exists(decodedSculptMapPath))
113 Directory.CreateDirectory(decodedSculptMapPath);
114 }
115 catch (Exception e)
116 {
117 m_log.WarnFormat("[SCULPT]: Unable to create {0} directory: ", decodedSculptMapPath, e.Message);
118 }
119
120 }
111 } 121 }
112 } 122 }
113 123
124 public void Close()
125 {
126 }
127
128 public void AddRegion(Scene scene)
129 {
130 if (!m_Enabled)
131 return;
132
133 scene.RegisterModuleInterface<IMesher>(this);
134 }
135
136 public void RemoveRegion(Scene scene)
137 {
138 if (!m_Enabled)
139 return;
140
141 scene.UnregisterModuleInterface<IMesher>(this);
142 }
143
144 public void RegionLoaded(Scene scene)
145 {
146 if (!m_Enabled)
147 return;
148 }
149 #endregion
150
151
114 /// <summary> 152 /// <summary>
115 /// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may 153 /// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may
116 /// be useful as a backup proxy when level of detail is not needed or when more complex meshes fail 154 /// be useful as a backup proxy when level of detail is not needed or when more complex meshes fail
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/PrimMesher.cs
index 4049ee1..4049ee1 100644
--- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs
+++ b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/PrimMesher.cs
diff --git a/OpenSim/Region/Physics/Meshing/SculptMap.cs b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/SculptMap.cs
index b3d9cb6..b3d9cb6 100644
--- a/OpenSim/Region/Physics/Meshing/SculptMap.cs
+++ b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/SculptMap.cs
diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/SculptMesh.cs
index 4a7f3ad..4a7f3ad 100644
--- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs
+++ b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/SculptMesh.cs
diff --git a/OpenSim/Region/RegionCombinerModule/Properties/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/Meshing/Properties/AssemblyInfo.cs
index 11b89d2..d6ac8b2 100644
--- a/OpenSim/Region/RegionCombinerModule/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/PhysicsModules/Meshing/Properties/AssemblyInfo.cs
@@ -6,7 +6,7 @@ using Mono.Addins;
6// General Information about an assembly is controlled through the following 6// General Information about an assembly is controlled through the following
7// set of attributes. Change these attribute values to modify the information 7// set of attributes. Change these attribute values to modify the information
8// associated with an assembly. 8// associated with an assembly.
9[assembly: AssemblyTitle("OpenSim.Region.RegionCombinerModule")] 9[assembly: AssemblyTitle("OpenSim.Region.PhysicsModules.Meshing")]
10[assembly: AssemblyDescription("")] 10[assembly: AssemblyDescription("")]
11[assembly: AssemblyConfiguration("")] 11[assembly: AssemblyConfiguration("")]
12[assembly: AssemblyCompany("http://opensimulator.org")] 12[assembly: AssemblyCompany("http://opensimulator.org")]
@@ -21,7 +21,7 @@ using Mono.Addins;
21[assembly: ComVisible(false)] 21[assembly: ComVisible(false)]
22 22
23// The following GUID is for the ID of the typelib if this project is exposed to COM 23// The following GUID is for the ID of the typelib if this project is exposed to COM
24[assembly: Guid("73c166d2-c9d8-4ab8-af4e-89c41b4b58a9")] 24[assembly: Guid("4b7e35c2-a9dd-4b10-b778-eb417f4f6884")]
25 25
26// Version information for an assembly consists of the following four values: 26// Version information for an assembly consists of the following four values:
27// 27//
@@ -32,5 +32,5 @@ using Mono.Addins;
32// 32//
33[assembly: AssemblyVersion("0.8.2.*")] 33[assembly: AssemblyVersion("0.8.2.*")]
34 34
35[assembly: Addin("OpenSim.RegionModules.RegionCombinerModule", OpenSim.VersionInfo.VersionNumber)] 35[assembly: Addin("OpenSim.Region.PhysicsModules.Meshing", OpenSim.VersionInfo.VersionNumber)]
36[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)] 36[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
diff --git a/OpenSim/Region/Physics/Manager/ZeroMesher.cs b/OpenSim/Region/PhysicsModules/Meshing/ZeroMesher.cs
index 890951f..09676c6 100644
--- a/OpenSim/Region/Physics/Manager/ZeroMesher.cs
+++ b/OpenSim/Region/PhysicsModules/Meshing/ZeroMesher.cs
@@ -26,9 +26,15 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection;
29using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes;
32using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.PhysicsModules.SharedBase;
30using OpenMetaverse; 34using OpenMetaverse;
31using Nini.Config; 35using Nini.Config;
36using Mono.Addins;
37using log4net;
32 38
33/* 39/*
34 * This is the zero mesher. 40 * This is the zero mesher.
@@ -41,27 +47,67 @@ using Nini.Config;
41 * it's always availabe and thus the default in case of configuration errors 47 * it's always availabe and thus the default in case of configuration errors
42*/ 48*/
43 49
44namespace OpenSim.Region.Physics.Manager 50namespace OpenSim.Region.PhysicsModules.Meshing
45{ 51{
46 public class ZeroMesherPlugin : IMeshingPlugin 52
53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ZeroMesher")]
54 public class ZeroMesher : IMesher, INonSharedRegionModule
47 { 55 {
48 public ZeroMesherPlugin() 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
57 private bool m_Enabled = false;
58
59 #region INonSharedRegionModule
60 public string Name
49 { 61 {
62 get { return "ZeroMesher"; }
50 } 63 }
51 64
52 public string GetName() 65 public Type ReplaceableInterface
53 { 66 {
54 return "ZeroMesher"; 67 get { return null; }
55 } 68 }
56 69
57 public IMesher GetMesher(IConfigSource config) 70 public void Initialise(IConfigSource source)
58 { 71 {
59 return new ZeroMesher(); 72 // TODO: Move this out of Startup
73 IConfig config = source.Configs["Startup"];
74 if (config != null)
75 {
76 // This is the default Mesher
77 string mesher = config.GetString("meshing", Name);
78 if (mesher == Name)
79 m_Enabled = true;
80 }
60 } 81 }
61 }
62 82
63 public class ZeroMesher : IMesher 83 public void Close()
64 { 84 {
85 }
86
87 public void AddRegion(Scene scene)
88 {
89 if (!m_Enabled)
90 return;
91
92 scene.RegisterModuleInterface<IMesher>(this);
93 }
94
95 public void RemoveRegion(Scene scene)
96 {
97 if (!m_Enabled)
98 return;
99
100 scene.UnregisterModuleInterface<IMesher>(this);
101 }
102
103 public void RegionLoaded(Scene scene)
104 {
105 if (!m_Enabled)
106 return;
107 }
108 #endregion
109
110 #region IMesher
65 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod) 111 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
66 { 112 {
67 return CreateMesh(primName, primShape, size, lod, false); 113 return CreateMesh(primName, primShape, size, lod, false);
@@ -93,5 +139,7 @@ namespace OpenSim.Region.Physics.Manager
93 public void ReleaseMesh(IMesh mesh) { } 139 public void ReleaseMesh(IMesh mesh) { }
94 public void ExpireReleaseMeshs() { } 140 public void ExpireReleaseMeshs() { }
95 public void ExpireFileCache() { } 141 public void ExpireFileCache() { }
142
143 #endregion
96 } 144 }
97} 145}
diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/Ode/AssemblyInfo.cs
index 076da78..7869739 100644
--- a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/AssemblyInfo.cs
@@ -27,6 +27,7 @@
27 27
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30using Mono.Addins;
30 31
31// Information about this assembly is defined by the following 32// Information about this assembly is defined by the following
32// attributes. 33// attributes.
@@ -56,3 +57,6 @@ using System.Runtime.InteropServices;
56// numbers with the '*' character (the default): 57// numbers with the '*' character (the default):
57 58
58[assembly : AssemblyVersion("0.8.2.*")] 59[assembly : AssemblyVersion("0.8.2.*")]
60
61[assembly: Addin("OpenSim.Region.PhysicsModule.ODE", OpenSim.VersionInfo.VersionNumber)]
62[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs
index 05eaf2a..b35c299 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs
@@ -31,10 +31,10 @@ using System.Reflection;
31using OpenMetaverse; 31using OpenMetaverse;
32using Ode.NET; 32using Ode.NET;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.PhysicsModules.SharedBase;
35using log4net; 35using log4net;
36 36
37namespace OpenSim.Region.Physics.OdePlugin 37namespace OpenSim.Region.PhysicsModule.ODE
38{ 38{
39 /// <summary> 39 /// <summary>
40 /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves. 40 /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves.
@@ -511,7 +511,7 @@ namespace OpenSim.Region.Physics.OdePlugin
511 } 511 }
512 else 512 else
513 { 513 {
514 m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Size for {0} in {1}", Name, _parent_scene.Name); 514 m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Size for {0} in {1}", Name, _parent_scene.PhysicsSceneName);
515 } 515 }
516 } 516 }
517 517
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.c_comments b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.c_comments
index 1060aa6..1060aa6 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.c_comments
+++ b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.c_comments
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs
index 2342bfa..8f8e2bd 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs
@@ -46,9 +46,9 @@ using log4net;
46using OpenMetaverse; 46using OpenMetaverse;
47using Ode.NET; 47using Ode.NET;
48using OpenSim.Framework; 48using OpenSim.Framework;
49using OpenSim.Region.Physics.Manager; 49using OpenSim.Region.PhysicsModules.SharedBase;
50 50
51namespace OpenSim.Region.Physics.OdePlugin 51namespace OpenSim.Region.PhysicsModule.ODE
52{ 52{
53 public class ODEDynamics 53 public class ODEDynamics
54 { 54 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs
index 0a99e30..5e48de6 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs
@@ -50,9 +50,9 @@ using log4net;
50using OpenMetaverse; 50using OpenMetaverse;
51using Ode.NET; 51using Ode.NET;
52using OpenSim.Framework; 52using OpenSim.Framework;
53using OpenSim.Region.Physics.Manager; 53using OpenSim.Region.PhysicsModules.SharedBase;
54 54
55namespace OpenSim.Region.Physics.OdePlugin 55namespace OpenSim.Region.PhysicsModule.ODE
56{ 56{
57 /// <summary> 57 /// <summary>
58 /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves. 58 /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves.
@@ -3381,7 +3381,7 @@ Console.WriteLine(" JointCreateFixed");
3381 { 3381 {
3382 m_log.WarnFormat( 3382 m_log.WarnFormat(
3383 "[ODE PRIM]: Could not get mesh/sculpt asset {0} for {1} at {2} in {3}", 3383 "[ODE PRIM]: Could not get mesh/sculpt asset {0} for {1} at {2} in {3}",
3384 _pbs.SculptTexture, Name, _position, _parent_scene.Name); 3384 _pbs.SculptTexture, Name, _position, _parent_scene.PhysicsSceneName);
3385 } 3385 }
3386 } 3386 }
3387 } 3387 }
diff --git a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs
index fa2ed3e..80f0fcf 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs
@@ -31,11 +31,11 @@ using System.Reflection;
31using System.Runtime.InteropServices; 31using System.Runtime.InteropServices;
32using System.Text; 32using System.Text;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.PhysicsModules.SharedBase;
35using Ode.NET; 35using Ode.NET;
36using log4net; 36using log4net;
37 37
38namespace OpenSim.Region.Physics.OdePlugin 38namespace OpenSim.Region.PhysicsModule.ODE
39{ 39{
40 /// <summary> 40 /// <summary>
41 /// Processes raycast requests as ODE is in a state to be able to do them. 41 /// Processes raycast requests as ODE is in a state to be able to do them.
@@ -172,7 +172,9 @@ namespace OpenSim.Region.Physics.OdePlugin
172 /// <param name="req"></param> 172 /// <param name="req"></param>
173 private void RayCast(ODERayCastRequest req) 173 private void RayCast(ODERayCastRequest req)
174 { 174 {
175 // limit ray lenght or collisions will take all avaiable stack space 175 // NOTE: limit ray lenght or collisions will take all avaiable stack space
176 // this value may still be too large, depending on machine configuration
177 // of maximum stack
176 float len = req.length; 178 float len = req.length;
177 if (len > 250f) 179 if (len > 250f)
178 len = 250f; 180 len = 250f;
@@ -441,4 +443,4 @@ namespace OpenSim.Region.Physics.OdePlugin
441 public float length; 443 public float length;
442 public RayCallback callbackMethod; 444 public RayCallback callbackMethod;
443 } 445 }
444} \ No newline at end of file 446}
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePhysicsJoint.cs b/OpenSim/Region/PhysicsModules/Ode/OdePhysicsJoint.cs
index b4a3c48..2eb7ba6 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePhysicsJoint.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/OdePhysicsJoint.cs
@@ -29,10 +29,10 @@ using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using Ode.NET; 30using Ode.NET;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.PhysicsModules.SharedBase;
33using OpenSim.Region.Physics.OdePlugin; 33using OpenSim.Region.PhysicsModule.ODE;
34 34
35namespace OpenSim.Region.Physics.OdePlugin 35namespace OpenSim.Region.PhysicsModule.ODE
36{ 36{
37 class OdePhysicsJoint : PhysicsJoint 37 class OdePhysicsJoint : PhysicsJoint
38 { 38 {
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs
index 812b469..26210d6 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs
@@ -25,13 +25,11 @@
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// Ubit changes for varsize regions 28// changes for varsize regions
29// using a large Heightfield geometry for terrain 29// note that raycasts need to have limited range
30// ODE ode should handle it fine
31// EXCEPT raycasts, those need to have limited range
32// (even in normal regions) 30// (even in normal regions)
33// or aplication stack will just blowup 31// or aplication thread stack may just blowup
34 32// see RayCast(ODERayCastRequest req)
35 33
36//#define USE_DRAWSTUFF 34//#define USE_DRAWSTUFF
37//#define SPAM 35//#define SPAM
@@ -46,15 +44,19 @@ using System.Runtime.InteropServices;
46using System.Threading; 44using System.Threading;
47using log4net; 45using log4net;
48using Nini.Config; 46using Nini.Config;
47using Mono.Addins;
49using Ode.NET; 48using Ode.NET;
50using OpenMetaverse; 49using OpenMetaverse;
51#if USE_DRAWSTUFF 50#if USE_DRAWSTUFF
52using Drawstuff.NET; 51using Drawstuff.NET;
53#endif 52#endif
54using OpenSim.Framework; 53using OpenSim.Framework;
55using OpenSim.Region.Physics.Manager; 54using OpenSim.Region.PhysicsModules.SharedBase;
55using OpenSim.Region.Framework.Scenes;
56using OpenSim.Region.Framework.Interfaces;
57
56 58
57namespace OpenSim.Region.Physics.OdePlugin 59namespace OpenSim.Region.PhysicsModule.ODE
58{ 60{
59 public enum StatusIndicators : int 61 public enum StatusIndicators : int
60 { 62 {
@@ -109,9 +111,12 @@ namespace OpenSim.Region.Physics.OdePlugin
109 Rubber = 6 111 Rubber = 6
110 } 112 }
111 113
112 public class OdeScene : PhysicsScene 114 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ODEPhysicsScene")]
115 public class OdeScene : PhysicsScene, INonSharedRegionModule
113 { 116 {
114 private readonly ILog m_log; 117 private readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString());
118 private bool m_Enabled = false;
119
115 // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); 120 // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>();
116 121
117 /// <summary> 122 /// <summary>
@@ -298,7 +303,7 @@ namespace OpenSim.Region.Physics.OdePlugin
298 private int framecount = 0; 303 private int framecount = 0;
299 //private int m_returncollisions = 10; 304 //private int m_returncollisions = 10;
300 305
301 private readonly IntPtr contactgroup; 306 private IntPtr contactgroup;
302 307
303// internal IntPtr WaterGeom; 308// internal IntPtr WaterGeom;
304 309
@@ -530,19 +535,103 @@ namespace OpenSim.Region.Physics.OdePlugin
530 535
531 private ODERayCastRequestManager m_rayCastManager; 536 private ODERayCastRequestManager m_rayCastManager;
532 537
538
539 #region INonSharedRegionModule
540 public string Name
541 {
542 get { return "OpenDynamicsEngine"; }
543 }
544
545 public Type ReplaceableInterface
546 {
547 get { return null; }
548 }
549
550 public void Initialise(IConfigSource source)
551 {
552 // TODO: Move this out of Startup
553 IConfig config = source.Configs["Startup"];
554 if (config != null)
555 {
556 string physics = config.GetString("physics", string.Empty);
557 if (physics == Name)
558 {
559 m_Enabled = true;
560 m_config = source;
561
562 // We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether
563 // it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports
564 // will find it already loaded later on.
565 //
566 // This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be
567 // controlled in Ode.NET.dll.config
568 if (Util.IsWindows())
569 Util.LoadArchSpecificWindowsDll("ode.dll");
570
571 // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
572 // http://opensimulator.org/mantis/view.php?id=2750).
573 d.InitODE();
574
575 }
576 }
577
578 }
579
580 public void Close()
581 {
582 }
583
584 public void AddRegion(Scene scene)
585 {
586 if (!m_Enabled)
587 return;
588
589 EngineType = Name;
590 PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName;
591
592 scene.RegisterModuleInterface<PhysicsScene>(this);
593 Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
594 Initialise(extent);
595 InitialiseFromConfig(m_config);
596
597 // This may not be that good since terrain may not be avaiable at this point
598 base.Initialise(scene.PhysicsRequestAsset,
599 (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[(int)(extent.X * extent.Y)]),
600 (float)scene.RegionInfo.RegionSettings.WaterHeight);
601
602 }
603
604 public void RemoveRegion(Scene scene)
605 {
606 if (!m_Enabled)
607 return;
608 }
609
610 public void RegionLoaded(Scene scene)
611 {
612 if (!m_Enabled)
613 return;
614
615 mesher = scene.RequestModuleInterface<IMesher>();
616 if (mesher == null)
617 m_log.WarnFormat("[ODE SCENE]: No mesher in {0}. Things will not work well.", PhysicsSceneName);
618 }
619 #endregion
620
533 /// <summary> 621 /// <summary>
534 /// Initiailizes the scene 622 /// Initiailizes the scene
535 /// Sets many properties that ODE requires to be stable 623 /// Sets many properties that ODE requires to be stable
536 /// These settings need to be tweaked 'exactly' right or weird stuff happens. 624 /// These settings need to be tweaked 'exactly' right or weird stuff happens.
537 /// </summary> 625 /// </summary>
538 /// <param value="name">Name of the scene. Useful in debug messages.</param> 626 private void Initialise(Vector3 regionExtent)
539 public OdeScene(string engineType, string name)
540 { 627 {
541 m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name); 628 WorldExtents.X = regionExtent.X;
542 629 m_regionWidth = (uint)regionExtent.X;
543 Name = name; 630 WorldExtents.Y = regionExtent.Y;
544 EngineType = engineType; 631 m_regionHeight = (uint)regionExtent.Y;
545 632
633 m_suportCombine = false;
634
546 nearCallback = near; 635 nearCallback = near;
547 triCallback = TriCallback; 636 triCallback = TriCallback;
548 triArrayCallback = TriArrayCallback; 637 triArrayCallback = TriArrayCallback;
@@ -597,7 +686,6 @@ namespace OpenSim.Region.Physics.OdePlugin
597 { 686 {
598 InitializeExtraStats(); 687 InitializeExtraStats();
599 688
600 mesher = meshmerizer;
601 m_config = config; 689 m_config = config;
602 // Defaults 690 // Defaults
603 691
@@ -725,11 +813,11 @@ namespace OpenSim.Region.Physics.OdePlugin
725 spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeterX); 813 spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeterX);
726 spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeterY); 814 spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeterY);
727 815
728 // ubit: limit number of spaces 816 // note: limit number of spaces
729 if (spaceGridMaxX > 24) 817 if (spaceGridMaxX > 24)
730 { 818 {
731 spaceGridMaxX = 24; 819 spaceGridMaxX = 24;
732 spacesPerMeterX = spaceGridMaxX / WorldExtents.X ; 820 spacesPerMeterX = spaceGridMaxX / WorldExtents.X;
733 } 821 }
734 if (spaceGridMaxY > 24) 822 if (spaceGridMaxY > 24)
735 { 823 {
@@ -1862,7 +1950,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1862 } 1950 }
1863 catch (AccessViolationException) 1951 catch (AccessViolationException)
1864 { 1952 {
1865 m_log.ErrorFormat("[ODE SCENE]: Unable to space collide {0}", Name); 1953 m_log.ErrorFormat("[ODE SCENE]: Unable to space collide {0}", PhysicsSceneName);
1866 } 1954 }
1867 1955
1868 //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y); 1956 //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y);
@@ -3119,7 +3207,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3119 { 3207 {
3120 m_log.ErrorFormat( 3208 m_log.ErrorFormat(
3121 "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when moving", 3209 "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when moving",
3122 actor.Name, actor.LocalID, Name); 3210 actor.Name, actor.LocalID, PhysicsSceneName);
3123 3211
3124 RemoveCharacter(actor); 3212 RemoveCharacter(actor);
3125 actor.DestroyOdeStructures(); 3213 actor.DestroyOdeStructures();
@@ -3236,7 +3324,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3236 { 3324 {
3237 m_log.ErrorFormat( 3325 m_log.ErrorFormat(
3238 "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when updating position and velocity", 3326 "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when updating position and velocity",
3239 actor.Name, actor.LocalID, Name); 3327 actor.Name, actor.LocalID, PhysicsSceneName);
3240 3328
3241 RemoveCharacter(actor); 3329 RemoveCharacter(actor);
3242 actor.DestroyOdeStructures(); 3330 actor.DestroyOdeStructures();
@@ -3835,7 +3923,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3835 private void SetTerrain(float[] heightMap, Vector3 pOffset) 3923 private void SetTerrain(float[] heightMap, Vector3 pOffset)
3836 { 3924 {
3837 int startTime = Util.EnvironmentTickCount(); 3925 int startTime = Util.EnvironmentTickCount();
3838 m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", Name, pOffset); 3926 m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", PhysicsSceneName, pOffset);
3839 3927
3840 3928
3841 float[] _heightmap; 3929 float[] _heightmap;
@@ -3873,6 +3961,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3873 uint xt = 0; 3961 uint xt = 0;
3874 xx = 0; 3962 xx = 0;
3875 3963
3964
3876 for (uint x = 0; x < heightmapWidthSamples; x++) 3965 for (uint x = 0; x < heightmapWidthSamples; x++)
3877 { 3966 {
3878 if (x > 1 && xx < maxXX) 3967 if (x > 1 && xx < maxXX)
@@ -3951,7 +4040,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3951 } 4040 }
3952 4041
3953 m_log.DebugFormat( 4042 m_log.DebugFormat(
3954 "[ODE SCENE]: Setting terrain for {0} took {1}ms", Name, Util.EnvironmentTickCountSubtract(startTime)); 4043 "[ODE SCENE]: Setting terrain for {0} took {1}ms", PhysicsSceneName, Util.EnvironmentTickCountSubtract(startTime));
3955 } 4044 }
3956 4045
3957 public override void DeleteTerrain() 4046 public override void DeleteTerrain()
diff --git a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs
index 16404c6..6dc22bd 100644
--- a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs
@@ -30,51 +30,74 @@ using Nini.Config;
30using NUnit.Framework; 30using NUnit.Framework;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34using OpenSim.Region.Physics.OdePlugin; 34using OpenSim.Region.PhysicsModule.ODE;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
36using log4net; 38using log4net;
37using System.Reflection; 39using System.Reflection;
38 40
39namespace OpenSim.Region.Physics.OdePlugin.Tests 41namespace OpenSim.Region.PhysicsModule.ODE.Tests
40{ 42{
41 [TestFixture] 43 [TestFixture]
42 public class ODETestClass : OpenSimTestCase 44 public class ODETestClass : OpenSimTestCase
43 { 45 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 47
46 private OpenSim.Region.Physics.OdePlugin.OdePlugin cbt; 48 //private OpenSim.Region.PhysicsModule.ODE.OdePlugin cbt;
47 private PhysicsScene ps; 49 private PhysicsScene pScene;
48 private IMeshingPlugin imp;
49 50
50 [SetUp] 51 [SetUp]
51 public void Initialize() 52 public void Initialize()
52 { 53 {
53 IConfigSource TopConfig = new IniConfigSource(); 54 IConfigSource openSimINI = new IniConfigSource();
54 IConfig config = TopConfig.AddConfig("Startup"); 55 IConfig startupConfig = openSimINI.AddConfig("Startup");
55 config.Set("DecodedSculptMapPath","j2kDecodeCache"); 56 startupConfig.Set("physics", "OpenDynamicsEngine");
57 startupConfig.Set("DecodedSculptMapPath", "j2kDecodeCache");
58
59 Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
60
61 //PhysicsScene pScene = physicsPluginManager.GetPhysicsScene(
62 // "BulletSim", "Meshmerizer", openSimINI, "BSTestRegion", regionExtent);
63 RegionInfo info = new RegionInfo();
64 info.RegionName = "ODETestRegion";
65 info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize;
66 OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info);
67
68 //IMesher mesher = new OpenSim.Region.PhysicsModules.Meshing.Meshmerizer();
69 //INonSharedRegionModule mod = mesher as INonSharedRegionModule;
70 //mod.Initialise(openSimINI);
71 //mod.AddRegion(scene);
72 //mod.RegionLoaded(scene);
73
74 pScene = new OdeScene();
75 Console.WriteLine("HERE " + (pScene == null ? "Null" : "Not null"));
76 INonSharedRegionModule mod = (pScene as INonSharedRegionModule);
77 Console.WriteLine("HERE " + (mod == null ? "Null" : "Not null"));
78 mod.Initialise(openSimINI);
79 mod.AddRegion(scene);
80 mod.RegionLoaded(scene);
56 81
57 // Loading ODEPlugin 82 // Loading ODEPlugin
58 cbt = new OdePlugin(); 83 //cbt = new OdePlugin();
59 // Loading Zero Mesher
60 imp = new ZeroMesherPlugin();
61 // Getting Physics Scene 84 // Getting Physics Scene
62 ps = cbt.GetScene("test"); 85 //ps = cbt.GetScene("test");
63 // Initializing Physics Scene. 86 // Initializing Physics Scene.
64 ps.Initialise(imp.GetMesher(TopConfig),null); 87 //ps.Initialise(imp.GetMesher(TopConfig), null, Vector3.Zero);
65 float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize]; 88 float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize];
66 for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++) 89 for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++)
67 { 90 {
68 _heightmap[i] = 21f; 91 _heightmap[i] = 21f;
69 } 92 }
70 ps.SetTerrain(_heightmap); 93 pScene.SetTerrain(_heightmap);
71 } 94 }
72 95
73 [TearDown] 96 [TearDown]
74 public void Terminate() 97 public void Terminate()
75 { 98 {
76 ps.DeleteTerrain(); 99 pScene.DeleteTerrain();
77 ps.Dispose(); 100 pScene.Dispose();
78 101
79 } 102 }
80 103
@@ -85,9 +108,9 @@ namespace OpenSim.Region.Physics.OdePlugin.Tests
85 Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f); 108 Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f);
86 Vector3 size = new Vector3(0.5f, 0.5f, 0.5f); 109 Vector3 size = new Vector3(0.5f, 0.5f, 0.5f);
87 Quaternion rot = Quaternion.Identity; 110 Quaternion rot = Quaternion.Identity;
88 PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0); 111 PhysicsActor prim = pScene.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0);
89 OdePrim oprim = (OdePrim)prim; 112 OdePrim oprim = (OdePrim)prim;
90 OdeScene pscene = (OdeScene) ps; 113 OdeScene pscene = (OdeScene)pScene;
91 114
92 Assert.That(oprim.m_taintadd); 115 Assert.That(oprim.m_taintadd);
93 116
@@ -95,7 +118,7 @@ namespace OpenSim.Region.Physics.OdePlugin.Tests
95 118
96 for (int i = 0; i < 58; i++) 119 for (int i = 0; i < 58; i++)
97 { 120 {
98 ps.Simulate(0.133f); 121 pScene.Simulate(0.133f);
99 122
100 Assert.That(oprim.prim_geom != (IntPtr)0); 123 Assert.That(oprim.prim_geom != (IntPtr)0);
101 124
@@ -119,9 +142,9 @@ namespace OpenSim.Region.Physics.OdePlugin.Tests
119 // Make sure we're not somewhere above the ground 142 // Make sure we're not somewhere above the ground
120 Assert.That(prim.Position.Z < 21.5f); 143 Assert.That(prim.Position.Z < 21.5f);
121 144
122 ps.RemovePrim(prim); 145 pScene.RemovePrim(prim);
123 Assert.That(oprim.m_taintremove); 146 Assert.That(oprim.m_taintremove);
124 ps.Simulate(0.133f); 147 pScene.Simulate(0.133f);
125 Assert.That(oprim.Body == (IntPtr)0); 148 Assert.That(oprim.Body == (IntPtr)0);
126 } 149 }
127 } 150 }
diff --git a/OpenSim/Region/Physics/OdePlugin/drawstuff.cs b/OpenSim/Region/PhysicsModules/Ode/drawstuff.cs
index 87ca446..87ca446 100644
--- a/OpenSim/Region/Physics/OdePlugin/drawstuff.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/drawstuff.cs
diff --git a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/POS/AssemblyInfo.cs
index fc1ffba..e3a3e35 100644
--- a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/PhysicsModules/POS/AssemblyInfo.cs
@@ -27,6 +27,7 @@
27 27
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30using Mono.Addins;
30 31
31// Information about this assembly is defined by the following 32// Information about this assembly is defined by the following
32// attributes. 33// attributes.
@@ -56,3 +57,6 @@ using System.Runtime.InteropServices;
56// numbers with the '*' character (the default): 57// numbers with the '*' character (the default):
57 58
58[assembly : AssemblyVersion("0.8.2.*")] 59[assembly : AssemblyVersion("0.8.2.*")]
60
61[assembly: Addin("OpenSim.Region.PhysicsModule.POS", OpenSim.VersionInfo.VersionNumber)]
62[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
diff --git a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs b/OpenSim/Region/PhysicsModules/POS/POSCharacter.cs
index 40ab984..32469d9 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
+++ b/OpenSim/Region/PhysicsModules/POS/POSCharacter.cs
@@ -30,9 +30,9 @@ using System.Collections.Generic;
30using Nini.Config; 30using Nini.Config;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34 34
35namespace OpenSim.Region.Physics.POSPlugin 35namespace OpenSim.Region.PhysicsModule.POS
36{ 36{
37 public class POSCharacter : PhysicsActor 37 public class POSCharacter : PhysicsActor
38 { 38 {
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs b/OpenSim/Region/PhysicsModules/POS/POSPrim.cs
index 782ba82..c190fab 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
+++ b/OpenSim/Region/PhysicsModules/POS/POSPrim.cs
@@ -30,9 +30,9 @@ using System.Collections.Generic;
30using Nini.Config; 30using Nini.Config;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.PhysicsModules.SharedBase;
34 34
35namespace OpenSim.Region.Physics.POSPlugin 35namespace OpenSim.Region.PhysicsModule.POS
36{ 36{
37 public class POSPrim : PhysicsActor 37 public class POSPrim : PhysicsActor
38 { 38 {
diff --git a/OpenSim/Region/Physics/POSPlugin/POSScene.cs b/OpenSim/Region/PhysicsModules/POS/POSScene.cs
index 061304a..e6bcbf2 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSScene.cs
+++ b/OpenSim/Region/PhysicsModules/POS/POSScene.cs
@@ -29,31 +29,81 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using Nini.Config; 30using Nini.Config;
31using OpenMetaverse; 31using OpenMetaverse;
32using Mono.Addins;
32using OpenSim.Framework; 33using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.PhysicsModules.SharedBase;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces;
34 37
35namespace OpenSim.Region.Physics.POSPlugin 38namespace OpenSim.Region.PhysicsModule.POS
36{ 39{
37 public class POSScene : PhysicsScene 40 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "POSPhysicsScene")]
41 public class POSScene : PhysicsScene, INonSharedRegionModule
38 { 42 {
39 private List<POSCharacter> _characters = new List<POSCharacter>(); 43 private List<POSCharacter> _characters = new List<POSCharacter>();
40 private List<POSPrim> _prims = new List<POSPrim>(); 44 private List<POSPrim> _prims = new List<POSPrim>();
41 private float[] _heightMap; 45 private float[] _heightMap;
42 private const float gravity = -9.8f; 46 private const float gravity = -9.8f;
43 47
48 private bool m_Enabled = false;
44 //protected internal string sceneIdentifier; 49 //protected internal string sceneIdentifier;
45 50
46 public POSScene(string engineType, String _sceneIdentifier) 51 #region INonSharedRegionModule
52 public string Name
47 { 53 {
48 EngineType = engineType; 54 get { return "POS"; }
49 Name = EngineType + "/" + _sceneIdentifier;
50 //sceneIdentifier = _sceneIdentifier;
51 } 55 }
52 56
53 public override void Initialise(IMesher meshmerizer, IConfigSource config) 57 public Type ReplaceableInterface
54 { 58 {
59 get { return null; }
55 } 60 }
56 61
62 public void Initialise(IConfigSource source)
63 {
64 // TODO: Move this out of Startup
65 IConfig config = source.Configs["Startup"];
66 if (config != null)
67 {
68 string physics = config.GetString("physics", string.Empty);
69 if (physics == Name)
70 m_Enabled = true;
71 }
72
73 }
74
75 public void Close()
76 {
77 }
78
79 public void AddRegion(Scene scene)
80 {
81 if (!m_Enabled)
82 return;
83
84 EngineType = Name;
85 PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName;
86
87 scene.RegisterModuleInterface<PhysicsScene>(this);
88 base.Initialise(scene.PhysicsRequestAsset,
89 (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[Constants.RegionSize * Constants.RegionSize]),
90 (float)scene.RegionInfo.RegionSettings.WaterHeight);
91
92 }
93
94 public void RemoveRegion(Scene scene)
95 {
96 if (!m_Enabled)
97 return;
98 }
99
100 public void RegionLoaded(Scene scene)
101 {
102 if (!m_Enabled)
103 return;
104 }
105 #endregion
106
57 public override void Dispose() 107 public override void Dispose()
58 { 108 {
59 } 109 }
diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs
index 33f60e4..33f60e4 100644
--- a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs
diff --git a/OpenSim/Region/Physics/Manager/CollisionLocker.cs b/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs
index cace4e4..6e658b5 100644
--- a/OpenSim/Region/Physics/Manager/CollisionLocker.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs
@@ -28,7 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31namespace OpenSim.Region.Physics.Manager 31namespace OpenSim.Region.PhysicsModules.SharedBase
32{ 32{
33 public class CollisionLocker 33 public class CollisionLocker
34 { 34 {
diff --git a/OpenSim/Region/Physics/Manager/IMesher.cs b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs
index e290dc9..88169bb 100644
--- a/OpenSim/Region/Physics/Manager/IMesher.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs
@@ -31,7 +31,7 @@ using System.Runtime.InteropServices;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenMetaverse; 32using OpenMetaverse;
33 33
34namespace OpenSim.Region.Physics.Manager 34namespace OpenSim.Region.PhysicsModules.SharedBase
35{ 35{
36 public interface IMesher 36 public interface IMesher
37 { 37 {
diff --git a/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs b/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs
index 31a397c..fb0c9e2 100755
--- a/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs
@@ -30,7 +30,7 @@ using System.Collections.Generic;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenMetaverse; 31using OpenMetaverse;
32 32
33namespace OpenSim.Region.Physics.Manager 33namespace OpenSim.Region.PhysicsModules.SharedBase
34{ 34{
35 public struct PhysParameterEntry 35 public struct PhysParameterEntry
36 { 36 {
diff --git a/OpenSim/Region/Physics/Manager/NullPhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs
index b52f1f6..432708c 100644
--- a/OpenSim/Region/Physics/Manager/NullPhysicsScene.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs
@@ -32,7 +32,7 @@ using Nini.Config;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenMetaverse; 33using OpenMetaverse;
34 34
35namespace OpenSim.Region.Physics.Manager 35namespace OpenSim.Region.PhysicsModules.SharedBase
36{ 36{
37 class NullPhysicsScene : PhysicsScene 37 class NullPhysicsScene : PhysicsScene
38 { 38 {
@@ -40,11 +40,6 @@ namespace OpenSim.Region.Physics.Manager
40 40
41 private static int m_workIndicator; 41 private static int m_workIndicator;
42 42
43 public override void Initialise(IMesher meshmerizer, IConfigSource config)
44 {
45 // Does nothing right now
46 }
47
48 public override PhysicsActor AddAvatar( 43 public override PhysicsActor AddAvatar(
49 string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) 44 string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
50 { 45 {
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
index 60f6480..edc41e4 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
@@ -32,7 +32,7 @@ using System.Reflection;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenMetaverse; 33using OpenMetaverse;
34 34
35namespace OpenSim.Region.Physics.Manager 35namespace OpenSim.Region.PhysicsModules.SharedBase
36{ 36{
37 public delegate void PositionUpdate(Vector3 position); 37 public delegate void PositionUpdate(Vector3 position);
38 public delegate void VelocityUpdate(Vector3 velocity); 38 public delegate void VelocityUpdate(Vector3 velocity);
diff --git a/OpenSim/Region/Physics/Manager/PhysicsJoint.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs
index b685d04..ce2bf05 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsJoint.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs
@@ -30,7 +30,7 @@ using System.Collections.Generic;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenMetaverse; 31using OpenMetaverse;
32 32
33namespace OpenSim.Region.Physics.Manager 33namespace OpenSim.Region.PhysicsModules.SharedBase
34{ 34{
35 public enum PhysicsJointType : int 35 public enum PhysicsJointType : int
36 { 36 {
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs
index a9b30e1..1c0ad20 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs
@@ -35,7 +35,7 @@ using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenMetaverse; 36using OpenMetaverse;
37 37
38namespace OpenSim.Region.Physics.Manager 38namespace OpenSim.Region.PhysicsModules.SharedBase
39{ 39{
40 public delegate void physicsCrash(); 40 public delegate void physicsCrash();
41 41
@@ -104,7 +104,7 @@ namespace OpenSim.Region.Physics.Manager
104 /// Useful in debug messages to distinguish one OdeScene instance from another. 104 /// Useful in debug messages to distinguish one OdeScene instance from another.
105 /// Usually set to include the region name that the physics engine is acting for. 105 /// Usually set to include the region name that the physics engine is acting for.
106 /// </summary> 106 /// </summary>
107 public string Name { get; protected set; } 107 public string PhysicsSceneName { get; protected set; }
108 108
109 /// <summary> 109 /// <summary>
110 /// A string identifying the family of this physics engine. Most common values returned 110 /// A string identifying the family of this physics engine. Most common values returned
@@ -123,6 +123,14 @@ namespace OpenSim.Region.Physics.Manager
123 123
124 public RequestAssetDelegate RequestAssetMethod { get; set; } 124 public RequestAssetDelegate RequestAssetMethod { get; set; }
125 125
126 protected void Initialise(RequestAssetDelegate m, float[] terrain, float waterHeight)
127 {
128 RequestAssetMethod = m;
129 SetTerrain(terrain);
130 SetWaterLevel(waterHeight);
131
132 }
133
126 public virtual void TriggerPhysicsBasedRestart() 134 public virtual void TriggerPhysicsBasedRestart()
127 { 135 {
128 physicsCrash handler = OnPhysicsCrash; 136 physicsCrash handler = OnPhysicsCrash;
@@ -132,17 +140,6 @@ namespace OpenSim.Region.Physics.Manager
132 } 140 }
133 } 141 }
134 142
135 // Deprecated. Do not use this for new physics engines.
136 public abstract void Initialise(IMesher meshmerizer, IConfigSource config);
137
138 // For older physics engines that do not implement non-legacy region sizes.
139 // If the physics engine handles the region extent feature, it overrides this function.
140 public virtual void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
141 {
142 // If not overridden, call the old initialization entry.
143 Initialise(meshmerizer, config);
144 }
145
146 /// <summary> 143 /// <summary>
147 /// Add an avatar 144 /// Add an avatar
148 /// </summary> 145 /// </summary>
diff --git a/OpenSim/Region/Physics/Manager/PhysicsSensor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs
index f480d71..da9c96c 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsSensor.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs
@@ -29,7 +29,7 @@ using System;
29using System.Timers; 29using System.Timers;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32namespace OpenSim.Region.Physics.Manager 32namespace OpenSim.Region.PhysicsModules.SharedBase
33{ 33{
34 [Flags] 34 [Flags]
35 public enum SenseType : uint 35 public enum SenseType : uint
diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs
index f60a636..76a82fa 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsVector.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs
@@ -27,7 +27,7 @@
27 27
28using System; 28using System;
29 29
30namespace OpenSim.Region.Physics.Manager 30namespace OpenSim.Region.PhysicsModules.SharedBase
31{ 31{
32 /*public class PhysicsVector 32 /*public class PhysicsVector
33 { 33 {
diff --git a/OpenSim/Region/Physics/Manager/VehicleConstants.cs b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs
index 8e24b4c..e850b11 100644
--- a/OpenSim/Region/Physics/Manager/VehicleConstants.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs
@@ -28,7 +28,7 @@
28using System; 28using System;
29using OpenMetaverse; 29using OpenMetaverse;
30 30
31namespace OpenSim.Region.Physics.Manager 31namespace OpenSim.Region.PhysicsModules.SharedBase
32{ 32{
33 public enum Vehicle : int 33 public enum Vehicle : int
34 { 34 {