public ParticleProcessorViewModel(IParticleProcessor particleProcessor, TreeViewItemViewModel parent, INodeAddedCallback nodeAddCB, ICommand removeParticleProcessor) : base(particleProcessor.GetType().Name, parent, nodeAddCB, particleProcessor) { RemoveParticleProcessor = removeParticleProcessor; ParticleProcessor = particleProcessor; }
//build it public ParticleStore(uint maxTimeSteps, ParticleSystemTypeData type, IParticleProcessor processor, int particleTypeCount, int particleTypeIndex) { if (type == null) throw new ArgumentNullException(); this.typeEmitDependancy = new bool[particleTypeCount + 1]; this.particleTypeIndex = particleTypeIndex; this.particleType = type; this.processor = processor; this.frameEmitter = type.FrameEmitter; this.removeEmitter = type.RemoveEmitter; this.timeStepCount = 1; while (maxTimeSteps > this.timeStepCount) this.timeStepCount *= 2; this.timeStepMask = (int)this.timeStepCount - 1; this.timeSteps = new SystemTimeStep[timeStepCount]; this.particles = new Particle[Math.Max(4,type.ExpectedMaxCapacity)]; this.addActions = new AddAction[8]; this.copyActions = new CopyAction[8]; }
public ProcessorAddList(IParticleProcessor processor) { this.processor = processor as GpuParticleProcessor; }
void IParticleProcessor.Initalise(ParticleSystemTypeData typeData, IParticleProcessor[] allProcessors, bool useColourValues, uint maxLifeTimeSteps, uint timeStepHz, uint maxExpectedCount) { CpuParticleProcessorData processor = typeData.RuntimeLogicData.CpuParticleProcessorData; this.particleTypeData = typeData; this.timeStepHz = timeStepHz; this.processors = allProcessors; this.addIndices = new uint[8]; //max expected count is always a power of 2 this.maxCount = maxExpectedCount; this.countMask = maxExpectedCount - 1; bool usesUserValues = typeData.RuntimeLogicData.SystemUsesUserValues; bool usesLifeOrAge = typeData.RuntimeLogicData.SystemUsesLifeOrAgeValues; positions = new Vector4[maxExpectedCount]; velocity = new Vector4[maxExpectedCount]; if (useColourValues) colours = new Vector4[maxExpectedCount]; if (usesUserValues) userdata = new Vector4[maxExpectedCount]; if (usesLifeOrAge) lifeData = new Vector2[maxExpectedCount]; System.Reflection.Assembly asm = processor.Assembly; Type type = asm.GetType(processor.RuntimeClassName); System.Reflection.MethodInfo frameMethod = type.GetMethod(typeData.Name + "_frame", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); System.Reflection.MethodInfo onceMethod = type.GetMethod(typeData.Name + "_once", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); this.frameMethod = (UpdateParticleDelegate)Delegate.CreateDelegate(typeof(UpdateParticleDelegate), frameMethod); this.onceMethod = (AddParticleDelegate)Delegate.CreateDelegate(typeof(AddParticleDelegate), onceMethod); }