aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/OdePlugin.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs31
1 files changed, 20 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 4e69175..646ccb5 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -32,7 +32,7 @@ using Axiom.Math;
32using Ode.NET; 32using Ode.NET;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.Physics.Manager;
35using OpenSim.Region.Physics.OdePlugin.Meshing; 35//using OpenSim.Region.Physics.OdePlugin.Meshing;
36 36
37namespace OpenSim.Region.Physics.OdePlugin 37namespace OpenSim.Region.Physics.OdePlugin
38{ 38{
@@ -98,6 +98,8 @@ namespace OpenSim.Region.Physics.OdePlugin
98 public IntPtr space; 98 public IntPtr space;
99 public static Object OdeLock = new Object(); 99 public static Object OdeLock = new Object();
100 100
101 public IMesher mesher;
102
101 public OdeScene() 103 public OdeScene()
102 { 104 {
103 nearCallback = near; 105 nearCallback = near;
@@ -137,6 +139,12 @@ namespace OpenSim.Region.Physics.OdePlugin
137 139
138 } 140 }
139 141
142 public override void Initialise(IMesher meshmerizer)
143 {
144 mesher = meshmerizer;
145 }
146
147
140 // This function blatantly ripped off from BoxStack.cs 148 // This function blatantly ripped off from BoxStack.cs
141 private void near(IntPtr space, IntPtr g1, IntPtr g2) 149 private void near(IntPtr space, IntPtr g1, IntPtr g2)
142 { 150 {
@@ -308,7 +316,7 @@ namespace OpenSim.Region.Physics.OdePlugin
308 } 316 }
309 317
310 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, 318 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation,
311 Mesh mesh, PrimitiveBaseShape pbs, bool isphysical) 319 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
312 { 320 {
313 PhysicsVector pos = new PhysicsVector(); 321 PhysicsVector pos = new PhysicsVector();
314 pos.X = position.X; 322 pos.X = position.X;
@@ -409,11 +417,12 @@ namespace OpenSim.Region.Physics.OdePlugin
409 { 417 {
410 return this.AddPrimShape(primName, pbs, position, size, rotation, false); 418 return this.AddPrimShape(primName, pbs, position, size, rotation, false);
411 } 419 }
420
412 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 421 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
413 PhysicsVector size, Quaternion rotation, bool isPhysical) 422 PhysicsVector size, Quaternion rotation, bool isPhysical)
414 { 423 {
415 PhysicsActor result; 424 PhysicsActor result;
416 Mesh mesh = null; 425 IMesh mesh = null;
417 426
418 switch (pbs.ProfileShape) 427 switch (pbs.ProfileShape)
419 { 428 {
@@ -421,7 +430,7 @@ namespace OpenSim.Region.Physics.OdePlugin
421 /// support simple box & hollow box now; later, more shapes 430 /// support simple box & hollow box now; later, more shapes
422 if (needsMeshing(pbs)) 431 if (needsMeshing(pbs))
423 { 432 {
424 mesh = Meshmerizer.CreateMesh(primName, pbs, size); 433 mesh = mesher.CreateMesh(primName, pbs, size);
425 } 434 }
426 435
427 break; 436 break;
@@ -931,7 +940,7 @@ namespace OpenSim.Region.Physics.OdePlugin
931 private PhysicsVector _acceleration; 940 private PhysicsVector _acceleration;
932 public Quaternion _orientation; 941 public Quaternion _orientation;
933 942
934 private Mesh _mesh; 943 private IMesh _mesh;
935 private PrimitiveBaseShape _pbs; 944 private PrimitiveBaseShape _pbs;
936 private OdeScene _parent_scene; 945 private OdeScene _parent_scene;
937 public IntPtr prim_geom; 946 public IntPtr prim_geom;
@@ -953,7 +962,7 @@ namespace OpenSim.Region.Physics.OdePlugin
953 962
954 963
955 public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, 964 public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size,
956 Quaternion rotation, Mesh mesh, PrimitiveBaseShape pbs, bool pisPhysical) 965 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical)
957 { 966 {
958 967
959 968
@@ -1036,15 +1045,15 @@ namespace OpenSim.Region.Physics.OdePlugin
1036 Body = (IntPtr)0; 1045 Body = (IntPtr)0;
1037 } 1046 }
1038 } 1047 }
1039 public void setMesh(OdeScene parent_scene, Mesh mesh) 1048 public void setMesh(OdeScene parent_scene, IMesh mesh)
1040 { 1049 {
1041 //Kill Body so that mesh can re-make the geom 1050 //Kill Body so that mesh can re-make the geom
1042 if (IsPhysical && Body != (IntPtr)0) 1051 if (IsPhysical && Body != (IntPtr)0)
1043 { 1052 {
1044 disableBody(); 1053 disableBody();
1045 } 1054 }
1046 float[] vertexList = mesh.getVertexListAsFloat(); // Note, that vertextList is pinned in memory 1055 float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
1047 int[] indexList = mesh.getIndexListAsInt(); // Also pinned, needs release after usage 1056 int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
1048 int VertexCount = vertexList.GetLength(0)/3; 1057 int VertexCount = vertexList.GetLength(0)/3;
1049 int IndexCount = indexList.GetLength(0); 1058 int IndexCount = indexList.GetLength(0);
1050 1059
@@ -1169,7 +1178,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1169 1178
1170 1179
1171 // Don't need to re-enable body.. it's done in SetMesh 1180 // Don't need to re-enable body.. it's done in SetMesh
1172 Mesh mesh = Meshmerizer.CreateMesh(oldname, _pbs, _size); 1181 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size);
1173 // createmesh returns null when it's a shape that isn't a cube. 1182 // createmesh returns null when it's a shape that isn't a cube.
1174 if (mesh != null) 1183 if (mesh != null)
1175 setMesh(_parent_scene, mesh); 1184 setMesh(_parent_scene, mesh);
@@ -1218,7 +1227,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1218 // Construction of new prim 1227 // Construction of new prim
1219 if (this._parent_scene.needsMeshing(_pbs)) 1228 if (this._parent_scene.needsMeshing(_pbs))
1220 { 1229 {
1221 Mesh mesh = Meshmerizer.CreateMesh(oldname, _pbs, _size); 1230 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size);
1222 setMesh(_parent_scene, mesh); 1231 setMesh(_parent_scene, mesh);
1223 } else { 1232 } else {
1224 prim_geom = d.CreateBox(_parent_scene.space, _size.X, _size.Y, _size.Z); 1233 prim_geom = d.CreateBox(_parent_scene.space, _size.X, _size.Y, _size.Z);