Merge branch 'avination-current'
Conflicts: OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.csavinationmerge
commit
e1b2ecdfdc
|
@ -1626,7 +1626,12 @@ namespace OpenSim.Framework
|
||||||
BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247,
|
BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247,
|
||||||
BREAST_PHYSICS_LEFTRIGHT_SPRING= 248,
|
BREAST_PHYSICS_LEFTRIGHT_SPRING= 248,
|
||||||
BREAST_PHYSICS_LEFTRIGHT_GAIN = 249,
|
BREAST_PHYSICS_LEFTRIGHT_GAIN = 249,
|
||||||
BREAST_PHYSICS_LEFTRIGHT_DAMPING = 250
|
BREAST_PHYSICS_LEFTRIGHT_DAMPING = 250,
|
||||||
|
|
||||||
|
// Ubit: 07/96/2013 new parameters
|
||||||
|
_APPEARANCEMESSAGE_VERSION = 251, //ID 11000
|
||||||
|
|
||||||
|
SHAPE_HOVER = 252, //ID 11001
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,14 +358,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
bool asAttachment)
|
bool asAttachment)
|
||||||
{
|
{
|
||||||
CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero);
|
CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero);
|
||||||
// Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>();
|
Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>();
|
||||||
|
// this possible is not needed if keyframes are saved
|
||||||
|
Dictionary<UUID, KeyframeMotion> originalKeyframes = new Dictionary<UUID, KeyframeMotion>();
|
||||||
|
|
||||||
foreach (SceneObjectGroup objectGroup in objlist)
|
foreach (SceneObjectGroup objectGroup in objlist)
|
||||||
{
|
{
|
||||||
if (objectGroup.RootPart.KeyframeMotion != null)
|
if (objectGroup.RootPart.KeyframeMotion != null)
|
||||||
objectGroup.RootPart.KeyframeMotion.Stop();
|
{
|
||||||
|
objectGroup.RootPart.KeyframeMotion.Suspend();
|
||||||
|
}
|
||||||
objectGroup.RootPart.SetForce(Vector3.Zero);
|
objectGroup.RootPart.SetForce(Vector3.Zero);
|
||||||
objectGroup.RootPart.SetAngularImpulse(Vector3.Zero, false);
|
objectGroup.RootPart.SetAngularImpulse(Vector3.Zero, false);
|
||||||
|
|
||||||
|
originalKeyframes[objectGroup.UUID] = objectGroup.RootPart.KeyframeMotion;
|
||||||
objectGroup.RootPart.KeyframeMotion = null;
|
objectGroup.RootPart.KeyframeMotion = null;
|
||||||
|
|
||||||
Vector3 inventoryStoredPosition = new Vector3
|
Vector3 inventoryStoredPosition = new Vector3
|
||||||
|
@ -427,9 +433,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
else
|
else
|
||||||
itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment);
|
itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment);
|
||||||
|
|
||||||
// // Restore the position of each group now that it has been stored to inventory.
|
// Restore the position of each group now that it has been stored to inventory.
|
||||||
// foreach (SceneObjectGroup objectGroup in objlist)
|
foreach (SceneObjectGroup objectGroup in objlist)
|
||||||
// objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID];
|
{
|
||||||
|
objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID];
|
||||||
|
objectGroup.RootPart.KeyframeMotion = originalKeyframes[objectGroup.UUID];
|
||||||
|
if (objectGroup.RootPart.KeyframeMotion != null)
|
||||||
|
objectGroup.RootPart.KeyframeMotion.Resume();
|
||||||
|
}
|
||||||
|
|
||||||
InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID);
|
InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID);
|
||||||
|
|
||||||
|
|
|
@ -265,14 +265,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
private void StartTimer()
|
private void StartTimer()
|
||||||
{
|
{
|
||||||
KeyframeTimer.Add(this);
|
lock (m_frames)
|
||||||
m_timerStopped = false;
|
{
|
||||||
|
KeyframeTimer.Add(this);
|
||||||
|
m_timerStopped = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StopTimer()
|
private void StopTimer()
|
||||||
{
|
{
|
||||||
m_timerStopped = true;
|
lock (m_frames)
|
||||||
KeyframeTimer.Remove(this);
|
m_timerStopped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data)
|
public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data)
|
||||||
|
@ -427,19 +430,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_running = false;
|
|
||||||
StopTimer();
|
StopTimer();
|
||||||
|
m_running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
|
StopTimer();
|
||||||
m_running = false;
|
m_running = false;
|
||||||
m_isCrossing = false;
|
m_isCrossing = false;
|
||||||
m_waitingCrossing = false;
|
m_waitingCrossing = false;
|
||||||
|
|
||||||
StopTimer();
|
|
||||||
|
|
||||||
m_basePosition = m_group.AbsolutePosition;
|
m_basePosition = m_group.AbsolutePosition;
|
||||||
m_baseRotation = m_group.GroupRotation;
|
m_baseRotation = m_group.GroupRotation;
|
||||||
|
|
||||||
|
@ -452,14 +454,34 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public void Pause()
|
public void Pause()
|
||||||
{
|
{
|
||||||
m_running = false;
|
|
||||||
StopTimer();
|
StopTimer();
|
||||||
|
m_running = false;
|
||||||
|
|
||||||
m_group.RootPart.Velocity = Vector3.Zero;
|
m_group.RootPart.Velocity = Vector3.Zero;
|
||||||
m_group.RootPart.AngularVelocity = Vector3.Zero;
|
m_group.RootPart.AngularVelocity = Vector3.Zero;
|
||||||
m_group.SendGroupRootTerseUpdate();
|
m_group.SendGroupRootTerseUpdate();
|
||||||
// m_group.RootPart.ScheduleTerseUpdate();
|
// m_group.RootPart.ScheduleTerseUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Suspend()
|
||||||
|
{
|
||||||
|
lock (m_frames)
|
||||||
|
{
|
||||||
|
if (m_timerStopped)
|
||||||
|
return;
|
||||||
|
m_timerStopped = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Resume()
|
||||||
|
{
|
||||||
|
lock (m_frames)
|
||||||
|
{
|
||||||
|
if (!m_timerStopped)
|
||||||
|
return;
|
||||||
|
if (m_running && !m_waitingCrossing)
|
||||||
|
StartTimer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetNextList()
|
private void GetNextList()
|
||||||
|
@ -550,6 +572,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
pos = (Vector3)k.Position;
|
pos = (Vector3)k.Position;
|
||||||
rot = (Quaternion)k.Rotation;
|
rot = (Quaternion)k.Rotation;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_basePosition = pos;
|
m_basePosition = pos;
|
||||||
|
@ -560,6 +583,35 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnTimer(double tickDuration)
|
public void OnTimer(double tickDuration)
|
||||||
|
{
|
||||||
|
if (!Monitor.TryEnter(m_frames))
|
||||||
|
return;
|
||||||
|
if (m_timerStopped)
|
||||||
|
KeyframeTimer.Remove(this);
|
||||||
|
else
|
||||||
|
DoOnTimer(tickDuration);
|
||||||
|
Monitor.Exit(m_frames);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Done()
|
||||||
|
{
|
||||||
|
KeyframeTimer.Remove(this);
|
||||||
|
m_timerStopped = true;
|
||||||
|
m_running = false;
|
||||||
|
m_isCrossing = false;
|
||||||
|
m_waitingCrossing = false;
|
||||||
|
|
||||||
|
m_basePosition = m_group.AbsolutePosition;
|
||||||
|
m_baseRotation = m_group.GroupRotation;
|
||||||
|
|
||||||
|
m_group.RootPart.Velocity = Vector3.Zero;
|
||||||
|
m_group.RootPart.AngularVelocity = Vector3.Zero;
|
||||||
|
m_group.SendGroupRootTerseUpdate();
|
||||||
|
// m_group.RootPart.ScheduleTerseUpdate();
|
||||||
|
m_frames.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoOnTimer(double tickDuration)
|
||||||
{
|
{
|
||||||
if (m_skipLoops > 0)
|
if (m_skipLoops > 0)
|
||||||
{
|
{
|
||||||
|
@ -567,8 +619,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_timerStopped) // trap events still in air even after a timer.stop
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_group == null)
|
if (m_group == null)
|
||||||
return;
|
return;
|
||||||
|
@ -608,7 +658,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
if (m_frames.Count == 0)
|
if (m_frames.Count == 0)
|
||||||
{
|
{
|
||||||
Stop();
|
Done();
|
||||||
Scene scene = m_group.Scene;
|
Scene scene = m_group.Scene;
|
||||||
|
|
||||||
IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
|
IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
|
||||||
|
@ -707,11 +757,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
if (angle > 0.01f)
|
if (angle > 0.01f)
|
||||||
*/
|
*/
|
||||||
if(Math.Abs(step.X - current.X) > 0.001f
|
if (Math.Abs(step.X - current.X) > 0.001f
|
||||||
|| Math.Abs(step.Y - current.Y) > 0.001f
|
|| Math.Abs(step.Y - current.Y) > 0.001f
|
||||||
|| Math.Abs(step.Z - current.Z) > 0.001f)
|
|| Math.Abs(step.Z - current.Z) > 0.001f)
|
||||||
// assuming w is a dependente var
|
// assuming w is a dependente var
|
||||||
|
|
||||||
{
|
{
|
||||||
// m_group.UpdateGroupRotationR(step);
|
// m_group.UpdateGroupRotationR(step);
|
||||||
m_group.RootPart.RotationOffset = step;
|
m_group.RootPart.RotationOffset = step;
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace OpenSim.Region.Physics.Manager
|
||||||
{
|
{
|
||||||
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod);
|
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod);
|
||||||
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical);
|
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical);
|
||||||
|
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex, bool forOde);
|
||||||
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache, bool convex, bool forOde);
|
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache, bool convex, bool forOde);
|
||||||
IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex);
|
IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex);
|
||||||
void ReleaseMesh(IMesh mesh);
|
void ReleaseMesh(IMesh mesh);
|
||||||
|
|
|
@ -64,20 +64,20 @@ namespace OpenSim.Region.Physics.Manager
|
||||||
{
|
{
|
||||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
|
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
|
||||||
{
|
{
|
||||||
return CreateMesh(primName, primShape, size, lod, false, false);
|
return CreateMesh(primName, primShape, size, lod, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache, bool convex,bool forOde)
|
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache, bool convex, bool forOde)
|
||||||
|
{
|
||||||
|
return CreateMesh(primName, primShape, size, lod, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex,bool forOde)
|
||||||
{
|
{
|
||||||
return CreateMesh(primName, primShape, size, lod, false);
|
return CreateMesh(primName, primShape, size, lod, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
|
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
|
||||||
{
|
|
||||||
return CreateMesh(primName, primShape, size, lod, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache)
|
|
||||||
{
|
{
|
||||||
// Remove the reference to the encoded JPEG2000 data so it can be GCed
|
// Remove the reference to the encoded JPEG2000 data so it can be GCed
|
||||||
primShape.SculptData = OpenMetaverse.Utils.EmptyBytes;
|
primShape.SculptData = OpenMetaverse.Utils.EmptyBytes;
|
||||||
|
|
|
@ -918,6 +918,11 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
return CreateMesh(primName, primShape, size, lod, isPhysical, true);
|
return CreateMesh(primName, primShape, size, lod, isPhysical, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex, bool forOde)
|
||||||
|
{
|
||||||
|
return CreateMesh(primName, primShape, size, lod, isPhysical, true);
|
||||||
|
}
|
||||||
|
|
||||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache)
|
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache)
|
||||||
{
|
{
|
||||||
#if SPAM
|
#if SPAM
|
||||||
|
|
|
@ -500,7 +500,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
m_pidControllerActive = true;
|
m_pidControllerActive = true;
|
||||||
|
|
||||||
m_tainted_CAPSULE_LENGTH = (size.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
|
m_tainted_CAPSULE_LENGTH = (size.Z) - CAPSULE_RADIUS * 2.0f;
|
||||||
// m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH);
|
// m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -256,9 +256,9 @@ public class Vertex : IComparable<Vertex>
|
||||||
// settings your machine works with. Unusable for a machine readable file format :-(
|
// settings your machine works with. Unusable for a machine readable file format :-(
|
||||||
NumberFormatInfo nfi = new NumberFormatInfo();
|
NumberFormatInfo nfi = new NumberFormatInfo();
|
||||||
nfi.NumberDecimalSeparator = ".";
|
nfi.NumberDecimalSeparator = ".";
|
||||||
nfi.NumberDecimalDigits = 3;
|
nfi.NumberDecimalDigits = 6;
|
||||||
|
|
||||||
String s1 = X.ToString("N2", nfi) + " " + Y.ToString("N2", nfi) + " " + Z.ToString("N2", nfi);
|
String s1 = X.ToString(nfi) + " " + Y.ToString(nfi) + " " + Z.ToString(nfi);
|
||||||
|
|
||||||
return s1;
|
return s1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,34 +205,21 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private float fRound(float f)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if (f == 0f)
|
|
||||||
return f;
|
|
||||||
else if (f > 0f)
|
|
||||||
i = (int)(1e5f * f + 0.5f);
|
|
||||||
else
|
|
||||||
i = (int)(1e5f * f - 0.5f);
|
|
||||||
|
|
||||||
return ((float)i * 1e-5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Add(Triangle triangle)
|
public void Add(Triangle triangle)
|
||||||
{
|
{
|
||||||
if (m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero)
|
if (m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero)
|
||||||
throw new NotSupportedException("Attempt to Add to a pinned Mesh");
|
throw new NotSupportedException("Attempt to Add to a pinned Mesh");
|
||||||
|
|
||||||
// round down
|
|
||||||
triangle.v1.X = fRound(triangle.v1.X);
|
triangle.v1.X = (float)Math.Round(triangle.v1.X, 6);
|
||||||
triangle.v1.Y = fRound(triangle.v1.Y);
|
triangle.v1.Y = (float)Math.Round(triangle.v1.Y, 6);
|
||||||
triangle.v1.Z = fRound(triangle.v1.Z);
|
triangle.v1.Z = (float)Math.Round(triangle.v1.Z, 6);
|
||||||
triangle.v2.X = fRound(triangle.v2.X);
|
triangle.v2.X = (float)Math.Round(triangle.v2.X, 6);
|
||||||
triangle.v2.Y = fRound(triangle.v2.Y);
|
triangle.v2.Y = (float)Math.Round(triangle.v2.Y, 6);
|
||||||
triangle.v2.Z = fRound(triangle.v2.Z);
|
triangle.v2.Z = (float)Math.Round(triangle.v2.Z, 6);
|
||||||
triangle.v3.X = fRound(triangle.v3.X);
|
triangle.v3.X = (float)Math.Round(triangle.v3.X, 6);
|
||||||
triangle.v3.Y = fRound(triangle.v3.Y);
|
triangle.v3.Y = (float)Math.Round(triangle.v3.Y, 6);
|
||||||
triangle.v3.Z = fRound(triangle.v3.Z);
|
triangle.v3.Z = (float)Math.Round(triangle.v3.Z, 6);
|
||||||
|
|
||||||
if ((triangle.v1.X == triangle.v2.X && triangle.v1.Y == triangle.v2.Y && triangle.v1.Z == triangle.v2.Z)
|
if ((triangle.v1.X == triangle.v2.X && triangle.v1.Y == triangle.v2.Y && triangle.v1.Z == triangle.v2.Z)
|
||||||
|| (triangle.v1.X == triangle.v3.X && triangle.v1.Y == triangle.v3.Y && triangle.v1.Z == triangle.v3.Z)
|
|| (triangle.v1.X == triangle.v3.X && triangle.v1.Y == triangle.v3.Y && triangle.v1.Z == triangle.v3.Z)
|
||||||
|
|
|
@ -816,15 +816,31 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
|
|
||||||
float profileBegin = (float)primShape.ProfileBegin * 2.0e-5f;
|
float profileBegin = (float)primShape.ProfileBegin * 2.0e-5f;
|
||||||
float profileEnd = 1.0f - (float)primShape.ProfileEnd * 2.0e-5f;
|
float profileEnd = 1.0f - (float)primShape.ProfileEnd * 2.0e-5f;
|
||||||
|
|
||||||
|
if (profileBegin < 0.0f)
|
||||||
|
profileBegin = 0.0f;
|
||||||
|
|
||||||
|
if (profileEnd < 0.02f)
|
||||||
|
profileEnd = 0.02f;
|
||||||
|
else if (profileEnd > 1.0f)
|
||||||
|
profileEnd = 1.0f;
|
||||||
|
|
||||||
|
if (profileBegin >= profileEnd)
|
||||||
|
profileBegin = profileEnd - 0.02f;
|
||||||
|
|
||||||
float profileHollow = (float)primShape.ProfileHollow * 2.0e-5f;
|
float profileHollow = (float)primShape.ProfileHollow * 2.0e-5f;
|
||||||
if (profileHollow > 0.95f)
|
if (profileHollow > 0.95f)
|
||||||
profileHollow = 0.95f;
|
profileHollow = 0.95f;
|
||||||
|
|
||||||
int sides = 4;
|
int sides = 4;
|
||||||
LevelOfDetail iLOD = (LevelOfDetail)lod;
|
LevelOfDetail iLOD = (LevelOfDetail)lod;
|
||||||
if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
|
byte profshape = (byte)(primShape.ProfileCurve & 0x07);
|
||||||
|
|
||||||
|
if (profshape == (byte)ProfileShape.EquilateralTriangle
|
||||||
|
|| profshape == (byte)ProfileShape.IsometricTriangle
|
||||||
|
|| profshape == (byte)ProfileShape.RightTriangle)
|
||||||
sides = 3;
|
sides = 3;
|
||||||
else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
|
else if (profshape == (byte)ProfileShape.Circle)
|
||||||
{
|
{
|
||||||
switch (iLOD)
|
switch (iLOD)
|
||||||
{
|
{
|
||||||
|
@ -835,7 +851,7 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
default: sides = 24; break;
|
default: sides = 24; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
|
else if (profshape == (byte)ProfileShape.HalfCircle)
|
||||||
{ // half circle, prim is a sphere
|
{ // half circle, prim is a sphere
|
||||||
switch (iLOD)
|
switch (iLOD)
|
||||||
{
|
{
|
||||||
|
@ -865,7 +881,12 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
else if (primShape.HollowShape == HollowShape.Square)
|
else if (primShape.HollowShape == HollowShape.Square)
|
||||||
hollowSides = 4;
|
hollowSides = 4;
|
||||||
else if (primShape.HollowShape == HollowShape.Triangle)
|
else if (primShape.HollowShape == HollowShape.Triangle)
|
||||||
hollowSides = 3;
|
{
|
||||||
|
if (profshape == (byte)ProfileShape.HalfCircle)
|
||||||
|
hollowSides = 6;
|
||||||
|
else
|
||||||
|
hollowSides = 3;
|
||||||
|
}
|
||||||
|
|
||||||
primMesh = new PrimMesh(sides, profileBegin, profileEnd, profileHollow, hollowSides);
|
primMesh = new PrimMesh(sides, profileBegin, profileEnd, profileHollow, hollowSides);
|
||||||
|
|
||||||
|
@ -880,17 +901,11 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
|
|
||||||
if (primShape.PathCurve == (byte)Extrusion.Straight || primShape.PathCurve == (byte) Extrusion.Flexible)
|
if (primShape.PathCurve == (byte)Extrusion.Straight || primShape.PathCurve == (byte) Extrusion.Flexible)
|
||||||
{
|
{
|
||||||
primMesh.twistBegin = primShape.PathTwistBegin * 18 / 10;
|
primMesh.twistBegin = (primShape.PathTwistBegin * 18) / 10;
|
||||||
primMesh.twistEnd = primShape.PathTwist * 18 / 10;
|
primMesh.twistEnd = (primShape.PathTwist * 18) / 10;
|
||||||
primMesh.taperX = pathScaleX;
|
primMesh.taperX = pathScaleX;
|
||||||
primMesh.taperY = pathScaleY;
|
primMesh.taperY = pathScaleY;
|
||||||
|
|
||||||
if (profileBegin < 0.0f || profileBegin >= profileEnd || profileEnd > 1.0f)
|
|
||||||
{
|
|
||||||
ReportPrimError("*** CORRUPT PRIM!! ***", primName, primMesh);
|
|
||||||
if (profileBegin < 0.0f) profileBegin = 0.0f;
|
|
||||||
if (profileEnd > 1.0f) profileEnd = 1.0f;
|
|
||||||
}
|
|
||||||
#if SPAM
|
#if SPAM
|
||||||
m_log.Debug("****** PrimMesh Parameters (Linear) ******\n" + primMesh.ParamsToDisplayString());
|
m_log.Debug("****** PrimMesh Parameters (Linear) ******\n" + primMesh.ParamsToDisplayString());
|
||||||
#endif
|
#endif
|
||||||
|
@ -911,17 +926,11 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
primMesh.radius = 0.01f * primShape.PathRadiusOffset;
|
primMesh.radius = 0.01f * primShape.PathRadiusOffset;
|
||||||
primMesh.revolutions = 1.0f + 0.015f * primShape.PathRevolutions;
|
primMesh.revolutions = 1.0f + 0.015f * primShape.PathRevolutions;
|
||||||
primMesh.skew = 0.01f * primShape.PathSkew;
|
primMesh.skew = 0.01f * primShape.PathSkew;
|
||||||
primMesh.twistBegin = primShape.PathTwistBegin * 36 / 10;
|
primMesh.twistBegin = (primShape.PathTwistBegin * 36) / 10;
|
||||||
primMesh.twistEnd = primShape.PathTwist * 36 / 10;
|
primMesh.twistEnd = (primShape.PathTwist * 36) / 10;
|
||||||
primMesh.taperX = primShape.PathTaperX * 0.01f;
|
primMesh.taperX = primShape.PathTaperX * 0.01f;
|
||||||
primMesh.taperY = primShape.PathTaperY * 0.01f;
|
primMesh.taperY = primShape.PathTaperY * 0.01f;
|
||||||
|
|
||||||
if (profileBegin < 0.0f || profileBegin >= profileEnd || profileEnd > 1.0f)
|
|
||||||
{
|
|
||||||
ReportPrimError("*** CORRUPT PRIM!! ***", primName, primMesh);
|
|
||||||
if (profileBegin < 0.0f) profileBegin = 0.0f;
|
|
||||||
if (profileEnd > 1.0f) profileEnd = 1.0f;
|
|
||||||
}
|
|
||||||
#if SPAM
|
#if SPAM
|
||||||
m_log.Debug("****** PrimMesh Parameters (Circular) ******\n" + primMesh.ParamsToDisplayString());
|
m_log.Debug("****** PrimMesh Parameters (Circular) ******\n" + primMesh.ParamsToDisplayString());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1031,12 +1040,17 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
|
|
||||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
|
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
|
||||||
{
|
{
|
||||||
return CreateMesh(primName, primShape, size, lod, false,false,false,false);
|
return CreateMesh(primName, primShape, size, lod, false,false,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
|
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
|
||||||
{
|
{
|
||||||
return CreateMesh(primName, primShape, size, lod, false,false,false,false);
|
return CreateMesh(primName, primShape, size, lod, false,false,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache, bool convex, bool forOde)
|
||||||
|
{
|
||||||
|
return CreateMesh(primName, primShape, size, lod, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex)
|
public IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex)
|
||||||
|
@ -1080,7 +1094,7 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
|
|
||||||
private static Vector3 m_MeshUnitSize = new Vector3(1.0f, 1.0f, 1.0f);
|
private static Vector3 m_MeshUnitSize = new Vector3(1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache, bool convex, bool forOde)
|
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex, bool forOde)
|
||||||
{
|
{
|
||||||
#if SPAM
|
#if SPAM
|
||||||
m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName);
|
m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -95,10 +95,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
private float m_feetOffset = 0;
|
private float m_feetOffset = 0;
|
||||||
private float feetOff = 0;
|
private float feetOff = 0;
|
||||||
private float feetSZ = 0.5f;
|
|
||||||
const float feetScale = 0.8f;
|
|
||||||
private float boneOff = 0;
|
private float boneOff = 0;
|
||||||
private float m_lastVelocitySqr = 0;
|
|
||||||
|
|
||||||
public float walkDivisor = 1.3f;
|
public float walkDivisor = 1.3f;
|
||||||
public float runDivisor = 0.8f;
|
public float runDivisor = 0.8f;
|
||||||
|
@ -110,7 +107,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
private bool _zeroFlag = false;
|
private bool _zeroFlag = false;
|
||||||
|
|
||||||
private int m_requestedUpdateFrequency = 0;
|
|
||||||
private uint m_localID = 0;
|
private uint m_localID = 0;
|
||||||
public bool m_returnCollisions = false;
|
public bool m_returnCollisions = false;
|
||||||
// taints and their non-tainted counterparts
|
// taints and their non-tainted counterparts
|
||||||
|
@ -127,7 +123,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
int m_colliderfilter = 0;
|
int m_colliderfilter = 0;
|
||||||
int m_colliderGroundfilter = 0;
|
int m_colliderGroundfilter = 0;
|
||||||
int m_colliderObjectfilter = 0;
|
int m_colliderObjectfilter = 0;
|
||||||
bool m_collisionException = false;
|
|
||||||
|
|
||||||
// Default we're a Character
|
// Default we're a Character
|
||||||
private CollisionCategories m_collisionCategories = (CollisionCategories.Character);
|
private CollisionCategories m_collisionCategories = (CollisionCategories.Character);
|
||||||
|
@ -140,9 +135,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// we do land collisions not ode | CollisionCategories.Land);
|
// we do land collisions not ode | CollisionCategories.Land);
|
||||||
public IntPtr Body = IntPtr.Zero;
|
public IntPtr Body = IntPtr.Zero;
|
||||||
private OdeScene _parent_scene;
|
private OdeScene _parent_scene;
|
||||||
private IntPtr topbox = IntPtr.Zero;
|
private IntPtr capsule = IntPtr.Zero;
|
||||||
private IntPtr midbox = IntPtr.Zero;
|
|
||||||
private IntPtr feetbox = IntPtr.Zero;
|
|
||||||
private IntPtr bbox = IntPtr.Zero;
|
private IntPtr bbox = IntPtr.Zero;
|
||||||
public IntPtr collider = IntPtr.Zero;
|
public IntPtr collider = IntPtr.Zero;
|
||||||
|
|
||||||
|
@ -150,9 +143,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public d.Mass ShellMass;
|
public d.Mass ShellMass;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int m_eventsubscription = 0;
|
public int m_eventsubscription = 0;
|
||||||
private int m_cureventsubscription = 0;
|
private int m_cureventsubscription = 0;
|
||||||
private CollisionEventUpdate CollisionEventsThisFrame = null;
|
private CollisionEventUpdate CollisionEventsThisFrame = null;
|
||||||
|
@ -214,8 +204,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// force lower density for testing
|
// force lower density for testing
|
||||||
m_density = 3.0f;
|
m_density = 3.0f;
|
||||||
|
|
||||||
m_density *= 1.4f; // scale to have mass similar to capsule
|
|
||||||
|
|
||||||
mu = parent_scene.AvatarFriction;
|
mu = parent_scene.AvatarFriction;
|
||||||
|
|
||||||
walkDivisor = walk_divisor;
|
walkDivisor = walk_divisor;
|
||||||
|
@ -704,58 +692,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
AddChange(changes.Momentum, momentum);
|
AddChange(changes.Momentum, momentum);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ajustCollider()
|
|
||||||
{
|
|
||||||
float vq = _velocity.LengthSquared();
|
|
||||||
if (m_lastVelocitySqr != vq)
|
|
||||||
{
|
|
||||||
m_lastVelocitySqr = vq;
|
|
||||||
if (vq > 100.0f)
|
|
||||||
{
|
|
||||||
Vector3 off = _velocity;
|
|
||||||
float t = 0.5f * timeStep;
|
|
||||||
off = off * t;
|
|
||||||
d.Quaternion qtmp;
|
|
||||||
d.GeomCopyQuaternion(bbox, out qtmp);
|
|
||||||
Quaternion q;
|
|
||||||
q.X = qtmp.X;
|
|
||||||
q.Y = qtmp.Y;
|
|
||||||
q.Z = qtmp.Z;
|
|
||||||
q.W = qtmp.W;
|
|
||||||
off *= Quaternion.Conjugate(q);
|
|
||||||
|
|
||||||
d.GeomSetOffsetPosition(bbox, off.X, off.Y, off.Z);
|
|
||||||
|
|
||||||
off.X = 2.0f * (m_size.X + Math.Abs(off.X));
|
|
||||||
off.Y = 2.0f * (m_size.Y + Math.Abs(off.Y));
|
|
||||||
off.Z = m_size.Z + 2.0f * Math.Abs(off.Z);
|
|
||||||
d.GeomBoxSetLengths(bbox, off.X, off.Y, off.Z);
|
|
||||||
|
|
||||||
d.GeomSetCategoryBits(bbox, (uint)m_collisionCategories);
|
|
||||||
d.GeomSetCollideBits(bbox, (uint)m_collisionFlags);
|
|
||||||
d.GeomSetCategoryBits(topbox, 0);
|
|
||||||
d.GeomSetCollideBits(topbox, 0);
|
|
||||||
d.GeomSetCategoryBits(midbox, 0);
|
|
||||||
d.GeomSetCollideBits(midbox, 0);
|
|
||||||
d.GeomSetCategoryBits(feetbox, 0);
|
|
||||||
d.GeomSetCollideBits(feetbox, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
d.GeomSetCategoryBits(bbox, 0);
|
|
||||||
d.GeomSetCollideBits(bbox, 0);
|
|
||||||
d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories);
|
|
||||||
d.GeomSetCollideBits(topbox, (uint)m_collisionFlags);
|
|
||||||
d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories);
|
|
||||||
d.GeomSetCollideBits(midbox, (uint)m_collisionFlags);
|
|
||||||
d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories);
|
|
||||||
d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags);
|
|
||||||
}
|
|
||||||
uint cat1 = d.GeomGetCategoryBits(bbox);
|
|
||||||
uint col1 = d.GeomGetCollideBits(bbox);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
|
private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
|
||||||
{
|
{
|
||||||
|
@ -764,37 +700,14 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
float sy = m_size.Y;
|
float sy = m_size.Y;
|
||||||
float sz = m_size.Z;
|
float sz = m_size.Z;
|
||||||
|
|
||||||
float topsx = sx * 0.9f;
|
float bot = -sz * 0.5f + m_feetOffset;
|
||||||
float midsx = sx;
|
boneOff = bot + 0.3f;
|
||||||
float feetsx = sx * feetScale;
|
|
||||||
float bonesx = sx * 0.2f;
|
|
||||||
|
|
||||||
float topsy = sy * 0.4f;
|
|
||||||
float midsy = sy;
|
|
||||||
float feetsy = sy * feetScale * 0.8f;
|
|
||||||
float bonesy = feetsy * 0.2f;
|
|
||||||
|
|
||||||
float topsz = sz * 0.15f;
|
|
||||||
float feetsz = sz * 0.45f;
|
float feetsz = sz * 0.45f;
|
||||||
if (feetsz > 0.6f)
|
if (feetsz > 0.6f)
|
||||||
feetsz = 0.6f;
|
feetsz = 0.6f;
|
||||||
|
|
||||||
float midsz = sz - topsz - feetsz;
|
feetOff = bot + feetsz;
|
||||||
float bonesz = sz;
|
|
||||||
|
|
||||||
float bot = -sz * 0.5f + m_feetOffset;
|
|
||||||
|
|
||||||
boneOff = bot + 0.3f;
|
|
||||||
|
|
||||||
float feetz = bot + feetsz * 0.5f;
|
|
||||||
bot += feetsz;
|
|
||||||
|
|
||||||
feetOff = bot;
|
|
||||||
feetSZ = feetsz;
|
|
||||||
|
|
||||||
float midz = bot + midsz * 0.5f;
|
|
||||||
bot += midsz;
|
|
||||||
float topz = bot + topsz * 0.5f;
|
|
||||||
|
|
||||||
_parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
|
_parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
|
||||||
|
|
||||||
|
@ -805,9 +718,13 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
d.GeomSetCategoryBits(collider, (uint)m_collisionCategories);
|
d.GeomSetCategoryBits(collider, (uint)m_collisionCategories);
|
||||||
d.GeomSetCollideBits(collider, (uint)m_collisionFlags);
|
d.GeomSetCollideBits(collider, (uint)m_collisionFlags);
|
||||||
|
|
||||||
feetbox = d.CreateBox(collider, feetsx, feetsy, feetsz);
|
float r = m_size.X;
|
||||||
midbox = d.CreateBox(collider, midsx, midsy, midsz);
|
if (m_size.Y > r)
|
||||||
topbox = d.CreateBox(collider, topsx, topsy, topsz);
|
r = m_size.Y;
|
||||||
|
float l = m_size.Z - r;
|
||||||
|
r *= 0.5f;
|
||||||
|
capsule = d.CreateCapsule(collider, r, l);
|
||||||
|
|
||||||
bbox = d.CreateBox(collider, m_size.X, m_size.Y, m_size.Z);
|
bbox = d.CreateBox(collider, m_size.X, m_size.Y, m_size.Z);
|
||||||
|
|
||||||
m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass
|
m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass
|
||||||
|
@ -820,12 +737,10 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
Body = d.BodyCreate(_parent_scene.world);
|
Body = d.BodyCreate(_parent_scene.world);
|
||||||
|
|
||||||
_zeroFlag = false;
|
_zeroFlag = false;
|
||||||
m_collisionException = false;
|
|
||||||
m_pidControllerActive = true;
|
m_pidControllerActive = true;
|
||||||
m_freemove = false;
|
m_freemove = false;
|
||||||
|
|
||||||
_velocity = Vector3.Zero;
|
_velocity = Vector3.Zero;
|
||||||
m_lastVelocitySqr = 0;
|
|
||||||
|
|
||||||
d.BodySetAutoDisableFlag(Body, false);
|
d.BodySetAutoDisableFlag(Body, false);
|
||||||
d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
|
d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
|
||||||
|
@ -835,17 +750,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
_position.Z = npositionZ;
|
_position.Z = npositionZ;
|
||||||
|
|
||||||
d.BodySetMass(Body, ref ShellMass);
|
d.BodySetMass(Body, ref ShellMass);
|
||||||
d.GeomSetBody(feetbox, Body);
|
|
||||||
d.GeomSetBody(midbox, Body);
|
|
||||||
d.GeomSetBody(topbox, Body);
|
|
||||||
d.GeomSetBody(bbox, Body);
|
d.GeomSetBody(bbox, Body);
|
||||||
|
d.GeomSetBody(capsule, Body);
|
||||||
d.GeomSetOffsetPosition(feetbox, 0, 0, feetz);
|
|
||||||
d.GeomSetOffsetPosition(midbox, 0, 0, midz);
|
|
||||||
d.GeomSetOffsetPosition(topbox, 0, 0, topz);
|
|
||||||
|
|
||||||
ajustCollider();
|
|
||||||
|
|
||||||
|
|
||||||
// The purpose of the AMotor here is to keep the avatar's physical
|
// The purpose of the AMotor here is to keep the avatar's physical
|
||||||
// surrogate from rotating while moving
|
// surrogate from rotating while moving
|
||||||
|
@ -906,26 +813,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
//kill the Geoms
|
//kill the Geoms
|
||||||
if (topbox != IntPtr.Zero)
|
if (capsule != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
_parent_scene.actor_name_map.Remove(topbox);
|
_parent_scene.actor_name_map.Remove(capsule);
|
||||||
_parent_scene.waitForSpaceUnlock(collider);
|
_parent_scene.waitForSpaceUnlock(collider);
|
||||||
d.GeomDestroy(topbox);
|
d.GeomDestroy(capsule);
|
||||||
topbox = IntPtr.Zero;
|
capsule = IntPtr.Zero;
|
||||||
}
|
|
||||||
if (midbox != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
_parent_scene.actor_name_map.Remove(midbox);
|
|
||||||
_parent_scene.waitForSpaceUnlock(collider);
|
|
||||||
d.GeomDestroy(midbox);
|
|
||||||
midbox = IntPtr.Zero;
|
|
||||||
}
|
|
||||||
if (feetbox != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
_parent_scene.actor_name_map.Remove(feetbox);
|
|
||||||
_parent_scene.waitForSpaceUnlock(collider);
|
|
||||||
d.GeomDestroy(feetbox);
|
|
||||||
feetbox = IntPtr.Zero;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bbox != IntPtr.Zero)
|
if (bbox != IntPtr.Zero)
|
||||||
|
@ -981,163 +874,21 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact, ref bool feetcollision)
|
public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact, ref bool feetcollision)
|
||||||
{
|
{
|
||||||
feetcollision = false;
|
feetcollision = false;
|
||||||
if (m_collisionException)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Vector3 offset;
|
Vector3 offset;
|
||||||
|
|
||||||
if (me == bbox) // if moving fast
|
|
||||||
{
|
|
||||||
// force a full inelastic collision
|
|
||||||
m_collisionException = true;
|
|
||||||
|
|
||||||
offset = m_size * m_orientation2D;
|
|
||||||
|
|
||||||
offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth;
|
|
||||||
offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth;
|
|
||||||
offset.Z = (float)Math.Abs(offset.Z) * 0.5f + contact.depth;
|
|
||||||
|
|
||||||
if (reverse)
|
|
||||||
{
|
|
||||||
offset.X *= -contact.normal.X;
|
|
||||||
offset.Y *= -contact.normal.Y;
|
|
||||||
offset.Z *= -contact.normal.Z;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
offset.X *= contact.normal.X;
|
|
||||||
offset.Y *= contact.normal.Y;
|
|
||||||
offset.Z *= contact.normal.Z;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset.X += contact.pos.X;
|
|
||||||
offset.Y += contact.pos.Y;
|
|
||||||
offset.Z += contact.pos.Z;
|
|
||||||
|
|
||||||
//_position = offset;
|
|
||||||
//return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset.X = contact.pos.X - _position.X;
|
offset.X = contact.pos.X - _position.X;
|
||||||
offset.Y = contact.pos.Y - _position.Y;
|
offset.Y = contact.pos.Y - _position.Y;
|
||||||
|
|
||||||
if (me == topbox)
|
if (me == capsule)
|
||||||
{
|
|
||||||
offset.Z = contact.pos.Z - _position.Z;
|
|
||||||
|
|
||||||
offset.Normalize();
|
|
||||||
|
|
||||||
if (reverse)
|
|
||||||
{
|
|
||||||
contact.normal.X = offset.X;
|
|
||||||
contact.normal.Y = offset.Y;
|
|
||||||
contact.normal.Z = offset.Z;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
contact.normal.X = -offset.X;
|
|
||||||
contact.normal.Y = -offset.Y;
|
|
||||||
contact.normal.Z = -offset.Z;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (me == midbox)
|
|
||||||
{
|
|
||||||
if (Math.Abs(contact.normal.Z) > 0.95f)
|
|
||||||
{
|
|
||||||
offset.Z = contact.pos.Z - _position.Z;
|
|
||||||
offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth;
|
|
||||||
offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth;
|
|
||||||
offset.Z = (float)Math.Abs(offset.Z) * 0.5f + contact.depth;
|
|
||||||
|
|
||||||
if (reverse)
|
|
||||||
{
|
|
||||||
offset.X *= -contact.normal.X;
|
|
||||||
offset.Y *= -contact.normal.Y;
|
|
||||||
offset.Z *= -contact.normal.Z;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
offset.X *= contact.normal.X;
|
|
||||||
offset.Y *= contact.normal.Y;
|
|
||||||
offset.Z *= contact.normal.Z;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset.X += contact.pos.X;
|
|
||||||
offset.Y += contact.pos.Y;
|
|
||||||
offset.Z += contact.pos.Z;
|
|
||||||
_position = offset;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
offset.Z = contact.normal.Z;
|
|
||||||
|
|
||||||
offset.Normalize();
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (reverse)
|
|
||||||
{
|
|
||||||
contact.normal.X = offset.X;
|
|
||||||
contact.normal.Y = offset.Y;
|
|
||||||
contact.normal.Z = offset.Z;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
contact.normal.X = -offset.X;
|
|
||||||
contact.normal.Y = -offset.Y;
|
|
||||||
contact.normal.Z = -offset.Z;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//_position.Z = offset.Z;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (me == feetbox)
|
|
||||||
{
|
{
|
||||||
float h = contact.pos.Z - _position.Z;
|
float h = contact.pos.Z - _position.Z;
|
||||||
|
offset.Z = h - feetOff;
|
||||||
// Only do this if the normal is sufficiently pointing in the 'up' direction
|
|
||||||
if (Math.Abs(contact.normal.Z) > 0.95f)
|
|
||||||
{
|
|
||||||
// We Only want to do this if we're sunk into the object a bit and we're stuck and we're trying to move and feetcollision is false
|
|
||||||
if ((contact.depth > 0.0010f && _velocity.X == 0f && _velocity.Y == 0 && _velocity.Z == 0)
|
|
||||||
&& (_target_velocity.X > 0 || _target_velocity.Y > 0 || _target_velocity.Z > 0)
|
|
||||||
&& (!feetcollision) )
|
|
||||||
{
|
|
||||||
m_collisionException = true; // Stop looping, do this only once not X times Contacts
|
|
||||||
_position.Z += contact.depth + 0.01f; // Move us Up the amount that we sank in, and add 0.01 meters to gently lift avatar up.
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contact.normal.Z > 0)
|
|
||||||
contact.normal.Z = 1.0f;
|
|
||||||
else
|
|
||||||
contact.normal.Z = -1.0f;
|
|
||||||
contact.normal.X = 0.0f;
|
|
||||||
contact.normal.Y = 0.0f;
|
|
||||||
feetcollision = true;
|
|
||||||
if (h < boneOff)
|
|
||||||
IsColliding = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset.Z = h - feetOff; // distance from top of feetbox
|
|
||||||
|
|
||||||
if (offset.Z > 0)
|
if (offset.Z > 0)
|
||||||
return false;
|
return true;
|
||||||
|
|
||||||
if (offset.Z > -0.01)
|
offset.Normalize();
|
||||||
{
|
|
||||||
offset.X = 0;
|
|
||||||
offset.Y = 0;
|
|
||||||
offset.Z = -1.0f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
offset.Normalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reverse)
|
if (reverse)
|
||||||
{
|
{
|
||||||
|
@ -1171,23 +922,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
if (Body == IntPtr.Zero)
|
if (Body == IntPtr.Zero)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_collisionException)
|
|
||||||
{
|
|
||||||
d.BodySetPosition(Body,_position.X, _position.Y, _position.Z);
|
|
||||||
d.BodySetLinearVel(Body, 0, 0, 0);
|
|
||||||
|
|
||||||
float v = _velocity.Length();
|
|
||||||
if (v != 0)
|
|
||||||
{
|
|
||||||
v = 5.0f / v;
|
|
||||||
_velocity = _velocity * v;
|
|
||||||
d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
|
|
||||||
}
|
|
||||||
ajustCollider();
|
|
||||||
m_collisionException = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
d.Vector3 dtmp = d.BodyGetPosition(Body);
|
d.Vector3 dtmp = d.BodyGetPosition(Body);
|
||||||
Vector3 localpos = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
|
Vector3 localpos = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
|
||||||
|
|
||||||
|
@ -1263,7 +997,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// colide with land
|
// colide with land
|
||||||
|
|
||||||
d.AABB aabb;
|
d.AABB aabb;
|
||||||
d.GeomGetAABB(feetbox, out aabb);
|
// d.GeomGetAABB(feetbox, out aabb);
|
||||||
|
d.GeomGetAABB(capsule, out aabb);
|
||||||
float chrminZ = aabb.MinZ; ; // move up a bit
|
float chrminZ = aabb.MinZ; ; // move up a bit
|
||||||
Vector3 posch = localpos;
|
Vector3 posch = localpos;
|
||||||
|
|
||||||
|
@ -1489,7 +1224,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
m_rotationalVelocity.Z = dtmp.Z;
|
m_rotationalVelocity.Z = dtmp.Z;
|
||||||
Math.Round(m_rotationalVelocity.Z,3);
|
Math.Round(m_rotationalVelocity.Z,3);
|
||||||
}
|
}
|
||||||
ajustCollider();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void round(ref Vector3 v, int digits)
|
public void round(ref Vector3 v, int digits)
|
||||||
|
@ -1655,10 +1389,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
|
AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
|
||||||
|
|
||||||
_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
|
_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
|
||||||
_parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
|
// _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
|
||||||
_parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
|
// _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
|
||||||
_parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
|
// _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
|
||||||
_parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
|
_parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
|
||||||
|
_parent_scene.actor_name_map[capsule] = (PhysicsActor)this;
|
||||||
_parent_scene.AddCharacter(this);
|
_parent_scene.AddCharacter(this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1714,13 +1449,10 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
|
|
||||||
_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
|
_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
|
||||||
_parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
|
|
||||||
_parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
|
|
||||||
_parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
|
|
||||||
_parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
|
_parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
|
||||||
|
_parent_scene.actor_name_map[capsule] = (PhysicsActor)this;
|
||||||
}
|
}
|
||||||
m_freemove = false;
|
m_freemove = false;
|
||||||
m_collisionException = false;
|
|
||||||
m_pidControllerActive = true;
|
m_pidControllerActive = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1851,7 +1583,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
if (Body != IntPtr.Zero)
|
if (Body != IntPtr.Zero)
|
||||||
d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z);
|
d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z);
|
||||||
ajustCollider();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void donullchange()
|
private void donullchange()
|
||||||
|
|
|
@ -137,6 +137,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
float m_amdampY;
|
float m_amdampY;
|
||||||
float m_amdampZ;
|
float m_amdampZ;
|
||||||
|
|
||||||
|
float m_gravmod;
|
||||||
|
|
||||||
public float FrictionFactor
|
public float FrictionFactor
|
||||||
{
|
{
|
||||||
|
@ -146,6 +147,14 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GravMod
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_gravmod = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public ODEDynamics(OdePrim rootp)
|
public ODEDynamics(OdePrim rootp)
|
||||||
{
|
{
|
||||||
|
@ -153,6 +162,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
_pParentScene = rootPrim._parent_scene;
|
_pParentScene = rootPrim._parent_scene;
|
||||||
m_timestep = _pParentScene.ODE_STEPSIZE;
|
m_timestep = _pParentScene.ODE_STEPSIZE;
|
||||||
m_invtimestep = 1.0f / m_timestep;
|
m_invtimestep = 1.0f / m_timestep;
|
||||||
|
m_gravmod = rootPrim.GravModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoSetVehicle(VehicleData vd)
|
public void DoSetVehicle(VehicleData vd)
|
||||||
|
@ -862,7 +872,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
force.Z += perr;
|
force.Z += perr;
|
||||||
ldampZ *= -curVel.Z;
|
ldampZ *= -curVel.Z;
|
||||||
|
|
||||||
force.Z += _pParentScene.gravityz * (1f - m_VehicleBuoyancy);
|
force.Z += _pParentScene.gravityz * m_gravmod * (1f - m_VehicleBuoyancy);
|
||||||
}
|
}
|
||||||
else // no buoyancy
|
else // no buoyancy
|
||||||
force.Z += _pParentScene.gravityz;
|
force.Z += _pParentScene.gravityz;
|
||||||
|
@ -870,7 +880,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// default gravity and Buoyancy
|
// default gravity and Buoyancy
|
||||||
force.Z += _pParentScene.gravityz * (1f - m_VehicleBuoyancy);
|
force.Z += _pParentScene.gravityz * m_gravmod * (1f - m_VehicleBuoyancy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// linear deflection
|
// linear deflection
|
||||||
|
@ -1065,7 +1075,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (force.X != 0 || force.Y != 0 || force.Z != 0)
|
if (force.X != 0 || force.Y != 0 || force.Z != 0)
|
||||||
{
|
{
|
||||||
force *= dmass.mass;
|
force *= dmass.mass;
|
||||||
|
|
|
@ -448,7 +448,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
repData.meshState = MeshState.needMesh;
|
repData.meshState = MeshState.needMesh;
|
||||||
mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, false, convex, true);
|
mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, convex, true);
|
||||||
if (mesh == null)
|
if (mesh == null)
|
||||||
{
|
{
|
||||||
repData.meshState = MeshState.MeshFailed;
|
repData.meshState = MeshState.MeshFailed;
|
||||||
|
@ -513,7 +513,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
clod = (int)LevelOfDetail.Low;
|
clod = (int)LevelOfDetail.Low;
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, false, convex, true);
|
mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, convex, true);
|
||||||
|
|
||||||
if (mesh == null)
|
if (mesh == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Revision 2011/12 by Ubit Umarov
|
/* Revision 2011/12/13 by Ubit Umarov
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -115,7 +115,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
private int body_autodisable_frames;
|
private int body_autodisable_frames;
|
||||||
public int bodydisablecontrol;
|
public int bodydisablecontrol;
|
||||||
|
private float m_gravmod = 1.0f;
|
||||||
|
|
||||||
// Default we're a Geometry
|
// Default we're a Geometry
|
||||||
private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
|
private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
|
||||||
|
@ -914,6 +914,55 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
bounce = _parent_scene.m_materialContactsData[pMaterial].bounce;
|
bounce = _parent_scene.m_materialContactsData[pMaterial].bounce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override float Density
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_density * 100f;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_density = value / 100f;
|
||||||
|
// for not prim mass is not updated since this implies full rebuild of body inertia TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override float GravModifier
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_gravmod;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_gravmod = value;
|
||||||
|
if (m_vehicle != null)
|
||||||
|
m_vehicle.GravMod = m_gravmod;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override float Friction
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mu;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
mu = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float Restitution
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return bounce;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
bounce = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setPrimForRemoval()
|
public void setPrimForRemoval()
|
||||||
{
|
{
|
||||||
AddChange(changes.Remove, null);
|
AddChange(changes.Remove, null);
|
||||||
|
@ -1736,7 +1785,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
d.BodySetAutoDisableFlag(Body, true);
|
d.BodySetAutoDisableFlag(Body, true);
|
||||||
d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
|
d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
|
||||||
d.BodySetDamping(Body, .005f, .005f);
|
d.BodySetAutoDisableAngularThreshold(Body, 0.01f);
|
||||||
|
d.BodySetAutoDisableLinearThreshold(Body, 0.01f);
|
||||||
|
d.BodySetDamping(Body, .005f, .001f);
|
||||||
|
|
||||||
if (m_targetSpace != IntPtr.Zero)
|
if (m_targetSpace != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
|
@ -2144,7 +2195,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
_mass = primMass; // just in case
|
_mass = primMass; // just in case
|
||||||
|
|
||||||
d.MassSetBoxTotal(out primdMass, primMass, m_OBB.X, m_OBB.Y, m_OBB.Z);
|
d.MassSetBoxTotal(out primdMass, primMass, 2.0f * m_OBB.X, 2.0f * m_OBB.Y, 2.0f * m_OBB.Z);
|
||||||
|
|
||||||
d.MassTranslate(ref primdMass,
|
d.MassTranslate(ref primdMass,
|
||||||
m_OBBOffset.X,
|
m_OBBOffset.X,
|
||||||
|
@ -2362,6 +2413,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
MakeBody();
|
MakeBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#region changes
|
#region changes
|
||||||
|
|
||||||
private void changeadd()
|
private void changeadd()
|
||||||
|
@ -3214,7 +3266,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
if (++bodydisablecontrol < 20)
|
if (++bodydisablecontrol < 20)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
d.BodyEnable(Body);
|
d.BodyEnable(Body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3334,7 +3385,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float b = (1.0f - m_buoyancy);
|
float b = (1.0f - m_buoyancy) * m_gravmod;
|
||||||
fx = _parent_scene.gravityx * b;
|
fx = _parent_scene.gravityx * b;
|
||||||
fy = _parent_scene.gravityy * b;
|
fy = _parent_scene.gravityy * b;
|
||||||
fz = _parent_scene.gravityz * b;
|
fz = _parent_scene.gravityz * b;
|
||||||
|
@ -3381,11 +3432,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdatePositionAndVelocity()
|
public void UpdatePositionAndVelocity(int frame)
|
||||||
{
|
{
|
||||||
if (_parent == null && !m_disabled && !m_building && !m_outbounds && Body != IntPtr.Zero)
|
if (_parent == null && !m_disabled && !m_building && !m_outbounds && Body != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
if (d.BodyIsEnabled(Body) || !_zeroFlag)
|
bool bodyenabled = d.BodyIsEnabled(Body);
|
||||||
|
if (bodyenabled || !_zeroFlag)
|
||||||
{
|
{
|
||||||
bool lastZeroFlag = _zeroFlag;
|
bool lastZeroFlag = _zeroFlag;
|
||||||
|
|
||||||
|
@ -3478,13 +3530,13 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// tolerance values depende a lot on simulation noise...
|
// tolerance values depende a lot on simulation noise...
|
||||||
// use simple math.abs since we dont need to be exact
|
// use simple math.abs since we dont need to be exact
|
||||||
|
|
||||||
if (
|
if (!bodyenabled ||
|
||||||
(Math.Abs(_position.X - lpos.X) < 0.001f)
|
(Math.Abs(_position.X - lpos.X) < 0.005f)
|
||||||
&& (Math.Abs(_position.Y - lpos.Y) < 0.001f)
|
&& (Math.Abs(_position.Y - lpos.Y) < 0.005f)
|
||||||
&& (Math.Abs(_position.Z - lpos.Z) < 0.001f)
|
&& (Math.Abs(_position.Z - lpos.Z) < 0.005f)
|
||||||
&& (Math.Abs(_orientation.X - ori.X) < 0.0001f)
|
&& (Math.Abs(_orientation.X - ori.X) < 0.0005f)
|
||||||
&& (Math.Abs(_orientation.Y - ori.Y) < 0.0001f)
|
&& (Math.Abs(_orientation.Y - ori.Y) < 0.0005f)
|
||||||
&& (Math.Abs(_orientation.Z - ori.Z) < 0.0001f) // ignore W
|
&& (Math.Abs(_orientation.Z - ori.Z) < 0.0005f) // ignore W
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_zeroFlag = true;
|
_zeroFlag = true;
|
||||||
|
@ -3499,9 +3551,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
_acceleration = _velocity;
|
_acceleration = _velocity;
|
||||||
|
|
||||||
if ((Math.Abs(vel.X) < 0.001f) &&
|
if ((Math.Abs(vel.X) < 0.005f) &&
|
||||||
(Math.Abs(vel.Y) < 0.001f) &&
|
(Math.Abs(vel.Y) < 0.005f) &&
|
||||||
(Math.Abs(vel.Z) < 0.001f))
|
(Math.Abs(vel.Z) < 0.005f))
|
||||||
{
|
{
|
||||||
_velocity = Vector3.Zero;
|
_velocity = Vector3.Zero;
|
||||||
float t = -m_invTimeStep;
|
float t = -m_invTimeStep;
|
||||||
|
@ -3538,6 +3590,15 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_position.X = lpos.X;
|
||||||
|
_position.Y = lpos.Y;
|
||||||
|
_position.Z = lpos.Z;
|
||||||
|
|
||||||
|
_orientation.X = ori.X;
|
||||||
|
_orientation.Y = ori.Y;
|
||||||
|
_orientation.Z = ori.Z;
|
||||||
|
_orientation.W = ori.W;
|
||||||
|
|
||||||
if (_zeroFlag)
|
if (_zeroFlag)
|
||||||
{
|
{
|
||||||
if (lastZeroFlag)
|
if (lastZeroFlag)
|
||||||
|
@ -3556,14 +3617,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_position.X = lpos.X;
|
|
||||||
_position.Y = lpos.Y;
|
|
||||||
_position.Z = lpos.Z;
|
|
||||||
|
|
||||||
_orientation.X = ori.X;
|
|
||||||
_orientation.Y = ori.Y;
|
|
||||||
_orientation.Z = ori.Z;
|
|
||||||
_orientation.W = ori.W;
|
|
||||||
base.RequestPhysicsterseUpdate();
|
base.RequestPhysicsterseUpdate();
|
||||||
m_lastUpdateSent = false;
|
m_lastUpdateSent = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Revision 2011/12/13 by Ubit Umarov
|
||||||
//#define SPAM
|
//#define SPAM
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
@ -43,25 +44,7 @@ using OpenMetaverse;
|
||||||
|
|
||||||
namespace OpenSim.Region.Physics.OdePlugin
|
namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
public enum StatusIndicators : int
|
// colision flags of things others can colide with
|
||||||
{
|
|
||||||
Generic = 0,
|
|
||||||
Start = 1,
|
|
||||||
End = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct sCollisionData
|
|
||||||
{
|
|
||||||
public uint ColliderLocalId;
|
|
||||||
public uint CollidedWithLocalId;
|
|
||||||
public int NumberOfCollisions;
|
|
||||||
public int CollisionType;
|
|
||||||
public int StatusIndicator;
|
|
||||||
public int lastframe;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// colision flags of things others can colide with
|
|
||||||
// rays, sensors, probes removed since can't be colided with
|
// rays, sensors, probes removed since can't be colided with
|
||||||
// The top space where things are placed provided further selection
|
// The top space where things are placed provided further selection
|
||||||
// ie physical are in active space nonphysical in static
|
// ie physical are in active space nonphysical in static
|
||||||
|
@ -188,12 +171,14 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public bool OdeUbitLib = false;
|
public bool OdeUbitLib = false;
|
||||||
// private int threadid = 0;
|
// private int threadid = 0;
|
||||||
private Random fluidRandomizer = new Random(Environment.TickCount);
|
// private Random fluidRandomizer = new Random(Environment.TickCount);
|
||||||
|
|
||||||
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 float MaxERP = 0.8f;
|
|
||||||
const float minERP = 0.1f;
|
const d.ContactFlags comumContactFlags = d.ContactFlags.Bounce | d.ContactFlags.Approx1 | d.ContactFlags.Slip1 | d.ContactFlags.Slip2;
|
||||||
|
const float comumContactERP = 0.7f;
|
||||||
const float comumContactCFM = 0.0001f;
|
const float comumContactCFM = 0.0001f;
|
||||||
|
const float comumContactSLIP = 0f;
|
||||||
|
|
||||||
float frictionMovementMult = 0.8f;
|
float frictionMovementMult = 0.8f;
|
||||||
|
|
||||||
|
@ -236,8 +221,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public float geomDefaultDensity = 10.000006836f;
|
public float geomDefaultDensity = 10.000006836f;
|
||||||
|
|
||||||
public int geomContactPointsStartthrottle = 3;
|
// public int geomContactPointsStartthrottle = 3;
|
||||||
public int geomUpdatesPerThrottledUpdate = 15;
|
// public int geomUpdatesPerThrottledUpdate = 15;
|
||||||
|
|
||||||
public float bodyPIDD = 35f;
|
public float bodyPIDD = 35f;
|
||||||
public float bodyPIDG = 25;
|
public float bodyPIDG = 25;
|
||||||
|
@ -246,7 +231,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public int bodyFramesAutoDisable = 5;
|
public int bodyFramesAutoDisable = 5;
|
||||||
|
|
||||||
|
|
||||||
private d.NearCallback nearCallback;
|
private d.NearCallback nearCallback;
|
||||||
|
|
||||||
private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
|
private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
|
||||||
|
@ -266,11 +250,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
|
// public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
|
||||||
public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
|
public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
|
||||||
|
|
||||||
private float contactsurfacelayer = 0.002f;
|
private float contactsurfacelayer = 0.001f;
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
const int maxContactsbeforedeath = 4000;
|
const int maxContactsbeforedeath = 4000;
|
||||||
private volatile int m_global_contactcount = 0;
|
private volatile int m_global_contactcount = 0;
|
||||||
|
@ -283,7 +268,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
private Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>();
|
private Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>();
|
||||||
private Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>();
|
private Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>();
|
||||||
|
|
||||||
private int m_physicsiterations = 10;
|
private int m_physicsiterations = 15;
|
||||||
private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag
|
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;
|
private float step_time = 0.0f;
|
||||||
|
@ -303,8 +288,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
public IntPtr StaticSpace; // space for the static things around
|
public IntPtr StaticSpace; // space for the static things around
|
||||||
public IntPtr GroundSpace; // space for ground
|
public IntPtr GroundSpace; // space for ground
|
||||||
|
|
||||||
public IntPtr SharedRay;
|
|
||||||
|
|
||||||
// some speedup variables
|
// some speedup variables
|
||||||
private int spaceGridMaxX;
|
private int spaceGridMaxX;
|
||||||
private int spaceGridMaxY;
|
private int spaceGridMaxY;
|
||||||
|
@ -428,11 +411,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
d.GeomSetCategoryBits(GroundSpace, (uint)(CollisionCategories.Land));
|
d.GeomSetCategoryBits(GroundSpace, (uint)(CollisionCategories.Land));
|
||||||
d.GeomSetCollideBits(GroundSpace, 0);
|
d.GeomSetCollideBits(GroundSpace, 0);
|
||||||
|
|
||||||
contactgroup = d.JointGroupCreate(0);
|
contactgroup = d.JointGroupCreate(maxContactsbeforedeath + 1);
|
||||||
//contactgroup
|
//contactgroup
|
||||||
|
|
||||||
SharedRay = d.CreateRay(TopSpace, 1.0f);
|
|
||||||
|
|
||||||
d.WorldSetAutoDisableFlag(world, false);
|
d.WorldSetAutoDisableFlag(world, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,10 +462,10 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
metersInSpace = physicsconfig.GetFloat("meters_in_small_space", metersInSpace);
|
metersInSpace = physicsconfig.GetFloat("meters_in_small_space", metersInSpace);
|
||||||
|
|
||||||
contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", contactsurfacelayer);
|
// contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", contactsurfacelayer);
|
||||||
|
|
||||||
ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", ODE_STEPSIZE);
|
ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", ODE_STEPSIZE);
|
||||||
m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", m_physicsiterations);
|
// m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", m_physicsiterations);
|
||||||
|
|
||||||
avDensity = physicsconfig.GetFloat("av_density", avDensity);
|
avDensity = physicsconfig.GetFloat("av_density", avDensity);
|
||||||
avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk);
|
avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk);
|
||||||
|
@ -492,8 +473,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision);
|
contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision);
|
||||||
|
|
||||||
geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3);
|
// geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3);
|
||||||
geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15);
|
// geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15);
|
||||||
// geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5);
|
// geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5);
|
||||||
|
|
||||||
geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", geomDefaultDensity);
|
geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", geomDefaultDensity);
|
||||||
|
@ -508,6 +489,23 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
d.WorldSetCFM(world, comumContactCFM);
|
||||||
|
d.WorldSetERP(world, comumContactERP);
|
||||||
|
|
||||||
|
d.WorldSetGravity(world, gravityx, gravityy, gravityz);
|
||||||
|
|
||||||
|
d.WorldSetLinearDamping(world, 0.002f);
|
||||||
|
d.WorldSetAngularDamping(world, 0.002f);
|
||||||
|
d.WorldSetAngularDampingThreshold(world, 0f);
|
||||||
|
d.WorldSetLinearDampingThreshold(world, 0f);
|
||||||
|
d.WorldSetMaxAngularSpeed(world, 100f);
|
||||||
|
|
||||||
|
d.WorldSetQuickStepNumIterations(world, m_physicsiterations);
|
||||||
|
|
||||||
|
d.WorldSetContactSurfaceLayer(world, contactsurfacelayer);
|
||||||
|
d.WorldSetContactMaxCorrectingVel(world, 60.0f);
|
||||||
|
|
||||||
m_meshWorker = new ODEMeshWorker(this, m_log, meshmerizer, physicsconfig);
|
m_meshWorker = new ODEMeshWorker(this, m_log, meshmerizer, physicsconfig);
|
||||||
|
|
||||||
HalfOdeStep = ODE_STEPSIZE * 0.5f;
|
HalfOdeStep = ODE_STEPSIZE * 0.5f;
|
||||||
|
@ -516,6 +514,20 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf);
|
ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf);
|
||||||
GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf);
|
GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf);
|
||||||
|
|
||||||
|
SharedTmpcontact.geom.g1 = IntPtr.Zero;
|
||||||
|
SharedTmpcontact.geom.g2 = IntPtr.Zero;
|
||||||
|
|
||||||
|
SharedTmpcontact.geom.side1 = -1;
|
||||||
|
SharedTmpcontact.geom.side2 = -1;
|
||||||
|
|
||||||
|
SharedTmpcontact.surface.mode = comumContactFlags;
|
||||||
|
SharedTmpcontact.surface.mu = 0;
|
||||||
|
SharedTmpcontact.surface.bounce = 0;
|
||||||
|
SharedTmpcontact.surface.soft_cfm = comumContactCFM;
|
||||||
|
SharedTmpcontact.surface.soft_erp = comumContactERP;
|
||||||
|
SharedTmpcontact.surface.slip1 = comumContactSLIP;
|
||||||
|
SharedTmpcontact.surface.slip2 = comumContactSLIP;
|
||||||
|
|
||||||
m_materialContactsData[(int)Material.Stone].mu = 0.8f;
|
m_materialContactsData[(int)Material.Stone].mu = 0.8f;
|
||||||
m_materialContactsData[(int)Material.Stone].bounce = 0.4f;
|
m_materialContactsData[(int)Material.Stone].bounce = 0.4f;
|
||||||
|
|
||||||
|
@ -540,27 +552,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
m_materialContactsData[(int)Material.light].mu = 0.0f;
|
m_materialContactsData[(int)Material.light].mu = 0.0f;
|
||||||
m_materialContactsData[(int)Material.light].bounce = 0.0f;
|
m_materialContactsData[(int)Material.light].bounce = 0.0f;
|
||||||
|
|
||||||
// Set the gravity,, don't disable things automatically (we set it explicitly on some things)
|
|
||||||
|
|
||||||
d.WorldSetGravity(world, gravityx, gravityy, gravityz);
|
|
||||||
d.WorldSetContactSurfaceLayer(world, contactsurfacelayer);
|
|
||||||
|
|
||||||
d.WorldSetLinearDamping(world, 0.002f);
|
|
||||||
d.WorldSetAngularDamping(world, 0.002f);
|
|
||||||
d.WorldSetAngularDampingThreshold(world, 0f);
|
|
||||||
d.WorldSetLinearDampingThreshold(world, 0f);
|
|
||||||
d.WorldSetMaxAngularSpeed(world, 100f);
|
|
||||||
|
|
||||||
d.WorldSetCFM(world,1e-6f); // a bit harder than default
|
|
||||||
//d.WorldSetCFM(world, 1e-4f); // a bit harder than default
|
|
||||||
d.WorldSetERP(world, 0.6f); // higher than original
|
|
||||||
|
|
||||||
// Set how many steps we go without running collision testing
|
|
||||||
// This is in addition to the step size.
|
|
||||||
// Essentially Steps * m_physicsiterations
|
|
||||||
d.WorldSetQuickStepNumIterations(world, m_physicsiterations);
|
|
||||||
|
|
||||||
d.WorldSetContactMaxCorrectingVel(world, 60.0f);
|
|
||||||
|
|
||||||
spacesPerMeter = 1 / metersInSpace;
|
spacesPerMeter = 1 / metersInSpace;
|
||||||
spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeter);
|
spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeter);
|
||||||
|
@ -631,40 +622,21 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
// 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, float mu, float bounce, float cfm, float erpscale, float dscale)
|
|
||||||
|
|
||||||
|
private IntPtr CreateContacJoint(ref d.ContactGeom contactGeom)
|
||||||
{
|
{
|
||||||
if (GlobalContactsArray == IntPtr.Zero || m_global_contactcount >= maxContactsbeforedeath)
|
if (m_global_contactcount >= maxContactsbeforedeath)
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
|
|
||||||
float erp = contactGeom.depth;
|
m_global_contactcount++;
|
||||||
erp *= erpscale;
|
|
||||||
if (erp < minERP)
|
|
||||||
erp = minERP;
|
|
||||||
else if (erp > MaxERP)
|
|
||||||
erp = MaxERP;
|
|
||||||
|
|
||||||
float depth = contactGeom.depth * dscale;
|
SharedTmpcontact.geom.depth = contactGeom.depth;
|
||||||
if (depth > 0.5f)
|
SharedTmpcontact.geom.pos = contactGeom.pos;
|
||||||
depth = 0.5f;
|
SharedTmpcontact.geom.normal = contactGeom.normal;
|
||||||
|
|
||||||
d.Contact newcontact = new d.Contact();
|
|
||||||
newcontact.geom.depth = depth;
|
|
||||||
newcontact.geom.g1 = contactGeom.g1;
|
|
||||||
newcontact.geom.g2 = contactGeom.g2;
|
|
||||||
newcontact.geom.pos = contactGeom.pos;
|
|
||||||
newcontact.geom.normal = contactGeom.normal;
|
|
||||||
newcontact.geom.side1 = contactGeom.side1;
|
|
||||||
newcontact.geom.side2 = contactGeom.side2;
|
|
||||||
|
|
||||||
// this needs bounce also
|
|
||||||
newcontact.surface.mode = comumContactFlags;
|
|
||||||
newcontact.surface.mu = mu;
|
|
||||||
newcontact.surface.bounce = bounce;
|
|
||||||
newcontact.surface.soft_cfm = cfm;
|
|
||||||
newcontact.surface.soft_erp = erp;
|
|
||||||
|
|
||||||
IntPtr contact = new IntPtr(GlobalContactsArray.ToInt64() + (Int64)(m_global_contactcount * d.Contact.unmanagedSizeOf));
|
IntPtr contact = new IntPtr(GlobalContactsArray.ToInt64() + (Int64)(m_global_contactcount * d.Contact.unmanagedSizeOf));
|
||||||
Marshal.StructureToPtr(newcontact, contact, true);
|
Marshal.StructureToPtr(SharedTmpcontact, contact, true);
|
||||||
return d.JointCreateContactPtr(world, contactgroup, contact);
|
return d.JointCreateContactPtr(world, contactgroup, contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,10 +797,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
if (!GetCurContactGeom(0, ref curContact))
|
if (!GetCurContactGeom(0, ref curContact))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ContactPoint maxDepthContact = new ContactPoint();
|
||||||
|
|
||||||
// do volume detection case
|
// do volume detection case
|
||||||
if ((p1.IsVolumeDtc || p2.IsVolumeDtc))
|
if ((p1.IsVolumeDtc || p2.IsVolumeDtc))
|
||||||
{
|
{
|
||||||
ContactPoint maxDepthContact = new ContactPoint(
|
maxDepthContact = new ContactPoint(
|
||||||
new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z),
|
new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z),
|
||||||
new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z),
|
new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z),
|
||||||
curContact.depth, false
|
curContact.depth, false
|
||||||
|
@ -842,10 +816,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
float mu = 0;
|
float mu = 0;
|
||||||
float bounce = 0;
|
float bounce = 0;
|
||||||
float cfm = 0.0001f;
|
// bool IgnoreNegSides = false;
|
||||||
float erpscale = 1.0f;
|
|
||||||
float dscale = 1.0f;
|
|
||||||
bool IgnoreNegSides = false;
|
|
||||||
|
|
||||||
ContactData contactdata1 = new ContactData(0, 0, false);
|
ContactData contactdata1 = new ContactData(0, 0, false);
|
||||||
ContactData contactdata2 = new ContactData(0, 0, false);
|
ContactData contactdata2 = new ContactData(0, 0, false);
|
||||||
|
@ -890,7 +861,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (int)ActorTypes.Prim:
|
case (int)ActorTypes.Prim:
|
||||||
if ((p1.Velocity - p2.Velocity).LengthSquared() > 0.0f)
|
Vector3 relV = p1.Velocity - p2.Velocity;
|
||||||
|
float relVlenSQ = relV.LengthSquared();
|
||||||
|
if (relVlenSQ > 0.0001f)
|
||||||
{
|
{
|
||||||
p1.CollidingObj = true;
|
p1.CollidingObj = true;
|
||||||
p2.CollidingObj = true;
|
p2.CollidingObj = true;
|
||||||
|
@ -900,21 +873,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
bounce = contactdata1.bounce * contactdata2.bounce;
|
bounce = contactdata1.bounce * contactdata2.bounce;
|
||||||
mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
|
mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
|
||||||
|
|
||||||
cfm = p1.Mass;
|
if (relVlenSQ > 0.01f)
|
||||||
if (cfm > p2.Mass)
|
|
||||||
cfm = p2.Mass;
|
|
||||||
dscale = 10 / cfm;
|
|
||||||
dscale = (float)Math.Sqrt(dscale);
|
|
||||||
if (dscale > 1.0f)
|
|
||||||
dscale = 1.0f;
|
|
||||||
erpscale = cfm * 0.01f;
|
|
||||||
cfm = 0.0001f / cfm;
|
|
||||||
if (cfm > 0.01f)
|
|
||||||
cfm = 0.01f;
|
|
||||||
else if (cfm < 0.00001f)
|
|
||||||
cfm = 0.00001f;
|
|
||||||
|
|
||||||
if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
|
|
||||||
mu *= frictionMovementMult;
|
mu *= frictionMovementMult;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -923,27 +882,17 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
p1.getContactData(ref contactdata1);
|
p1.getContactData(ref contactdata1);
|
||||||
bounce = contactdata1.bounce * TerrainBounce;
|
bounce = contactdata1.bounce * TerrainBounce;
|
||||||
mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction);
|
mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction);
|
||||||
|
|
||||||
if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f)
|
if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f)
|
||||||
mu *= frictionMovementMult;
|
mu *= frictionMovementMult;
|
||||||
p1.CollidingGround = true;
|
p1.CollidingGround = true;
|
||||||
|
/*
|
||||||
cfm = p1.Mass;
|
|
||||||
dscale = 10 / cfm;
|
|
||||||
dscale = (float)Math.Sqrt(dscale);
|
|
||||||
if (dscale > 1.0f)
|
|
||||||
dscale = 1.0f;
|
|
||||||
erpscale = cfm * 0.01f;
|
|
||||||
cfm = 0.0001f / cfm;
|
|
||||||
if (cfm > 0.01f)
|
|
||||||
cfm = 0.01f;
|
|
||||||
else if (cfm < 0.00001f)
|
|
||||||
cfm = 0.00001f;
|
|
||||||
|
|
||||||
if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
|
if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
|
||||||
{
|
{
|
||||||
if (curContact.side1 > 0)
|
if (curContact.side1 > 0)
|
||||||
IgnoreNegSides = true;
|
IgnoreNegSides = true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (int)ActorTypes.Water:
|
case (int)ActorTypes.Water:
|
||||||
|
@ -961,22 +910,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
bounce = contactdata2.bounce * TerrainBounce;
|
bounce = contactdata2.bounce * TerrainBounce;
|
||||||
mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction);
|
mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction);
|
||||||
|
|
||||||
cfm = p2.Mass;
|
// if (curContact.side1 > 0) // should be 2 ?
|
||||||
dscale = 10 / cfm;
|
// IgnoreNegSides = true;
|
||||||
dscale = (float)Math.Sqrt(dscale);
|
|
||||||
|
|
||||||
if (dscale > 1.0f)
|
|
||||||
dscale = 1.0f;
|
|
||||||
|
|
||||||
erpscale = cfm * 0.01f;
|
|
||||||
cfm = 0.0001f / cfm;
|
|
||||||
if (cfm > 0.01f)
|
|
||||||
cfm = 0.01f;
|
|
||||||
else if (cfm < 0.00001f)
|
|
||||||
cfm = 0.00001f;
|
|
||||||
|
|
||||||
if (curContact.side1 > 0) // should be 2 ?
|
|
||||||
IgnoreNegSides = true;
|
|
||||||
|
|
||||||
if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f)
|
if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f)
|
||||||
mu *= frictionMovementMult;
|
mu *= frictionMovementMult;
|
||||||
|
@ -993,26 +928,24 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
if (ignore)
|
if (ignore)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
d.ContactGeom maxContact = curContact;
|
|
||||||
// if (IgnoreNegSides && curContact.side1 < 0)
|
|
||||||
// maxContact.depth = float.MinValue;
|
|
||||||
|
|
||||||
d.ContactGeom minContact = curContact;
|
|
||||||
// if (IgnoreNegSides && curContact.side1 < 0)
|
|
||||||
// minContact.depth = float.MaxValue;
|
|
||||||
|
|
||||||
IntPtr Joint;
|
IntPtr Joint;
|
||||||
bool FeetCollision = false;
|
bool FeetCollision = false;
|
||||||
int ncontacts = 0;
|
int ncontacts = 0;
|
||||||
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
maxDepthContact = new ContactPoint();
|
||||||
|
maxDepthContact.PenetrationDepth = float.MinValue;
|
||||||
|
ContactPoint minDepthContact = new ContactPoint();
|
||||||
|
minDepthContact.PenetrationDepth = float.MaxValue;
|
||||||
|
|
||||||
|
SharedTmpcontact.geom.depth = 0;
|
||||||
|
SharedTmpcontact.surface.mu = mu;
|
||||||
|
SharedTmpcontact.surface.bounce = bounce;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
// if (!(IgnoreNegSides && curContact.side1 < 0))
|
||||||
// if (!(IgnoreNegSides && curContact.side1 < 0))
|
|
||||||
{
|
{
|
||||||
bool noskip = true;
|
bool noskip = true;
|
||||||
if (dop1ava)
|
if (dop1ava)
|
||||||
|
@ -1029,26 +962,32 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
if (noskip)
|
if (noskip)
|
||||||
{
|
{
|
||||||
m_global_contactcount++;
|
Joint = CreateContacJoint(ref curContact);
|
||||||
if (m_global_contactcount >= maxContactsbeforedeath)
|
|
||||||
break;
|
|
||||||
|
|
||||||
ncontacts++;
|
|
||||||
|
|
||||||
Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale);
|
|
||||||
if (Joint == IntPtr.Zero)
|
if (Joint == IntPtr.Zero)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
d.JointAttach(Joint, b1, b2);
|
d.JointAttach(Joint, b1, b2);
|
||||||
|
|
||||||
if (curContact.depth > maxContact.depth)
|
ncontacts++;
|
||||||
maxContact = curContact;
|
|
||||||
|
|
||||||
if (curContact.depth < minContact.depth)
|
if (curContact.depth > maxDepthContact.PenetrationDepth)
|
||||||
minContact = curContact;
|
{
|
||||||
|
maxDepthContact.Position.X = curContact.pos.X;
|
||||||
|
maxDepthContact.Position.Y = curContact.pos.Y;
|
||||||
|
maxDepthContact.Position.Z = curContact.pos.Z;
|
||||||
|
maxDepthContact.PenetrationDepth = curContact.depth;
|
||||||
|
maxDepthContact.CharacterFeet = FeetCollision;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curContact.depth < minDepthContact.PenetrationDepth)
|
||||||
|
{
|
||||||
|
minDepthContact.PenetrationDepth = curContact.depth;
|
||||||
|
minDepthContact.SurfaceNormal.X = curContact.normal.X;
|
||||||
|
minDepthContact.SurfaceNormal.Y = curContact.normal.Y;
|
||||||
|
minDepthContact.SurfaceNormal.Z = curContact.normal.Z;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++i >= count)
|
if (++i >= count)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1058,11 +997,10 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
if (ncontacts > 0)
|
if (ncontacts > 0)
|
||||||
{
|
{
|
||||||
ContactPoint maxDepthContact = new ContactPoint(
|
maxDepthContact.SurfaceNormal.X = minDepthContact.SurfaceNormal.X;
|
||||||
new Vector3(maxContact.pos.X, maxContact.pos.Y, maxContact.pos.Z),
|
maxDepthContact.SurfaceNormal.Y = minDepthContact.SurfaceNormal.Y;
|
||||||
new Vector3(minContact.normal.X, minContact.normal.Y, minContact.normal.Z),
|
maxDepthContact.SurfaceNormal.Z = minDepthContact.SurfaceNormal.Z;
|
||||||
maxContact.depth, FeetCollision
|
|
||||||
);
|
|
||||||
collision_accounting_events(p1, p2, maxDepthContact);
|
collision_accounting_events(p1, p2, maxDepthContact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1629,16 +1567,15 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
if (framecount < 0)
|
if (framecount < 0)
|
||||||
framecount = 0;
|
framecount = 0;
|
||||||
|
|
||||||
|
|
||||||
framecount++;
|
framecount++;
|
||||||
|
|
||||||
int curphysiteractions;
|
// int curphysiteractions;
|
||||||
|
|
||||||
// if in trouble reduce step resolution
|
// if in trouble reduce step resolution
|
||||||
if (step_time >= m_SkipFramesAtms)
|
// if (step_time >= m_SkipFramesAtms)
|
||||||
curphysiteractions = m_physicsiterations / 2;
|
// curphysiteractions = m_physicsiterations / 2;
|
||||||
else
|
// else
|
||||||
curphysiteractions = m_physicsiterations;
|
// curphysiteractions = m_physicsiterations;
|
||||||
|
|
||||||
// checkThread();
|
// checkThread();
|
||||||
int nodeframes = 0;
|
int nodeframes = 0;
|
||||||
|
@ -1654,9 +1591,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
ODEchangeitem item;
|
ODEchangeitem item;
|
||||||
|
|
||||||
|
// d.WorldSetQuickStepNumIterations(world, curphysiteractions);
|
||||||
|
|
||||||
d.WorldSetQuickStepNumIterations(world, curphysiteractions);
|
|
||||||
|
|
||||||
int loopstartMS = Util.EnvironmentTickCount();
|
int loopstartMS = Util.EnvironmentTickCount();
|
||||||
int looptimeMS = 0;
|
int looptimeMS = 0;
|
||||||
|
@ -1763,6 +1698,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
// do a ode simulation step
|
// do a ode simulation step
|
||||||
d.WorldQuickStep(world, ODE_STEPSIZE);
|
d.WorldQuickStep(world, ODE_STEPSIZE);
|
||||||
|
// d.WorldStep(world, ODE_STEPSIZE);
|
||||||
d.JointGroupEmpty(contactgroup);
|
d.JointGroupEmpty(contactgroup);
|
||||||
|
|
||||||
// update managed ideia of physical data and do updates to core
|
// update managed ideia of physical data and do updates to core
|
||||||
|
@ -1789,7 +1725,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
if (actor.IsPhysical)
|
if (actor.IsPhysical)
|
||||||
{
|
{
|
||||||
actor.UpdatePositionAndVelocity();
|
actor.UpdatePositionAndVelocity(framecount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1325,13 +1325,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
(m_Scripts[itemID].AssetID != assetID))
|
(m_Scripts[itemID].AssetID != assetID))
|
||||||
{
|
{
|
||||||
lockScriptsForRead(false);
|
lockScriptsForRead(false);
|
||||||
instance = new ScriptInstance(this, part,
|
instance = new ScriptInstance(this, part,
|
||||||
item,
|
item,
|
||||||
startParam, postOnRez,
|
startParam, postOnRez,
|
||||||
m_MaxScriptQueue);
|
m_MaxScriptQueue);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (part.ParentGroup.IsAttachment)
|
if (part.ParentGroup.IsAttachment)
|
||||||
appDomain = part.ParentGroup.RootPart.UUID;
|
appDomain = part.ParentGroup.RootPart.UUID;
|
||||||
|
|
||||||
|
@ -1392,8 +1390,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
sandbox = AppDomain.CurrentDomain;
|
sandbox = AppDomain.CurrentDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource))
|
// if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource))
|
||||||
return false;
|
// return false;
|
||||||
|
|
||||||
m_AppDomains[appDomain] = sandbox;
|
m_AppDomains[appDomain] = sandbox;
|
||||||
|
|
||||||
|
@ -1413,7 +1411,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
instance.Load(m_AppDomains[appDomain], assembly, stateSource);
|
if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource))
|
||||||
|
return false;
|
||||||
// m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
// "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}",
|
// "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}",
|
||||||
// part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID,
|
// part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID,
|
||||||
|
|
Loading…
Reference in New Issue