[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17345] branches/etch-a-ton/source/blender : Sketch Retargetting: template selection from dropdown ( listing all other armatures) instead of silly object name input.
Martin Poirier
theeth at yahoo.com
Thu Nov 6 04:31:26 CET 2008
Revision: 17345
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17345
Author: theeth
Date: 2008-11-06 04:31:25 +0100 (Thu, 06 Nov 2008)
Log Message:
-----------
Sketch Retargetting: template selection from dropdown (listing all other armatures) instead of silly object name input.
Modified Paths:
--------------
branches/etch-a-ton/source/blender/blenloader/intern/readfile.c
branches/etch-a-ton/source/blender/include/BIF_sketch.h
branches/etch-a-ton/source/blender/src/drawview.c
branches/etch-a-ton/source/blender/src/editarmature_sketch.c
branches/etch-a-ton/source/blender/src/usiblender.c
Modified: branches/etch-a-ton/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/etch-a-ton/source/blender/blenloader/intern/readfile.c 2008-11-06 02:08:41 UTC (rev 17344)
+++ branches/etch-a-ton/source/blender/blenloader/intern/readfile.c 2008-11-06 03:31:25 UTC (rev 17345)
@@ -3459,6 +3459,9 @@
sce->toolsettings->imapaint.brush=
newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.brush);
+
+ sce->toolsettings->skgen_template = newlibadr_us(fd, sce->id.lib, sce->toolsettings->skgen_template);
+
/* Sculptdata textures */
for(a=0; a<MAX_MTEX; ++a) {
MTex *mtex= sce->sculptdata.mtex[a];
@@ -3549,8 +3552,6 @@
sce->radio= newdataadr(fd, sce->radio);
sce->toolsettings= newdataadr(fd, sce->toolsettings);
-
- sce->toolsettings->skgen_template = newdataadr(fd, sce->toolsettings->skgen_template);
sce->sculptdata.session= NULL;
/* SculptData textures */
Modified: branches/etch-a-ton/source/blender/include/BIF_sketch.h
===================================================================
--- branches/etch-a-ton/source/blender/include/BIF_sketch.h 2008-11-06 02:08:41 UTC (rev 17344)
+++ branches/etch-a-ton/source/blender/include/BIF_sketch.h 2008-11-06 03:31:25 UTC (rev 17345)
@@ -32,4 +32,10 @@
int BIF_fullSketchMode(); /* full sketch turned on (not Quick) */
void BIF_cancelStrokeSketch();
+void BIF_makeListTemplates();
+char *BIF_listTemplates();
+int BIF_currentTemplate();
+void BIF_freeTemplates();
+void BIF_setTemplate(int);
+
#endif /* BIF_SKETCH_H */
Modified: branches/etch-a-ton/source/blender/src/drawview.c
===================================================================
--- branches/etch-a-ton/source/blender/src/drawview.c 2008-11-06 02:08:41 UTC (rev 17344)
+++ branches/etch-a-ton/source/blender/src/drawview.c 2008-11-06 03:31:25 UTC (rev 17345)
@@ -2283,8 +2283,14 @@
BIF_convertSketch();
}
+static void assign_template_sketch_armature(void *arg1, void *arg2)
+{
+ int index = *(int*)arg1;
+ BIF_setTemplate(index);
+}
static void view3d_panel_bonesketch_spaces(short cntrl)
{
+ static int template_index;
uiBlock *block;
uiBut *but;
int yco = 70, height = 140;
@@ -2342,7 +2348,13 @@
yco -= 10;
uiBlockBeginAlign(block);
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_DIFF, "OB:", 10, yco, 150, 19, &G.scene->toolsettings->skgen_template, "Template Object");
+ BIF_makeListTemplates();
+ template_index = BIF_currentTemplate();
+
+ but = uiDefButI(block, MENU, B_REDR, BIF_listTemplates(), 10,yco,150,19, &template_index, 0, 0, 0, 0, "Template");
+ uiButSetFunc(but, assign_template_sketch_armature, &template_index, NULL);
+
+ //uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_DIFF, "OB:", 10, yco, 150, 19, &G.scene->toolsettings->skgen_template, "Template Object");
yco -= 20;
uiDefButF(block, NUM, B_DIFF, "Ang:", 10, yco, 50,19, &G.scene->toolsettings->skgen_retarget_angle_weight, 0, 10, 1, 0, "Angle Weight");
Modified: branches/etch-a-ton/source/blender/src/editarmature_sketch.c
===================================================================
--- branches/etch-a-ton/source/blender/src/editarmature_sketch.c 2008-11-06 02:08:41 UTC (rev 17344)
+++ branches/etch-a-ton/source/blender/src/editarmature_sketch.c 2008-11-06 03:31:25 UTC (rev 17345)
@@ -35,6 +35,7 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_graph.h"
+#include "BLI_ghash.h"
#include "BKE_utildefines.h"
#include "BKE_global.h"
@@ -135,6 +136,122 @@
int nextLengthSubdivision(SK_Stroke *stk, int start, int end, float head[3], float p[3]);
int nextCorrelationSubdivision(SK_Stroke *stk, int start, int end, float head[3], float p[3]);
+/******************** TEMPLATES UTILS *************************/
+
+char *TEMPLATES_MENU = NULL;
+int TEMPLATES_CURRENT = 0;
+GHash *TEMPLATES_HASH = NULL;
+
+void BIF_makeListTemplates()
+{
+ Base *base;
+ int index = 0;
+
+ if (TEMPLATES_HASH != NULL)
+ {
+ BLI_ghash_free(TEMPLATES_HASH, NULL, NULL);
+ }
+
+ TEMPLATES_HASH = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp);
+ TEMPLATES_CURRENT = 0;
+
+ for ( base = FIRSTBASE; base; base = base->next )
+ {
+ Object *ob = base->object;
+
+ if (ob != G.obedit && ob->type == OB_ARMATURE)
+ {
+ index++;
+ BLI_ghash_insert(TEMPLATES_HASH, SET_INT_IN_POINTER(index), ob);
+
+ if (ob == G.scene->toolsettings->skgen_template)
+ {
+ TEMPLATES_CURRENT = index;
+ }
+ }
+ }
+}
+
+char *BIF_listTemplates()
+{
+ GHashIterator ghi;
+ char menu_header[] = "Template%t|None%x0|";
+ char *p;
+
+ TEMPLATES_MENU = MEM_callocN(sizeof(char) * (BLI_ghash_size(TEMPLATES_HASH) * 32 + 30), "skeleton template menu");
+
+ p = TEMPLATES_MENU;
+
+ p += sprintf(TEMPLATES_MENU, "%s", menu_header);
+
+ BLI_ghashIterator_init(&ghi, TEMPLATES_HASH);
+
+ while (!BLI_ghashIterator_isDone(&ghi))
+ {
+ Object *ob = BLI_ghashIterator_getValue(&ghi);
+ int key = (int)BLI_ghashIterator_getKey(&ghi);
+
+ p += sprintf(p, "|%s%%x%i", ob->id.name+2, key);
+
+ BLI_ghashIterator_step(&ghi);
+ }
+
+ return TEMPLATES_MENU;
+}
+
+int BIF_currentTemplate()
+{
+ if (TEMPLATES_CURRENT == 0 && G.scene->toolsettings->skgen_template != NULL)
+ {
+ GHashIterator ghi;
+ int index = 0;
+ BLI_ghashIterator_init(&ghi, TEMPLATES_HASH);
+
+ while (!BLI_ghashIterator_isDone(&ghi))
+ {
+ Object *ob = BLI_ghashIterator_getValue(&ghi);
+ int key = (int)BLI_ghashIterator_getKey(&ghi);
+
+ index++;
+
+ if (ob == G.scene->toolsettings->skgen_template)
+ {
+ TEMPLATES_CURRENT = index;
+ break;
+ }
+
+ BLI_ghashIterator_step(&ghi);
+ }
+ }
+
+ return TEMPLATES_CURRENT;
+}
+
+void BIF_freeTemplates()
+{
+ if (TEMPLATES_MENU != NULL)
+ {
+ MEM_freeN(TEMPLATES_MENU);
+ }
+
+ if (TEMPLATES_HASH != NULL)
+ {
+ BLI_ghash_free(TEMPLATES_HASH, NULL, NULL);
+ }
+}
+
+void BIF_setTemplate(int index)
+{
+ if (index > 0)
+ {
+ G.scene->toolsettings->skgen_template = BLI_ghash_lookup(TEMPLATES_HASH, SET_INT_IN_POINTER(index));
+ }
+ else
+ {
+ G.scene->toolsettings->skgen_template = NULL;
+ }
+}
+
/******************** PEELING *********************************/
typedef struct SK_DepthPeel
Modified: branches/etch-a-ton/source/blender/src/usiblender.c
===================================================================
--- branches/etch-a-ton/source/blender/src/usiblender.c 2008-11-06 02:08:41 UTC (rev 17344)
+++ branches/etch-a-ton/source/blender/src/usiblender.c 2008-11-06 03:31:25 UTC (rev 17345)
@@ -1103,6 +1103,7 @@
BIF_GlobalReebFree();
BIF_freeRetarget();
+ BIF_freeTemplates();
tf= G.ttfdata.first;
while(tf)
More information about the Bf-blender-cvs
mailing list