fill data for llDetected funtions of collisions closer to the event. (xengine wasn't update with this on merge bc was not used there). fix some parameters

This commit is contained in:
UbitUmarov
2016-08-05 22:50:15 +01:00
parent 60b08b51b6
commit 9102f6e5da
4 changed files with 106 additions and 58 deletions

View File

@@ -2712,8 +2712,7 @@ namespace OpenSim.Region.Framework.Scenes
detobj.velVector = obj.Velocity;
detobj.colliderType = 0;
detobj.groupUUID = obj.GroupID;
detobj.linkNumber = LinkNum; // pass my link number
detobj.linkNumber = LinkNum;
return detobj;
}
@@ -2726,9 +2725,13 @@ namespace OpenSim.Region.Framework.Scenes
detobj.posVector = av.AbsolutePosition;
detobj.rotQuat = av.Rotation;
detobj.velVector = av.Velocity;
detobj.colliderType = 0;
detobj.colliderType = av.isNPC ? 0x20 : 0x1; // OpenSim\Region\ScriptEngine\Shared\Helpers.cs
if(av.IsSatOnObject)
detobj.colliderType |= 0x4; //passive
else if(detobj.velVector != Vector3.Zero)
detobj.colliderType |= 0x2; //active
detobj.groupUUID = av.ControllingClient.ActiveGroupId;
detobj.linkNumber = LinkNum; // pass my link number
detobj.linkNumber = LinkNum;
return detobj;
}
@@ -2842,7 +2845,8 @@ namespace OpenSim.Region.Framework.Scenes
if (ParentGroup.Scene == null || ParentGroup.IsDeleted)
return;
// single threaded here
// this a thread from physics ( heartbeat )
CollisionEventUpdate a = (CollisionEventUpdate)e;
Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList;
List<uint> thisHitColliders = new List<uint>();
@@ -2860,7 +2864,6 @@ namespace OpenSim.Region.Framework.Scenes
}
m_lastColliders.Clear();
}
else
{
List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
@@ -5256,7 +5259,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
{
// subscribe to physics updates.
pa.OnCollisionUpdate += PhysicsCollision;
pa.SubscribeEvents(50); // 20 reports per second
pa.SubscribeEvents(100); // 10 reports per second
}
else
{

View File

@@ -6037,7 +6037,11 @@ namespace OpenSim.Region.Framework.Scenes
detobj.posVector = av.AbsolutePosition;
detobj.rotQuat = av.Rotation;
detobj.velVector = av.Velocity;
detobj.colliderType = 0;
detobj.colliderType = av.isNPC ? 0x20 : 0x1; // OpenSim\Region\ScriptEngine\Shared\Helpers.cs
if(av.IsSatOnObject)
detobj.colliderType |= 0x4; //passive
else if(detobj.velVector != Vector3.Zero)
detobj.colliderType |= 0x2; //active
detobj.groupUUID = av.ControllingClient.ActiveGroupId;
detobj.linkNumber = 0;
@@ -6129,9 +6133,6 @@ namespace OpenSim.Region.Framework.Scenes
List<uint> thisHitColliders = new List<uint>();
List<uint> endedColliders = new List<uint>();
List<uint> startedColliders = new List<uint>();
List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
CollisionForSoundInfo soundinfo;
ContactPoint curcontact;
if (coldata.Count == 0)
{
@@ -6144,30 +6145,41 @@ namespace OpenSim.Region.Framework.Scenes
}
m_lastColliders.Clear();
}
else
{
bool candoparcelSound = ParcelAllowThisAvatarSounds;
foreach (uint id in coldata.Keys)
List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
if(ParcelAllowThisAvatarSounds)
{
thisHitColliders.Add(id);
if (!m_lastColliders.Contains(id))
CollisionForSoundInfo soundinfo;
ContactPoint curcontact;
foreach (uint id in coldata.Keys)
{
startedColliders.Add(id);
curcontact = coldata[id];
if (candoparcelSound && Math.Abs(curcontact.RelativeSpeed) > 0.2)
thisHitColliders.Add(id);
if (!m_lastColliders.Contains(id))
{
soundinfo = new CollisionForSoundInfo();
soundinfo.colliderID = id;
soundinfo.position = curcontact.Position;
soundinfo.relativeVel = curcontact.RelativeSpeed;
soundinfolist.Add(soundinfo);
startedColliders.Add(id);
curcontact = coldata[id];
if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
{
soundinfo = new CollisionForSoundInfo();
soundinfo.colliderID = id;
soundinfo.position = curcontact.Position;
soundinfo.relativeVel = curcontact.RelativeSpeed;
soundinfolist.Add(soundinfo);
}
}
}
//m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
}
else
{
foreach (uint id in coldata.Keys)
{
thisHitColliders.Add(id);
if (!m_lastColliders.Contains(id))
startedColliders.Add(id);
}
}
// calculate things that ended colliding
foreach (uint localID in m_lastColliders)
{

View File

@@ -213,24 +213,6 @@ namespace OpenSim.Region.ScriptEngine.Shared
if (presence.PresenceType == PresenceType.Npc)
Type = 0x20;
// Cope Impl. We don't use OS_NPC.
//if (presence.PresenceType != PresenceType.Npc)
//{
// Type = AGENT;
//}
//else
//{
// Type = OS_NPC;
// INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
// INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene);
// if (npcData.SenseAsAgent)
// {
// Type |= AGENT;
// }
//}
if (presence.Velocity != Vector3.Zero)
Type |= ACTIVE;
@@ -267,6 +249,64 @@ namespace OpenSim.Region.ScriptEngine.Shared
Velocity = new LSL_Types.Vector3(part.Velocity);
}
public void Populate(Scene scene, DetectedObject obj)
{
if(obj.keyUUID == UUID.Zero) // land
{
Position = new LSL_Types.Vector3(obj.posVector);
Rotation.s = 1.0;
return;
}
if((obj.colliderType & 0x21) != 0) // avatar or npc
{
ScenePresence presence = scene.GetScenePresence(obj.keyUUID);
if (presence == null)
return;
Name = obj.nameStr;
Owner = obj.keyUUID;
Group = obj.groupUUID;
Position = new LSL_Types.Vector3(obj.posVector);
Rotation = new LSL_Types.Quaternion(obj.rotQuat);
Velocity = new LSL_Types.Vector3(obj.velVector);
LinkNum = obj.linkNumber;
Type = obj.colliderType;
return;
}
SceneObjectPart part = scene.GetSceneObjectPart(obj.keyUUID);
if(part == null)
return;
Name = obj.nameStr;
Owner = obj.keyUUID;
Group = obj.groupUUID;
Position = new LSL_Types.Vector3(obj.posVector);
Rotation = new LSL_Types.Quaternion(obj.rotQuat);
Velocity = new LSL_Types.Vector3(obj.velVector);
LinkNum = obj.linkNumber;
if(obj.velVector == Vector3.Zero)
Type = 4;
else
Type = 2;
part = part.ParentGroup.RootPart;
foreach (SceneObjectPart p in part.ParentGroup.Parts)
{
if (p.Inventory.ContainsScripts())
{
// at sl a physical prim is active also if has active scripts
// assuming all scripts are in run state to save time
if((part.Flags & PrimFlags.Physics) != 0 )
Type = 10; // script + active
else
Type |= SCRIPTED; // Scripted
break;
}
}
}
}
/// <summary>

View File

@@ -244,7 +244,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
DetectParams d = new DetectParams();
d.Key =detobj.keyUUID;
d.Populate(myScriptEngine.World);
d.Populate(myScriptEngine.World, detobj);
d.LinkNum = detobj.linkNumber; // do it here since currently linknum is collided part
det.Add(d);
}
@@ -264,9 +264,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
d.Key =detobj.keyUUID;
d.Populate(myScriptEngine.World);
d.LinkNum = detobj.linkNumber; // do it here since currently linknum is collided part
d.Populate(myScriptEngine.World, detobj);
det.Add(d);
}
@@ -284,9 +282,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
d.Key =detobj.keyUUID;
d.Populate(myScriptEngine.World);
d.LinkNum = detobj.linkNumber; // do it here since currently linknum is collided part
d.Populate(myScriptEngine.World, detobj);
det.Add(d);
}
@@ -304,8 +300,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
d.Position = detobj.posVector;
d.Populate(myScriptEngine.World);
d.Populate(myScriptEngine.World, detobj);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
"land_collision_start",
@@ -322,8 +317,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
d.Position = detobj.posVector;
d.Populate(myScriptEngine.World);
d.Populate(myScriptEngine.World,detobj);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
"land_collision",
@@ -339,8 +333,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
d.Position = detobj.posVector;
d.Populate(myScriptEngine.World);
d.Populate(myScriptEngine.World,detobj);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
"land_collision_end",