make ubOde PInvoke follow ms coding rules

httptests
UbitUmarov 2018-01-14 01:02:21 +00:00
parent 8a68c330e8
commit 88511bfab2
9 changed files with 1670 additions and 1553 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -41,13 +41,7 @@
// Extensive change Ubit 2012 // Extensive change Ubit 2012
using System; using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using log4net;
using OpenMetaverse; using OpenMetaverse;
using OdeAPI;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
namespace OpenSim.Region.PhysicsModule.ubOde namespace OpenSim.Region.PhysicsModule.ubOde
@ -342,9 +336,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
m_amEfect = 1.0f ; // turn it on m_amEfect = 1.0f ; // turn it on
m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; 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) && !rootPrim.m_isSelected && !rootPrim.m_disabled)
d.BodyEnable(rootPrim.Body); SafeNativeMethods.BodyEnable(rootPrim.Body);
break; break;
case Vehicle.LINEAR_FRICTION_TIMESCALE: case Vehicle.LINEAR_FRICTION_TIMESCALE:
@ -361,9 +355,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
m_lmEfect = 1.0f; // turn it on m_lmEfect = 1.0f; // turn it on
m_ffactor = 0.0f; 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) && !rootPrim.m_isSelected && !rootPrim.m_disabled)
d.BodyEnable(rootPrim.Body); SafeNativeMethods.BodyEnable(rootPrim.Body);
break; break;
case Vehicle.LINEAR_MOTOR_OFFSET: case Vehicle.LINEAR_MOTOR_OFFSET:
m_linearMotorOffset = new Vector3(pValue, pValue, pValue); m_linearMotorOffset = new Vector3(pValue, pValue, pValue);
@ -399,9 +393,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
m_amEfect = 1.0f; // turn it on m_amEfect = 1.0f; // turn it on
m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; 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) && !rootPrim.m_isSelected && !rootPrim.m_disabled)
d.BodyEnable(rootPrim.Body); SafeNativeMethods.BodyEnable(rootPrim.Body);
break; break;
case Vehicle.LINEAR_FRICTION_TIMESCALE: case Vehicle.LINEAR_FRICTION_TIMESCALE:
if (pValue.X < m_timestep) pValue.X = m_timestep; 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_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale;
m_ffactor = 0.0f; 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) && !rootPrim.m_isSelected && !rootPrim.m_disabled)
d.BodyEnable(rootPrim.Body); SafeNativeMethods.BodyEnable(rootPrim.Body);
break; break;
case Vehicle.LINEAR_MOTOR_OFFSET: case Vehicle.LINEAR_MOTOR_OFFSET:
m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z);
@ -772,30 +766,30 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
IntPtr Body = rootPrim.Body; IntPtr Body = rootPrim.Body;
d.Mass dmass; SafeNativeMethods.Mass dmass;
d.BodyGetMass(Body, out 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 objrotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
Quaternion rotq = objrotq; // rotq = rotation of object Quaternion rotq = objrotq; // rotq = rotation of object
rotq *= m_referenceFrame; // rotq is now rotation in vehicle reference frame rotq *= m_referenceFrame; // rotq is now rotation in vehicle reference frame
Quaternion irotq = Quaternion.Inverse(rotq); Quaternion irotq = Quaternion.Inverse(rotq);
d.Vector3 dvtmp; SafeNativeMethods.Vector3 dvtmp;
Vector3 tmpV; Vector3 tmpV;
Vector3 curVel; // velocity in world Vector3 curVel; // velocity in world
Vector3 curAngVel; // angular velocity in world Vector3 curAngVel; // angular velocity in world
Vector3 force = Vector3.Zero; // actually linear aceleration until mult by mass in world frame 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 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.X = dvtmp.X;
curVel.Y = dvtmp.Y; curVel.Y = dvtmp.Y;
curVel.Z = dvtmp.Z; curVel.Z = dvtmp.Z;
Vector3 curLocalVel = curVel * irotq; // current velocity in local Vector3 curLocalVel = curVel * irotq; // current velocity in local
dvtmp = d.BodyGetAngularVel(Body); dvtmp = SafeNativeMethods.BodyGetAngularVel(Body);
curAngVel.X = dvtmp.X; curAngVel.X = dvtmp.X;
curAngVel.Y = dvtmp.Y; curAngVel.Y = dvtmp.Y;
curAngVel.Z = dvtmp.Z; curAngVel.Z = dvtmp.Z;
@ -839,7 +833,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
// have offset, do it now // have offset, do it now
tmpV *= dmass.mass; 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 else
{ {
@ -862,7 +856,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (m_VhoverTimescale < 300 && rootPrim.prim_geom != IntPtr.Zero) if (m_VhoverTimescale < 300 && rootPrim.prim_geom != IntPtr.Zero)
{ {
// d.Vector3 pos = d.BodyGetPosition(Body); // 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 pos.Z -= 0.21f; // minor offset that seems to be always there in sl
float t = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y); 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) 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) if (torque.X != 0 || torque.Y != 0 || torque.Z != 0)
@ -1191,15 +1185,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde
dtorque.Y = torque.Y; dtorque.Y = torque.Y;
dtorque.Z = torque.Z; dtorque.Z = torque.Z;
d.MultiplyM3V3(out dvtmp, ref dmass.I, ref dtorque); SafeNativeMethods.MultiplyM3V3(out dvtmp, ref dmass.I, ref dtorque);
d.BodyAddRelTorque(Body, dvtmp.X, dvtmp.Y, dvtmp.Z); // add torque in object frame SafeNativeMethods.BodyAddRelTorque(Body, dvtmp.X, dvtmp.Y, dvtmp.Z); // add torque in object frame
} }
torque = rootPrim.m_torque; torque = rootPrim.m_torque;
torque += rootPrim.m_angularForceacc; torque += rootPrim.m_angularForceacc;
rootPrim.m_angularForceacc = Vector3.Zero; rootPrim.m_angularForceacc = Vector3.Zero;
if (torque.X != 0 || torque.Y != 0 || torque.Z != 0) 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);
} }
} }
} }

View File

@ -4,14 +4,8 @@
using System; using System;
using System.Threading; 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.Framework;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using OdeAPI;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using OpenMetaverse; using OpenMetaverse;

View File

@ -4,7 +4,6 @@ using System.Reflection;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using Mono.Addins; using Mono.Addins;
using OdeAPI;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
@ -53,9 +52,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (Util.IsWindows()) if (Util.IsWindows())
Util.LoadArchSpecificWindowsDll("ode.dll"); Util.LoadArchSpecificWindowsDll("ode.dll");
d.InitODE(); SafeNativeMethods.InitODE();
string ode_config = d.GetConfiguration(); string ode_config = SafeNativeMethods.GetConfiguration();
if (ode_config != null && ode_config != "") if (ode_config != null && ode_config != "")
{ {
m_log.InfoFormat("[ubODE] ode library configuration: {0}", ode_config); m_log.InfoFormat("[ubODE] ode library configuration: {0}", ode_config);

File diff suppressed because it is too large Load Diff

View File

@ -29,10 +29,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using OdeAPI;
using log4net; using log4net;
using OpenMetaverse; using OpenMetaverse;
@ -67,7 +65,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
/// <summary> /// <summary>
/// ODE near callback delegate /// ODE near callback delegate
/// </summary> /// </summary>
private d.NearCallback nearCallback; private SafeNativeMethods.NearCallback nearCallback;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private List<ContactResult> m_contactResults = new List<ContactResult>(); private List<ContactResult> m_contactResults = new List<ContactResult>();
private RayFilterFlags CurrentRayFilter; private RayFilterFlags CurrentRayFilter;
@ -77,14 +75,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
m_scene = pScene; m_scene = pScene;
nearCallback = near; nearCallback = near;
ray = d.CreateRay(IntPtr.Zero, 1.0f); ray = SafeNativeMethods.CreateRay(IntPtr.Zero, 1.0f);
d.GeomSetCategoryBits(ray, 0); SafeNativeMethods.GeomSetCategoryBits(ray, 0);
Box = d.CreateBox(IntPtr.Zero, 1.0f, 1.0f, 1.0f); Box = SafeNativeMethods.CreateBox(IntPtr.Zero, 1.0f, 1.0f, 1.0f);
d.GeomSetCategoryBits(Box, 0); SafeNativeMethods.GeomSetCategoryBits(Box, 0);
Sphere = d.CreateSphere(IntPtr.Zero,1.0f); Sphere = SafeNativeMethods.CreateSphere(IntPtr.Zero,1.0f);
d.GeomSetCategoryBits(Sphere, 0); SafeNativeMethods.GeomSetCategoryBits(Sphere, 0);
Plane = d.CreatePlane(IntPtr.Zero, 0f,0f,1f,1f); Plane = SafeNativeMethods.CreatePlane(IntPtr.Zero, 0f,0f,1f,1f);
d.GeomSetCategoryBits(Sphere, 0); SafeNativeMethods.GeomSetCategoryBits(Sphere, 0);
} }
public void QueueRequest(ODERayRequest req) public void QueueRequest(ODERayRequest req)
@ -152,29 +150,29 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
if (CollisionContactGeomsPerTest > 80) if (CollisionContactGeomsPerTest > 80)
CollisionContactGeomsPerTest = 80; CollisionContactGeomsPerTest = 80;
d.GeomBoxSetLengths(Box, req.Normal.X, req.Normal.Y, req.Normal.Z); SafeNativeMethods.GeomBoxSetLengths(Box, req.Normal.X, req.Normal.Y, req.Normal.Z);
d.GeomSetPosition(Box, req.Origin.X, req.Origin.Y, req.Origin.Z); SafeNativeMethods.GeomSetPosition(Box, req.Origin.X, req.Origin.Y, req.Origin.Z);
d.Quaternion qtmp; SafeNativeMethods.Quaternion qtmp;
qtmp.X = req.orientation.X; qtmp.X = req.orientation.X;
qtmp.Y = req.orientation.Y; qtmp.Y = req.orientation.Y;
qtmp.Z = req.orientation.Z; qtmp.Z = req.orientation.Z;
qtmp.W = req.orientation.W; qtmp.W = req.orientation.W;
d.GeomSetQuaternion(Box, ref qtmp); SafeNativeMethods.GeomSetQuaternion(Box, ref qtmp);
} }
else if (req.callbackMethod is ProbeSphereCallback) else if (req.callbackMethod is ProbeSphereCallback)
{ {
if (CollisionContactGeomsPerTest > 80) if (CollisionContactGeomsPerTest > 80)
CollisionContactGeomsPerTest = 80; CollisionContactGeomsPerTest = 80;
d.GeomSphereSetRadius(Sphere, req.length); SafeNativeMethods.GeomSphereSetRadius(Sphere, req.length);
d.GeomSetPosition(Sphere, req.Origin.X, req.Origin.Y, req.Origin.Z); SafeNativeMethods.GeomSetPosition(Sphere, req.Origin.X, req.Origin.Y, req.Origin.Z);
} }
else if (req.callbackMethod is ProbePlaneCallback) else if (req.callbackMethod is ProbePlaneCallback)
{ {
if (CollisionContactGeomsPerTest > 80) if (CollisionContactGeomsPerTest > 80)
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 else
@ -182,24 +180,24 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (CollisionContactGeomsPerTest > 25) if (CollisionContactGeomsPerTest > 25)
CollisionContactGeomsPerTest = 25; CollisionContactGeomsPerTest = 25;
d.GeomRaySetLength(ray, req.length); SafeNativeMethods.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); SafeNativeMethods.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.GeomRaySetParams(ray, 0, backfacecull);
if (req.callbackMethod is RaycastCallback) if (req.callbackMethod is RaycastCallback)
{ {
// if we only want one get only one per Collision pair saving memory // if we only want one get only one per Collision pair saving memory
CurrentRayFilter |= RayFilterFlags.ClosestHit; CurrentRayFilter |= RayFilterFlags.ClosestHit;
d.GeomRaySetClosestHit(ray, 1); SafeNativeMethods.GeomRaySetClosestHit(ray, 1);
} }
else else
d.GeomRaySetClosestHit(ray, closestHit); SafeNativeMethods.GeomRaySetClosestHit(ray, closestHit);
} }
if ((CurrentRayFilter & RayFilterFlags.ContactsUnImportant) != 0) if ((CurrentRayFilter & RayFilterFlags.ContactsUnImportant) != 0)
unchecked unchecked
{ {
CollisionContactGeomsPerTest |= (int)d.CONTACTS_UNIMPORTANT; CollisionContactGeomsPerTest |= (int)SafeNativeMethods.CONTACTS_UNIMPORTANT;
} }
if (geom == IntPtr.Zero) if (geom == IntPtr.Zero)
@ -224,27 +222,27 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (req.callbackMethod is ProbeBoxCallback) if (req.callbackMethod is ProbeBoxCallback)
{ {
catflags |= CollisionCategories.Space; catflags |= CollisionCategories.Space;
d.GeomSetCollideBits(Box, (uint)catflags); SafeNativeMethods.GeomSetCollideBits(Box, (uint)catflags);
d.GeomSetCategoryBits(Box, (uint)catflags); SafeNativeMethods.GeomSetCategoryBits(Box, (uint)catflags);
doProbe(req, Box); doProbe(req, Box);
} }
else if (req.callbackMethod is ProbeSphereCallback) else if (req.callbackMethod is ProbeSphereCallback)
{ {
catflags |= CollisionCategories.Space; catflags |= CollisionCategories.Space;
d.GeomSetCollideBits(Sphere, (uint)catflags); SafeNativeMethods.GeomSetCollideBits(Sphere, (uint)catflags);
d.GeomSetCategoryBits(Sphere, (uint)catflags); SafeNativeMethods.GeomSetCategoryBits(Sphere, (uint)catflags);
doProbe(req, Sphere); doProbe(req, Sphere);
} }
else if (req.callbackMethod is ProbePlaneCallback) else if (req.callbackMethod is ProbePlaneCallback)
{ {
catflags |= CollisionCategories.Space; catflags |= CollisionCategories.Space;
d.GeomSetCollideBits(Plane, (uint)catflags); SafeNativeMethods.GeomSetCollideBits(Plane, (uint)catflags);
d.GeomSetCategoryBits(Plane, (uint)catflags); SafeNativeMethods.GeomSetCategoryBits(Plane, (uint)catflags);
doPlane(req,IntPtr.Zero); doPlane(req,IntPtr.Zero);
} }
else else
{ {
d.GeomSetCollideBits(ray, (uint)catflags); SafeNativeMethods.GeomSetCollideBits(ray, (uint)catflags);
doSpaceRay(req); doSpaceRay(req);
} }
} }
@ -255,12 +253,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (req.callbackMethod is ProbePlaneCallback) if (req.callbackMethod is ProbePlaneCallback)
{ {
d.GeomSetCollideBits(Plane, (uint)CollisionCategories.All); SafeNativeMethods.GeomSetCollideBits(Plane, (uint)CollisionCategories.All);
doPlane(req,geom); doPlane(req,geom);
} }
else else
{ {
d.GeomSetCollideBits(ray, (uint)CollisionCategories.All); SafeNativeMethods.GeomSetCollideBits(ray, (uint)CollisionCategories.All);
doGeomRay(req,geom); doGeomRay(req,geom);
} }
} }
@ -307,11 +305,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// Collide tests // Collide tests
if ((CurrentRayFilter & FilterActiveSpace) != 0) if ((CurrentRayFilter & FilterActiveSpace) != 0)
{ {
d.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback);
d.SpaceCollide2(ray, m_scene.CharsSpace, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide2(ray, m_scene.CharsSpace, IntPtr.Zero, nearCallback);
} }
if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount)) 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)) if ((CurrentRayFilter & RayFilterFlags.land) != 0 && (m_contactResults.Count < CurrentMaxCount))
{ {
// current ode land to ray collisions is very bad // 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; float tmp2 = req.length * req.length - tmp + 2500;
tmp2 = (float)Math.Sqrt(tmp2); 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) if (req.callbackMethod is RaycastCallback)
@ -377,13 +375,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// Collide tests // Collide tests
if ((CurrentRayFilter & FilterActiveSpace) != 0) if ((CurrentRayFilter & FilterActiveSpace) != 0)
{ {
d.SpaceCollide2(probe, m_scene.ActiveSpace, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide2(probe, m_scene.ActiveSpace, IntPtr.Zero, nearCallback);
d.SpaceCollide2(probe, m_scene.CharsSpace, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide2(probe, m_scene.CharsSpace, IntPtr.Zero, nearCallback);
} }
if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount)) 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)) 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); List<ContactResult> cresult = new List<ContactResult>(m_contactResults.Count);
lock (m_PendingRequests) lock (m_PendingRequests)
@ -404,17 +402,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
if ((CurrentRayFilter & FilterActiveSpace) != 0) if ((CurrentRayFilter & FilterActiveSpace) != 0)
{ {
d.SpaceCollide2(Plane, m_scene.ActiveSpace, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide2(Plane, m_scene.ActiveSpace, IntPtr.Zero, nearCallback);
d.SpaceCollide2(Plane, m_scene.CharsSpace, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide2(Plane, m_scene.CharsSpace, IntPtr.Zero, nearCallback);
} }
if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount)) 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)) 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 else
{ {
d.SpaceCollide2(Plane, geom, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide2(Plane, geom, IntPtr.Zero, nearCallback);
} }
List<ContactResult> cresult = new List<ContactResult>(m_contactResults.Count); 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) private void doGeomRay(ODERayRequest req, IntPtr geom)
{ {
// Collide test // 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) 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; IntPtr ContactgeomsArray = m_scene.ContactgeomsArray;
if (ContactgeomsArray == IntPtr.Zero || index >= CollisionContactGeomsPerTest) if (ContactgeomsArray == IntPtr.Zero || index >= CollisionContactGeomsPerTest)
return false; return false;
IntPtr contactptr = new IntPtr(ContactgeomsArray.ToInt64() + (Int64)(index * d.ContactGeom.unmanagedSizeOf)); IntPtr contactptr = new IntPtr(ContactgeomsArray.ToInt64() + (Int64)(index * SafeNativeMethods.ContactGeom.unmanagedSizeOf));
newcontactgeom = (d.ContactGeom)Marshal.PtrToStructure(contactptr, typeof(d.ContactGeom)); newcontactgeom = (SafeNativeMethods.ContactGeom)Marshal.PtrToStructure(contactptr, typeof(SafeNativeMethods.ContactGeom));
return true; return true;
} }
@ -498,11 +496,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (m_contactResults.Count >= CurrentMaxCount) if (m_contactResults.Count >= CurrentMaxCount)
return; return;
if (d.GeomIsSpace(g2)) if (SafeNativeMethods.GeomIsSpace(g2))
{ {
try try
{ {
d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback);
} }
catch (Exception e) catch (Exception e)
{ {
@ -514,7 +512,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
int count = 0; int count = 0;
try 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) catch (Exception e)
{ {
@ -586,7 +584,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
break; 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 // closestHit for now only works for meshs, so must do it for others
if ((CurrentRayFilter & RayFilterFlags.ClosestHit) == 0) if ((CurrentRayFilter & RayFilterFlags.ClosestHit) == 0)
@ -654,22 +652,22 @@ namespace OpenSim.Region.PhysicsModule.ubOde
m_scene = null; m_scene = null;
if (ray != IntPtr.Zero) if (ray != IntPtr.Zero)
{ {
d.GeomDestroy(ray); SafeNativeMethods.GeomDestroy(ray);
ray = IntPtr.Zero; ray = IntPtr.Zero;
} }
if (Box != IntPtr.Zero) if (Box != IntPtr.Zero)
{ {
d.GeomDestroy(Box); SafeNativeMethods.GeomDestroy(Box);
Box = IntPtr.Zero; Box = IntPtr.Zero;
} }
if (Sphere != IntPtr.Zero) if (Sphere != IntPtr.Zero)
{ {
d.GeomDestroy(Sphere); SafeNativeMethods.GeomDestroy(Sphere);
Sphere = IntPtr.Zero; Sphere = IntPtr.Zero;
} }
if (Plane != IntPtr.Zero) if (Plane != IntPtr.Zero)
{ {
d.GeomDestroy(Plane); SafeNativeMethods.GeomDestroy(Plane);
Plane = IntPtr.Zero; Plane = IntPtr.Zero;
} }
} }

View File

@ -34,15 +34,10 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using System.IO;
using System.Diagnostics;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using Mono.Addins;
using OdeAPI;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using OpenMetaverse; 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.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 | 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 comumContactERP = 0.75f;
const float comumContactCFM = 0.0001f; const float comumContactCFM = 0.0001f;
const float comumContactSLIP = 0f; const float comumContactSLIP = 0f;
@ -228,7 +223,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public int bodyFramesAutoDisable = 5; public int bodyFramesAutoDisable = 5;
private d.NearCallback nearCallback; private SafeNativeMethods.NearCallback nearCallback;
private Dictionary<uint,OdePrim> _prims = new Dictionary<uint,OdePrim>(); private Dictionary<uint,OdePrim> _prims = new Dictionary<uint,OdePrim>();
private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
@ -251,7 +246,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
private int contactsPerCollision = 80; private int contactsPerCollision = 80;
internal IntPtr ContactgeomsArray = IntPtr.Zero; internal IntPtr ContactgeomsArray = IntPtr.Zero;
private IntPtr GlobalContactsArray = 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; const int maxContactsbeforedeath = 6000;
private volatile int m_global_contactcount = 0; private volatile int m_global_contactcount = 0;
@ -356,7 +351,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
/// </summary> /// </summary>
private void Initialization() private void Initialization()
{ {
d.AllocateODEDataForThread(~0U); SafeNativeMethods.AllocateODEDataForThread(~0U);
SimulationLock = new Object(); SimulationLock = new Object();
@ -374,15 +369,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// Create the world and the first space // Create the world and the first space
try try
{ {
world = d.WorldCreate(); world = SafeNativeMethods.WorldCreate();
TopSpace = d.SimpleSpaceCreate(IntPtr.Zero); TopSpace = SafeNativeMethods.SimpleSpaceCreate(IntPtr.Zero);
ActiveSpace = d.SimpleSpaceCreate(TopSpace); ActiveSpace = SafeNativeMethods.SimpleSpaceCreate(TopSpace);
CharsSpace = d.SimpleSpaceCreate(TopSpace); CharsSpace = SafeNativeMethods.SimpleSpaceCreate(TopSpace);
GroundSpace = d.SimpleSpaceCreate(TopSpace); GroundSpace = SafeNativeMethods.SimpleSpaceCreate(TopSpace);
float sx = WorldExtents.X + 16; float sx = WorldExtents.X + 16;
float sy = WorldExtents.Y + 16; float sy = WorldExtents.Y + 16;
d.Vector3 ex =new d.Vector3(sx, sy, 0); SafeNativeMethods.Vector3 ex =new SafeNativeMethods.Vector3(sx, sy, 0);
d.Vector3 px =new d.Vector3(sx * 0.5f, sx * 0.5f, 0); SafeNativeMethods.Vector3 px =new SafeNativeMethods.Vector3(sx * 0.5f, sx * 0.5f, 0);
if(sx < sy) if(sx < sy)
sx = sy; sx = sy;
sx = (float)Math.Log(sx) * 1.442695f + 0.5f; sx = (float)Math.Log(sx) * 1.442695f + 0.5f;
@ -391,7 +386,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
dp = 8; dp = 8;
else if(dp < 4) else if(dp < 4)
dp = 4; dp = 4;
StaticSpace = d.QuadTreeSpaceCreate(TopSpace, ref px, ref ex, dp); StaticSpace = SafeNativeMethods.QuadTreeSpaceCreate(TopSpace, ref px, ref ex, dp);
} }
catch catch
{ {
@ -400,47 +395,47 @@ namespace OpenSim.Region.PhysicsModule.ubOde
} }
// demote to second level // demote to second level
d.SpaceSetSublevel(ActiveSpace, 1); SafeNativeMethods.SpaceSetSublevel(ActiveSpace, 1);
d.SpaceSetSublevel(CharsSpace, 1); SafeNativeMethods.SpaceSetSublevel(CharsSpace, 1);
d.SpaceSetSublevel(StaticSpace, 1); SafeNativeMethods.SpaceSetSublevel(StaticSpace, 1);
d.SpaceSetSublevel(GroundSpace, 1); SafeNativeMethods.SpaceSetSublevel(GroundSpace, 1);
d.GeomSetCategoryBits(ActiveSpace, (uint)(CollisionCategories.Space | SafeNativeMethods.GeomSetCategoryBits(ActiveSpace, (uint)(CollisionCategories.Space |
CollisionCategories.Geom | CollisionCategories.Geom |
CollisionCategories.Character | CollisionCategories.Character |
CollisionCategories.Phantom | CollisionCategories.Phantom |
CollisionCategories.VolumeDtc CollisionCategories.VolumeDtc
)); ));
d.GeomSetCollideBits(ActiveSpace, (uint)(CollisionCategories.Space | SafeNativeMethods.GeomSetCollideBits(ActiveSpace, (uint)(CollisionCategories.Space |
CollisionCategories.Geom | CollisionCategories.Geom |
CollisionCategories.Character | CollisionCategories.Character |
CollisionCategories.Phantom | CollisionCategories.Phantom |
CollisionCategories.VolumeDtc CollisionCategories.VolumeDtc
)); ));
d.GeomSetCategoryBits(CharsSpace, (uint)(CollisionCategories.Space | SafeNativeMethods.GeomSetCategoryBits(CharsSpace, (uint)(CollisionCategories.Space |
CollisionCategories.Geom | CollisionCategories.Geom |
CollisionCategories.Character | CollisionCategories.Character |
CollisionCategories.Phantom | CollisionCategories.Phantom |
CollisionCategories.VolumeDtc 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.Geom |
// CollisionCategories.Land | // CollisionCategories.Land |
// CollisionCategories.Water | // CollisionCategories.Water |
CollisionCategories.Phantom | CollisionCategories.Phantom |
CollisionCategories.VolumeDtc CollisionCategories.VolumeDtc
)); ));
d.GeomSetCollideBits(StaticSpace, 0); SafeNativeMethods.GeomSetCollideBits(StaticSpace, 0);
d.GeomSetCategoryBits(GroundSpace, (uint)(CollisionCategories.Land)); SafeNativeMethods.GeomSetCategoryBits(GroundSpace, (uint)(CollisionCategories.Land));
d.GeomSetCollideBits(GroundSpace, 0); SafeNativeMethods.GeomSetCollideBits(GroundSpace, 0);
contactgroup = d.JointGroupCreate(maxContactsbeforedeath + 1); contactgroup = SafeNativeMethods.JointGroupCreate(maxContactsbeforedeath + 1);
//contactgroup //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; maximumAngularVelocity = 0.49f * heartbeat *(float)Math.PI;
maxAngVelocitySQ = maximumAngularVelocity * maximumAngularVelocity; maxAngVelocitySQ = maximumAngularVelocity * maximumAngularVelocity;
d.WorldSetCFM(world, comumContactCFM); SafeNativeMethods.WorldSetCFM(world, comumContactCFM);
d.WorldSetERP(world, comumContactERP); SafeNativeMethods.WorldSetERP(world, comumContactERP);
d.WorldSetGravity(world, gravityx, gravityy, gravityz); SafeNativeMethods.WorldSetGravity(world, gravityx, gravityy, gravityz);
d.WorldSetLinearDamping(world, 0.001f); SafeNativeMethods.WorldSetLinearDamping(world, 0.001f);
d.WorldSetAngularDamping(world, 0.002f); SafeNativeMethods.WorldSetAngularDamping(world, 0.002f);
d.WorldSetAngularDampingThreshold(world, 0f); SafeNativeMethods.WorldSetAngularDampingThreshold(world, 0f);
d.WorldSetLinearDampingThreshold(world, 0f); SafeNativeMethods.WorldSetLinearDampingThreshold(world, 0f);
d.WorldSetMaxAngularSpeed(world, maximumAngularVelocity); SafeNativeMethods.WorldSetMaxAngularSpeed(world, maximumAngularVelocity);
d.WorldSetQuickStepNumIterations(world, m_physicsiterations); SafeNativeMethods.WorldSetQuickStepNumIterations(world, m_physicsiterations);
d.WorldSetContactSurfaceLayer(world, contactsurfacelayer); SafeNativeMethods.WorldSetContactSurfaceLayer(world, contactsurfacelayer);
d.WorldSetContactMaxCorrectingVel(world, 60.0f); SafeNativeMethods.WorldSetContactMaxCorrectingVel(world, 60.0f);
HalfOdeStep = ODE_STEPSIZE * 0.5f; HalfOdeStep = ODE_STEPSIZE * 0.5f;
odetimestepMS = (int)(1000.0f * ODE_STEPSIZE + 0.5f); odetimestepMS = (int)(1000.0f * ODE_STEPSIZE + 0.5f);
ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * SafeNativeMethods.ContactGeom.unmanagedSizeOf);
GlobalContactsArray = Marshal.AllocHGlobal((maxContactsbeforedeath + 100) * d.Contact.unmanagedSizeOf); GlobalContactsArray = Marshal.AllocHGlobal((maxContactsbeforedeath + 100) * SafeNativeMethods.Contact.unmanagedSizeOf);
SharedTmpcontact.geom.g1 = IntPtr.Zero; SharedTmpcontact.geom.g1 = IntPtr.Zero;
SharedTmpcontact.geom.g2 = IntPtr.Zero; SharedTmpcontact.geom.g2 = IntPtr.Zero;
@ -565,7 +560,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
#region Collision Detection #region Collision Detection
// sets a global contact for a joint for contactgeom , and base contact description) // 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) if (m_global_contactcount >= maxContactsbeforedeath)
return IntPtr.Zero; return IntPtr.Zero;
@ -578,18 +573,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde
SharedTmpcontact.geom.pos = contactGeom.pos; SharedTmpcontact.geom.pos = contactGeom.pos;
SharedTmpcontact.geom.normal = contactGeom.normal; 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); 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) if (ContactgeomsArray == IntPtr.Zero || index >= contactsPerCollision)
return false; return false;
IntPtr contactptr = new IntPtr(ContactgeomsArray.ToInt64() + (Int64)(index * d.ContactGeom.unmanagedSizeOf)); IntPtr contactptr = new IntPtr(ContactgeomsArray.ToInt64() + (Int64)(index * SafeNativeMethods.ContactGeom.unmanagedSizeOf));
newcontactgeom = (d.ContactGeom)Marshal.PtrToStructure(contactptr, typeof(d.ContactGeom)); newcontactgeom = (SafeNativeMethods.ContactGeom)Marshal.PtrToStructure(contactptr, typeof(SafeNativeMethods.ContactGeom));
return true; return true;
} }
@ -614,14 +609,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
return; return;
if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) if (SafeNativeMethods.GeomIsSpace(g1) || SafeNativeMethods.GeomIsSpace(g2))
{ {
// We'll be calling near recursivly if one // We'll be calling near recursivly if one
// of them is a space to find all of the // of them is a space to find all of the
// contact points in the space // contact points in the space
try try
{ {
d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback);
} }
catch (AccessViolationException) catch (AccessViolationException)
{ {
@ -636,8 +631,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// get geom bodies to check if we already a joint contact // get geom bodies to check if we already a joint contact
// guess this shouldn't happen now // guess this shouldn't happen now
IntPtr b1 = d.GeomGetBody(g1); IntPtr b1 = SafeNativeMethods.GeomGetBody(g1);
IntPtr b2 = d.GeomGetBody(g2); IntPtr b2 = SafeNativeMethods.GeomGetBody(g2);
// d.GeomClassID id = d.GeomGetClass(g1); // d.GeomClassID id = d.GeomGetClass(g1);
@ -679,18 +674,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// //
*/ */
if (d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || if (SafeNativeMethods.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc ||
d.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc) SafeNativeMethods.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc)
{ {
int cflags; int cflags;
unchecked 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 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) catch (SEHException)
{ {
@ -726,7 +721,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// get first contact // get first contact
d.ContactGeom curContact = new d.ContactGeom(); SafeNativeMethods.ContactGeom curContact = new SafeNativeMethods.ContactGeom();
if (!GetCurContactGeom(0, ref curContact)) if (!GetCurContactGeom(0, ref curContact))
return; return;
@ -802,8 +797,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// if (relVlenSQ > 0.01f) // if (relVlenSQ > 0.01f)
// mu *= frictionMovementMult; // mu *= frictionMovementMult;
if(d.GeomGetClass(g2) == d.GeomClassID.TriMeshClass && if(SafeNativeMethods.GeomGetClass(g2) == SafeNativeMethods.GeomClassID.TriMeshClass &&
d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) SafeNativeMethods.GeomGetClass(g1) == SafeNativeMethods.GeomClassID.TriMeshClass)
smoothMesh = true; smoothMesh = true;
break; break;
@ -817,7 +812,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// mu *= frictionMovementMult; // mu *= frictionMovementMult;
p1.CollidingGround = true; p1.CollidingGround = true;
if(d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) if(SafeNativeMethods.GeomGetClass(g1) == SafeNativeMethods.GeomClassID.TriMeshClass)
smoothMesh = true; smoothMesh = true;
break; break;
@ -843,7 +838,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// if (Math.Abs(v2.X) > 0.1f || Math.Abs(v2.Y) > 0.1f) // if (Math.Abs(v2.X) > 0.1f || Math.Abs(v2.Y) > 0.1f)
// mu *= frictionMovementMult; // mu *= frictionMovementMult;
if(d.GeomGetClass(g2) == d.GeomClassID.TriMeshClass) if(SafeNativeMethods.GeomGetClass(g2) == SafeNativeMethods.GeomClassID.TriMeshClass)
smoothMesh = true; smoothMesh = true;
} }
else else
@ -873,7 +868,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
SharedTmpcontact.surface.mu = mu; SharedTmpcontact.surface.mu = mu;
SharedTmpcontact.surface.bounce = bounce; SharedTmpcontact.surface.bounce = bounce;
d.ContactGeom altContact = new d.ContactGeom(); SafeNativeMethods.ContactGeom altContact = new SafeNativeMethods.ContactGeom();
bool useAltcontact; bool useAltcontact;
bool noskip; bool noskip;
@ -925,7 +920,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (Joint == IntPtr.Zero) if (Joint == IntPtr.Zero)
break; break;
d.JointAttach(Joint, b1, b2); SafeNativeMethods.JointAttach(Joint, b1, b2);
ncontacts++; ncontacts++;
@ -1073,12 +1068,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
continue; continue;
// do colisions with static space // 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 // no coll with gnd
} }
// chars with chars // chars with chars
d.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback);
} }
catch (AccessViolationException) catch (AccessViolationException)
@ -1094,7 +1089,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
aprim.CollisionScore = 0; aprim.CollisionScore = 0;
aprim.IsColliding = false; aprim.IsColliding = false;
if(!aprim.m_outbounds && d.BodyIsEnabled(aprim.Body)) if(!aprim.m_outbounds && SafeNativeMethods.BodyIsEnabled(aprim.Body))
aprim.clearSleeperCollisions(); aprim.clearSleeperCollisions();
} }
} }
@ -1105,11 +1100,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
foreach (OdePrim aprim in _activegroups) 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) aprim.collide_geom != IntPtr.Zero)
{ {
d.SpaceCollide2(StaticSpace, aprim.collide_geom, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide2(StaticSpace, aprim.collide_geom, IntPtr.Zero, nearCallback);
d.SpaceCollide2(GroundSpace, 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 // colide active amoung them
try try
{ {
d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback);
} }
catch (Exception e) catch (Exception e)
{ {
@ -1132,7 +1127,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// and with chars // and with chars
try try
{ {
d.SpaceCollide2(CharsSpace,ActiveSpace, IntPtr.Zero, nearCallback); SafeNativeMethods.SpaceCollide2(CharsSpace,ActiveSpace, IntPtr.Zero, nearCallback);
} }
catch (Exception e) catch (Exception e)
{ {
@ -1232,7 +1227,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
lock (OdeLock) lock (OdeLock)
{ {
d.AllocateODEDataForThread(0); SafeNativeMethods.AllocateODEDataForThread(0);
((OdeCharacter) actor).Destroy(); ((OdeCharacter) actor).Destroy();
} }
} }
@ -1403,16 +1398,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
return StaticSpace; return StaticSpace;
// else remove it from its current space // 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); 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 else
@ -1421,19 +1416,19 @@ namespace OpenSim.Region.PhysicsModule.ubOde
" Geom:" + geom); " 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 (currentspace != IntPtr.Zero)
{ {
if (d.GeomIsSpace(currentspace)) if (SafeNativeMethods.GeomIsSpace(currentspace))
{ {
waitForSpaceUnlock(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 // put the geom in the newspace
waitForSpaceUnlock(StaticSpace); 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; return StaticSpace;
} }
#endregion #endregion
@ -1485,7 +1481,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
return; return;
} }
d.AllocateODEDataForThread(~0U); SafeNativeMethods.AllocateODEDataForThread(~0U);
ODEchangeitem item; ODEchangeitem item;
@ -1585,7 +1581,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
double moveTime = 0; double moveTime = 0;
double rayTime = 0; double rayTime = 0;
*/ */
d.AllocateODEDataForThread(~0U); SafeNativeMethods.AllocateODEDataForThread(~0U);
if (ChangesQueue.Count > 0) if (ChangesQueue.Count > 0)
{ {
@ -1689,7 +1685,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
pobj.SendCollisions((int)(odetimestepMS)); pobj.SendCollisions((int)(odetimestepMS));
if(pobj.Body != IntPtr.Zero && !pobj.m_isSelected && if(pobj.Body != IntPtr.Zero && !pobj.m_isSelected &&
!pobj.m_disabled && !pobj.m_building && !pobj.m_disabled && !pobj.m_building &&
!d.BodyIsEnabled(pobj.Body)) !SafeNativeMethods.BodyIsEnabled(pobj.Body))
sleepers.Add(pobj); sleepers.Add(pobj);
} }
break; break;
@ -1704,8 +1700,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// do a ode simulation step // do a ode simulation step
// tmpTime = Util.GetTimeStampMS(); // tmpTime = Util.GetTimeStampMS();
d.WorldQuickStep(world, ODE_STEPSIZE); SafeNativeMethods.WorldQuickStep(world, ODE_STEPSIZE);
d.JointGroupEmpty(contactgroup); SafeNativeMethods.JointGroupEmpty(contactgroup);
// qstepTIme += Util.GetTimeStampMS() - tmpTime; // qstepTIme += Util.GetTimeStampMS() - tmpTime;
// update managed ideia of physical data and do updates to core // 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; fps = (float)nodeframes * ODE_STEPSIZE / reqTimeStep;
if(step_time < HalfOdeStep) if(step_time < HalfOdeStep)
@ -2208,35 +2184,35 @@ namespace OpenSim.Region.PhysicsModule.ubOde
lock (OdeLock) lock (OdeLock)
{ {
d.AllocateODEDataForThread(~0U); SafeNativeMethods.AllocateODEDataForThread(~0U);
if (TerrainGeom != IntPtr.Zero) if (TerrainGeom != IntPtr.Zero)
{ {
actor_name_map.Remove(TerrainGeom); actor_name_map.Remove(TerrainGeom);
d.GeomDestroy(TerrainGeom); SafeNativeMethods.GeomDestroy(TerrainGeom);
} }
if (TerrainHeightFieldHeightsHandler.IsAllocated) if (TerrainHeightFieldHeightsHandler.IsAllocated)
TerrainHeightFieldHeightsHandler.Free(); TerrainHeightFieldHeightsHandler.Free();
IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); IntPtr HeightmapData = SafeNativeMethods.GeomHeightfieldDataCreate();
TerrainHeightFieldHeightsHandler = GCHandle.Alloc(_heightmap, GCHandleType.Pinned); TerrainHeightFieldHeightsHandler = GCHandle.Alloc(_heightmap, GCHandleType.Pinned);
d.GeomHeightfieldDataBuildSingle(HeightmapData, TerrainHeightFieldHeightsHandler.AddrOfPinnedObject(), 0, SafeNativeMethods.GeomHeightfieldDataBuildSingle(HeightmapData, TerrainHeightFieldHeightsHandler.AddrOfPinnedObject(), 0,
heightmapHeight, heightmapWidth , heightmapHeight, heightmapWidth ,
(int)heightmapHeightSamples, (int)heightmapWidthSamples, scale, (int)heightmapHeightSamples, (int)heightmapWidthSamples, scale,
offset, thickness, wrap); 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) if (TerrainGeom != IntPtr.Zero)
{ {
d.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land)); SafeNativeMethods.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land));
d.GeomSetCollideBits(TerrainGeom, 0); SafeNativeMethods.GeomSetCollideBits(TerrainGeom, 0);
PhysicsActor pa = new NullPhysicsActor(); PhysicsActor pa = new NullPhysicsActor();
pa.Name = "Terrain"; pa.Name = "Terrain";
@ -2245,14 +2221,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// geom_name_map[GroundGeom] = "Terrain"; // geom_name_map[GroundGeom] = "Terrain";
d.Quaternion q = new d.Quaternion(); SafeNativeMethods.Quaternion q = new SafeNativeMethods.Quaternion();
q.X = 0.5f; q.X = 0.5f;
q.Y = 0.5f; q.Y = 0.5f;
q.Z = 0.5f; q.Z = 0.5f;
q.W = 0.5f; q.W = 0.5f;
d.GeomSetQuaternion(TerrainGeom, ref q); SafeNativeMethods.GeomSetQuaternion(TerrainGeom, ref q);
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; TerrainHeightFieldHeight = _heightmap;
} }
else else
@ -2320,7 +2296,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (TerrainGeom != IntPtr.Zero) if (TerrainGeom != IntPtr.Zero)
{ {
actor_name_map.Remove(TerrainGeom); actor_name_map.Remove(TerrainGeom);
d.GeomDestroy(TerrainGeom); SafeNativeMethods.GeomDestroy(TerrainGeom);
} }
if (TerrainHeightFieldHeightsHandler.IsAllocated) if (TerrainHeightFieldHeightsHandler.IsAllocated)
@ -2328,7 +2304,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
TerrainHeightFieldHeight = null; TerrainHeightFieldHeight = null;
IntPtr HeightmapData = d.GeomOSTerrainDataCreate(); IntPtr HeightmapData = SafeNativeMethods.GeomOSTerrainDataCreate();
const int wrap = 0; const int wrap = 0;
float thickness = hfmin; float thickness = hfmin;
@ -2337,16 +2313,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
TerrainHeightFieldHeightsHandler = GCHandle.Alloc(_heightmap, GCHandleType.Pinned); 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, (int)heightmapWidthSamples, (int)heightmapHeightSamples,
thickness, wrap); thickness, wrap);
// d.GeomOSTerrainDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); // d.GeomOSTerrainDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1);
TerrainGeom = d.CreateOSTerrain(GroundSpace, HeightmapData, 1); TerrainGeom = SafeNativeMethods.CreateOSTerrain(GroundSpace, HeightmapData, 1);
if (TerrainGeom != IntPtr.Zero) if (TerrainGeom != IntPtr.Zero)
{ {
d.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land)); SafeNativeMethods.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land));
d.GeomSetCollideBits(TerrainGeom, 0); SafeNativeMethods.GeomSetCollideBits(TerrainGeom, 0);
PhysicsActor pa = new NullPhysicsActor(); PhysicsActor pa = new NullPhysicsActor();
pa.Name = "Terrain"; pa.Name = "Terrain";
@ -2355,7 +2331,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// geom_name_map[GroundGeom] = "Terrain"; // 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; TerrainHeightFieldHeight = _heightmap;
} }
else else
@ -2385,7 +2361,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (world == IntPtr.Zero) if (world == IntPtr.Zero)
return; return;
d.AllocateODEDataForThread(~0U); SafeNativeMethods.AllocateODEDataForThread(~0U);
if (m_meshWorker != null) if (m_meshWorker != null)
m_meshWorker.Stop(); m_meshWorker.Stop();
@ -2419,7 +2395,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
ch.DoAChange(changes.Remove, null); ch.DoAChange(changes.Remove, null);
if (TerrainGeom != IntPtr.Zero) if (TerrainGeom != IntPtr.Zero)
d.GeomDestroy(TerrainGeom); SafeNativeMethods.GeomDestroy(TerrainGeom);
TerrainGeom = IntPtr.Zero; TerrainGeom = IntPtr.Zero;
if (TerrainHeightFieldHeightsHandler.IsAllocated) if (TerrainHeightFieldHeightsHandler.IsAllocated)
@ -2438,7 +2414,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
GlobalContactsArray = IntPtr.Zero; GlobalContactsArray = IntPtr.Zero;
} }
d.WorldDestroy(world); SafeNativeMethods.WorldDestroy(world);
world = IntPtr.Zero; world = IntPtr.Zero;
//d.CloseODE(); //d.CloseODE();
} }

View File

@ -27,13 +27,7 @@
// Ubit Umarov 2012 // Ubit Umarov 2012
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using OdeAPI;
using log4net;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Region.PhysicsModule.ubOde namespace OpenSim.Region.PhysicsModule.ubOde
@ -78,8 +72,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
IntPtr geom = ((OdePrim)actor).prim_geom; IntPtr geom = ((OdePrim)actor).prim_geom;
Vector3 geopos = d.GeomGetPositionOMV(geom); Vector3 geopos = SafeNativeMethods.GeomGetPositionOMV(geom);
Quaternion geomOri = d.GeomGetQuaternionOMV(geom); Quaternion geomOri = SafeNativeMethods.GeomGetQuaternionOMV(geom);
// Vector3 geopos = actor.Position; // Vector3 geopos = actor.Position;
// Quaternion geomOri = actor.Orientation; // Quaternion geomOri = actor.Orientation;
@ -123,11 +117,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
offset = rayResults[0].Pos - geopos; 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.Normalize();
offset *= r; offset *= r;