//called when data for any output pin is requested public void Evaluate(int SpreadMax) { //check if delete is called at all (if not, quit early) if (!FInDelete.Any(value => value == true)) { return; } //update inputs { FInSlides.Sync(); SpreadMax = Utils.SpreadMax(FInSlides, FInDelete); } for (int i = 0; i < SpreadMax; i++) { if (FInDelete[i]) { var slide = FInSlides[i]; if (slide != null) { World world; if (slide.World.TryGetTarget(out world)) { if (world.Slides.Contains(slide)) { world.Slides.Remove(slide); } } } } } }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { //check if set is called at all (if not, quit early) if (!FInSet.Any(value => value == true)) { return; } //update inputs { FInSlides.Sync(); FInTransform.Sync(); SpreadMax = Utils.SpreadMax(FInSlides, FInTransform, FInSet); } for (int i = 0; i < SpreadMax; i++) { if (FInSet[i]) { var slide = FInSlides[i]; if (slide != null) { slide.Transform = FInTransform[i]; } } } }
#pragma warning restore #endregion fields & pins public void Evaluate(int spreadMax) { if (FSetIn[0]) { FInput.Sync(); FOutput.AssignFrom(FInput); } }
void HandleDeclarationChanged() { bool invalidate = false; for (int i = 0; i < FBuffer.SliceCount; i++) { if (FBuffer[i] != null && (FBuffer[i].Name == oldDeclarationName || !FBuffer[i].Equals(changedDeclaration))) { if (!invalidate) { FInput.Sync(); } FBuffer[i] = new Core.Struct(FInput[i]); FOutput[i] = new Core.Struct(FInput[i]); invalidate = true; } } declarationChanged = invalidate; }
public void PushToLid(IEnumerable <Agent> agents) { if (IsPinValid(FSink)) { FSink[0].Agents.Clear(); FSink[0].Agents.AddRange(FAgents); } FSink.Sync(); FEditedAgents.Sync(); FReturn.Sync(); }
public void Evaluate(int SpreadMax) { FInvalidate = false; if (FApply[0] || FFirst) { FInData.Sync(); if (FInData.SliceCount > 0) { if (FInData.SliceCount < FOutput.SliceCount) { for (int i = FInData.SliceCount; i < FOutput.SliceCount; i++) { if (FOutput[i] != null) { FOutput[i].Dispose(); } } } FOutput.SliceCount = FInData.SliceCount; FValid.SliceCount = FInData.SliceCount; for (int i = 0; i < FInData.SliceCount; i++) { if (FOutput[i] == null) { FOutput[i] = new DX11Resource <IDX11ReadableStructureBuffer>(); } } } else { if (FOutput.SliceCount > 0) { for (int i = 0; i < FOutput.SliceCount; i++) { if (FOutput[i] != null) { FOutput[i].Dispose(); } } } FOutput.SliceCount = 0; FValid.SliceCount = 0; } FInvalidate = true; FFirst = false; FOutput.Stream.IsChanged = true; } }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { FExceptionMsg.SliceCount = 0; try { FInput.Sync(); } catch (Exception e) { FExceptionMsg.SliceCount = 1; FExceptionMsg[0] = e.Message; } }
public void Evaluate(int SpreadMax) { this.FInvalidate = false; if (FUpdate != null && FUpdate[0]) { this.FVertex.Clear(); this.FIndices.Clear(); FVertexPin.Sync(); FNormalsPin.Sync(); FTexPin.Sync(); FIndexPin.Sync(); int meshCount = Math.Max(FVertexPin.SliceCount, FTexPin.SliceCount); meshCount = Math.Max(meshCount, FNormalsPin.SliceCount); meshCount = Math.Max(meshCount, FIndexPin.SliceCount); for (int i = 0; i < meshCount; i++) { int vertexCount = Math.Max(FVertexPin[i].SliceCount, FTexPin[i].SliceCount); Pos4Norm3Tex2Vertex[] verts = new Pos4Norm3Tex2Vertex[Convert.ToInt32(vertexCount)]; for (int j = 0; j < vertexCount; j++) { verts[j].Position = new Vector4(FVertexPin[i][j], 1.0f); verts[j].Normals = FNormalsPin[i][j]; verts[j].TexCoords = FTexPin[i][j]; } this.FVertex.Add(verts); List <int> inds = new List <int>(); for (int j = 0; j < FIndexPin[i].SliceCount; j++) { Vector3 triangle = FIndexPin[i][j]; inds.Add((int)triangle.X); inds.Add((int)triangle.Y); inds.Add((int)triangle.Z); } this.FIndices.Add(inds.ToArray()); } this.InvalidateMesh(meshCount); } }
public void Evaluate(int SpreadMax) { FOutput.Stream.IsChanged = false; if (Initial) { FOutput.AssignFrom(FDefault); Initial = false; FOutput.Flush(); FOutput.Stream.IsChanged = true; } if (FEval[0]) { FInput.Sync(); FOutput.AssignFrom(FInput); FOutput.Flush(); FOutput.Stream.IsChanged = true; } }
public void Evaluate(int SpreadMax) { SpreadMax = FInput.SliceCount; if (FInput.IsAnyInvalid()) { SpreadMax = 0; } FKill.Sync(); for (int i = 0; i < SpreadMax; i++) { var agent = FInput[i]; agent.Killed = FKill[i]; } FOutput.AssignFrom(FInput); FOutput.Flush(); }
protected void TestInputPin <T>(T[] sampleData) { var pinName = string.Format("{0} Input", typeof(T)); var attribute = new InputAttribute(pinName); ISpread <T> spread = FFactory.CreateIO <ISpread <T> >(attribute); spread.Sync(); Assert.AreEqual(1, spread.SliceCount, "Initial slice count must be 1 of input spread."); TestSpread(spread, sampleData); ISpread <ISpread <T> > spreadedSpread = FFactory.CreateIO <ISpread <ISpread <T> > >(attribute); spreadedSpread.Sync(); Assert.True(spreadedSpread.SliceCount == 1); TestSpread(spreadedSpread, new ISpread <T>[] { new Spread <T>(sampleData.ToList()), new Spread <T>(sampleData.ToList()) }); }
public void Evaluate(int SpreadMax) { SpreadMax = FInput.SliceCount; if (FInput.IsAnyInvalid()) { SpreadMax = 0; } FHistoryCount.Sync(); FTransform.SliceCount = SpreadMax; FPosition.SliceCount = SpreadMax; FVelocity.SliceCount = SpreadMax; FForceSum.SliceCount = SpreadMax; for (int i = 0; i < SpreadMax; i++) { IAgent agent = FInput[i]; agent["HistoryCount"].First = FHistoryCount[i]; FPosition[i].AssignFrom(agent.PositionHistory()); FVelocity[i].AssignFrom(agent.VelocityHistory()); FForceSum[i].AssignFrom(agent.ForceSumHistory()); var rot = VMath.PolarVVVV(agent.VelocityHistory(0)); var transform = VMath.RotateY(VMath.Pi / 2) * VMath.Rotate(rot) * VMath.Translate(agent.PositionHistory(0)); FTransform[i] = transform; } FOutput.AssignFrom(FInput); FTransform.Flush(); FPosition.Flush(); FVelocity.Flush(); FForceSum.Flush(); FOutput.Flush(); }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { FInBp.Sync(); FOutBp.Sync(); SpreadMax = FInput.CombineWith(FInBp).CombineWith(FOutBp).CombineWith(FMapMode); FOutput.SliceCount = SpreadMax; for (int i = 0; i < SpreadMax; i++) { if (FOutBp[i].SliceCount == 1) //if only one in- & outbreakpoint output outbreakpoint { FOutput[i] = FOutBp[i][0]; } else if (FOutBp[i].SliceCount > 0) //apply mapinterval only if more than one in-/outbreakpoint { MapInterval m = new MapInterval(FInBp[i].ToList(), FOutBp[i].ToList()); FOutput[i] = m.DoMap(FInput[i], FMapMode[i].Index); } } }
public void Evaluate(int spreadMax) { FLastSet.ResizeAndDismiss(FSet.SliceCount, (int i) => !FSet[i]); if (FSet.SliceCount == 1) { if (FSet[0]) { FInput.Sync(); FOutput.ResizeAndDismiss(spreadMax, (int i) => FInput[i]); FBuffer.ResizeAndDismiss(spreadMax, (int i) => FInput[i] == null ? null : new StructType(FInput[i])); for (int i = 0; i < FInput.SliceCount; i++) { if (FOutput[i] != FInput[i]) { FOutput[i] = FInput[i]; if (FInput[i] != null) { FBuffer[i] = new StructType(FInput[i]); } } } } else if ((FSet[0] != FLastSet[0]) && (!FSet[0])) { FOutput.SliceCount = FBuffer.SliceCount; for (int i = 0; i < FInput.SliceCount; i++) { if (FBuffer[i] != null) { FOutput[i] = new StructType(FBuffer[i]); foreach (var f in FBuffer[i].Fields) { FOutput[i][f] = FBuffer[i].GetClonedData(f); } } else { FOutput[i] = null; } } } } else { FInput.Sync(); FOutput.ResizeAndDismiss(spreadMax, (int i) => null); FBuffer.ResizeAndDismiss(spreadMax, (int i) => null); for (int i = 0; i < spreadMax; i++) { if (FSet[i]) { if (FOutput[i] != FInput[i]) { FOutput[i] = FInput[i]; if (FInput[i] != null) { FBuffer[i] = new StructType(FInput[i]); } } } else if ((FSet[i] != FLastSet[i]) && (!FSet[i])) { if (FBuffer[i] == null) { FOutput[i] = null; } else { FOutput[i] = new StructType(FBuffer[i]); foreach (var f in FBuffer[i].Fields) { FOutput[i][f] = FBuffer[i].GetClonedData(f); } } } } } FLastSet.AssignFrom(FSet); }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { if (!FInWorld.PluginIO.IsConnected) { return; } //check if add is called at all (if not, quit early) if (!FInAdd.Any(add => add == true)) { return; } //evaluate the inputs { FInPosition.Sync(); FInRotation.Sync(); FInScale.Sync(); FInTags.Sync(); FInBehavior.Sync(); FInConstraint.Sync(); FInDragHitTestFunction.Sync(); FInHitEvents.Sync(); SpreadMax = Utils.SpreadMax(FInPosition , FInRotation , FInScale , FInTags , FInBehavior , FInConstraint , FInDragHitTestFunction , FInHitEvents , FInAdd); } var world = FInWorld[0]; for (int i = 0; i < SpreadMax; i++) { if (FInAdd[i]) { //construct the new slide var newSlide = new Slide(world) { Index = world.NextAvailableIndex, Transform = VMath.Scale(FInScale[i].x, FInScale[i].y, 1.0) * VMath.RotateZ(FInRotation[i]) * VMath.Translate(FInPosition[i].x, FInPosition[i].y, 0.0), Tags = new List <String>(FInTags[i]), Behavior = FInBehavior[i], Constraint = FInConstraint[i], DragHitTestFunction = FInDragHitTestFunction[i], HitEvents = new List <HitEvent>(FInHitEvents[i]) }; //clear out any null HitEvents (e.g. if spread was empty) newSlide.HitEvents.RemoveAll(hitEvent => hitEvent == null); //add the new slide to the world world.Slides.Add(newSlide); } } }