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

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

View File

@ -6037,7 +6037,11 @@ namespace OpenSim.Region.Framework.Scenes
detobj.posVector = av.AbsolutePosition; detobj.posVector = av.AbsolutePosition;
detobj.rotQuat = av.Rotation; detobj.rotQuat = av.Rotation;
detobj.velVector = av.Velocity; 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.groupUUID = av.ControllingClient.ActiveGroupId;
detobj.linkNumber = 0; detobj.linkNumber = 0;
@ -6129,9 +6133,6 @@ namespace OpenSim.Region.Framework.Scenes
List<uint> thisHitColliders = new List<uint>(); List<uint> thisHitColliders = new List<uint>();
List<uint> endedColliders = new List<uint>(); List<uint> endedColliders = new List<uint>();
List<uint> startedColliders = new List<uint>(); List<uint> startedColliders = new List<uint>();
List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
CollisionForSoundInfo soundinfo;
ContactPoint curcontact;
if (coldata.Count == 0) if (coldata.Count == 0)
{ {
@ -6144,10 +6145,13 @@ namespace OpenSim.Region.Framework.Scenes
} }
m_lastColliders.Clear(); m_lastColliders.Clear();
} }
else else
{ {
bool candoparcelSound = ParcelAllowThisAvatarSounds; List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
if(ParcelAllowThisAvatarSounds)
{
CollisionForSoundInfo soundinfo;
ContactPoint curcontact;
foreach (uint id in coldata.Keys) foreach (uint id in coldata.Keys)
{ {
@ -6156,7 +6160,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
startedColliders.Add(id); startedColliders.Add(id);
curcontact = coldata[id]; curcontact = coldata[id];
if (candoparcelSound && Math.Abs(curcontact.RelativeSpeed) > 0.2) if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
{ {
soundinfo = new CollisionForSoundInfo(); soundinfo = new CollisionForSoundInfo();
soundinfo.colliderID = id; soundinfo.colliderID = id;
@ -6165,9 +6169,17 @@ namespace OpenSim.Region.Framework.Scenes
soundinfolist.Add(soundinfo); 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 // calculate things that ended colliding
foreach (uint localID in m_lastColliders) foreach (uint localID in m_lastColliders)
{ {

View File

@ -213,24 +213,6 @@ namespace OpenSim.Region.ScriptEngine.Shared
if (presence.PresenceType == PresenceType.Npc) if (presence.PresenceType == PresenceType.Npc)
Type = 0x20; 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) if (presence.Velocity != Vector3.Zero)
Type |= ACTIVE; Type |= ACTIVE;
@ -267,6 +249,64 @@ namespace OpenSim.Region.ScriptEngine.Shared
Velocity = new LSL_Types.Vector3(part.Velocity); 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> /// <summary>

View File

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