diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 2778b5c5c1..f700e6fdb4 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -535,7 +535,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage } if (upd != null) - { +<<<<<<< HEAD + { GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, upd.RegionID); // If we found the reginfo, send the IM to the region diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index ac4b4f4ca3..cca4b2b4fd 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1641,7 +1641,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { grp.OffsetForNewRegion(oldGroupPosition); //grp.ScheduleGroupForFullUpdate(); - grp.ScheduleGroupForFullUpdate(new List(){SceneObjectPartSyncProperties.Position}); + grp.ScheduleGroupForFullUpdate(new List(){SceneObjectPartSyncProperties.GroupPosition}); } } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/GridDialogModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/GridDialogModule.cs index b355393f5a..9bdfdf4b9a 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/GridDialogModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/GridDialogModule.cs @@ -201,6 +201,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule if (!imresult) { SendGridDialogViaXMLRPCAsync(avatarID, objectName, objectID, ownerID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels, prevRegionID); + m_log.WarnFormat("Couldn't deliver dialog to {0}" + avatarID); + return; } } } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index c952f813e7..42045bb962 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -199,6 +199,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule get { return m_isSyncRelay; } } + public class SyncMessageRecord + { + public SymmetricSyncMessage SyncMessage; + public long ReceivedTime; + } + private List m_savedSyncMessage = new List(); + //The following Sendxxx calls,send out a message immediately, w/o putting it in the SyncConnector's outgoing queue. //May need some optimization there on the priorities. @@ -256,7 +263,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case EventManager.EventNames.ChatBroadcast: if (evArgs.Length < 2) { - m_log.Error(LogHeader + " not enough event args for ChatFromWorld"); + m_log.Error(LogHeader + " not enough event args for ChatEvents"); return; } //OnLocalChatBroadcast(evArgs[0], (OSChatMessage)evArgs[1]); @@ -278,7 +285,17 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule OnLocalPhysicsCollision((UUID)evArgs[0], (OSDArray)evArgs[1]); return; case EventManager.EventNames.ScriptCollidingStart: - OnLocalScriptCollidingStart((uint)evArgs[0], (ColliderArgs)evArgs[1]); + case EventManager.EventNames.ScriptColliding: + case EventManager.EventNames.ScriptCollidingEnd: + case EventManager.EventNames.ScriptLandCollidingStart: + case EventManager.EventNames.ScriptLandColliding: + case EventManager.EventNames.ScriptLandCollidingEnd: + if (evArgs.Length < 2) + { + m_log.Error(LogHeader + " not enough event args for ScriptCollidingEvents"); + return; + } + OnLocalScriptCollidingEvents(ev, (uint)evArgs[0], (ColliderArgs)evArgs[1]); return; default: return; @@ -472,7 +489,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule Command cmdSyncDebug = new Command("debug", CommandIntentions.COMMAND_HAZARDOUS, SyncDebug, "Trigger some debugging functions"); //for sync state comparison, - Command cmdSyncStateDetailReport = new Command("state detail", CommandIntentions.COMMAND_HAZARDOUS, SyncStateDetailReport, "Trigger synchronization state comparision functions"); + Command cmdSyncStateDetailReport = new Command("state_detail", CommandIntentions.COMMAND_HAZARDOUS, SyncStateDetailReport, "Trigger synchronization state comparision functions"); //for sync state comparison, Command cmdSyncStateReport = new Command("state", CommandIntentions.COMMAND_HAZARDOUS, SyncStateReport, "Trigger synchronization state comparision functions"); @@ -480,7 +497,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_commander.RegisterCommand("stop", cmdSyncStop); m_commander.RegisterCommand("status", cmdSyncStatus); m_commander.RegisterCommand("debug", cmdSyncDebug); - m_commander.RegisterCommand("state detail", cmdSyncStateDetailReport); + m_commander.RegisterCommand("state_detail", cmdSyncStateDetailReport); m_commander.RegisterCommand("state", cmdSyncStateReport); lock (m_scene) @@ -733,9 +750,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule foreach (SyncConnector connector in syncConnectors) { - //special fix for demo, need better optimization later - if ((rsm.Type == SymmetricSyncMessage.MsgType.PhysicsCollision || rsm.Type == SymmetricSyncMessage.MsgType.ScriptCollidingStart - || rsm.Type == SymmetricSyncMessage.MsgType.ScriptCollidingEnd) + //special fix for R@I demo, need better optimization later + if ((rsm.Type == SymmetricSyncMessage.MsgType.PhysicsCollision || rsm.Type == SymmetricSyncMessage.MsgType.ScriptCollidingStart + || rsm.Type == SymmetricSyncMessage.MsgType.ScriptColliding || rsm.Type == SymmetricSyncMessage.MsgType.ScriptCollidingEnd + || rsm.Type == SymmetricSyncMessage.MsgType.ScriptLandCollidingStart + || rsm.Type == SymmetricSyncMessage.MsgType.ScriptLandColliding || rsm.Type == SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd) && m_isSyncRelay) { //for persistence actor, only forward collision events to script engines @@ -1368,6 +1387,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /////////////////////// //SOG properties /////////////////////// + case SceneObjectPartSyncProperties.AbsolutePosition: + estimateBytes += ((Vector3)propertySyncInfo.LastUpdateValue).GetBytes().Length; + break; case SceneObjectPartSyncProperties.IsSelected: //propertyData["Value"] = OSD.FromBoolean((bool)LastUpdateValue); estimateBytes += 1; @@ -1387,6 +1409,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private void SyncDebug(Object[] args) { + /* if (m_scene != null) { EntityBase[] entities = m_scene.GetEntities(); @@ -1403,6 +1426,49 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } } } + * */ + //Test HandleRemoteEvent_ScriptCollidingStart + + if (m_scene != null) + { + EntityBase[] entities = m_scene.GetEntities(); + SceneObjectGroup sog = null; + + foreach (EntityBase entity in entities) + { + if (entity is SceneObjectGroup) + { + + sog = (SceneObjectGroup)entity; + break; + } + } + + if (sog != null) + { + SceneObjectPart part = sog.RootPart; + + OSDArray collisionUUIDs = new OSDArray(); + + UUID collider = UUID.Random(); + collisionUUIDs.Add(OSD.FromUUID(collider)); + + + OSDMap data = new OSDMap(); + data["primUUID"] = OSD.FromUUID(part.UUID); + data["collisionUUIDs"] = collisionUUIDs; + //SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptCollidingStart, data); + + ulong evSeq = GetNextEventSeq(); + data["actorID"] = OSD.FromString(m_actorID); + data["seqNum"] = OSD.FromULong(evSeq); + SymmetricSyncMessage rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.ScriptCollidingStart, OSDParser.SerializeJsonString(data)); + + //HandleRemoteEvent_ScriptCollidingStart(m_actorID, evSeq, data, DateTime.Now.Ticks); + HandleRemoteEvent_ScriptCollidingEvents(SymmetricSyncMessage.MsgType.ScriptCollidingStart, m_actorID, evSeq, data, DateTime.Now.Ticks); + } + } + } private void PrimSyncSerializationDebug() @@ -1698,6 +1764,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case SymmetricSyncMessage.MsgType.Attach: case SymmetricSyncMessage.MsgType.PhysicsCollision: case SymmetricSyncMessage.MsgType.ScriptCollidingStart: + case SymmetricSyncMessage.MsgType.ScriptColliding: + case SymmetricSyncMessage.MsgType.ScriptCollidingEnd: + case SymmetricSyncMessage.MsgType.ScriptLandCollidingStart: + case SymmetricSyncMessage.MsgType.ScriptLandColliding: + case SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd: { HandleRemoteEvent(msg, senderActorID); return; @@ -1795,12 +1866,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule PrimitiveBaseShape shape = PropertySerializer.DeSerializeShape((String)p.LastUpdateValue); m_log.DebugFormat("Shape to be changed on SOP {0}, {1} to ProfileShape {2}", sop.Name, sop.UUID, shape.ProfileShape); } - } - * */ + } - - //m_log.DebugFormat("ms {0}: HandleUpdatedPrimProperties, for prim {1},{2} with updated properties -- {3}", DateTime.Now.Millisecond, sop.Name, sop.UUID, pString); + m_log.DebugFormat("ms {0}: HandleUpdatedPrimProperties, for prim {1},{2} with updated properties -- {3}", DateTime.Now.Millisecond, sop.Name, sop.UUID, pString); + * */ List propertiesUpdated = m_primSyncInfoManager.UpdatePrimSyncInfoBySync(sop, propertiesSyncInfo); @@ -1834,13 +1904,26 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule break; } } - if (allTerseUpdates) + + bool hasGroupUpdates = false; + if (PrimSyncInfo.GroupProperties.Overlaps(propertiesUpdated)) { - sop.ScheduleTerseUpdate(null); + hasGroupUpdates = true; + } + + if (!hasGroupUpdates || sop.ParentGroup == null) + { + if (allTerseUpdates) + sop.ScheduleTerseUpdate(null); + else + sop.ScheduleFullUpdate(null); } else { - sop.ScheduleFullUpdate(null); + if (allTerseUpdates) + sop.ParentGroup.ScheduleGroupForTerseUpdate(null); + else + sop.ParentGroup.ScheduleGroupForFullUpdate(null); } } } @@ -2154,7 +2237,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule HandleRemoteEvent_PhysicsCollision(init_actorID, evSeqNum, data); break; case SymmetricSyncMessage.MsgType.ScriptCollidingStart: - HandleRemoteEvent_ScriptCollidingStart(init_actorID, evSeqNum, data); + case SymmetricSyncMessage.MsgType.ScriptColliding: + case SymmetricSyncMessage.MsgType.ScriptCollidingEnd: + case SymmetricSyncMessage.MsgType.ScriptLandCollidingStart: + case SymmetricSyncMessage.MsgType.ScriptLandColliding: + case SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd: + //HandleRemoteEvent_ScriptCollidingStart(init_actorID, evSeqNum, data, DateTime.Now.Ticks); + HandleRemoteEvent_ScriptCollidingEvents(msg.Type, init_actorID, evSeqNum, data, DateTime.Now.Ticks); break; } @@ -2403,24 +2492,28 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_scene.EventManager.TriggerOnAttachLocally(localID, itemID, avatarID); } - private void HandleRemoteEvent_ScriptCollidingStart(string actorID, ulong evSeqNum, OSDMap data) + //private void HandleRemoteEvent_ScriptCollidingStart(string actorID, ulong evSeqNum, OSDMap data, long recvTime) + private void HandleRemoteEvent_ScriptCollidingEvents(SymmetricSyncMessage.MsgType msgType, string actorID, ulong evSeqNum, OSDMap data, long recvTime) { if (!data.ContainsKey("primUUID") || !data.ContainsKey("collisionUUIDs")) { m_log.ErrorFormat("RemoteEvent_ScriptCollidingStart: either primUUID or collisionUUIDs is missing in incoming OSDMap"); + return; } ColliderArgs StartCollidingMessage = new ColliderArgs(); List colliding = new List(); - SceneObjectPart part=null; + SceneObjectPart collisionPart = null; + OSDArray collidersNotFound = new OSDArray(); + try { UUID primUUID = data["primUUID"].AsUUID(); //OSDArray collisionLocalIDs = (OSDArray)data["collisionLocalIDs"]; OSDArray collisionUUIDs = (OSDArray)data["collisionUUIDs"]; - part = m_scene.GetSceneObjectPart(primUUID); - if (part == null) + collisionPart = m_scene.GetSceneObjectPart(primUUID); + if (collisionPart == null) { m_log.WarnFormat("{0}: HandleRemoteEvent_PhysicsCollision: no part with UUID {1} found, event initiator {2}", LogHeader, primUUID, actorID); return; @@ -2430,54 +2523,125 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_log.WarnFormat("{0}: HandleRemoteEvent_PhysicsCollision: no collisionLocalIDs", LogHeader); return; } - if(part.ParentGroup.IsDeleted == true) + if (collisionPart.ParentGroup.IsDeleted == true) return; - m_log.DebugFormat("HandleRemoteEvent_ScriptCollidingStart received for {0}", part.Name); - - for (int i = 0; i < collisionUUIDs.Count; i++) + switch (msgType) { - OSD arg = collisionUUIDs[i]; - UUID collidingUUID = arg.AsUUID(); - - SceneObjectPart obj = m_scene.GetSceneObjectPart(collidingUUID); - if (obj != null) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); - } - else - { - //collision object is not a prim, check if it's an avatar - ScenePresence av = m_scene.GetScenePresence(collidingUUID); - if (av != null) + case SymmetricSyncMessage.MsgType.ScriptCollidingStart: + case SymmetricSyncMessage.MsgType.ScriptColliding: + case SymmetricSyncMessage.MsgType.ScriptCollidingEnd: { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = av.UUID; - detobj.nameStr = av.ControllingClient.Name; - detobj.ownerUUID = av.UUID; - detobj.posVector = av.AbsolutePosition; - detobj.rotQuat = av.Rotation; - detobj.velVector = av.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = av.ControllingClient.ActiveGroupId; - colliding.Add(detobj); - } - else - { - m_log.WarnFormat("HandleRemoteEvent_ScriptCollidingStart for SOP {0},{1} with another SOP/SP {2}, but the latter is not found in local Scene", - part.Name, part.UUID, collidingUUID); - } + for (int i = 0; i < collisionUUIDs.Count; i++) + { + OSD arg = collisionUUIDs[i]; + UUID collidingUUID = arg.AsUUID(); - } + SceneObjectPart obj = m_scene.GetSceneObjectPart(collidingUUID); + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + else + { + //collision object is not a prim, check if it's an avatar + ScenePresence av = m_scene.GetScenePresence(collidingUUID); + if (av != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = av.UUID; + detobj.nameStr = av.ControllingClient.Name; + detobj.ownerUUID = av.UUID; + detobj.posVector = av.AbsolutePosition; + detobj.rotQuat = av.Rotation; + detobj.velVector = av.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = av.ControllingClient.ActiveGroupId; + colliding.Add(detobj); + } + else + { + m_log.WarnFormat("HandleRemoteEvent_ScriptCollidingStart for SOP {0},{1} with SOP/SP {2}, but the latter is not found in local Scene. Saved for later processing", + collisionPart.Name, collisionPart.UUID, collidingUUID); + collidersNotFound.Add(OSD.FromUUID(collidingUUID)); + } + } + } + + if (collidersNotFound.Count > 0) + { + //hard-coded expiration time to be one minute + TimeSpan msgExpireTime = new TimeSpan(0, 1, 0); + TimeSpan msgSavedTime = new TimeSpan(DateTime.Now.Ticks - recvTime); + + if (msgSavedTime < msgExpireTime) + { + + OSDMap newdata = new OSDMap(); + newdata["primUUID"] = OSD.FromUUID(collisionPart.UUID); + newdata["collisionUUIDs"] = collidersNotFound; + + newdata["actorID"] = OSD.FromString(actorID); + newdata["seqNum"] = OSD.FromULong(evSeqNum); + + SymmetricSyncMessage rsm = null; + switch (msgType) + { + case SymmetricSyncMessage.MsgType.ScriptCollidingStart: + rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.ScriptCollidingStart, OSDParser.SerializeJsonString(newdata)); + break; + case SymmetricSyncMessage.MsgType.ScriptColliding: + rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.ScriptColliding, OSDParser.SerializeJsonString(newdata)); + break; + case SymmetricSyncMessage.MsgType.ScriptCollidingEnd: + rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.ScriptCollidingEnd, OSDParser.SerializeJsonString(newdata)); + break; + } + SyncMessageRecord syncMsgToSave = new SyncMessageRecord(); + syncMsgToSave.ReceivedTime = recvTime; + syncMsgToSave.SyncMessage = rsm; + lock (m_savedSyncMessage) + { + m_savedSyncMessage.Add(syncMsgToSave); + } + } + } + } + break; + case SymmetricSyncMessage.MsgType.ScriptLandCollidingStart: + case SymmetricSyncMessage.MsgType.ScriptLandColliding: + case SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd: + { + for (int i = 0; i < collisionUUIDs.Count; i++) + { + OSD arg = collisionUUIDs[i]; + UUID collidingUUID = arg.AsUUID(); + if (collidingUUID.Equals(UUID.Zero)) + { + //Hope that all is left is ground! + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = UUID.Zero; + detobj.nameStr = ""; + detobj.ownerUUID = UUID.Zero; + detobj.posVector = collisionPart.ParentGroup.RootPart.AbsolutePosition; + detobj.rotQuat = Quaternion.Identity; + detobj.velVector = Vector3.Zero; + detobj.colliderType = 0; + detobj.groupUUID = UUID.Zero; + colliding.Add(detobj); + } + } + } + break; } } catch (Exception e) @@ -2485,11 +2649,39 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_log.ErrorFormat("HandleRemoteEvent_ScriptCollidingStart Error: {0}", e.Message); } + if (colliding.Count > 0) { StartCollidingMessage.Colliders = colliding; // always running this check because if the user deletes the object it would return a null reference. - LocalScene.EventManager.TriggerScriptCollidingStartLocally(part.LocalId, StartCollidingMessage); + //LocalScene.EventManager.TriggerScriptCollidingStartLocally(part.LocalId, StartCollidingMessage); + switch (msgType) + { + case SymmetricSyncMessage.MsgType.ScriptCollidingStart: + m_log.DebugFormat("ScriptCollidingStart received for {0}", collisionPart.Name); + LocalScene.EventManager.TriggerScriptCollidingStartLocally(collisionPart.LocalId, StartCollidingMessage); + break; + case SymmetricSyncMessage.MsgType.ScriptColliding: + m_log.DebugFormat("ScriptColliding received for {0}", collisionPart.Name); + LocalScene.EventManager.TriggerScriptCollidingLocally(collisionPart.LocalId, StartCollidingMessage); + break; + case SymmetricSyncMessage.MsgType.ScriptCollidingEnd: + m_log.DebugFormat("ScriptCollidingEnd received for {0}", collisionPart.Name); + LocalScene.EventManager.TriggerScriptCollidingEndLocally(collisionPart.LocalId, StartCollidingMessage); + break; + case SymmetricSyncMessage.MsgType.ScriptLandCollidingStart: + m_log.DebugFormat("ScriptLandCollidingStart received for {0}", collisionPart.Name); + LocalScene.EventManager.TriggerScriptLandCollidingStartLocally(collisionPart.LocalId, StartCollidingMessage); + break; + case SymmetricSyncMessage.MsgType.ScriptLandColliding: + m_log.DebugFormat("ScriptLandColliding received for {0}", collisionPart.Name); + LocalScene.EventManager.TriggerScriptLandCollidingLocally(collisionPart.LocalId, StartCollidingMessage); + break; + case SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd: + m_log.DebugFormat("ScriptLandCollidingEnd received for {0}", collisionPart.Name); + LocalScene.EventManager.TriggerScriptLandCollidingEndLocally(collisionPart.LocalId, StartCollidingMessage); + break; + } } } @@ -2502,6 +2694,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule if (!data.ContainsKey("primUUID") || !data.ContainsKey("collisionUUIDs")) { m_log.ErrorFormat("RemoteEvent_PhysicsCollision: either primUUID or collisionUUIDs is missing in incoming OSDMap"); + return; } try @@ -2524,13 +2717,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule // Build up the collision list. The contact point is ignored so we generate some default. CollisionEventUpdate e = new CollisionEventUpdate(); - /* - foreach (uint collisionID in collisionLocalIDs) - { - // e.addCollider(collisionID, new ContactPoint()); - e.addCollider(collisionID, new ContactPoint(Vector3.Zero, Vector3.UnitX, 0.03f)); - } - * */ + for (int i = 0; i < collisionUUIDs.Count; i++) { OSD arg = collisionUUIDs[i]; @@ -2809,11 +2996,47 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } + private void OnLocalScriptCollidingEvents(EventManager.EventNames evType, uint localID, ColliderArgs colliders) + { + SceneObjectPart part = LocalScene.GetSceneObjectPart(localID); + if (part == null) + return; + + OSDMap data = PrepareCollisionArgs(localID, colliders); + + if (data.Count == 0) + return; + + switch (evType) + { + case EventManager.EventNames.ScriptCollidingStart: + SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptCollidingStart, data); + break; + case EventManager.EventNames.ScriptColliding: + SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptColliding, data); + break; + case EventManager.EventNames.ScriptCollidingEnd: + SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptCollidingEnd, data); + break; + case EventManager.EventNames.ScriptLandCollidingStart: + SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptLandCollidingStart, data); + break; + case EventManager.EventNames.ScriptLandColliding: + SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptLandColliding, data); + break; + case EventManager.EventNames.ScriptLandCollidingEnd: + SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd, data); + break; + + } + } + private void OnLocalScriptCollidingStart(uint localID, ColliderArgs colliders) { SceneObjectPart part = LocalScene.GetSceneObjectPart(localID); if (part == null) return; + /* OSDArray collisionUUIDs = new OSDArray(); foreach (DetectedObject detObj in colliders.Colliders) { @@ -2823,9 +3046,45 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule OSDMap data = new OSDMap(); data["primUUID"] = OSD.FromUUID(part.UUID); data["collisionUUIDs"] = collisionUUIDs; + * */ + OSDMap data = PrepareCollisionArgs(localID, colliders); SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptCollidingStart, data); } + private void OnLocalScriptColliding(uint localID, ColliderArgs colliders) + { + SceneObjectPart part = LocalScene.GetSceneObjectPart(localID); + if (part == null) + return; + OSDMap data = PrepareCollisionArgs(localID, colliders); + SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptColliding, data); + } + + private void OnLocalScriptCollidingEnd(uint localID, ColliderArgs colliders) + { + SceneObjectPart part = LocalScene.GetSceneObjectPart(localID); + if (part == null) + return; + OSDMap data = PrepareCollisionArgs(localID, colliders); + SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptCollidingEnd, data); + } + + private OSDMap PrepareCollisionArgs(uint localID, ColliderArgs colliders) + { + OSDMap data = new OSDMap(); + SceneObjectPart part = LocalScene.GetSceneObjectPart(localID); + if (part == null) + return data; + OSDArray collisionUUIDs = new OSDArray(); + foreach (DetectedObject detObj in colliders.Colliders) + { + collisionUUIDs.Add(OSD.FromUUID(detObj.keyUUID)); + } + + data["primUUID"] = OSD.FromUUID(part.UUID); + data["collisionUUIDs"] = collisionUUIDs; + return data; + } //private void OnLocalScriptCollidingStart(uint localID, ColliderArgs OSDArray collisionUUIDs); @@ -2886,6 +3145,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Enqueue the prim with the set of updated properties, excluding the group properties if (propertiesWithSyncInfoUpdated.Count > 0) { + /* lock (m_primPropertyUpdateLock) { if (m_primPropertyUpdates.ContainsKey(part.UUID)) @@ -2895,7 +3155,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Include the "property" into the list of updated properties. //HashSet's Add function should handle it correctly whether the property //is or is not in the set. - m_primPropertyUpdates[part.UUID].Add(property); + + //If it's a group property, only add it to the RootPart's + //updated property queue, to avoid too many prim updates. + //For all non-group properties, simply add it to the prim's + //updated property queue. + if (!PrimSyncInfo.GroupProperties.Contains(property) || + (PrimSyncInfo.GroupProperties.Contains(property) && part.UUID.Equals(part.ParentGroup.RootPart.UUID))) + { + m_primPropertyUpdates[part.UUID].Add(property); + } } } else @@ -2903,6 +3172,45 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_primPropertyUpdates.Add(part.UUID, propertiesWithSyncInfoUpdated); } } + * */ + EnqueueUpdatedProperty(part, propertiesWithSyncInfoUpdated); + } + } + + private void EnqueueUpdatedProperty(SceneObjectPart part, HashSet propertiesWithSyncInfoUpdated) + { + lock (m_primPropertyUpdateLock) + { + if (m_primPropertyUpdates.ContainsKey(part.UUID)) + { + foreach (SceneObjectPartSyncProperties property in propertiesWithSyncInfoUpdated) + { + //Include the "property" into the list of updated properties. + //HashSet's Add function should handle it correctly whether the property + //is or is not in the set. + + //If it's a group property, only add it to the RootPart's + //updated property queue, to avoid too many prim updates. + //For all non-group properties, simply add it to the prim's + //updated property queue. + if (!PrimSyncInfo.GroupProperties.Contains(property) || + (PrimSyncInfo.GroupProperties.Contains(property) && part.UUID.Equals(part.ParentGroup.RootPart.UUID))) + { + m_primPropertyUpdates[part.UUID].Add(property); + } + } + } + else + { + //If it's a group property and the part is not the RootPart, + //do not enlist the property. + if (!part.UUID.Equals(part.ParentGroup.RootPart.UUID)) + { + propertiesWithSyncInfoUpdated.ExceptWith(PrimSyncInfo.GroupProperties); + } + + m_primPropertyUpdates.Add(part.UUID, propertiesWithSyncInfoUpdated); + } } } @@ -2928,6 +3236,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Enqueue the prim with the set of updated properties if (propertiesToSync.Count > 0) { + /* lock (m_primPropertyUpdateLock) { if (m_primPropertyUpdates.ContainsKey(part.UUID)) @@ -2937,7 +3246,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Include the "property" into the list of updated properties. //HashSet's Add function should handle it correctly whether the property //is or is not in the set. - m_primPropertyUpdates[part.UUID].Add(property); + + if (!PrimSyncInfo.GroupProperties.Contains(property) || + (PrimSyncInfo.GroupProperties.Contains(property) && part.UUID.Equals(part.ParentGroup.RootPart.UUID))) + { + m_primPropertyUpdates[part.UUID].Add(property); + } } } else @@ -2945,6 +3259,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_primPropertyUpdates.Add(part.UUID, propertiesToSync); } } + * */ + EnqueueUpdatedProperty(part, propertiesToSync); } } @@ -2955,6 +3271,40 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /// public void SyncOutPrimUpdates() { + //we are riding on this periodic events to check if there are un-handled sync event messages + if (m_savedSyncMessage.Count > 0) + { + System.Threading.ThreadPool.QueueUserWorkItem(delegate + { + List savedSyncMessage; + lock (m_savedSyncMessage) + { + savedSyncMessage = new List(m_savedSyncMessage); + m_savedSyncMessage.Clear(); + } + foreach (SyncMessageRecord syncMsgSaved in savedSyncMessage) + { + SymmetricSyncMessage msg = syncMsgSaved.SyncMessage; + switch (msg.Type) + { + case SymmetricSyncMessage.MsgType.ScriptCollidingStart: + case SymmetricSyncMessage.MsgType.ScriptColliding: + case SymmetricSyncMessage.MsgType.ScriptCollidingEnd: + { + OSDMap data = DeserializeMessage(msg); + string init_actorID = data["actorID"].AsString(); + ulong evSeqNum = data["seqNum"].AsULong(); + HandleRemoteEvent_ScriptCollidingEvents(msg.Type, init_actorID, evSeqNum, data, syncMsgSaved.ReceivedTime); + break; + } + default: + break; + } + + } + }); + } + if (!IsSyncingWithOtherSyncNodes()) { //no SyncConnector connected. clear update queues and return. @@ -3774,6 +4124,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /////////////////////// //SOG properties /////////////////////// + case SceneObjectPartSyncProperties.AbsolutePosition: + propertyData["Value"] = OSD.FromVector3((Vector3)LastUpdateValue); + break; case SceneObjectPartSyncProperties.IsSelected: propertyData["Value"] = OSD.FromBoolean((bool)LastUpdateValue); break; @@ -4021,6 +4374,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /////////////////////// //SOG properties /////////////////////// + case SceneObjectPartSyncProperties.AbsolutePosition: + m_lastUpdateValue = (Object)(propertyData["Value"].AsVector3()); + break; case SceneObjectPartSyncProperties.IsSelected: //propertyData["Value"] = OSD.FromBoolean((bool)LastUpdateValue); m_lastUpdateValue = (Object)(propertyData["Value"].AsBoolean()); @@ -4372,6 +4728,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //UpdateSOPProperty(part, m_propertiesSyncInfo[property]); SetSOPPropertyValue(part, property); propertiesUpdated.Add(property); + + if (property == SceneObjectPartSyncProperties.TaskInventory) + { + //Mark the inventory as has changed, for proper backup + part.Inventory.ForceInventoryPersistence(); + } + + part.ParentGroup.HasGroupChanged = true; } } catch (Exception e) @@ -4507,6 +4871,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule foreach (SceneObjectPartSyncProperties property in GroupProperties) { SetSOPPropertyValue(sop, property); + if (property == SceneObjectPartSyncProperties.AbsolutePosition) + { + + } } } @@ -5001,7 +5369,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } break; case SceneObjectPartSyncProperties.GroupPosition: - propertyUpdatedByLocal = CompareAndUpdateSOPGroupPosition(part, lastUpdateByLocalTS, syncID); + propertyUpdatedByLocal = CompareAndUpdateSOPGroupPositionByLocal(part, lastUpdateByLocalTS, syncID); break; case SceneObjectPartSyncProperties.InventorySerial: if (!part.InventorySerial.Equals(m_propertiesSyncInfo[property].LastUpdateValue)) @@ -5647,7 +6015,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } break; case SceneObjectPartSyncProperties.Position: - propertyUpdatedByLocal = CompareAndUpdateSOPPosition(part, lastUpdateByLocalTS, syncID); + propertyUpdatedByLocal = CompareAndUpdateSOPPositionByLocal(part, lastUpdateByLocalTS, syncID); break; case SceneObjectPartSyncProperties.RotationalVelocity: if (!part.PhysActor.RotationalVelocity.Equals(m_propertiesSyncInfo[property].LastUpdateValue)) @@ -5698,6 +6066,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /////////////////////// //SOG properties /////////////////////// + case SceneObjectPartSyncProperties.AbsolutePosition: + /* + if (!part.ParentGroup.AbsolutePosition.Equals(m_propertiesSyncInfo[property].LastUpdateValue)) + { + if (lastUpdateByLocalTS > m_propertiesSyncInfo[property].LastUpdateTimeStamp) + { + m_propertiesSyncInfo[property].UpdateSyncInfoByLocal(lastUpdateByLocalTS, syncID, (Object)part.ParentGroup.AbsolutePosition); + propertyUpdatedByLocal = true; + } + else if (lastUpdateByLocalTS < m_propertiesSyncInfo[property].LastUpdateTimeStamp) + { + //overwrite SOG's data + part.ParentGroup.AbsolutePosition = (Vector3)m_propertiesSyncInfo[property].LastUpdateValue; + } + } + * */ + propertyUpdatedByLocal = CompareAndUpdateSOPAbsolutePositionByLocal(part, lastUpdateByLocalTS, syncID); + break; case SceneObjectPartSyncProperties.IsSelected: if (!part.ParentGroup.IsSelected.Equals(m_propertiesSyncInfo[property].LastUpdateValue)) { @@ -5708,7 +6094,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } else if (lastUpdateByLocalTS < m_propertiesSyncInfo[property].LastUpdateTimeStamp) { - //overwrite PhysActor's data + //overwrite SOG's data part.ParentGroup.IsSelected = (bool)m_propertiesSyncInfo[property].LastUpdateValue; } } @@ -5921,6 +6307,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /////////////////////// //SOG properties /////////////////////// + case SceneObjectPartSyncProperties.AbsolutePosition: + return (Object)part.ParentGroup.AbsolutePosition; case SceneObjectPartSyncProperties.IsSelected: return (Object)part.ParentGroup.IsSelected; } @@ -5930,21 +6318,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /// /// Set the property's value based on the value maintained in PrimSyncInfoManager. - /// Assumption: caller will call ScheduleFullUpdate to enqueue updates properly. + /// Assumption: caller will call ScheduleFullUpdate to enqueue updates properly to + /// update viewers. + /// This function should only be triggered when a prim update is received (i.e. + /// triggered by remote update instead of local update). /// /// /// private void SetSOPPropertyValue(SceneObjectPart part, SceneObjectPartSyncProperties property) { if (part == null) return; - if (!m_propertiesSyncInfo.ContainsKey(property) && part.PhysActor == null){ + if (PrimPhysActorProperties.Contains(property) && !m_propertiesSyncInfo.ContainsKey(property) && part.PhysActor == null){ //DebugLog.WarnFormat("SetSOPPropertyValue: property {0} not in record.", property.ToString()); //For phantom prims, they don't have physActor properties, //so for those properties, simply return return; } - if (!m_propertiesSyncInfo.ContainsKey(property) && part.PhysActor != null) + if (!m_propertiesSyncInfo.ContainsKey(property)) { DebugLog.WarnFormat("PrimSyncInfo.SetSOPPropertyValue: property {0} not in sync cache. ", property); return; @@ -6265,6 +6656,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /////////////////////// //SOG properties /////////////////////// + case SceneObjectPartSyncProperties.AbsolutePosition: + SetSOPAbsolutePosition(part, pSyncInfo); + break; case SceneObjectPartSyncProperties.IsSelected: if (part.ParentGroup != null) part.ParentGroup.IsSelected = (bool)pSyncInfo.LastUpdateValue; @@ -6275,6 +6669,45 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //part.ScheduleFullUpdate(new List() { property }); } + private void SetSOPAbsolutePosition(SceneObjectPart part, PropertySyncInfo pSyncInfo) + { + if (part.ParentGroup != null) + { + part.ParentGroup.AbsolutePosition = (Vector3)pSyncInfo.LastUpdateValue; + + PropertySyncInfo gPosSyncInfo; + if (m_propertiesSyncInfo.ContainsKey(SceneObjectPartSyncProperties.GroupPosition)) + { + gPosSyncInfo = m_propertiesSyncInfo[SceneObjectPartSyncProperties.GroupPosition]; + gPosSyncInfo.UpdateSyncInfoBySync(pSyncInfo.LastUpdateTimeStamp, pSyncInfo.LastUpdateSyncID, part.GroupPosition, pSyncInfo.LastSyncUpdateRecvTime); + } + else + { + gPosSyncInfo = new PropertySyncInfo(SceneObjectPartSyncProperties.GroupPosition, + part.GroupPosition, pSyncInfo.LastUpdateTimeStamp, pSyncInfo.LastUpdateSyncID); + m_propertiesSyncInfo.Add(SceneObjectPartSyncProperties.GroupPosition, gPosSyncInfo); + } + + if (part.PhysActor != null) + { + PropertySyncInfo posSyncInfo; + if (m_propertiesSyncInfo.ContainsKey(SceneObjectPartSyncProperties.Position)) + { + posSyncInfo = m_propertiesSyncInfo[SceneObjectPartSyncProperties.Position]; + posSyncInfo.UpdateSyncInfoBySync(pSyncInfo.LastUpdateTimeStamp, pSyncInfo.LastUpdateSyncID, part.PhysActor.Position, pSyncInfo.LastSyncUpdateRecvTime); + } + else + { + posSyncInfo = new PropertySyncInfo(SceneObjectPartSyncProperties.Position, + part.PhysActor.Position, pSyncInfo.LastUpdateTimeStamp, pSyncInfo.LastUpdateSyncID); + m_propertiesSyncInfo.Add(SceneObjectPartSyncProperties.Position, posSyncInfo); + } + } + //the above operation may change GroupPosition and PhysActor.Postiion + //as well. so update their values + } + } + //Do not call "part.CollisionSound =" to go through its set function. //We don't want the side effect of calling aggregateScriptEvents. private void SetSOPCollisionSound(SceneObjectPart part, UUID cSound) @@ -6305,9 +6738,36 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule part.ScheduleFullUpdate(null); } + private bool CompareAndUpdateSOPAbsolutePositionByLocal(SceneObjectPart part, long lastUpdateByLocalTS, string syncID) + { + SceneObjectPartSyncProperties property = SceneObjectPartSyncProperties.AbsolutePosition; + + bool propertyUpdatedByLocal = false; + if (!part.ParentGroup.AbsolutePosition.Equals(m_propertiesSyncInfo[property].LastUpdateValue)) + { + if (lastUpdateByLocalTS > m_propertiesSyncInfo[property].LastUpdateTimeStamp) + { + m_propertiesSyncInfo[property].UpdateSyncInfoByLocal(lastUpdateByLocalTS, syncID, (Object)part.ParentGroup.AbsolutePosition); + propertyUpdatedByLocal = true; + } + else if (lastUpdateByLocalTS < m_propertiesSyncInfo[property].LastUpdateTimeStamp) + { + //overwrite SOG's data + part.ParentGroup.AbsolutePosition = (Vector3)m_propertiesSyncInfo[property].LastUpdateValue; + } + } + + //Since writing to AbsolutePosition also changes values of GroupPosition + //and PhysActor.Postiion (these properties are different representations + //of the same prim property), we also need to update the latter two. + CompareAndUpdateSOPGroupPositionByLocal(part, lastUpdateByLocalTS, syncID); + + return propertyUpdatedByLocal; + } + //In SOP's implementation, GroupPosition and SOP.PhysActor.Position are //correlated. We need to make sure that they are both properly synced. - private bool CompareAndUpdateSOPGroupPosition(SceneObjectPart part, long lastUpdateByLocalTS, string syncID) + private bool CompareAndUpdateSOPGroupPositionByLocal(SceneObjectPart part, long lastUpdateByLocalTS, string syncID) { if (!part.GroupPosition.Equals(m_propertiesSyncInfo[SceneObjectPartSyncProperties.GroupPosition].LastUpdateValue)) { @@ -6371,7 +6831,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule return false; } - private bool CompareAndUpdateSOPPosition(SceneObjectPart part, long lastUpdateByLocalTS, string syncID) + private bool CompareAndUpdateSOPPositionByLocal(SceneObjectPart part, long lastUpdateByLocalTS, string syncID) { if (part.PhysActor == null) return false; diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs index dc454132a8..b038ef7cd6 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs @@ -72,6 +72,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule ScriptCollidingStart, ScriptColliding, ScriptCollidingEnd, + ScriptLandCollidingStart, + ScriptLandColliding, + ScriptLandCollidingEnd, //contorl command SyncStateReport, } diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index d34a8a8f5a..17350df79f 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -233,5 +233,8 @@ namespace OpenSim.Region.Framework.Interfaces /// A /// Dictionary GetScriptStates(); + + //DSG + bool UpdateInventoryItemBySync(TaskInventoryItem item); } } diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index b1000176e8..eabd1ebc28 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -63,7 +63,10 @@ namespace OpenSim.Region.Framework.Scenes PhysicsCollision, ScriptCollidingStart, ScriptColliding, - ScriptCollidingEnd + ScriptCollidingEnd, + ScriptLandCollidingStart, + ScriptLandColliding, + ScriptLandCollidingEnd } public EventManager(Scene scene) @@ -158,7 +161,7 @@ namespace OpenSim.Region.Framework.Scenes } #endregion //ChatFromClient -#region ChatBroadcast + #region ChatBroadcast public override void TriggerOnChatBroadcast(Object sender, OSChatMessage chat) { @@ -176,7 +179,7 @@ namespace OpenSim.Region.Framework.Scenes { base.TriggerOnChatBroadcast(sender, chat); } -#endregion + #endregion #region ChatFromWorld @@ -280,7 +283,7 @@ namespace OpenSim.Region.Framework.Scenes #endregion //GrabObject -#region collisions + #region collisions public override void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders) { if (m_scene.RegionSyncModule != null) @@ -297,7 +300,93 @@ namespace OpenSim.Region.Framework.Scenes { base.TriggerScriptCollidingStart(localId, colliders); } -#endregion + + public override void TriggerScriptColliding(uint localId, ColliderArgs colliders) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[4]; + eventArgs[0] = (Object)localId; + eventArgs[1] = (Object)colliders; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ScriptColliding, eventArgs); + } + TriggerScriptCollidingLocally(localId, colliders); + } + + public void TriggerScriptCollidingLocally(uint localId, ColliderArgs colliders) + { + base.TriggerScriptColliding(localId, colliders); + } + + public override void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[4]; + eventArgs[0] = (Object)localId; + eventArgs[1] = (Object)colliders; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ScriptCollidingEnd, eventArgs); + } + TriggerScriptCollidingEndLocally(localId, colliders); + } + + public void TriggerScriptCollidingEndLocally(uint localId, ColliderArgs colliders) + { + base.TriggerScriptCollidingEnd(localId, colliders); + } + + public override void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[4]; + eventArgs[0] = (Object)localId; + eventArgs[1] = (Object)colliders; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ScriptLandCollidingStart, eventArgs); + } + TriggerScriptLandCollidingStartLocally(localId, colliders); + } + + public void TriggerScriptLandCollidingStartLocally(uint localId, ColliderArgs colliders) + { + base.TriggerScriptLandCollidingStart(localId, colliders); + } + + public override void TriggerScriptLandColliding(uint localId, ColliderArgs colliders) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[4]; + eventArgs[0] = (Object)localId; + eventArgs[1] = (Object)colliders; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ScriptLandColliding, eventArgs); + } + TriggerScriptLandCollidingLocally(localId, colliders); + } + + public void TriggerScriptLandCollidingLocally(uint localId, ColliderArgs colliders) + { + base.TriggerScriptLandColliding(localId, colliders); + } + + public override void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[4]; + eventArgs[0] = (Object)localId; + eventArgs[1] = (Object)colliders; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ScriptLandCollidingEnd, eventArgs); + } + TriggerScriptLandCollidingEndLocally(localId, colliders); + } + + public void TriggerScriptLandCollidingEndLocally(uint localId, ColliderArgs colliders) + { + base.TriggerScriptLandCollidingEnd(localId, colliders); + } + + #endregion } /// @@ -2248,7 +2337,8 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerScriptColliding(uint localId, ColliderArgs colliders) + //public void TriggerScriptColliding(uint localId, ColliderArgs colliders) + public virtual void TriggerScriptColliding(uint localId, ColliderArgs colliders) { ScriptColliding handlerColliding = OnScriptColliding; if (handlerColliding != null) @@ -2269,7 +2359,8 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders) + //public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders) + public virtual void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders) { ScriptColliding handlerCollidingEnd = OnScriptCollidingEnd; if (handlerCollidingEnd != null) @@ -2290,7 +2381,8 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders) + //public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders) + public virtual void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders) { ScriptColliding handlerLandCollidingStart = OnScriptLandColliderStart; if (handlerLandCollidingStart != null) @@ -2311,7 +2403,8 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders) + //public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders) + public virtual void TriggerScriptLandColliding(uint localId, ColliderArgs colliders) { ScriptColliding handlerLandColliding = OnScriptLandColliding; if (handlerLandColliding != null) @@ -2332,7 +2425,8 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders) + //public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders) + public virtual void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders) { ScriptColliding handlerLandCollidingEnd = OnScriptLandColliderEnd; if (handlerLandCollidingEnd != null) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 19bd58d944..458756ce39 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -327,7 +327,7 @@ namespace OpenSim.Region.Framework.Scenes //Scene does permission checking, asset creation and storing, then informs Script Engine to //update the script. //////////////////////////////////////////////////////////////////////////////////////////////// - //Only should be called when this is the cached Scene of script engine + //Only should be called when this is the local Scene of script engine public ArrayList OnUpdateScript(UUID avatarID, UUID itemID, UUID primID, bool isScriptRunning, UUID newAssetID) { ArrayList errors = new ArrayList(); @@ -353,7 +353,7 @@ namespace OpenSim.Region.Framework.Scenes // Update item with new asset item.AssetID = newAssetID; - group.UpdateInventoryItem(item); + group.UpdateInventoryItemBySync(item); m_log.Debug("UpdateInventoryItem on object "+group.UUID); if (isScriptRunning) @@ -419,9 +419,14 @@ namespace OpenSim.Region.Framework.Scenes return new ArrayList(); } - // Update item with new asset + // Update item with new asset. + // The actor that initiate the UpdateScript event should also send out + // a sync message for the updated task inventory. In case that sync message is + // not here year, we retrieve and update the task item -- w/o marking that + // the taskinventory is modified here, so that when the sync message is here, + // the actor and timestamp info will be copied. item.AssetID = newAssetID; - group.UpdateInventoryItem(item); + group.UpdateInventoryItemBySync(item); m_log.Debug("UpdateInventoryItem on object "+group.UUID); if (isScriptRunning) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 61fde6f0e9..be480f0172 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -398,5 +398,33 @@ namespace OpenSim.Region.Framework.Scenes parts[i].Inventory.SuspendScripts(); } #endregion REGION SYNC + + #region DSG SYNC + /// + /// Update an existing inventory item. + /// + /// The updated item. An item with the same id must already exist + /// in this prim's inventory + /// false if the item did not exist, true if the update occurred succesfully + public bool UpdateInventoryItemBySync(TaskInventoryItem item) + { + SceneObjectPart part = GetChildPart(item.ParentPartID); + if (part != null) + { + part.Inventory.UpdateInventoryItemBySync(item); + + return true; + } + else + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "Couldn't find prim ID {0} to update item {1}, {2}", + item.ParentPartID, item.Name, item.ItemID); + } + + return false; + } + #endregion } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d264b2b0ab..71c26306e3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -988,7 +988,8 @@ namespace OpenSim.Region.Framework.Scenes AttachToBackup(); m_scene.EventManager.TriggerParcelPrimCountTainted(); //m_rootPart.ScheduleFullUpdate(); - m_rootPart.ScheduleFullUpdate(new List() { SceneObjectPartSyncProperties.GroupPosition, SceneObjectPartSyncProperties.AttachmentPoint, + //m_rootPart.ScheduleFullUpdate(new List() { SceneObjectPartSyncProperties.GroupPosition, SceneObjectPartSyncProperties.AttachmentPoint, + m_rootPart.ScheduleFullUpdate(new List() { SceneObjectPartSyncProperties.AbsolutePosition, SceneObjectPartSyncProperties.AttachmentPoint, SceneObjectPartSyncProperties.AttachedAvatar, SceneObjectPartSyncProperties.Flags}); //Physics properties, such as Position, OffsetPosition, etc, should be tainted in ApplyPhysics() m_rootPart.ClearUndoState(); } @@ -1016,6 +1017,10 @@ namespace OpenSim.Region.Framework.Scenes //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); //AttachToBackup(); //m_rootPart.ScheduleFullUpdate(); + + //m_rootPart.ScheduleSyncUpdate(new List() { SceneObjectPartSyncProperties.GroupPosition, SceneObjectPartSyncProperties.AttachmentPoint, + m_rootPart.ScheduleSyncUpdate(new List() { SceneObjectPartSyncProperties.AbsolutePosition, SceneObjectPartSyncProperties.AttachmentPoint, + SceneObjectPartSyncProperties.AttachedAvatar, SceneObjectPartSyncProperties.Flags}); } /// @@ -2913,7 +2918,8 @@ namespace OpenSim.Region.Framework.Scenes //we need to do a terse update even if the move wasn't allowed // so that the position is reset in the client (the object snaps back) //ScheduleGroupForTerseUpdate(); - List updatedProperties = new List() { SceneObjectPartSyncProperties.GroupPosition }; + //List updatedProperties = new List() { SceneObjectPartSyncProperties.GroupPosition }; + List updatedProperties = new List() { SceneObjectPartSyncProperties.AbsolutePosition }; if (IsAttachment) { updatedProperties.Add(SceneObjectPartSyncProperties.AttachedPos); @@ -2982,7 +2988,8 @@ namespace OpenSim.Region.Framework.Scenes HasGroupChanged = true; //ScheduleGroupForTerseUpdate(); - ScheduleGroupForTerseUpdate(new List(){SceneObjectPartSyncProperties.Position, SceneObjectPartSyncProperties.OffsetPosition}); + //ScheduleGroupForTerseUpdate(new List(){SceneObjectPartSyncProperties.Position, SceneObjectPartSyncProperties.OffsetPosition}); + ScheduleGroupForTerseUpdate(new List() { SceneObjectPartSyncProperties.AbsolutePosition, SceneObjectPartSyncProperties.OffsetPosition }); } public void OffsetForNewRegion(Vector3 offset) @@ -3056,11 +3063,13 @@ namespace OpenSim.Region.Framework.Scenes if (actor != null) { //RotationOffset is only updated for m_rootPart, and m_rootPart.UpdateRotation should already taint RotationOffset as updated - ScheduleGroupForTerseUpdate(new List() { SceneObjectPartSyncProperties.Position, SceneObjectPartSyncProperties.Orientation }); + //ScheduleGroupForTerseUpdate(new List() { SceneObjectPartSyncProperties.Position, SceneObjectPartSyncProperties.Orientation }); + ScheduleGroupForTerseUpdate(new List() { SceneObjectPartSyncProperties.AbsolutePosition, SceneObjectPartSyncProperties.Orientation }); } else { - ScheduleGroupForTerseUpdate(new List() { SceneObjectPartSyncProperties.Position }); + //ScheduleGroupForTerseUpdate(new List() { SceneObjectPartSyncProperties.Position }); + ScheduleGroupForTerseUpdate(new List() { SceneObjectPartSyncProperties.AbsolutePosition}); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e799e5d873..b3e7e22aea 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2804,7 +2804,8 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPartSyncProperties.Position, SceneObjectPartSyncProperties.Orientation, SceneObjectPartSyncProperties.Velocity, - SceneObjectPartSyncProperties.RotationalVelocity + SceneObjectPartSyncProperties.RotationalVelocity, + SceneObjectPartSyncProperties.PA_Acceleration }); //SendTerseUpdateToAllClients(); @@ -5041,6 +5042,7 @@ namespace OpenSim.Region.Framework.Scenes VolumeDetectActive, //Group properties + AbsolutePosition, IsSelected, //Client Manager may want to add some property here that viewers care about and should be synchronized across actors @@ -5169,8 +5171,10 @@ namespace OpenSim.Region.Framework.Scenes public static HashSet GetGroupProperties() { - HashSet allProperties = new HashSet(){SceneObjectPartSyncProperties.IsSelected}; - return allProperties; + HashSet groupProperties = new HashSet(); + groupProperties.Add(SceneObjectPartSyncProperties.IsSelected); + groupProperties.Add(SceneObjectPartSyncProperties.AbsolutePosition); + return groupProperties; } public static HashSet GetTerseUpdateProperties() @@ -5185,41 +5189,13 @@ namespace OpenSim.Region.Framework.Scenes allProperties.Add(SceneObjectPartSyncProperties.Orientation); allProperties.Add(SceneObjectPartSyncProperties.RotationalVelocity); allProperties.Add(SceneObjectPartSyncProperties.Position); + allProperties.Add(SceneObjectPartSyncProperties.AbsolutePosition); return allProperties; } #endregion SceneObjectPartSyncProperties categorization - /* - #region overridden SOPBase members - public new IEntityInventory Inventory - { - get { return m_inventory; } - } - protected new SceneObjectPartInventory m_inventory; - - /// - /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes - /// - public new uint InventorySerial - { - get { return m_inventory.Serial; } - set { m_inventory.Serial = value; } - } - - /// - /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes - /// - public new TaskInventoryDictionary TaskInventory - { - get { return m_inventory.Items; } - set { m_inventory.Items = value; } - } - - #endregion //overridden SOPBase members - */ - #region overridden SOPBase functions //Implementation of ScheduleFullUpdate and ScheduleTerseUpdate for Bucket //based synchronization diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 1ce7076e07..21a670fe7d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -727,6 +727,9 @@ namespace OpenSim.Region.Framework.Scenes { HasInventoryChanged = true; m_part.ParentGroup.HasGroupChanged = true; + + //DSG + m_part.ScheduleSyncUpdate(new List(){SceneObjectPartSyncProperties.TaskInventory}); } return true; @@ -1182,6 +1185,68 @@ namespace OpenSim.Region.Framework.Scenes } } #endregion REGION SYNC + + #region DSG SYNC + /// + /// Update an existing inventory item. + /// + /// The updated item. An item with the same id must already exist + /// in this prim's inventory. + /// false if the item did not exist, true if the update occurred successfully + public bool UpdateInventoryItemBySync(TaskInventoryItem item) + { + return UpdateInventoryItemBySync(item, true, true); + } + + //Similar to UpdateInventoryItem except that ScheduleSyncUpdate is not triggered + private bool UpdateInventoryItemBySync(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) + { + TaskInventoryItem it = GetInventoryItem(item.ItemID); + if (it != null) + { +// m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); + + item.ParentID = m_part.UUID; + item.ParentPartID = m_part.UUID; + + // If group permissions have been set on, check that the groupID is up to date in case it has + // changed since permissions were last set. + if (item.GroupPermissions != (uint)PermissionMask.None) + item.GroupID = m_part.GroupID; + + if (item.AssetID == UUID.Zero) + item.AssetID = it.AssetID; + + lock (m_items) + { + m_items[item.ItemID] = item; + m_inventorySerial++; + } + + if (fireScriptEvents) + m_part.TriggerScriptChangedEvent(Changed.INVENTORY); + + if (considerChanged) + { + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; + } + + return true; + } + else + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", + item.ItemID, m_part.Name, m_part.UUID, + m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); + } + return false; + + } + + #endregion DSG SYNC } /* diff --git a/addon-modules/BulletSPlugin/BSCharacter.cs b/addon-modules/BulletSPlugin/BSCharacter.cs index fa9fc8d4b9..d66b1a6522 100644 --- a/addon-modules/BulletSPlugin/BSCharacter.cs +++ b/addon-modules/BulletSPlugin/BSCharacter.cs @@ -93,6 +93,7 @@ public class BSCharacter : PhysicsActor _size = size; _orientation = Quaternion.Identity; _velocity = Vector3.Zero; + _buoyancy = 0f; // characters return a buoyancy of zero _scale = new Vector3(1f, 1f, 1f); float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH); _mass = _density*AVvolume; @@ -105,8 +106,8 @@ public class BSCharacter : PhysicsActor shapeData.Velocity = _velocity; shapeData.Scale = _scale; shapeData.Mass = _mass; - shapeData.Flying = isFlying ? ShapeData.numericTrue : ShapeData.numericFalse; - shapeData.Dynamic = ShapeData.numericFalse; + shapeData.Buoyancy = isFlying ? 0f : 1f; + shapeData.Static = ShapeData.numericFalse; BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData); @@ -131,6 +132,7 @@ public class BSCharacter : PhysicsActor if (ChangingActorID == RegionSyncServerModule.ActorID) { // m_log.DebugFormat("{0}: Sending terse update for {1}", LogHeader, LocalID); + ChangingActorID = "XX"; // undo our mark on the changes so this won't get sent over and over PhysEngineToSceneConnectorModule.RouteUpdate(this); } } @@ -268,7 +270,8 @@ public class BSCharacter : PhysicsActor _flying = value; _scene.TaintedObject(delegate() { - BulletSimAPI.SetObjectFlying(_scene.WorldID, LocalID, _flying); + // simulate flying by changing the effect of gravity + BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _flying ? 0f : 1f); }); } } @@ -415,7 +418,7 @@ public class BSCharacter : PhysicsActor { // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); - // The following says we're colliding this simulation step + // The following makes IsColliding() and IsCollidingGround() work _collidingStep = _scene.SimulationStep; if (collidingWith == BSScene.TERRAIN_ID || collidingWith == BSScene.GROUNDPLANE_ID) { diff --git a/addon-modules/BulletSPlugin/BSPrim.cs b/addon-modules/BulletSPlugin/BSPrim.cs index 06a8a03574..515c4dad61 100644 --- a/addon-modules/BulletSPlugin/BSPrim.cs +++ b/addon-modules/BulletSPlugin/BSPrim.cs @@ -106,6 +106,7 @@ public sealed class BSPrim : PhysicsActor _size = size; _scale = new OMV.Vector3(1f, 1f, 1f); // the scale will be set by CreateGeom depending on object type _orientation = rotation; + _buoyancy = 1f; _mesh = mesh; _hullKey = 0; _pbs = pbs; @@ -181,7 +182,6 @@ public sealed class BSPrim : PhysicsActor _isSelected = value; _scene.TaintedObject(delegate() { - m_log.DebugFormat("{0}: Selected={1}, localID={2}", LogHeader, _isSelected, _localID); SetObjectDynamic(); // SyncUpdated = true; }); @@ -287,6 +287,7 @@ public sealed class BSPrim : PhysicsActor public override OMV.Vector3 Position { get { + // don't do the following GetObjectPosition because this function is called a zillion times // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); return _position; } @@ -332,10 +333,7 @@ public sealed class BSPrim : PhysicsActor _isVolumeDetect = newValue; _scene.TaintedObject(delegate() { - // make the object ghostly or not (walk throughable) - BulletSimAPI.SetObjectGhost(_scene.WorldID, LocalID, _isVolumeDetect); - // set whether we hear about collisions - BulletSimAPI.SetObjectCollidable(_scene.WorldID, LocalID, !IsPhantom); + SetObjectDynamic(); }); } return; @@ -390,40 +388,39 @@ public sealed class BSPrim : PhysicsActor _scene.TaintedObject(delegate() { SetObjectDynamic(); - m_log.DebugFormat("{0}: ID={1}, IsPhysical={2}, IsSelected={3}, mass={4}", LogHeader, _localID, _isPhysical, _isSelected, _mass); // SyncUpdated = true; }); } } + + // An object is static (does not move) if selected or not physical + private bool IsStatic + { + get { return _isSelected || !IsPhysical; } + } + + // An object is solid if it's not phantom and if it's not doing VolumeDetect + private bool IsSolid + { + get { return !IsPhantom && !_isVolumeDetect; } + } + // make gravity work if the object is physical and not selected // no locking here because only called when it is safe private void SetObjectDynamic() { - // a selected object is not physical - if (_isSelected || !_isPhysical) - { - _mass = 0f; // non-physical things work best with a mass of zero - BulletSimAPI.SetObjectDynamic(_scene.WorldID, _localID, false, _mass); - } - else - { - _mass = CalculateMass(); - BulletSimAPI.SetObjectDynamic(_scene.WorldID, _localID, true, _mass); - } + // non-physical things work best with a mass of zero + _mass = IsStatic ? 0f : CalculateMass(); + BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), _mass); + // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}, mass={4}", LogHeader, _localID, IsStatic, IsSolid, _mass); } + + // prims don't fly public override bool Flying { get { return _flying; } - set { - _flying = value; - _scene.TaintedObject(delegate() - { - BulletSimAPI.SetObjectFlying(_scene.WorldID, LocalID, _flying); - // SyncUpdated = true; - }); - } + set { _flying = value; } } - public override bool - SetAlwaysRun { + public override bool SetAlwaysRun { get { return _setAlwaysRun; } set { _setAlwaysRun = value; } } @@ -431,12 +428,12 @@ public sealed class BSPrim : PhysicsActor get { return _throttleUpdates; } set { _throttleUpdates = value; } } - public override bool IsColliding { - get { return _isColliding; } + public override bool IsColliding { + get { return (_collidingStep == _scene.SimulationStep); } set { _isColliding = value; } } - public override bool CollidingGround { - get { return _collidingGround; } + public override bool CollidingGround { + get { return (_collidingGroundStep == _scene.SimulationStep); } set { _collidingGround = value; } } public override bool CollidingObj { @@ -468,7 +465,12 @@ public sealed class BSPrim : PhysicsActor } public override float Buoyancy { get { return _buoyancy; } - set { _buoyancy = value; } + set { _buoyancy = value; + _scene.TaintedObject(delegate() + { + BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy); + }); + } } // Used for MoveTo @@ -1003,11 +1005,11 @@ public sealed class BSPrim : PhysicsActor shape.Velocity = _velocity; shape.Scale = _scale; shape.Mass = _isPhysical ? _mass : 0f; + shape.Buoyancy = _buoyancy; shape.MeshKey = _hullKey; shape.Collidable = (!IsPhantom) ? ShapeData.numericTrue : ShapeData.numericFalse; - shape.Flying = _flying ? ShapeData.numericTrue : ShapeData.numericFalse; shape.Friction = _friction; - shape.Dynamic = _isPhysical ? ShapeData.numericTrue : ShapeData.numericFalse; + shape.Static = _isPhysical ? ShapeData.numericFalse : ShapeData.numericTrue; } // Rebuild the geometry and object. @@ -1044,7 +1046,7 @@ public sealed class BSPrim : PhysicsActor public void UpdateProperties(EntityProperties entprop) { bool changed = false; - // we assign to the local variables so the normal set action does not happen + // assign to the local variables so the normal set action does not happen if (_position != entprop.Position) { _position = entprop.Position; diff --git a/addon-modules/BulletSPlugin/BSScene.cs b/addon-modules/BulletSPlugin/BSScene.cs index a302b21139..d656b8aa24 100644 --- a/addon-modules/BulletSPlugin/BSScene.cs +++ b/addon-modules/BulletSPlugin/BSScene.cs @@ -35,23 +35,24 @@ using OpenSim.Region.Physics.Manager; using OpenMetaverse; using OpenSim.Region.Framework; -// TODOs for BulletSim (both BSScene and BSPrim) +// TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim) // Does NeedsMeshing() really need to exclude all the different shapes? // Based on material, set density and friction // More efficient memory usage in passing hull information from BSPrim to BulletSim // Four states of prim: Physical, regular, phantom and selected. Are we modeling these correctly? // In SL one can set both physical and phantom (gravity, does not effect others, makes collisions with ground) +// At the moment, physical and phantom causes object to drop through the terrain // LinkSets // Freeing of memory of linksets in BulletSim::DestroyObject // Set child prims phantom since the physicality is handled by the parent prim // Linked children need rotation relative to parent (passed as world rotation) // Should prim.link() and prim.delink() membership checking happen at taint time? -// Pass collision enable flags to BulletSim code so collisions are not reported up unless they are really needed -// Set bouyancy(). Maybe generalize SetFlying() to SetBouyancy() and use the factor to change the gravity effect // Test sculpties // Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once // Do attachments need to be handled separately? Need collision events. Do not collide with VolumeDetect // Parameterize BulletSim. Pass a structure of parameters to the C++ code. Capsule size, friction, ... +// Use event subscription times to reduce the number of events passed up (_subscribedEventMS) +// Implement the genCollisions feature in BulletSim::SetObjectProperties (don't pass up unneeded collisions) // namespace OpenSim.Region.Physics.BulletSPlugin { diff --git a/addon-modules/BulletSPlugin/BulletSimAPI.cs b/addon-modules/BulletSPlugin/BulletSimAPI.cs index b1f7bd314f..8d97f30bb1 100644 --- a/addon-modules/BulletSPlugin/BulletSimAPI.cs +++ b/addon-modules/BulletSPlugin/BulletSimAPI.cs @@ -59,11 +59,11 @@ public struct ShapeData public Vector3 Velocity; public Vector3 Scale; public float Mass; + public float Buoyancy; public System.UInt64 MeshKey; public int Collidable; - public int Flying; public float Friction; - public int Dynamic; + public int Static; // true if a static object. Otherwise gravity, etc. // note that bools are passed as ints since bool size changes by language } public struct SweepHit @@ -148,7 +148,10 @@ public static extern bool SetObjectDynamic(uint worldID, uint id, bool isDynamic public static extern bool SetObjectGhost(uint worldID, uint id, bool ghostly); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern bool SetObjectFlying(uint worldID, uint id, bool flying); +public static extern bool SetObjectProperties(uint worldID, uint id, bool isStatic, bool isSolid, bool genCollisions, float mass); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool SetObjectBuoyancy(uint worldID, uint id, float buoyancy); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool HasObject(uint worldID, uint id); diff --git a/bin/BulletSim.dll b/bin/BulletSim.dll index 02f1056f6c..88271a2b11 100755 Binary files a/bin/BulletSim.dll and b/bin/BulletSim.dll differ