Fix bug where setting phantom on a prim would result in a server log message rather than setting phantom.

This was an oversight when removing some race conditions from PhysicsActor setting recently.
Regression tests extended to probe this code path.
Extending regression tests required implementation of a BasicPhysicsPrim (there was none before).  However, BasicPhysics plugin is still of no current practical use other than to fill in as a component for other parts of regression testing.
0.7.3-extended
Justin Clark-Casey (justincc) 2012-04-22 19:51:51 +01:00
parent 2889961622
commit 2cd927bb14
6 changed files with 383 additions and 33 deletions

View File

@ -102,9 +102,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
Vector3 groupPosition = new Vector3(10, 20, 30); Vector3 groupPosition = new Vector3(10, 20, 30);
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
Vector3 offsetPosition = new Vector3(5, 10, 15); // Vector3 offsetPosition = new Vector3(5, 10, 15);
return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, Vector3.Zero) { Name = partName };
} }
protected SceneObjectPart CreateSceneObjectPart2() protected SceneObjectPart CreateSceneObjectPart2()

View File

@ -685,8 +685,8 @@ namespace OpenSim.Region.Framework.Scenes
//Animation states //Animation states
m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims);
CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims);
m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
if (RegionInfo.NonphysPrimMax > 0) if (RegionInfo.NonphysPrimMax > 0)
@ -801,13 +801,11 @@ namespace OpenSim.Region.Framework.Scenes
StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
} }
/// <summary>
/// Mock constructor for scene group persistency unit tests.
/// SceneObjectGroup RegionId property is delegated to Scene.
/// </summary>
/// <param name="regInfo"></param>
public Scene(RegionInfo regInfo) public Scene(RegionInfo regInfo)
{ {
PhysicalPrims = true;
CollidablePrims = true;
BordersLocked = true; BordersLocked = true;
Border northBorder = new Border(); Border northBorder = new Border();
northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<---
@ -834,8 +832,6 @@ namespace OpenSim.Region.Framework.Scenes
m_eventManager = new EventManager(); m_eventManager = new EventManager();
m_permissions = new ScenePermissions(this); m_permissions = new ScenePermissions(this);
// m_lastUpdate = Util.EnvironmentTickCount();
} }
#endregion #endregion

View File

@ -4283,7 +4283,10 @@ namespace OpenSim.Region.Framework.Scenes
AddFlag(PrimFlags.Phantom); AddFlag(PrimFlags.Phantom);
if (PhysActor != null) if (PhysActor != null)
{
RemoveFromPhysics(); RemoveFromPhysics();
pa = null;
}
} }
else // Not phantom else // Not phantom
{ {
@ -4349,7 +4352,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
pa.SetVolumeDetect(1); pa.SetVolumeDetect(1);
AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
this.VolumeDetectActive = true; VolumeDetectActive = true;
} }
} }
else else
@ -4357,9 +4360,9 @@ namespace OpenSim.Region.Framework.Scenes
// Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like // 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 :-)) // (mumbles, well, at least if you have infinte CPU powers :-))
if (pa != null) if (pa != null)
PhysActor.SetVolumeDetect(0); pa.SetVolumeDetect(0);
this.VolumeDetectActive = false; VolumeDetectActive = false;
} }
if (SetTemporary) if (SetTemporary)

View File

@ -62,6 +62,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
m_scene.AddSceneObject(m_so1);
SceneObjectPart rootPart = m_so1.RootPart; SceneObjectPart rootPart = m_so1.RootPart;
Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));

View File

@ -0,0 +1,344 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Physics.Manager;
namespace OpenSim.Region.Physics.BasicPhysicsPlugin
{
public class BasicPhysicsPrim : PhysicsActor
{
private Vector3 _position;
private Vector3 _velocity;
private Vector3 _acceleration;
private Vector3 _size;
private PrimitiveBaseShape _shape;
private Vector3 m_rotationalVelocity;
private bool flying;
private bool iscolliding;
public BasicPhysicsPrim(
string name, uint localId, Vector3 position, Vector3 size, Quaternion orientation, PrimitiveBaseShape shape)
{
Name = name;
LocalID = localId;
Position = position;
Size = size;
Orientation = orientation;
Shape = shape;
}
public override int PhysicsActorType
{
get { return (int) ActorTypes.Agent; }
set { return; }
}
public override Vector3 RotationalVelocity
{
get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; }
}
public override bool SetAlwaysRun
{
get { return false; }
set { return; }
}
public override uint LocalID
{
set { return; }
}
public override bool Grabbed
{
set { return; }
}
public override bool Selected
{
set { return; }
}
public override float Buoyancy
{
get { return 0f; }
set { return; }
}
public override bool FloatOnWater
{
set { return; }
}
public override bool IsPhysical
{
get { return false; }
set { return; }
}
public override bool ThrottleUpdates
{
get { return false; }
set { return; }
}
public override bool Flying
{
get { return flying; }
set { flying = value; }
}
public override bool IsColliding
{
get { return iscolliding; }
set { iscolliding = value; }
}
public override bool CollidingGround
{
get { return false; }
set { return; }
}
public override bool CollidingObj
{
get { return false; }
set { return; }
}
public override bool Stopped
{
get { return false; }
}
public override Vector3 Position
{
get { return _position; }
set { _position = value; }
}
public override Vector3 Size
{
get { return _size; }
set {
_size = value;
_size.Z = _size.Z / 2.0f;
}
}
public override PrimitiveBaseShape Shape
{
set { _shape = value; }
}
public override float Mass
{
get { return 0f; }
}
public override Vector3 Force
{
get { return Vector3.Zero; }
set { return; }
}
public override int VehicleType
{
get { return 0; }
set { return; }
}
public override void VehicleFloatParam(int param, float value)
{
}
public override void VehicleVectorParam(int param, Vector3 value)
{
}
public override void VehicleRotationParam(int param, Quaternion rotation)
{
}
public override void VehicleFlags(int param, bool remove)
{
}
public override void SetVolumeDetect(int param)
{
}
public override Vector3 CenterOfMass
{
get { return Vector3.Zero; }
}
public override Vector3 GeometricCenter
{
get { return Vector3.Zero; }
}
public override Vector3 Velocity
{
get { return _velocity; }
set { _velocity = value; }
}
public override Vector3 Torque
{
get { return Vector3.Zero; }
set { return; }
}
public override float CollisionScore
{
get { return 0f; }
set { }
}
public override Quaternion Orientation { get; set; }
public override Vector3 Acceleration
{
get { return _acceleration; }
set { _acceleration = value; }
}
public override bool Kinematic
{
get { return true; }
set { }
}
public override void link(PhysicsActor obj)
{
}
public override void delink()
{
}
public override void LockAngularMotion(Vector3 axis)
{
}
public override void AddForce(Vector3 force, bool pushforce)
{
}
public override void AddAngularForce(Vector3 force, bool pushforce)
{
}
public override void SetMomentum(Vector3 momentum)
{
}
public override void CrossingFailure()
{
}
public override Vector3 PIDTarget
{
set { return; }
}
public override bool PIDActive
{
set { return; }
}
public override float PIDTau
{
set { return; }
}
public override float PIDHoverHeight
{
set { return; }
}
public override bool PIDHoverActive
{
set { return; }
}
public override PIDHoverType PIDHoverType
{
set { return; }
}
public override float PIDHoverTau
{
set { return; }
}
public override Quaternion APIDTarget
{
set { return; }
}
public override bool APIDActive
{
set { return; }
}
public override float APIDStrength
{
set { return; }
}
public override float APIDDamping
{
set { return; }
}
public override void SubscribeEvents(int ms)
{
}
public override void UnSubscribeEvents()
{
}
public override bool SubscribedEvents()
{
return false;
}
}
}

View File

@ -34,9 +34,17 @@ using OpenSim.Region.Physics.Manager;
namespace OpenSim.Region.Physics.BasicPhysicsPlugin namespace OpenSim.Region.Physics.BasicPhysicsPlugin
{ {
/// <summary>
/// This is an incomplete extremely basic physics implementation
/// </summary>
/// <remarks>
/// Not useful for anything at the moment apart from some regression testing in other components where some form
/// of physics plugin is needed.
/// </remarks>
public class BasicScene : PhysicsScene public class BasicScene : PhysicsScene
{ {
private List<BasicActor> _actors = new List<BasicActor>(); private List<BasicActor> _actors = new List<BasicActor>();
private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>();
private float[] _heightMap; private float[] _heightMap;
//protected internal string sceneIdentifier; //protected internal string sceneIdentifier;
@ -50,10 +58,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
{ {
} }
public override void Dispose() public override void Dispose() {}
{
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
{
BasicPhysicsPrim prim = new BasicPhysicsPrim(primName, localid, position, size, rotation, pbs);
prim.IsPhysical = isPhysical;
_prims.Add(prim);
return prim;
} }
public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
{ {
BasicActor act = new BasicActor(size); BasicActor act = new BasicActor(size);
@ -63,30 +80,18 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
return act; return act;
} }
public override void RemovePrim(PhysicsActor prim) public override void RemovePrim(PhysicsActor actor)
{ {
BasicPhysicsPrim prim = (BasicPhysicsPrim)actor;
if (_prims.Contains(prim))
_prims.Remove(prim);
} }
public override void RemoveAvatar(PhysicsActor actor) public override void RemoveAvatar(PhysicsActor actor)
{ {
BasicActor act = (BasicActor) actor; BasicActor act = (BasicActor)actor;
if (_actors.Contains(act)) if (_actors.Contains(act))
{
_actors.Remove(act); _actors.Remove(act);
}
}
/*
public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
{
return null;
}
*/
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
{
return null;
} }
public override void AddPhysicsActorTaint(PhysicsActor prim) public override void AddPhysicsActorTaint(PhysicsActor prim)