Fix removeing object from scene and using existing objects

pull/1/merge
Jak Daniels 2014-12-31 21:12:20 +00:00
parent ca41de0286
commit 80dfa5a0d6
2 changed files with 43 additions and 50 deletions

View File

@ -220,17 +220,21 @@ namespace Flocking
string[] args = (cmd + " <ui>").Split (" ".ToCharArray ()); string[] args = (cmd + " <ui>").Split (" ".ToCharArray ());
if (cmd.StartsWith ("stop")) { if (cmd.StartsWith ("stop")) {
HandleStopCmd ("flock", args); HandleStopCmd (m_name, args);
} else if (cmd.StartsWith ("start")) { } else if (cmd.StartsWith ("start")) {
HandleStartCmd ("flock", args); HandleStartCmd (m_name, args);
} else if (cmd.StartsWith("enable")) {
HandleEnableCmd(m_name, args);
} else if (cmd.StartsWith("disable")) {
HandleDisableCmd(m_name, args);
} else if (cmd.StartsWith ("size")) { } else if (cmd.StartsWith ("size")) {
HandleSetSizeCmd ("flock", args); HandleSetSizeCmd (m_name, args);
} else if (cmd.StartsWith ("stats")) { } else if (cmd.StartsWith ("stats")) {
HandleShowStatsCmd ("flock", args); HandleShowStatsCmd (m_name, args);
} else if (cmd.StartsWith ("prim")) { } else if (cmd.StartsWith ("prim")) {
HandleSetPrimCmd ("flock", args); HandleSetPrimCmd (m_name, args);
} else if (cmd.StartsWith ("framerate")) { } else if (cmd.StartsWith ("framerate")) {
HandleSetFrameRateCmd ("flock", args); HandleSetFrameRateCmd (m_name, args);
} }
} }
@ -264,24 +268,19 @@ namespace Flocking
private bool ShouldHandleCmd () private bool ShouldHandleCmd ()
{ {
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) {
{
m_log.InfoFormat("[{0}]: Command Ignored!", m_name);
return false; return false;
} else {
m_log.InfoFormat("[{0}]: Command Executed!", m_name);
return true;
} }
return true;
} }
private bool IsInWorldCmd (ref string [] args) private bool IsInWorldCmd (ref string [] args)
{ {
bool retVal = false;
if (args.Length > 0 && args [args.Length - 1].Equals ("<ui>")) { if (args.Length > 0 && args [args.Length - 1].Equals ("<ui>")) {
retVal = true; m_log.InfoFormat("[{0}]: Inworld command detected in region {1}", m_name, m_scene.RegionInfo.RegionName);
return true;
} }
return retVal; return false;
} }
private void ShowResponse (string response, bool inWorld) private void ShowResponse (string response, bool inWorld)
@ -311,7 +310,6 @@ namespace Flocking
if (!m_ready && ShouldHandleCmd()) if (!m_ready && ShouldHandleCmd())
{ {
m_log.InfoFormat("[{0}]: Bird flocking is enabled.", m_name); m_log.InfoFormat("[{0}]: Bird flocking is enabled.", m_name);
FlockInitialise();
m_enabled = true; m_enabled = true;
m_ready = true; m_ready = true;
} }

View File

@ -65,9 +65,11 @@ namespace Flocking
foreach (string name in m_sogMap.Keys) foreach (string name in m_sogMap.Keys)
{ {
m_log.InfoFormat("[{0}]: Removing prim {1} from region {2}", m_name, name, m_scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Removing prim {1} from region {2}", m_name, name, m_scene.RegionInfo.RegionName);
RemoveSOGFromScene(name); SceneObjectGroup sog = m_sogMap[name];
m_scene.DeleteSceneObject(sog, false);
} }
m_sogMap.Clear(); m_sogMap.Clear();
m_scene.ForceClientUpdate();
} }
public void Render (List<Bird> birds) public void Render (List<Bird> birds)
@ -96,6 +98,7 @@ namespace Flocking
m_scene.AddNewSceneObject (sog, false); m_scene.AddNewSceneObject (sog, false);
} else { } else {
sog = existing.ParentGroup; sog = existing.ParentGroup;
m_sogMap[bird.Id] = sog;
rootPart = sog.RootPart; rootPart = sog.RootPart;
//set prim to phantom //set prim to phantom
sog.UpdatePrimFlags(rootPart.LocalId, false, false, true, false); sog.UpdatePrimFlags(rootPart.LocalId, false, false, true, false);
@ -162,14 +165,6 @@ namespace Flocking
return prim; return prim;
} }
private void RemoveSOGFromScene(string sogName)
{
SceneObjectGroup sog = m_sogMap[sogName];
m_scene.DeleteSceneObject(sog, false);
}
} }
} }