Added synchronization of SOP property VolumnDetectActive, and proper actions following

its setting to true.
dsg
Huaiyu (Kitty) Liu 2011-05-26 14:15:23 -07:00
parent 486497331c
commit c3c566cd24
3 changed files with 76 additions and 4 deletions

View File

@ -1111,6 +1111,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
debugMsg += ", Text = " + part.Text+", Color = "+part.Color.ToString();
}
debugMsg += ", AggregateScriptEvents = " + part.AggregateScriptEvents;
debugMsg += ", VolumeDetectActive" + part.VolumeDetectActive;
ScenePresence sp = m_scene.GetScenePresence(part.AttachedAvatar);
if (sp != null)
@ -2955,6 +2956,23 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_property = property;
}
public PropertySyncInfo(PropertySyncInfo pSyncInfo)
{
m_property = pSyncInfo.Property;
m_lastUpdateValue = pSyncInfo.LastUpdateValue;
m_lastUpdateTimeStamp = pSyncInfo.LastUpdateTimeStamp;
m_lastUpdateSyncID = pSyncInfo.LastUpdateSyncID;
//m_lastSyncUpdateRecvTime == ??
switch (m_property)
{
case SceneObjectPartSyncProperties.Shape:
case SceneObjectPartSyncProperties.TaskInventory:
m_lastUpdateValueHash = GetPropertyHashValue((string)pSyncInfo.LastUpdateValue);
break;
}
}
public PropertySyncInfo(SceneObjectPartSyncProperties property, Object initValue, long initTS, string syncID)
{
m_property = property;
@ -3846,8 +3864,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//different than the value in SOP
if (!m_propertiesSyncInfo.ContainsKey(property))
{
//Should not happen
DebugLog.WarnFormat("PrimSyncInfo.UpdatePropertiesBySync -- no record of property {0} for SOP {1},{2}", property, part.Name, part.UUID);
//could happen if PhysActor is just created (object stops being phantom)
if (PrimSyncInfo.PrimPhysActorProperties.Contains(property))
{
PropertySyncInfo syncInfo = new PropertySyncInfo(pSyncInfo);
m_propertiesSyncInfo.Add(property, syncInfo);
}
else
{
DebugLog.WarnFormat("PrimSyncInfo.UpdatePropertiesBySync -- no record of property {0} for SOP {1},{2}", property, part.Name, part.UUID);
}
}
else
{
@ -5478,8 +5504,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
///////////////////////
case SceneObjectPartSyncProperties.AggregateScriptEvents:
part.AggregateScriptEvents = (scriptEvents)pSyncInfo.LastUpdateValue;
part.aggregateScriptEventSubscriptions();
DebugLog.DebugFormat("set {0} value to be {1}", property.ToString(), part.AggregateScriptEvents);
part.aggregateScriptEventSubscriptions();
break;
case SceneObjectPartSyncProperties.AllowedDrop:
@ -5688,7 +5714,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
part.Velocity = (Vector3)pSyncInfo.LastUpdateValue;
break;
case SceneObjectPartSyncProperties.VolumeDetectActive:
part.VolumeDetectActive = (bool)pSyncInfo.LastUpdateValue;
//part.ParentGroup.UpdatePrimFlagsBySync(part.LocalId, part., IsTemporary, IsPhantom, part.VolumeDetectActive);
bool isVD = (bool)pSyncInfo.LastUpdateValue;
DebugLog.DebugFormat("VolumeDetectActive updated on SOP {0}, to {1}", part.Name, part.VolumeDetectActive);
if (part.ParentGroup != null)
{
DebugLog.DebugFormat("calling ScriptSetVolumeDetectBySync");
part.ParentGroup.ScriptSetVolumeDetectBySync(isVD);
}
part.VolumeDetectActive = isVD;
part.aggregateScriptEventSubscriptions();
break;

View File

@ -3932,6 +3932,16 @@ namespace OpenSim.Region.Framework.Scenes
parts[i].UpdatePrimFlagsBySync(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
}
}
public void ScriptSetVolumeDetectBySync(bool SetVD)
{
m_log.DebugFormat("ScriptSetVolumeDetectBySync called for SOG {0}", Name);
bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0);
bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
UpdatePrimFlagsBySync(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, SetVD);
}
///////////////////////////////////////////////////////////////////////
// Per SOP property based sync
///////////////////////////////////////////////////////////////////////

View File

@ -3017,6 +3017,9 @@ namespace OpenSim.Region.Framework.Scenes
if (m_parentGroup != null)
{
m_parentGroup.ScriptSetVolumeDetect(SetVD);
//DSG: report that VolumeDetect has changed
ScheduleFullUpdate(new List<SceneObjectPartSyncProperties>() { SceneObjectPartSyncProperties.VolumeDetectActive });
}
}
@ -4414,9 +4417,12 @@ namespace OpenSim.Region.Framework.Scenes
if ((UsePhysics == wasUsingPhysics) && (wasTemporary == IsTemporary) && (wasPhantom == IsPhantom) && (IsVD==wasVD))
{
m_log.DebugFormat("UpdatePrimFlags called on {0}, nothing changed", Name);
return;
}
m_log.DebugFormat("UpdatePrimFlags for SOP {0}, with args UsePhysics ={1}, IsTemporary= {2}, IsPhantom= {3}, IsVD = {4}", Name, UsePhysics, IsTemporary, IsPhantom, IsVD);
// Special cases for VD. VD can only be called from a script
// and can't be combined with changes to other states. So we can rely
// that...
@ -4424,6 +4430,8 @@ namespace OpenSim.Region.Framework.Scenes
// ... if one of the others is changed, VD is not.
if (IsVD) // VD is active, special logic applies
{
m_log.DebugFormat("VolumnDetectActive is set");
// State machine logic for VolumeDetect
// More logic below
bool phanReset = (IsPhantom != wasPhantom) && !IsPhantom;
@ -4496,6 +4504,9 @@ namespace OpenSim.Region.Framework.Scenes
if (pa == null)
{
// It's not phantom anymore. So make sure the physics engine get's knowledge of it
m_log.DebugFormat("Create PhysActor for {0}", Name);
PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
LocalId,
string.Format("{0}/{1}", Name, UUID),
@ -4556,6 +4567,8 @@ namespace OpenSim.Region.Framework.Scenes
if (IsVD)
{
m_log.DebugFormat("more logic on VD");
// If the above logic worked (this is urgent candidate to unit tests!)
// we now have a physicsactor.
// Defensive programming calls for a check here.
@ -4563,6 +4576,8 @@ namespace OpenSim.Region.Framework.Scenes
// logic should make sure, this Physactor is always here.
if (this.PhysActor != null)
{
m_log.DebugFormat("PhysActor.SetVolumnDetect");
PhysActor.SetVolumeDetect(1);
AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
this.VolumeDetectActive = true;
@ -5273,9 +5288,13 @@ namespace OpenSim.Region.Framework.Scenes
(CollisionSound != UUID.Zero)
)
{
m_log.DebugFormat("Need to Hook up collision events for {0} ", Name);
// subscribe to physics updates.
if (PhysActor != null)
{
m_log.DebugFormat("Hook up with PhysicsCollision for {0} ", Name);
PhysActor.OnCollisionUpdate += PhysicsCollision;
PhysActor.SubscribeEvents(1000);
@ -5321,8 +5340,11 @@ namespace OpenSim.Region.Framework.Scenes
bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
bool wasVD = VolumeDetectActive;
m_log.DebugFormat("UpdatePrimFlagsBySync called for SOP {0}, UsePhysics ={1}, IsTemporary= {2}, IsPhantom= {3}, IsVD = {4}", Name, UsePhysics, IsTemporary, IsPhantom, IsVD);
if ((UsePhysics == wasUsingPhysics) && (wasTemporary == IsTemporary) && (wasPhantom == IsPhantom) && (IsVD == wasVD))
{
m_log.DebugFormat("no property changed, return");
return;
}
@ -5333,6 +5355,12 @@ namespace OpenSim.Region.Framework.Scenes
// ... if one of the others is changed, VD is not.
if (IsVD) // VD is active, special logic applies
{
m_log.DebugFormat("{0}: IsVD", Name);
if (PhysActor == null)
{
m_log.WarnFormat("But {0}'s PhysActor is null", Name);
}
// State machine logic for VolumeDetect
// More logic below
bool phanReset = (IsPhantom != wasPhantom) && !IsPhantom;