Page MenuHome

drawview_2.patch

File Metadata

Author
Martin Poirier (theeth)
Created
Nov 13 2013, 12:58 PM

drawview_2.patch

Index: source/blender/src/drawview.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/drawview.c,v
retrieving revision 1.123
diff -u -r1.123 drawview.c
--- source/blender/src/drawview.c 3 Apr 2005 16:57:16 -0000 1.123
+++ source/blender/src/drawview.c 10 Apr 2005 16:30:35 -0000
@@ -1073,6 +1073,14 @@
/* this one assumes there is only one editmode in blender... (for object panel) */
static float ve_median[4];
+/* (jcmuro) patching starts here */
+#define R_REFLOCAL 1
+#define R_REFGLOBAL 2
+#define R_REFCURSOR 3
+
+static short r_ref = 1; /* reference to (which radio button is selected) */
+static short r_refp = 1; /* previous reference (for monitoring of r_ref ) */
+
/* is used for both read and write... */
static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim)
{
@@ -1081,6 +1089,7 @@
EditEdge *eed;
float median[4];
int tot, totw, totedge;
+ float *curs;
median[0]= median[1]= median[2]= median[3]= 0.0;
tot= totw= totedge= 0;
@@ -1176,37 +1185,72 @@
if(totedge) median[3] /= (float)totedge;
else median[3] /= (float)tot;
+ switch(r_ref) {
+ /* R_REFLOCAL doesn't need any change */
+ case R_REFGLOBAL:
+ Mat4MulVecfl(ob->obmat, median);
+ break;
+ case R_REFCURSOR:
+ curs= give_cursor();
+ Mat4MulVecfl(ob->obmat, median);
+ VecSubf(median, median, curs);
+ break;
+ }
+
if(block) { // buttons
QUATCOPY(ve_median, median);
uiBlockBeginAlign(block);
- if(tot==1) {
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex X:", 10, 140, 300, 19, &(ve_median[0]), -lim, lim, 10, 3, "");
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex Y:", 10, 120, 300, 19, &(ve_median[1]), -lim, lim, 10, 3, "");
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex Z:", 10, 100, 300, 19, &(ve_median[2]), -lim, lim, 10, 3, "");
- if(totw==1)
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex W:", 10, 80, 300, 19, &(ve_median[3]), 0.01, 100.0, 10, 3, "");
- }
- else {
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median X:", 10, 140, 300, 19, &(ve_median[0]), -lim, lim, 10, 3, "");
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median Y:", 10, 120, 300, 19, &(ve_median[1]), -lim, lim, 10, 3, "");
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median Z:", 10, 100, 300, 19, &(ve_median[2]), -lim, lim, 10, 3, "");
- if(totw==tot)
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median W:", 10, 80, 300, 19, &(ve_median[3]), 0.01, 100.0, 10, 3, "");
- }
- uiBlockEndAlign(block);
-
- if(totedge==1)
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Crease W:", 10, 60, 300, 19, &(ve_median[3]), 0.0, 1.0, 10, 3, "");
- else if(totedge>1)
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median Crease W:", 10, 60, 300, 19, &(ve_median[3]), 0.0, 1.0, 10, 3, "");
+ uiDefBut (block, LABEL, 0, "Reference:", 10, 150, 100, 20, 0, 0, 0, 0, 0, "");
+ uiDefButS(block, ROW, B_OBJECTPANELMEDIAN, "Local ", 110, 150, 60, 19, &r_ref, 0, R_REFLOCAL, 10, 3, "Relative to object's origin");
+ uiDefButS(block, ROW, B_OBJECTPANELMEDIAN, "Global", 180, 150, 60, 19, &r_ref, 0, R_REFGLOBAL, 10, 3, "Relative to screen origin");
+ uiDefButS(block, ROW, B_OBJECTPANELMEDIAN, "Cursor", 250, 150, 60, 19, &r_ref, 0, R_REFCURSOR, 10, 3, "Relative to 3D-Cursor");
+ uiBlockEndAlign(block);
+
+ uiBlockBeginAlign(block);
+ if(tot==1) {
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex X:", 10, 120, 300, 19, &(ve_median[0]), -lim, lim, 10, 3, "");
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex Y:", 10, 100, 300, 19, &(ve_median[1]), -lim, lim, 10, 3, "");
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex Z:", 10, 80, 300, 19, &(ve_median[2]), -lim, lim, 10, 3, "");
+
+ if(totw==1)
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex W:", 10, 60, 300, 19, &(ve_median[3]), 0.01, 100.0, 10, 3, "");
+ }
+ else {
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median X:", 10, 120, 300, 19, &(ve_median[0]), -lim, lim, 10, 3, "");
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median Y:", 10, 100, 300, 19, &(ve_median[1]), -lim, lim, 10, 3, "");
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median Z:", 10, 80, 300, 19, &(ve_median[2]), -lim, lim, 10, 3, "");
+ if(totw==tot)
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median W:", 10, 60, 300, 19, &(ve_median[3]), 0.01, 100.0, 10, 3, "");
+ }
+ uiBlockEndAlign(block);
+
+ if(totedge==1)
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Crease W:", 10, 40, 300, 19, &(ve_median[3]), 0.0, 1.0, 10, 3, "");
+ else if(totedge>1)
+ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median Crease W:", 10, 40, 300, 19, &(ve_median[3]), 0.0, 1.0, 10, 3, "");
}
else { // apply
- VecSubf(median, ve_median, median);
- median[3]= ve_median[3]-median[3];
+ if (r_ref == r_refp) {
+ VecSubf(median, ve_median, median);
+ median[3]= ve_median[3]-median[3];
+ /* R_REFLOCAL doesn't need any change */
+ if (r_ref == R_REFGLOBAL || r_ref == R_REFCURSOR) {
+ /* really, we only need a 3x3 matrix here, but it's faster to just
+ invert the 4x4 and substract the translation vector afterward.
+ */
+ Mat4Invert(ob->imat, ob->obmat);
+ Mat4MulVecfl(ob->imat, median);
+ VecSubf(median, median, ob->imat[3]);
+ }
+ }
+ else {
+ median[0]= median[1]= median[2]= median[3]= 0.0;
+ r_refp = r_ref;
+ }
if(ob->type==OB_MESH) {
float diffac= 1.0;
@@ -1308,6 +1352,7 @@
BIF_undo_push("Transform properties");
}
}
+/* (jcmuro) patching ends here */
static void v3d_posearmature_buts(uiBlock *block, Object *ob, float lim)
{

Event Timeline