more cosmetics

This commit is contained in:
UbitUmarov
2022-04-18 23:08:56 +01:00
parent 7c3ad0699f
commit 578c0f36ce
5 changed files with 194 additions and 226 deletions

View File

@@ -74,7 +74,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
private Vector3 _position;
private Vector3 _zeroPosition;
private Vector3 _velocity;
private Vector3 _target_velocity;
private Vector3 _acceleration;
private Vector3 m_rotationalVelocity;
private Vector3 m_size;
@@ -604,11 +603,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
get
{
return _target_velocity;
return m_targetVelocity;
}
set
{
return;
}
}
@@ -1210,7 +1208,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
dtmp = SafeNativeMethods.BodyGetLinearVel(Body);
Vector3 vel = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
Vector3 ctz = _target_velocity;
Vector3 ctz = m_targetVelocity;
if (m_alwaysRun)
{
@@ -1340,11 +1338,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
break;
case PIDHoverType.GroundAndWater:
float waterHeight = m_parent_scene.GetWaterLevel();
if (terrainheight > waterHeight)
if (terrainheight > m_parent_scene.WaterLevel)
m_targetHoverHeight = terrainheight + m_PIDHoverHeight;
else
m_targetHoverHeight = waterHeight + m_PIDHoverHeight;
m_targetHoverHeight = m_parent_scene.WaterLevel + m_PIDHoverHeight;
break;
} // end switch (m_PIDHoverType)
@@ -1973,7 +1970,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
//m_pidControllerActive = true;
//m_freemove = false;
_target_velocity = newVel;
m_targetVelocity = newVel;
if (Body != IntPtr.Zero)
SafeNativeMethods.BodyEnable(Body);
}
@@ -2018,7 +2015,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
m_pidControllerActive = true;
_zeroFlag = false;
_target_velocity = Vector3.Zero;
m_targetVelocity = Vector3.Zero;
m_freemove = true;
m_colliderfilter = -1;
m_colliderObjectfilter = -1;

View File

@@ -869,7 +869,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0)
{
perr += _pParentScene.GetWaterLevel();
perr += _pParentScene.WaterLevel;
}
else if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0)
{
@@ -877,11 +877,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
}
else
{
float w = _pParentScene.GetWaterLevel();
if (t > w)
if (t > _pParentScene.WaterLevel)
perr += t;
else
perr += w;
perr += _pParentScene.WaterLevel;
}
}
else if (t > m_VhoverHeight)

View File

@@ -3703,11 +3703,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
break;
case PIDHoverType.GroundAndWater:
float waterHeight = m_parentScene.GetWaterLevel();
if (groundHeight > waterHeight)
if (groundHeight > m_parentScene.WaterLevel)
m_targetHoverHeight = groundHeight + m_PIDHoverHeight;
else
m_targetHoverHeight = waterHeight + m_PIDHoverHeight;
m_targetHoverHeight = m_parentScene.WaterLevel + m_PIDHoverHeight;
break;
} // end switch (m_PIDHoverType)
@@ -4108,12 +4107,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
changevelocity((Vector3)arg);
break;
case changes.TargetVelocity:
break;
//case changes.TargetVelocity:
// break;
// case changes.Acceleration:
// changeacceleration((Vector3)arg);
// break;
//case changes.Acceleration:
// changeacceleration((Vector3)arg);
// break;
case changes.AngVelocity:
changeangvelocity((Vector3)arg);

View File

@@ -112,157 +112,153 @@ namespace OpenSim.Region.PhysicsModule.ubOde
int time = Util.EnvironmentTickCount();
ODERayRequest req;
int closestHit;
int backfacecull;
CollisionCategories catflags;
while (m_PendingRequests.Dequeue(out req))
while (m_PendingRequests.Dequeue(out ODERayRequest req))
{
if (req.callbackMethod != null)
IntPtr geom = IntPtr.Zero;
if (req.actor != null)
{
IntPtr geom = IntPtr.Zero;
if (req.actor != null)
if (m_scene.haveActor(req.actor))
{
if (m_scene.haveActor(req.actor))
{
if (req.actor is OdePrim)
geom = ((OdePrim)req.actor).m_prim_geom;
else if (req.actor is OdeCharacter)
geom = ((OdePrim)req.actor).m_prim_geom;
}
if (geom == IntPtr.Zero)
{
NoContacts(req);
continue;
}
if (req.actor is OdePrim)
geom = ((OdePrim)req.actor).m_prim_geom;
else if (req.actor is OdeCharacter)
geom = ((OdeCharacter)req.actor).collider;
}
CurrentRayFilter = req.filter;
CurrentMaxCount = req.Count;
CollisionContactGeomsPerTest = req.Count & 0xffff;
closestHit = ((CurrentRayFilter & RayFilterFlags.ClosestHit) == 0 ? 0 : 1);
backfacecull = ((CurrentRayFilter & RayFilterFlags.BackFaceCull) == 0 ? 0 : 1);
if (req.callbackMethod is ProbeBoxCallback)
{
if (CollisionContactGeomsPerTest > 80)
CollisionContactGeomsPerTest = 80;
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;
SafeNativeMethods.GeomSetQuaternion(Box, ref qtmp);
}
else if (req.callbackMethod is ProbeSphereCallback)
{
if (CollisionContactGeomsPerTest > 80)
CollisionContactGeomsPerTest = 80;
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;
SafeNativeMethods.GeomPlaneSetParams(Plane, req.Normal.X, req.Normal.Y, req.Normal.Z, req.length);
}
else
{
if (CollisionContactGeomsPerTest > 25)
CollisionContactGeomsPerTest = 25;
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;
SafeNativeMethods.GeomRaySetClosestHit(ray, 1);
}
else
SafeNativeMethods.GeomRaySetClosestHit(ray, closestHit);
}
if ((CurrentRayFilter & RayFilterFlags.ContactsUnImportant) != 0)
unchecked
{
CollisionContactGeomsPerTest |= (int)SafeNativeMethods.CONTACTS_UNIMPORTANT;
}
if (geom == IntPtr.Zero)
{
// translate ray filter to Collision flags
catflags = 0;
if ((CurrentRayFilter & RayFilterFlags.volumedtc) != 0)
catflags |= CollisionCategories.VolumeDtc;
if ((CurrentRayFilter & RayFilterFlags.phantom) != 0)
catflags |= CollisionCategories.Phantom;
if ((CurrentRayFilter & RayFilterFlags.agent) != 0)
catflags |= CollisionCategories.Character;
if ((CurrentRayFilter & RayFilterFlags.PrimsNonPhantom) != 0)
catflags |= CollisionCategories.Geom;
if ((CurrentRayFilter & RayFilterFlags.land) != 0)
catflags |= CollisionCategories.Land;
if ((CurrentRayFilter & RayFilterFlags.water) != 0)
catflags |= CollisionCategories.Water;
NoContacts(req);
continue;
}
}
if (catflags != 0)
{
if (req.callbackMethod is ProbeBoxCallback)
{
catflags |= CollisionCategories.Space;
SafeNativeMethods.GeomSetCollideBits(Box, (uint)catflags);
SafeNativeMethods.GeomSetCategoryBits(Box, (uint)catflags);
doProbe(req, Box);
}
else if (req.callbackMethod is ProbeSphereCallback)
{
catflags |= CollisionCategories.Space;
SafeNativeMethods.GeomSetCollideBits(Sphere, (uint)catflags);
SafeNativeMethods.GeomSetCategoryBits(Sphere, (uint)catflags);
doProbe(req, Sphere);
}
else if (req.callbackMethod is ProbePlaneCallback)
{
catflags |= CollisionCategories.Space;
SafeNativeMethods.GeomSetCollideBits(Plane, (uint)catflags);
SafeNativeMethods.GeomSetCategoryBits(Plane, (uint)catflags);
doPlane(req,IntPtr.Zero);
}
else
{
SafeNativeMethods.GeomSetCollideBits(ray, (uint)catflags);
doSpaceRay(req);
}
}
CurrentRayFilter = req.filter;
CurrentMaxCount = req.Count;
CollisionContactGeomsPerTest = req.Count & 0xffff;
closestHit = ((CurrentRayFilter & RayFilterFlags.ClosestHit) == 0 ? 0 : 1);
backfacecull = ((CurrentRayFilter & RayFilterFlags.BackFaceCull) == 0 ? 0 : 1);
if (req.callbackMethod is ProbeBoxCallback)
{
if (CollisionContactGeomsPerTest > 80)
CollisionContactGeomsPerTest = 80;
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;
SafeNativeMethods.GeomSetQuaternion(Box, ref qtmp);
}
else if (req.callbackMethod is ProbeSphereCallback)
{
if (CollisionContactGeomsPerTest > 80)
CollisionContactGeomsPerTest = 80;
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;
SafeNativeMethods.GeomPlaneSetParams(Plane, req.Normal.X, req.Normal.Y, req.Normal.Z, req.length);
}
else
{
if (CollisionContactGeomsPerTest > 25)
CollisionContactGeomsPerTest = 25;
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;
SafeNativeMethods.GeomRaySetClosestHit(ray, 1);
}
else
{
// if we select a geom don't use filters
SafeNativeMethods.GeomRaySetClosestHit(ray, closestHit);
}
if (req.callbackMethod is ProbePlaneCallback)
if ((CurrentRayFilter & RayFilterFlags.ContactsUnImportant) != 0)
unchecked
{
CollisionContactGeomsPerTest |= (int)SafeNativeMethods.CONTACTS_UNIMPORTANT;
}
if (geom == IntPtr.Zero)
{
// translate ray filter to Collision flags
catflags = 0;
if ((CurrentRayFilter & RayFilterFlags.volumedtc) != 0)
catflags |= CollisionCategories.VolumeDtc;
if ((CurrentRayFilter & RayFilterFlags.phantom) != 0)
catflags |= CollisionCategories.Phantom;
if ((CurrentRayFilter & RayFilterFlags.agent) != 0)
catflags |= CollisionCategories.Character;
if ((CurrentRayFilter & RayFilterFlags.PrimsNonPhantom) != 0)
catflags |= CollisionCategories.Geom;
if ((CurrentRayFilter & RayFilterFlags.land) != 0)
catflags |= CollisionCategories.Land;
if ((CurrentRayFilter & RayFilterFlags.water) != 0)
catflags |= CollisionCategories.Water;
if (catflags != 0)
{
if (req.callbackMethod is ProbeBoxCallback)
{
SafeNativeMethods.GeomSetCollideBits(Plane, (uint)CollisionCategories.All);
doPlane(req,geom);
catflags |= CollisionCategories.Space;
SafeNativeMethods.GeomSetCollideBits(Box, (uint)catflags);
SafeNativeMethods.GeomSetCategoryBits(Box, (uint)catflags);
doProbe(req, Box);
}
else if (req.callbackMethod is ProbeSphereCallback)
{
catflags |= CollisionCategories.Space;
SafeNativeMethods.GeomSetCollideBits(Sphere, (uint)catflags);
SafeNativeMethods.GeomSetCategoryBits(Sphere, (uint)catflags);
doProbe(req, Sphere);
}
else if (req.callbackMethod is ProbePlaneCallback)
{
catflags |= CollisionCategories.Space;
SafeNativeMethods.GeomSetCollideBits(Plane, (uint)catflags);
SafeNativeMethods.GeomSetCategoryBits(Plane, (uint)catflags);
doPlane(req,IntPtr.Zero);
}
else
{
SafeNativeMethods.GeomSetCollideBits(ray, (uint)CollisionCategories.All);
doGeomRay(req,geom);
SafeNativeMethods.GeomSetCollideBits(ray, (uint)catflags);
doSpaceRay(req);
}
}
}
else
{
// if we select a geom don't use filters
if (req.callbackMethod is ProbePlaneCallback)
{
SafeNativeMethods.GeomSetCollideBits(Plane, (uint)CollisionCategories.All);
doPlane(req,geom);
}
else
{
SafeNativeMethods.GeomSetCollideBits(ray, (uint)CollisionCategories.All);
doGeomRay(req,geom);
}
}
if (Util.EnvironmentTickCountSubtract(time) > MaxTimePerCallMS)
break;

View File

@@ -169,18 +169,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public Scene m_frameWorkScene = null;
// private int threadid = 0;
//private int threadid = 0;
// 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 SafeNativeMethods.ContactFlags comumContactFlags = SafeNativeMethods.ContactFlags.Bounce | SafeNativeMethods.ContactFlags.Approx1;
const float comumContactERP = 0.75f;
const float comumContactCFM = 0.0001f;
const float comumContactSLIP = 0f;
// float frictionMovementMult = 0.2f;
float TerrainBounce = 0.001f;
float TerrainFriction = 0.3f;
@@ -207,7 +202,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public float gravityy = 0f;
public float gravityz = -9.8f;
private float waterlevel = 0f;
public float WaterLevel = 0f;
private int framecount = 0;
private float avDensity = 80f;
@@ -266,7 +261,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
private int m_physicsiterations = 15;
private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag
// private PhysicsActor PANull = new NullPhysicsActor();
//private PhysicsActor PANull = new NullPhysicsActor();
private float step_time = 0.0f;
public IntPtr world;
@@ -1480,27 +1475,25 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (step_time < HalfOdeStep)
return 0;
if (framecount < 0)
framecount = 0;
if (framecount <= 0)
framecount = 1;
else
framecount++;
framecount++;
// checkThread();
//checkThread();
int nodeframes = 0;
float fps = 0;
lock (OdeLock)
{
// d.WorldSetQuickStepNumIterations(world, curphysiteractions);
//d.WorldSetQuickStepNumIterations(world, curphysiteractions);
double loopstartMS = Util.GetTimeStampMS();
double looptimeMS = 0;
double changestimeMS = 0;
double maxChangestime = (int)(reqTimeStep * 500f); // half the time
double maxLoopTime = (int)(reqTimeStep * 1200f); // 1.2 the time
double maxChangestime = (int)(reqTimeStep * 500f) + loopstartMS; // half the time
double maxLoopTime = (int)(reqTimeStep * 1200f) + loopstartMS; // 1.2 the time
/*
/*
double collisionTime = 0;
double qstepTIme = 0;
double tmpTime = 0;
@@ -1509,37 +1502,29 @@ namespace OpenSim.Region.PhysicsModule.ubOde
double updatesTime = 0;
double moveTime = 0;
double rayTime = 0;
*/
*/
SafeNativeMethods.AllocateODEDataForThread(~0U);
if (!ChangesQueue.IsEmpty)
while (ChangesQueue.TryDequeue(out ODEchangeitem item))
{
ODEchangeitem item;
while (ChangesQueue.TryDequeue(out item))
try
{
if (item.actor != null)
lock (SimulationLock)
{
try
{
lock (SimulationLock)
{
if (item.actor is OdeCharacter)
((OdeCharacter)item.actor).DoAChange(item.what, item.arg);
else if (((OdePrim)item.actor).DoAChange(item.what, item.arg))
RemovePrimThreadLocked((OdePrim)item.actor);
}
}
catch
{
m_log.WarnFormat("[PHYSICS]: doChange failed for a actor {0} {1}",
item.actor.Name, item.what.ToString());
}
if (item.actor is OdeCharacter)
((OdeCharacter)item.actor).DoAChange(item.what, item.arg);
else if (((OdePrim)item.actor).DoAChange(item.what, item.arg))
RemovePrimThreadLocked((OdePrim)item.actor);
}
changestimeMS = Util.GetTimeStampMS() - loopstartMS;
if (changestimeMS > maxChangestime)
break;
}
catch
{
m_log.WarnFormat("[PHYSICS]: doChange failed for a actor {0} {1}",
item.actor.Name, item.what.ToString());
}
if (maxChangestime < Util.GetTimeStampMS())
break;
}
// do simulation taking at most 150ms total time including changes
@@ -1550,7 +1535,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// clear pointer/counter to contacts to pass into joints
m_global_contactcount = 0;
// tmpTime = Util.GetTimeStampMS();
//tmpTime = Util.GetTimeStampMS();
// Move characters
lock (_characters)
@@ -1637,21 +1622,21 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// update managed ideia of physical data and do updates to core
/*
lock (_characters)
{
foreach (OdeCharacter actor in _characters)
{
if (actor != null)
{
if (actor.bad)
m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
lock (_characters)
{
foreach (OdeCharacter actor in _characters)
{
if (actor != null)
{
if (actor.bad)
m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
actor.UpdatePositionAndVelocity();
}
}
}
actor.UpdatePositionAndVelocity();
}
}
}
*/
// tmpTime = Util.GetTimeStampMS();
//tmpTime = Util.GetTimeStampMS();
//lock (SimulationLock)
{
lock (_activegroups)
@@ -1669,20 +1654,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde
}
}
// updatesTime += Util.GetTimeStampMS() - tmpTime;
//updatesTime += Util.GetTimeStampMS() - tmpTime;
}
catch (Exception e)
{
m_log.ErrorFormat("[PHYSICS]: {0}, {1}, {2}", e.Message, e.TargetSite, e);
// ode.dunlock(world);
//ode.dunlock(world);
}
step_time -= ODE_STEPSIZE;
nodeframes++;
looptimeMS = Util.GetTimeStampMS() - loopstartMS;
if (looptimeMS > maxLoopTime)
if (Util.GetTimeStampMS() > maxLoopTime)
break;
}
@@ -1697,8 +1680,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
_badCharacter.Clear();
}
}
/*
// information block for in debug breakpoint only
/*
// information block for in debug breakpoint only
int ntopactivegeoms = d.SpaceGetNumGeoms(ActiveSpace);
int ntopstaticgeoms = d.SpaceGetNumGeoms(StaticSpace);
@@ -1740,9 +1724,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
int totgeoms = nstaticgeoms + nactivegeoms + ngroundgeoms + 1; // one ray
int nbodies = d.NTotalBodies;
int ngeoms = d.NTotalGeoms;
*/
*/
/*
/*
looptimeMS /= nodeframes;
collisionTime /= nodeframes;
qstepTIme /= nodeframes;
@@ -1757,7 +1741,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
}
*/
*/
fps = (float)nodeframes * ODE_STEPSIZE / reqTimeStep;
if(step_time < HalfOdeStep)
@@ -2077,14 +2061,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
}
public float GetWaterLevel()
{
return waterlevel;
}
public override void SetWaterLevel(float baseheight)
{
waterlevel = baseheight;
WaterLevel = baseheight;
}
public override void Dispose()
@@ -2134,8 +2113,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
m_terrainHeightsHandler.Free();
m_terrainHeights = null;
m_lastRegionWidth = 0;
m_lastRegionHeight = 0;
if (ContactgeomsArray != IntPtr.Zero)
{