From f65ce8bbe4da44ed9c84d6f346f72c6ef3f5752e Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 1 Feb 2020 22:33:31 +0000 Subject: [PATCH] Make some init_points variables const --- similar/main/morph.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/similar/main/morph.cpp b/similar/main/morph.cpp index 7c253deda..c45f4c38d 100644 --- a/similar/main/morph.cpp +++ b/similar/main/morph.cpp @@ -124,34 +124,30 @@ constexpr fix morph_rate = MORPH_RATE; static void init_points(const polymodel *const pm, const vms_vector *const box_size, const unsigned submodel_num, morph_data *const md) { - ushort nverts; - uint16_t type; - int i; - auto data = reinterpret_cast(&pm->model_data[pm->submodel_ptrs[submodel_num]]); - type = *data++; + const uint16_t type = *data++; Assert(type == 7 || type == 1); - nverts = *data++; + const uint16_t nverts = *data++; md->n_morphing_points[submodel_num] = 0; - if (type==7) { - i = *data++; //get start point number - data++; //skip pad - } - else - i = 0; //start at zero + const unsigned startpoint = (type == 7) + ? *exchange(data, data + 2) //get start point number, skip pad + : 0; //start at zero + unsigned i = startpoint; assert(i + nverts < morph_data::MAX_VECS); md->submodel_startpoints[submodel_num] = i; auto vp = reinterpret_cast(data); - while (nverts--) { + range_for (auto &&iteration, xrange(nverts)) + { + (void)iteration; fix k,dist; if (box_size) {