make ubOde PInvoke follow ms coding rules
parent
8a68c330e8
commit
88511bfab2
File diff suppressed because it is too large
Load Diff
|
@ -32,7 +32,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using OpenMetaverse;
|
||||
using OdeAPI;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.PhysicsModules.SharedBase;
|
||||
using log4net;
|
||||
|
@ -144,7 +143,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
public IntPtr Amotor = IntPtr.Zero;
|
||||
|
||||
public d.Mass ShellMass;
|
||||
internal SafeNativeMethods.Mass ShellMass;
|
||||
|
||||
public int m_eventsubscription = 0;
|
||||
private int m_cureventsubscription = 0;
|
||||
|
@ -216,7 +215,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
walkDivisor = walk_divisor;
|
||||
runDivisor = rundivisor;
|
||||
|
||||
m_mass = m_density * m_size.X * m_size.Y * m_size.Z; ; // sure we have a default
|
||||
m_mass = m_density * m_size.X * m_size.Y * m_size.Z;
|
||||
; // sure we have a default
|
||||
|
||||
PID_D = basePID_D * m_mass * invtimeStep;
|
||||
PID_P = basePID_P * m_mass * invtimeStep;
|
||||
|
@ -230,8 +230,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
public override int PhysicsActorType
|
||||
{
|
||||
get { return (int)ActorTypes.Agent; }
|
||||
set { return; }
|
||||
get
|
||||
{
|
||||
return (int)ActorTypes.Agent;
|
||||
}
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override void getContactData(ref ContactData cdata)
|
||||
|
@ -241,64 +247,112 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
cdata.softcolide = false;
|
||||
}
|
||||
|
||||
public override bool Building { get; set; }
|
||||
public override bool Building
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If this is set, the avatar will move faster
|
||||
/// </summary>
|
||||
public override bool SetAlwaysRun
|
||||
{
|
||||
get { return m_alwaysRun; }
|
||||
set { m_alwaysRun = value; }
|
||||
get
|
||||
{
|
||||
return m_alwaysRun;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_alwaysRun = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override uint LocalID
|
||||
{
|
||||
get { return m_localID; }
|
||||
set { m_localID = value; }
|
||||
get
|
||||
{
|
||||
return m_localID;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_localID = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override PhysicsActor ParentActor
|
||||
{
|
||||
get { return (PhysicsActor)this; }
|
||||
get
|
||||
{
|
||||
return (PhysicsActor)this;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Grabbed
|
||||
{
|
||||
set { return; }
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Selected
|
||||
{
|
||||
set { return; }
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override float Buoyancy
|
||||
{
|
||||
get { return m_buoyancy; }
|
||||
set { m_buoyancy = value; }
|
||||
get
|
||||
{
|
||||
return m_buoyancy;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_buoyancy = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool FloatOnWater
|
||||
{
|
||||
set { return; }
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsPhysical
|
||||
{
|
||||
get { return m_isPhysical; }
|
||||
set { return; }
|
||||
get
|
||||
{
|
||||
return m_isPhysical;
|
||||
}
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ThrottleUpdates
|
||||
{
|
||||
get { return false; }
|
||||
set { return; }
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Flying
|
||||
{
|
||||
get { return m_flying; }
|
||||
get
|
||||
{
|
||||
return m_flying;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_flying = value;
|
||||
|
@ -312,7 +366,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
/// </summary>
|
||||
public override bool IsColliding
|
||||
{
|
||||
get { return (m_iscolliding || m_iscollidingGround); }
|
||||
get
|
||||
{
|
||||
return (m_iscolliding || m_iscollidingGround);
|
||||
}
|
||||
set
|
||||
{
|
||||
if(value)
|
||||
|
@ -344,7 +401,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
/// </summary>
|
||||
public override bool CollidingGround
|
||||
{
|
||||
get { return m_iscollidingGround; }
|
||||
get
|
||||
{
|
||||
return m_iscollidingGround;
|
||||
}
|
||||
set
|
||||
{
|
||||
/* we now control this
|
||||
|
@ -375,7 +435,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
/// </summary>
|
||||
public override bool CollidingObj
|
||||
{
|
||||
get { return m_iscollidingObj; }
|
||||
get
|
||||
{
|
||||
return m_iscollidingObj;
|
||||
}
|
||||
set
|
||||
{
|
||||
// Ubit filter this also
|
||||
|
@ -418,7 +481,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
public override bool Stopped
|
||||
{
|
||||
get { return _zeroFlag; }
|
||||
get
|
||||
{
|
||||
return _zeroFlag;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -428,7 +494,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
/// </summary>
|
||||
public override Vector3 Position
|
||||
{
|
||||
get { return _position; }
|
||||
get
|
||||
{
|
||||
return _position;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(value.IsFinite())
|
||||
|
@ -452,8 +521,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
public override Vector3 RotationalVelocity
|
||||
{
|
||||
get { return m_rotationalVelocity; }
|
||||
set { m_rotationalVelocity = value; }
|
||||
get
|
||||
{
|
||||
return m_rotationalVelocity;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_rotationalVelocity = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -545,14 +620,26 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
public override Vector3 Force
|
||||
{
|
||||
get { return _target_velocity; }
|
||||
set { return; }
|
||||
get
|
||||
{
|
||||
return _target_velocity;
|
||||
}
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override int VehicleType
|
||||
{
|
||||
get { return 0; }
|
||||
set { return; }
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override void VehicleFloatParam(int param,float value)
|
||||
|
@ -600,7 +687,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
public override PrimitiveBaseShape Shape
|
||||
{
|
||||
set { return; }
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override Vector3 rootVelocity
|
||||
|
@ -651,25 +741,44 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
public override Vector3 Torque
|
||||
{
|
||||
get { return Vector3.Zero; }
|
||||
set { return; }
|
||||
get
|
||||
{
|
||||
return Vector3.Zero;
|
||||
}
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override float CollisionScore
|
||||
{
|
||||
get { return 0f; }
|
||||
set { }
|
||||
get
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Kinematic
|
||||
{
|
||||
get { return false; }
|
||||
set { }
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public override Quaternion Orientation
|
||||
{
|
||||
get { return m_orientation; }
|
||||
get
|
||||
{
|
||||
return m_orientation;
|
||||
}
|
||||
set
|
||||
{
|
||||
// fakeori = value;
|
||||
|
@ -681,8 +790,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
public override Vector3 Acceleration
|
||||
{
|
||||
get { return _acceleration; }
|
||||
set { }
|
||||
get
|
||||
{
|
||||
return _acceleration;
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAcceleration(Vector3 accel)
|
||||
|
@ -751,11 +865,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
m_parent_scene.waitForSpaceUnlock(m_parent_scene.CharsSpace);
|
||||
|
||||
collider = d.SimpleSpaceCreate(m_parent_scene.CharsSpace);
|
||||
d.SpaceSetSublevel(collider, 3);
|
||||
d.SpaceSetCleanup(collider, false);
|
||||
d.GeomSetCategoryBits(collider, (uint)m_collisionCategories);
|
||||
d.GeomSetCollideBits(collider, (uint)m_collisionFlags);
|
||||
collider = SafeNativeMethods.SimpleSpaceCreate(m_parent_scene.CharsSpace);
|
||||
SafeNativeMethods.SpaceSetSublevel(collider,3);
|
||||
SafeNativeMethods.SpaceSetCleanup(collider,false);
|
||||
SafeNativeMethods.GeomSetCategoryBits(collider,(uint)m_collisionCategories);
|
||||
SafeNativeMethods.GeomSetCollideBits(collider,(uint)m_collisionFlags);
|
||||
|
||||
float r = m_size.X;
|
||||
if(m_size.Y > r)
|
||||
|
@ -763,16 +877,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
float l = m_size.Z - r;
|
||||
r *= 0.5f;
|
||||
|
||||
capsule = d.CreateCapsule(collider, r, l);
|
||||
capsule = SafeNativeMethods.CreateCapsule(collider,r,l);
|
||||
|
||||
m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass
|
||||
|
||||
d.MassSetBoxTotal(out ShellMass, m_mass, m_size.X, m_size.Y, m_size.Z);
|
||||
SafeNativeMethods.MassSetBoxTotal(out ShellMass,m_mass,m_size.X,m_size.Y,m_size.Z);
|
||||
|
||||
PID_D = basePID_D * m_mass / m_parent_scene.ODE_STEPSIZE;
|
||||
PID_P = basePID_P * m_mass / m_parent_scene.ODE_STEPSIZE;
|
||||
|
||||
Body = d.BodyCreate(m_parent_scene.world);
|
||||
Body = SafeNativeMethods.BodyCreate(m_parent_scene.world);
|
||||
|
||||
_zeroFlag = false;
|
||||
m_pidControllerActive = true;
|
||||
|
@ -780,53 +894,53 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
_velocity = Vector3.Zero;
|
||||
|
||||
d.BodySetAutoDisableFlag(Body, false);
|
||||
d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
|
||||
SafeNativeMethods.BodySetAutoDisableFlag(Body,false);
|
||||
SafeNativeMethods.BodySetPosition(Body,npositionX,npositionY,npositionZ);
|
||||
|
||||
_position.X = npositionX;
|
||||
_position.Y = npositionY;
|
||||
_position.Z = npositionZ;
|
||||
|
||||
d.BodySetMass(Body, ref ShellMass);
|
||||
d.GeomSetBody(capsule, Body);
|
||||
SafeNativeMethods.BodySetMass(Body,ref ShellMass);
|
||||
SafeNativeMethods.GeomSetBody(capsule,Body);
|
||||
|
||||
// The purpose of the AMotor here is to keep the avatar's physical
|
||||
// surrogate from rotating while moving
|
||||
Amotor = d.JointCreateAMotor(m_parent_scene.world, IntPtr.Zero);
|
||||
d.JointAttach(Amotor, Body, IntPtr.Zero);
|
||||
Amotor = SafeNativeMethods.JointCreateAMotor(m_parent_scene.world,IntPtr.Zero);
|
||||
SafeNativeMethods.JointAttach(Amotor,Body,IntPtr.Zero);
|
||||
|
||||
d.JointSetAMotorMode(Amotor, 0);
|
||||
d.JointSetAMotorNumAxes(Amotor, 3);
|
||||
d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0);
|
||||
d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0);
|
||||
d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1);
|
||||
SafeNativeMethods.JointSetAMotorMode(Amotor,0);
|
||||
SafeNativeMethods.JointSetAMotorNumAxes(Amotor,3);
|
||||
SafeNativeMethods.JointSetAMotorAxis(Amotor,0,0,1,0,0);
|
||||
SafeNativeMethods.JointSetAMotorAxis(Amotor,1,0,0,1,0);
|
||||
SafeNativeMethods.JointSetAMotorAxis(Amotor,2,0,0,0,1);
|
||||
|
||||
d.JointSetAMotorAngle(Amotor, 0, 0);
|
||||
d.JointSetAMotorAngle(Amotor, 1, 0);
|
||||
d.JointSetAMotorAngle(Amotor, 2, 0);
|
||||
SafeNativeMethods.JointSetAMotorAngle(Amotor,0,0);
|
||||
SafeNativeMethods.JointSetAMotorAngle(Amotor,1,0);
|
||||
SafeNativeMethods.JointSetAMotorAngle(Amotor,2,0);
|
||||
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM, 0f); // make it HARD
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM2, 0f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM3, 0f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.StopERP, 0.8f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.StopERP2, 0.8f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.StopERP3, 0.8f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.StopCFM,0f); // make it HARD
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.StopCFM2,0f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.StopCFM3,0f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.StopERP,0.8f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.StopERP2,0.8f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.StopERP3,0.8f);
|
||||
|
||||
// These lowstops and high stops are effectively (no wiggle room)
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -1e-5f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 1e-5f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -1e-5f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 1e-5f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -1e-5f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 1e-5f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.LowStop,-1e-5f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.HiStop,1e-5f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.LoStop2,-1e-5f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.HiStop2,1e-5f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.LoStop3,-1e-5f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.HiStop3,1e-5f);
|
||||
|
||||
d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel, 0);
|
||||
d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel2, 0);
|
||||
d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel3, 0);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)SafeNativeMethods.JointParam.Vel,0);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)SafeNativeMethods.JointParam.Vel2,0);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)SafeNativeMethods.JointParam.Vel3,0);
|
||||
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.FMax, 5e8f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.FMax2, 5e8f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.FMax3, 5e8f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.FMax,5e8f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.FMax2,5e8f);
|
||||
SafeNativeMethods.JointSetAMotorParam(Amotor,(int)dParam.FMax3,5e8f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -837,14 +951,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
// Kill the Amotor
|
||||
if(Amotor != IntPtr.Zero)
|
||||
{
|
||||
d.JointDestroy(Amotor);
|
||||
SafeNativeMethods.JointDestroy(Amotor);
|
||||
Amotor = IntPtr.Zero;
|
||||
}
|
||||
|
||||
if(Body != IntPtr.Zero)
|
||||
{
|
||||
//kill the body
|
||||
d.BodyDestroy(Body);
|
||||
SafeNativeMethods.BodyDestroy(Body);
|
||||
Body = IntPtr.Zero;
|
||||
}
|
||||
|
||||
|
@ -853,13 +967,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
{
|
||||
m_parent_scene.actor_name_map.Remove(capsule);
|
||||
m_parent_scene.waitForSpaceUnlock(collider);
|
||||
d.GeomDestroy(capsule);
|
||||
SafeNativeMethods.GeomDestroy(capsule);
|
||||
capsule = IntPtr.Zero;
|
||||
}
|
||||
|
||||
if(collider != IntPtr.Zero)
|
||||
{
|
||||
d.SpaceDestroy(collider);
|
||||
SafeNativeMethods.SpaceDestroy(collider);
|
||||
collider = IntPtr.Zero;
|
||||
}
|
||||
|
||||
|
@ -898,8 +1012,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
y = tx * sin + y * cos;
|
||||
}
|
||||
|
||||
public bool Collide(IntPtr me, IntPtr other, bool reverse, ref d.ContactGeom contact,
|
||||
ref d.ContactGeom altContact , ref bool useAltcontact, ref bool feetcollision)
|
||||
internal bool Collide(IntPtr me,IntPtr other,bool reverse,ref SafeNativeMethods.ContactGeom contact,
|
||||
ref SafeNativeMethods.ContactGeom altContact,ref bool useAltcontact,ref bool feetcollision)
|
||||
{
|
||||
feetcollision = false;
|
||||
useAltcontact = false;
|
||||
|
@ -914,8 +1028,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
offset.X = contact.pos.X - _position.X;
|
||||
offset.Y = contact.pos.Y - _position.Y;
|
||||
|
||||
d.GeomClassID gtype = d.GeomGetClass(other);
|
||||
if (gtype == d.GeomClassID.CapsuleClass)
|
||||
SafeNativeMethods.GeomClassID gtype = SafeNativeMethods.GeomGetClass(other);
|
||||
if(gtype == SafeNativeMethods.GeomClassID.CapsuleClass)
|
||||
{
|
||||
Vector3 roff = offset * Quaternion.Inverse(m_orientation2D);
|
||||
float r = roff.X *roff.X / AvaAvaSizeXsq;
|
||||
|
@ -943,9 +1057,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
return true;
|
||||
}
|
||||
|
||||
if (gtype == d.GeomClassID.SphereClass && d.GeomGetBody(other) != IntPtr.Zero)
|
||||
if(gtype == SafeNativeMethods.GeomClassID.SphereClass && SafeNativeMethods.GeomGetBody(other) != IntPtr.Zero)
|
||||
{
|
||||
if(d.GeomSphereGetRadius(other) < 0.5)
|
||||
if(SafeNativeMethods.GeomSphereGetRadius(other) < 0.5)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1027,18 +1141,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if(Body == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
d.Vector3 dtmp = d.BodyGetPosition(Body);
|
||||
SafeNativeMethods.Vector3 dtmp = SafeNativeMethods.BodyGetPosition(Body);
|
||||
Vector3 localpos = new Vector3(dtmp.X,dtmp.Y,dtmp.Z);
|
||||
|
||||
// the Amotor still lets avatar rotation to drift during colisions
|
||||
// so force it back to identity
|
||||
|
||||
d.Quaternion qtmp;
|
||||
SafeNativeMethods.Quaternion qtmp;
|
||||
qtmp.W = m_orientation2D.W;
|
||||
qtmp.X = m_orientation2D.X;
|
||||
qtmp.Y = m_orientation2D.Y;
|
||||
qtmp.Z = m_orientation2D.Z;
|
||||
d.BodySetQuaternion(Body, ref qtmp);
|
||||
SafeNativeMethods.BodySetQuaternion(Body,ref qtmp);
|
||||
|
||||
if(m_pidControllerActive == false)
|
||||
{
|
||||
|
@ -1081,13 +1195,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if(fixbody)
|
||||
{
|
||||
m_freemove = false;
|
||||
d.BodySetPosition(Body, localpos.X, localpos.Y, localpos.Z);
|
||||
SafeNativeMethods.BodySetPosition(Body,localpos.X,localpos.Y,localpos.Z);
|
||||
}
|
||||
|
||||
float breakfactor;
|
||||
|
||||
Vector3 vec = Vector3.Zero;
|
||||
dtmp = d.BodyGetLinearVel(Body);
|
||||
dtmp = SafeNativeMethods.BodyGetLinearVel(Body);
|
||||
Vector3 vel = new Vector3(dtmp.X,dtmp.Y,dtmp.Z);
|
||||
float velLengthSquared = vel.LengthSquared();
|
||||
|
||||
|
@ -1106,9 +1220,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
//******************************************
|
||||
// colide with land
|
||||
|
||||
d.AABB aabb;
|
||||
SafeNativeMethods.AABB aabb;
|
||||
// d.GeomGetAABB(feetbox, out aabb);
|
||||
d.GeomGetAABB(capsule, out aabb);
|
||||
SafeNativeMethods.GeomGetAABB(capsule,out aabb);
|
||||
float chrminZ = aabb.MinZ; // move up a bit
|
||||
Vector3 posch = localpos;
|
||||
|
||||
|
@ -1439,7 +1553,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if(vec.IsFinite())
|
||||
{
|
||||
if(vec.X != 0 || vec.Y !=0 || vec.Z !=0)
|
||||
d.BodyAddForce(Body, vec.X, vec.Y, vec.Z);
|
||||
SafeNativeMethods.BodyAddForce(Body,vec.X,vec.Y,vec.Z);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1469,7 +1583,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
a = (_velocity - a) * invtimeStep;
|
||||
SetSmooth(ref _acceleration,ref a,2);
|
||||
|
||||
dtmp = d.BodyGetAngularVel(Body);
|
||||
dtmp = SafeNativeMethods.BodyGetAngularVel(Body);
|
||||
m_rotationalVelocity.X = 0f;
|
||||
m_rotationalVelocity.Y = 0f;
|
||||
m_rotationalVelocity.Z = dtmp.Z;
|
||||
|
@ -1532,9 +1646,31 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
{
|
||||
}
|
||||
|
||||
public override Vector3 PIDTarget { set { return; } }
|
||||
public override bool PIDActive {get {return m_pidControllerActive;} set { return; } }
|
||||
public override float PIDTau { set { return; } }
|
||||
public override Vector3 PIDTarget
|
||||
{
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
public override bool PIDActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_pidControllerActive;
|
||||
}
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
public override float PIDTau
|
||||
{
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override float PIDHoverHeight
|
||||
{
|
||||
|
@ -1580,13 +1716,37 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
}
|
||||
}
|
||||
|
||||
public override Quaternion APIDTarget { set { return; } }
|
||||
public override Quaternion APIDTarget
|
||||
{
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool APIDActive { set { return; } }
|
||||
public override bool APIDActive
|
||||
{
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override float APIDStrength { set { return; } }
|
||||
public override float APIDStrength
|
||||
{
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override float APIDDamping { set { return; } }
|
||||
public override float APIDDamping
|
||||
{
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SubscribeEvents(int ms)
|
||||
{
|
||||
|
@ -1728,7 +1888,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
private void changePosition(Vector3 newPos)
|
||||
{
|
||||
if(Body != IntPtr.Zero)
|
||||
d.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z);
|
||||
SafeNativeMethods.BodySetPosition(Body,newPos.X,newPos.Y,newPos.Z);
|
||||
_position = newPos;
|
||||
m_freemove = false;
|
||||
m_pidControllerActive = true;
|
||||
|
@ -1759,12 +1919,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
m_orientation2D.Y = 0f;
|
||||
m_orientation2D.X = 0f;
|
||||
|
||||
d.Quaternion myrot = new d.Quaternion();
|
||||
SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion();
|
||||
myrot.X = m_orientation2D.X;
|
||||
myrot.Y = m_orientation2D.Y;
|
||||
myrot.Z = m_orientation2D.Z;
|
||||
myrot.W = m_orientation2D.W;
|
||||
d.BodySetQuaternion(Body, ref myrot);
|
||||
SafeNativeMethods.BodySetQuaternion(Body,ref myrot);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1774,7 +1934,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
setFreeMove();
|
||||
|
||||
if(Body != IntPtr.Zero)
|
||||
d.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z);
|
||||
SafeNativeMethods.BodySetLinearVel(Body,newVel.X,newVel.Y,newVel.Z);
|
||||
}
|
||||
|
||||
private void changeTargetVelocity(Vector3 newVel)
|
||||
|
@ -1844,7 +2004,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if(Body != IntPtr.Zero)
|
||||
{
|
||||
if(newForce.X != 0f || newForce.Y != 0f || newForce.Z != 0)
|
||||
d.BodyAddForce(Body, newForce.X, newForce.Y, newForce.Z);
|
||||
SafeNativeMethods.BodyAddForce(Body,newForce.X,newForce.Y,newForce.Z);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1855,7 +2015,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
setFreeMove();
|
||||
|
||||
if(Body != IntPtr.Zero)
|
||||
d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z);
|
||||
SafeNativeMethods.BodySetLinearVel(Body,newmomentum.X,newmomentum.Y,newmomentum.Z);
|
||||
}
|
||||
|
||||
private void changePIDHoverHeight(float val)
|
||||
|
|
|
@ -41,13 +41,7 @@
|
|||
// Extensive change Ubit 2012
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OdeAPI;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.PhysicsModules.SharedBase;
|
||||
|
||||
namespace OpenSim.Region.PhysicsModule.ubOde
|
||||
|
@ -342,9 +336,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
m_amEfect = 1.0f ; // turn it on
|
||||
m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale;
|
||||
|
||||
if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
|
||||
if (rootPrim.Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(rootPrim.Body)
|
||||
&& !rootPrim.m_isSelected && !rootPrim.m_disabled)
|
||||
d.BodyEnable(rootPrim.Body);
|
||||
SafeNativeMethods.BodyEnable(rootPrim.Body);
|
||||
|
||||
break;
|
||||
case Vehicle.LINEAR_FRICTION_TIMESCALE:
|
||||
|
@ -361,9 +355,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
m_lmEfect = 1.0f; // turn it on
|
||||
|
||||
m_ffactor = 0.0f;
|
||||
if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
|
||||
if (rootPrim.Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(rootPrim.Body)
|
||||
&& !rootPrim.m_isSelected && !rootPrim.m_disabled)
|
||||
d.BodyEnable(rootPrim.Body);
|
||||
SafeNativeMethods.BodyEnable(rootPrim.Body);
|
||||
break;
|
||||
case Vehicle.LINEAR_MOTOR_OFFSET:
|
||||
m_linearMotorOffset = new Vector3(pValue, pValue, pValue);
|
||||
|
@ -399,9 +393,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
m_amEfect = 1.0f; // turn it on
|
||||
m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale;
|
||||
|
||||
if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
|
||||
if (rootPrim.Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(rootPrim.Body)
|
||||
&& !rootPrim.m_isSelected && !rootPrim.m_disabled)
|
||||
d.BodyEnable(rootPrim.Body);
|
||||
SafeNativeMethods.BodyEnable(rootPrim.Body);
|
||||
break;
|
||||
case Vehicle.LINEAR_FRICTION_TIMESCALE:
|
||||
if (pValue.X < m_timestep) pValue.X = m_timestep;
|
||||
|
@ -419,9 +413,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale;
|
||||
|
||||
m_ffactor = 0.0f;
|
||||
if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
|
||||
if (rootPrim.Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(rootPrim.Body)
|
||||
&& !rootPrim.m_isSelected && !rootPrim.m_disabled)
|
||||
d.BodyEnable(rootPrim.Body);
|
||||
SafeNativeMethods.BodyEnable(rootPrim.Body);
|
||||
break;
|
||||
case Vehicle.LINEAR_MOTOR_OFFSET:
|
||||
m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z);
|
||||
|
@ -772,30 +766,30 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
{
|
||||
IntPtr Body = rootPrim.Body;
|
||||
|
||||
d.Mass dmass;
|
||||
d.BodyGetMass(Body, out dmass);
|
||||
SafeNativeMethods.Mass dmass;
|
||||
SafeNativeMethods.BodyGetMass(Body, out dmass);
|
||||
|
||||
d.Quaternion rot = d.BodyGetQuaternion(Body);
|
||||
SafeNativeMethods.Quaternion rot = SafeNativeMethods.BodyGetQuaternion(Body);
|
||||
Quaternion objrotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
|
||||
Quaternion rotq = objrotq; // rotq = rotation of object
|
||||
rotq *= m_referenceFrame; // rotq is now rotation in vehicle reference frame
|
||||
Quaternion irotq = Quaternion.Inverse(rotq);
|
||||
|
||||
d.Vector3 dvtmp;
|
||||
SafeNativeMethods.Vector3 dvtmp;
|
||||
Vector3 tmpV;
|
||||
Vector3 curVel; // velocity in world
|
||||
Vector3 curAngVel; // angular velocity in world
|
||||
Vector3 force = Vector3.Zero; // actually linear aceleration until mult by mass in world frame
|
||||
Vector3 torque = Vector3.Zero;// actually angular aceleration until mult by Inertia in vehicle frame
|
||||
d.Vector3 dtorque = new d.Vector3();
|
||||
SafeNativeMethods.Vector3 dtorque = new SafeNativeMethods.Vector3();
|
||||
|
||||
dvtmp = d.BodyGetLinearVel(Body);
|
||||
dvtmp = SafeNativeMethods.BodyGetLinearVel(Body);
|
||||
curVel.X = dvtmp.X;
|
||||
curVel.Y = dvtmp.Y;
|
||||
curVel.Z = dvtmp.Z;
|
||||
Vector3 curLocalVel = curVel * irotq; // current velocity in local
|
||||
|
||||
dvtmp = d.BodyGetAngularVel(Body);
|
||||
dvtmp = SafeNativeMethods.BodyGetAngularVel(Body);
|
||||
curAngVel.X = dvtmp.X;
|
||||
curAngVel.Y = dvtmp.Y;
|
||||
curAngVel.Z = dvtmp.Z;
|
||||
|
@ -839,7 +833,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
{
|
||||
// have offset, do it now
|
||||
tmpV *= dmass.mass;
|
||||
d.BodyAddForceAtRelPos(Body, tmpV.X, tmpV.Y, tmpV.Z, m_linearMotorOffset.X, m_linearMotorOffset.Y, m_linearMotorOffset.Z);
|
||||
SafeNativeMethods.BodyAddForceAtRelPos(Body, tmpV.X, tmpV.Y, tmpV.Z, m_linearMotorOffset.X, m_linearMotorOffset.Y, m_linearMotorOffset.Z);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -862,7 +856,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if (m_VhoverTimescale < 300 && rootPrim.prim_geom != IntPtr.Zero)
|
||||
{
|
||||
// d.Vector3 pos = d.BodyGetPosition(Body);
|
||||
d.Vector3 pos = d.GeomGetPosition(rootPrim.prim_geom);
|
||||
SafeNativeMethods.Vector3 pos = SafeNativeMethods.GeomGetPosition(rootPrim.prim_geom);
|
||||
pos.Z -= 0.21f; // minor offset that seems to be always there in sl
|
||||
|
||||
float t = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y);
|
||||
|
@ -1181,7 +1175,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
if (force.X != 0 || force.Y != 0 || force.Z != 0)
|
||||
{
|
||||
d.BodyAddForce(Body, force.X, force.Y, force.Z);
|
||||
SafeNativeMethods.BodyAddForce(Body, force.X, force.Y, force.Z);
|
||||
}
|
||||
|
||||
if (torque.X != 0 || torque.Y != 0 || torque.Z != 0)
|
||||
|
@ -1191,15 +1185,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
dtorque.Y = torque.Y;
|
||||
dtorque.Z = torque.Z;
|
||||
|
||||
d.MultiplyM3V3(out dvtmp, ref dmass.I, ref dtorque);
|
||||
d.BodyAddRelTorque(Body, dvtmp.X, dvtmp.Y, dvtmp.Z); // add torque in object frame
|
||||
SafeNativeMethods.MultiplyM3V3(out dvtmp, ref dmass.I, ref dtorque);
|
||||
SafeNativeMethods.BodyAddRelTorque(Body, dvtmp.X, dvtmp.Y, dvtmp.Z); // add torque in object frame
|
||||
}
|
||||
|
||||
torque = rootPrim.m_torque;
|
||||
torque += rootPrim.m_angularForceacc;
|
||||
rootPrim.m_angularForceacc = Vector3.Zero;
|
||||
if (torque.X != 0 || torque.Y != 0 || torque.Z != 0)
|
||||
d.BodyAddTorque(Body,torque.X, torque.Y, torque.Z);
|
||||
SafeNativeMethods.BodyAddTorque(Body,torque.X, torque.Y, torque.Z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,14 +4,8 @@
|
|||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.PhysicsModules.SharedBase;
|
||||
using OdeAPI;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
|
|
|
@ -4,7 +4,6 @@ using System.Reflection;
|
|||
using log4net;
|
||||
using Nini.Config;
|
||||
using Mono.Addins;
|
||||
using OdeAPI;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
|
@ -53,9 +52,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if (Util.IsWindows())
|
||||
Util.LoadArchSpecificWindowsDll("ode.dll");
|
||||
|
||||
d.InitODE();
|
||||
SafeNativeMethods.InitODE();
|
||||
|
||||
string ode_config = d.GetConfiguration();
|
||||
string ode_config = SafeNativeMethods.GetConfiguration();
|
||||
if (ode_config != null && ode_config != "")
|
||||
{
|
||||
m_log.InfoFormat("[ubODE] ode library configuration: {0}", ode_config);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,10 +29,8 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.PhysicsModules.SharedBase;
|
||||
using OdeAPI;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
|
||||
|
@ -67,7 +65,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
/// <summary>
|
||||
/// ODE near callback delegate
|
||||
/// </summary>
|
||||
private d.NearCallback nearCallback;
|
||||
private SafeNativeMethods.NearCallback nearCallback;
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private List<ContactResult> m_contactResults = new List<ContactResult>();
|
||||
private RayFilterFlags CurrentRayFilter;
|
||||
|
@ -77,14 +75,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
{
|
||||
m_scene = pScene;
|
||||
nearCallback = near;
|
||||
ray = d.CreateRay(IntPtr.Zero, 1.0f);
|
||||
d.GeomSetCategoryBits(ray, 0);
|
||||
Box = d.CreateBox(IntPtr.Zero, 1.0f, 1.0f, 1.0f);
|
||||
d.GeomSetCategoryBits(Box, 0);
|
||||
Sphere = d.CreateSphere(IntPtr.Zero,1.0f);
|
||||
d.GeomSetCategoryBits(Sphere, 0);
|
||||
Plane = d.CreatePlane(IntPtr.Zero, 0f,0f,1f,1f);
|
||||
d.GeomSetCategoryBits(Sphere, 0);
|
||||
ray = SafeNativeMethods.CreateRay(IntPtr.Zero, 1.0f);
|
||||
SafeNativeMethods.GeomSetCategoryBits(ray, 0);
|
||||
Box = SafeNativeMethods.CreateBox(IntPtr.Zero, 1.0f, 1.0f, 1.0f);
|
||||
SafeNativeMethods.GeomSetCategoryBits(Box, 0);
|
||||
Sphere = SafeNativeMethods.CreateSphere(IntPtr.Zero,1.0f);
|
||||
SafeNativeMethods.GeomSetCategoryBits(Sphere, 0);
|
||||
Plane = SafeNativeMethods.CreatePlane(IntPtr.Zero, 0f,0f,1f,1f);
|
||||
SafeNativeMethods.GeomSetCategoryBits(Sphere, 0);
|
||||
}
|
||||
|
||||
public void QueueRequest(ODERayRequest req)
|
||||
|
@ -152,29 +150,29 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
{
|
||||
if (CollisionContactGeomsPerTest > 80)
|
||||
CollisionContactGeomsPerTest = 80;
|
||||
d.GeomBoxSetLengths(Box, req.Normal.X, req.Normal.Y, req.Normal.Z);
|
||||
d.GeomSetPosition(Box, req.Origin.X, req.Origin.Y, req.Origin.Z);
|
||||
d.Quaternion qtmp;
|
||||
SafeNativeMethods.GeomBoxSetLengths(Box, req.Normal.X, req.Normal.Y, req.Normal.Z);
|
||||
SafeNativeMethods.GeomSetPosition(Box, req.Origin.X, req.Origin.Y, req.Origin.Z);
|
||||
SafeNativeMethods.Quaternion qtmp;
|
||||
qtmp.X = req.orientation.X;
|
||||
qtmp.Y = req.orientation.Y;
|
||||
qtmp.Z = req.orientation.Z;
|
||||
qtmp.W = req.orientation.W;
|
||||
d.GeomSetQuaternion(Box, ref qtmp);
|
||||
SafeNativeMethods.GeomSetQuaternion(Box, ref qtmp);
|
||||
}
|
||||
else if (req.callbackMethod is ProbeSphereCallback)
|
||||
{
|
||||
if (CollisionContactGeomsPerTest > 80)
|
||||
CollisionContactGeomsPerTest = 80;
|
||||
|
||||
d.GeomSphereSetRadius(Sphere, req.length);
|
||||
d.GeomSetPosition(Sphere, req.Origin.X, req.Origin.Y, req.Origin.Z);
|
||||
SafeNativeMethods.GeomSphereSetRadius(Sphere, req.length);
|
||||
SafeNativeMethods.GeomSetPosition(Sphere, req.Origin.X, req.Origin.Y, req.Origin.Z);
|
||||
}
|
||||
else if (req.callbackMethod is ProbePlaneCallback)
|
||||
{
|
||||
if (CollisionContactGeomsPerTest > 80)
|
||||
CollisionContactGeomsPerTest = 80;
|
||||
|
||||
d.GeomPlaneSetParams(Plane, req.Normal.X, req.Normal.Y, req.Normal.Z, req.length);
|
||||
SafeNativeMethods.GeomPlaneSetParams(Plane, req.Normal.X, req.Normal.Y, req.Normal.Z, req.length);
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -182,24 +180,24 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if (CollisionContactGeomsPerTest > 25)
|
||||
CollisionContactGeomsPerTest = 25;
|
||||
|
||||
d.GeomRaySetLength(ray, req.length);
|
||||
d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z);
|
||||
d.GeomRaySetParams(ray, 0, backfacecull);
|
||||
SafeNativeMethods.GeomRaySetLength(ray, req.length);
|
||||
SafeNativeMethods.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z);
|
||||
SafeNativeMethods.GeomRaySetParams(ray, 0, backfacecull);
|
||||
|
||||
if (req.callbackMethod is RaycastCallback)
|
||||
{
|
||||
// if we only want one get only one per Collision pair saving memory
|
||||
CurrentRayFilter |= RayFilterFlags.ClosestHit;
|
||||
d.GeomRaySetClosestHit(ray, 1);
|
||||
SafeNativeMethods.GeomRaySetClosestHit(ray, 1);
|
||||
}
|
||||
else
|
||||
d.GeomRaySetClosestHit(ray, closestHit);
|
||||
SafeNativeMethods.GeomRaySetClosestHit(ray, closestHit);
|
||||
}
|
||||
|
||||
if ((CurrentRayFilter & RayFilterFlags.ContactsUnImportant) != 0)
|
||||
unchecked
|
||||
{
|
||||
CollisionContactGeomsPerTest |= (int)d.CONTACTS_UNIMPORTANT;
|
||||
CollisionContactGeomsPerTest |= (int)SafeNativeMethods.CONTACTS_UNIMPORTANT;
|
||||
}
|
||||
|
||||
if (geom == IntPtr.Zero)
|
||||
|
@ -224,27 +222,27 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if (req.callbackMethod is ProbeBoxCallback)
|
||||
{
|
||||
catflags |= CollisionCategories.Space;
|
||||
d.GeomSetCollideBits(Box, (uint)catflags);
|
||||
d.GeomSetCategoryBits(Box, (uint)catflags);
|
||||
SafeNativeMethods.GeomSetCollideBits(Box, (uint)catflags);
|
||||
SafeNativeMethods.GeomSetCategoryBits(Box, (uint)catflags);
|
||||
doProbe(req, Box);
|
||||
}
|
||||
else if (req.callbackMethod is ProbeSphereCallback)
|
||||
{
|
||||
catflags |= CollisionCategories.Space;
|
||||
d.GeomSetCollideBits(Sphere, (uint)catflags);
|
||||
d.GeomSetCategoryBits(Sphere, (uint)catflags);
|
||||
SafeNativeMethods.GeomSetCollideBits(Sphere, (uint)catflags);
|
||||
SafeNativeMethods.GeomSetCategoryBits(Sphere, (uint)catflags);
|
||||
doProbe(req, Sphere);
|
||||
}
|
||||
else if (req.callbackMethod is ProbePlaneCallback)
|
||||
{
|
||||
catflags |= CollisionCategories.Space;
|
||||
d.GeomSetCollideBits(Plane, (uint)catflags);
|
||||
d.GeomSetCategoryBits(Plane, (uint)catflags);
|
||||
SafeNativeMethods.GeomSetCollideBits(Plane, (uint)catflags);
|
||||
SafeNativeMethods.GeomSetCategoryBits(Plane, (uint)catflags);
|
||||
doPlane(req,IntPtr.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
d.GeomSetCollideBits(ray, (uint)catflags);
|
||||
SafeNativeMethods.GeomSetCollideBits(ray, (uint)catflags);
|
||||
doSpaceRay(req);
|
||||
}
|
||||
}
|
||||
|
@ -255,12 +253,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
if (req.callbackMethod is ProbePlaneCallback)
|
||||
{
|
||||
d.GeomSetCollideBits(Plane, (uint)CollisionCategories.All);
|
||||
SafeNativeMethods.GeomSetCollideBits(Plane, (uint)CollisionCategories.All);
|
||||
doPlane(req,geom);
|
||||
}
|
||||
else
|
||||
{
|
||||
d.GeomSetCollideBits(ray, (uint)CollisionCategories.All);
|
||||
SafeNativeMethods.GeomSetCollideBits(ray, (uint)CollisionCategories.All);
|
||||
doGeomRay(req,geom);
|
||||
}
|
||||
}
|
||||
|
@ -307,11 +305,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
// Collide tests
|
||||
if ((CurrentRayFilter & FilterActiveSpace) != 0)
|
||||
{
|
||||
d.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback);
|
||||
d.SpaceCollide2(ray, m_scene.CharsSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(ray, m_scene.CharsSpace, IntPtr.Zero, nearCallback);
|
||||
}
|
||||
if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount))
|
||||
d.SpaceCollide2(ray, m_scene.StaticSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(ray, m_scene.StaticSpace, IntPtr.Zero, nearCallback);
|
||||
if ((CurrentRayFilter & RayFilterFlags.land) != 0 && (m_contactResults.Count < CurrentMaxCount))
|
||||
{
|
||||
// current ode land to ray collisions is very bad
|
||||
|
@ -324,11 +322,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
{
|
||||
float tmp2 = req.length * req.length - tmp + 2500;
|
||||
tmp2 = (float)Math.Sqrt(tmp2);
|
||||
d.GeomRaySetLength(ray, tmp2);
|
||||
SafeNativeMethods.GeomRaySetLength(ray, tmp2);
|
||||
}
|
||||
|
||||
}
|
||||
d.SpaceCollide2(ray, m_scene.GroundSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(ray, m_scene.GroundSpace, IntPtr.Zero, nearCallback);
|
||||
}
|
||||
|
||||
if (req.callbackMethod is RaycastCallback)
|
||||
|
@ -377,13 +375,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
// Collide tests
|
||||
if ((CurrentRayFilter & FilterActiveSpace) != 0)
|
||||
{
|
||||
d.SpaceCollide2(probe, m_scene.ActiveSpace, IntPtr.Zero, nearCallback);
|
||||
d.SpaceCollide2(probe, m_scene.CharsSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(probe, m_scene.ActiveSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(probe, m_scene.CharsSpace, IntPtr.Zero, nearCallback);
|
||||
}
|
||||
if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount))
|
||||
d.SpaceCollide2(probe, m_scene.StaticSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(probe, m_scene.StaticSpace, IntPtr.Zero, nearCallback);
|
||||
if ((CurrentRayFilter & RayFilterFlags.land) != 0 && (m_contactResults.Count < CurrentMaxCount))
|
||||
d.SpaceCollide2(probe, m_scene.GroundSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(probe, m_scene.GroundSpace, IntPtr.Zero, nearCallback);
|
||||
|
||||
List<ContactResult> cresult = new List<ContactResult>(m_contactResults.Count);
|
||||
lock (m_PendingRequests)
|
||||
|
@ -404,17 +402,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
{
|
||||
if ((CurrentRayFilter & FilterActiveSpace) != 0)
|
||||
{
|
||||
d.SpaceCollide2(Plane, m_scene.ActiveSpace, IntPtr.Zero, nearCallback);
|
||||
d.SpaceCollide2(Plane, m_scene.CharsSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(Plane, m_scene.ActiveSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(Plane, m_scene.CharsSpace, IntPtr.Zero, nearCallback);
|
||||
}
|
||||
if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount))
|
||||
d.SpaceCollide2(Plane, m_scene.StaticSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(Plane, m_scene.StaticSpace, IntPtr.Zero, nearCallback);
|
||||
if ((CurrentRayFilter & RayFilterFlags.land) != 0 && (m_contactResults.Count < CurrentMaxCount))
|
||||
d.SpaceCollide2(Plane, m_scene.GroundSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(Plane, m_scene.GroundSpace, IntPtr.Zero, nearCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
d.SpaceCollide2(Plane, geom, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(Plane, geom, IntPtr.Zero, nearCallback);
|
||||
}
|
||||
|
||||
List<ContactResult> cresult = new List<ContactResult>(m_contactResults.Count);
|
||||
|
@ -434,7 +432,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
private void doGeomRay(ODERayRequest req, IntPtr geom)
|
||||
{
|
||||
// Collide test
|
||||
d.SpaceCollide2(ray, geom, IntPtr.Zero, nearCallback); // still do this to have full AABB pre test
|
||||
SafeNativeMethods.SpaceCollide2(ray, geom, IntPtr.Zero, nearCallback); // still do this to have full AABB pre test
|
||||
|
||||
if (req.callbackMethod is RaycastCallback)
|
||||
{
|
||||
|
@ -478,14 +476,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
}
|
||||
}
|
||||
|
||||
private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom)
|
||||
private bool GetCurContactGeom(int index, ref SafeNativeMethods.ContactGeom newcontactgeom)
|
||||
{
|
||||
IntPtr ContactgeomsArray = m_scene.ContactgeomsArray;
|
||||
if (ContactgeomsArray == IntPtr.Zero || index >= CollisionContactGeomsPerTest)
|
||||
return false;
|
||||
|
||||
IntPtr contactptr = new IntPtr(ContactgeomsArray.ToInt64() + (Int64)(index * d.ContactGeom.unmanagedSizeOf));
|
||||
newcontactgeom = (d.ContactGeom)Marshal.PtrToStructure(contactptr, typeof(d.ContactGeom));
|
||||
IntPtr contactptr = new IntPtr(ContactgeomsArray.ToInt64() + (Int64)(index * SafeNativeMethods.ContactGeom.unmanagedSizeOf));
|
||||
newcontactgeom = (SafeNativeMethods.ContactGeom)Marshal.PtrToStructure(contactptr, typeof(SafeNativeMethods.ContactGeom));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -498,11 +496,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if (m_contactResults.Count >= CurrentMaxCount)
|
||||
return;
|
||||
|
||||
if (d.GeomIsSpace(g2))
|
||||
if (SafeNativeMethods.GeomIsSpace(g2))
|
||||
{
|
||||
try
|
||||
{
|
||||
d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -514,7 +512,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
int count = 0;
|
||||
try
|
||||
{
|
||||
count = d.CollidePtr(g1, g2, CollisionContactGeomsPerTest, m_scene.ContactgeomsArray, d.ContactGeom.unmanagedSizeOf);
|
||||
count = SafeNativeMethods.CollidePtr(g1, g2, CollisionContactGeomsPerTest, m_scene.ContactgeomsArray, SafeNativeMethods.ContactGeom.unmanagedSizeOf);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -586,7 +584,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
break;
|
||||
}
|
||||
|
||||
d.ContactGeom curcontact = new d.ContactGeom();
|
||||
SafeNativeMethods.ContactGeom curcontact = new SafeNativeMethods.ContactGeom();
|
||||
|
||||
// closestHit for now only works for meshs, so must do it for others
|
||||
if ((CurrentRayFilter & RayFilterFlags.ClosestHit) == 0)
|
||||
|
@ -654,22 +652,22 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
m_scene = null;
|
||||
if (ray != IntPtr.Zero)
|
||||
{
|
||||
d.GeomDestroy(ray);
|
||||
SafeNativeMethods.GeomDestroy(ray);
|
||||
ray = IntPtr.Zero;
|
||||
}
|
||||
if (Box != IntPtr.Zero)
|
||||
{
|
||||
d.GeomDestroy(Box);
|
||||
SafeNativeMethods.GeomDestroy(Box);
|
||||
Box = IntPtr.Zero;
|
||||
}
|
||||
if (Sphere != IntPtr.Zero)
|
||||
{
|
||||
d.GeomDestroy(Sphere);
|
||||
SafeNativeMethods.GeomDestroy(Sphere);
|
||||
Sphere = IntPtr.Zero;
|
||||
}
|
||||
if (Plane != IntPtr.Zero)
|
||||
{
|
||||
d.GeomDestroy(Plane);
|
||||
SafeNativeMethods.GeomDestroy(Plane);
|
||||
Plane = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,15 +34,10 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using Mono.Addins;
|
||||
using OdeAPI;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.PhysicsModules.SharedBase;
|
||||
using OpenMetaverse;
|
||||
|
||||
|
@ -180,7 +175,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
// const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce;
|
||||
|
||||
// const d.ContactFlags comumContactFlags = d.ContactFlags.Bounce | d.ContactFlags.Approx1 | d.ContactFlags.Slip1 | d.ContactFlags.Slip2;
|
||||
const d.ContactFlags comumContactFlags = d.ContactFlags.Bounce | d.ContactFlags.Approx1;
|
||||
const SafeNativeMethods.ContactFlags comumContactFlags = SafeNativeMethods.ContactFlags.Bounce | SafeNativeMethods.ContactFlags.Approx1;
|
||||
const float comumContactERP = 0.75f;
|
||||
const float comumContactCFM = 0.0001f;
|
||||
const float comumContactSLIP = 0f;
|
||||
|
@ -228,7 +223,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
public int bodyFramesAutoDisable = 5;
|
||||
|
||||
private d.NearCallback nearCallback;
|
||||
private SafeNativeMethods.NearCallback nearCallback;
|
||||
|
||||
private Dictionary<uint,OdePrim> _prims = new Dictionary<uint,OdePrim>();
|
||||
private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
|
||||
|
@ -251,7 +246,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
private int contactsPerCollision = 80;
|
||||
internal IntPtr ContactgeomsArray = IntPtr.Zero;
|
||||
private IntPtr GlobalContactsArray = IntPtr.Zero;
|
||||
private d.Contact SharedTmpcontact = new d.Contact();
|
||||
private SafeNativeMethods.Contact SharedTmpcontact = new SafeNativeMethods.Contact();
|
||||
|
||||
const int maxContactsbeforedeath = 6000;
|
||||
private volatile int m_global_contactcount = 0;
|
||||
|
@ -356,7 +351,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
/// </summary>
|
||||
private void Initialization()
|
||||
{
|
||||
d.AllocateODEDataForThread(~0U);
|
||||
SafeNativeMethods.AllocateODEDataForThread(~0U);
|
||||
|
||||
SimulationLock = new Object();
|
||||
|
||||
|
@ -374,15 +369,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
// Create the world and the first space
|
||||
try
|
||||
{
|
||||
world = d.WorldCreate();
|
||||
TopSpace = d.SimpleSpaceCreate(IntPtr.Zero);
|
||||
ActiveSpace = d.SimpleSpaceCreate(TopSpace);
|
||||
CharsSpace = d.SimpleSpaceCreate(TopSpace);
|
||||
GroundSpace = d.SimpleSpaceCreate(TopSpace);
|
||||
world = SafeNativeMethods.WorldCreate();
|
||||
TopSpace = SafeNativeMethods.SimpleSpaceCreate(IntPtr.Zero);
|
||||
ActiveSpace = SafeNativeMethods.SimpleSpaceCreate(TopSpace);
|
||||
CharsSpace = SafeNativeMethods.SimpleSpaceCreate(TopSpace);
|
||||
GroundSpace = SafeNativeMethods.SimpleSpaceCreate(TopSpace);
|
||||
float sx = WorldExtents.X + 16;
|
||||
float sy = WorldExtents.Y + 16;
|
||||
d.Vector3 ex =new d.Vector3(sx, sy, 0);
|
||||
d.Vector3 px =new d.Vector3(sx * 0.5f, sx * 0.5f, 0);
|
||||
SafeNativeMethods.Vector3 ex =new SafeNativeMethods.Vector3(sx, sy, 0);
|
||||
SafeNativeMethods.Vector3 px =new SafeNativeMethods.Vector3(sx * 0.5f, sx * 0.5f, 0);
|
||||
if(sx < sy)
|
||||
sx = sy;
|
||||
sx = (float)Math.Log(sx) * 1.442695f + 0.5f;
|
||||
|
@ -391,7 +386,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
dp = 8;
|
||||
else if(dp < 4)
|
||||
dp = 4;
|
||||
StaticSpace = d.QuadTreeSpaceCreate(TopSpace, ref px, ref ex, dp);
|
||||
StaticSpace = SafeNativeMethods.QuadTreeSpaceCreate(TopSpace, ref px, ref ex, dp);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -400,47 +395,47 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
}
|
||||
|
||||
// demote to second level
|
||||
d.SpaceSetSublevel(ActiveSpace, 1);
|
||||
d.SpaceSetSublevel(CharsSpace, 1);
|
||||
d.SpaceSetSublevel(StaticSpace, 1);
|
||||
d.SpaceSetSublevel(GroundSpace, 1);
|
||||
SafeNativeMethods.SpaceSetSublevel(ActiveSpace, 1);
|
||||
SafeNativeMethods.SpaceSetSublevel(CharsSpace, 1);
|
||||
SafeNativeMethods.SpaceSetSublevel(StaticSpace, 1);
|
||||
SafeNativeMethods.SpaceSetSublevel(GroundSpace, 1);
|
||||
|
||||
d.GeomSetCategoryBits(ActiveSpace, (uint)(CollisionCategories.Space |
|
||||
SafeNativeMethods.GeomSetCategoryBits(ActiveSpace, (uint)(CollisionCategories.Space |
|
||||
CollisionCategories.Geom |
|
||||
CollisionCategories.Character |
|
||||
CollisionCategories.Phantom |
|
||||
CollisionCategories.VolumeDtc
|
||||
));
|
||||
d.GeomSetCollideBits(ActiveSpace, (uint)(CollisionCategories.Space |
|
||||
SafeNativeMethods.GeomSetCollideBits(ActiveSpace, (uint)(CollisionCategories.Space |
|
||||
CollisionCategories.Geom |
|
||||
CollisionCategories.Character |
|
||||
CollisionCategories.Phantom |
|
||||
CollisionCategories.VolumeDtc
|
||||
));
|
||||
d.GeomSetCategoryBits(CharsSpace, (uint)(CollisionCategories.Space |
|
||||
SafeNativeMethods.GeomSetCategoryBits(CharsSpace, (uint)(CollisionCategories.Space |
|
||||
CollisionCategories.Geom |
|
||||
CollisionCategories.Character |
|
||||
CollisionCategories.Phantom |
|
||||
CollisionCategories.VolumeDtc
|
||||
));
|
||||
d.GeomSetCollideBits(CharsSpace, 0);
|
||||
SafeNativeMethods.GeomSetCollideBits(CharsSpace, 0);
|
||||
|
||||
d.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space |
|
||||
SafeNativeMethods.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space |
|
||||
CollisionCategories.Geom |
|
||||
// CollisionCategories.Land |
|
||||
// CollisionCategories.Water |
|
||||
CollisionCategories.Phantom |
|
||||
CollisionCategories.VolumeDtc
|
||||
));
|
||||
d.GeomSetCollideBits(StaticSpace, 0);
|
||||
SafeNativeMethods.GeomSetCollideBits(StaticSpace, 0);
|
||||
|
||||
d.GeomSetCategoryBits(GroundSpace, (uint)(CollisionCategories.Land));
|
||||
d.GeomSetCollideBits(GroundSpace, 0);
|
||||
SafeNativeMethods.GeomSetCategoryBits(GroundSpace, (uint)(CollisionCategories.Land));
|
||||
SafeNativeMethods.GeomSetCollideBits(GroundSpace, 0);
|
||||
|
||||
contactgroup = d.JointGroupCreate(maxContactsbeforedeath + 1);
|
||||
contactgroup = SafeNativeMethods.JointGroupCreate(maxContactsbeforedeath + 1);
|
||||
//contactgroup
|
||||
|
||||
d.WorldSetAutoDisableFlag(world, false);
|
||||
SafeNativeMethods.WorldSetAutoDisableFlag(world, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -490,27 +485,27 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
maximumAngularVelocity = 0.49f * heartbeat *(float)Math.PI;
|
||||
maxAngVelocitySQ = maximumAngularVelocity * maximumAngularVelocity;
|
||||
|
||||
d.WorldSetCFM(world, comumContactCFM);
|
||||
d.WorldSetERP(world, comumContactERP);
|
||||
SafeNativeMethods.WorldSetCFM(world, comumContactCFM);
|
||||
SafeNativeMethods.WorldSetERP(world, comumContactERP);
|
||||
|
||||
d.WorldSetGravity(world, gravityx, gravityy, gravityz);
|
||||
SafeNativeMethods.WorldSetGravity(world, gravityx, gravityy, gravityz);
|
||||
|
||||
d.WorldSetLinearDamping(world, 0.001f);
|
||||
d.WorldSetAngularDamping(world, 0.002f);
|
||||
d.WorldSetAngularDampingThreshold(world, 0f);
|
||||
d.WorldSetLinearDampingThreshold(world, 0f);
|
||||
d.WorldSetMaxAngularSpeed(world, maximumAngularVelocity);
|
||||
SafeNativeMethods.WorldSetLinearDamping(world, 0.001f);
|
||||
SafeNativeMethods.WorldSetAngularDamping(world, 0.002f);
|
||||
SafeNativeMethods.WorldSetAngularDampingThreshold(world, 0f);
|
||||
SafeNativeMethods.WorldSetLinearDampingThreshold(world, 0f);
|
||||
SafeNativeMethods.WorldSetMaxAngularSpeed(world, maximumAngularVelocity);
|
||||
|
||||
d.WorldSetQuickStepNumIterations(world, m_physicsiterations);
|
||||
SafeNativeMethods.WorldSetQuickStepNumIterations(world, m_physicsiterations);
|
||||
|
||||
d.WorldSetContactSurfaceLayer(world, contactsurfacelayer);
|
||||
d.WorldSetContactMaxCorrectingVel(world, 60.0f);
|
||||
SafeNativeMethods.WorldSetContactSurfaceLayer(world, contactsurfacelayer);
|
||||
SafeNativeMethods.WorldSetContactMaxCorrectingVel(world, 60.0f);
|
||||
|
||||
HalfOdeStep = ODE_STEPSIZE * 0.5f;
|
||||
odetimestepMS = (int)(1000.0f * ODE_STEPSIZE + 0.5f);
|
||||
|
||||
ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf);
|
||||
GlobalContactsArray = Marshal.AllocHGlobal((maxContactsbeforedeath + 100) * d.Contact.unmanagedSizeOf);
|
||||
ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * SafeNativeMethods.ContactGeom.unmanagedSizeOf);
|
||||
GlobalContactsArray = Marshal.AllocHGlobal((maxContactsbeforedeath + 100) * SafeNativeMethods.Contact.unmanagedSizeOf);
|
||||
|
||||
SharedTmpcontact.geom.g1 = IntPtr.Zero;
|
||||
SharedTmpcontact.geom.g2 = IntPtr.Zero;
|
||||
|
@ -565,7 +560,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
#region Collision Detection
|
||||
|
||||
// sets a global contact for a joint for contactgeom , and base contact description)
|
||||
private IntPtr CreateContacJoint(ref d.ContactGeom contactGeom,bool smooth)
|
||||
private IntPtr CreateContacJoint(ref SafeNativeMethods.ContactGeom contactGeom,bool smooth)
|
||||
{
|
||||
if (m_global_contactcount >= maxContactsbeforedeath)
|
||||
return IntPtr.Zero;
|
||||
|
@ -578,18 +573,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
SharedTmpcontact.geom.pos = contactGeom.pos;
|
||||
SharedTmpcontact.geom.normal = contactGeom.normal;
|
||||
|
||||
IntPtr contact = new IntPtr(GlobalContactsArray.ToInt64() + (Int64)(m_global_contactcount * d.Contact.unmanagedSizeOf));
|
||||
IntPtr contact = new IntPtr(GlobalContactsArray.ToInt64() + (Int64)(m_global_contactcount * SafeNativeMethods.Contact.unmanagedSizeOf));
|
||||
Marshal.StructureToPtr(SharedTmpcontact, contact, true);
|
||||
return d.JointCreateContactPtr(world, contactgroup, contact);
|
||||
return SafeNativeMethods.JointCreateContactPtr(world, contactgroup, contact);
|
||||
}
|
||||
|
||||
private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom)
|
||||
private bool GetCurContactGeom(int index, ref SafeNativeMethods.ContactGeom newcontactgeom)
|
||||
{
|
||||
if (ContactgeomsArray == IntPtr.Zero || index >= contactsPerCollision)
|
||||
return false;
|
||||
|
||||
IntPtr contactptr = new IntPtr(ContactgeomsArray.ToInt64() + (Int64)(index * d.ContactGeom.unmanagedSizeOf));
|
||||
newcontactgeom = (d.ContactGeom)Marshal.PtrToStructure(contactptr, typeof(d.ContactGeom));
|
||||
IntPtr contactptr = new IntPtr(ContactgeomsArray.ToInt64() + (Int64)(index * SafeNativeMethods.ContactGeom.unmanagedSizeOf));
|
||||
newcontactgeom = (SafeNativeMethods.ContactGeom)Marshal.PtrToStructure(contactptr, typeof(SafeNativeMethods.ContactGeom));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -614,14 +609,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2))
|
||||
if (SafeNativeMethods.GeomIsSpace(g1) || SafeNativeMethods.GeomIsSpace(g2))
|
||||
{
|
||||
// We'll be calling near recursivly if one
|
||||
// of them is a space to find all of the
|
||||
// contact points in the space
|
||||
try
|
||||
{
|
||||
d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback);
|
||||
}
|
||||
catch (AccessViolationException)
|
||||
{
|
||||
|
@ -636,8 +631,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
// get geom bodies to check if we already a joint contact
|
||||
// guess this shouldn't happen now
|
||||
IntPtr b1 = d.GeomGetBody(g1);
|
||||
IntPtr b2 = d.GeomGetBody(g2);
|
||||
IntPtr b1 = SafeNativeMethods.GeomGetBody(g1);
|
||||
IntPtr b2 = SafeNativeMethods.GeomGetBody(g2);
|
||||
|
||||
// d.GeomClassID id = d.GeomGetClass(g1);
|
||||
|
||||
|
@ -679,18 +674,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
//
|
||||
*/
|
||||
|
||||
if (d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc ||
|
||||
d.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc)
|
||||
if (SafeNativeMethods.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc ||
|
||||
SafeNativeMethods.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc)
|
||||
{
|
||||
int cflags;
|
||||
unchecked
|
||||
{
|
||||
cflags = (int)(1 | d.CONTACTS_UNIMPORTANT);
|
||||
cflags = (int)(1 | SafeNativeMethods.CONTACTS_UNIMPORTANT);
|
||||
}
|
||||
count = d.CollidePtr(g1, g2, cflags, ContactgeomsArray, d.ContactGeom.unmanagedSizeOf);
|
||||
count = SafeNativeMethods.CollidePtr(g1, g2, cflags, ContactgeomsArray, SafeNativeMethods.ContactGeom.unmanagedSizeOf);
|
||||
}
|
||||
else
|
||||
count = d.CollidePtr(g1, g2, (contactsPerCollision & 0xffff), ContactgeomsArray, d.ContactGeom.unmanagedSizeOf);
|
||||
count = SafeNativeMethods.CollidePtr(g1, g2, (contactsPerCollision & 0xffff), ContactgeomsArray, SafeNativeMethods.ContactGeom.unmanagedSizeOf);
|
||||
}
|
||||
catch (SEHException)
|
||||
{
|
||||
|
@ -726,7 +721,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
|
||||
// get first contact
|
||||
d.ContactGeom curContact = new d.ContactGeom();
|
||||
SafeNativeMethods.ContactGeom curContact = new SafeNativeMethods.ContactGeom();
|
||||
|
||||
if (!GetCurContactGeom(0, ref curContact))
|
||||
return;
|
||||
|
@ -802,8 +797,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
// if (relVlenSQ > 0.01f)
|
||||
// mu *= frictionMovementMult;
|
||||
|
||||
if(d.GeomGetClass(g2) == d.GeomClassID.TriMeshClass &&
|
||||
d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
|
||||
if(SafeNativeMethods.GeomGetClass(g2) == SafeNativeMethods.GeomClassID.TriMeshClass &&
|
||||
SafeNativeMethods.GeomGetClass(g1) == SafeNativeMethods.GeomClassID.TriMeshClass)
|
||||
smoothMesh = true;
|
||||
break;
|
||||
|
||||
|
@ -817,7 +812,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
// mu *= frictionMovementMult;
|
||||
p1.CollidingGround = true;
|
||||
|
||||
if(d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
|
||||
if(SafeNativeMethods.GeomGetClass(g1) == SafeNativeMethods.GeomClassID.TriMeshClass)
|
||||
smoothMesh = true;
|
||||
break;
|
||||
|
||||
|
@ -843,7 +838,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
// if (Math.Abs(v2.X) > 0.1f || Math.Abs(v2.Y) > 0.1f)
|
||||
// mu *= frictionMovementMult;
|
||||
|
||||
if(d.GeomGetClass(g2) == d.GeomClassID.TriMeshClass)
|
||||
if(SafeNativeMethods.GeomGetClass(g2) == SafeNativeMethods.GeomClassID.TriMeshClass)
|
||||
smoothMesh = true;
|
||||
}
|
||||
else
|
||||
|
@ -873,7 +868,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
SharedTmpcontact.surface.mu = mu;
|
||||
SharedTmpcontact.surface.bounce = bounce;
|
||||
|
||||
d.ContactGeom altContact = new d.ContactGeom();
|
||||
SafeNativeMethods.ContactGeom altContact = new SafeNativeMethods.ContactGeom();
|
||||
bool useAltcontact;
|
||||
bool noskip;
|
||||
|
||||
|
@ -925,7 +920,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if (Joint == IntPtr.Zero)
|
||||
break;
|
||||
|
||||
d.JointAttach(Joint, b1, b2);
|
||||
SafeNativeMethods.JointAttach(Joint, b1, b2);
|
||||
|
||||
ncontacts++;
|
||||
|
||||
|
@ -1073,12 +1068,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
continue;
|
||||
|
||||
// do colisions with static space
|
||||
d.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, nearCallback);
|
||||
|
||||
// no coll with gnd
|
||||
}
|
||||
// chars with chars
|
||||
d.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback);
|
||||
|
||||
}
|
||||
catch (AccessViolationException)
|
||||
|
@ -1094,7 +1089,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
{
|
||||
aprim.CollisionScore = 0;
|
||||
aprim.IsColliding = false;
|
||||
if(!aprim.m_outbounds && d.BodyIsEnabled(aprim.Body))
|
||||
if(!aprim.m_outbounds && SafeNativeMethods.BodyIsEnabled(aprim.Body))
|
||||
aprim.clearSleeperCollisions();
|
||||
}
|
||||
}
|
||||
|
@ -1105,11 +1100,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
{
|
||||
foreach (OdePrim aprim in _activegroups)
|
||||
{
|
||||
if(!aprim.m_outbounds && d.BodyIsEnabled(aprim.Body) &&
|
||||
if(!aprim.m_outbounds && SafeNativeMethods.BodyIsEnabled(aprim.Body) &&
|
||||
aprim.collide_geom != IntPtr.Zero)
|
||||
{
|
||||
d.SpaceCollide2(StaticSpace, aprim.collide_geom, IntPtr.Zero, nearCallback);
|
||||
d.SpaceCollide2(GroundSpace, aprim.collide_geom, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(StaticSpace, aprim.collide_geom, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(GroundSpace, aprim.collide_geom, IntPtr.Zero, nearCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1122,7 +1117,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
// colide active amoung them
|
||||
try
|
||||
{
|
||||
d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -1132,7 +1127,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
// and with chars
|
||||
try
|
||||
{
|
||||
d.SpaceCollide2(CharsSpace,ActiveSpace, IntPtr.Zero, nearCallback);
|
||||
SafeNativeMethods.SpaceCollide2(CharsSpace,ActiveSpace, IntPtr.Zero, nearCallback);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -1232,7 +1227,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
lock (OdeLock)
|
||||
{
|
||||
d.AllocateODEDataForThread(0);
|
||||
SafeNativeMethods.AllocateODEDataForThread(0);
|
||||
((OdeCharacter) actor).Destroy();
|
||||
}
|
||||
}
|
||||
|
@ -1403,16 +1398,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
return StaticSpace;
|
||||
|
||||
// else remove it from its current space
|
||||
if (currentspace != IntPtr.Zero && d.SpaceQuery(currentspace, geom))
|
||||
if (currentspace != IntPtr.Zero && SafeNativeMethods.SpaceQuery(currentspace, geom))
|
||||
{
|
||||
if (d.GeomIsSpace(currentspace))
|
||||
if (SafeNativeMethods.GeomIsSpace(currentspace))
|
||||
{
|
||||
waitForSpaceUnlock(currentspace);
|
||||
d.SpaceRemove(currentspace, geom);
|
||||
SafeNativeMethods.SpaceRemove(currentspace, geom);
|
||||
|
||||
if (d.SpaceGetSublevel(currentspace) > 2 && d.SpaceGetNumGeoms(currentspace) == 0)
|
||||
if (SafeNativeMethods.SpaceGetSublevel(currentspace) > 2 && SafeNativeMethods.SpaceGetNumGeoms(currentspace) == 0)
|
||||
{
|
||||
d.SpaceDestroy(currentspace);
|
||||
SafeNativeMethods.SpaceDestroy(currentspace);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1421,19 +1416,19 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
" Geom:" + geom);
|
||||
}
|
||||
}
|
||||
else // odd currentspace is null or doesn't contain the geom? lets try the geom ideia of current space
|
||||
else
|
||||
{
|
||||
currentspace = d.GeomGetSpace(geom);
|
||||
currentspace = SafeNativeMethods.GeomGetSpace(geom);
|
||||
if (currentspace != IntPtr.Zero)
|
||||
{
|
||||
if (d.GeomIsSpace(currentspace))
|
||||
if (SafeNativeMethods.GeomIsSpace(currentspace))
|
||||
{
|
||||
waitForSpaceUnlock(currentspace);
|
||||
d.SpaceRemove(currentspace, geom);
|
||||
SafeNativeMethods.SpaceRemove(currentspace, geom);
|
||||
|
||||
if (d.SpaceGetSublevel(currentspace) > 2 && d.SpaceGetNumGeoms(currentspace) == 0)
|
||||
if (SafeNativeMethods.SpaceGetSublevel(currentspace) > 2 && SafeNativeMethods.SpaceGetNumGeoms(currentspace) == 0)
|
||||
{
|
||||
d.SpaceDestroy(currentspace);
|
||||
SafeNativeMethods.SpaceDestroy(currentspace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1441,12 +1436,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
// put the geom in the newspace
|
||||
waitForSpaceUnlock(StaticSpace);
|
||||
d.SpaceAdd(StaticSpace, geom);
|
||||
if(SafeNativeMethods.SpaceQuery(StaticSpace, geom))
|
||||
m_log.Info("[Physics]: 'MoveGeomToStaticSpace' geom already in static space:" + geom);
|
||||
else
|
||||
SafeNativeMethods.SpaceAdd(StaticSpace, geom);
|
||||
|
||||
return StaticSpace;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
@ -1485,7 +1481,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
return;
|
||||
}
|
||||
|
||||
d.AllocateODEDataForThread(~0U);
|
||||
SafeNativeMethods.AllocateODEDataForThread(~0U);
|
||||
|
||||
ODEchangeitem item;
|
||||
|
||||
|
@ -1585,7 +1581,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
double moveTime = 0;
|
||||
double rayTime = 0;
|
||||
*/
|
||||
d.AllocateODEDataForThread(~0U);
|
||||
SafeNativeMethods.AllocateODEDataForThread(~0U);
|
||||
|
||||
if (ChangesQueue.Count > 0)
|
||||
{
|
||||
|
@ -1689,7 +1685,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
pobj.SendCollisions((int)(odetimestepMS));
|
||||
if(pobj.Body != IntPtr.Zero && !pobj.m_isSelected &&
|
||||
!pobj.m_disabled && !pobj.m_building &&
|
||||
!d.BodyIsEnabled(pobj.Body))
|
||||
!SafeNativeMethods.BodyIsEnabled(pobj.Body))
|
||||
sleepers.Add(pobj);
|
||||
}
|
||||
break;
|
||||
|
@ -1704,8 +1700,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
// do a ode simulation step
|
||||
// tmpTime = Util.GetTimeStampMS();
|
||||
d.WorldQuickStep(world, ODE_STEPSIZE);
|
||||
d.JointGroupEmpty(contactgroup);
|
||||
SafeNativeMethods.WorldQuickStep(world, ODE_STEPSIZE);
|
||||
SafeNativeMethods.JointGroupEmpty(contactgroup);
|
||||
// qstepTIme += Util.GetTimeStampMS() - tmpTime;
|
||||
|
||||
// update managed ideia of physical data and do updates to core
|
||||
|
@ -1828,26 +1824,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// Finished with all sim stepping. If requested, dump world state to file for debugging.
|
||||
// TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed?
|
||||
// TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots?
|
||||
if (physics_logging && (physics_logging_interval > 0) && (framecount % physics_logging_interval == 0))
|
||||
{
|
||||
string fname = "state-" + world.ToString() + ".DIF"; // give each physics world a separate filename
|
||||
string prefix = "world" + world.ToString(); // prefix for variable names in exported .DIF file
|
||||
|
||||
if (physics_logging_append_existing_logfile)
|
||||
{
|
||||
string header = "-------------- START OF PHYSICS FRAME " + framecount.ToString() + " --------------";
|
||||
TextWriter fwriter = File.AppendText(fname);
|
||||
fwriter.WriteLine(header);
|
||||
fwriter.Close();
|
||||
}
|
||||
|
||||
d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix);
|
||||
}
|
||||
*/
|
||||
fps = (float)nodeframes * ODE_STEPSIZE / reqTimeStep;
|
||||
|
||||
if(step_time < HalfOdeStep)
|
||||
|
@ -2208,35 +2184,35 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
lock (OdeLock)
|
||||
{
|
||||
d.AllocateODEDataForThread(~0U);
|
||||
SafeNativeMethods.AllocateODEDataForThread(~0U);
|
||||
|
||||
if (TerrainGeom != IntPtr.Zero)
|
||||
{
|
||||
actor_name_map.Remove(TerrainGeom);
|
||||
d.GeomDestroy(TerrainGeom);
|
||||
SafeNativeMethods.GeomDestroy(TerrainGeom);
|
||||
|
||||
}
|
||||
|
||||
if (TerrainHeightFieldHeightsHandler.IsAllocated)
|
||||
TerrainHeightFieldHeightsHandler.Free();
|
||||
|
||||
IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
|
||||
IntPtr HeightmapData = SafeNativeMethods.GeomHeightfieldDataCreate();
|
||||
|
||||
TerrainHeightFieldHeightsHandler = GCHandle.Alloc(_heightmap, GCHandleType.Pinned);
|
||||
|
||||
d.GeomHeightfieldDataBuildSingle(HeightmapData, TerrainHeightFieldHeightsHandler.AddrOfPinnedObject(), 0,
|
||||
SafeNativeMethods.GeomHeightfieldDataBuildSingle(HeightmapData, TerrainHeightFieldHeightsHandler.AddrOfPinnedObject(), 0,
|
||||
heightmapHeight, heightmapWidth ,
|
||||
(int)heightmapHeightSamples, (int)heightmapWidthSamples, scale,
|
||||
offset, thickness, wrap);
|
||||
|
||||
d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1);
|
||||
SafeNativeMethods.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1);
|
||||
|
||||
TerrainGeom = d.CreateHeightfield(GroundSpace, HeightmapData, 1);
|
||||
TerrainGeom = SafeNativeMethods.CreateHeightfield(GroundSpace, HeightmapData, 1);
|
||||
|
||||
if (TerrainGeom != IntPtr.Zero)
|
||||
{
|
||||
d.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land));
|
||||
d.GeomSetCollideBits(TerrainGeom, 0);
|
||||
SafeNativeMethods.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land));
|
||||
SafeNativeMethods.GeomSetCollideBits(TerrainGeom, 0);
|
||||
|
||||
PhysicsActor pa = new NullPhysicsActor();
|
||||
pa.Name = "Terrain";
|
||||
|
@ -2245,14 +2221,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
// geom_name_map[GroundGeom] = "Terrain";
|
||||
|
||||
d.Quaternion q = new d.Quaternion();
|
||||
SafeNativeMethods.Quaternion q = new SafeNativeMethods.Quaternion();
|
||||
q.X = 0.5f;
|
||||
q.Y = 0.5f;
|
||||
q.Z = 0.5f;
|
||||
q.W = 0.5f;
|
||||
|
||||
d.GeomSetQuaternion(TerrainGeom, ref q);
|
||||
d.GeomSetPosition(TerrainGeom, m_regionWidth * 0.5f, m_regionHeight * 0.5f, 0.0f);
|
||||
SafeNativeMethods.GeomSetQuaternion(TerrainGeom, ref q);
|
||||
SafeNativeMethods.GeomSetPosition(TerrainGeom, m_regionWidth * 0.5f, m_regionHeight * 0.5f, 0.0f);
|
||||
TerrainHeightFieldHeight = _heightmap;
|
||||
}
|
||||
else
|
||||
|
@ -2320,7 +2296,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if (TerrainGeom != IntPtr.Zero)
|
||||
{
|
||||
actor_name_map.Remove(TerrainGeom);
|
||||
d.GeomDestroy(TerrainGeom);
|
||||
SafeNativeMethods.GeomDestroy(TerrainGeom);
|
||||
}
|
||||
|
||||
if (TerrainHeightFieldHeightsHandler.IsAllocated)
|
||||
|
@ -2328,7 +2304,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
TerrainHeightFieldHeight = null;
|
||||
|
||||
IntPtr HeightmapData = d.GeomOSTerrainDataCreate();
|
||||
IntPtr HeightmapData = SafeNativeMethods.GeomOSTerrainDataCreate();
|
||||
|
||||
const int wrap = 0;
|
||||
float thickness = hfmin;
|
||||
|
@ -2337,16 +2313,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
TerrainHeightFieldHeightsHandler = GCHandle.Alloc(_heightmap, GCHandleType.Pinned);
|
||||
|
||||
d.GeomOSTerrainDataBuild(HeightmapData, TerrainHeightFieldHeightsHandler.AddrOfPinnedObject(), 0, 1.0f,
|
||||
SafeNativeMethods.GeomOSTerrainDataBuild(HeightmapData, TerrainHeightFieldHeightsHandler.AddrOfPinnedObject(), 0, 1.0f,
|
||||
(int)heightmapWidthSamples, (int)heightmapHeightSamples,
|
||||
thickness, wrap);
|
||||
|
||||
// d.GeomOSTerrainDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1);
|
||||
TerrainGeom = d.CreateOSTerrain(GroundSpace, HeightmapData, 1);
|
||||
TerrainGeom = SafeNativeMethods.CreateOSTerrain(GroundSpace, HeightmapData, 1);
|
||||
if (TerrainGeom != IntPtr.Zero)
|
||||
{
|
||||
d.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land));
|
||||
d.GeomSetCollideBits(TerrainGeom, 0);
|
||||
SafeNativeMethods.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land));
|
||||
SafeNativeMethods.GeomSetCollideBits(TerrainGeom, 0);
|
||||
|
||||
PhysicsActor pa = new NullPhysicsActor();
|
||||
pa.Name = "Terrain";
|
||||
|
@ -2355,7 +2331,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
// geom_name_map[GroundGeom] = "Terrain";
|
||||
|
||||
d.GeomSetPosition(TerrainGeom, m_regionWidth * 0.5f, m_regionHeight * 0.5f, 0.0f);
|
||||
SafeNativeMethods.GeomSetPosition(TerrainGeom, m_regionWidth * 0.5f, m_regionHeight * 0.5f, 0.0f);
|
||||
TerrainHeightFieldHeight = _heightmap;
|
||||
}
|
||||
else
|
||||
|
@ -2385,7 +2361,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
if (world == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
d.AllocateODEDataForThread(~0U);
|
||||
SafeNativeMethods.AllocateODEDataForThread(~0U);
|
||||
|
||||
if (m_meshWorker != null)
|
||||
m_meshWorker.Stop();
|
||||
|
@ -2419,7 +2395,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
ch.DoAChange(changes.Remove, null);
|
||||
|
||||
if (TerrainGeom != IntPtr.Zero)
|
||||
d.GeomDestroy(TerrainGeom);
|
||||
SafeNativeMethods.GeomDestroy(TerrainGeom);
|
||||
TerrainGeom = IntPtr.Zero;
|
||||
|
||||
if (TerrainHeightFieldHeightsHandler.IsAllocated)
|
||||
|
@ -2438,7 +2414,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
GlobalContactsArray = IntPtr.Zero;
|
||||
}
|
||||
|
||||
d.WorldDestroy(world);
|
||||
SafeNativeMethods.WorldDestroy(world);
|
||||
world = IntPtr.Zero;
|
||||
//d.CloseODE();
|
||||
}
|
||||
|
|
|
@ -27,13 +27,7 @@
|
|||
// Ubit Umarov 2012
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.PhysicsModules.SharedBase;
|
||||
using OdeAPI;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.PhysicsModule.ubOde
|
||||
|
@ -78,8 +72,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
IntPtr geom = ((OdePrim)actor).prim_geom;
|
||||
|
||||
Vector3 geopos = d.GeomGetPositionOMV(geom);
|
||||
Quaternion geomOri = d.GeomGetQuaternionOMV(geom);
|
||||
Vector3 geopos = SafeNativeMethods.GeomGetPositionOMV(geom);
|
||||
Quaternion geomOri = SafeNativeMethods.GeomGetQuaternionOMV(geom);
|
||||
|
||||
// Vector3 geopos = actor.Position;
|
||||
// Quaternion geomOri = actor.Orientation;
|
||||
|
@ -123,11 +117,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
|||
|
||||
offset = rayResults[0].Pos - geopos;
|
||||
|
||||
d.GeomClassID geoclass = d.GeomGetClass(geom);
|
||||
SafeNativeMethods.GeomClassID geoclass = SafeNativeMethods.GeomGetClass(geom);
|
||||
|
||||
if (geoclass == d.GeomClassID.SphereClass)
|
||||
if (geoclass == SafeNativeMethods.GeomClassID.SphereClass)
|
||||
{
|
||||
float r = d.GeomSphereGetRadius(geom);
|
||||
float r = SafeNativeMethods.GeomSphereGetRadius(geom);
|
||||
|
||||
offset.Normalize();
|
||||
offset *= r;
|
||||
|
|
Loading…
Reference in New Issue