Merge branch 'master' into careminster

avinationmerge
Melanie 2012-04-22 15:06:06 +01:00
commit 8df4bd14f5
6 changed files with 360 additions and 256 deletions

View File

@ -2673,6 +2673,7 @@ namespace OpenSim.Region.Framework.Scenes
}
linkPart.LinkNum = linkNum++;
linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect);
SceneObjectPart[] ogParts = objectGroup.Parts;
Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b)
@ -2908,6 +2909,8 @@ namespace OpenSim.Region.Framework.Scenes
oldRot = part.RotationOffset;
Quaternion newRot = Quaternion.Inverse(parentRot) * worldRot;
part.RotationOffset = newRot;
part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect);
}
/// <summary>

View File

@ -2074,6 +2074,9 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="isNew"></param>
public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew)
{
if (ParentGroup.Scene == null)
return;
if (!ParentGroup.Scene.PhysicalPrims && UsePhysics)
return;
@ -4531,7 +4534,7 @@ namespace OpenSim.Region.Framework.Scenes
// For now, we use the NINJA naming scheme for identifying joints.
// In the future, we can support other joint specification schemes such as a
// custom checkbox in the viewer GUI.
if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
{
string hingeString = "hingejoint";
return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString);
@ -4547,7 +4550,7 @@ namespace OpenSim.Region.Framework.Scenes
// For now, we use the NINJA naming scheme for identifying joints.
// In the future, we can support other joint specification schemes such as a
// custom checkbox in the viewer GUI.
if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
{
string ballString = "balljoint";
return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString);
@ -4563,7 +4566,7 @@ namespace OpenSim.Region.Framework.Scenes
// For now, we use the NINJA naming scheme for identifying joints.
// In the future, we can support other joint specification schemes such as a
// custom checkbox in the viewer GUI.
if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
{
return IsHingeJoint() || IsBallJoint();
}

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using NUnit.Framework;
using OpenMetaverse;
@ -43,24 +44,137 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[TestFixture]
public class SceneObjectStatusTests
{
private TestScene m_scene;
private UUID m_ownerId = TestHelpers.ParseTail(0x1);
private SceneObjectGroup m_so1;
private SceneObjectGroup m_so2;
[SetUp]
public void Init()
{
m_scene = SceneHelpers.SetupScene();
m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10);
m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20);
}
[Test]
public void TestSetPhantom()
public void TestSetPhantomSinglePrim()
{
TestHelpers.InMethod();
// Scene scene = SceneSetupHelpers.SetupScene();
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero);
SceneObjectPart rootPart = so.RootPart;
SceneObjectPart rootPart = m_so1.RootPart;
Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
so.ScriptSetPhantomStatus(true);
m_so1.ScriptSetPhantomStatus(true);
// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
so.ScriptSetPhantomStatus(false);
m_so1.ScriptSetPhantomStatus(false);
Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
}
[Test]
public void TestSetPhysicsSinglePrim()
{
TestHelpers.InMethod();
SceneObjectPart rootPart = m_so1.RootPart;
Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
m_so1.ScriptSetPhysicsStatus(true);
// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
m_so1.ScriptSetPhysicsStatus(false);
Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
}
[Test]
public void TestSetPhysicsLinkset()
{
TestHelpers.InMethod();
m_scene.AddSceneObject(m_so1);
m_scene.AddSceneObject(m_so2);
m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
m_so1.ScriptSetPhysicsStatus(true);
Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
m_so1.ScriptSetPhysicsStatus(false);
Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
m_so1.ScriptSetPhysicsStatus(true);
Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
}
/// <summary>
/// Test that linking results in the correct physical status for all linkees.
/// </summary>
[Test]
public void TestLinkPhysicsBothPhysical()
{
TestHelpers.InMethod();
m_scene.AddSceneObject(m_so1);
m_scene.AddSceneObject(m_so2);
m_so1.ScriptSetPhysicsStatus(true);
m_so2.ScriptSetPhysicsStatus(true);
m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
}
/// <summary>
/// Test that linking results in the correct physical status for all linkees.
/// </summary>
[Test]
public void TestLinkPhysicsRootPhysicalOnly()
{
TestHelpers.InMethod();
m_scene.AddSceneObject(m_so1);
m_scene.AddSceneObject(m_so2);
m_so1.ScriptSetPhysicsStatus(true);
m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
}
/// <summary>
/// Test that linking results in the correct physical status for all linkees.
/// </summary>
[Test]
public void TestLinkPhysicsChildPhysicalOnly()
{
TestHelpers.InMethod();
m_scene.AddSceneObject(m_so1);
m_scene.AddSceneObject(m_so2);
m_so2.ScriptSetPhysicsStatus(true);
m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
}
}
}

View File

@ -156,7 +156,15 @@ namespace OpenSim.Region.Physics.OdePlugin
/// </summary>
public IntPtr m_targetSpace = IntPtr.Zero;
/// <summary>
/// The prim geometry, used for collision detection.
/// </summary>
/// <remarks>
/// This is never null except for a brief period when the geometry needs to be replaced (due to resizing or
/// mesh change) or when the physical prim is being removed from the scene.
/// </remarks>
public IntPtr prim_geom { get; private set; }
public IntPtr _triMeshData { get; private set; }
private IntPtr _linkJointGroup = IntPtr.Zero;
@ -325,14 +333,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{
prim_geom = geom;
//Console.WriteLine("SetGeom to " + prim_geom + " for " + Name);
if (prim_geom != IntPtr.Zero)
{
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
_parent_scene.geom_name_map[prim_geom] = Name;
_parent_scene.actor_name_map[prim_geom] = this;
}
if (childPrim)
{
@ -765,11 +770,8 @@ namespace OpenSim.Region.Physics.OdePlugin
m_collisionCategories &= ~CollisionCategories.Body;
m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land);
if (prim_geom != IntPtr.Zero)
{
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
}
d.BodyDestroy(Body);
lock (childrenPrim)
@ -793,11 +795,8 @@ namespace OpenSim.Region.Physics.OdePlugin
m_collisionCategories &= ~CollisionCategories.Body;
m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land);
if (prim_geom != IntPtr.Zero)
{
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
}
Body = IntPtr.Zero;
}
@ -863,12 +862,9 @@ namespace OpenSim.Region.Physics.OdePlugin
// _parent_scene.waitForSpaceUnlock(m_targetSpace);
try
{
if (prim_geom == IntPtr.Zero)
{
SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
}
}
catch (AccessViolationException)
{
m_log.ErrorFormat("[PHYSICS]: MESH LOCKED FOR {0}", Name);
@ -890,13 +886,12 @@ namespace OpenSim.Region.Physics.OdePlugin
#if SPAM
Console.WriteLine("ZProcessTaints for " + Name);
#endif
if (m_taintadd)
{
changeadd();
}
if (prim_geom != IntPtr.Zero)
{
// This must be processed as the very first taint so that later operations have a prim_geom to work with
// if this is a new prim.
if (m_taintadd)
changeadd();
if (!_position.ApproxEquals(m_taintposition, 0f))
changemove();
@ -953,11 +948,6 @@ Console.WriteLine("ZProcessTaints for " + Name);
if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f))
changeAngularLock();
}
else
{
m_log.ErrorFormat("[PHYSICS]: The scene reused a disposed PhysActor for {0}! *waves finger*, Don't be evil. A couple of things can cause this. An improper prim breakdown(be sure to set prim_geom to zero after d.GeomDestroy! An improper buildup (creating the geom failed). Or, the Scene Reused a physics actor after disposing it.)", Name);
}
}
/// <summary>
/// Change prim in response to an angular lock taint.
@ -1052,21 +1042,23 @@ Console.WriteLine("ZProcessTaints for " + Name);
/// <param name="prim">Child prim</param>
private void AddChildPrim(OdePrim prim)
{
//Console.WriteLine("AddChildPrim " + Name);
if (LocalID != prim.LocalID)
{
if (LocalID == prim.LocalID)
return;
if (Body == IntPtr.Zero)
{
Body = d.BodyCreate(_parent_scene.world);
setMass();
}
if (Body != IntPtr.Zero)
{
lock (childrenPrim)
{
if (!childrenPrim.Contains(prim))
{
//Console.WriteLine("childrenPrim.Add " + prim);
if (childrenPrim.Contains(prim))
return;
// m_log.DebugFormat(
// "[ODE PRIM]: Linking prim {0} {1} to {2} {3}", prim.Name, prim.LocalID, Name, LocalID);
childrenPrim.Add(prim);
foreach (OdePrim prm in childrenPrim)
@ -1093,18 +1085,10 @@ Console.WriteLine("ZProcessTaints for " + Name);
prm.m_collisionCategories |= CollisionCategories.Body;
prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
if (prm.prim_geom == IntPtr.Zero)
{
m_log.WarnFormat(
"[PHYSICS]: Unable to link one of the linkset elements {0} for parent {1}. No geom yet",
prm.Name, prim.Name);
continue;
}
//Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + Name);
d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories);
d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags);
d.Quaternion quat = new d.Quaternion();
quat.W = prm._orientation.W;
quat.X = prm._orientation.X;
@ -1183,19 +1167,21 @@ Console.WriteLine("ZProcessTaints for " + Name);
{
createAMotor(m_angularlock);
}
d.BodySetPosition(Body, Position.X, Position.Y, Position.Z);
if (m_vehicle.Type != Vehicle.TYPE_NONE)
m_vehicle.Enable(Body, _parent_scene);
_parent_scene.ActivatePrim(this);
}
}
}
}
}
private void ChildSetGeom(OdePrim odePrim)
{
// m_log.DebugFormat(
// "[ODE PRIM]: ChildSetGeom {0} {1} for {2} {3}", odePrim.Name, odePrim.LocalID, Name, LocalID);
//if (IsPhysical && Body != IntPtr.Zero)
lock (childrenPrim)
{
@ -1210,12 +1196,14 @@ Console.WriteLine("ZProcessTaints for " + Name);
//prm.childPrim = false;
}
}
disableBody();
if (Body != IntPtr.Zero)
{
_parent_scene.DeactivatePrim(this);
}
// Spurious - Body == IntPtr.Zero after disableBody()
// if (Body != IntPtr.Zero)
// {
// _parent_scene.DeactivatePrim(this);
// }
lock (childrenPrim)
{
@ -1229,6 +1217,9 @@ Console.WriteLine("ZProcessTaints for " + Name);
private void ChildDelink(OdePrim odePrim)
{
// m_log.DebugFormat(
// "[ODE PRIM]: Delinking prim {0} {1} from {2} {3}", odePrim.Name, odePrim.LocalID, Name, LocalID);
// Okay, we have a delinked child.. need to rebuild the body.
lock (childrenPrim)
{
@ -1243,6 +1234,7 @@ Console.WriteLine("ZProcessTaints for " + Name);
//prm.childPrim = false;
}
}
disableBody();
lock (childrenPrim)
@ -1251,10 +1243,11 @@ Console.WriteLine("ZProcessTaints for " + Name);
childrenPrim.Remove(odePrim);
}
if (Body != IntPtr.Zero)
{
_parent_scene.DeactivatePrim(this);
}
// Spurious - Body == IntPtr.Zero after disableBody()
// if (Body != IntPtr.Zero)
// {
// _parent_scene.DeactivatePrim(this);
// }
lock (childrenPrim)
{
@ -1303,11 +1296,8 @@ Console.WriteLine("ZProcessTaints for " + Name);
disableBodySoft();
}
if (prim_geom != IntPtr.Zero)
{
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
}
if (IsPhysical)
{
@ -1328,11 +1318,8 @@ Console.WriteLine("ZProcessTaints for " + Name);
if (m_collidesWater)
m_collisionFlags |= CollisionCategories.Water;
if (prim_geom != IntPtr.Zero)
{
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
}
if (IsPhysical)
{
@ -1472,6 +1459,9 @@ Console.WriteLine("CreateGeom:");
}
else
{
m_log.WarnFormat(
"[ODE PRIM]: Called RemoveGeom() on {0} {1} where geometry was already null.", Name, LocalID);
return false;
}
}
@ -1505,8 +1495,6 @@ Console.WriteLine("changeadd 1");
#endif
CreateGeom(m_targetSpace, mesh);
if (prim_geom != IntPtr.Zero)
{
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
d.Quaternion myrot = new d.Quaternion();
myrot.X = _orientation.X;
@ -1514,7 +1502,6 @@ Console.WriteLine("changeadd 1");
myrot.Z = _orientation.Z;
myrot.W = _orientation.W;
d.GeomSetQuaternion(prim_geom, ref myrot);
}
if (IsPhysical && Body == IntPtr.Zero)
enableBody();
@ -1588,13 +1575,11 @@ Console.WriteLine(" JointCreateFixed");
m_targetSpace = tempspace;
// _parent_scene.waitForSpaceUnlock(m_targetSpace);
if (prim_geom != IntPtr.Zero)
{
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
// _parent_scene.waitForSpaceUnlock(m_targetSpace);
d.SpaceAdd(m_targetSpace, prim_geom);
}
changeSelectedStatus();
@ -2045,8 +2030,6 @@ Console.WriteLine(" JointCreateFixed");
{
m_collidesWater = m_taintCollidesWater;
if (prim_geom != IntPtr.Zero)
{
if (m_collidesWater)
{
m_collisionFlags |= CollisionCategories.Water;
@ -2055,9 +2038,9 @@ Console.WriteLine(" JointCreateFixed");
{
m_collisionFlags &= ~CollisionCategories.Water;
}
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
}
}
/// <summary>
/// Change prim in response to a shape taint.

View File

@ -2226,7 +2226,8 @@ namespace OpenSim.Region.Physics.OdePlugin
/// <param name="prim"></param>
internal void RemovePrimThreadLocked(OdePrim prim)
{
//Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName);
// m_log.DebugFormat("[ODE SCENE]: Removing physical prim {0} {1}", prim.Name, prim.LocalID);
lock (prim)
{
RemoveCollisionEventReporting(prim);