[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36922] branches/soc-2011-pepper/source/ blender: New experimental drawtype for armatures: "Wire"
Joshua Leung
aligorith at gmail.com
Thu May 26 14:34:53 CEST 2011
Revision: 36922
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36922
Author: aligorith
Date: 2011-05-26 12:34:53 +0000 (Thu, 26 May 2011)
Log Message:
-----------
New experimental drawtype for armatures: "Wire"
This is equivalent to using B-Bones which are all scaled to have
xwidth=zwidth=0, which can be useful to see how some limbs will bend,
without the overhead of blocks blocking the view or having to scale
down bone sizes first.
Modified Paths:
--------------
branches/soc-2011-pepper/source/blender/editors/space_view3d/drawarmature.c
branches/soc-2011-pepper/source/blender/makesdna/DNA_armature_types.h
branches/soc-2011-pepper/source/blender/makesrna/intern/rna_armature.c
Modified: branches/soc-2011-pepper/source/blender/editors/space_view3d/drawarmature.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/space_view3d/drawarmature.c 2011-05-26 12:23:56 UTC (rev 36921)
+++ branches/soc-2011-pepper/source/blender/editors/space_view3d/drawarmature.c 2011-05-26 12:34:53 UTC (rev 36922)
@@ -1217,6 +1217,87 @@
}
}
+static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float length, int segments)
+{
+ if ((segments > 1) && (pchan)) {
+ float dlen= length/(float)segments;
+ Mat4 *bbone = bbones;
+ int a;
+
+ for (a=0; a<segments; a++, bbone++) {
+ glPushMatrix();
+ glMultMatrixf(bbone->mat);
+
+ glBegin(GL_LINES);
+ glVertex3f(0.0f, 0.0f, 0.0f);
+ glVertex3f(0.0f, dlen, 0.0f);
+ glEnd(); // GL_LINES
+
+ glPopMatrix();
+ }
+ }
+ else {
+ glPushMatrix();
+
+ glBegin(GL_LINES);
+ glVertex3f(0.0f, 0.0f, 0.0f);
+ glVertex3f(0.0f, length, 0.0f);
+ glEnd();
+
+ glPopMatrix();
+ }
+}
+
+static void draw_wire_bone(int dt, int armflag, int boneflag, int constflag, unsigned int id, bPoseChannel *pchan, EditBone *ebone)
+{
+ Mat4 *bbones = NULL;
+ int segments = 0;
+ float length;
+
+ if (pchan) {
+ segments= pchan->bone->segments;
+ length= pchan->bone->length;
+
+ if (segments > 1)
+ bbones = b_bone_spline_setup(pchan, 0);
+ }
+ else
+ length= ebone->length;
+
+ /* draw points only if... */
+ if (armflag & ARM_EDITMODE) {
+ /* move to unitspace */
+ glPushMatrix();
+ glScalef(length, length, length);
+ draw_bone_points(dt, armflag, boneflag, id);
+ glPopMatrix();
+ length *= 0.95f; // make vertices visible
+ }
+
+ /* this chunk not in object mode */
+ if (armflag & (ARM_EDITMODE|ARM_POSEMODE)) {
+ if (id != -1)
+ glLoadName((GLuint) id|BONESEL_BONE);
+
+ draw_wire_bone_segments(pchan, bbones, length, segments);
+
+ /* further we send no names */
+ if (id != -1)
+ glLoadName(id & 0xFFFF); /* object tag, for bordersel optim */
+ }
+
+ /* colors for modes */
+ if (armflag & ARM_POSEMODE) {
+ set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
+ }
+ else if (armflag & ARM_EDITMODE) {
+ set_ebone_glColor(boneflag);
+ }
+
+ /* draw normal */
+ draw_wire_bone_segments(pchan, bbones, length, segments);
+}
+
static void draw_bone(int dt, int armflag, int boneflag, int constflag, unsigned int id, float length)
{
@@ -1656,7 +1737,7 @@
int use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM);
glPushMatrix();
- if(use_custom && pchan->custom_tx) {
+ if (use_custom && pchan->custom_tx) {
glMultMatrixf(pchan->custom_tx->pose_mat);
}
else {
@@ -1684,6 +1765,8 @@
}
else if (arm->drawtype==ARM_LINE)
; /* nothing in solid */
+ else if (arm->drawtype==ARM_WIRE)
+ ; /* nothing in solid */
else if (arm->drawtype==ARM_ENVELOPE)
draw_sphere_bone(OB_SOLID, arm->flag, flag, 0, index, pchan, NULL);
else if (arm->drawtype==ARM_B_BONE)
@@ -1702,7 +1785,7 @@
/* very very confusing... but in object mode, solid draw, we cannot do glLoadName yet,
* stick bones and/or wire custom-shapes are drawn in next loop
*/
- if ((arm->drawtype != ARM_LINE) && (draw_wire == 0)) {
+ if (ELEM(arm->drawtype,ARM_LINE,ARM_WIRE)==0 && (draw_wire == 0)) {
/* object tag, for bordersel optim */
glLoadName(index & 0xFFFF);
index= -1;
@@ -1773,8 +1856,8 @@
if (index != -1)
index+= 0x10000; // pose bones count in higher 2 bytes only
}
- /* stick bones have not been drawn yet so dont clear object selection in this case */
- if ((arm->drawtype != ARM_LINE) && draw_wire) {
+ /* stick or wire bones have not been drawn yet so dont clear object selection in this case */
+ if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)==0 && draw_wire) {
/* object tag, for bordersel optim */
glLoadName(index & 0xFFFF);
index= -1;
@@ -1784,7 +1867,7 @@
/* wire draw over solid only in posemode */
if ((dt <= OB_WIRE) || (arm->flag & ARM_POSEMODE) || (arm->drawtype==ARM_LINE)) {
/* draw line check first. we do selection indices */
- if (arm->drawtype==ARM_LINE) {
+ if ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) {
if (arm->flag & ARM_POSEMODE)
index= base->selcol;
}
@@ -1879,6 +1962,8 @@
}
else if (arm->drawtype==ARM_LINE)
draw_line_bone(arm->flag, flag, constflag, index, pchan, NULL);
+ else if (arm->drawtype==ARM_WIRE)
+ draw_wire_bone(dt, arm->flag, flag, constflag, index, pchan, NULL);
else if (arm->drawtype==ARM_B_BONE)
draw_b_bone(OB_WIRE, arm->flag, flag, constflag, index, pchan, NULL);
else
@@ -2013,7 +2098,7 @@
}
/* if solid we draw it first */
- if ((dt > OB_WIRE) && (arm->drawtype!=ARM_LINE)) {
+ if ((dt > OB_WIRE) && (arm->drawtype != ARM_LINE)) {
for (eBone=arm->edbo->first, index=0; eBone; eBone=eBone->next, index++) {
if (eBone->layer & arm->layer) {
if ((eBone->flag & BONE_HIDDEN_A)==0) {
@@ -2034,6 +2119,8 @@
draw_sphere_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone);
else if(arm->drawtype==ARM_B_BONE)
draw_b_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone);
+ else if (arm->drawtype==ARM_WIRE)
+ draw_wire_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone);
else {
draw_bone(OB_SOLID, arm->flag, flag, 0, index, eBone->length);
}
@@ -2047,7 +2134,7 @@
/* if wire over solid, set offset */
index= -1;
glLoadName(-1);
- if (arm->drawtype==ARM_LINE) {
+ if ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) {
if(G.f & G_PICKSEL)
index= 0;
}
@@ -2081,6 +2168,8 @@
if (arm->drawtype == ARM_LINE)
draw_line_bone(arm->flag, flag, 0, index, NULL, eBone);
+ else if (arm->drawtype==ARM_WIRE)
+ draw_wire_bone(OB_WIRE, arm->flag, flag, 0, index, NULL, eBone);
else if (arm->drawtype == ARM_B_BONE)
draw_b_bone(OB_WIRE, arm->flag, flag, 0, index, NULL, eBone);
else
@@ -2109,7 +2198,7 @@
/* restore */
if(index!=-1) glLoadName(-1);
- if (arm->drawtype==ARM_LINE);
+ if ELEM(arm->drawtype,ARM_LINE,ARM_WIRE);
else if (dt>OB_WIRE) bglPolygonOffset(rv3d->dist, 0.0f);
/* finally names and axes */
Modified: branches/soc-2011-pepper/source/blender/makesdna/DNA_armature_types.h
===================================================================
--- branches/soc-2011-pepper/source/blender/makesdna/DNA_armature_types.h 2011-05-26 12:23:56 UTC (rev 36921)
+++ branches/soc-2011-pepper/source/blender/makesdna/DNA_armature_types.h 2011-05-26 12:34:53 UTC (rev 36922)
@@ -136,7 +136,8 @@
ARM_OCTA = 0,
ARM_LINE,
ARM_B_BONE,
- ARM_ENVELOPE
+ ARM_ENVELOPE,
+ ARM_WIRE
} eArmature_Drawtype;
/* armature->deformflag */
Modified: branches/soc-2011-pepper/source/blender/makesrna/intern/rna_armature.c
===================================================================
--- branches/soc-2011-pepper/source/blender/makesrna/intern/rna_armature.c 2011-05-26 12:23:56 UTC (rev 36921)
+++ branches/soc-2011-pepper/source/blender/makesrna/intern/rna_armature.c 2011-05-26 12:34:53 UTC (rev 36922)
@@ -814,6 +814,7 @@
{ARM_LINE, "STICK", 0, "Stick", "Display bones as simple 2D lines with dots"},
{ARM_B_BONE, "BBONE", 0, "B-Bone", "Display bones as boxes, showing subdivision and B-Splines"},
{ARM_ENVELOPE, "ENVELOPE", 0, "Envelope", "Display bones as extruded spheres, showing deformation influence volume"},
+ {ARM_WIRE, "WIRE", 0, "Wire", "Display bones as thin wires, showing subdivision and B-Splines"},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem prop_ghost_type_items[] = {
{ARM_GHOST_CUR, "CURRENT_FRAME", 0, "Around Frame", "Display Ghosts of poses within a fixed number of frames around the current frame"},
More information about the Bf-blender-cvs
mailing list