Commit: 002cb94cc68f150344f8ee213c9b02c0b47c3f65
Author: Grigory Revzin
Date:   Sun Aug 3 17:16:12 2014 +0400
Branches: soc-2014-shapekey
https://developer.blender.org/rB002cb94cc68f150344f8ee213c9b02c0b47c3f65

Better naming for compressed keyblock vertices-related stuff

(No 'real' changes)

===================================================================

M       source/blender/blenloader/intern/readfile.c
M       source/blender/blenloader/intern/writefile.c
M       source/blender/makesdna/DNA_key_types.h

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 8f314a8..eb10aae 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3042,7 +3042,7 @@ static void uncompress_kb(Key * key, KeyBlock *kb)
        float(*kbco)[3];
 
        KeyBlock *rk = key->refkey;
-       KB_ComprMeshDataEnt *kbcde = (KB_ComprMeshDataEnt *)kb->data;
+       CompressedMeshVertex *verts = (CompressedMeshVertex *)kb->data;
 
        /* allocate space for uncompressed data */
        kb->data = MEM_mallocN(sizeof(float) * 3 * rk->totelem, "KeyBlock");
@@ -3053,16 +3053,16 @@ static void uncompress_kb(Key * key, KeyBlock *kb)
        
        /* step two: overwrite the saved vertices */
        for (a = 0; a < kb->totelem; ++a) {
-               index = kbcde[a].vertex_index;
-               copy_v3_v3(kbco[index], kbcde[a].co);
+               index = verts[a].vertex_index;
+               copy_v3_v3(kbco[index], verts[a].co);
        }
 
        kb->totelem = rk->totelem;
 
        /* free compressed data */
-       if (kbcde) {
+       if (verts) {
                /* compressed data may be NULL when a kb doesn't have any 
differences from the basis */
-               MEM_freeN(kbcde);
+               MEM_freeN(verts);
        }
 }
 
@@ -3073,10 +3073,10 @@ static void switch_endian_keyblock(Key *key, KeyBlock 
*kb)
        data = kb->data;
 
        if (kb->compressed) {
-               KB_ComprMeshDataEnt *kbcde = (KB_ComprMeshDataEnt *)data;
+               CompressedMeshVertex *verts = (CompressedMeshVertex *)data;
                for (a = 0; a < kb->totelem; ++a) {
-                       BLI_endian_switch_int32(&kbcde[a].vertex_index);
-                       BLI_endian_switch_float_array((float *) &kbcde[a].co, 
3);
+                       BLI_endian_switch_int32(&verts[a].vertex_index);
+                       BLI_endian_switch_float_array((float *) &verts[a].co, 
3);
                }
        } 
        else {
diff --git a/source/blender/blenloader/intern/writefile.c 
b/source/blender/blenloader/intern/writefile.c
index dc18c17..de10e6f 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1585,43 +1585,43 @@ static void write_vfonts(WriteData *wd, ListBase 
*idbase)
 static void compress_kb(KeyBlock *kb, Key *key_owner)
 {
        /* the idea: we can get a space win by storing only the vertices with 
changed positions */
-       int a, changed_verts;
+       int a, n_changed_verts;
        float diff[3];
        KeyBlock *rk = key_owner->refkey;
        float (*kbco)[3] = kb->data;
        float (*rkbco)[3] = rk->data;
 
-       KB_ComprMeshDataEnt *kbcde = MEM_callocN(sizeof(KB_ComprMeshDataEnt) * 
rk->totelem, __func__);
+       CompressedMeshVertex *verts = MEM_callocN(sizeof(CompressedMeshVertex)* 
rk->totelem, __func__);
 
        BLI_assert(kb->data); /* should not happen at any time! */
 
-       changed_verts = 0; /* counts CompMeshDataEntries as well */
+       n_changed_verts = 0; /* counts CompressedMeshVertexes */
        for (a = 0; a < rk->totelem; ++a) {
                sub_v3_v3v3(diff, rkbco[a], kbco[a]);
                if (len_squared_v3(diff) > 0.0001f) {
                        /* this vert's pos has changed from the base */
-                       copy_v3_v3(kbcde[changed_verts].co, kbco[a]);
-                       kbcde[changed_verts].vertex_index = a;
-                       ++changed_verts;
+                       copy_v3_v3(verts[n_changed_verts].co, kbco[a]);
+                       verts[n_changed_verts].vertex_index = a;
+                       ++n_changed_verts;
                }
        }
 
        /* time to decide if we're going to win space by saving to compressed 
format */
-       if (changed_verts * sizeof(KB_ComprMeshDataEnt) < rk->totelem * 
sizeof(float) * 3) {
+       if (n_changed_verts * sizeof(verts) < rk->totelem * sizeof(float)* 3) {
                /*       size we get with compress      */   /* size we get 
without compress */
                kb->compressed = 1;
-               kb->totelem = changed_verts;
+               kb->totelem = n_changed_verts;
 
                MEM_freeN(kb->data);
-               kb->data = kbcde;
+               kb->data = verts;
 
                if (G.debug_value == 1) {
                        printf("Compressed Shape Key %s, %.2f times smaller\n", 
kb->name,
-                                       (rk->totelem * sizeof(float) * 3.0f) / 
(changed_verts * sizeof(KB_ComprMeshDataEnt)));
+                               (rk->totelem * sizeof(float) * 3.0f) / 
(n_changed_verts * sizeof(CompressedMeshVertex)));
                }
        }
        else {
-               MEM_freeN(kbcde);
+               MEM_freeN(verts);
                /* just ensure */
                kb->compressed = 0;
        }
@@ -1675,7 +1675,7 @@ static void write_keys(WriteData *wd, ListBase *idbase)
                                while (kb) {
                                        writestruct(wd, DATA, "KeyBlock", 1, 
kb);
                                        if (kb->compressed) 
-                                               writedata(wd, DATA, 
sizeof(KB_ComprMeshDataEnt) * kb->totelem, kb->data);
+                                               writedata(wd, DATA, 
sizeof(CompressedMeshVertex)* kb->totelem, kb->data);
                                        else
                                                writedata(wd, DATA, kb->totelem 
* key->elemsize, kb->data);
                                        kb = kb->next;
diff --git a/source/blender/makesdna/DNA_key_types.h 
b/source/blender/makesdna/DNA_key_types.h
index 55eaf58..a53d1d0 100644
--- a/source/blender/makesdna/DNA_key_types.h
+++ b/source/blender/makesdna/DNA_key_types.h
@@ -42,12 +42,12 @@
 struct AnimData;
 struct Ipo;
 
+# /* These two things tell makesdna to ignore this struct */
 #
-#
-typedef struct KB_ComprMeshDataEnt {
+typedef struct CompressedMeshVertex {
        int vertex_index;
        float co[3];
-} KB_ComprMeshDataEnt;
+} CompressedMeshVertex;
 
 typedef struct KeyBlock {
        struct KeyBlock *next, *prev;
@@ -59,7 +59,7 @@ typedef struct KeyBlock {
 
        short type;        /* interpolation type (Key->type == KEY_NORMAL) 
only. */
        short compressed;  /* for disk write/read; if 1, then they key's data 
is laid out as an array of
-                                           * KB_ComprMeshDataEnt structs 
(total totelem).
+                                           * CompressedMeshVertex structs 
(total totelem).
                                                * Mesh only. Does not do 
anything useful at runtime */
 
        short relative;    /* relative == 0 means first key is reference, 
otherwise the index of Key->blocks */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to