void LightComponent::init() { Noto::info("Initializing lighting"); auto& terrain = world(Terrain); auto& light = world(Light); MetricsTimer lightInitTimer("Light initialization timer"); AccumVecRange3<VoxelCoord> coordRange(VoxelCoord(100000,100000,100000),VoxelCoord(-1000000,-1000000,-1000000)); terrain.material.foreach([&](MaterialTalea *talea) { coordRange.apply(talea->position); }); for (int tz = coordRange.max.z; tz >= coordRange.min.z; tz -= TaleaDim) { for (int ty = coordRange.min.y; ty <= coordRange.max.y; ty += TaleaDim) { for (int tx = coordRange.min.x; tx <= coordRange.max.x; tx += TaleaDim) { LightTalea& lightTal = light.globalLightValues.getTaleaRW(tx,ty,tz); lightTal.setAll(0); } } } for (int tz = coordRange.max.z + TaleaDim; tz >= coordRange.min.z - TaleaDim; tz -= TaleaDim) { for (int ty = coordRange.min.y - TaleaDim; ty <= coordRange.max.y + TaleaDim; ty += TaleaDim) { for (int tx = coordRange.min.x - TaleaDim; tx <= coordRange.max.x + TaleaDim; tx += TaleaDim) { initializeLightingTalea(tx,ty,tz,terrain,light); } } } lightInitTimer.printElapsed(); }
void MotionSystem::randomlyShiftParticle(Particle* particle) { // TODO: This should be experimentally determined boost::uniform_real<float> coordRange(-1.f * xAndYNoise, xAndYNoise); boost::uniform_real<float> headRange (-1.f * hNoise , hNoise); boost::variate_generator<boost::mt19937&, boost::uniform_real<float> > coordNoise(rng, coordRange); boost::variate_generator<boost::mt19937&, boost::uniform_real<float> > headNoise(rng, headRange); // Determine random noise messages::RobotLocation noise; noise.set_x(coordNoise()); noise.set_y(coordNoise()); noise.set_h(NBMath::subPIAngle(headNoise())); particle->shift(noise); }