/// <summary>Runs modifiers on a path</summary> public void RunModifiers(ModifierPass pass, Path path) { if (pass == ModifierPass.PreProcess) { if (preProcessPath != null) { preProcessPath(path); } for (var i = 0; i < modifiers.Count; i++) { modifiers[i].PreProcess(path); } } else if (pass == ModifierPass.PostProcess) { Profiler.BeginSample("Running Path Modifiers"); // Call delegates if they exist if (postProcessPath != null) { postProcessPath(path); } // Loop through all modifiers and apply post processing for (var i = 0; i < modifiers.Count; i++) { modifiers[i].Apply(path); } Profiler.EndSample(); } }
/** Runs modifiers on a path */ public void RunModifiers(ModifierPass pass, Path path) { if (pass == ModifierPass.PreProcess) { if (preProcessPath != null) { preProcessPath(path); } for (int i = 0; i < modifiers.Count; i++) { modifiers[i].PreProcess(path); } } else if (pass == ModifierPass.PostProcess) { // Call delegates if they exist if (postProcessPath != null) { postProcessPath(path); } // Loop through all modifiers and apply post processing for (int i = 0; i < modifiers.Count; i++) { modifiers[i].Apply(path); } } }
/** Runs modifiers on path \a p */ public void RunModifiers(ModifierPass pass, Path p) { // Call delegates if they exist if (pass == ModifierPass.PreProcess && preProcessPath != null) { preProcessPath(p); } else if (pass == ModifierPass.PostProcess && postProcessPath != null) { postProcessPath(p); } // Loop through all modifiers and apply post processing for (int i = 0; i < modifiers.Count; i++) { // Cast to MonoModifier, i.e modifiers attached as scripts to the game object var mMod = modifiers[i] as MonoModifier; // Ignore modifiers which are not enabled if (mMod != null && !mMod.enabled) { continue; } if (pass == ModifierPass.PreProcess) { modifiers[i].PreProcess(p); } else if (pass == ModifierPass.PostProcess) { modifiers[i].Apply(p); } } }
/// <summary>Runs modifiers on a path</summary> public void RunModifiers(ModifierPass pass, Path path) { if (pass == ModifierPass.PreProcess) { if (preProcessPath != null) preProcessPath(path); for (int i = 0; i < modifiers.Count; i++) modifiers[i].PreProcess(path); } else if (pass == ModifierPass.PostProcess) { #if UNITY_EDITOR Profiler.BeginSample("Running Path Modifiers"); #endif // Call delegates if they exist if (postProcessPath != null) postProcessPath(path); // Loop through all modifiers and apply post processing for (int i = 0; i < modifiers.Count; i++) modifiers[i].Apply(path); #if UNITY_EDITOR Profiler.EndSample(); #endif } }
/** Runs modifiers on path \a p */ public void RunModifiers (ModifierPass pass, Path p) { //Sort the modifiers based on priority (bubble sort (slow but since it's a small list, it works good)) bool changed = true; while (changed) { changed = false; for (int i=0;i<modifiers.Count-1;i++) { if (modifiers[i].Priority < modifiers[i+1].Priority) { IPathModifier tmp = modifiers[i]; modifiers[i] = modifiers[i+1]; modifiers[i+1] = tmp; changed = true; } } } //Call eventual delegates switch (pass) { case ModifierPass.PreProcess: if (preProcessPath != null) preProcessPath (p); break; case ModifierPass.PostProcessOriginal: if (postProcessOriginalPath != null) postProcessOriginalPath (p); break; case ModifierPass.PostProcess: if (postProcessPath != null) postProcessPath (p); break; } //No modifiers, then exit here if (modifiers.Count == 0) return; ModifierData prevOutput = ModifierData.All; IPathModifier prevMod = modifiers[0]; //Loop through all modifiers and apply post processing for (int i=0;i<modifiers.Count;i++) { //Cast to MonoModifier, i.e modifiers attached as scripts to the game object MonoModifier mMod = modifiers[i] as MonoModifier; //Ignore modifiers which are not enabled if (mMod != null && !mMod.enabled) continue; switch (pass) { case ModifierPass.PreProcess: modifiers[i].PreProcess (p); break; case ModifierPass.PostProcessOriginal: modifiers[i].ApplyOriginal (p); break; case ModifierPass.PostProcess: //Convert the path if necessary to match the required input for the modifier ModifierData newInput = ModifierConverter.Convert (p,prevOutput,modifiers[i].input); if (newInput != ModifierData.None) { modifiers[i].Apply (p,newInput); prevOutput = modifiers[i].output; } else { UnityEngine.Debug.Log ("Error converting "+(i > 0 ? prevMod.GetType ().Name : "original")+"'s output to "+(modifiers[i].GetType ().Name)+"'s input.\nTry rearranging the modifier priorities on the Seeker."); prevOutput = ModifierData.None; } prevMod = modifiers[i]; break; } if (prevOutput == ModifierData.None) { break; } } }
/** Runs modifiers on path \a p */ public void RunModifiers(ModifierPass pass, Path p) { // Sort the modifiers based on priority // Bubble sort works because it is a small list and it is always // going to be sorted anyway since the same list is // re-sorted every time this method is executed bool changed = true; while (changed) { changed = false; for (int i = 0; i < modifiers.Count - 1; i++) { if (modifiers[i].Priority < modifiers[i + 1].Priority) { IPathModifier tmp = modifiers[i]; modifiers[i] = modifiers[i + 1]; modifiers[i + 1] = tmp; changed = true; } } } // Call delegates if they exist switch (pass) { case ModifierPass.PreProcess: if (preProcessPath != null) { preProcessPath(p); } break; case ModifierPass.PostProcess: if (postProcessPath != null) { postProcessPath(p); } break; } // No modifiers, then exit here if (modifiers.Count == 0) { return; } ModifierData prevOutput = ModifierData.All; IPathModifier prevMod = modifiers[0]; // Loop through all modifiers and apply post processing for (int i = 0; i < modifiers.Count; i++) { // Cast to MonoModifier, i.e modifiers attached as scripts to the game object var mMod = modifiers[i] as MonoModifier; // Ignore modifiers which are not enabled if (mMod != null && !mMod.enabled) { continue; } switch (pass) { case ModifierPass.PreProcess: modifiers[i].PreProcess(p); break; case ModifierPass.PostProcess: // Convert the path if necessary to match the required input for the modifier ModifierData newInput = ModifierConverter.Convert(p, prevOutput, modifiers[i].input); if (newInput != ModifierData.None) { modifiers[i].Apply(p, newInput); prevOutput = modifiers[i].output; } else { UnityEngine.Debug.Log("Error converting " + (i > 0 ? prevMod.GetType().Name : "original") + "'s output to " + (modifiers[i].GetType().Name) + "'s input.\nTry rearranging the modifier priorities on the Seeker."); prevOutput = ModifierData.None; } prevMod = modifiers[i]; break; } if (prevOutput == ModifierData.None) { break; } } }
public void RunModifiers(ModifierPass pass, Path p) { //Sort the modifiers based on priority bool changed = true; while (changed) { changed = false; for (int i = 0; i < modifiers.Count - 1; i++) { if (modifiers[i].Priority < modifiers[i + 1].Priority) { IPathModifier tmp = modifiers[i]; modifiers[i] = modifiers[i + 1]; modifiers[i + 1] = tmp; changed = true; } } } switch (pass) { case ModifierPass.PreProcess: if (preProcessPath != null) { preProcessPath(p); } break; case ModifierPass.PostProcessOriginal: if (postProcessOriginalPath != null) { postProcessOriginalPath(p); } break; case ModifierPass.PostProcess: if (postProcessPath != null) { postProcessPath(p); } break; } ModifierData prevOutput = ModifierData.All; for (int i = 0; i < modifiers.Count; i++) { switch (pass) { case ModifierPass.PreProcess: modifiers[i].PreProcess(p); break; case ModifierPass.PostProcessOriginal: modifiers[i].ApplyOriginal(p); break; case ModifierPass.PostProcess: //Convert the path if necessary to match the required input for the modifier ModifierData newInput = ModifierConverter.Convert(p, prevOutput, modifiers[i].input); if (newInput != ModifierData.None) { modifiers[i].Apply(p, newInput); prevOutput = modifiers[i].output; } else { UnityEngine.Debug.Log("Error converting " + (i > 0 ? modifiers[i - 1].GetType().Name : "original") + "'s output to " + (modifiers[i].GetType().Name) + "'s input"); prevOutput = ModifierData.None; } break; } if (prevOutput == ModifierData.None) { break; } } }
/** Runs modifiers on path \a p */ public void RunModifiers (ModifierPass pass, Path p) { // Call delegates if they exist if (pass == ModifierPass.PreProcess && preProcessPath != null) { preProcessPath(p); } else if (pass == ModifierPass.PostProcess && postProcessPath != null) { postProcessPath(p); } // Loop through all modifiers and apply post processing for (int i = 0; i < modifiers.Count; i++) { // Cast to MonoModifier, i.e modifiers attached as scripts to the game object var mMod = modifiers[i] as MonoModifier; // Ignore modifiers which are not enabled if (mMod != null && !mMod.enabled) continue; if (pass == ModifierPass.PreProcess) { modifiers[i].PreProcess(p); } else if (pass == ModifierPass.PostProcess) { modifiers[i].Apply(p); } } }
/** Runs modifiers on path \a p */ public void RunModifiers(ModifierPass pass, Path p) { //Sort the modifiers based on priority (bubble sort (slow but since it's a small list, it works good)) var changed = true; while (changed) { changed = false; for (var i = 0; i < modifiers.Count - 1; i++) { if (modifiers[i].Priority < modifiers[i + 1].Priority) { var tmp = modifiers[i]; modifiers[i] = modifiers[i + 1]; modifiers[i + 1] = tmp; changed = true; } } } //Call eventual delegates switch (pass) { case ModifierPass.PreProcess: if (preProcessPath != null) { preProcessPath(p); } break; case ModifierPass.PostProcessOriginal: if (postProcessOriginalPath != null) { postProcessOriginalPath(p); } break; case ModifierPass.PostProcess: if (postProcessPath != null) { postProcessPath(p); } break; } //No modifiers, then exit here if (modifiers.Count == 0) { return; } var prevOutput = ModifierData.All; var prevMod = modifiers[0]; //Loop through all modifiers and apply post processing for (var i = 0; i < modifiers.Count; i++) { //Cast to MonoModifier, i.e modifiers attached as scripts to the game object var mMod = modifiers[i] as MonoModifier; //Ignore modifiers which are not enabled if (mMod != null && !mMod.enabled) { continue; } switch (pass) { case ModifierPass.PreProcess: modifiers[i].PreProcess(p); break; case ModifierPass.PostProcessOriginal: modifiers[i].ApplyOriginal(p); break; case ModifierPass.PostProcess: //Convert the path if necessary to match the required input for the modifier var newInput = ModifierConverter.Convert(p, prevOutput, modifiers[i].input); if (newInput != ModifierData.None) { modifiers[i].Apply(p, newInput); prevOutput = modifiers[i].output; } else { Debug.Log("Error converting " + (i > 0 ? prevMod.GetType().Name : "original") + "'s output to " + (modifiers[i].GetType().Name) + "'s input.\nTry rearranging the modifier priorities on the Seeker."); prevOutput = ModifierData.None; } prevMod = modifiers[i]; break; } if (prevOutput == ModifierData.None) { break; } } }
public void RunModifiers (ModifierPass pass, Path p) { //Sort the modifiers based on priority bool changed = true; while (changed) { changed = false; for (int i=0;i<modifiers.Count-1;i++) { if (modifiers[i].Priority < modifiers[i+1].Priority) { IPathModifier tmp = modifiers[i]; modifiers[i] = modifiers[i+1]; modifiers[i+1] = tmp; changed = true; } } } switch (pass) { case ModifierPass.PreProcess: if (preProcessPath != null) preProcessPath (p); break; case ModifierPass.PostProcessOriginal: if (postProcessOriginalPath != null) postProcessOriginalPath (p); break; case ModifierPass.PostProcess: if (postProcessPath != null) postProcessPath (p); break; } ModifierData prevOutput = ModifierData.All; IPathModifier prevMod = modifiers[0]; //Loop through all modifiers and apply post processing for (int i=0;i<modifiers.Count;i++) { MonoModifier mMod = modifiers[i] as MonoModifier; //Ignore modifiers which are not enabled if (mMod != null && !mMod.enabled) continue; switch (pass) { case ModifierPass.PreProcess: modifiers[i].PreProcess (p); break; case ModifierPass.PostProcessOriginal: modifiers[i].ApplyOriginal (p); break; case ModifierPass.PostProcess: //UnityEngine.Debug.Log ("Applying Post"); //Convert the path if necessary to match the required input for the modifier ModifierData newInput = ModifierConverter.Convert (p,prevOutput,modifiers[i].input); if (newInput != ModifierData.None) { modifiers[i].Apply (p,newInput); prevOutput = modifiers[i].output; } else { UnityEngine.Debug.Log ("Error converting "+(i > 0 ? prevMod.GetType ().Name : "original")+"'s output to "+(modifiers[i].GetType ().Name)+"'s input"); prevOutput = ModifierData.None; } prevMod = modifiers[i]; break; } if (prevOutput == ModifierData.None) { break; } } }
public void RunModifiers(ModifierPass pass, Path p) { //Sort the modifiers based on priority bool changed = true; while (changed) { changed = false; for (int i = 0; i < modifiers.Count - 1; i++) { if (modifiers[i].Priority < modifiers[i + 1].Priority) { IPathModifier tmp = modifiers[i]; modifiers[i] = modifiers[i + 1]; modifiers[i + 1] = tmp; changed = true; } } } switch (pass) { case ModifierPass.PreProcess: if (preProcessPath != null) { preProcessPath(p); } break; case ModifierPass.PostProcessOriginal: if (postProcessOriginalPath != null) { postProcessOriginalPath(p); } break; case ModifierPass.PostProcess: if (postProcessPath != null) { postProcessPath(p); } break; } ModifierData prevOutput = ModifierData.All; IPathModifier prevMod = modifiers[0]; //Loop through all modifiers and apply post processing for (int i = 0; i < modifiers.Count; i++) { MonoModifier mMod = modifiers[i] as MonoModifier; //Ignore modifiers which are not enabled if (mMod != null && !mMod.enabled) { continue; } switch (pass) { case ModifierPass.PreProcess: modifiers[i].PreProcess(p); break; case ModifierPass.PostProcessOriginal: modifiers[i].ApplyOriginal(p); break; case ModifierPass.PostProcess: //UnityEngine.Debug.Log ("Applying Post"); //Convert the path if necessary to match the required input for the modifier ModifierData newInput = ModifierConverter.Convert(p, prevOutput, modifiers[i].input); if (newInput != ModifierData.None) { modifiers[i].Apply(p, newInput); prevOutput = modifiers[i].output; } else { UnityEngine.Debug.Log("Error converting " + (i > 0 ? prevMod.GetType().Name : "original") + "'s output to " + (modifiers[i].GetType().Name) + "'s input"); prevOutput = ModifierData.None; } prevMod = modifiers[i]; break; } if (prevOutput == ModifierData.None) { break; } } }