Applied danx0r's ODE patch [mantis number 340].
Corrected a few out dated things in the ExtensionsScriptModule.afrisby
parent
7915adc6c5
commit
3a97f3f597
|
@ -47,8 +47,9 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp
|
||||||
compilerParams.GenerateExecutable = false;
|
compilerParams.GenerateExecutable = false;
|
||||||
compilerParams.GenerateInMemory = true;
|
compilerParams.GenerateInMemory = true;
|
||||||
compilerParams.IncludeDebugInformation = false;
|
compilerParams.IncludeDebugInformation = false;
|
||||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
|
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll");
|
||||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll");
|
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll");
|
||||||
|
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll");
|
||||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
|
compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
|
||||||
compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
|
compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
|
||||||
compilerParams.ReferencedAssemblies.Add("System.dll");
|
compilerParams.ReferencedAssemblies.Add("System.dll");
|
||||||
|
|
|
@ -47,8 +47,9 @@ namespace OpenSim.Region.ExtensionsScriptModule.JScript
|
||||||
compilerParams.GenerateExecutable = false;
|
compilerParams.GenerateExecutable = false;
|
||||||
compilerParams.GenerateInMemory = true;
|
compilerParams.GenerateInMemory = true;
|
||||||
compilerParams.IncludeDebugInformation = false;
|
compilerParams.IncludeDebugInformation = false;
|
||||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
|
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll");
|
||||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll");
|
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll");
|
||||||
|
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll");
|
||||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
|
compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
|
||||||
compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
|
compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
|
||||||
compilerParams.ReferencedAssemblies.Add("System.dll");
|
compilerParams.ReferencedAssemblies.Add("System.dll");
|
||||||
|
|
|
@ -84,6 +84,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
private List<OdePrim> _prims = new List<OdePrim>();
|
private List<OdePrim> _prims = new List<OdePrim>();
|
||||||
private static d.ContactGeom[] contacts = new d.ContactGeom[30];
|
private static d.ContactGeom[] contacts = new d.ContactGeom[30];
|
||||||
private static d.Contact contact;
|
private static d.Contact contact;
|
||||||
|
public static Object OdeLock = new Object();
|
||||||
public OdeScene()
|
public OdeScene()
|
||||||
{
|
{
|
||||||
contact.surface.mode |= d.ContactFlags.Approx1 | d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP;
|
contact.surface.mode |= d.ContactFlags.Approx1 | d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP;
|
||||||
|
@ -92,14 +93,15 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
contact.surface.soft_erp = 0.005f;
|
contact.surface.soft_erp = 0.005f;
|
||||||
contact.surface.soft_cfm = 0.00003f;
|
contact.surface.soft_cfm = 0.00003f;
|
||||||
|
|
||||||
Monitor.Enter(typeof(OdeScene));
|
lock (OdeLock)
|
||||||
|
{
|
||||||
world = d.WorldCreate();
|
world = d.WorldCreate();
|
||||||
space = d.HashSpaceCreate(IntPtr.Zero);
|
space = d.HashSpaceCreate(IntPtr.Zero);
|
||||||
contactgroup = d.JointGroupCreate(0);
|
contactgroup = d.JointGroupCreate(0);
|
||||||
d.WorldSetGravity(world, 0.0f, 0.0f, -10.0f);
|
d.WorldSetGravity(world, 0.0f, 0.0f, -10.0f);
|
||||||
d.WorldSetAutoDisableFlag(world, false);
|
d.WorldSetAutoDisableFlag(world, false);
|
||||||
d.WorldSetContactSurfaceLayer(world, 0.001f);
|
d.WorldSetContactSurfaceLayer(world, 0.001f);
|
||||||
Monitor.Exit(typeof(OdeScene));
|
}
|
||||||
|
|
||||||
this._heightmap = new double[65536];
|
this._heightmap = new double[65536];
|
||||||
}
|
}
|
||||||
|
@ -128,7 +130,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
PhysicsVector pos = new PhysicsVector();
|
PhysicsVector pos = new PhysicsVector();
|
||||||
pos.X = position.X;
|
pos.X = position.X;
|
||||||
pos.Y = position.Y;
|
pos.Y = position.Y;
|
||||||
pos.Z = position.Z + 20;
|
pos.Z = position.Z;
|
||||||
OdeCharacter newAv = new OdeCharacter(this, pos);
|
OdeCharacter newAv = new OdeCharacter(this, pos);
|
||||||
this._characters.Add(newAv);
|
this._characters.Add(newAv);
|
||||||
return newAv;
|
return newAv;
|
||||||
|
@ -136,7 +138,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public override void RemoveAvatar(PhysicsActor actor)
|
public override void RemoveAvatar(PhysicsActor actor)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RemovePrim(PhysicsActor prim)
|
public override void RemovePrim(PhysicsActor prim)
|
||||||
|
@ -150,7 +151,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation)
|
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation)
|
||||||
{
|
{
|
||||||
//Console.WriteLine("+++++++++++++++++++++++++++++++++AddPrim pos: " + position + " size: " + size + " quat: " + rotation);
|
|
||||||
PhysicsVector pos = new PhysicsVector();
|
PhysicsVector pos = new PhysicsVector();
|
||||||
pos.X = position.X;
|
pos.X = position.X;
|
||||||
pos.Y = position.Y;
|
pos.Y = position.Y;
|
||||||
|
@ -165,7 +165,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
rot.y = rotation.y;
|
rot.y = rotation.y;
|
||||||
rot.z = rotation.z;
|
rot.z = rotation.z;
|
||||||
OdePrim newPrim;
|
OdePrim newPrim;
|
||||||
lock(typeof(OdeScene)) {
|
lock (OdeLock)
|
||||||
|
{
|
||||||
newPrim = new OdePrim(this, pos, siz, rot);
|
newPrim = new OdePrim(this, pos, siz, rot);
|
||||||
}
|
}
|
||||||
this._prims.Add(newPrim);
|
this._prims.Add(newPrim);
|
||||||
|
@ -174,10 +175,10 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public override void Simulate(float timeStep)
|
public override void Simulate(float timeStep)
|
||||||
{
|
{
|
||||||
Monitor.Enter(typeof(OdeScene));
|
lock (OdeLock)
|
||||||
|
{
|
||||||
foreach (OdePrim p in _prims)
|
foreach (OdePrim p in _prims)
|
||||||
{
|
{
|
||||||
// Console.WriteLine("+++ prim: " + p.Position);
|
|
||||||
}
|
}
|
||||||
foreach (OdeCharacter actor in _characters)
|
foreach (OdeCharacter actor in _characters)
|
||||||
{
|
{
|
||||||
|
@ -194,7 +195,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
actor.UpdatePosition();
|
actor.UpdatePosition();
|
||||||
}
|
}
|
||||||
Monitor.Exit(typeof(OdeScene));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void GetResults()
|
public override void GetResults()
|
||||||
|
@ -222,7 +223,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
|
IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
|
||||||
|
|
||||||
Monitor.Enter(typeof(OdeScene));
|
lock (OdeLock)
|
||||||
|
{
|
||||||
d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
|
d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
|
||||||
d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
|
d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
|
||||||
LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
|
LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
|
||||||
|
@ -241,7 +243,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle);
|
d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle);
|
||||||
d.GeomSetRotation(LandGeom, ref R);
|
d.GeomSetRotation(LandGeom, ref R);
|
||||||
d.GeomSetPosition(LandGeom, 128, 128, 0);
|
d.GeomSetPosition(LandGeom, 128, 128, 0);
|
||||||
Monitor.Exit(typeof(OdeScene));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeleteTerrain()
|
public override void DeleteTerrain()
|
||||||
|
@ -260,20 +262,23 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
private IntPtr BoundingCapsule;
|
private IntPtr BoundingCapsule;
|
||||||
IntPtr capsule_geom;
|
IntPtr capsule_geom;
|
||||||
d.Mass capsule_mass;
|
d.Mass capsule_mass;
|
||||||
|
private OdeScene _parent_scene;
|
||||||
|
|
||||||
public OdeCharacter(OdeScene parent_scene, PhysicsVector pos)
|
public OdeCharacter(OdeScene parent_scene, PhysicsVector pos)
|
||||||
{
|
{
|
||||||
_velocity = new PhysicsVector();
|
_velocity = new PhysicsVector();
|
||||||
_position = pos;
|
_position = pos;
|
||||||
_acceleration = new PhysicsVector();
|
_acceleration = new PhysicsVector();
|
||||||
Monitor.Enter(typeof(OdeScene));
|
_parent_scene = parent_scene;
|
||||||
|
lock (OdeScene.OdeLock)
|
||||||
|
{
|
||||||
d.MassSetCapsule(out capsule_mass, 50.0f, 3, 0.5f, 2f);
|
d.MassSetCapsule(out capsule_mass, 50.0f, 3, 0.5f, 2f);
|
||||||
capsule_geom = d.CreateSphere(OdeScene.space, 1.0f); /// not a typo! Spheres roll, capsules tumble
|
capsule_geom = d.CreateSphere(OdeScene.space, 1.0f); /// not a typo! Spheres roll, capsules tumble
|
||||||
this.BoundingCapsule = d.BodyCreate(OdeScene.world);
|
this.BoundingCapsule = d.BodyCreate(OdeScene.world);
|
||||||
d.BodySetMass(BoundingCapsule, ref capsule_mass);
|
d.BodySetMass(BoundingCapsule, ref capsule_mass);
|
||||||
d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z);
|
d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z);
|
||||||
d.GeomSetBody(capsule_geom, BoundingCapsule);
|
d.GeomSetBody(capsule_geom, BoundingCapsule);
|
||||||
Monitor.Exit(typeof(OdeScene));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Flying
|
public override bool Flying
|
||||||
|
@ -296,9 +301,13 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
lock (OdeScene.OdeLock)
|
||||||
|
{
|
||||||
|
d.BodySetPosition(BoundingCapsule, value.X, value.Y, value.Z);
|
||||||
_position = value;
|
_position = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override PhysicsVector Size
|
public override PhysicsVector Size
|
||||||
{
|
{
|
||||||
|
@ -389,6 +398,13 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
// no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
|
// no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
|
||||||
d.Vector3 vec = d.BodyGetPosition(BoundingCapsule);
|
d.Vector3 vec = d.BodyGetPosition(BoundingCapsule);
|
||||||
|
|
||||||
|
// kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
|
||||||
|
if (vec.X < 0.0f) vec.X = 0.0f;
|
||||||
|
if (vec.Y < 0.0f) vec.Y = 0.0f;
|
||||||
|
if (vec.X > 255.95f) vec.X = 255.95f;
|
||||||
|
if (vec.Y > 255.95f) vec.Y = 255.95f;
|
||||||
|
|
||||||
this._position.X = vec.X;
|
this._position.X = vec.X;
|
||||||
this._position.Y = vec.Y;
|
this._position.Y = vec.Y;
|
||||||
this._position.Z = vec.Z;
|
this._position.Z = vec.Z;
|
||||||
|
@ -412,7 +428,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
_acceleration = new PhysicsVector();
|
_acceleration = new PhysicsVector();
|
||||||
_orientation = rotation;
|
_orientation = rotation;
|
||||||
prim_geom = d.CreateBox(OdeScene.space, _size.X, _size.Y, _size.Z);
|
prim_geom = d.CreateBox(OdeScene.space, _size.X, _size.Y, _size.Z);
|
||||||
Monitor.Enter(typeof(OdeScene));
|
lock (OdeScene.OdeLock)
|
||||||
|
{
|
||||||
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
|
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
|
||||||
d.Quaternion myrot = new d.Quaternion();
|
d.Quaternion myrot = new d.Quaternion();
|
||||||
myrot.W = rotation.w;
|
myrot.W = rotation.w;
|
||||||
|
@ -420,7 +437,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
myrot.Y = rotation.y;
|
myrot.Y = rotation.y;
|
||||||
myrot.Z = rotation.z;
|
myrot.Z = rotation.z;
|
||||||
d.GeomSetQuaternion(prim_geom, ref myrot);
|
d.GeomSetQuaternion(prim_geom, ref myrot);
|
||||||
Monitor.Exit(typeof(OdeScene));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Flying
|
public override bool Flying
|
||||||
|
@ -442,12 +459,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
//Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++ setting pos: " + value);
|
|
||||||
_position = value;
|
_position = value;
|
||||||
Monitor.Enter(typeof(OdeScene));
|
lock (OdeScene.OdeLock)
|
||||||
|
{
|
||||||
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
|
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
|
||||||
Monitor.Exit(typeof(OdeScene));
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,11 +475,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
//Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++ setting size: " + value);
|
|
||||||
_size = value;
|
_size = value;
|
||||||
Monitor.Enter(typeof(OdeScene));
|
lock (OdeScene.OdeLock)
|
||||||
|
{
|
||||||
d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
|
d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
|
||||||
Monitor.Exit(typeof(OdeScene));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,16 +514,16 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
//Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++ setting Orientation");
|
|
||||||
_orientation = value;
|
_orientation = value;
|
||||||
Monitor.Enter(typeof(OdeScene));
|
lock (OdeScene.OdeLock)
|
||||||
|
{
|
||||||
d.Quaternion myrot = new d.Quaternion();
|
d.Quaternion myrot = new d.Quaternion();
|
||||||
myrot.W = _orientation.w;
|
myrot.W = _orientation.w;
|
||||||
myrot.X = _orientation.x;
|
myrot.X = _orientation.x;
|
||||||
myrot.Y = _orientation.y;
|
myrot.Y = _orientation.y;
|
||||||
myrot.Z = _orientation.z;
|
myrot.Z = _orientation.z;
|
||||||
d.GeomSetQuaternion(prim_geom, ref myrot);
|
d.GeomSetQuaternion(prim_geom, ref myrot);
|
||||||
Monitor.Exit(typeof(OdeScene));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue