PhysicsObject::PhysicsObject(const Box3d<float>& box, const float divideLength, const SPHConstant& constant): constant(constant), nextId(0) { const auto points = box.toPoints(divideLength); for (const auto& pos : points) { SPHParticle* p = new SPHParticle(pos, divideLength*0.5f, &this->constant, nextId++); particles.push_back(p); } }
std::vector<SPHParticle*> PhysicsObject::createParticles(const Box3d<float>& box, const float divideLength) { std::vector<SPHParticle*> newParticles; const auto points = box.toPoints(divideLength); for (const auto& pos : points) { SPHParticle* p = new SPHParticle(pos, divideLength*0.5f, &this->constant, nextId++); particles.push_back(p); newParticles.push_back(p); } return newParticles; }