From fbf3c6a768274cfdb1e91e73758f9ee893094153 Mon Sep 17 00:00:00 2001 From: darok Date: Sat, 3 Nov 2007 19:33:00 +0000 Subject: Modifications for prim movement. For now only in Mod. BulletX, but i think it can be easy to add to ODE. Enjoy kick the prims and be careful with the falling ones ;D --- .../Region/Environment/Scenes/SceneObjectGroup.cs | 22 +++++++ .../Region/Environment/Scenes/SceneObjectPart.cs | 73 ++++++++++++++++++++-- 2 files changed, 90 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 39f4e5c..b00d465 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -55,6 +55,9 @@ namespace OpenSim.Region.Environment.Scenes public bool HasChanged = false; + private LLVector3 lastPhysGroupPos; + private LLQuaternion lastPhysGroupRot; + #region Properties /// @@ -490,6 +493,25 @@ namespace OpenSim.Region.Environment.Scenes /// public override void Update() { + if (lastPhysGroupPos.GetDistanceTo(AbsolutePosition) > 0.02) + { + foreach (SceneObjectPart part in m_parts.Values) + { + if (part.UpdateFlag == 0) part.UpdateFlag = 1; + } + lastPhysGroupPos = AbsolutePosition; + } + if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) + || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) + || (Math.Abs(lastPhysGroupRot.Y - GroupRotation.Y) > 0.1) + || (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1)) + { + foreach (SceneObjectPart part in m_parts.Values) + { + if (part.UpdateFlag == 0) part.UpdateFlag = 1; + } + lastPhysGroupRot = GroupRotation; + } foreach (SceneObjectPart part in m_parts.Values) { part.SendScheduledUpdates(); diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 637e090..b558bb2 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -148,8 +148,34 @@ namespace OpenSim.Region.Environment.Scenes public LLVector3 GroupPosition { - get { return m_groupPosition; } - set { m_groupPosition = value; } + get + { + if (PhysActor != null) + { + m_groupPosition.X = PhysActor.Position.X; + m_groupPosition.Y = PhysActor.Position.Y; + m_groupPosition.Z = PhysActor.Position.Z; + } + return m_groupPosition; + } + set + { + if (PhysActor != null) + { + try + { + //lock (m_scene.SyncRoot) + //{ + PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); + //} + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + m_groupPosition = value; + } } protected LLVector3 m_offsetPosition; @@ -169,8 +195,35 @@ namespace OpenSim.Region.Environment.Scenes public LLQuaternion RotationOffset { - get { return m_rotationOffset; } - set { m_rotationOffset = value; } + get + { + if (PhysActor != null) + { + m_rotationOffset.X = PhysActor.Orientation.x; + m_rotationOffset.Y = PhysActor.Orientation.y; + m_rotationOffset.Z = PhysActor.Orientation.z; + m_rotationOffset.W = PhysActor.Orientation.w; + } + return m_rotationOffset; + } + set + { + if (PhysActor != null) + { + try + { + //lock (m_scene.SyncRoot) + //{ + PhysActor.Orientation = new Quaternion(value.W, value.X, value.Y, value.Z); + //} + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + m_rotationOffset = value; + } } protected LLVector3 m_velocity; @@ -260,7 +313,12 @@ namespace OpenSim.Region.Environment.Scenes public SceneObjectGroup ParentGroup { get { return m_parentGroup; } - + } + + public byte UpdateFlag + { + get { return m_updateFlag; } + set { m_updateFlag = value; } } #region Constructors @@ -502,6 +560,7 @@ namespace OpenSim.Region.Environment.Scenes { AddTerseUpdateToAllAvatars(); ClearUpdateSchedule(); + ScheduleTerseUpdate(); } else { @@ -706,6 +765,10 @@ namespace OpenSim.Region.Environment.Scenes new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z), UsePhysics); } + else + { + PhysActor.IsPhysical = UsePhysics; + } } if (IsTemporary) -- cgit v1.1