Don't store ray lengths in a second array, instead store them in the rays. Also store their starting index, which makes the ray_coords indexing a little cleaner.
WY3Q6JZ3HTBF2CYFJOUVG4MMFINBK4PI2DJ625CVKMJ5BPMXAW2AC 4FBWCGO5NTT2KBBTYTYVR2AOBI5LHSP7L3TB3ESYF6OFLMEJQESQC Q52ILIIFMJ6HBSIUF7V7XQ6DQJGGYMHUZJ6CWVQKDX2JKBHEP2HAC SVY2PTCLXR3KNPQAWXVXTTGCC5DR334HOAKHYO3VDDRWM2BWMALAC YGPAMROCZY2O2N4PJONW6NMFUNOFHAGT5ZA4APCXKFXQUHLEIN2AC ACZYEIX7WMPIIODKCATBCUE626AJ4ZGGBOMVC6BGXM27EQU2RECAC PHJ2TT2CQ2IRXOB5KAV2664KKTPYFPFUIBEGAOQBGB4SAZ7PKNHAC ICVDXXH2Z5MV7BLYVWQNLQSV63THIB4E6NVORIDBB7D6TBEHBXOAC ZJBFGI5FGCP7WGFKEUTLWZK4ATGB35Q4I5IB4BKJTHVKS2HDR5LQC UFMQQPYCBI6Z576P7PH4ZAPC7L7P3D4H66NJMFQKP6WRAPIK2NOQC A2CVFMQAYVHJX2DVHZKWBSV54JQ52LARAOA66R65ID5VAORTSRJAC // Fullrays and raylengths are of equal size. The footprint// of fullray[i] consists of raylengths[i] cells, whose// coordinates are stored in ray_coord after the// coordinates of fullray[i-1].
// The footprint of fullray[i] consists of fullray[i].length cells,// whose coordinates are stored in ray_coords after the// coordinates of fullray[i-1].
// Only compare equal-length rays.if (raylengths[i] != len)
}// Shoot a ray from the given start point (accx, accy) with the given// slope, bounded by the given pre-squared LOS radius.std::vector<coord_def> footprint(int radius2){std::vector<coord_def> cs;los_ray copy = *this;coord_def c;int cellnum;for (cellnum = 0; true; ++cellnum)
int j;for (j = 0; j < len; ++j)if (ray_coord[j + cur_offset] != pos[j])break;
coord_def operator[](unsigned int i){ASSERT(0 <= i && i < length);return ray_coords[start+i];}};
// Exact duplicate?if (j == len)return (true);
// Check if the passed rays have identical footprint.static bool _is_same_ray(los_ray ray, std::vector<coord_def> newray){if (ray.length != newray.size())return false;for (unsigned int i = 0; i < ray.length; i++)if (ray[i] != newray[i])return false;return true;}
// Move to beginning of next ray.cur_offset += raylengths[i];}return (false);
// Check if the passed ray has already been created.static bool _is_duplicate_ray(std::vector<coord_def> newray){for (unsigned int i = 0; i < fullrays.size(); ++i)if (_is_same_ray(fullrays[i], newray))return true;return false;
const coord_def test = ray_coord[testidx + testcell];// We can short-circuit sometimes.if (test.x > cur.x || test.y > cur.y)
// Short-circuit if we've passed ray[i]// in either coordinate.if (prev[j].x > ray[i].x || prev[j].y > ray[i].y)
coord_def pos[LOS_MAX_RANGE * 2 + 1];ray_def ray = ray_def(accx, accy, slope, QUAD_SE);// find out which cells the ray passes throughint raylen = ray.footprint(LOS_RADIUS2, pos);
los_ray ray = los_ray(accx, accy, slope);std::vector<coord_def> coords = ray.footprint(LOS_RADIUS2);
// Not duplicate, register.for (int i = 0; i < raylen; ++i){// Create the cellrays.ray_coord.push_back(pos[i]);}// Register the fullray.raylengths.push_back(raylen);fullrays.push_back(ray);
ray.start = ray_coords.size();ray.length = coords.size();for (unsigned int i = 0; i < coords.size(); i++)ray_coords.push_back(coords[i]);
std::vector<int> nondupe_cellrays = _find_nonduped_cellrays();const int num_nondupe_rays = nondupe_cellrays.size();const int num_cellrays = ray_coord.size();
std::vector<int> nondupe_cellrays = _find_nonduped_cellrays();const int num_nondupe_rays = nondupe_cellrays.size();const int num_cellrays = ray_coords.size();