[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21448] branches/blender2.5/blender/source /blender: Cosmetic changes in etch-a-ton drawing code, mostly.

Martin Poirier theeth at yahoo.com
Thu Jul 9 03:48:10 CEST 2009


Revision: 21448
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21448
Author:   theeth
Date:     2009-07-09 03:48:08 +0200 (Thu, 09 Jul 2009)

Log Message:
-----------
Cosmetic changes in etch-a-ton drawing code, mostly.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenlib/BLI_graph.h
    branches/blender2.5/blender/source/blender/editors/armature/editarmature_generate.c
    branches/blender2.5/blender/source/blender/editors/armature/editarmature_sketch.c
    branches/blender2.5/blender/source/blender/editors/armature/reeb.c
    branches/blender2.5/blender/source/blender/editors/armature/reeb.h

Modified: branches/blender2.5/blender/source/blender/blenlib/BLI_graph.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/BLI_graph.h	2009-07-09 01:32:13 UTC (rev 21447)
+++ branches/blender2.5/blender/source/blender/blenlib/BLI_graph.h	2009-07-09 01:48:08 UTC (rev 21448)
@@ -88,6 +88,7 @@
 	StoppedFct	stopped;
 	
 	float *p, *no;
+	float size;
 	
 	int length;
 	int index;

Modified: branches/blender2.5/blender/source/blender/editors/armature/editarmature_generate.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/editarmature_generate.c	2009-07-09 01:32:13 UTC (rev 21447)
+++ branches/blender2.5/blender/source/blender/editors/armature/editarmature_generate.c	2009-07-09 01:48:08 UTC (rev 21448)
@@ -285,6 +285,8 @@
 	EditBone *lastBone = NULL;
 	EditBone *child = NULL;
 	EditBone *parent = NULL;
+	float *normal = NULL;
+	float size_buffer = 1.2;
 	int bone_start = 0;
 	int end = iter->length;
 	int index;
@@ -294,6 +296,13 @@
 	parent = addEditBone(arm, "Bone");
 	VECCOPY(parent->head, iter->p);
 	
+	if (iter->size > 0)
+	{
+		parent->rad_head = iter->size * size_buffer;
+	}
+	
+	normal = iter->no;
+	
 	index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail);
 	while (index != -1)
 	{
@@ -304,21 +313,33 @@
 		child->parent = parent;
 		child->flag |= BONE_CONNECTED;
 		
+		if (iter->size > 0)
+		{
+			child->rad_head = iter->size * size_buffer;
+			parent->rad_tail = iter->size * size_buffer;
+		}
+
 		/* going to next bone, fix parent */
 		Mat4MulVecfl(invmat, parent->tail);
 		Mat4MulVecfl(invmat, parent->head);
-		setBoneRollFromNormal(parent, iter->no, invmat, tmat);
+		setBoneRollFromNormal(parent, normal, invmat, tmat);
 
 		parent = child; // new child is next parent
 		bone_start = index; // start next bone from current index
 
+		normal = iter->no; /* use normal at head, not tail */
+
 		index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail);
 	}
 	
 	iter->tail(iter);
 
 	VECCOPY(parent->tail, iter->p);
-
+	if (iter->size > 0)
+	{
+		parent->rad_tail = iter->size * size_buffer;
+	}
+		
 	/* fix last bone */
 	Mat4MulVecfl(invmat, parent->tail);
 	Mat4MulVecfl(invmat, parent->head);

Modified: branches/blender2.5/blender/source/blender/editors/armature/editarmature_sketch.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/editarmature_sketch.c	2009-07-09 01:32:13 UTC (rev 21447)
+++ branches/blender2.5/blender/source/blender/editors/armature/editarmature_sketch.c	2009-07-09 01:48:08 UTC (rev 21448)
@@ -90,6 +90,7 @@
 {
 	float p[3];
 	float no[3];
+	float size;
 	SK_PType type;
 	SK_PMode mode;
 } SK_Point;
@@ -136,6 +137,7 @@
 typedef struct SK_Sketch
 {
 	ListBase	strokes;
+	ListBase	depth_peels;
 	SK_Stroke	*active_stroke;
 	SK_Stroke	*gesture;
 	SK_Point	next_point;
@@ -150,9 +152,10 @@
 	NextNFct	nextN;
 	PreviousFct	previous;
 	StoppedFct	stopped;
-	
+
 	float *p, *no;
-	
+	float size;
+
 	int length;
 	int index;
 	/*********************************/
@@ -251,19 +254,19 @@
 	{
 		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 != obedit && ob->type == OB_ARMATURE)
 		{
 			index++;
 			BLI_ghash_insert(TEMPLATES_HASH, SET_INT_IN_POINTER(index), ob);
-			
+
 			if (ob == ts->skgen_template)
 			{
 				TEMPLATES_CURRENT = index;
@@ -277,30 +280,30 @@
 	GHashIterator ghi;
 	char menu_header[] = "Template%t|None%x0|";
 	char *p;
-	
+
 	if (TEMPLATES_MENU != NULL)
 	{
 		MEM_freeN(TEMPLATES_MENU);
 	}
-	
+
 	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 = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(&ghi));
-		
+
 		p += sprintf(p, "|%s%%x%i", ob->id.name+2, key);
-		
+
 		BLI_ghashIterator_step(&ghi);
 	}
-	
+
 	return TEMPLATES_MENU;
 }
 
@@ -312,22 +315,22 @@
 	{
 		GHashIterator ghi;
 		BLI_ghashIterator_init(&ghi, TEMPLATES_HASH);
-		
+
 		while (!BLI_ghashIterator_isDone(&ghi))
 		{
 			Object *ob = BLI_ghashIterator_getValue(&ghi);
 			int key = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(&ghi));
-			
+
 			if (ob == ts->skgen_template)
 			{
 				TEMPLATES_CURRENT = key;
 				break;
 			}
-			
+
 			BLI_ghashIterator_step(&ghi);
 		}
 	}
-	
+
 	return TEMPLATES_CURRENT;
 }
 
@@ -338,7 +341,7 @@
 	{
 		return NULL;
 	}
-	
+
 	if (ob != NULL)
 	{
 		if (TEMPLATE_RIGG && TEMPLATE_RIGG->ob != ob)
@@ -346,17 +349,17 @@
 			RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG);
 			TEMPLATE_RIGG = NULL;
 		}
-		
+
 		if (TEMPLATE_RIGG == NULL)
 		{
 			bArmature *arm;
 
 			arm = ob->data;
-			
+
 			TEMPLATE_RIGG = RIG_graphFromArmature(C, ob, arm);
 		}
 	}
-	
+
 	return TEMPLATE_RIGG;
 }
 
@@ -364,14 +367,14 @@
 {
 	ToolSettings *ts = CTX_data_tool_settings(C);
 	RigGraph *rg = sk_makeTemplateGraph(C, ts->skgen_template);
-	
+
 	if (rg)
 	{
 		return RIG_nbJoints(rg);
 	}
 	else
 	{
-		return -1; 
+		return -1;
 	}
 }
 
@@ -386,9 +389,9 @@
 	{
 		index = stk->active_stroke->nb_points;
 	}
-	
+
 	rg = sk_makeTemplateGraph(C, ts->skgen_template);
-	
+
 	if (rg == NULL)
 	{
 		return "";
@@ -404,13 +407,13 @@
 		MEM_freeN(TEMPLATES_MENU);
 		TEMPLATES_MENU = NULL;
 	}
-	
+
 	if (TEMPLATES_HASH != NULL)
 	{
 		BLI_ghash_free(TEMPLATES_HASH, NULL, NULL);
 		TEMPLATES_HASH = NULL;
 	}
-	
+
 	if (TEMPLATE_RIGG != NULL)
 	{
 		RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG);
@@ -428,14 +431,14 @@
 	else
 	{
 		ts->skgen_template = NULL;
-		
+
 		if (TEMPLATE_RIGG != NULL)
 		{
 			RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG);
 		}
 		TEMPLATE_RIGG = NULL;
 	}
-}	
+}
 
 /*********************** CONVERSION ***************************/
 
@@ -456,7 +459,7 @@
 			char *side = ts->skgen_side_string;
 			int valid = 0;
 			int caps = 0;
-			
+
 			if (BLI_streq(side, ""))
 			{
 				valid = 1;
@@ -471,7 +474,7 @@
 				valid = 1;
 				caps = 0;
 			}
-			
+
 			if (valid)
 			{
 				if (arc->head->p[0] < 0)
@@ -490,14 +493,14 @@
 ReebNode *sk_pointToNode(SK_Point *pt, float imat[][4], float tmat[][3])
 {
 	ReebNode *node;
-	
+
 	node = MEM_callocN(sizeof(ReebNode), "reeb node");
 	VECCOPY(node->p, pt->p);
 	Mat4MulVecfl(imat, node->p);
-	
+
 	VECCOPY(node->no, pt->no);
 	Mat3MulVecfl(tmat, node->no);
-	
+
 	return node;
 }
 
@@ -505,14 +508,14 @@
 {
 	ReebArc *arc;
 	int i;
-	
+
 	arc = MEM_callocN(sizeof(ReebArc), "reeb arc");
 	arc->head = sk_pointToNode(stk->points, imat, tmat);
 	arc->tail = sk_pointToNode(sk_lastStrokePoint(stk), imat, tmat);
-	
+
 	arc->bcount = stk->nb_points - 2; /* first and last are nodes, don't count */
 	arc->buckets = MEM_callocN(sizeof(EmbedBucket) * arc->bcount, "Buckets");
-	
+
 	for (i = 0; i < arc->bcount; i++)
 	{
 		VECCOPY(arc->buckets[i].p, stk->points[i + 1].p);
@@ -521,7 +524,7 @@
 		VECCOPY(arc->buckets[i].no, stk->points[i + 1].no);
 		Mat3MulVecfl(tmat, arc->buckets[i].no);
 	}
-	
+
 	return arc;
 }
 
@@ -533,22 +536,22 @@
 	float tmat[3][3];
 	ReebArc *arc;
 	RigGraph *rg;
-	
+
 	Mat4Invert(imat, obedit->obmat);
-	
+
 	Mat3CpyMat4(tmat, obedit->obmat);
 	Mat3Transp(tmat);
 
 	arc = sk_strokeToArc(stk, imat, tmat);
-	
+
 	sk_autoname(C, arc);
-	
+
 	rg = sk_makeTemplateGraph(C, ts->skgen_template);
 
 	BIF_retargetArc(C, arc, rg);
-	
+
 	sk_autoname(C, NULL);
-	
+
 	MEM_freeN(arc->head);
 	MEM_freeN(arc->tail);
 	REEB_freeArc((BArc*)arc);
@@ -559,29 +562,31 @@
 void sk_freeSketch(SK_Sketch *sketch)
 {
 	SK_Stroke *stk, *next;
-	
+
 	for (stk = sketch->strokes.first; stk; stk = next)
 	{
 		next = stk->next;
-		
+
 		sk_freeStroke(stk);
 	}
-	
+
+	BLI_freelistN(&sketch->depth_peels);
+
 	MEM_freeN(sketch);
 }
 
 SK_Sketch* sk_createSketch()
 {
 	SK_Sketch *sketch;
-	
+
 	sketch = MEM_callocN(sizeof(SK_Sketch), "SK_Sketch");
-	
+
 	sketch->active_stroke = NULL;
 	sketch->gesture = NULL;
 
 	sketch->strokes.first = NULL;
 	sketch->strokes.last = NULL;
-	
+
 	return sketch;
 }
 
@@ -614,15 +619,15 @@
 SK_Stroke* sk_createStroke()
 {
 	SK_Stroke *stk;
-	
+
 	stk = MEM_callocN(sizeof(SK_Stroke), "SK_Stroke");
-	
+
 	stk->selected = 0;
 	stk->nb_points = 0;
 	stk->buf_size = SK_Stroke_BUFFER_INIT_SIZE;
-	
+
 	sk_allocStrokeBuffer(stk);
-	
+
 	return stk;
 }
 
@@ -631,13 +636,13 @@
 	if (stk->nb_points < stk->buf_size)
 	{
 		SK_Point *old_points = stk->points;
-		
+
 		stk->buf_size = stk->nb_points;
 
-		sk_allocStrokeBuffer(stk);		
-		
+		sk_allocStrokeBuffer(stk);
+
 		memcpy(stk->points, old_points, sizeof(SK_Point) * stk->nb_points);
-		
+
 		MEM_freeN(old_points);
 	}
 }
@@ -647,13 +652,13 @@
 	if (stk->nb_points == stk->buf_size)
 	{
 		SK_Point *old_points = stk->points;
-		
+
 		stk->buf_size *= 2;
-		
+
 		sk_allocStrokeBuffer(stk);
-		
+
 		memcpy(stk->points, old_points, sizeof(SK_Point) * stk->nb_points);
-		
+
 		MEM_freeN(old_points);
 	}
 }
@@ -663,16 +668,16 @@
 	if (stk->nb_points + n > stk->buf_size)
 	{
 		SK_Point *old_points = stk->points;
-		
+
 		while (stk->nb_points + n > stk->buf_size)
 		{
 			stk->buf_size *= 2;
 		}
-		
+
 		sk_allocStrokeBuffer(stk);
-		
+
 		memcpy(stk->points, old_points, sizeof(SK_Point) * stk->nb_points);
-		
+
 		MEM_freeN(old_points);
 	}
 }
@@ -686,52 +691,52 @@
 void sk_insertStrokePoint(SK_Stroke *stk, SK_Point *pt, int n)
 {
 	int size = stk->nb_points - n;
-	
+
 	sk_growStrokeBuffer(stk);
-	
+
 	memmove(stk->points + n + 1, stk->points + n, size * sizeof(SK_Point));
-	
+
 	memcpy(stk->points + n, pt, sizeof(SK_Point));
-	
+
 	stk->nb_points++;
 }
 
 void sk_appendStrokePoint(SK_Stroke *stk, SK_Point *pt)
 {
 	sk_growStrokeBuffer(stk);
-	
+
 	memcpy(stk->points + stk->nb_points, pt, sizeof(SK_Point));
-	
+
 	stk->nb_points++;
 }
 
 void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, int end)
 {
 	int size = end - start + 1;
-	
+
 	sk_growStrokeBufferN(stk, len - size);
-	
+
 	if (len != size)
 	{
 		int tail_size = stk->nb_points - end + 1;
-		
+
 		memmove(stk->points + start + len, stk->points + end + 1, tail_size * sizeof(SK_Point));
 	}
-	
+
 	memcpy(stk->points + start, pts, len * sizeof(SK_Point));
-	
+
 	stk->nb_points += len - size;
 }
 
 void sk_trimStroke(SK_Stroke *stk, int start, int end)
 {
 	int size = end - start + 1;
-	
+
 	if (start > 0)
 	{

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list