diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index b797cc3fdc..ba2a2cffda 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -745,7 +745,7 @@ namespace OpenSim.Region.Environment.Scenes } catch (Exception e) { - m_log.Error("[Scene]: Failed with exception " + e.ToString()); + m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); } finally { @@ -1230,32 +1230,32 @@ namespace OpenSim.Region.Environment.Scenes int thisx = (int)RegionInfo.RegionLocX; int thisy = (int)RegionInfo.RegionLocY; ulong newRegionHandle = 0; - LLVector3 pos = grp.AbsolutePosition; + LLVector3 pos = position; - if (position.X > 255.6f) + if (position.X > 257f) { - pos.X = ((pos.X - 256) + 10); + pos.X = ((pos.X - 256)); newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * 256), (uint)(thisy * 256)); // x + 1 } - else if (position.X < 0.4f) + else if (position.X < -1f) { - pos.X = ((pos.X + 256) - 10); + pos.X = ((pos.X + 256)); newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * 256), (uint)(thisy * 256)); // x - 1 } - if (position.Y > 255.6f) + if (position.Y > 257f) { - pos.Y = ((pos.Y - 256) + 10); + pos.Y = ((pos.Y - 256)); newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy + 1) * 256)); // y + 1 } - else if (position.Y < 0.4f) + else if (position.Y < -1f) { - pos.Y = ((pos.Y + 256) - 10); + pos.Y = ((pos.Y + 256)); newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy - 1) * 256)); // y - 1 } @@ -1287,7 +1287,7 @@ namespace OpenSim.Region.Environment.Scenes } public void IncomingInterRegionPrimGroup(ulong regionHandle, LLUUID primID, string objXMLData) { - m_log.Warn("{[INTERREGION]: OMG! A new prim arrived from a neighbor!.. Kyill eeehht! before it corrupts my entire database! AHHH! I feel so dirty now! yuck! ack! arg!"); + m_log.Warn("{[INTERREGION]: A new prim arrived from a neighbor"); m_sceneXmlLoader.LoadGroupFromXml2String(objXMLData); } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 3b146ea611..117bcbc3e4 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -126,7 +126,7 @@ namespace OpenSim.Region.Environment.Scenes set { LLVector3 val = value; - if (val.X > 255.6f || val.X < 0.4f || val.Y > 255.6f || val.Y < 0.4f) + if (val.X > 257f || val.X < -1f || val.Y > 257f || val.Y < -1f) { m_scene.CrossPrimGroupIntoNewRegion(val, this); } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 79009007a6..4f5eefefa3 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -405,7 +405,19 @@ namespace OpenSim.Region.Environment.Scenes return m_velocity; } - set { m_velocity = value; } + set { + + m_velocity = value; + if (PhysActor != null) + { + if (PhysActor.IsPhysical) + { + PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); + } + } + + } } public LLVector3 RotationalVelocity @@ -742,6 +754,7 @@ namespace OpenSim.Region.Environment.Scenes { XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader); + return newobject; } @@ -1776,6 +1789,16 @@ namespace OpenSim.Region.Environment.Scenes public void PhysicsRequestingTerseUpdate() { + if (PhysActor != null) + { + LLVector3 newpos = new LLVector3(PhysActor.Position.GetBytes(), 0); + if (newpos.X > 257f || newpos.X < -1f || newpos.Y > 257f || newpos.Y < -1f) + { + m_parentGroup.AbsolutePosition = newpos; + return; + } + + } ScheduleTerseUpdate(); //SendTerseUpdateToAllClients(); diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs index 6d911f1d78..498261374c 100644 --- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs @@ -175,6 +175,8 @@ namespace OpenSim.Region.Environment.Scenes public void CreatePrimFromXml(string xmlData) { SceneObjectGroup obj = new SceneObjectGroup(xmlData); + LLVector3 receivedVelocity = obj.RootPart.Velocity; + //System.Console.WriteLine(obj.RootPart.Velocity.ToString()); m_innerScene.AddEntityFromStorage(obj); SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); @@ -191,6 +193,8 @@ namespace OpenSim.Region.Environment.Scenes new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); + rootPart.Velocity = receivedVelocity; + } } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 819d823bfd..5cdbb77bbf 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -49,6 +49,7 @@ namespace OpenSim.Region.Physics.OdePlugin private Quaternion _orientation; private PhysicsVector m_taintposition; private PhysicsVector m_taintsize; + private PhysicsVector m_taintVelocity = PhysicsVector.Zero; private Quaternion m_taintrot; private bool m_taintshape = false; private bool m_taintPhysics = false; @@ -455,8 +456,13 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_taintdisable) changedisable(timestep); + + if (m_taintVelocity != PhysicsVector.Zero) + changevelocity(timestep); } + + public void Move(float timestep) { if (m_isphysical) @@ -743,7 +749,18 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintforce = false; } - + private void changevelocity(float timestep) + { + System.Threading.Thread.Sleep(20); + if (IsPhysical) + { + if (Body != (IntPtr)0) + { + d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); + } + } + m_taintVelocity = PhysicsVector.Zero; + } public override bool IsPhysical { get { return m_isphysical; } @@ -838,7 +855,14 @@ namespace OpenSim.Region.Physics.OdePlugin returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2; return returnVelocity; } - set { _velocity = value; } + set { + _velocity = value; + + m_taintVelocity = value; + _parent_scene.AddPhysicsActorTaint(this); + + + } } public override bool Kinematic @@ -898,16 +922,24 @@ namespace OpenSim.Region.Physics.OdePlugin d.Vector3 rotvel = d.BodyGetAngularVel(Body); PhysicsVector l_position = new PhysicsVector(); + + // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) - if (vec.X < 0.0f) vec.X = 0.0f; - if (vec.Y < 0.0f) vec.Y = 0.0f; - if (vec.X > 255.95f) vec.X = 255.95f; - if (vec.Y > 255.95f) vec.Y = 255.95f; + //if (vec.X < 0.0f) vec.X = 0.0f; + //if (vec.Y < 0.0f) vec.Y = 0.0f; + //if (vec.X > 255.95f) vec.X = 255.95f; + //if (vec.Y > 255.95f) vec.Y = 255.95f; m_lastposition = _position; l_position.X = vec.X; l_position.Y = vec.Y; l_position.Z = vec.Z; + + if (l_position.X > 257f || l_position.X < -1f || l_position.Y > 257f || l_position.Y < -1f) + { + base.RequestPhysicsterseUpdate(); + } + if (l_position.Z < 0) { // This is so prim that get lost underground don't fall forever and suck up