diff options
Diffstat (limited to '')
15 files changed, 467 insertions, 156 deletions
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs index 20b337a..ac2c1f3 100644 --- a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs +++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs | |||
@@ -220,7 +220,7 @@ namespace OpenSim.Region.PhysicsModule.BasicPhysics | |||
220 | actor.Velocity = actorVelocity; | 220 | actor.Velocity = actorVelocity; |
221 | } | 221 | } |
222 | 222 | ||
223 | return fps; | 223 | return 1.0f; |
224 | } | 224 | } |
225 | 225 | ||
226 | public override void GetResults() | 226 | public override void GetResults() |
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSShapes.cs b/OpenSim/Region/PhysicsModules/BulletS/BSShapes.cs index 086a412..79f1a89 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSShapes.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSShapes.cs | |||
@@ -555,7 +555,9 @@ public class BSShapeMesh : BSShape | |||
555 | { | 555 | { |
556 | meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, | 556 | meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, |
557 | false, // say it is not physical so a bounding box is not built | 557 | false, // say it is not physical so a bounding box is not built |
558 | false // do not cache the mesh and do not use previously built versions | 558 | false, // do not cache the mesh and do not use previously built versions |
559 | false, | ||
560 | false | ||
559 | ); | 561 | ); |
560 | } | 562 | } |
561 | 563 | ||
@@ -712,7 +714,7 @@ public class BSShapeHull : BSShape | |||
712 | lock (physicsScene.mesher) | 714 | lock (physicsScene.mesher) |
713 | { | 715 | { |
714 | // Pass true for physicalness as this prevents the creation of bounding box which is not needed | 716 | // Pass true for physicalness as this prevents the creation of bounding box which is not needed |
715 | meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, true /* isPhysical */, false /* shouldCache */); | 717 | meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, true /* isPhysical */, false /* shouldCache */, false, false); |
716 | 718 | ||
717 | // If we should use the asset's hull info, fetch it out of the locked mesher | 719 | // If we should use the asset's hull info, fetch it out of the locked mesher |
718 | if (meshData != null && BSParam.ShouldUseAssetHulls) | 720 | if (meshData != null && BSParam.ShouldUseAssetHulls) |
diff --git a/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Mesh.cs b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Mesh.cs index bf397ee..8c97f2f 100644 --- a/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Mesh.cs +++ b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Mesh.cs | |||
@@ -46,11 +46,36 @@ namespace OpenSim.Region.PhysicsModules.Meshing | |||
46 | IntPtr m_indicesPtr = IntPtr.Zero; | 46 | IntPtr m_indicesPtr = IntPtr.Zero; |
47 | int m_indexCount = 0; | 47 | int m_indexCount = 0; |
48 | public float[] m_normals; | 48 | public float[] m_normals; |
49 | Vector3 _centroid; | ||
50 | int _centroidDiv; | ||
51 | |||
52 | private class vertexcomp : IEqualityComparer<Vertex> | ||
53 | { | ||
54 | public bool Equals(Vertex v1, Vertex v2) | ||
55 | { | ||
56 | if (v1.X == v2.X && v1.Y == v2.Y && v1.Z == v2.Z) | ||
57 | return true; | ||
58 | else | ||
59 | return false; | ||
60 | } | ||
61 | public int GetHashCode(Vertex v) | ||
62 | { | ||
63 | int a = v.X.GetHashCode(); | ||
64 | int b = v.Y.GetHashCode(); | ||
65 | int c = v.Z.GetHashCode(); | ||
66 | return (a << 16) ^ (b << 8) ^ c; | ||
67 | } | ||
68 | |||
69 | } | ||
49 | 70 | ||
50 | public Mesh() | 71 | public Mesh() |
51 | { | 72 | { |
52 | m_vertices = new Dictionary<Vertex, int>(); | 73 | vertexcomp vcomp = new vertexcomp(); |
74 | |||
75 | m_vertices = new Dictionary<Vertex, int>(vcomp); | ||
53 | m_triangles = new List<Triangle>(); | 76 | m_triangles = new List<Triangle>(); |
77 | _centroid = Vector3.Zero; | ||
78 | _centroidDiv = 0; | ||
54 | } | 79 | } |
55 | 80 | ||
56 | public Mesh Clone() | 81 | public Mesh Clone() |
@@ -61,7 +86,8 @@ namespace OpenSim.Region.PhysicsModules.Meshing | |||
61 | { | 86 | { |
62 | result.Add(new Triangle(t.v1.Clone(), t.v2.Clone(), t.v3.Clone())); | 87 | result.Add(new Triangle(t.v1.Clone(), t.v2.Clone(), t.v3.Clone())); |
63 | } | 88 | } |
64 | 89 | result._centroid = _centroid; | |
90 | result._centroidDiv = _centroidDiv; | ||
65 | return result; | 91 | return result; |
66 | } | 92 | } |
67 | 93 | ||
@@ -71,15 +97,63 @@ namespace OpenSim.Region.PhysicsModules.Meshing | |||
71 | throw new NotSupportedException("Attempt to Add to a pinned Mesh"); | 97 | throw new NotSupportedException("Attempt to Add to a pinned Mesh"); |
72 | // If a vertex of the triangle is not yet in the vertices list, | 98 | // If a vertex of the triangle is not yet in the vertices list, |
73 | // add it and set its index to the current index count | 99 | // add it and set its index to the current index count |
100 | // vertex == seems broken | ||
101 | // skip colapsed triangles | ||
102 | if ((triangle.v1.X == triangle.v2.X && triangle.v1.Y == triangle.v2.Y && triangle.v1.Z == triangle.v2.Z) | ||
103 | || (triangle.v1.X == triangle.v3.X && triangle.v1.Y == triangle.v3.Y && triangle.v1.Z == triangle.v3.Z) | ||
104 | || (triangle.v2.X == triangle.v3.X && triangle.v2.Y == triangle.v3.Y && triangle.v2.Z == triangle.v3.Z) | ||
105 | ) | ||
106 | { | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | if (m_vertices.Count == 0) | ||
111 | { | ||
112 | _centroidDiv = 0; | ||
113 | _centroid = Vector3.Zero; | ||
114 | } | ||
115 | |||
74 | if (!m_vertices.ContainsKey(triangle.v1)) | 116 | if (!m_vertices.ContainsKey(triangle.v1)) |
117 | { | ||
75 | m_vertices[triangle.v1] = m_vertices.Count; | 118 | m_vertices[triangle.v1] = m_vertices.Count; |
119 | _centroid.X += triangle.v1.X; | ||
120 | _centroid.Y += triangle.v1.Y; | ||
121 | _centroid.Z += triangle.v1.Z; | ||
122 | _centroidDiv++; | ||
123 | } | ||
76 | if (!m_vertices.ContainsKey(triangle.v2)) | 124 | if (!m_vertices.ContainsKey(triangle.v2)) |
125 | { | ||
77 | m_vertices[triangle.v2] = m_vertices.Count; | 126 | m_vertices[triangle.v2] = m_vertices.Count; |
127 | _centroid.X += triangle.v2.X; | ||
128 | _centroid.Y += triangle.v2.Y; | ||
129 | _centroid.Z += triangle.v2.Z; | ||
130 | _centroidDiv++; | ||
131 | } | ||
78 | if (!m_vertices.ContainsKey(triangle.v3)) | 132 | if (!m_vertices.ContainsKey(triangle.v3)) |
133 | { | ||
79 | m_vertices[triangle.v3] = m_vertices.Count; | 134 | m_vertices[triangle.v3] = m_vertices.Count; |
135 | _centroid.X += triangle.v3.X; | ||
136 | _centroid.Y += triangle.v3.Y; | ||
137 | _centroid.Z += triangle.v3.Z; | ||
138 | _centroidDiv++; | ||
139 | } | ||
80 | m_triangles.Add(triangle); | 140 | m_triangles.Add(triangle); |
81 | } | 141 | } |
82 | 142 | ||
143 | public Vector3 GetCentroid() | ||
144 | { | ||
145 | if (_centroidDiv > 0) | ||
146 | return new Vector3(_centroid.X / _centroidDiv, _centroid.Y / _centroidDiv, _centroid.Z / _centroidDiv); | ||
147 | else | ||
148 | return Vector3.Zero; | ||
149 | } | ||
150 | |||
151 | // not functional | ||
152 | public Vector3 GetOBB() | ||
153 | { | ||
154 | return new Vector3(0.5f, 0.5f, 0.5f); | ||
155 | } | ||
156 | |||
83 | public void CalcNormals() | 157 | public void CalcNormals() |
84 | { | 158 | { |
85 | int iTriangles = m_triangles.Count; | 159 | int iTriangles = m_triangles.Count; |
@@ -185,6 +259,7 @@ namespace OpenSim.Region.PhysicsModules.Meshing | |||
185 | public void getVertexListAsPtrToFloatArray(out IntPtr vertices, out int vertexStride, out int vertexCount) | 259 | public void getVertexListAsPtrToFloatArray(out IntPtr vertices, out int vertexStride, out int vertexCount) |
186 | { | 260 | { |
187 | // A vertex is 3 floats | 261 | // A vertex is 3 floats |
262 | |||
188 | vertexStride = 3 * sizeof(float); | 263 | vertexStride = 3 * sizeof(float); |
189 | 264 | ||
190 | // If there isn't an unmanaged array allocated yet, do it now | 265 | // If there isn't an unmanaged array allocated yet, do it now |
diff --git a/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs index 4d25bf3..bae3449 100644 --- a/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs +++ b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs | |||
@@ -947,11 +947,21 @@ namespace OpenSim.Region.PhysicsModules.Meshing | |||
947 | return CreateMesh(primName, primShape, size, lod, false, true); | 947 | return CreateMesh(primName, primShape, size, lod, false, true); |
948 | } | 948 | } |
949 | 949 | ||
950 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache, bool convex, bool forOde) | ||
951 | { | ||
952 | return CreateMesh(primName, primShape, size, lod, false); | ||
953 | } | ||
954 | |||
950 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical) | 955 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical) |
951 | { | 956 | { |
952 | return CreateMesh(primName, primShape, size, lod, isPhysical, true); | 957 | return CreateMesh(primName, primShape, size, lod, isPhysical, true); |
953 | } | 958 | } |
954 | 959 | ||
960 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex, bool forOde) | ||
961 | { | ||
962 | return CreateMesh(primName, primShape, size, lod, isPhysical, true); | ||
963 | } | ||
964 | |||
955 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache) | 965 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache) |
956 | { | 966 | { |
957 | #if SPAM | 967 | #if SPAM |
@@ -1005,6 +1015,13 @@ namespace OpenSim.Region.PhysicsModules.Meshing | |||
1005 | 1015 | ||
1006 | return mesh; | 1016 | return mesh; |
1007 | } | 1017 | } |
1018 | public IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex) | ||
1019 | { | ||
1020 | return null; | ||
1021 | } | ||
1008 | 1022 | ||
1023 | public void ReleaseMesh(IMesh imesh) { } | ||
1024 | public void ExpireReleaseMeshs() { } | ||
1025 | public void ExpireFileCache() { } | ||
1009 | } | 1026 | } |
1010 | } | 1027 | } |
diff --git a/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/SculptMap.cs b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/SculptMap.cs index 740424e..b3d9cb6 100644 --- a/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/SculptMap.cs +++ b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/SculptMap.cs | |||
@@ -58,28 +58,24 @@ namespace PrimMesher | |||
58 | if (bmW == 0 || bmH == 0) | 58 | if (bmW == 0 || bmH == 0) |
59 | throw new Exception("SculptMap: bitmap has no data"); | 59 | throw new Exception("SculptMap: bitmap has no data"); |
60 | 60 | ||
61 | int numLodPixels = lod * 2 * lod * 2; // (32 * 2)^2 = 64^2 pixels for default sculpt map image | 61 | int numLodPixels = lod * lod; // (32 * 2)^2 = 64^2 pixels for default sculpt map image |
62 | 62 | ||
63 | bool smallMap = bmW * bmH <= numLodPixels; | ||
63 | bool needsScaling = false; | 64 | bool needsScaling = false; |
64 | 65 | ||
65 | bool smallMap = bmW * bmH <= lod * lod; | ||
66 | |||
67 | width = bmW; | 66 | width = bmW; |
68 | height = bmH; | 67 | height = bmH; |
69 | while (width * height > numLodPixels) | 68 | while (width * height > numLodPixels * 4) |
70 | { | 69 | { |
71 | width >>= 1; | 70 | width >>= 1; |
72 | height >>= 1; | 71 | height >>= 1; |
73 | needsScaling = true; | 72 | needsScaling = true; |
74 | } | 73 | } |
75 | 74 | ||
76 | |||
77 | |||
78 | try | 75 | try |
79 | { | 76 | { |
80 | if (needsScaling) | 77 | if (needsScaling) |
81 | bm = ScaleImage(bm, width, height, | 78 | bm = ScaleImage(bm, width, height); |
82 | System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor); | ||
83 | } | 79 | } |
84 | 80 | ||
85 | catch (Exception e) | 81 | catch (Exception e) |
@@ -87,7 +83,7 @@ namespace PrimMesher | |||
87 | throw new Exception("Exception in ScaleImage(): e: " + e.ToString()); | 83 | throw new Exception("Exception in ScaleImage(): e: " + e.ToString()); |
88 | } | 84 | } |
89 | 85 | ||
90 | if (width * height > lod * lod) | 86 | if (width * height > numLodPixels) |
91 | { | 87 | { |
92 | width >>= 1; | 88 | width >>= 1; |
93 | height >>= 1; | 89 | height >>= 1; |
@@ -144,15 +140,17 @@ namespace PrimMesher | |||
144 | int rowNdx, colNdx; | 140 | int rowNdx, colNdx; |
145 | int smNdx = 0; | 141 | int smNdx = 0; |
146 | 142 | ||
143 | |||
147 | for (rowNdx = 0; rowNdx < numRows; rowNdx++) | 144 | for (rowNdx = 0; rowNdx < numRows; rowNdx++) |
148 | { | 145 | { |
149 | List<Coord> row = new List<Coord>(numCols); | 146 | List<Coord> row = new List<Coord>(numCols); |
150 | for (colNdx = 0; colNdx < numCols; colNdx++) | 147 | for (colNdx = 0; colNdx < numCols; colNdx++) |
151 | { | 148 | { |
149 | |||
152 | if (mirror) | 150 | if (mirror) |
153 | row.Add(new Coord(-(redBytes[smNdx] * pixScale - 0.5f), (greenBytes[smNdx] * pixScale - 0.5f), blueBytes[smNdx] * pixScale - 0.5f)); | 151 | row.Add(new Coord(-((float)redBytes[smNdx] * pixScale - 0.5f), ((float)greenBytes[smNdx] * pixScale - 0.5f), (float)blueBytes[smNdx] * pixScale - 0.5f)); |
154 | else | 152 | else |
155 | row.Add(new Coord(redBytes[smNdx] * pixScale - 0.5f, greenBytes[smNdx] * pixScale - 0.5f, blueBytes[smNdx] * pixScale - 0.5f)); | 153 | row.Add(new Coord((float)redBytes[smNdx] * pixScale - 0.5f, (float)greenBytes[smNdx] * pixScale - 0.5f, (float)blueBytes[smNdx] * pixScale - 0.5f)); |
156 | 154 | ||
157 | ++smNdx; | 155 | ++smNdx; |
158 | } | 156 | } |
@@ -161,23 +159,39 @@ namespace PrimMesher | |||
161 | return rows; | 159 | return rows; |
162 | } | 160 | } |
163 | 161 | ||
164 | private Bitmap ScaleImage(Bitmap srcImage, int destWidth, int destHeight, | 162 | private Bitmap ScaleImage(Bitmap srcImage, int destWidth, int destHeight) |
165 | System.Drawing.Drawing2D.InterpolationMode interpMode) | ||
166 | { | 163 | { |
167 | Bitmap scaledImage = new Bitmap(srcImage, destWidth, destHeight); | ||
168 | scaledImage.SetResolution(96.0f, 96.0f); | ||
169 | |||
170 | Graphics grPhoto = Graphics.FromImage(scaledImage); | ||
171 | grPhoto.InterpolationMode = interpMode; | ||
172 | 164 | ||
173 | grPhoto.DrawImage(srcImage, | 165 | Bitmap scaledImage = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb); |
174 | new Rectangle(0, 0, destWidth, destHeight), | 166 | |
175 | new Rectangle(0, 0, srcImage.Width, srcImage.Height), | 167 | Color c; |
176 | GraphicsUnit.Pixel); | 168 | float xscale = srcImage.Width / destWidth; |
169 | float yscale = srcImage.Height / destHeight; | ||
170 | |||
171 | float sy = 0.5f; | ||
172 | for (int y = 0; y < destHeight; y++) | ||
173 | { | ||
174 | float sx = 0.5f; | ||
175 | for (int x = 0; x < destWidth; x++) | ||
176 | { | ||
177 | try | ||
178 | { | ||
179 | c = srcImage.GetPixel((int)(sx), (int)(sy)); | ||
180 | scaledImage.SetPixel(x, y, Color.FromArgb(c.R, c.G, c.B)); | ||
181 | } | ||
182 | catch (IndexOutOfRangeException) | ||
183 | { | ||
184 | } | ||
177 | 185 | ||
178 | grPhoto.Dispose(); | 186 | sx += xscale; |
187 | } | ||
188 | sy += yscale; | ||
189 | } | ||
190 | srcImage.Dispose(); | ||
179 | return scaledImage; | 191 | return scaledImage; |
180 | } | 192 | } |
193 | |||
194 | } | ||
195 | |||
181 | } | 196 | } |
182 | } | ||
183 | #endif | 197 | #endif |
diff --git a/OpenSim/Region/PhysicsModules/Meshing/ZeroMesher.cs b/OpenSim/Region/PhysicsModules/Meshing/ZeroMesher.cs index 0a3b3a4..09676c6 100644 --- a/OpenSim/Region/PhysicsModules/Meshing/ZeroMesher.cs +++ b/OpenSim/Region/PhysicsModules/Meshing/ZeroMesher.cs | |||
@@ -110,23 +110,36 @@ namespace OpenSim.Region.PhysicsModules.Meshing | |||
110 | #region IMesher | 110 | #region IMesher |
111 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod) | 111 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod) |
112 | { | 112 | { |
113 | return CreateMesh(primName, primShape, size, lod, false, false); | 113 | return CreateMesh(primName, primShape, size, lod, false); |
114 | } | 114 | } |
115 | 115 | ||
116 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical) | 116 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache, bool convex, bool forOde) |
117 | { | ||
118 | return CreateMesh(primName, primShape, size, lod, false); | ||
119 | } | ||
120 | |||
121 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex,bool forOde) | ||
117 | { | 122 | { |
118 | return CreateMesh(primName, primShape, size, lod, false, false); | 123 | return CreateMesh(primName, primShape, size, lod, false); |
119 | } | 124 | } |
120 | 125 | ||
121 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache) | 126 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical) |
122 | { | 127 | { |
123 | // Remove the reference to the encoded JPEG2000 data so it can be GCed | 128 | // Remove the reference to the encoded JPEG2000 data so it can be GCed |
124 | primShape.SculptData = OpenMetaverse.Utils.EmptyBytes; | 129 | primShape.SculptData = OpenMetaverse.Utils.EmptyBytes; |
125 | 130 | ||
126 | return null; | 131 | return null; |
127 | } | 132 | } |
128 | #endregion | ||
129 | 133 | ||
134 | public IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex) | ||
135 | { | ||
136 | return null; | ||
137 | } | ||
130 | 138 | ||
139 | public void ReleaseMesh(IMesh mesh) { } | ||
140 | public void ExpireReleaseMeshs() { } | ||
141 | public void ExpireFileCache() { } | ||
142 | |||
143 | #endregion | ||
131 | } | 144 | } |
132 | } | 145 | } |
diff --git a/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs index 445fef8..5e48de6 100644 --- a/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs | |||
@@ -2955,6 +2955,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
2955 | m_log.WarnFormat("[PHYSICS]: Got NaN PIDTarget from Scene on Object {0}", Name); | 2955 | m_log.WarnFormat("[PHYSICS]: Got NaN PIDTarget from Scene on Object {0}", Name); |
2956 | } | 2956 | } |
2957 | } | 2957 | } |
2958 | |||
2958 | public override bool PIDActive { get; set; } | 2959 | public override bool PIDActive { get; set; } |
2959 | public override float PIDTau { set { m_PIDTau = value; } } | 2960 | public override float PIDTau { set { m_PIDTau = value; } } |
2960 | 2961 | ||
diff --git a/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs index cd5dbf8..80f0fcf 100644 --- a/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs | |||
@@ -180,7 +180,7 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
180 | len = 250f; | 180 | len = 250f; |
181 | 181 | ||
182 | // Create the ray | 182 | // Create the ray |
183 | IntPtr ray = d.CreateRay(m_scene.space, req.length); | 183 | IntPtr ray = d.CreateRay(m_scene.space, len); |
184 | d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); | 184 | d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); |
185 | 185 | ||
186 | // Collide test | 186 | // Collide test |
@@ -225,8 +225,13 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
225 | /// <param name="req"></param> | 225 | /// <param name="req"></param> |
226 | private void RayCast(ODERayRequest req) | 226 | private void RayCast(ODERayRequest req) |
227 | { | 227 | { |
228 | // limit ray lenght or collisions will take all avaiable stack space | ||
229 | float len = req.length; | ||
230 | if (len > 250f) | ||
231 | len = 250f; | ||
232 | |||
228 | // Create the ray | 233 | // Create the ray |
229 | IntPtr ray = d.CreateRay(m_scene.space, req.length); | 234 | IntPtr ray = d.CreateRay(m_scene.space, len); |
230 | d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); | 235 | d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); |
231 | 236 | ||
232 | // Collide test | 237 | // Collide test |
@@ -438,4 +443,4 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
438 | public float length; | 443 | public float length; |
439 | public RayCallback callbackMethod; | 444 | public RayCallback callbackMethod; |
440 | } | 445 | } |
441 | } \ No newline at end of file | 446 | } |
diff --git a/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs index 88d4d15..26210d6 100644 --- a/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs +++ b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs | |||
@@ -478,7 +478,7 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
478 | private int m_physicsiterations = 10; | 478 | private int m_physicsiterations = 10; |
479 | private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag | 479 | private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag |
480 | private readonly PhysicsActor PANull = new NullPhysicsActor(); | 480 | private readonly PhysicsActor PANull = new NullPhysicsActor(); |
481 | // private float step_time = 0.0f; | 481 | private float step_time = 0.0f; |
482 | //Ckrinke: Comment out until used. We declare it, initialize it, but do not use it | 482 | //Ckrinke: Comment out until used. We declare it, initialize it, but do not use it |
483 | //Ckrinke private int ms = 0; | 483 | //Ckrinke private int ms = 0; |
484 | public IntPtr world; | 484 | public IntPtr world; |
@@ -671,8 +671,18 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
671 | } | 671 | } |
672 | #endif | 672 | #endif |
673 | 673 | ||
674 | // Initialize from configs | 674 | public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) |
675 | private void InitialiseFromConfig(IConfigSource config) | 675 | { |
676 | WorldExtents.X = regionExtent.X; | ||
677 | m_regionWidth = (uint)regionExtent.X; | ||
678 | WorldExtents.Y = regionExtent.Y; | ||
679 | m_regionHeight = (uint)regionExtent.Y; | ||
680 | m_suportCombine = false; | ||
681 | Initialise(meshmerizer, config); | ||
682 | } | ||
683 | |||
684 | // Initialize the mesh plugin | ||
685 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | ||
676 | { | 686 | { |
677 | InitializeExtraStats(); | 687 | InitializeExtraStats(); |
678 | 688 | ||
@@ -812,7 +822,7 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
812 | if (spaceGridMaxY > 24) | 822 | if (spaceGridMaxY > 24) |
813 | { | 823 | { |
814 | spaceGridMaxY = 24; | 824 | spaceGridMaxY = 24; |
815 | spacesPerMeterY = spaceGridMaxY / WorldExtents.Y ; | 825 | spacesPerMeterY = spaceGridMaxY / WorldExtents.Y; |
816 | } | 826 | } |
817 | 827 | ||
818 | staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY]; | 828 | staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY]; |
@@ -3077,26 +3087,12 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
3077 | 3087 | ||
3078 | float fps = 0; | 3088 | float fps = 0; |
3079 | 3089 | ||
3080 | float timeLeft = timeStep; | 3090 | step_time += timeStep; |
3091 | |||
3092 | float HalfOdeStep = ODE_STEPSIZE * 0.5f; | ||
3093 | if (step_time < HalfOdeStep) | ||
3094 | return 0; | ||
3081 | 3095 | ||
3082 | //m_log.Info(timeStep.ToString()); | ||
3083 | // step_time += timeSte | ||
3084 | // | ||
3085 | // // If We're loaded down by something else, | ||
3086 | // // or debugging with the Visual Studio project on pause | ||
3087 | // // skip a few frames to catch up gracefully. | ||
3088 | // // without shooting the physicsactors all over the place | ||
3089 | // | ||
3090 | // if (step_time >= m_SkipFramesAtms) | ||
3091 | // { | ||
3092 | // // Instead of trying to catch up, it'll do 5 physics frames only | ||
3093 | // step_time = ODE_STEPSIZE; | ||
3094 | // m_physicsiterations = 5; | ||
3095 | // } | ||
3096 | // else | ||
3097 | // { | ||
3098 | // m_physicsiterations = 10; | ||
3099 | // } | ||
3100 | 3096 | ||
3101 | // We change _collisionEventPrimChanges to avoid locking _collisionEventPrim itself and causing potential | 3097 | // We change _collisionEventPrimChanges to avoid locking _collisionEventPrim itself and causing potential |
3102 | // deadlock if the collision event tries to lock something else later on which is already locked by a | 3098 | // deadlock if the collision event tries to lock something else later on which is already locked by a |
@@ -3138,11 +3134,11 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
3138 | // Figure out the Frames Per Second we're going at. | 3134 | // Figure out the Frames Per Second we're going at. |
3139 | //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size | 3135 | //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size |
3140 | 3136 | ||
3141 | fps = (timeStep / ODE_STEPSIZE) * 1000; | 3137 | |
3142 | // HACK: Using a time dilation of 1.0 to debug rubberbanding issues | 3138 | // HACK: Using a time dilation of 1.0 to debug rubberbanding issues |
3143 | //m_timeDilation = Math.Min((step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE), 1.0f); | 3139 | //m_timeDilation = Math.Min((step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE), 1.0f); |
3144 | 3140 | ||
3145 | while (timeLeft > 0.0f) | 3141 | while (step_time > HalfOdeStep) |
3146 | { | 3142 | { |
3147 | try | 3143 | try |
3148 | { | 3144 | { |
@@ -3307,7 +3303,8 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
3307 | m_log.ErrorFormat("[ODE SCENE]: {0}, {1}, {2}", e.Message, e.TargetSite, e); | 3303 | m_log.ErrorFormat("[ODE SCENE]: {0}, {1}, {2}", e.Message, e.TargetSite, e); |
3308 | } | 3304 | } |
3309 | 3305 | ||
3310 | timeLeft -= ODE_STEPSIZE; | 3306 | step_time -= ODE_STEPSIZE; |
3307 | fps += ODE_STEPSIZE; | ||
3311 | } | 3308 | } |
3312 | 3309 | ||
3313 | if (CollectStats) | 3310 | if (CollectStats) |
@@ -3403,6 +3400,7 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
3403 | m_stats[ODETotalFrameMsStatName] += Util.EnvironmentTickCountSubtract(startFrameTick); | 3400 | m_stats[ODETotalFrameMsStatName] += Util.EnvironmentTickCountSubtract(startFrameTick); |
3404 | } | 3401 | } |
3405 | 3402 | ||
3403 | fps *= 1.0f/timeStep; | ||
3406 | return fps; | 3404 | return fps; |
3407 | } | 3405 | } |
3408 | 3406 | ||
@@ -3943,7 +3941,6 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
3943 | 3941 | ||
3944 | _heightmap = new float[heightmapWidthSamples * heightmapHeightSamples]; | 3942 | _heightmap = new float[heightmapWidthSamples * heightmapHeightSamples]; |
3945 | 3943 | ||
3946 | |||
3947 | const float scale = 1.0f; | 3944 | const float scale = 1.0f; |
3948 | const float offset = 0.0f; | 3945 | const float offset = 0.0f; |
3949 | const float thickness = 10f; | 3946 | const float thickness = 10f; |
diff --git a/OpenSim/Region/PhysicsModules/POS/POSPrim.cs b/OpenSim/Region/PhysicsModules/POS/POSPrim.cs index 8aae716..c190fab 100644 --- a/OpenSim/Region/PhysicsModules/POS/POSPrim.cs +++ b/OpenSim/Region/PhysicsModules/POS/POSPrim.cs | |||
@@ -298,7 +298,7 @@ namespace OpenSim.Region.PhysicsModule.POS | |||
298 | { | 298 | { |
299 | set { return; } | 299 | set { return; } |
300 | } | 300 | } |
301 | 301 | ||
302 | public override Quaternion APIDTarget | 302 | public override Quaternion APIDTarget |
303 | { | 303 | { |
304 | set { return; } | 304 | set { return; } |
diff --git a/OpenSim/Region/PhysicsModules/POS/POSScene.cs b/OpenSim/Region/PhysicsModules/POS/POSScene.cs index 6375f18..e6bcbf2 100644 --- a/OpenSim/Region/PhysicsModules/POS/POSScene.cs +++ b/OpenSim/Region/PhysicsModules/POS/POSScene.cs | |||
@@ -288,7 +288,7 @@ namespace OpenSim.Region.PhysicsModule.POS | |||
288 | character._velocity.Z = (character.Position.Z - oldposZ)/timeStep; | 288 | character._velocity.Z = (character.Position.Z - oldposZ)/timeStep; |
289 | } | 289 | } |
290 | } | 290 | } |
291 | return fps; | 291 | return 1.0f; |
292 | } | 292 | } |
293 | 293 | ||
294 | public override void GetResults() | 294 | public override void GetResults() |
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs index 5c75307..88169bb 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Runtime.InteropServices; | ||
30 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
32 | 33 | ||
@@ -36,7 +37,12 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
36 | { | 37 | { |
37 | IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod); | 38 | IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod); |
38 | IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical); | 39 | IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical); |
39 | IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache); | 40 | IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex, bool forOde); |
41 | IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache, bool convex, bool forOde); | ||
42 | IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex); | ||
43 | void ReleaseMesh(IMesh mesh); | ||
44 | void ExpireReleaseMeshs(); | ||
45 | void ExpireFileCache(); | ||
40 | } | 46 | } |
41 | 47 | ||
42 | // Values for level of detail to be passed to the mesher. | 48 | // Values for level of detail to be passed to the mesher. |
@@ -54,6 +60,25 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
54 | { | 60 | { |
55 | } | 61 | } |
56 | 62 | ||
63 | [Serializable()] | ||
64 | [StructLayout(LayoutKind.Explicit)] | ||
65 | public struct AMeshKey | ||
66 | { | ||
67 | [FieldOffset(0)] | ||
68 | public UUID uuid; | ||
69 | [FieldOffset(0)] | ||
70 | public ulong hashA; | ||
71 | [FieldOffset(8)] | ||
72 | public ulong hashB; | ||
73 | [FieldOffset(16)] | ||
74 | public ulong hashC; | ||
75 | |||
76 | public override string ToString() | ||
77 | { | ||
78 | return uuid.ToString() + "-" + hashC.ToString("x") ; | ||
79 | } | ||
80 | } | ||
81 | |||
57 | public interface IMesh | 82 | public interface IMesh |
58 | { | 83 | { |
59 | List<Vector3> getVertexList(); | 84 | List<Vector3> getVertexList(); |
@@ -67,5 +92,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
67 | void releasePinned(); | 92 | void releasePinned(); |
68 | void Append(IMesh newMesh); | 93 | void Append(IMesh newMesh); |
69 | void TransformLinear(float[,] matrix, float[] offset); | 94 | void TransformLinear(float[,] matrix, float[] offset); |
95 | Vector3 GetCentroid(); | ||
96 | Vector3 GetOBB(); | ||
70 | } | 97 | } |
71 | } | 98 | } |
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs index c04ff58..edc41e4 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs | |||
@@ -43,7 +43,8 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
43 | Unknown = 0, | 43 | Unknown = 0, |
44 | Agent = 1, | 44 | Agent = 1, |
45 | Prim = 2, | 45 | Prim = 2, |
46 | Ground = 3 | 46 | Ground = 3, |
47 | Water = 4 | ||
47 | } | 48 | } |
48 | 49 | ||
49 | public enum PIDHoverType | 50 | public enum PIDHoverType |
@@ -59,15 +60,41 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
59 | public Vector3 Position; | 60 | public Vector3 Position; |
60 | public Vector3 SurfaceNormal; | 61 | public Vector3 SurfaceNormal; |
61 | public float PenetrationDepth; | 62 | public float PenetrationDepth; |
63 | public float RelativeSpeed; | ||
64 | public bool CharacterFeet; | ||
62 | 65 | ||
63 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) | 66 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) |
64 | { | 67 | { |
65 | Position = position; | 68 | Position = position; |
66 | SurfaceNormal = surfaceNormal; | 69 | SurfaceNormal = surfaceNormal; |
67 | PenetrationDepth = penetrationDepth; | 70 | PenetrationDepth = penetrationDepth; |
71 | RelativeSpeed = 0f; // for now let this one be set explicity | ||
72 | CharacterFeet = true; // keep other plugins work as before | ||
73 | } | ||
74 | |||
75 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth, bool feet) | ||
76 | { | ||
77 | Position = position; | ||
78 | SurfaceNormal = surfaceNormal; | ||
79 | PenetrationDepth = penetrationDepth; | ||
80 | RelativeSpeed = 0f; // for now let this one be set explicity | ||
81 | CharacterFeet = feet; // keep other plugins work as before | ||
68 | } | 82 | } |
69 | } | 83 | } |
70 | 84 | ||
85 | public struct ContactData | ||
86 | { | ||
87 | public float mu; | ||
88 | public float bounce; | ||
89 | public bool softcolide; | ||
90 | |||
91 | public ContactData(float _mu, float _bounce, bool _softcolide) | ||
92 | { | ||
93 | mu = _mu; | ||
94 | bounce = _bounce; | ||
95 | softcolide = _softcolide; | ||
96 | } | ||
97 | } | ||
71 | /// <summary> | 98 | /// <summary> |
72 | /// Used to pass collision information to OnCollisionUpdate listeners. | 99 | /// Used to pass collision information to OnCollisionUpdate listeners. |
73 | /// </summary> | 100 | /// </summary> |
@@ -99,7 +126,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
99 | m_objCollisionList.Add(localID, contact); | 126 | m_objCollisionList.Add(localID, contact); |
100 | } | 127 | } |
101 | else | 128 | else |
102 | { | 129 | { |
103 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) | 130 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) |
104 | m_objCollisionList[localID] = contact; | 131 | m_objCollisionList[localID] = contact; |
105 | } | 132 | } |
@@ -135,6 +162,8 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
135 | /// </summary> | 162 | /// </summary> |
136 | public event CollisionUpdate OnCollisionUpdate; | 163 | public event CollisionUpdate OnCollisionUpdate; |
137 | 164 | ||
165 | public virtual void SetVehicle(object vdata) { } | ||
166 | |||
138 | public event OutOfBounds OnOutOfBounds; | 167 | public event OutOfBounds OnOutOfBounds; |
139 | #pragma warning restore 67 | 168 | #pragma warning restore 67 |
140 | 169 | ||
@@ -142,11 +171,32 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
142 | { | 171 | { |
143 | get { return new NullPhysicsActor(); } | 172 | get { return new NullPhysicsActor(); } |
144 | } | 173 | } |
174 | |||
175 | public virtual bool Building { get; set; } | ||
176 | |||
177 | public virtual void getContactData(ref ContactData cdata) | ||
178 | { | ||
179 | cdata.mu = 0; | ||
180 | cdata.bounce = 0; | ||
181 | } | ||
145 | 182 | ||
146 | public abstract bool Stopped { get; } | 183 | public abstract bool Stopped { get; } |
147 | 184 | ||
148 | public abstract Vector3 Size { get; set; } | 185 | public abstract Vector3 Size { get; set; } |
149 | 186 | ||
187 | public virtual void setAvatarSize(Vector3 size, float feetOffset) | ||
188 | { | ||
189 | Size = size; | ||
190 | } | ||
191 | |||
192 | public virtual bool Phantom { get; set; } | ||
193 | |||
194 | public virtual bool IsVolumeDtc | ||
195 | { | ||
196 | get { return false; } | ||
197 | set { return; } | ||
198 | } | ||
199 | |||
150 | public virtual byte PhysicsShapeType { get; set; } | 200 | public virtual byte PhysicsShapeType { get; set; } |
151 | 201 | ||
152 | public abstract PrimitiveBaseShape Shape { set; } | 202 | public abstract PrimitiveBaseShape Shape { set; } |
@@ -169,7 +219,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
169 | /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or | 219 | /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or |
170 | /// water. This is not a problem due to the formatting of names given by prims and avatars. | 220 | /// water. This is not a problem due to the formatting of names given by prims and avatars. |
171 | /// </remarks> | 221 | /// </remarks> |
172 | public string Name { get; protected set; } | 222 | public string Name { get; set; } |
173 | 223 | ||
174 | /// <summary> | 224 | /// <summary> |
175 | /// This is being used by ODE joint code. | 225 | /// This is being used by ODE joint code. |
@@ -253,6 +303,51 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
253 | public abstract Vector3 GeometricCenter { get; } | 303 | public abstract Vector3 GeometricCenter { get; } |
254 | public abstract Vector3 CenterOfMass { get; } | 304 | public abstract Vector3 CenterOfMass { get; } |
255 | 305 | ||
306 | public virtual Vector3 OOBsize | ||
307 | { | ||
308 | get | ||
309 | { | ||
310 | Vector3 s=Size; | ||
311 | s.X *=0.5f; | ||
312 | s.Y *=0.5f; | ||
313 | s.Z *=0.5f; | ||
314 | return s; | ||
315 | } | ||
316 | } | ||
317 | |||
318 | public virtual Vector3 OOBoffset | ||
319 | { | ||
320 | get | ||
321 | { | ||
322 | return Vector3.Zero; | ||
323 | } | ||
324 | } | ||
325 | |||
326 | public virtual float OOBRadiusSQ | ||
327 | { | ||
328 | get | ||
329 | { | ||
330 | return Size.LengthSquared() * 0.25f; // ((0.5^2) | ||
331 | } | ||
332 | } | ||
333 | |||
334 | |||
335 | public virtual float PhysicsCost | ||
336 | { | ||
337 | get | ||
338 | { | ||
339 | return 0.1f; | ||
340 | } | ||
341 | } | ||
342 | |||
343 | public virtual float StreamCost | ||
344 | { | ||
345 | get | ||
346 | { | ||
347 | return 1.0f; | ||
348 | } | ||
349 | } | ||
350 | |||
256 | /// <summary> | 351 | /// <summary> |
257 | /// The desired velocity of this actor. | 352 | /// The desired velocity of this actor. |
258 | /// </summary> | 353 | /// </summary> |
@@ -314,6 +409,12 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
314 | public abstract void UnSubscribeEvents(); | 409 | public abstract void UnSubscribeEvents(); |
315 | public abstract bool SubscribedEvents(); | 410 | public abstract bool SubscribedEvents(); |
316 | 411 | ||
412 | public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { } | ||
413 | |||
414 | // Warning in a parent part it returns itself, not null | ||
415 | public virtual PhysicsActor ParentActor { get { return this; } } | ||
416 | |||
417 | |||
317 | // Extendable interface for new, physics engine specific operations | 418 | // Extendable interface for new, physics engine specific operations |
318 | public virtual object Extension(string pFunct, params object[] pParams) | 419 | public virtual object Extension(string pFunct, params object[] pParams) |
319 | { | 420 | { |
@@ -324,9 +425,11 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
324 | 425 | ||
325 | public class NullPhysicsActor : PhysicsActor | 426 | public class NullPhysicsActor : PhysicsActor |
326 | { | 427 | { |
428 | private ActorTypes m_actorType = ActorTypes.Unknown; | ||
429 | |||
327 | public override bool Stopped | 430 | public override bool Stopped |
328 | { | 431 | { |
329 | get{ return false; } | 432 | get{ return true; } |
330 | } | 433 | } |
331 | 434 | ||
332 | public override Vector3 Position | 435 | public override Vector3 Position |
@@ -343,6 +446,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
343 | 446 | ||
344 | public override uint LocalID | 447 | public override uint LocalID |
345 | { | 448 | { |
449 | get { return 0; } | ||
346 | set { return; } | 450 | set { return; } |
347 | } | 451 | } |
348 | 452 | ||
@@ -402,50 +506,17 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
402 | set { return; } | 506 | set { return; } |
403 | } | 507 | } |
404 | 508 | ||
405 | public override void VehicleFloatParam(int param, float value) | 509 | public override void VehicleFloatParam(int param, float value) {} |
406 | { | 510 | public override void VehicleVectorParam(int param, Vector3 value) { } |
511 | public override void VehicleRotationParam(int param, Quaternion rotation) { } | ||
512 | public override void VehicleFlags(int param, bool remove) { } | ||
513 | public override void SetVolumeDetect(int param) {} | ||
514 | public override void SetMaterial(int material) {} | ||
515 | public override Vector3 CenterOfMass { get { return Vector3.Zero; }} | ||
407 | 516 | ||
408 | } | 517 | public override Vector3 GeometricCenter { get { return Vector3.Zero; }} |
409 | 518 | ||
410 | public override void VehicleVectorParam(int param, Vector3 value) | 519 | public override PrimitiveBaseShape Shape { set { return; }} |
411 | { | ||
412 | |||
413 | } | ||
414 | |||
415 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
416 | { | ||
417 | |||
418 | } | ||
419 | |||
420 | public override void VehicleFlags(int param, bool remove) | ||
421 | { | ||
422 | |||
423 | } | ||
424 | |||
425 | public override void SetVolumeDetect(int param) | ||
426 | { | ||
427 | |||
428 | } | ||
429 | |||
430 | public override void SetMaterial(int material) | ||
431 | { | ||
432 | |||
433 | } | ||
434 | |||
435 | public override Vector3 CenterOfMass | ||
436 | { | ||
437 | get { return Vector3.Zero; } | ||
438 | } | ||
439 | |||
440 | public override Vector3 GeometricCenter | ||
441 | { | ||
442 | get { return Vector3.Zero; } | ||
443 | } | ||
444 | |||
445 | public override PrimitiveBaseShape Shape | ||
446 | { | ||
447 | set { return; } | ||
448 | } | ||
449 | 520 | ||
450 | public override Vector3 Velocity | 521 | public override Vector3 Velocity |
451 | { | 522 | { |
@@ -465,9 +536,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
465 | set { } | 536 | set { } |
466 | } | 537 | } |
467 | 538 | ||
468 | public override void CrossingFailure() | 539 | public override void CrossingFailure() {} |
469 | { | ||
470 | } | ||
471 | 540 | ||
472 | public override Quaternion Orientation | 541 | public override Quaternion Orientation |
473 | { | 542 | { |
@@ -507,8 +576,20 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
507 | 576 | ||
508 | public override int PhysicsActorType | 577 | public override int PhysicsActorType |
509 | { | 578 | { |
510 | get { return (int) ActorTypes.Unknown; } | 579 | get { return (int)m_actorType; } |
511 | set { return; } | 580 | set { |
581 | ActorTypes type = (ActorTypes)value; | ||
582 | switch (type) | ||
583 | { | ||
584 | case ActorTypes.Ground: | ||
585 | case ActorTypes.Water: | ||
586 | m_actorType = type; | ||
587 | break; | ||
588 | default: | ||
589 | m_actorType = ActorTypes.Unknown; | ||
590 | break; | ||
591 | } | ||
592 | } | ||
512 | } | 593 | } |
513 | 594 | ||
514 | public override bool Kinematic | 595 | public override bool Kinematic |
@@ -517,26 +598,11 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
517 | set { return; } | 598 | set { return; } |
518 | } | 599 | } |
519 | 600 | ||
520 | public override void link(PhysicsActor obj) | 601 | public override void link(PhysicsActor obj) { } |
521 | { | 602 | public override void delink() { } |
522 | } | 603 | public override void LockAngularMotion(Vector3 axis) { } |
523 | 604 | public override void AddForce(Vector3 force, bool pushforce) { } | |
524 | public override void delink() | 605 | public override void AddAngularForce(Vector3 force, bool pushforce) { } |
525 | { | ||
526 | } | ||
527 | |||
528 | public override void LockAngularMotion(Vector3 axis) | ||
529 | { | ||
530 | } | ||
531 | |||
532 | public override void AddForce(Vector3 force, bool pushforce) | ||
533 | { | ||
534 | } | ||
535 | |||
536 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
537 | { | ||
538 | |||
539 | } | ||
540 | 606 | ||
541 | public override Vector3 RotationalVelocity | 607 | public override Vector3 RotationalVelocity |
542 | { | 608 | { |
@@ -564,21 +630,10 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
564 | public override float APIDStrength { set { return; } } | 630 | public override float APIDStrength { set { return; } } |
565 | public override float APIDDamping { set { return; } } | 631 | public override float APIDDamping { set { return; } } |
566 | 632 | ||
567 | public override void SetMomentum(Vector3 momentum) | 633 | public override void SetMomentum(Vector3 momentum) { } |
568 | { | ||
569 | } | ||
570 | |||
571 | public override void SubscribeEvents(int ms) | ||
572 | { | ||
573 | |||
574 | } | ||
575 | public override void UnSubscribeEvents() | ||
576 | { | ||
577 | 634 | ||
578 | } | 635 | public override void SubscribeEvents(int ms) { } |
579 | public override bool SubscribedEvents() | 636 | public override void UnSubscribeEvents() { } |
580 | { | 637 | public override bool SubscribedEvents() { return false; } |
581 | return false; | ||
582 | } | ||
583 | } | 638 | } |
584 | } | 639 | } |
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs index 32691fc..1c0ad20 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs | |||
@@ -41,6 +41,10 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
41 | 41 | ||
42 | public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal); | 42 | public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal); |
43 | public delegate void RayCallback(List<ContactResult> list); | 43 | public delegate void RayCallback(List<ContactResult> list); |
44 | public delegate void ProbeBoxCallback(List<ContactResult> list); | ||
45 | public delegate void ProbeSphereCallback(List<ContactResult> list); | ||
46 | public delegate void ProbePlaneCallback(List<ContactResult> list); | ||
47 | public delegate void SitAvatarCallback(int status, uint partID, Vector3 offset, Quaternion Orientation); | ||
44 | 48 | ||
45 | public delegate void JointMoved(PhysicsJoint joint); | 49 | public delegate void JointMoved(PhysicsJoint joint); |
46 | public delegate void JointDeactivated(PhysicsJoint joint); | 50 | public delegate void JointDeactivated(PhysicsJoint joint); |
@@ -89,6 +93,8 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
89 | public Vector3 Normal; | 93 | public Vector3 Normal; |
90 | } | 94 | } |
91 | 95 | ||
96 | |||
97 | |||
92 | public abstract class PhysicsScene | 98 | public abstract class PhysicsScene |
93 | { | 99 | { |
94 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 100 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -143,6 +149,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
143 | /// <param name="size"></param> | 149 | /// <param name="size"></param> |
144 | /// <param name="isFlying"></param> | 150 | /// <param name="isFlying"></param> |
145 | /// <returns></returns> | 151 | /// <returns></returns> |
152 | |||
146 | public abstract PhysicsActor AddAvatar( | 153 | public abstract PhysicsActor AddAvatar( |
147 | string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying); | 154 | string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying); |
148 | 155 | ||
@@ -161,12 +168,26 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
161 | { | 168 | { |
162 | PhysicsActor ret = AddAvatar(avName, position, velocity, size, isFlying); | 169 | PhysicsActor ret = AddAvatar(avName, position, velocity, size, isFlying); |
163 | 170 | ||
164 | if (ret != null) | 171 | if (ret != null) |
165 | ret.LocalID = localID; | 172 | ret.LocalID = localID; |
166 | 173 | ||
167 | return ret; | 174 | return ret; |
168 | } | 175 | } |
169 | 176 | ||
177 | public virtual PhysicsActor AddAvatar( | ||
178 | uint localID, string avName, Vector3 position, Vector3 size, bool isFlying) | ||
179 | { | ||
180 | PhysicsActor ret = AddAvatar(localID, avName, position, Vector3.Zero, size, isFlying); | ||
181 | return ret; | ||
182 | } | ||
183 | |||
184 | public virtual PhysicsActor AddAvatar( | ||
185 | uint localID, string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying) | ||
186 | { | ||
187 | PhysicsActor ret = AddAvatar(localID, avName, position, Vector3.Zero, size, isFlying); | ||
188 | return ret; | ||
189 | } | ||
190 | |||
170 | /// <summary> | 191 | /// <summary> |
171 | /// Remove an avatar. | 192 | /// Remove an avatar. |
172 | /// </summary> | 193 | /// </summary> |
@@ -182,6 +203,19 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
182 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 203 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
183 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid); | 204 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid); |
184 | 205 | ||
206 | public virtual PhysicsActor AddPrimShape(string primName, PhysicsActor parent, PrimitiveBaseShape pbs, Vector3 position, | ||
207 | uint localid, byte[] sdata) | ||
208 | { | ||
209 | return null; | ||
210 | } | ||
211 | |||
212 | public virtual PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
213 | Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid) | ||
214 | { | ||
215 | return AddPrimShape(primName, pbs, position, size, rotation, isPhysical, localid); | ||
216 | } | ||
217 | |||
218 | |||
185 | public virtual PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 219 | public virtual PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
186 | Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapetype, uint localid) | 220 | Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapetype, uint localid) |
187 | { | 221 | { |
@@ -255,6 +289,9 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
255 | 289 | ||
256 | public abstract void AddPhysicsActorTaint(PhysicsActor prim); | 290 | public abstract void AddPhysicsActorTaint(PhysicsActor prim); |
257 | 291 | ||
292 | |||
293 | public virtual void PrepareSimulation() { } | ||
294 | |||
258 | /// <summary> | 295 | /// <summary> |
259 | /// Perform a simulation of the current physics scene over the given timestep. | 296 | /// Perform a simulation of the current physics scene over the given timestep. |
260 | /// </summary> | 297 | /// </summary> |
@@ -299,7 +336,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
299 | } | 336 | } |
300 | 337 | ||
301 | public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) {} | 338 | public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) {} |
302 | 339 | public virtual void CombineTerrain(float[] heightMap, Vector3 pOffset) {} | |
303 | public virtual void UnCombine(PhysicsScene pScene) {} | 340 | public virtual void UnCombine(PhysicsScene pScene) {} |
304 | 341 | ||
305 | /// <summary> | 342 | /// <summary> |
@@ -348,6 +385,31 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
348 | return false; | 385 | return false; |
349 | } | 386 | } |
350 | 387 | ||
388 | public virtual List<ContactResult> RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags flags) | ||
389 | { | ||
390 | return new List<ContactResult>(); | ||
391 | } | ||
392 | |||
393 | public virtual List<ContactResult> BoxProbe(Vector3 position, Vector3 size, Quaternion orientation, int Count, RayFilterFlags flags) | ||
394 | { | ||
395 | return new List<ContactResult>(); | ||
396 | } | ||
397 | |||
398 | public virtual List<ContactResult> SphereProbe(Vector3 position, float radius, int Count, RayFilterFlags flags) | ||
399 | { | ||
400 | return new List<ContactResult>(); | ||
401 | } | ||
402 | |||
403 | public virtual List<ContactResult> PlaneProbe(PhysicsActor actor, Vector4 plane, int Count, RayFilterFlags flags) | ||
404 | { | ||
405 | return new List<ContactResult>(); | ||
406 | } | ||
407 | |||
408 | public virtual int SitAvatar(PhysicsActor actor, Vector3 AbsolutePosition, Vector3 CameraPosition, Vector3 offset, Vector3 AvatarSize, SitAvatarCallback PhysicsSitResponse) | ||
409 | { | ||
410 | return 0; | ||
411 | } | ||
412 | |||
351 | // Extendable interface for new, physics engine specific operations | 413 | // Extendable interface for new, physics engine specific operations |
352 | public virtual object Extension(string pFunct, params object[] pParams) | 414 | public virtual object Extension(string pFunct, params object[] pParams) |
353 | { | 415 | { |
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs index 63a8cb8..e850b11 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenMetaverse; | ||
29 | 30 | ||
30 | namespace OpenSim.Region.PhysicsModules.SharedBase | 31 | namespace OpenSim.Region.PhysicsModules.SharedBase |
31 | { | 32 | { |
@@ -117,5 +118,47 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
117 | NO_DEFLECTION = 16392, | 118 | NO_DEFLECTION = 16392, |
118 | LOCK_ROTATION = 32784 | 119 | LOCK_ROTATION = 32784 |
119 | } | 120 | } |
120 | 121 | ||
122 | public struct VehicleData | ||
123 | { | ||
124 | public Vehicle m_type; | ||
125 | public VehicleFlag m_flags; | ||
126 | |||
127 | // Linear properties | ||
128 | public Vector3 m_linearMotorDirection; | ||
129 | public Vector3 m_linearFrictionTimescale; | ||
130 | public float m_linearMotorDecayTimescale; | ||
131 | public float m_linearMotorTimescale; | ||
132 | public Vector3 m_linearMotorOffset; | ||
133 | |||
134 | //Angular properties | ||
135 | public Vector3 m_angularMotorDirection; | ||
136 | public float m_angularMotorTimescale; | ||
137 | public float m_angularMotorDecayTimescale; | ||
138 | public Vector3 m_angularFrictionTimescale; | ||
139 | |||
140 | //Deflection properties | ||
141 | public float m_angularDeflectionEfficiency; | ||
142 | public float m_angularDeflectionTimescale; | ||
143 | public float m_linearDeflectionEfficiency; | ||
144 | public float m_linearDeflectionTimescale; | ||
145 | |||
146 | //Banking properties | ||
147 | public float m_bankingEfficiency; | ||
148 | public float m_bankingMix; | ||
149 | public float m_bankingTimescale; | ||
150 | |||
151 | //Hover and Buoyancy properties | ||
152 | public float m_VhoverHeight; | ||
153 | public float m_VhoverEfficiency; | ||
154 | public float m_VhoverTimescale; | ||
155 | public float m_VehicleBuoyancy; | ||
156 | |||
157 | //Attractor properties | ||
158 | public float m_verticalAttractionEfficiency; | ||
159 | public float m_verticalAttractionTimescale; | ||
160 | |||
161 | // Axis | ||
162 | public Quaternion m_referenceFrame; | ||
163 | } | ||
121 | } | 164 | } |