CCG: Remove number of layers from key
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 5 Sep 2018 13:56:50 +0000 (15:56 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 5 Sep 2018 13:56:50 +0000 (15:56 +0200)
The issue there was that number of layers did not include normals,
while element size counts bytes used by normals. This sounds very
fragile and dangerous to work further. Also, one value can easily
be delivered from another, so it is redundancy going on here.

Possible difference now is that multires subdivision will copy
normals to a higher levels. Shouldn't be big of a problem, since
leaving old normals and updating coordinates is not correct either.

source/blender/blenkernel/BKE_ccg.h
source/blender/blenkernel/intern/CCGSubSurf.c
source/blender/blenkernel/intern/multires.c

index 7d5d423282dbc6adc2ebc5a8197b30f62211f385..65d4688947e6e765e460fa40e315ff79a563a8c1 100644 (file)
@@ -72,7 +72,6 @@ typedef struct CCGKey {
         * true */
        int mask_offset;
 
-       int num_layers;
        int has_normals;
        int has_mask;
 } CCGKey;
index c6224da2fe01f3eb88df20df262d092aa618602e..40dea6ca663e8ebe3ff3069d268773b5c0cd24b1 100644 (file)
@@ -1553,7 +1553,6 @@ void CCG_key(CCGKey *key, const CCGSubSurf *ss, int level)
 
        key->elem_size = ss->meshIFC.vertDataSize;
        key->has_normals = ss->calcVertNormals;
-       key->num_layers = ss->meshIFC.numLayers;
 
        /* if normals are present, always the last three floats of an
         * element */
index 636157b08dd9286ada0c8d31906dded15563c1bf..279c6eb0c8275fa2bd78f73766aec60974f764c2 100644 (file)
@@ -578,7 +578,7 @@ static void multires_copy_dm_grid(CCGElem *gridA, CCGElem *gridB, CCGKey *keyA,
                        for (x = 0; x < keyB->grid_size; x++, j++)
                                memcpy(CCG_elem_offset_co(keyA, gridA, y * skip * keyA->grid_size + x * skip),
                                       CCG_elem_offset_co(keyB, gridB, j),
-                                      sizeof(float) * keyA->num_layers);
+                                      keyA->elem_size);
        }
        else {
                skip = (keyB->grid_size - 1) / (keyA->grid_size - 1);
@@ -587,7 +587,7 @@ static void multires_copy_dm_grid(CCGElem *gridA, CCGElem *gridB, CCGKey *keyA,
                        for (x = 0; x < keyA->grid_size; x++, j++)
                                memcpy(CCG_elem_offset_co(keyA, gridA, j),
                                       CCG_elem_offset_co(keyB, gridB, y * skip * keyB->grid_size + x * skip),
-                                      sizeof(float) * keyA->num_layers);
+                                      keyA->elem_size);
        }
 }