Revision: 16116
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16116
Author:   nicholasbishop
Date:     2008-08-14 19:36:08 +0200 (Thu, 14 Aug 2008)

Log Message:
-----------
Added a Del Higher button to multires, removes levels higher than the currently 
selected one.

Modified Paths:
--------------
    branches/soc-2008-nicholasbishop/source/blender/blenkernel/BKE_multires.h
    branches/soc-2008-nicholasbishop/source/blender/blenkernel/intern/multires.c
    branches/soc-2008-nicholasbishop/source/blender/src/buttons_editing.c

Modified: 
branches/soc-2008-nicholasbishop/source/blender/blenkernel/BKE_multires.h
===================================================================
--- branches/soc-2008-nicholasbishop/source/blender/blenkernel/BKE_multires.h   
2008-08-14 17:24:39 UTC (rev 16115)
+++ branches/soc-2008-nicholasbishop/source/blender/blenkernel/BKE_multires.h   
2008-08-14 17:36:08 UTC (rev 16116)
@@ -30,7 +30,6 @@
 struct DerivedMesh;
 struct Mesh;
 struct MFace;
-struct Multires;
 struct Object;
 
 typedef struct MultiresSubsurf {
@@ -43,8 +42,6 @@
        int index;
 } IndexNode;
 
-void multires_free(struct Multires*);
-
 void create_vert_face_map(ListBase **map, IndexNode **mem, const struct MFace 
*mface,
                          const int totvert, const int totface);
 
@@ -89,14 +86,14 @@
        int x, y, ax, ay;
 } MultiresDisplacer;
 
-void multires_load_old(struct DerivedMesh *, struct Multires *);
 void multires_force_update(struct Object *ob);
 
 struct DerivedMesh *multires_dm_create_from_derived(struct 
MultiresModifierData*, struct DerivedMesh*,
                                                    struct Mesh *, int, int);
 
-int multiresModifier_switch_level(struct Object *ob, const int);
-void multiresModifier_join(struct Object *ob);
+int multiresModifier_switch_level(struct Object *, const int);
+void multiresModifier_join(struct Object *);
+void multiresModifier_del_levels(struct MultiresModifierData *, struct Object 
*, int direction);
 void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct 
Object *ob, int distance,
                                int updateblock, int simple);
 void multiresModifier_setLevel(void *mmd_v, void *ob_v);
@@ -110,3 +107,8 @@
 void multires_displacer_anchor_vert(MultiresDisplacer *d, const int);
 void multires_displacer_jump(MultiresDisplacer *d);
 void multires_displace(MultiresDisplacer *d, float out[3]);
+
+/* Related to the old multires */
+struct Multires;
+void multires_load_old(struct DerivedMesh *, struct Multires *);
+void multires_free(struct Multires*);

Modified: 
branches/soc-2008-nicholasbishop/source/blender/blenkernel/intern/multires.c
===================================================================
--- 
branches/soc-2008-nicholasbishop/source/blender/blenkernel/intern/multires.c    
    2008-08-14 17:24:39 UTC (rev 16115)
+++ 
branches/soc-2008-nicholasbishop/source/blender/blenkernel/intern/multires.c    
    2008-08-14 17:36:08 UTC (rev 16116)
@@ -758,6 +758,40 @@
        mrdm->release(mrdm);
 }
 
+/* direction=1 for delete higher, direction=0 for lower (not implemented yet) 
*/
+void multiresModifier_del_levels(struct MultiresModifierData *mmd, struct 
Object *ob, int direction)
+{
+       Mesh *me = get_mesh(ob);
+       int distance = mmd->totlvl - mmd->lvl;
+       MDisps *mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS);
+
+       multires_force_update(ob);
+
+       if(mdisps && distance > 0 && direction == 1) {
+               int skip = multires_side_tot[distance] - 1;
+               int st = multires_side_tot[mmd->totlvl - 1];
+               int totdisp = multires_quad_tot[mmd->lvl - 1];
+               int i, j, x, y;
+
+               for(i = 0; i < me->totface; ++i) {
+                       float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * 
totdisp, "multires del disps");
+                       
+                       for(j = 0, y = 0; y < st; y += skip) {
+                               for(x = 0; x < st; x += skip) {
+                                       VecCopyf(disps[j], mdisps[i].disps[y * 
st + x]);
+                                       ++j;
+                               }
+                       }
+
+                       MEM_freeN(mdisps[i].disps);
+                       mdisps[i].disps = disps;
+                       mdisps[i].totdisp = totdisp;
+               }
+       }
+
+       mmd->totlvl = mmd->lvl;
+}
+
 void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int 
distance, int updateblock, int simple)
 {
        DerivedMesh *final = NULL;
@@ -783,7 +817,7 @@
        if(!mdisps)
                mdisps = CustomData_add_layer(&me->fdata, CD_MDISPS, 
CD_DEFAULT, NULL, me->totface);
 
-       if(mdisps->disps && !updateblock) {
+       if(mdisps->disps && !updateblock && mmd->totlvl > 2) {
                DerivedMesh *orig, *mrdm;
                MultiresModifierData mmd_sub;
 
@@ -814,7 +848,7 @@
        }
 
 
-       if(final && !updateblock) {
+       if(final) {
                DerivedMesh *orig;
 
                orig = CDDM_from_mesh(me, NULL);

Modified: branches/soc-2008-nicholasbishop/source/blender/src/buttons_editing.c
===================================================================
--- branches/soc-2008-nicholasbishop/source/blender/src/buttons_editing.c       
2008-08-14 17:24:39 UTC (rev 16115)
+++ branches/soc-2008-nicholasbishop/source/blender/src/buttons_editing.c       
2008-08-14 17:36:08 UTC (rev 16116)
@@ -1684,6 +1684,16 @@
        }
 }
 
+static void multiresModifier_del_higher_button(void *mmd_v, void *ob_v)
+{
+       MultiresModifierData *mmd = mmd_v;
+
+       if(mmd && ob_v) {
+               multiresModifier_del_levels(mmd, ob_v, 1);
+               BIF_undo_push("Delete higher");
+       }              
+}
+
 static int modifier_is_fluid_particles(ModifierData *md) {
        if(md->type == eModifierType_ParticleSystem) {
                if(((ParticleSystemModifierData *)md)->psys->part->type == 
PART_FLUID)
@@ -1854,7 +1864,7 @@
                } else if (md->type==eModifierType_Explode) {
                        height = 94;
                } else if (md->type==eModifierType_Multires) {
-                       height = 72;
+                       height = 94;
                }
                                                        /* roundbox 4 free 
variables: corner-rounding, nop, roundbox type, shade */
                uiDefBut(block, ROUNDBOX, 0, "", x-10, y-height-2, width, 
height-2, NULL, 5.0, 0.0, 12, 40, ""); 
@@ -2491,6 +2501,8 @@
                        uiBlockBeginAlign(block);
                        but = uiDefBut(block,BUT,B_MODIFIER_RECALC,"Reshape", 
lx,(cy-=24),buttonWidth/2,19,0,0,0,0,0,"Copy vertices from another selected 
mesh into the current level");
                        uiButSetFunc(but, multiresModifier_reshape_button, mmd, 
ob);
+                       but = uiDefBut(block,BUT,B_MODIFIER_RECALC,"Del 
Higher", lx+buttonWidth/2,cy,buttonWidth/2,19,0,0,0,0,0,"Copy vertices from 
another selected mesh into the current level");
+                       uiButSetFunc(but, multiresModifier_del_higher_button, 
mmd, ob);
                }
 
                uiBlockEndAlign(block);


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to