Revision: 15308
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15308
Author:   theeth
Date:     2008-06-22 19:06:50 +0200 (Sun, 22 Jun 2008)

Log Message:
-----------
Display graph in 3d view

Modified Paths:
--------------
    branches/harmonic-skeleton/source/blender/include/reeb.h
    branches/harmonic-skeleton/source/blender/src/buttons_editing.c
    branches/harmonic-skeleton/source/blender/src/drawview.c
    branches/harmonic-skeleton/source/blender/src/reeb.c
    branches/harmonic-skeleton/source/blender/src/usiblender.c

Modified: branches/harmonic-skeleton/source/blender/include/reeb.h
===================================================================
--- branches/harmonic-skeleton/source/blender/include/reeb.h    2008-06-22 
15:48:12 UTC (rev 15307)
+++ branches/harmonic-skeleton/source/blender/include/reeb.h    2008-06-22 
17:06:50 UTC (rev 15308)
@@ -119,7 +119,7 @@
 int weightFromLoc(struct EditMesh *me, int axis);
 void weightToVCol(struct EditMesh *em, int index);
 void arcToVCol(struct ReebGraph *rg, struct EditMesh *em, int index);
-void angleToVCol(EditMesh *em, int index);
+void angleToVCol(struct EditMesh *em, int index);
 void renormalizeWeight(struct EditMesh *em, float newmax);
 
 ReebGraph * generateReebGraph(struct EditMesh *me, int subdivisions);
@@ -155,7 +155,13 @@
 
 /*********************** PUBLIC *********************************/
 ReebGraph *BIF_ReebGraphFromEditMesh(void);
+
+void BIF_GlobalReebGraphFromEditMesh(void);
+void BIF_GlobalReebFree(void);
+
 void REEB_freeGraph(ReebGraph *rg);
 void REEB_exportGraph(ReebGraph *rg, int count);
+void REEB_draw();
 
+
 #endif /*REEB_H_*/

Modified: branches/harmonic-skeleton/source/blender/src/buttons_editing.c
===================================================================
--- branches/harmonic-skeleton/source/blender/src/buttons_editing.c     
2008-06-22 15:48:12 UTC (rev 15307)
+++ branches/harmonic-skeleton/source/blender/src/buttons_editing.c     
2008-06-22 17:06:50 UTC (rev 15308)
@@ -180,6 +180,8 @@
 #include "butspace.h" // own module
 #include "multires.h"
 
+#include "reeb.h"
+
 static float editbutweight= 1.0;
 float editbutvweight= 1;
 static int actmcol= 0, acttface= 0, acttface_rnd = 0, actmcol_rnd = 0;
@@ -4992,6 +4994,16 @@
        }
 }
 
+static void skgen_graphgen(void *arg1, void *arg2)
+{
+       BIF_GlobalReebGraphFromEditMesh();
+}
+
+static void skgen_graphfree(void *arg1, void *arg2)
+{
+       BIF_GlobalReebFree();
+}
+
 static void editing_panel_mesh_skgen_retarget(Object *ob, Mesh *me)
 {
        uiBlock *block;
@@ -5035,10 +5047,14 @@
        uiNewPanelTabbed("Mesh Tools More", "Editing");
        if(uiNewPanel(curarea, block, "Skeleton Generator", "Editing", 960, 0, 
318, 204)==0) return;
        
-       uiDefBut(block, BUT, B_GEN_SKELETON, "Generate Skeleton",               
        1025,170,250,19, 0, 0, 0, 0, 0, "Generate Skeleton from Mesh");
+       uiDefBut(block, BUT, B_GEN_SKELETON, "Generate Skeleton",               
        1025,170,125,19, 0, 0, 0, 0, 0, "Generate Skeleton from Mesh");
+       but = uiDefBut(block, BUT, B_DIFF, "Generate",                          
1150,170,65,19, 0, 0, 0, 0, 0, "Generate Graph from Mesh");
+       uiButSetFunc(but, skgen_graphgen, NULL, NULL);
+       but = uiDefBut(block, BUT, B_DIFF, "Free",                              
        1215,170,60,19, 0, 0, 0, 0, 0, "Free Graph from Mesh");
+       uiButSetFunc(but, skgen_graphfree, NULL, NULL);
 
        uiBlockBeginAlign(block);
-       uiDefButS(block, NUM, B_DIFF, "Resolution:",                            
                        1025,150,225,19, 
&G.scene->toolsettings->skgen_resolution,10.0,1000.0, 0, 0,            
"Specifies the resolution of the graph's embedding");
+       uiDefButS(block, NUM, B_DIFF, "Resolution:",                            
                        1025,150,225,19, 
&G.scene->toolsettings->skgen_resolution,2.0,1000.0, 0, 0,             
"Specifies the resolution of the graph's embedding");
        uiDefButBitS(block, TOG, SKGEN_HARMONIC, B_DIFF,                "H",    
                1250,150, 25,19, &G.scene->toolsettings->skgen_options, 0, 0, 
0, 0,                                     "Apply harmonic smoothing to the 
weighting");
        uiDefButBitS(block, TOG, SKGEN_FILTER_INTERNAL, B_DIFF, "Filter In",    
1025,130, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,             
                        "Filter internal small arcs from graph");
        uiDefButF(block, NUM, B_DIFF,                                           
        "T:",                   1111,130,164,19, 
&G.scene->toolsettings->skgen_threshold_internal,0.0, 1.0, 10, 0,      "Specify 
the threshold ratio for filtering internal arcs");

Modified: branches/harmonic-skeleton/source/blender/src/drawview.c
===================================================================
--- branches/harmonic-skeleton/source/blender/src/drawview.c    2008-06-22 
15:48:12 UTC (rev 15307)
+++ branches/harmonic-skeleton/source/blender/src/drawview.c    2008-06-22 
17:06:50 UTC (rev 15308)
@@ -159,6 +159,8 @@
 
 #include "RE_pipeline.h"       // make_stars
 
+#include "reeb.h"
+
 #include "multires.h"
 
 /* For MULTISAMPLE_ARB #define.
@@ -3145,6 +3147,8 @@
                        BIF_drawPropCircle(); // only editmode and particles 
have proportional edit
                BIF_drawSnap();
        }
+       
+       REEB_draw();
 
        if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID);
        

Modified: branches/harmonic-skeleton/source/blender/src/reeb.c
===================================================================
--- branches/harmonic-skeleton/source/blender/src/reeb.c        2008-06-22 
15:48:12 UTC (rev 15307)
+++ branches/harmonic-skeleton/source/blender/src/reeb.c        2008-06-22 
17:06:50 UTC (rev 15308)
@@ -51,6 +51,7 @@
 #include "BIF_interface.h"
 #include "BIF_toolbox.h"
 #include "BIF_graphics.h"
+#include "BIF_gl.h"
 
 #include "BKE_global.h"
 #include "BKE_utildefines.h"
@@ -65,6 +66,9 @@
 /* REPLACE WITH NEW ONE IN UTILDEFINES ONCE PATCH IS APPLIED */
 #define FTOCHAR(val) (val<=0.0f)? 0 : ((val>(1.0f-0.5f/255.0f))? 255 : 
(char)((255.0f*val)+0.5f))
 
+ReebGraph *GLOBAL_RG = NULL;
+ReebGraph *FILTERED_RG = NULL;
+
 /*
  * Skeleton generation algorithm based on: 
  * "Harmonic Skeleton for Realistic Character Animation"
@@ -86,10 +90,10 @@
        MERGE_APPEND
 } MergeDirection;
 
-int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1);
-int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1);
+int mergeArcs(ReebGraph *GLOBAL_RG, ReebArc *a0, ReebArc *a1);
+int mergeConnectedArcs(ReebGraph *GLOBAL_RG, ReebArc *a0, ReebArc *a1);
 EditEdge * NextEdgeForVert(EditMesh *em, EditVert *v);
-void mergeArcFaces(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc);
+void mergeArcFaces(ReebGraph *GLOBAL_RG, ReebArc *aDst, ReebArc *aSrc);
 void addFacetoArc(ReebArc *arc, EditFace *efa);
 
 void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count);
@@ -243,11 +247,11 @@
        arc->length += VecLenf(arc->tail->p, vec1);     
 }
 
-void calculateGraphLength(ReebGraph *rg)
+void calculateGraphLength(ReebGraph *GLOBAL_RG)
 {
        ReebArc *arc;
        
-       for (arc = rg->arcs.first; arc; arc = arc->next)
+       for (arc = GLOBAL_RG->arcs.first; arc; arc = arc->next)
        {
                calculateArcLength(arc);
        }
@@ -294,13 +298,13 @@
        MEM_freeN(arc);
 }
 
-void REEB_freeGraph(ReebGraph *rg)
+void REEB_freeGraph(ReebGraph *GLOBAL_RG)
 {
        ReebArc *arc;
        ReebNode *node;
        
        // free nodes
-       for( node = rg->nodes.first; node; node = node->next )
+       for( node = GLOBAL_RG->nodes.first; node; node = node->next )
        {
                // Free adjacency lists
                if (node->arcs != NULL)
@@ -308,10 +312,10 @@
                        MEM_freeN(node->arcs);
                }
        }
-       BLI_freelistN(&rg->nodes);
+       BLI_freelistN(&GLOBAL_RG->nodes);
        
        // free arcs
-       arc = rg->arcs.first;
+       arc = GLOBAL_RG->arcs.first;
        while( arc )
        {
                ReebArc *next = arc->next;
@@ -320,23 +324,23 @@
        }
        
        // free edge map
-       BLI_edgehash_free(rg->emap, NULL);
+       BLI_edgehash_free(GLOBAL_RG->emap, NULL);
        
-       MEM_freeN(rg);
+       MEM_freeN(GLOBAL_RG);
 }
 
-void repositionNodes(ReebGraph *rg)
+void repositionNodes(ReebGraph *GLOBAL_RG)
 {
        BArc *arc = NULL;
        BNode *node = NULL;
        
        // Reset node positions
-       for(node = rg->nodes.first; node; node = node->next)
+       for(node = GLOBAL_RG->nodes.first; node; node = node->next)
        {
                node->p[0] = node->p[1] = node->p[2] = 0;
        }
        
-       for(arc = rg->arcs.first; arc; arc = arc->next)
+       for(arc = GLOBAL_RG->arcs.first; arc; arc = arc->next)
        {
                if (((ReebArc*)arc)->bcount > 0)
                {
@@ -353,16 +357,16 @@
        }
 }
 
-void verifyNodeDegree(ReebGraph *rg)
+void verifyNodeDegree(ReebGraph *GLOBAL_RG)
 {
 #ifdef DEBUG_REEB
        ReebNode *node = NULL;
        ReebArc *arc = NULL;
 
-       for(node = rg->nodes.first; node; node = node->next)
+       for(node = GLOBAL_RG->nodes.first; node; node = node->next)
        {
                int count = 0;
-               for(arc = rg->arcs.first; arc; arc = arc->next)
+               for(arc = GLOBAL_RG->arcs.first; arc; arc = arc->next)
                {
                        if (arc->head == node || arc->tail == node)
                        {
@@ -377,11 +381,11 @@
 #endif
 }
 
-void verifyBuckets(ReebGraph *rg)
+void verifyBuckets(ReebGraph *GLOBAL_RG)
 {
 #ifdef DEBUG_REEB
        ReebArc *arc = NULL;
-       for(arc = rg->arcs.first; arc; arc = arc->next)
+       for(arc = GLOBAL_RG->arcs.first; arc; arc = arc->next)
        {
                ReebNode *head = (ReebNode*)arc->head;
                ReebNode *tail = (ReebNode*)arc->tail;
@@ -413,12 +417,12 @@
 #endif
 }
 
-void verifyFaces(ReebGraph *rg)
+void verifyFaces(ReebGraph *GLOBAL_RG)
 {
 #ifdef DEBUG_REEB
        int total = 0;
        ReebArc *arc = NULL;
-       for(arc = rg->arcs.first; arc; arc = arc->next)
+       for(arc = GLOBAL_RG->arcs.first; arc; arc = arc->next)
        {
                total += BLI_ghash_size(arc->faces);
        }
@@ -625,7 +629,7 @@
 
 /****************************************** SMOOTHING 
**************************************************/
 
-void postprocessGraph(ReebGraph *rg, char mode)
+void postprocessGraph(ReebGraph *GLOBAL_RG, char mode)
 {
        ReebArc *arc;
        float fac1 = 0, fac2 = 1, fac3 = 0;
@@ -648,7 +652,7 @@
                return;
        }
        
-       for(arc = rg->arcs.first; arc; arc = arc->next)
+       for(arc = GLOBAL_RG->arcs.first; arc; arc = arc->next)
        {
                EmbedBucket *buckets = arc->buckets;
                int bcount = arc->bcount;
@@ -683,9 +687,9 @@
        }
 }
 
-void sortNodes(ReebGraph *rg)
+void sortNodes(ReebGraph *GLOBAL_RG)
 {
-       BLI_sortlist(&rg->nodes, compareNodesWeight);
+       BLI_sortlist(&GLOBAL_RG->nodes, compareNodesWeight);
 }
 
 int compareArcsWeight(void *varc1, void *varc2)
@@ -709,9 +713,9 @@
        }
 }
 
-void sortArcs(ReebGraph *rg)
+void sortArcs(ReebGraph *GLOBAL_RG)
 {
-       BLI_sortlist(&rg->arcs, compareArcsWeight);
+       BLI_sortlist(&GLOBAL_RG->arcs, compareArcsWeight);
 }
 
 /****************************************** FILTERING 
**************************************************/
@@ -745,12 +749,12 @@
        }
 }
 
-void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, 
ReebArc * srcArc, int merging)
+void filterArc(ReebGraph *GLOBAL_RG, ReebNode *newNode, ReebNode *removedNode, 
ReebArc * srcArc, int merging)
 {
        ReebArc *arc = NULL, *nextArc = NULL;
 
        /* first pass, merge buckets for arcs that spawned the two nodes into 
the source arc*/
-       for(arc = rg->arcs.first; arc; arc = arc->next)
+       for(arc = GLOBAL_RG->arcs.first; arc; arc = arc->next)
        {
                if (arc->head == srcArc->head && arc->tail == srcArc->tail && 
arc != srcArc)
                {
@@ -761,7 +765,7 @@
        }
 
        /* second pass, replace removedNode by newNode, remove arcs that are 
collapsed in a loop */
-       arc = rg->arcs.first;
+       arc = GLOBAL_RG->arcs.first;
        while(arc)
        {
                nextArc = arc->next;
@@ -786,7 +790,7 @@

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to