Point p1, p2, p3, p4;
Point pRowStart, pRowEnd, p, rowStartInc, rowEndInc, pInc;
void rippleRender()
{
int px = 0, py = 0, dx = 0, dy = 0;
int index = 0, offset = 0;
for (int j = 1; j < m_meshHeight; ++j) {
offset = j * m_meshWidth;
for (int i = 1; i < m_meshWidth; ++i) {
index = offset + i;
p1.x = m_bufDiffX[index - m_meshWidth - 1];
p1.y = m_bufDiffY[index - m_meshWidth - 1];
p2.x = m_bufDiffX[index - m_meshWidth];
p2.y = m_bufDiffY[index - m_meshWidth];
p3.x = m_bufDiffX[index - 1];
p3.y = m_bufDiffY[index - 1];
p4.x = m_bufDiffX[index];
p4.y = m_bufDiffY[index];
pRowStart.x = p1.x << MeshShift;
pRowStart.y = p1.y << MeshShift;
rowStartInc.x = p3.x - p1.x;
rowStartInc.y = p3.y - p1.y;
pRowEnd.x = p2.x << MeshShift;
pRowEnd.y = p2.y << MeshShift;
rowEndInc.x = p4.x - p2.x;
rowEndInc.y = p4.y - p2.y;
py = (j - 1) << MeshShift;
for (int y = 0; y < MeshSize; ++y) {
p.x = pRowStart.x;
p.y = pRowStart.y;
// scaled by MeshSize times
pInc.x = (pRowEnd.x - pRowStart.x) >> MeshShift;
pInc.y = (pRowEnd.y - pRowStart.y) >> MeshShift;
px = (i - 1) << MeshShift;
for (int x = 0; x < MeshSize; ++x) {
dx
= px + p.x >> MeshShift;
dy
= py + p.y >> MeshShift;
if ((dx >= 0)
&& (dy >= 0) && (dx < m_width) && (dy < m_height) ) {
m_bitmap2[py * m_width + px] = m_bitmap1[dy * m_width + dx];
}
else {
m_bitmap2[py * m_width + px] = m_bitmap1[py * m_width + px];
}
p.x += pInc.x;
p.y += pInc.y;
++px;
}
pRowStart.x += rowStartInc.x;
pRowStart.y += rowStartInc.y;
pRowEnd.x += rowEndInc.x;
pRowEnd.y += rowEndInc.y;
++py;
}
}
}
}
|