void WideVM::addParticles(int amount, VMLocation runprogram) { const int oldsize = particleCount(); m_particles.resize(m_particles.size() + amount * m_particlesize, 0.f); if(runprogram.valid()) { runVmProgram(runprogram, oldsize); } }
/****************************************************************************** * Toggles the selection state of a single particle. ******************************************************************************/ void ParticleSelectionSet::toggleParticle(const PipelineFlowState& state, size_t particleIndex) { if(particleIndex >= particleCount(state)) return; ParticlePropertyObject* identifiers = ParticlePropertyObject::findInState(state, ParticleProperty::IdentifierProperty); if(useIdentifiers() && identifiers) { _selection.clear(); toggleParticleIdentifier(identifiers->getInt(particleIndex)); } else if((int)particleIndex < _selection.size()) { _selectedIdentifiers.clear(); toggleParticleIndex(particleIndex); } }
/****************************************************************************** * Clears the particle selection. ******************************************************************************/ void ParticleSelectionSet::clearSelection(const PipelineFlowState& state) { // Make a backup of the old selection state so it may be restored. if(dataset()->undoStack().isRecording()) dataset()->undoStack().push(new ReplaceSelectionOperation(this)); if(useIdentifiers() && ParticlePropertyObject::findInState(state, ParticleProperty::IdentifierProperty)) { _selection.clear(); _selectedIdentifiers.clear(); } else { _selection.fill(false, particleCount(state)); _selectedIdentifiers.clear(); } notifyDependents(ReferenceEvent::TargetChanged); }
/****************************************************************************** * Selects all particles in the given particle data set. ******************************************************************************/ void ParticleSelectionSet::selectAll(const PipelineFlowState& state) { // Make a backup of the old selection state so it may be restored. if(dataset()->undoStack().isRecording()) dataset()->undoStack().push(new ReplaceSelectionOperation(this)); ParticlePropertyObject* identifiers = ParticlePropertyObject::findInState(state, ParticleProperty::IdentifierProperty); if(useIdentifiers() && identifiers != nullptr) { _selection.clear(); _selectedIdentifiers.clear(); for(int id : identifiers->constIntRange()) _selectedIdentifiers.insert(id); } else { _selection.fill(true, particleCount(state)); _selectedIdentifiers.clear(); } notifyDependents(ReferenceEvent::TargetChanged); }
void WideVM::runVmProgram(VMLocation loc, int b, int e) { m_begin = (b == -1)?0:b; m_end = (e == -1)?particleCount():e; if(loc.Location == -1) loc.Location = findStrInVector(loc.Name, m_prognames); if(loc.Location == -1) return; m_programcounter = m_subprograms[loc.Location]; while(m_programcounter < m_program.size()) { startLoop(); //in case an opcode uses while loopParticle init counter for it const int opcode = fetch(); switch(opcode) { case EVO_QUIT: opQuit(); break; case EVO_SIN: opSin(); break; case EVO_COS: opCos(); break; case EVO_COPY: opCopy(); break; case EVO_RAND2: opRand2(); break; case EVO_MATH2: opMath2(); break; } //switch opcodes pc } //while pc < opcodes size }