/** * This functions does a scan conversion of a line with the given start and end points. * This problem is equal to the following problem: * Assuming an index that works by referencing lines by linking them to all cells in a cell * grid that contain or are crossed by the line. Which cells does the line cross? * * The given vector for the result data is not cleared on start, to allow multiple calls * to this method with different line segments. * * The algorithm of Bresenham is used together with some checks for special cases. */ void ScanConvertLine(int x1, int y1, int x2, int y2, std::vector<ScanCell>& cells) { bool steep=std::abs(y2-y1)>std::abs(x2-x1); if (steep) { std::swap(x1,y1); std::swap(x2,y2); } if (x1>x2) { std::swap(x1,x2); std::swap(y1,y2); } int dx=x2-x1; int dy=std::abs(y2-y1); int error=dx/2; int ystep; int y=y1; if (y1<y2) { ystep=1; } else { ystep=-1; } for (int x=x1; x<=x2; x++) { if (steep) { cells.push_back(ScanCell(y,x)); } else { cells.push_back(ScanCell(x,y)); } error-=dy; if (error<0) { y+=ystep; error+=dx; } } }
void CWorld::DoUpdate() { _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); if(m_suspended) return; //ScanHair(); m_lock.lock(); auto currTime = m_useSeperatedClock ? clock()*0.001 : *timeStamp; auto interval = currTime - m_timeLastUpdate; if(interval > TIME_TICK * 0.5) { m_timeLastUpdate = currTime; ScanCell(); //if(m_savedDeltaTime > TIME_TICK_US*2) m_savedDeltaTime = TIME_TICK_US*2; StepWorld(interval); } hkSkyrimMemoryAllocator::releaseAll(); m_lock.unlock(); }