int step(){ memcpy(cmap, map, sizeof(map)); int i; int j; for (i = 0; i < WIDTH; i ++){ for (j = 0; j < HEIGHT; j ++){ cellStep(i,j); } } return 0; }
//-------------------------------------------------------------- // return first brick at ray. return false if none BOOL BrickBlob::rayIntersect( const mgPoint3& origin, const mgPoint3& ray, double limit, double& dist, mgPoint3& hitPt, int& face, int& cellX, int& cellY, int& cellZ) { mgPoint3 pt(origin); // get the initial cell cellX = (int) floor(pt.x); cellY = (int) floor(pt.y); cellZ = (int) floor(pt.z); dist = 0.0; // point assumed to start within the blob, in an air brick while (true) { // step to next cell edge cellStep(pt, ray, dist, cellX, cellY, cellZ, face); // if we're out of the blob, we're done if (cellX < 0 || cellX >= BRICKBLOB_CELLS || cellY < 0 || cellY >= BRICKBLOB_CELLS || cellZ < 0 || cellZ >= BRICKBLOB_CELLS) return false; // if distance over limit, we're done if (dist > limit) return false; short brickType = m_bricks[BRICK_CELL(BRICKBLOB_SIZE, cellX, cellY, cellZ)]; // if not air, we've hit a block if (brickType != 0) { hitPt = pt; return true; } } }