From 827b0fb1993c6f9b1289931a1ac38ff2b810952c Mon Sep 17 00:00:00 2001 From: opensim Date: Wed, 30 Sep 2009 18:51:02 +0200 Subject: Commit initial version of KittoFlora's vehicle changes --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 6 +- .../Region/Framework/Scenes/SceneObjectGroup.cs | 42 ++-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 267 +++++++++------------ .../Scenes/Tests/SceneObjectLinkingTests.cs | 6 +- 6 files changed, 149 insertions(+), 178 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index eb397f6..a6e137d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2265,7 +2265,7 @@ namespace OpenSim.Region.Framework.Scenes group.ClearPartAttachmentData(); } - group.UpdateGroupRotation(rot); + group.UpdateGroupRotationR(rot); //group.ApplyPhysics(m_physicalPrim); if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d8478a2..db107a9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2810,7 +2810,7 @@ namespace OpenSim.Region.Framework.Scenes // SceneObjectGroup obj = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot); m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot); //obj.Rotation = worldRot; - //obj.UpdateGroupRotation(worldRot); + //obj.UpdateGroupRotationR(worldRot); } else { @@ -4504,7 +4504,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion q = trackedBody.RotationOffset * joint.LocalRotation; jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos); // schedules the entire group for a terse update - jointProxyObject.ParentGroup.UpdateGroupRotation(q); // schedules the entire group for a terse update + jointProxyObject.ParentGroup.UpdateGroupRotationR(q); // schedules the entire group for a terse update } break; } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 48dea07..09116fa 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1236,7 +1236,7 @@ namespace OpenSim.Region.Framework.Scenes { if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) { - group.UpdateGroupRotation(rot); + group.UpdateGroupRotationR(rot); } } } @@ -1255,7 +1255,7 @@ namespace OpenSim.Region.Framework.Scenes { if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) { - group.UpdateGroupRotation(pos, rot); + group.UpdateGroupRotationPR(pos, rot); } } } @@ -1811,7 +1811,7 @@ namespace OpenSim.Region.Framework.Scenes if (rot != Quaternion.Identity) { - copy.UpdateGroupRotation(rot); + copy.UpdateGroupRotationR(rot); } copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3c17bbe..4bd10bd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -368,6 +368,13 @@ namespace OpenSim.Region.Framework.Scenes #region Constructors /// + /// Constructor + /// + public SceneObjectGroup() + { + } + + /// /// This constructor creates a SceneObjectGroup using a pre-existing SceneObjectPart. /// The original SceneObjectPart will be used rather than a copy, preserving /// its existing localID and UUID. @@ -2953,8 +2960,9 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void UpdateGroupRotation(Quaternion rot) + public void UpdateGroupRotationR(Quaternion rot) { + m_rootPart.UpdateRotation(rot); if (m_rootPart.PhysActor != null) { @@ -2971,7 +2979,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void UpdateGroupRotation(Vector3 pos, Quaternion rot) + public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) { m_rootPart.UpdateRotation(rot); if (m_rootPart.PhysActor != null) @@ -3079,22 +3087,26 @@ namespace OpenSim.Region.Framework.Scenes int yaxis = 4; int zaxis = 8; - setX = ((axis & xaxis) != 0) ? true : false; - setY = ((axis & yaxis) != 0) ? true : false; - setZ = ((axis & zaxis) != 0) ? true : false; + if (m_rootPart != null) + { + setX = ((axis & xaxis) != 0) ? true : false; + setY = ((axis & yaxis) != 0) ? true : false; + setZ = ((axis & zaxis) != 0) ? true : false; - float setval = (rotate10 > 0) ? 1f : 0f; + float setval = (rotate10 > 0) ? 1f : 0f; - if (setX) - m_rootPart.RotationAxis.X = setval; - if (setY) - m_rootPart.RotationAxis.Y = setval; - if (setZ) - m_rootPart.RotationAxis.Z = setval; + if (setX) + m_rootPart.RotationAxis.X = setval; + if (setY) + m_rootPart.RotationAxis.Y = setval; + if (setZ) + m_rootPart.RotationAxis.Z = setval; + + if (setX || setY || setZ) + { + m_rootPart.SetPhysicsAxisRotation(); + } - if (setX || setY || setZ) - { - m_rootPart.SetPhysicsAxisRotation(); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 51bb114..40e7471 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -415,10 +415,9 @@ namespace OpenSim.Region.Framework.Scenes set { m_name = value; - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.SOPName = value; + PhysActor.SOPName = value; } } } @@ -428,11 +427,10 @@ namespace OpenSim.Region.Framework.Scenes get { return (byte) m_material; } set { - PhysicsActor pa = PhysActor; m_material = (Material)value; - if (pa != null) + if (PhysActor != null) { - pa.SetMaterial((int)value); + PhysActor.SetMaterial((int)value); } } } @@ -503,12 +501,11 @@ namespace OpenSim.Region.Framework.Scenes get { // If this is a linkset, we don't want the physics engine mucking up our group position here. - PhysicsActor pa = PhysActor; - if (pa != null && _parentID == 0) + if (PhysActor != null && _parentID == 0) { - m_groupPosition.X = pa.Position.X; - m_groupPosition.Y = pa.Position.Y; - m_groupPosition.Z = pa.Position.Z; + m_groupPosition.X = PhysActor.Position.X; + m_groupPosition.Y = PhysActor.Position.Y; + m_groupPosition.Z = PhysActor.Position.Z; } if (IsAttachment) @@ -528,27 +525,26 @@ namespace OpenSim.Region.Framework.Scenes m_groupPosition = value; - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { try { // Root prim actually goes at Position if (_parentID == 0) { - pa.Position = new PhysicsVector(value.X, value.Y, value.Z); + PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); } else { // To move the child prim in respect to the group position and rotation we have to calculate Vector3 resultingposition = GetWorldPosition(); - pa.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); + PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); Quaternion resultingrot = GetWorldRotation(); - pa.Orientation = resultingrot; + PhysActor.Orientation = resultingrot; } // Tell the physics engines that this prim changed. - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); } catch (Exception e) { @@ -581,16 +577,15 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup != null && !ParentGroup.IsDeleted) { - PhysicsActor pa = PhysActor; - if (_parentID != 0 && pa != null) + if (_parentID != 0 && PhysActor != null) { Vector3 resultingposition = GetWorldPosition(); - pa.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); + PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); Quaternion resultingrot = GetWorldRotation(); - pa.Orientation = resultingrot; + PhysActor.Orientation = resultingrot; // Tell the physics engines that this prim changed. - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); } } } @@ -600,14 +595,13 @@ namespace OpenSim.Region.Framework.Scenes { get { - PhysicsActor pa = PhysActor; // We don't want the physics engine mucking up the rotations in a linkset - if ((_parentID == 0) && (Shape.PCode != 9 || Shape.State == 0) && (pa != null)) + if ((_parentID == 0) && (Shape.PCode != 9 || Shape.State == 0) && (PhysActor != null)) { - if (pa.Orientation.X != 0 || pa.Orientation.Y != 0 - || pa.Orientation.Z != 0 || pa.Orientation.W != 0) + if (PhysActor.Orientation.X != 0 || PhysActor.Orientation.Y != 0 + || PhysActor.Orientation.Z != 0 || PhysActor.Orientation.W != 0) { - m_rotationOffset = pa.Orientation; + m_rotationOffset = PhysActor.Orientation; } } @@ -616,28 +610,27 @@ namespace OpenSim.Region.Framework.Scenes set { - PhysicsActor pa = PhysActor; StoreUndoState(); m_rotationOffset = value; - if (pa != null) + if (PhysActor != null) { try { // Root prim gets value directly if (_parentID == 0) { - pa.Orientation = value; + PhysActor.Orientation = value; //m_log.Info("[PART]: RO1:" + PhysActor.Orientation.ToString()); } else { // Child prim we have to calculate it's world rotationwel Quaternion resultingrotation = GetWorldRotation(); - pa.Orientation = resultingrotation; + PhysActor.Orientation = resultingrotation; //m_log.Info("[PART]: RO2:" + PhysActor.Orientation.ToString()); } - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); //} } catch (Exception ex) @@ -657,14 +650,13 @@ namespace OpenSim.Region.Framework.Scenes //if (PhysActor.Velocity.X != 0 || PhysActor.Velocity.Y != 0 //|| PhysActor.Velocity.Z != 0) //{ - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - if (pa.IsPhysical) + if (PhysActor.IsPhysical) { - m_velocity.X = pa.Velocity.X; - m_velocity.Y = pa.Velocity.Y; - m_velocity.Z = pa.Velocity.Z; + m_velocity.X = PhysActor.Velocity.X; + m_velocity.Y = PhysActor.Velocity.Y; + m_velocity.Z = PhysActor.Velocity.Z; } } @@ -674,13 +666,12 @@ namespace OpenSim.Region.Framework.Scenes set { m_velocity = value; - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - if (pa.IsPhysical) + if (PhysActor.IsPhysical) { - pa.Velocity = new PhysicsVector(value.X, value.Y, value.Z); - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); + PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); } } } @@ -697,10 +688,9 @@ namespace OpenSim.Region.Framework.Scenes { get { - PhysicsActor pa = PhysActor; - if ((pa != null) && pa.IsPhysical) + if ((PhysActor != null) && PhysActor.IsPhysical) { - m_angularVelocity.FromBytes(pa.RotationalVelocity.GetBytes(), 0); + m_angularVelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(), 0); } return m_angularVelocity; } @@ -719,11 +709,10 @@ namespace OpenSim.Region.Framework.Scenes get { return m_description; } set { - PhysicsActor pa = PhysActor; m_description = value; - if (pa != null) + if (PhysActor != null) { - pa.SOPDescription = value; + PhysActor.SOPDescription = value; } } } @@ -817,15 +806,14 @@ namespace OpenSim.Region.Framework.Scenes if (m_shape != null) { m_shape.Scale = value; - PhysicsActor pa = PhysActor; - if (pa != null && m_parentGroup != null) + if (PhysActor != null && m_parentGroup != null) { if (m_parentGroup.Scene != null) { if (m_parentGroup.Scene.PhysicsScene != null) { - pa.Size = new PhysicsVector(m_shape.Scale.X, m_shape.Scale.Y, m_shape.Scale.Z); - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); + PhysActor.Size = new PhysicsVector(m_shape.Scale.X, m_shape.Scale.Y, m_shape.Scale.Z); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); } } } @@ -1355,14 +1343,13 @@ if (m_shape != null) { RigidBody); // Basic Physics returns null.. joy joy joy. - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.SOPName = this.Name; // save object name and desc into the PhysActor so ODE internals know the joint/body info - pa.SOPDescription = this.Description; - pa.LocalID = LocalId; + PhysActor.SOPName = this.Name; // save object name and desc into the PhysActor so ODE internals know the joint/body info + PhysActor.SOPDescription = this.Description; + PhysActor.LocalID = LocalId; DoPhysicsPropertyUpdate(RigidBody, true); - pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0); + PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); } } } @@ -1576,24 +1563,23 @@ if (m_shape != null) { } else { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - if (UsePhysics != pa.IsPhysical || isNew) + if (UsePhysics != PhysActor.IsPhysical || isNew) { - if (pa.IsPhysical) // implies UsePhysics==false for this block + if (PhysActor.IsPhysical) // implies UsePhysics==false for this block { if (!isNew) ParentGroup.Scene.RemovePhysicalPrim(1); - pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; - pa.OnOutOfBounds -= PhysicsOutOfBounds; - pa.delink(); + PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; + PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; + PhysActor.delink(); if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) { // destroy all joints connected to this now deactivated body - m_parentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); + m_parentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(PhysActor); } // stop client-side interpolation of all joint proxy objects that have just been deleted @@ -1612,7 +1598,7 @@ if (m_shape != null) { //RotationalVelocity = new Vector3(0, 0, 0); } - pa.IsPhysical = UsePhysics; + PhysActor.IsPhysical = UsePhysics; // If we're not what we're supposed to be in the physics scene, recreate ourselves. @@ -1626,19 +1612,19 @@ if (m_shape != null) { { ParentGroup.Scene.AddPhysicalPrim(1); - pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; - pa.OnOutOfBounds += PhysicsOutOfBounds; + PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; + PhysActor.OnOutOfBounds += PhysicsOutOfBounds; if (_parentID != 0 && _parentID != LocalId) { if (ParentGroup.RootPart.PhysActor != null) { - pa.link(ParentGroup.RootPart.PhysActor); + PhysActor.link(ParentGroup.RootPart.PhysActor); } } } } } - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); } } } @@ -1704,10 +1690,9 @@ if (m_shape != null) { public Vector3 GetGeometricCenter() { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); + return new Vector3(PhysActor.CenterOfMass.X, PhysActor.CenterOfMass.Y, PhysActor.CenterOfMass.Z); } else { @@ -1717,10 +1702,9 @@ if (m_shape != null) { public float GetMass() { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - return pa.Mass; + return PhysActor.Mass; } else { @@ -1730,9 +1714,8 @@ if (m_shape != null) { public PhysicsVector GetForce() { - PhysicsActor pa = PhysActor; - if (pa != null) - return pa.Force; + if (PhysActor != null) + return PhysActor.Force; else return new PhysicsVector(); } @@ -2111,15 +2094,11 @@ if (m_shape != null) { public void PhysicsRequestingTerseUpdate() { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); + Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0); - if (m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | - m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | - m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | - m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) + if (m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) { m_parentGroup.AbsolutePosition = newpos; return; @@ -2315,15 +2294,14 @@ if (m_shape != null) { if (texture != null) m_shape.SculptData = texture.Data; - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { // Tricks physics engine into thinking we've changed the part shape. PrimitiveBaseShape m_newshape = m_shape.Copy(); - pa.Shape = m_newshape; + PhysActor.Shape = m_newshape; m_shape = m_newshape; - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); } } } @@ -2542,10 +2520,9 @@ if (m_shape != null) { public void SetBuoyancy(float fvalue) { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.Buoyancy = fvalue; + PhysActor.Buoyancy = fvalue; } } @@ -2561,62 +2538,56 @@ if (m_shape != null) { public void SetFloatOnWater(int floatYN) { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { if (floatYN == 1) { - pa.FloatOnWater = true; + PhysActor.FloatOnWater = true; } else { - pa.FloatOnWater = false; + PhysActor.FloatOnWater = false; } } } public void SetForce(PhysicsVector force) { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.Force = force; + PhysActor.Force = force; } } public void SetVehicleType(int type) { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.VehicleType = type; + PhysActor.VehicleType = type; } } public void SetVehicleFloatParam(int param, float value) { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.VehicleFloatParam(param, value); + PhysActor.VehicleFloatParam(param, value); } } public void SetVehicleVectorParam(int param, PhysicsVector value) { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.VehicleVectorParam(param, value); + PhysActor.VehicleVectorParam(param, value); } } public void SetVehicleRotationParam(int param, Quaternion rotation) { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.VehicleRotationParam(param, rotation); + PhysActor.VehicleRotationParam(param, rotation); } } @@ -2644,11 +2615,10 @@ if (m_shape != null) { public void SetPhysicsAxisRotation() { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.LockAngularMotion(RotationAxis); - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); + PhysActor.LockAngularMotion(RotationAxis); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); } } @@ -3380,9 +3350,8 @@ if (m_shape != null) { { IsVD = false; // Switch it of for the course of this routine VolumeDetectActive = false; // and also permanently - PhysicsActor pa = PhysActor; - if (pa != null) - pa.SetVolumeDetect(0); // Let physics know about it too + if (PhysActor != null) + PhysActor.SetVolumeDetect(0); // Let physics know about it too } else { @@ -3430,21 +3399,18 @@ if (m_shape != null) { if (IsPhantom || IsAttachment) // note: this may have been changed above in the case of joints { AddFlag(PrimFlags.Phantom); - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - m_parentGroup.Scene.PhysicsScene.RemovePrim(pa); + m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); /// that's not wholesome. Had to make Scene public - pa = null; + PhysActor = null; } } else // Not phantom { RemFlag(PrimFlags.Phantom); - // This is NOT safe!! - PhysicsActor pa = PhysActor; - if (pa == null) + if (PhysActor == null) { // It's not phantom anymore. So make sure the physics engine get's knowledge of it PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( @@ -3455,9 +3421,9 @@ if (m_shape != null) { RotationOffset, UsePhysics); - if (pa != null) + if (PhysActor != null) { - pa.LocalID = LocalId; + PhysActor.LocalID = LocalId; DoPhysicsPropertyUpdate(UsePhysics, true); if (m_parentGroup != null) { @@ -3476,14 +3442,14 @@ if (m_shape != null) { (CollisionSound != UUID.Zero) ) { - pa.OnCollisionUpdate += PhysicsCollision; - pa.SubscribeEvents(1000); + PhysActor.OnCollisionUpdate += PhysicsCollision; + PhysActor.SubscribeEvents(1000); } } } else // it already has a physical representation { - pa.IsPhysical = UsePhysics; + PhysActor.IsPhysical = UsePhysics; DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim if (m_parentGroup != null) @@ -3506,10 +3472,9 @@ if (m_shape != null) { // Defensive programming calls for a check here. // Better would be throwing an exception that could be catched by a unit test as the internal // logic should make sure, this Physactor is always here. - PhysicsActor pa = this.PhysActor; - if (pa != null) + if (this.PhysActor != null) { - pa.SetVolumeDetect(1); + PhysActor.SetVolumeDetect(1); AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active this.VolumeDetectActive = true; } @@ -3517,11 +3482,10 @@ if (m_shape != null) { } else { // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like - // (mumbles, well, at least if you have infinte CPU powers :-) ) - PhysicsActor pa = this.PhysActor; - if (pa != null) + // (mumbles, well, at least if you have infinte CPU powers :-)) + if (this.PhysActor != null) { - pa.SetVolumeDetect(0); + PhysActor.SetVolumeDetect(0); } this.VolumeDetectActive = false; } @@ -3579,11 +3543,10 @@ if (m_shape != null) { m_shape.PathTaperY = shapeBlock.PathTaperY; m_shape.PathTwist = shapeBlock.PathTwist; m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.Shape = m_shape; - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); + PhysActor.Shape = m_shape; + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); } // This is what makes vehicle trailers work @@ -3684,21 +3647,19 @@ if (m_shape != null) { ) { // subscribe to physics updates. - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.OnCollisionUpdate += PhysicsCollision; - pa.SubscribeEvents(1000); + PhysActor.OnCollisionUpdate += PhysicsCollision; + PhysActor.SubscribeEvents(1000); } } else { - PhysicsActor pa = PhysActor; - if (pa != null) + if (PhysActor != null) { - pa.UnSubscribeEvents(); - pa.OnCollisionUpdate -= PhysicsCollision; + PhysActor.UnSubscribeEvents(); + PhysActor.OnCollisionUpdate -= PhysicsCollision; } } @@ -3801,8 +3762,6 @@ if (m_shape != null) { lPos = AbsolutePosition; } - // Causes this thread to dig into the Client Thread Data. - // Remember your locking here! remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index bf13607..e74b18e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs @@ -70,7 +70,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests grp1.Rotation = (Quaternion.CreateFromEulers(90 * Utils.DEG_TO_RAD, 0, 0)); // <180,0,0> - grp2.UpdateGroupRotation(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); + grp2.UpdateGroupRotationR(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); // Required for linking grp1.RootPart.UpdateFlag = 0; @@ -154,13 +154,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests grp1.Rotation = (Quaternion.CreateFromEulers(90 * Utils.DEG_TO_RAD, 0, 0)); // <180,0,0> - grp2.UpdateGroupRotation(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); + grp2.UpdateGroupRotationR(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); // <270,0,0> grp3.Rotation = (Quaternion.CreateFromEulers(270 * Utils.DEG_TO_RAD, 0, 0)); // <0,90,0> - grp4.UpdateGroupRotation(Quaternion.CreateFromEulers(0, 90 * Utils.DEG_TO_RAD, 0)); + grp4.UpdateGroupRotationR(Quaternion.CreateFromEulers(0, 90 * Utils.DEG_TO_RAD, 0)); // Required for linking grp1.RootPart.UpdateFlag = 0; -- cgit v1.1 From 53fbc970cabf7ce94f771de5d4ccd1757005d16e Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Wed, 30 Sep 2009 18:58:52 +0200 Subject: Small chaneg to adapt to trunk --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 40e7471..b284ed4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3421,9 +3421,10 @@ if (m_shape != null) { RotationOffset, UsePhysics); - if (PhysActor != null) + PhysicsActor pa = PhysActor; + if (pa != null) { - PhysActor.LocalID = LocalId; + pa.LocalID = LocalId; DoPhysicsPropertyUpdate(UsePhysics, true); if (m_parentGroup != null) { -- cgit v1.1 From 6b65eb76d0a664a582f10ac105733d3cdc2b4897 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Wed, 30 Sep 2009 19:01:55 +0200 Subject: Another small change to avoid later merge conflict --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b284ed4..203faed 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3410,7 +3410,8 @@ if (m_shape != null) { { RemFlag(PrimFlags.Phantom); - if (PhysActor == null) + PhysicsActor pa = PhysActor; + if (pa == null) { // It's not phantom anymore. So make sure the physics engine get's knowledge of it PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( @@ -3421,7 +3422,7 @@ if (m_shape != null) { RotationOffset, UsePhysics); - PhysicsActor pa = PhysActor; + pa = PhysActor; if (pa != null) { pa.LocalID = LocalId; -- cgit v1.1 From 11750a272eab3bb259b2808bb276b5c9f59ad9f6 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Wed, 30 Sep 2009 19:04:06 +0200 Subject: And another --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 203faed..d983b75 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3485,7 +3485,7 @@ if (m_shape != null) { else { // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like // (mumbles, well, at least if you have infinte CPU powers :-)) - if (this.PhysActor != null) + if (pa != null) { PhysActor.SetVolumeDetect(0); } -- cgit v1.1 From d43f739cef2c31200ab297d596b073da29972118 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Wed, 30 Sep 2009 19:05:39 +0200 Subject: And another merge issue --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index d983b75..9819163 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3485,6 +3485,7 @@ if (m_shape != null) { else { // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like // (mumbles, well, at least if you have infinte CPU powers :-)) + PhysicsActor pa = this.PhysActor; if (pa != null) { PhysActor.SetVolumeDetect(0); -- cgit v1.1 From 212e132e79f868fd3bb9bcf9ef2c13eb12f8c14e Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 2 Oct 2009 00:47:01 +0100 Subject: Revert "* Adding Scale to EntityBase * Fixing the incorrect initialization of EntityBase.Rotation * Removed SceneObjectGroup.GroupRotation and added overrides for Scale/Rotation/Velocity" This reverts commit 39842eb4af3b5a8c52d56c0f7f05ad54f0651bb0. --- OpenSim/Region/Framework/Scenes/EntityBase.cs | 18 +++++-------- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +-- .../Region/Framework/Scenes/SceneObjectGroup.cs | 30 +++++----------------- 3 files changed, 16 insertions(+), 36 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EntityBase.cs b/OpenSim/Region/Framework/Scenes/EntityBase.cs index 27a0785..c2ec6a5 100644 --- a/OpenSim/Region/Framework/Scenes/EntityBase.cs +++ b/OpenSim/Region/Framework/Scenes/EntityBase.cs @@ -94,7 +94,7 @@ namespace OpenSim.Region.Framework.Scenes set { m_velocity = value; } } - protected Quaternion m_rotation; + protected Quaternion m_rotation = new Quaternion(0f, 0f, 1f, 0f); public virtual Quaternion Rotation { @@ -102,14 +102,6 @@ namespace OpenSim.Region.Framework.Scenes set { m_rotation = value; } } - protected Vector3 m_scale; - - public virtual Vector3 Scale - { - get { return m_scale; } - set { m_scale = value; } - } - protected uint m_localId; public virtual uint LocalId @@ -123,9 +115,13 @@ namespace OpenSim.Region.Framework.Scenes /// public EntityBase() { - m_rotation = Quaternion.Identity; - m_scale = Vector3.One; + m_uuid = UUID.Zero; + + m_pos = Vector3.Zero; + m_velocity = Vector3.Zero; + Rotation = Quaternion.Identity; m_name = "(basic entity)"; + m_rotationalvelocity = Vector3.Zero; } /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 55ec281..9db2240 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2305,8 +2305,8 @@ namespace OpenSim.Region.Framework.Scenes "to avatar {0} at position {1}", sp.UUID.ToString(), grp.AbsolutePosition); AttachObject(sp.ControllingClient, - grp.LocalId, 0, - grp.Rotation, + grp.LocalId, (uint)0, + grp.GroupRotation, grp.AbsolutePosition, false); RootPrim.RemFlag(PrimFlags.TemporaryOnRez); grp.SendGroupFullUpdate(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6b4cc0d..9f44f92 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -204,22 +204,9 @@ namespace OpenSim.Region.Framework.Scenes get { return m_parts.Count; } } - public override Quaternion Rotation + public Quaternion GroupRotation { get { return m_rootPart.RotationOffset; } - set { m_rootPart.RotationOffset = value; } - } - - public override Vector3 Scale - { - get { return m_rootPart.Scale; } - set { m_rootPart.Scale = value; } - } - - public override Vector3 Velocity - { - get { return m_rootPart.Velocity; } - set { m_rootPart.Velocity = value; } } public UUID GroupID @@ -548,7 +535,7 @@ namespace OpenSim.Region.Framework.Scenes // Temporary commented to stop compiler warning //Vector3 partPosition = // new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); - Quaternion parentrotation = Rotation; + Quaternion parentrotation = GroupRotation; // Telling the prim to raytrace. //EntityIntersection inter = part.TestIntersection(hRay, parentrotation); @@ -1891,17 +1878,14 @@ namespace OpenSim.Region.Framework.Scenes checkAtTargets(); - Quaternion rot = Rotation; - - if (UsePhysics && - ((Math.Abs(lastPhysGroupRot.W - rot.W) > 0.1f) - || (Math.Abs(lastPhysGroupRot.X - rot.X) > 0.1f) - || (Math.Abs(lastPhysGroupRot.Y - rot.Y) > 0.1f) - || (Math.Abs(lastPhysGroupRot.Z - rot.Z) > 0.1f))) + if (UsePhysics && ((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))) { m_rootPart.UpdateFlag = 1; - lastPhysGroupRot = rot; + lastPhysGroupRot = GroupRotation; } foreach (SceneObjectPart part in m_parts.Values) -- cgit v1.1