Only launch a prims script(s) when adding the prim, not on every update.

Rename Bird prims to OpenSimBirdsN where N is 0-birdcount.
pull/1/merge
Jak Daniels 2015-01-02 15:11:06 +00:00
parent c487d9b945
commit 45fd724e56
2 changed files with 13 additions and 15 deletions

View File

@ -111,7 +111,7 @@ namespace Flocking
{ {
m_flowMap = flowMap; m_flowMap = flowMap;
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
AddBird ("Bird"+i ); AddBird (m_name + i );
} }
} }

View File

@ -88,30 +88,28 @@ namespace Flocking
SceneObjectPart rootPart; SceneObjectPart rootPart;
if (existing == null) { if (existing == null) {
m_log.InfoFormat("[{0}]: Adding prim {1} from region {2}", m_name, bird.Id, m_scene.RegionInfo.RegionName);
SceneObjectGroup group = findByName (m_birdPrim); SceneObjectGroup group = findByName (m_birdPrim);
sog = CopyPrim (group, bird.Id); sog = CopyPrim (group, bird.Id);
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);
m_sogMap [bird.Id] = sog; m_sogMap [bird.Id] = sog;
m_log.InfoFormat("[{0}]: Adding prim {1} from region {2}", m_name, bird.Id, m_scene.RegionInfo.RegionName);
m_scene.AddNewSceneObject (sog, false); m_scene.AddNewSceneObject (sog, false);
} else {
sog = existing.ParentGroup;
m_sogMap[bird.Id] = sog;
//m_log.InfoFormat("[{0}]: Reusing prim {1} from region {2}", m_name, bird.Id, m_scene.RegionInfo.RegionName);
rootPart = sog.RootPart;
//set prim to phantom
sog.UpdatePrimFlags(rootPart.LocalId, false, false, true, false);
}
Quaternion rotation = CalcRotationToEndpoint (sog, sog.AbsolutePosition, bird.Location);
sog.UpdateGroupRotationPR( bird.Location, rotation);
// Fire script on_rez // Fire script on_rez
sog.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 1); sog.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 1);
rootPart.ParentGroup.ResumeScripts(); rootPart.ParentGroup.ResumeScripts();
rootPart.ScheduleFullUpdate(); rootPart.ScheduleFullUpdate();
} else {
sog = existing.ParentGroup;
m_sogMap[bird.Id] = sog;
//rootPart = sog.RootPart;
//set prim to phantom
//sog.UpdatePrimFlags(rootPart.LocalId, false, false, true, false);
}
Quaternion rotation = CalcRotationToEndpoint (sog, sog.AbsolutePosition, bird.Location);
sog.UpdateGroupRotationPR( bird.Location, rotation);
} }
private static Quaternion CalcRotationToEndpoint (SceneObjectGroup copy, Vector3 sv, Vector3 ev) private static Quaternion CalcRotationToEndpoint (SceneObjectGroup copy, Vector3 sv, Vector3 ev)