Merge branch 'master' into careminster

avinationmerge
Melanie 2013-01-26 01:56:23 +00:00
commit e28c042dce
10 changed files with 523 additions and 118 deletions

View File

@ -41,7 +41,7 @@ using System.Linq.Expressions;
namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")]
class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms
public class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

View File

@ -592,11 +592,11 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
cdl.AddRow(
"LightColor",
string.Format("<{0},{1},{2},{3}>", s.LightColorR, s.LightColorB, s.LightColorG, s.LightColorA));
cdl.AddRow("FlexiDrag", s.LightCutoff);
cdl.AddRow("FlexiDrag", s.LightEntry);
cdl.AddRow("FlexiDrag", s.LightFalloff);
cdl.AddRow("FlexiDrag", s.LightIntensity);
cdl.AddRow("FlexiDrag", s.LightRadius);
cdl.AddRow("LightCutoff", s.LightCutoff);
cdl.AddRow("LightEntry", s.LightEntry);
cdl.AddRow("LightFalloff", s.LightFalloff);
cdl.AddRow("LightIntensity", s.LightIntensity);
cdl.AddRow("LightRadius", s.LightRadius);
cdl.AddRow("Media", string.Format("{0} entries", s.Media != null ? s.Media.Count.ToString() : "n/a"));
cdl.AddRow("PathBegin", s.PathBegin);
cdl.AddRow("PathEnd", s.PathEnd);

View File

@ -92,12 +92,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
}
catch (Exception e)
{
m_log.ErrorFormat("[JsonStoreScripts] initialization error: {0}",e.Message);
m_log.ErrorFormat("[JsonStoreScripts]: initialization error: {0}", e.Message);
return;
}
if (m_enabled)
m_log.DebugFormat("[JsonStoreScripts] module is enabled");
m_log.DebugFormat("[JsonStoreScripts]: module is enabled");
}
// -----------------------------------------------------------------
@ -150,7 +150,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
m_comms = m_scene.RequestModuleInterface<IScriptModuleComms>();
if (m_comms == null)
{
m_log.ErrorFormat("[JsonStoreScripts] ScriptModuleComms interface not defined");
m_log.ErrorFormat("[JsonStoreScripts]: ScriptModuleComms interface not defined");
m_enabled = false;
return;
}
@ -158,40 +158,40 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
m_store = m_scene.RequestModuleInterface<IJsonStoreModule>();
if (m_store == null)
{
m_log.ErrorFormat("[JsonStoreScripts] JsonModule interface not defined");
m_log.ErrorFormat("[JsonStoreScripts]: JsonModule interface not defined");
m_enabled = false;
return;
}
try
{
m_comms.RegisterScriptInvocation(this,"JsonCreateStore");
m_comms.RegisterScriptInvocation(this,"JsonDestroyStore");
m_comms.RegisterScriptInvocation(this, "JsonCreateStore");
m_comms.RegisterScriptInvocation(this, "JsonDestroyStore");
m_comms.RegisterScriptInvocation(this,"JsonReadNotecard");
m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard");
m_comms.RegisterScriptInvocation(this, "JsonReadNotecard");
m_comms.RegisterScriptInvocation(this, "JsonWriteNotecard");
m_comms.RegisterScriptInvocation(this,"JsonTestPath");
m_comms.RegisterScriptInvocation(this,"JsonTestPathJson");
m_comms.RegisterScriptInvocation(this, "JsonTestPath");
m_comms.RegisterScriptInvocation(this, "JsonTestPathJson");
m_comms.RegisterScriptInvocation(this,"JsonGetValue");
m_comms.RegisterScriptInvocation(this,"JsonGetValueJson");
m_comms.RegisterScriptInvocation(this, "JsonGetValue");
m_comms.RegisterScriptInvocation(this, "JsonGetValueJson");
m_comms.RegisterScriptInvocation(this,"JsonTakeValue");
m_comms.RegisterScriptInvocation(this,"JsonTakeValueJson");
m_comms.RegisterScriptInvocation(this, "JsonTakeValue");
m_comms.RegisterScriptInvocation(this, "JsonTakeValueJson");
m_comms.RegisterScriptInvocation(this,"JsonReadValue");
m_comms.RegisterScriptInvocation(this,"JsonReadValueJson");
m_comms.RegisterScriptInvocation(this, "JsonReadValue");
m_comms.RegisterScriptInvocation(this, "JsonReadValueJson");
m_comms.RegisterScriptInvocation(this,"JsonSetValue");
m_comms.RegisterScriptInvocation(this,"JsonSetValueJson");
m_comms.RegisterScriptInvocation(this, "JsonSetValue");
m_comms.RegisterScriptInvocation(this, "JsonSetValueJson");
m_comms.RegisterScriptInvocation(this,"JsonRemoveValue");
m_comms.RegisterScriptInvocation(this, "JsonRemoveValue");
}
catch (Exception e)
{
// See http://opensimulator.org/mantis/view.php?id=5971 for more information
m_log.WarnFormat("[JsonStroreScripts] script method registration failed; {0}",e.Message);
m_log.WarnFormat("[JsonStoreScripts]: script method registration failed; {0}", e.Message);
m_enabled = false;
}
}
@ -354,7 +354,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
}
catch (Exception e)
{
m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString());
m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString());
}
DispatchValue(scriptID,reqID,String.Empty);
@ -389,7 +389,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
}
catch (Exception e)
{
m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString());
m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString());
}
DispatchValue(scriptID,reqID,String.Empty);
@ -421,7 +421,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
if (a.Type != (sbyte)AssetType.Notecard)
GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID));
m_log.DebugFormat("[JsonStoreScripts] read notecard in context {0}",storeID);
m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID);
try
{
@ -432,7 +432,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
}
catch (Exception e)
{
m_log.WarnFormat("[JsonStoreScripts] Json parsing failed; {0}",e.Message);
m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}",e.Message);
}
GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString()));

View File

@ -0,0 +1,145 @@
/*
* 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 System.Reflection;
using System.Text;
using log4net;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Scripting.ScriptModuleComms;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api;
using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
{
/// <summary>
/// Tests for inventory functions in LSL
/// </summary>
[TestFixture]
public class LSL_ApiInventoryTests : OpenSimTestCase
{
private Scene m_scene;
private MockScriptEngine m_engine;
private ScriptModuleCommsModule m_smcm;
[SetUp]
public override void SetUp()
{
base.SetUp();
TestHelpers.EnableLogging();
IConfigSource configSource = new IniConfigSource();
IConfig jsonStoreConfig = configSource.AddConfig("JsonStore");
jsonStoreConfig.Set("Enabled", "true");
m_engine = new MockScriptEngine();
m_smcm = new ScriptModuleCommsModule();
JsonStoreModule jsm = new JsonStoreModule();
JsonStoreScriptModule jssm = new JsonStoreScriptModule();
m_scene = new SceneHelpers().SetupScene();
SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm);
}
// [Test]
public void TestJsonCreateStore()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID storeId = (UUID)m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{}" });
Assert.That(storeId, Is.Not.EqualTo(UUID.Zero));
}
// [Test]
public void TestJsonGetValue()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID storeId
= (UUID)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" });
string value
= (string)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" });
Assert.That(value, Is.EqualTo("World"));
}
// [Test]
public void TestJsonTestPath()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID storeId
= (UUID)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" });
int result
= (int)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonTestPath", new object[] { storeId, "Hello" });
Assert.That(result, Is.EqualTo(1));
}
// [Test]
public void TestJsonSetValue()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID storeId
= (UUID)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ }" });
int result
= (int)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonSetValue", new object[] { storeId, "Hello", "World" });
Assert.That(result, Is.EqualTo(1));
string value
= (string)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" });
Assert.That(value, Is.EqualTo("World"));
}
}
}

View File

@ -74,6 +74,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
[SetUp]
public void Init()
{
base.SetUp();
IConfigSource config = new IniConfigSource();
config.AddConfig("NPC");
config.Configs["NPC"].Set("Enabled", "true");

View File

@ -48,7 +48,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SceneCommandsModule")]
public class SceneCommandsModule : ISceneCommandsModule, INonSharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;

View File

@ -137,6 +137,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
internal int LastEntityProperty = 0;
internal EntityProperties[] UpdatedObjects;
internal Dictionary<uint, GhostObject> specialCollisionObjects;
private static int m_collisionsThisFrame;
private BSScene PhysicsScene { get; set; }
@ -158,7 +159,13 @@ private sealed class BulletConstraintXNA : BulletConstraint
{
DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
RigidBody body = ((BulletBodyXNA)pBody).rigidBody;
CollisionObject collisionObject = ((BulletBodyXNA)pBody).body;
if (body != null)
world.RemoveRigidBody(body);
else if (collisionObject != null)
world.RemoveCollisionObject(collisionObject);
else
return false;
return true;
}
@ -182,7 +189,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
public override void SetRestitution(BulletBody pCollisionObject, float pRestitution)
{
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
collisionObject.SetRestitution(pRestitution);
}
@ -219,13 +226,13 @@ private sealed class BulletConstraintXNA : BulletConstraint
public override void SetCcdMotionThreshold(BulletBody pCollisionObject, float pccdMotionThreashold)
{
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
collisionObject.SetCcdMotionThreshold(pccdMotionThreashold);
}
public override void SetCcdSweptSphereRadius(BulletBody pCollisionObject, float pCcdSweptSphereRadius)
{
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
collisionObject.SetCcdSweptSphereRadius(pCcdSweptSphereRadius);
}
@ -262,7 +269,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
}
else
{
world.AddCollisionObject(rbody);
world.AddCollisionObject(cbody);
}
cbody.SetWorldTransform(origPos);
@ -303,7 +310,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
public override bool SetCollisionGroupMask(BulletBody pCollisionObject, uint pGroup, uint pMask)
{
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
collisionObject.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup;
collisionObject.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup;
if ((uint) collisionObject.GetBroadphaseHandle().m_collisionFilterGroup == 0)
@ -390,7 +397,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
public override void SetTranslation(BulletBody pCollisionObject, Vector3 _position, Quaternion _orientation)
{
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
IndexedVector3 vposition = new IndexedVector3(_position.X, _position.Y, _position.Z);
IndexedQuaternion vquaternion = new IndexedQuaternion(_orientation.X, _orientation.Y, _orientation.Z,
_orientation.W);
@ -418,9 +425,12 @@ private sealed class BulletConstraintXNA : BulletConstraint
public override void SetMassProps(BulletBody pBody, float pphysMass, Vector3 plocalInertia)
{
RigidBody body = (pBody as BulletBodyXNA).rigidBody;
if (body != null) // Can't set mass props on collision object.
{
IndexedVector3 inertia = new IndexedVector3(plocalInertia.X, plocalInertia.Y, plocalInertia.Z);
body.SetMassProps(pphysMass, inertia);
}
}
public override void SetObjectForce(BulletBody pBody, Vector3 _force)
@ -432,7 +442,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
public override void SetFriction(BulletBody pCollisionObject, float _currentFriction)
{
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
collisionObject.SetFriction(_currentFriction);
}
@ -459,7 +469,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
public override CollisionFlags RemoveFromCollisionFlags(BulletBody pCollisionObject, CollisionFlags pcollisionFlags)
{
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
CollisionFlags existingcollisionFlags = (CollisionFlags)(uint)collisionObject.GetCollisionFlags();
existingcollisionFlags &= ~pcollisionFlags;
collisionObject.SetCollisionFlags((BulletXNA.BulletCollision.CollisionFlags)(uint)existingcollisionFlags);
@ -494,9 +504,12 @@ private sealed class BulletConstraintXNA : BulletConstraint
public override void SetGravity(BulletBody pBody, Vector3 pGravity)
{
RigidBody body = (pBody as BulletBodyXNA).rigidBody;
if (body != null) // Can't set collisionobject.set gravity
{
IndexedVector3 gravity = new IndexedVector3(pGravity.X, pGravity.Y, pGravity.Z);
body.SetGravity(gravity);
}
}
public override bool DestroyConstraint(BulletWorld pWorld, BulletConstraint pConstraint)
{
@ -733,6 +746,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
public override void UpdateInertiaTensor(BulletBody pBody)
{
RigidBody body = (pBody as BulletBodyXNA).rigidBody;
if (body != null) // can't update inertia tensor on CollisionObject
body.UpdateInertiaTensor();
}
@ -770,7 +784,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
public override CollisionObjectTypes GetBodyType(BulletBody pCollisionObject)
{
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
return (CollisionObjectTypes)(int) collisionObject.GetInternalType();
}
@ -889,6 +903,17 @@ private sealed class BulletConstraintXNA : BulletConstraint
world.RemoveRigidBody(bo);
}
}
if (co != null)
{
if (co.GetUserPointer() != null)
{
uint localId = (uint) co.GetUserPointer();
if (specialCollisionObjects.ContainsKey(localId))
{
specialCollisionObjects.Remove(localId);
}
}
}
}
@ -1050,7 +1075,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
m_maxCollisions = maxCollisions;
m_maxUpdatesPerFrame = maxUpdates;
specialCollisionObjects = new Dictionary<uint, GhostObject>();
return new BulletWorldXNA(1, PhysicsScene, BSAPIXNA.Initialize2(worldExtent, configparms, maxCollisions, ref collisionArray, maxUpdates, ref updateArray, null));
}
@ -1310,6 +1335,12 @@ private sealed class BulletConstraintXNA : BulletConstraint
CollisionShape shape = (pShape as BulletShapeXNA).shape;
gObj.SetCollisionShape(shape);
gObj.SetUserPointer(pLocalID);
if (specialCollisionObjects.ContainsKey(pLocalID))
specialCollisionObjects[pLocalID] = gObj;
else
specialCollisionObjects.Add(pLocalID, gObj);
// TODO: Add to Special CollisionObjects!
return new BulletBodyXNA(pLocalID, gObj);
}
@ -1399,7 +1430,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
}
public override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx) {
/* TODO */
if (cShape == null)
return null;
CompoundShape compoundShape = (cShape as BulletShapeXNA).shape as CompoundShape;
@ -1407,7 +1438,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
BulletShape retShape = new BulletShapeXNA(shape, BSShapeTypeFromBroadPhaseNativeType(shape.GetShapeType()));
return null;
return retShape;
}
public BSPhysicsShapeType BSShapeTypeFromBroadPhaseNativeType(BroadphaseNativeTypes pin)
@ -1802,26 +1833,29 @@ private sealed class BulletConstraintXNA : BulletConstraint
numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep);
int updates = 0;
PersistentManifold contactManifold;
CollisionObject objA;
CollisionObject objB;
ManifoldPoint manifoldPoint;
PairCachingGhostObject pairCachingGhostObject;
m_collisionsThisFrame = 0;
int numManifolds = world.GetDispatcher().GetNumManifolds();
for (int j = 0; j < numManifolds; j++)
{
PersistentManifold contactManifold = world.GetDispatcher().GetManifoldByIndexInternal(j);
contactManifold = world.GetDispatcher().GetManifoldByIndexInternal(j);
int numContacts = contactManifold.GetNumContacts();
if (numContacts == 0)
continue;
CollisionObject objA = contactManifold.GetBody0() as CollisionObject;
CollisionObject objB = contactManifold.GetBody1() as CollisionObject;
objA = contactManifold.GetBody0() as CollisionObject;
objB = contactManifold.GetBody1() as CollisionObject;
ManifoldPoint manifoldPoint = contactManifold.GetContactPoint(0);
IndexedVector3 contactPoint = manifoldPoint.GetPositionWorldOnB();
IndexedVector3 contactNormal = -manifoldPoint.m_normalWorldOnB; // make relative to A
manifoldPoint = contactManifold.GetContactPoint(0);
//IndexedVector3 contactPoint = manifoldPoint.GetPositionWorldOnB();
// IndexedVector3 contactNormal = -manifoldPoint.m_normalWorldOnB; // make relative to A
RecordCollision(this, objA, objB, contactPoint, contactNormal,manifoldPoint.GetDistance());
RecordCollision(this, objA, objB, manifoldPoint.GetPositionWorldOnB(), -manifoldPoint.m_normalWorldOnB, manifoldPoint.GetDistance());
m_collisionsThisFrame ++;
if (m_collisionsThisFrame >= 9999999)
break;
@ -1829,13 +1863,20 @@ private sealed class BulletConstraintXNA : BulletConstraint
}
foreach (GhostObject ghostObject in specialCollisionObjects.Values)
{
pairCachingGhostObject = ghostObject as PairCachingGhostObject;
if (pairCachingGhostObject != null)
{
RecordGhostCollisions(pairCachingGhostObject);
}
}
updatedEntityCount = LastEntityProperty;
updatedEntities = UpdatedObjects;
collidersCount = LastCollisionDesc;
colliders = UpdatedCollisions;
@ -1860,60 +1901,49 @@ private sealed class BulletConstraintXNA : BulletConstraint
}
public void RecordGhostCollisions(PairCachingGhostObject obj)
{
/*
*void BulletSim::RecordGhostCollisions(btPairCachingGhostObject* obj)
{
btManifoldArray manifoldArray;
btBroadphasePairArray& pairArray = obj->getOverlappingPairCache()->getOverlappingPairArray();
int numPairs = pairArray.size();
IOverlappingPairCache cache = obj.GetOverlappingPairCache();
ObjectArray<BroadphasePair> pairs = cache.GetOverlappingPairArray();
// For all the pairs of sets of contact points
for (int i=0; i < numPairs; i++)
DiscreteDynamicsWorld world = (PhysicsScene.World as BulletWorldXNA).world;
PersistentManifoldArray manifoldArray = new PersistentManifoldArray();
BroadphasePair collisionPair;
PersistentManifold contactManifold;
CollisionObject objA;
CollisionObject objB;
ManifoldPoint pt;
int numPairs = pairs.Count;
for (int i = 0; i < numPairs; i++)
{
if (m_collisionsThisFrame >= m_maxCollisionsPerFrame)
manifoldArray.Clear();
if (LastCollisionDesc < UpdatedCollisions.Length)
break;
manifoldArray.clear();
const btBroadphasePair& pair = pairArray[i];
// The real representation is over in the world pair cache
btBroadphasePair* collisionPair = m_worldData.dynamicsWorld->getPairCache()->findPair(pair.m_pProxy0,pair.m_pProxy1);
if (!collisionPair)
collisionPair = world.GetPairCache().FindPair(pairs[i].m_pProxy0, pairs[i].m_pProxy1);
if (collisionPair == null)
continue;
if (collisionPair->m_algorithm)
collisionPair->m_algorithm->getAllContactManifolds(manifoldArray);
// The collision pair has sets of collision points (manifolds)
for (int j=0; j < manifoldArray.size(); j++)
collisionPair.m_algorithm.GetAllContactManifolds(manifoldArray);
for (int j = 0; j < manifoldArray.Count; j++)
{
btPersistentManifold* contactManifold = manifoldArray[j];
int numContacts = contactManifold->getNumContacts();
const btCollisionObject* objA = static_cast<const btCollisionObject*>(contactManifold->getBody0());
const btCollisionObject* objB = static_cast<const btCollisionObject*>(contactManifold->getBody1());
// TODO: this is a more thurough check than the regular collision code --
// here we find the penetrating contact in the manifold but for regular
// collisions we assume the first point in the manifold is good enough.
// Decide of this extra checking is required or if first point is good enough.
for (int p=0; p < numContacts; p++)
contactManifold = manifoldArray[j];
int numContacts = contactManifold.GetNumContacts();
objA = contactManifold.GetBody0() as CollisionObject;
objB = contactManifold.GetBody1() as CollisionObject;
for (int p = 0; p < numContacts; p++)
{
const btManifoldPoint& pt = contactManifold->getContactPoint(p);
// If a penetrating contact, this is a hit
if (pt.getDistance()<0.f)
pt = contactManifold.GetContactPoint(p);
if (pt.GetDistance() < 0.0f)
{
const btVector3& contactPoint = pt.getPositionWorldOnA();
const btVector3& normalOnA = -pt.m_normalWorldOnB;
RecordCollision(objA, objB, contactPoint, normalOnA, pt.getDistance());
// Only one contact point for each set of colliding objects
RecordCollision(this, objA, objB, pt.GetPositionWorldOnA(), -pt.m_normalWorldOnB,pt.GetDistance());
break;
}
}
}
}
}
*/
}
private static void RecordCollision(BSAPIXNA world, CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm, float penetration)
{
@ -1934,7 +1964,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
contactNormal = -contactNormal;
}
ulong collisionID = ((ulong) idA << 32) | idB;
//ulong collisionID = ((ulong) idA << 32) | idB;
CollisionDesc cDesc = new CollisionDesc()
{

View File

@ -158,6 +158,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
get { return (Type != Vehicle.TYPE_NONE && Prim.IsPhysicallyActive); }
}
// Return 'true' if this a vehicle that should be sitting on the ground
public bool IsGroundVehicle
{
get { return (Type == Vehicle.TYPE_CAR || Type == Vehicle.TYPE_SLED); }
}
#region Vehicle parameter setting
internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
{
@ -1176,6 +1182,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
private void ApplyGravity(float pTimeStep)
{
Vector3 appliedGravity = m_VehicleGravity * m_vehicleMass;
// Hack to reduce downward force if the vehicle is probably sitting on the ground
if (Prim.IsColliding && IsGroundVehicle)
appliedGravity *= 0.2f;
VehicleAddForce(appliedGravity);
VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},appliedForce-{2}",

View File

@ -0,0 +1,214 @@
/*
* 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;
using System.Collections.Generic;
using System.Reflection;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared;
namespace OpenSim.Tests.Common
{
public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine
{
private Scene m_scene;
public void Initialise(IConfigSource source)
{
}
public void Close()
{
}
public void AddRegion(Scene scene)
{
m_scene = scene;
m_scene.StackModuleInterface<IScriptModule>(this);
}
public void RemoveRegion(Scene scene)
{
}
public void RegionLoaded(Scene scene)
{
}
public string Name { get { return "Mock Script Engine"; } }
public string ScriptEngineName { get { return Name; } }
public Type ReplaceableInterface { get { return null; } }
public event ScriptRemoved OnScriptRemoved;
public event ObjectRemoved OnObjectRemoved;
public string GetXMLState (UUID itemID)
{
throw new System.NotImplementedException ();
}
public bool SetXMLState(UUID itemID, string xml)
{
throw new System.NotImplementedException ();
}
public bool PostScriptEvent(UUID itemID, string name, object[] args)
{
throw new System.NotImplementedException ();
}
public bool PostObjectEvent(UUID itemID, string name, object[] args)
{
throw new System.NotImplementedException ();
}
public void SuspendScript(UUID itemID)
{
throw new System.NotImplementedException ();
}
public void ResumeScript(UUID itemID)
{
throw new System.NotImplementedException ();
}
public ArrayList GetScriptErrors(UUID itemID)
{
throw new System.NotImplementedException ();
}
public bool HasScript(UUID itemID, out bool running)
{
throw new System.NotImplementedException ();
}
public bool GetScriptState(UUID itemID)
{
throw new System.NotImplementedException ();
}
public void SaveAllState()
{
throw new System.NotImplementedException ();
}
public void StartProcessing()
{
throw new System.NotImplementedException ();
}
public float GetScriptExecutionTime(List<UUID> itemIDs)
{
throw new System.NotImplementedException ();
}
public Dictionary<uint, float> GetObjectScriptsExecutionTimes()
{
throw new System.NotImplementedException ();
}
public IScriptWorkItem QueueEventHandler(object parms)
{
throw new System.NotImplementedException ();
}
public bool PostScriptEvent(UUID itemID,EventParams parms)
{
throw new System.NotImplementedException ();
}
public bool PostObjectEvent (uint localID, EventParams parms)
{
throw new System.NotImplementedException ();
}
public DetectParams GetDetectParams(UUID item, int number)
{
throw new System.NotImplementedException ();
}
public void SetMinEventDelay(UUID itemID, double delay)
{
throw new System.NotImplementedException ();
}
public int GetStartParameter(UUID itemID)
{
throw new System.NotImplementedException ();
}
public void SetScriptState(UUID itemID, bool state)
{
throw new System.NotImplementedException ();
}
public void SetState(UUID itemID, string newState)
{
throw new System.NotImplementedException ();
}
public void ApiResetScript(UUID itemID)
{
throw new System.NotImplementedException ();
}
public void ResetScript (UUID itemID)
{
throw new System.NotImplementedException ();
}
public IScriptApi GetApi(UUID itemID, string name)
{
throw new System.NotImplementedException ();
}
public Scene World { get { return m_scene; } }
public IScriptModule ScriptModule { get { throw new System.NotImplementedException(); } }
public IConfig Config { get { throw new System.NotImplementedException (); } }
public IConfigSource ConfigSource { get { throw new System.NotImplementedException (); } }
public string ScriptEnginePath { get { throw new System.NotImplementedException (); }}
public string ScriptClassName { get { throw new System.NotImplementedException (); } }
public string ScriptBaseClassName { get { throw new System.NotImplementedException (); } }
public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } }
public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } }
}
}

View File

@ -2866,12 +2866,13 @@
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Server.Base"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.OptionalModules"/>
<Reference name="OpenSim.Region.Physics.Manager"/>
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
<Reference name="OpenSim.Server.Base"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
@ -3234,6 +3235,7 @@
<Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.OptionalModules"/>
<Reference name="OpenSim.Region.Physics.Manager"/>
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
<Reference name="OpenSim.Services.AvatarService"/>
<Reference name="OpenSim.Services.Interfaces"/>
@ -3258,6 +3260,7 @@
<Files>
<!-- SADLY the way this works means you need to keep adding these paths -->
<Match path="Avatar/XmlRpcGroups/Tests" pattern="*.cs" recurse="true"/>
<Match path="Scripting/JsonStore/Tests" pattern="*.cs" recurse="true"/>
<Match path="World/NPC/Tests" pattern="*.cs" recurse="true"/>
</Files>
</Project>