Page Menu
Home
Search
Configure Global Search
Log In
Files
F6710
cto_align.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Martin Poirier (theeth)
Nov 13 2013, 1:40 PM
Size
6 KB
Subscribers
None
cto_align.patch
View Options
Index: source/blender/include/BIF_editview.h
===================================================================
--- source/blender/include/BIF_editview.h (revision 15055)
+++ source/blender/include/BIF_editview.h (working copy)
@@ -54,6 +54,7 @@
void set_render_border(void);
void view3d_border_zoom(void);
void view3d_edit_clipping(struct View3D *v3d);
+void align_view_to_transform_orientation(struct View3D *v3d);
#endif
Index: source/blender/include/BSE_view.h
===================================================================
--- source/blender/include/BSE_view.h (revision 15055)
+++ source/blender/include/BSE_view.h (working copy)
@@ -80,6 +80,7 @@
int get_view3d_viewplane(int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend, float *pixsize);
void setwinmatrixview3d(int winx, int winy, struct rctf *rect);
+void mat_to_viewmat(float mat[][4], short smooth);
void obmat_to_viewmat(struct Object *ob, short smooth);
void setviewmatrixview3d(void);
float *give_cursor(void);
Index: source/blender/include/BIF_transform.h
===================================================================
--- source/blender/include/BIF_transform.h (revision 15055)
+++ source/blender/include/BIF_transform.h (working copy)
@@ -106,6 +106,7 @@
char * BIF_menustringTransformOrientation(char *title); /* the returned value was allocated and needs to be freed after use */
int BIF_countTransformOrientation();
+void BIF_getTransformOrientationMatrix(int mode, float mat[][3]);
/* Drawing callbacks */
void BIF_drawConstraint(void);
Index: source/blender/src/editview.c
===================================================================
--- source/blender/src/editview.c (revision 15055)
+++ source/blender/src/editview.c (working copy)
@@ -94,7 +94,9 @@
#include "BIF_space.h"
#include "BIF_screen.h"
#include "BIF_toolbox.h"
+#include "BIF_transform.h" /* to access CTO */
+
#include "BDR_editobject.h" /* For headerprint */
#include "BDR_sculptmode.h"
#include "BDR_vpaint.h"
@@ -2911,3 +2913,25 @@
}
}
+void align_view_to_transform_orientation(View3D *v3d)
+{
+ short val;
+ char *str_menu = BIF_menustringTransformOrientation("Align View");
+ val = pupmenu(str_menu);
+ MEM_freeN(str_menu);
+
+ if (val >= 0)
+ {
+ float mat[4][4];
+ float orientation[3][3];
+
+ BIF_getTransformOrientationMatrix(val, orientation);
+
+ Mat4CpyMat3(mat, orientation);
+
+ VECCOPY(mat[3], G.vd->viewinv[3])
+ mat[3][3] = 1;
+
+ mat_to_viewmat(mat, 1);
+ }
+}
Index: source/blender/src/transform_orientations.c
===================================================================
--- source/blender/src/transform_orientations.c (revision 15055)
+++ source/blender/src/transform_orientations.c (working copy)
@@ -352,7 +352,7 @@
char *str_menu, *p;
- str_menu = MEM_callocN(strlen(menu) + strlen(title) + 40 * BIF_countTransformOrientation(), "UserTransSpace from matrix");
+ str_menu = MEM_callocN(strlen(menu) + strlen(title) + 40 * BIF_countTransformOrientation() + 16, "Orientation Menu");
p = str_menu;
p += sprintf(str_menu, "%s", title);
Index: source/blender/src/transform.c
===================================================================
--- source/blender/src/transform.c (revision 15055)
+++ source/blender/src/transform.c (working copy)
@@ -531,6 +531,24 @@
}
}
+void BIF_getTransformOrientationMatrix(int mode, float mat[][3])
+{
+ int old_mode = G.vd->twmode;
+
+ /* Remove all ugly globals from here */
+ G.vd->twmode = mode;
+
+ if(curarea->spacetype == SPACE_VIEW3D) {
+ calc_manipulator_stats(curarea); /* especially that one */
+ Mat3CpyMat4(mat, G.vd->twmat);
+ Mat3Ortho(mat);
+ }
+ else
+ Mat3One(mat);
+
+ G.vd->twmode = old_mode;
+}
+
static void view_editmove(unsigned short event)
{
int refresh = 0;
Index: source/blender/src/edit.c
===================================================================
--- source/blender/src/edit.c (revision 15055)
+++ source/blender/src/edit.c (working copy)
@@ -1837,7 +1837,7 @@
void alignmenu()
{
short val;
- char *str_menu = BIF_menustringTransformOrientation("Align");
+ char *str_menu = BIF_menustringTransformOrientation("Align Object");
val= pupmenu(str_menu);
MEM_freeN(str_menu);
Index: source/blender/src/space.c
===================================================================
--- source/blender/src/space.c (revision 15055)
+++ source/blender/src/space.c (working copy)
@@ -2779,6 +2779,11 @@
scrarea_queue_winredraw(curarea);
}
}
+ else if (G.qual == LR_CTRLKEY)
+ {
+ align_view_to_transform_orientation(G.vd);
+ scrarea_queue_winredraw(curarea);
+ }
break;
case PADPERIOD: /* '.' */
if(G.qual==0)
Index: source/blender/src/header_view3d.c
===================================================================
--- source/blender/src/header_view3d.c (revision 15055)
+++ source/blender/src/header_view3d.c (working copy)
@@ -422,6 +422,9 @@
curs= give_cursor();
curs[0]=curs[1]=curs[2]= 0.0;
break;
+ case 7: /* Align View to CTO */
+ align_view_to_transform_orientation(v3d);
+ break;
}
allqueue(REDRAWVIEW3D, 0);
}
@@ -446,6 +449,7 @@
} else {
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected|NumPad *", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
}
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Transform Orientation|Ctrl NumPad *", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
Index: source/blender/src/view.c
===================================================================
--- source/blender/src/view.c (revision 15055)
+++ source/blender/src/view.c (working copy)
@@ -1443,14 +1443,14 @@
glMatrixMode(GL_MODELVIEW);
}
-void obmat_to_viewmat(Object *ob, short smooth)
+void mat_to_viewmat(float mat[][4], short smooth)
{
float bmat[4][4];
float tmat[3][3];
G.vd->view= 0; /* dont show the grid */
- Mat4CpyMat4(bmat, ob->obmat);
+ Mat4CpyMat4(bmat, mat);
Mat4Ortho(bmat);
Mat4Invert(G.vd->viewmat, bmat);
@@ -1486,6 +1486,11 @@
}
}
+void obmat_to_viewmat(Object *ob, short smooth)
+{
+ mat_to_viewmat(ob->obmat, smooth);
+}
+
/* dont set windows active in in here, is used by renderwin too */
void setviewmatrixview3d()
{
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
59/ce/bfbe104b96d9f28e68f009008daa
Event Timeline
Log In to Comment