diff options
Diffstat (limited to 'OpenSim/Region/Physics')
10 files changed, 311 insertions, 194 deletions
diff --git a/OpenSim/Region/Physics/BulletSNPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSNPlugin/BSPrim.cs index 9c4ba30..aadb5b2 100644 --- a/OpenSim/Region/Physics/BulletSNPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSNPlugin/BSPrim.cs | |||
@@ -111,10 +111,6 @@ public sealed class BSPrim : BSPhysObject | |||
111 | 111 | ||
112 | _mass = CalculateMass(); | 112 | _mass = CalculateMass(); |
113 | 113 | ||
114 | // No body or shape yet | ||
115 | PhysBody = new BulletBody(LocalID); | ||
116 | PhysShape = new BulletShape(); | ||
117 | |||
118 | Linkset.Refresh(this); | 114 | Linkset.Refresh(this); |
119 | 115 | ||
120 | DetailLog("{0},BSPrim.constructor,call", LocalID); | 116 | DetailLog("{0},BSPrim.constructor,call", LocalID); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs index 6e68053..0355b94 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | ||
29 | using System.Runtime.InteropServices; | 30 | using System.Runtime.InteropServices; |
30 | using System.Security; | 31 | using System.Security; |
31 | using System.Text; | 32 | using System.Text; |
@@ -36,31 +37,102 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
36 | { | 37 | { |
37 | public sealed class BSAPIUnman : BSAPITemplate | 38 | public sealed class BSAPIUnman : BSAPITemplate |
38 | { | 39 | { |
39 | /* | 40 | |
41 | // We pin the memory passed between the managed and unmanaged code. | ||
42 | GCHandle m_paramsHandle; | ||
43 | private GCHandle m_collisionArrayPinnedHandle; | ||
44 | private GCHandle m_updateArrayPinnedHandle; | ||
45 | |||
46 | // Handle to the callback used by the unmanaged code to call into the managed code. | ||
47 | // Used for debug logging. | ||
48 | // Need to store the handle in a persistant variable so it won't be freed. | ||
49 | private BSAPICPP.DebugLogCallback m_DebugLogCallbackHandle; | ||
50 | |||
51 | private BSScene PhysicsScene { get; set; } | ||
52 | |||
53 | public override string BulletEngineName { get { return "BulletUnmanaged"; } } | ||
54 | public override string BulletEngineVersion { get; protected set; } | ||
55 | |||
56 | public BSAPIUnman(string paramName, BSScene physScene) | ||
57 | { | ||
58 | PhysicsScene = physScene; | ||
59 | // Do something fancy with the paramName to get the right DLL implementation | ||
60 | // like "Bullet-2.80-OpenCL-Intel" loading the version for Intel based OpenCL implementation, etc. | ||
61 | } | ||
62 | |||
40 | // Initialization and simulation | 63 | // Initialization and simulation |
41 | public BulletWorld Initialize(Vector3 maxPosition, IntPtr parms, | 64 | public override BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms, |
42 | int maxCollisions, IntPtr collisionArray, | 65 | int maxCollisions, ref CollisionDesc[] collisionArray, |
43 | int maxUpdates, IntPtr updateArray | 66 | int maxUpdates, ref EntityProperties[] updateArray |
44 | ); | 67 | ) |
68 | { | ||
69 | // Pin down the memory that will be used to pass object collisions and updates back from unmanaged code | ||
70 | m_paramsHandle = GCHandle.Alloc(parms, GCHandleType.Pinned); | ||
71 | m_collisionArrayPinnedHandle = GCHandle.Alloc(collisionArray, GCHandleType.Pinned); | ||
72 | m_updateArrayPinnedHandle = GCHandle.Alloc(updateArray, GCHandleType.Pinned); | ||
45 | 73 | ||
46 | public bool UpdateParameter(BulletWorld world, uint localID, String parm, float value); | 74 | // If Debug logging level, enable logging from the unmanaged code |
75 | m_DebugLogCallbackHandle = null; | ||
76 | if (BSScene.m_log.IsDebugEnabled || PhysicsScene.PhysicsLogging.Enabled) | ||
77 | { | ||
78 | BSScene.m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", BSScene.LogHeader); | ||
79 | if (PhysicsScene.PhysicsLogging.Enabled) | ||
80 | // The handle is saved in a variable to make sure it doesn't get freed after this call | ||
81 | m_DebugLogCallbackHandle = new BSAPICPP.DebugLogCallback(BulletLoggerPhysLog); | ||
82 | else | ||
83 | m_DebugLogCallbackHandle = new BSAPICPP.DebugLogCallback(BulletLogger); | ||
84 | } | ||
47 | 85 | ||
48 | public void SetHeightMap(BulletWorld world, float[] heightmap); | 86 | // Get the version of the DLL |
87 | // TODO: this doesn't work yet. Something wrong with marshaling the returned string. | ||
88 | // BulletEngineVersion = BulletSimAPI.GetVersion2(); | ||
89 | BulletEngineVersion = ""; | ||
90 | |||
91 | // Call the unmanaged code with the buffers and other information | ||
92 | return new BulletWorld(0, PhysicsScene, BSAPICPP.Initialize2(maxPosition, m_paramsHandle.AddrOfPinnedObject(), | ||
93 | maxCollisions, m_collisionArrayPinnedHandle.AddrOfPinnedObject(), | ||
94 | maxUpdates, m_updateArrayPinnedHandle.AddrOfPinnedObject(), | ||
95 | m_DebugLogCallbackHandle)); | ||
49 | 96 | ||
50 | public void Shutdown(BulletWorld sim); | 97 | } |
51 | 98 | ||
52 | public int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, | 99 | // Called directly from unmanaged code so don't do much |
53 | out int updatedEntityCount, | 100 | private void BulletLogger(string msg) |
54 | out IntPtr updatedEntitiesPtr, | 101 | { |
55 | out int collidersCount, | 102 | BSScene.m_log.Debug("[BULLETS UNMANAGED]:" + msg); |
56 | out IntPtr collidersPtr); | 103 | } |
104 | |||
105 | // Called directly from unmanaged code so don't do much | ||
106 | private void BulletLoggerPhysLog(string msg) | ||
107 | { | ||
108 | PhysicsScene.DetailLog("[BULLETS UNMANAGED]:" + msg); | ||
109 | } | ||
110 | |||
111 | /* | ||
112 | public void SetHeightMap(BulletWorld world, float[] heightmap); | ||
57 | 113 | ||
58 | */ | 114 | */ |
115 | public override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, | ||
116 | out int updatedEntityCount, out int collidersCount) | ||
117 | { | ||
118 | return BSAPICPP.PhysicsStep2(world.ptr, timeStep, maxSubSteps, fixedTimeStep, out updatedEntityCount, out collidersCount); | ||
119 | } | ||
120 | |||
121 | public override void Shutdown(BulletWorld sim) | ||
122 | { | ||
123 | BSAPICPP.Shutdown2(sim.ptr); | ||
124 | } | ||
125 | |||
59 | public override bool PushUpdate(BulletBody obj) | 126 | public override bool PushUpdate(BulletBody obj) |
60 | { | 127 | { |
61 | return BSAPICPP.PushUpdate2(obj.ptr); | 128 | return BSAPICPP.PushUpdate2(obj.ptr); |
62 | } | 129 | } |
63 | 130 | ||
131 | public override bool UpdateParameter(BulletWorld world, uint localID, String parm, float value) | ||
132 | { | ||
133 | return BSAPICPP.UpdateParameter2(world.ptr, localID, parm, value); | ||
134 | } | ||
135 | |||
64 | // ===================================================================================== | 136 | // ===================================================================================== |
65 | // Mesh, hull, shape and body creation helper routines | 137 | // Mesh, hull, shape and body creation helper routines |
66 | public override BulletShape CreateMeshShape(BulletWorld world, | 138 | public override BulletShape CreateMeshShape(BulletWorld world, |
@@ -893,11 +965,81 @@ public override float GetMargin(BulletShape shape) | |||
893 | return BSAPICPP.GetMargin2(shape.ptr); | 965 | return BSAPICPP.GetMargin2(shape.ptr); |
894 | } | 966 | } |
895 | 967 | ||
968 | // ===================================================================================== | ||
969 | // Debugging | ||
970 | public override void DumpRigidBody(BulletWorld sim, BulletBody collisionObject) | ||
971 | { | ||
972 | BSAPICPP.DumpRigidBody2(sim.ptr, collisionObject.ptr); | ||
973 | } | ||
974 | |||
975 | public override void DumpCollisionShape(BulletWorld sim, BulletShape collisionShape) | ||
976 | { | ||
977 | BSAPICPP.DumpCollisionShape2(sim.ptr, collisionShape.ptr); | ||
978 | } | ||
979 | |||
980 | public override void DumpMapInfo(BulletWorld sim, BulletHMapInfo mapInfo) | ||
981 | { | ||
982 | BSAPICPP.DumpMapInfo2(sim.ptr, mapInfo.ptr); | ||
983 | } | ||
984 | |||
985 | public override void DumpConstraint(BulletWorld sim, BulletConstraint constrain) | ||
986 | { | ||
987 | BSAPICPP.DumpConstraint2(sim.ptr, constrain.ptr); | ||
988 | } | ||
989 | |||
990 | public override void DumpActivationInfo(BulletWorld sim) | ||
991 | { | ||
992 | BSAPICPP.DumpActivationInfo2(sim.ptr); | ||
993 | } | ||
994 | |||
995 | public override void DumpAllInfo(BulletWorld sim) | ||
996 | { | ||
997 | BSAPICPP.DumpAllInfo2(sim.ptr); | ||
998 | } | ||
999 | |||
1000 | public override void DumpPhysicsStatistics(BulletWorld sim) | ||
1001 | { | ||
1002 | BSAPICPP.DumpPhysicsStatistics2(sim.ptr); | ||
1003 | } | ||
1004 | |||
1005 | |||
1006 | // ===================================================================================== | ||
1007 | // ===================================================================================== | ||
1008 | // ===================================================================================== | ||
1009 | // ===================================================================================== | ||
1010 | // ===================================================================================== | ||
1011 | // The actual interface to the unmanaged code | ||
896 | static class BSAPICPP | 1012 | static class BSAPICPP |
897 | { | 1013 | { |
1014 | // =============================================================================== | ||
1015 | // Link back to the managed code for outputting log messages | ||
1016 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] | ||
1017 | public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg); | ||
1018 | |||
1019 | // =============================================================================== | ||
1020 | // Initialization and simulation | ||
1021 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1022 | public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms, | ||
1023 | int maxCollisions, IntPtr collisionArray, | ||
1024 | int maxUpdates, IntPtr updateArray, | ||
1025 | DebugLogCallback logRoutine); | ||
1026 | |||
1027 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1028 | public static extern void SetHeightMap2(IntPtr world, float[] heightmap); | ||
1029 | |||
1030 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1031 | public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep, | ||
1032 | out int updatedEntityCount, out int collidersCount); | ||
1033 | |||
1034 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1035 | public static extern void Shutdown2(IntPtr sim); | ||
1036 | |||
898 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1037 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
899 | public static extern bool PushUpdate2(IntPtr obj); | 1038 | public static extern bool PushUpdate2(IntPtr obj); |
900 | 1039 | ||
1040 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1041 | public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value); | ||
1042 | |||
901 | // ===================================================================================== | 1043 | // ===================================================================================== |
902 | // Mesh, hull, shape and body creation helper routines | 1044 | // Mesh, hull, shape and body creation helper routines |
903 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1045 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
@@ -1431,52 +1573,6 @@ public static extern void SetMargin2(IntPtr shape, float val); | |||
1431 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1573 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
1432 | public static extern float GetMargin2(IntPtr shape); | 1574 | public static extern float GetMargin2(IntPtr shape); |
1433 | 1575 | ||
1434 | } | ||
1435 | } | ||
1436 | |||
1437 | // =============================================================================== | ||
1438 | // =============================================================================== | ||
1439 | // =============================================================================== | ||
1440 | // =============================================================================== | ||
1441 | // =============================================================================== | ||
1442 | // =============================================================================== | ||
1443 | // =============================================================================== | ||
1444 | // =============================================================================== | ||
1445 | // =============================================================================== | ||
1446 | // =============================================================================== | ||
1447 | // =============================================================================== | ||
1448 | // =============================================================================== | ||
1449 | // =============================================================================== | ||
1450 | static class BulletSimAPI { | ||
1451 | // =============================================================================== | ||
1452 | // Link back to the managed code for outputting log messages | ||
1453 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] | ||
1454 | public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg); | ||
1455 | |||
1456 | // =============================================================================== | ||
1457 | // Initialization and simulation | ||
1458 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1459 | public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms, | ||
1460 | int maxCollisions, IntPtr collisionArray, | ||
1461 | int maxUpdates, IntPtr updateArray, | ||
1462 | DebugLogCallback logRoutine); | ||
1463 | |||
1464 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1465 | public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value); | ||
1466 | |||
1467 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1468 | public static extern void SetHeightMap2(IntPtr world, float[] heightmap); | ||
1469 | |||
1470 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1471 | public static extern void Shutdown2(IntPtr sim); | ||
1472 | |||
1473 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1474 | public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep, | ||
1475 | out int updatedEntityCount, | ||
1476 | out IntPtr updatedEntitiesPtr, | ||
1477 | out int collidersCount, | ||
1478 | out IntPtr collidersPtr); | ||
1479 | |||
1480 | // ===================================================================================== | 1576 | // ===================================================================================== |
1481 | // Debugging | 1577 | // Debugging |
1482 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1578 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
@@ -1501,4 +1597,7 @@ public static extern void DumpAllInfo2(IntPtr sim); | |||
1501 | public static extern void DumpPhysicsStatistics2(IntPtr sim); | 1597 | public static extern void DumpPhysicsStatistics2(IntPtr sim); |
1502 | 1598 | ||
1503 | } | 1599 | } |
1600 | |||
1601 | } | ||
1602 | |||
1504 | } | 1603 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs index a56a817..8ed791e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs | |||
@@ -1,39 +1,39 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyrightD | 9 | * * Redistributions in binary form must reproduce the above copyrightD |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Linq; | 29 | using System.Linq; |
30 | using System.Text; | 30 | using System.Text; |
31 | 31 | ||
32 | namespace OpenSim.Region.Physics.BulletSPlugin | 32 | namespace OpenSim.Region.Physics.BulletSPlugin |
33 | { | 33 | { |
34 | /* | 34 | /* |
35 | public sealed class BSAPIXNA : BulletSimAPITemplate | 35 | public sealed class BSAPIXNA : BSAPITemplate |
36 | { | 36 | { |
37 | } | 37 | } |
38 | */ | 38 | */ |
39 | } | 39 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs index fbf362d..64a886b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs | |||
@@ -292,26 +292,27 @@ public enum ConstraintParamAxis : int | |||
292 | 292 | ||
293 | public abstract class BSAPITemplate | 293 | public abstract class BSAPITemplate |
294 | { | 294 | { |
295 | /* | 295 | // Returns the name of the underlying Bullet engine |
296 | public abstract string BulletEngineName { get; } | ||
297 | public abstract string BulletEngineVersion { get; protected set;} | ||
298 | |||
296 | // Initialization and simulation | 299 | // Initialization and simulation |
297 | public abstract BulletWorld Initialize(Vector3 maxPosition, IntPtr parms, | 300 | public abstract BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms, |
298 | int maxCollisions, IntPtr collisionArray, | 301 | int maxCollisions, ref CollisionDesc[] collisionArray, |
299 | int maxUpdates, IntPtr updateArray | 302 | int maxUpdates, ref EntityProperties[] updateArray |
300 | ); | 303 | ); |
301 | 304 | ||
302 | public abstract bool UpdateParameter(BulletWorld world, uint localID, String parm, float value); | 305 | /* |
303 | |||
304 | public abstract void SetHeightMap(BulletWorld world, float[] heightmap); | 306 | public abstract void SetHeightMap(BulletWorld world, float[] heightmap); |
305 | 307 | ||
306 | public abstract void Shutdown(BulletWorld sim); | 308 | */ |
307 | |||
308 | public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, | 309 | public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, |
309 | out int updatedEntityCount, | 310 | out int updatedEntityCount, out int collidersCount); |
310 | out IntPtr updatedEntitiesPtr, | 311 | |
311 | out int collidersCount, | 312 | public abstract bool UpdateParameter(BulletWorld world, uint localID, String parm, float value); |
312 | out IntPtr collidersPtr); | 313 | |
314 | public abstract void Shutdown(BulletWorld sim); | ||
313 | 315 | ||
314 | */ | ||
315 | public abstract bool PushUpdate(BulletBody obj); | 316 | public abstract bool PushUpdate(BulletBody obj); |
316 | 317 | ||
317 | // ===================================================================================== | 318 | // ===================================================================================== |
@@ -660,5 +661,21 @@ public abstract void SetMargin(BulletShape shape, float val); | |||
660 | 661 | ||
661 | public abstract float GetMargin(BulletShape shape); | 662 | public abstract float GetMargin(BulletShape shape); |
662 | 663 | ||
664 | // ===================================================================================== | ||
665 | // Debugging | ||
666 | public abstract void DumpRigidBody(BulletWorld sim, BulletBody collisionObject); | ||
667 | |||
668 | public abstract void DumpCollisionShape(BulletWorld sim, BulletShape collisionShape); | ||
669 | |||
670 | public abstract void DumpMapInfo(BulletWorld sim, BulletHMapInfo mapInfo); | ||
671 | |||
672 | public abstract void DumpConstraint(BulletWorld sim, BulletConstraint constrain); | ||
673 | |||
674 | public abstract void DumpActivationInfo(BulletWorld sim); | ||
675 | |||
676 | public abstract void DumpAllInfo(BulletWorld sim); | ||
677 | |||
678 | public abstract void DumpPhysicsStatistics(BulletWorld sim); | ||
679 | |||
663 | }; | 680 | }; |
664 | } | 681 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index e4e3edc..13c2539 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -823,7 +823,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
823 | if (!IsActive) return; | 823 | if (!IsActive) return; |
824 | 824 | ||
825 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) | 825 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) |
826 | BulletSimAPI.DumpRigidBody2(PhysicsScene.World.ptr, Prim.PhysBody.ptr); | 826 | PhysicsScene.PE.DumpRigidBody(PhysicsScene.World, Prim.PhysBody); |
827 | 827 | ||
828 | ForgetKnownVehicleProperties(); | 828 | ForgetKnownVehicleProperties(); |
829 | 829 | ||
@@ -840,7 +840,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
840 | PushKnownChanged(); | 840 | PushKnownChanged(); |
841 | 841 | ||
842 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) | 842 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) |
843 | BulletSimAPI.DumpRigidBody2(PhysicsScene.World.ptr, Prim.PhysBody.ptr); | 843 | PhysicsScene.PE.DumpRigidBody(PhysicsScene.World, Prim.PhysBody); |
844 | 844 | ||
845 | VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", | 845 | VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", |
846 | Prim.LocalID, VehiclePosition, Prim.Force, VehicleVelocity, VehicleRotationalVelocity); | 846 | Prim.LocalID, VehiclePosition, Prim.Force, VehicleVelocity, VehicleRotationalVelocity); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 28c6680..258b72f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | ||
29 | using System.Runtime.InteropServices; | 30 | using System.Runtime.InteropServices; |
30 | using System.Text; | 31 | using System.Text; |
31 | using System.Threading; | 32 | using System.Threading; |
@@ -42,8 +43,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
42 | { | 43 | { |
43 | public sealed class BSScene : PhysicsScene, IPhysicsParameters | 44 | public sealed class BSScene : PhysicsScene, IPhysicsParameters |
44 | { | 45 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 46 | internal static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
46 | private static readonly string LogHeader = "[BULLETS SCENE]"; | 47 | internal static readonly string LogHeader = "[BULLETS SCENE]"; |
47 | 48 | ||
48 | // The name of the region we're working for. | 49 | // The name of the region we're working for. |
49 | public string RegionName { get; private set; } | 50 | public string RegionName { get; private set; } |
@@ -51,6 +52,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
51 | public string BulletSimVersion = "?"; | 52 | public string BulletSimVersion = "?"; |
52 | 53 | ||
53 | // The handle to the underlying managed or unmanaged version of Bullet being used. | 54 | // The handle to the underlying managed or unmanaged version of Bullet being used. |
55 | public string BulletEngineName { get; private set; } | ||
54 | public BSAPITemplate PE; | 56 | public BSAPITemplate PE; |
55 | 57 | ||
56 | public Dictionary<uint, BSPhysObject> PhysObjects; | 58 | public Dictionary<uint, BSPhysObject> PhysObjects; |
@@ -102,11 +104,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
102 | // Pinned memory used to pass step information between managed and unmanaged | 104 | // Pinned memory used to pass step information between managed and unmanaged |
103 | internal int m_maxCollisionsPerFrame; | 105 | internal int m_maxCollisionsPerFrame; |
104 | internal CollisionDesc[] m_collisionArray; | 106 | internal CollisionDesc[] m_collisionArray; |
105 | internal GCHandle m_collisionArrayPinnedHandle; | ||
106 | 107 | ||
107 | internal int m_maxUpdatesPerFrame; | 108 | internal int m_maxUpdatesPerFrame; |
108 | internal EntityProperties[] m_updateArray; | 109 | internal EntityProperties[] m_updateArray; |
109 | internal GCHandle m_updateArrayPinnedHandle; | ||
110 | 110 | ||
111 | public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero | 111 | public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero |
112 | public const uint GROUNDPLANE_ID = 1; | 112 | public const uint GROUNDPLANE_ID = 1; |
@@ -152,12 +152,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
152 | // A pointer to an instance if this structure is passed to the C++ code | 152 | // A pointer to an instance if this structure is passed to the C++ code |
153 | // Used to pass basic configuration values to the unmanaged code. | 153 | // Used to pass basic configuration values to the unmanaged code. |
154 | internal ConfigurationParameters[] UnmanagedParams; | 154 | internal ConfigurationParameters[] UnmanagedParams; |
155 | GCHandle m_paramsHandle; | ||
156 | |||
157 | // Handle to the callback used by the unmanaged code to call into the managed code. | ||
158 | // Used for debug logging. | ||
159 | // Need to store the handle in a persistant variable so it won't be freed. | ||
160 | private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle; | ||
161 | 155 | ||
162 | // Sometimes you just have to log everything. | 156 | // Sometimes you just have to log everything. |
163 | public Logging.LogWriter PhysicsLogging; | 157 | public Logging.LogWriter PhysicsLogging; |
@@ -194,15 +188,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
194 | // Set default values for physics parameters plus any overrides from the ini file | 188 | // Set default values for physics parameters plus any overrides from the ini file |
195 | GetInitialParameterValues(config); | 189 | GetInitialParameterValues(config); |
196 | 190 | ||
197 | // For the moment, only one version of the interface | 191 | // Get the connection to the physics engine (could be native or one of many DLLs) |
198 | PE = new BSAPIUnman(); | 192 | PE = SelectUnderlyingBulletEngine(BulletEngineName); |
199 | |||
200 | // Allocate more pinned memory. Do this early to try and get all pinned memory close together. | ||
201 | m_paramsHandle = GCHandle.Alloc(UnmanagedParams, GCHandleType.Pinned); | ||
202 | m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame]; | ||
203 | m_collisionArrayPinnedHandle = GCHandle.Alloc(m_collisionArray, GCHandleType.Pinned); | ||
204 | m_updateArray = new EntityProperties[m_maxUpdatesPerFrame]; | ||
205 | m_updateArrayPinnedHandle = GCHandle.Alloc(m_updateArray, GCHandleType.Pinned); | ||
206 | 193 | ||
207 | // Enable very detailed logging. | 194 | // Enable very detailed logging. |
208 | // By creating an empty logger when not logging, the log message invocation code | 195 | // By creating an empty logger when not logging, the log message invocation code |
@@ -217,22 +204,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
217 | PhysicsLogging = new Logging.LogWriter(); | 204 | PhysicsLogging = new Logging.LogWriter(); |
218 | } | 205 | } |
219 | 206 | ||
220 | // If Debug logging level, enable logging from the unmanaged code | 207 | // Allocate memory for returning of the updates and collisions from the physics engine |
221 | m_DebugLogCallbackHandle = null; | 208 | m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame]; |
222 | if (m_log.IsDebugEnabled || PhysicsLogging.Enabled) | 209 | m_updateArray = new EntityProperties[m_maxUpdatesPerFrame]; |
223 | { | ||
224 | m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader); | ||
225 | if (PhysicsLogging.Enabled) | ||
226 | // The handle is saved in a variable to make sure it doesn't get freed after this call | ||
227 | m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLoggerPhysLog); | ||
228 | else | ||
229 | m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger); | ||
230 | } | ||
231 | |||
232 | // Get the version of the DLL | ||
233 | // TODO: this doesn't work yet. Something wrong with marshaling the returned string. | ||
234 | // BulletSimVersion = BulletSimAPI.GetVersion(); | ||
235 | // m_log.WarnFormat("{0}: BulletSim.dll version='{1}'", LogHeader, BulletSimVersion); | ||
236 | 210 | ||
237 | // The bounding box for the simulated world. The origin is 0,0,0 unless we're | 211 | // The bounding box for the simulated world. The origin is 0,0,0 unless we're |
238 | // a child in a mega-region. | 212 | // a child in a mega-region. |
@@ -240,11 +214,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
240 | // area. It tracks active objects no matter where they are. | 214 | // area. It tracks active objects no matter where they are. |
241 | Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); | 215 | Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); |
242 | 216 | ||
243 | // m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader); | 217 | World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray, m_maxUpdatesPerFrame, ref m_updateArray); |
244 | World = new BulletWorld(0, this, BulletSimAPI.Initialize2(worldExtent, m_paramsHandle.AddrOfPinnedObject(), | ||
245 | m_maxCollisionsPerFrame, m_collisionArrayPinnedHandle.AddrOfPinnedObject(), | ||
246 | m_maxUpdatesPerFrame, m_updateArrayPinnedHandle.AddrOfPinnedObject(), | ||
247 | m_DebugLogCallbackHandle)); | ||
248 | 218 | ||
249 | Constraints = new BSConstraintCollection(World); | 219 | Constraints = new BSConstraintCollection(World); |
250 | 220 | ||
@@ -274,6 +244,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
274 | { | 244 | { |
275 | BSParam.SetParameterConfigurationValues(this, pConfig); | 245 | BSParam.SetParameterConfigurationValues(this, pConfig); |
276 | 246 | ||
247 | // There are two Bullet implementations to choose from | ||
248 | BulletEngineName = pConfig.GetString("BulletEngine", "BulletUnmanaged"); | ||
249 | |||
277 | // Very detailed logging for physics debugging | 250 | // Very detailed logging for physics debugging |
278 | // TODO: the boolean values can be moved to the normal parameter processing. | 251 | // TODO: the boolean values can be moved to the normal parameter processing. |
279 | m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false); | 252 | m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false); |
@@ -315,16 +288,41 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
315 | return ret; | 288 | return ret; |
316 | } | 289 | } |
317 | 290 | ||
318 | // Called directly from unmanaged code so don't do much | 291 | // Select the connection to the actual Bullet implementation. |
319 | private void BulletLogger(string msg) | 292 | // The main engine selection is the engineName up to the first hypen. |
293 | // So "Bullet-2.80-OpenCL-Intel" specifies the 'bullet' class here and the whole name | ||
294 | // is passed to the engine to do its special selection, etc. | ||
295 | private BSAPITemplate SelectUnderlyingBulletEngine(string engineName) | ||
320 | { | 296 | { |
321 | m_log.Debug("[BULLETS UNMANAGED]:" + msg); | 297 | // For the moment, do a simple switch statement. |
322 | } | 298 | // Someday do fancyness with looking up the interfaces in the assembly. |
299 | BSAPITemplate ret = null; | ||
323 | 300 | ||
324 | // Called directly from unmanaged code so don't do much | 301 | string selectionName = engineName.ToLower(); |
325 | private void BulletLoggerPhysLog(string msg) | 302 | int hyphenIndex = engineName.IndexOf("-"); |
326 | { | 303 | if (hyphenIndex > 0) |
327 | DetailLog("[BULLETS UNMANAGED]:" + msg); | 304 | selectionName = engineName.ToLower().Substring(0, hyphenIndex - 1); |
305 | |||
306 | switch (selectionName) | ||
307 | { | ||
308 | case "bulletunmanaged": | ||
309 | ret = new BSAPIUnman(engineName, this); | ||
310 | break; | ||
311 | case "bulletxna": | ||
312 | // ret = new BSAPIXNA(engineName, this); | ||
313 | break; | ||
314 | } | ||
315 | |||
316 | if (ret == null) | ||
317 | { | ||
318 | m_log.ErrorFormat("{0) COULD NOT SELECT BULLET ENGINE: '[BulletSim]PhysicsEngine' must be either 'BulletUnmanaged-*' or 'BulletXNA-*'", LogHeader); | ||
319 | } | ||
320 | else | ||
321 | { | ||
322 | m_log.WarnFormat("{0} Selected bullet engine {1} -> {2}/{3}", LogHeader, engineName, ret.BulletEngineName, ret.BulletEngineVersion); | ||
323 | } | ||
324 | |||
325 | return ret; | ||
328 | } | 326 | } |
329 | 327 | ||
330 | public override void Dispose() | 328 | public override void Dispose() |
@@ -361,7 +359,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
361 | } | 359 | } |
362 | 360 | ||
363 | // Anything left in the unmanaged code should be cleaned out | 361 | // Anything left in the unmanaged code should be cleaned out |
364 | BulletSimAPI.Shutdown2(World.ptr); | 362 | PE.Shutdown(World); |
365 | 363 | ||
366 | // Not logging any more | 364 | // Not logging any more |
367 | PhysicsLogging.Close(); | 365 | PhysicsLogging.Close(); |
@@ -474,9 +472,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
474 | LastTimeStep = timeStep; | 472 | LastTimeStep = timeStep; |
475 | 473 | ||
476 | int updatedEntityCount = 0; | 474 | int updatedEntityCount = 0; |
477 | IntPtr updatedEntitiesPtr; | ||
478 | int collidersCount = 0; | 475 | int collidersCount = 0; |
479 | IntPtr collidersPtr; | ||
480 | 476 | ||
481 | int beforeTime = 0; | 477 | int beforeTime = 0; |
482 | int simTime = 0; | 478 | int simTime = 0; |
@@ -492,6 +488,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
492 | TriggerPreStepEvent(timeStep); | 488 | TriggerPreStepEvent(timeStep); |
493 | 489 | ||
494 | // the prestep actions might have added taints | 490 | // the prestep actions might have added taints |
491 | numTaints += _taintOperations.Count; | ||
495 | ProcessTaints(); | 492 | ProcessTaints(); |
496 | 493 | ||
497 | InTaintTime = false; // Only used for debugging so locking is not necessary. | 494 | InTaintTime = false; // Only used for debugging so locking is not necessary. |
@@ -499,23 +496,25 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
499 | // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world. | 496 | // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world. |
500 | // Only enable this in a limited test world with few objects. | 497 | // Only enable this in a limited test world with few objects. |
501 | if (m_physicsPhysicalDumpEnabled) | 498 | if (m_physicsPhysicalDumpEnabled) |
502 | BulletSimAPI.DumpAllInfo2(World.ptr); | 499 | PE.DumpAllInfo(World); |
503 | 500 | ||
504 | // step the physical world one interval | 501 | // step the physical world one interval |
505 | m_simulationStep++; | 502 | m_simulationStep++; |
506 | int numSubSteps = 0; | 503 | int numSubSteps = 0; |
507 | |||
508 | try | 504 | try |
509 | { | 505 | { |
510 | if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount(); | 506 | if (PhysicsLogging.Enabled) |
507 | beforeTime = Util.EnvironmentTickCount(); | ||
511 | 508 | ||
512 | numSubSteps = BulletSimAPI.PhysicsStep2(World.ptr, timeStep, m_maxSubSteps, m_fixedTimeStep, | 509 | numSubSteps = PE.PhysicsStep(World, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out collidersCount); |
513 | out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr); | ||
514 | 510 | ||
515 | if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime); | 511 | if (PhysicsLogging.Enabled) |
516 | DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}", | 512 | { |
517 | DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, | 513 | simTime = Util.EnvironmentTickCountSubtract(beforeTime); |
518 | updatedEntityCount, collidersCount, ObjectsWithCollisions.Count); | 514 | DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}", |
515 | DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, | ||
516 | updatedEntityCount, collidersCount, ObjectsWithCollisions.Count); | ||
517 | } | ||
519 | } | 518 | } |
520 | catch (Exception e) | 519 | catch (Exception e) |
521 | { | 520 | { |
@@ -527,8 +526,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
527 | collidersCount = 0; | 526 | collidersCount = 0; |
528 | } | 527 | } |
529 | 528 | ||
530 | // Don't have to use the pointers passed back since we know it is the same pinned memory we passed in. | ||
531 | |||
532 | // Get a value for 'now' so all the collision and update routines don't have to get their own. | 529 | // Get a value for 'now' so all the collision and update routines don't have to get their own. |
533 | SimulationNowTime = Util.EnvironmentTickCount(); | 530 | SimulationNowTime = Util.EnvironmentTickCount(); |
534 | 531 | ||
@@ -570,7 +567,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
570 | // Objects that are done colliding are removed from the ObjectsWithCollisions list. | 567 | // Objects that are done colliding are removed from the ObjectsWithCollisions list. |
571 | // Not done above because it is inside an iteration of ObjectWithCollisions. | 568 | // Not done above because it is inside an iteration of ObjectWithCollisions. |
572 | // This complex collision processing is required to create an empty collision | 569 | // This complex collision processing is required to create an empty collision |
573 | // event call after all collisions have happened on an object. This enables | 570 | // event call after all real collisions have happened on an object. This enables |
574 | // the simulator to generate the 'collision end' event. | 571 | // the simulator to generate the 'collision end' event. |
575 | if (ObjectsWithNoMoreCollisions.Count > 0) | 572 | if (ObjectsWithNoMoreCollisions.Count > 0) |
576 | { | 573 | { |
@@ -599,11 +596,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
599 | // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world. | 596 | // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world. |
600 | // Only enable this in a limited test world with few objects. | 597 | // Only enable this in a limited test world with few objects. |
601 | if (m_physicsPhysicalDumpEnabled) | 598 | if (m_physicsPhysicalDumpEnabled) |
602 | BulletSimAPI.DumpAllInfo2(World.ptr); | 599 | PE.DumpAllInfo(World); |
603 | 600 | ||
604 | // The physics engine returns the number of milliseconds it simulated this call. | 601 | // The physics engine returns the number of milliseconds it simulated this call. |
605 | // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS. | 602 | // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS. |
606 | // Multiply by 55 to give a nominal frame rate of 55. | 603 | // Multiply by a fixed nominal frame rate to give a rate similar to the simulator (usually 55). |
607 | return (float)numSubSteps * m_fixedTimeStep * 1000f * NominalFrameRate; | 604 | return (float)numSubSteps * m_fixedTimeStep * 1000f * NominalFrameRate; |
608 | } | 605 | } |
609 | 606 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs index cc28344..0802b3a 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs | |||
@@ -44,7 +44,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
44 | { | 44 | { |
45 | static string LogHeader = "[BULLETSIM TERRAIN HEIGHTMAP]"; | 45 | static string LogHeader = "[BULLETSIM TERRAIN HEIGHTMAP]"; |
46 | 46 | ||
47 | BulletHeightMapInfo m_mapInfo = null; | 47 | BulletHMapInfo m_mapInfo = null; |
48 | 48 | ||
49 | // Constructor to build a default, flat heightmap terrain. | 49 | // Constructor to build a default, flat heightmap terrain. |
50 | public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, Vector3 regionSize) | 50 | public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, Vector3 regionSize) |
@@ -58,7 +58,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
58 | { | 58 | { |
59 | initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION; | 59 | initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION; |
60 | } | 60 | } |
61 | m_mapInfo = new BulletHeightMapInfo(id, initialMap, IntPtr.Zero); | 61 | m_mapInfo = new BulletHMapInfo(id, initialMap, IntPtr.Zero); |
62 | m_mapInfo.minCoords = minTerrainCoords; | 62 | m_mapInfo.minCoords = minTerrainCoords; |
63 | m_mapInfo.maxCoords = maxTerrainCoords; | 63 | m_mapInfo.maxCoords = maxTerrainCoords; |
64 | m_mapInfo.terrainRegionBase = TerrainBase; | 64 | m_mapInfo.terrainRegionBase = TerrainBase; |
@@ -72,7 +72,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
72 | Vector3 minCoords, Vector3 maxCoords) | 72 | Vector3 minCoords, Vector3 maxCoords) |
73 | : base(physicsScene, regionBase, id) | 73 | : base(physicsScene, regionBase, id) |
74 | { | 74 | { |
75 | m_mapInfo = new BulletHeightMapInfo(id, initialMap, IntPtr.Zero); | 75 | m_mapInfo = new BulletHMapInfo(id, initialMap, IntPtr.Zero); |
76 | m_mapInfo.minCoords = minCoords; | 76 | m_mapInfo.minCoords = minCoords; |
77 | m_mapInfo.maxCoords = maxCoords; | 77 | m_mapInfo.maxCoords = maxCoords; |
78 | m_mapInfo.minZ = minCoords.Z; | 78 | m_mapInfo.minZ = minCoords.Z; |
@@ -91,12 +91,12 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
91 | // Using the information in m_mapInfo, create the physical representation of the heightmap. | 91 | // Using the information in m_mapInfo, create the physical representation of the heightmap. |
92 | private void BuildHeightmapTerrain() | 92 | private void BuildHeightmapTerrain() |
93 | { | 93 | { |
94 | m_mapInfo.Ptr = PhysicsScene.PE.CreateHeightMapInfo(PhysicsScene.World, m_mapInfo.ID, | 94 | m_mapInfo.ptr = PhysicsScene.PE.CreateHeightMapInfo(PhysicsScene.World, m_mapInfo.ID, |
95 | m_mapInfo.minCoords, m_mapInfo.maxCoords, | 95 | m_mapInfo.minCoords, m_mapInfo.maxCoords, |
96 | m_mapInfo.heightMap, BSParam.TerrainCollisionMargin); | 96 | m_mapInfo.heightMap, BSParam.TerrainCollisionMargin); |
97 | 97 | ||
98 | // Create the terrain shape from the mapInfo | 98 | // Create the terrain shape from the mapInfo |
99 | m_mapInfo.terrainShape = PhysicsScene.PE.CreateTerrainShape(m_mapInfo.Ptr); | 99 | m_mapInfo.terrainShape = PhysicsScene.PE.CreateTerrainShape(m_mapInfo.ptr); |
100 | 100 | ||
101 | // The terrain object initial position is at the center of the object | 101 | // The terrain object initial position is at the center of the object |
102 | Vector3 centerPos; | 102 | Vector3 centerPos; |
@@ -138,7 +138,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
138 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_mapInfo.terrainBody); | 138 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_mapInfo.terrainBody); |
139 | // Frees both the body and the shape. | 139 | // Frees both the body and the shape. |
140 | PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_mapInfo.terrainBody); | 140 | PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_mapInfo.terrainBody); |
141 | PhysicsScene.PE.ReleaseHeightMapInfo(m_mapInfo.Ptr); | 141 | PhysicsScene.PE.ReleaseHeightMapInfo(m_mapInfo.ptr); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | m_mapInfo = null; | 144 | m_mapInfo = null; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs index a040928..c8f4602 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs | |||
@@ -187,11 +187,11 @@ public class BulletConstraint | |||
187 | // Made a class rather than a struct so there would be only one | 187 | // Made a class rather than a struct so there would be only one |
188 | // instance of this and C# will pass around pointers rather | 188 | // instance of this and C# will pass around pointers rather |
189 | // than making copies. | 189 | // than making copies. |
190 | public class BulletHeightMapInfo | 190 | public class BulletHMapInfo |
191 | { | 191 | { |
192 | public BulletHeightMapInfo(uint id, float[] hm, IntPtr xx) { | 192 | public BulletHMapInfo(uint id, float[] hm, IntPtr xx) { |
193 | ID = id; | 193 | ID = id; |
194 | Ptr = xx; | 194 | ptr = xx; |
195 | heightMap = hm; | 195 | heightMap = hm; |
196 | terrainRegionBase = OMV.Vector3.Zero; | 196 | terrainRegionBase = OMV.Vector3.Zero; |
197 | minCoords = new OMV.Vector3(100f, 100f, 25f); | 197 | minCoords = new OMV.Vector3(100f, 100f, 25f); |
@@ -200,7 +200,7 @@ public class BulletHeightMapInfo | |||
200 | sizeX = sizeY = 256f; | 200 | sizeX = sizeY = 256f; |
201 | } | 201 | } |
202 | public uint ID; | 202 | public uint ID; |
203 | public IntPtr Ptr; | 203 | public IntPtr ptr; |
204 | public float[] heightMap; | 204 | public float[] heightMap; |
205 | public OMV.Vector3 terrainRegionBase; | 205 | public OMV.Vector3 terrainRegionBase; |
206 | public OMV.Vector3 minCoords; | 206 | public OMV.Vector3 minCoords; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index 4cb8e6d..a8a4ff5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt | |||
@@ -61,7 +61,8 @@ Incorporate inter-relationship of angular corrections. For instance, angularDefl | |||
61 | 61 | ||
62 | BULLETSIM TODO LIST: | 62 | BULLETSIM TODO LIST: |
63 | ================================================= | 63 | ================================================= |
64 | Avatar density is WAY off. Compare and calibrate with what's in SL. | 64 | Implement an avatar mesh shape. The Bullet capsule is way too limited. |
65 | Consider just hand creating a vertex/index array in a new BSShapeAvatar. | ||
65 | Revisit CollisionMargin. Builders notice the 0.04 spacing between prims. | 66 | Revisit CollisionMargin. Builders notice the 0.04 spacing between prims. |
66 | Duplicating a physical prim causes old prim to jump away | 67 | Duplicating a physical prim causes old prim to jump away |
67 | Dup a phys prim and the original become unselected and thus interacts w/ selected prim. | 68 | Dup a phys prim and the original become unselected and thus interacts w/ selected prim. |
@@ -170,6 +171,9 @@ Avatar attachments have no mass? http://forums-archive.secondlife.com/54/f0/3179 | |||
170 | 171 | ||
171 | INTERNAL IMPROVEMENT/CLEANUP | 172 | INTERNAL IMPROVEMENT/CLEANUP |
172 | ================================================= | 173 | ================================================= |
174 | Create the physical wrapper classes (BulletBody, BulletShape) by methods on | ||
175 | BSAPITemplate and make their actual implementation Bullet engine specific. | ||
176 | For the short term, just call the existing functions in ShapeCollection. | ||
173 | Consider moving prim/character body and shape destruction in destroy() | 177 | Consider moving prim/character body and shape destruction in destroy() |
174 | to postTimeTime rather than protecting all the potential sets that | 178 | to postTimeTime rather than protecting all the potential sets that |
175 | might have been queued up. | 179 | might have been queued up. |
@@ -204,6 +208,8 @@ Should taints check for existance or activeness of target? | |||
204 | Possibly have and 'active' flag that is checked by the taint processor? | 208 | Possibly have and 'active' flag that is checked by the taint processor? |
205 | Parameters for physics logging should be moved from BSScene to BSParam (at least boolean ones) | 209 | Parameters for physics logging should be moved from BSScene to BSParam (at least boolean ones) |
206 | Can some of the physical wrapper classes (BulletBody, BulletWorld, BulletShape) be 'sealed'? | 210 | Can some of the physical wrapper classes (BulletBody, BulletWorld, BulletShape) be 'sealed'? |
211 | There are TOO MANY interfaces from BulletSim core to Bullet itself | ||
212 | Think of something to eliminate one or more of the layers | ||
207 | 213 | ||
208 | THREADING | 214 | THREADING |
209 | ================================================= | 215 | ================================================= |
@@ -262,3 +268,5 @@ llApplyImpulse() | |||
262 | (Resolution: tested on SL and OS. AddForce scales the force for timestep) | 268 | (Resolution: tested on SL and OS. AddForce scales the force for timestep) |
263 | llSetBuoyancy() (DONE) | 269 | llSetBuoyancy() (DONE) |
264 | (Resolution: Bullet resets object gravity when added to world. Moved set gravity) | 270 | (Resolution: Bullet resets object gravity when added to world. Moved set gravity) |
271 | Avatar density is WAY off. Compare and calibrate with what's in SL. (DONE) | ||
272 | (Resolution: set default density to 3.5 (from 60) which is closer to SL) | ||
diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs index 8587a2b..8ccfda5 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs | |||
@@ -30,7 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using log4net; | 33 | using log4net; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | 35 | ||
36 | namespace OpenSim.Region.Physics.Manager | 36 | namespace OpenSim.Region.Physics.Manager |