public static IValueFastIn CreateValueFastInput(this IPluginHost host, InputAttribute attribute, Type type) { attribute = NormalizePinAttribute(attribute, type); IValueFastIn result = null; host.CreateValueFastInput(attribute.Name, attribute.Dimension, attribute.DimensionNames, (TSliceMode)attribute.SliceMode, (TPinVisibility)attribute.Visibility, out result); switch (attribute.Dimension) { case 2: result.SetSubType2D(attribute.MinValue, attribute.MaxValue, attribute.StepSize, attribute.DefaultValues[0], attribute.DefaultValues[1], attribute.IsBang, attribute.IsToggle, attribute.AsInt); break; case 3: result.SetSubType3D(attribute.MinValue, attribute.MaxValue, attribute.StepSize, attribute.DefaultValues[0], attribute.DefaultValues[1], attribute.DefaultValues[2], attribute.IsBang, attribute.IsToggle, attribute.AsInt); break; case 4: result.SetSubType4D(attribute.MinValue, attribute.MaxValue, attribute.StepSize, attribute.DefaultValues[0], attribute.DefaultValues[1], attribute.DefaultValues[2], attribute.DefaultValues[3], attribute.IsBang, attribute.IsToggle, attribute.AsInt); break; default: result.SetSubType(attribute.MinValue, attribute.MaxValue, attribute.StepSize, attribute.DefaultValue, attribute.IsBang, attribute.IsToggle, attribute.AsInt); break; } result.Order = attribute.Order; result.AutoValidate = attribute.AutoValidate; return(result); }
public List <Particle3d> Update(IValueFastIn field, int sx, int sy, int sz) { List <Particle3d> alive = new List <Particle3d>(); if (this.particles.Count > 0) { LinkedListNode <Particle3d> current = this.particles.First; while (current != null) { try { int cellx = GetIndexX(current.Value.PositionX, sx); int celly = GetIndexY(current.Value.PositionY, sy); int cellz = GetIndexZ(current.Value.PositionZ, sz); int cell = celly * sx + cellx + cellz * sx * sy; double dblvx, dblvy, dblvz; field.GetValue3D(cell, out dblvx, out dblvy, out dblvz); //return ((i) + (_NX + 2) * (j)); if (current.Value.Update(this.dtage, this.dtvelocity, dblvx, dblvy, dblvz)) { LinkedListNode <Particle3d> next = current.Next; current.List.Remove(current); current = next; } else { alive.Add(current.Value); current = current.Next; } } catch { LinkedListNode <Particle3d> next = current.Next; current.List.Remove(current); current = next; } } } return(alive); }
public List <Particle> Update(IValueFastIn field, int sx, int sy) { List <Particle> alive = new List <Particle>(); if (this.particles.Count > 0) { LinkedListNode <Particle> current = this.particles.First; while (current != null) { bool err = false; try { int cellx = GetIndexX(current.Value.PositionX, sx); int celly = GetIndexY(current.Value.PositionY, sy); int cell = celly * sx + cellx; double dblvx, dblvy; field.GetValue2D(cell, out dblvx, out dblvy); if (current.Value.Update(this.dtage, this.dtvelocity, dblvx, dblvy)) { LinkedListNode <Particle> next = current.Next; current.List.Remove(current); current = next; } else { alive.Add(current.Value); current = current.Next; } } catch { LinkedListNode <Particle> next = current.Next; current.List.Remove(current); current = next; } } } return(alive); }
public FastValueInput(IValueFastIn pin) { FPin = pin; pin.GetValuePointer(out lenptr, out dataptr); }
//called by the plugin the host can create a pin public void CreateValueFastInput(string Name, int Dimension, string[] DimensionNames, TSliceMode SliceMode, TPinVisibility Visibility, out IValueFastIn Pin) { Pin = new TValuePin(this, Name, Dimension, DimensionNames, TPinDirection.Input, null, SliceMode, Visibility); AddPin(Pin as TBasePin); }
public override void Configurate(IPluginConfig Input, bool FirstFrame) { //if Input = last ConfigInput created! if (Input == FStateEvents && FirstFrame) { FKeyFrames.Clear(); string name, events; double time; for (int i = 0; i < FStateEvents.SliceCount; i++) { FStateTime.GetValue(i, out time); FStateName.GetString(i, out name); FStateEvents.GetString(i, out events); AddKeyFrame(name, time, events); } FKeyFrames.Sort(delegate(TLBaseKeyFrame k0, TLBaseKeyFrame k1) { return(k0.Time.CompareTo(k1.Time)); }); } //make sure every state's events have according input-pins //remove all inputs that don't have an according event //go through all events and find a corresponding pin List <IValueFastIn> tmpList = new List <IValueFastIn>(); IValueFastIn tmpEventPin; foreach (TLStateKeyFrame skf in FKeyFrames) { foreach (TLEvent e in skf.Events) { if (e.Name != "OnEnd") { IValueFastIn ep = FEventPins.Find(delegate(IValueFastIn p) { return(p.Name == e.Name); }); if (ep == null) { FHost.CreateValueFastInput(e.Name, 1, null, TSliceMode.Single, TPinVisibility.True, out tmpEventPin); tmpEventPin.SetSubType(0, 1, 1, 0, false, false, false); e.EventPin = tmpEventPin; tmpList.Add(tmpEventPin); FEventPins.Add(tmpEventPin); } else { e.EventPin = ep; if (!tmpList.Contains(ep)) { tmpList.Add(ep); } } } } } for (int i = 0; i < FEventPins.Count; i++) { if (!tmpList.Contains(FEventPins[i])) { FHost.DeletePin(FEventPins[i]); } } FEventPins.Clear(); FEventPins.AddRange(tmpList); }