[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13223] trunk/blender/source/blender: === Custom Transform Orientation ===
Joe Eagar
joeedh at gmail.com
Mon Jan 14 10:49:17 CET 2008
It'd be kindof nice if you could use the current transform orientation
(e.g. like what the manipulator uses) too.
Joe
Martin Poirier wrote:
> Revision: 13223
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13223
> Author: theeth
> Date: 2008-01-13 19:24:09 +0100 (Sun, 13 Jan 2008)
>
> Log Message:
> -----------
> === Custom Transform Orientation ===
>
> Custom Orientations can be added with Ctrl-Shift-C (hotkey suggestions are welcomed), this adds and select the new alignment. Custom Orientations can also be added, deleted, selected from the Transform Orientations panel (View -> Transform Orientations). Standard orientations (global, local, normal, view) can also be selected from this panel.
>
> If you plan on using only a single custom orientation and don't really need a list, I suggest you use the hotkey as it adds and selects at the same time.
>
> Custom Orientations are save in the scene and are selected per 3D view (like normal orientation).
>
> Adding from an object, the orientation is a normalized version of the object's orientation.
> Adding from mesh data, a single element (vertex, edge, face) must be selected in its respective selection mode. Vertex orientation Z-axis is based on the normal, edge Z-axis on the edge itself (X-axis is on the XoY plane when possible, Y-axis is perpendicular to the rest). Face orientation Z-axis is the face normal, X-axis is perpendicular to the first edge, Y-axis is perpendicular to the rest.
> (More logical orientations can be suggested).
>
> I plan to add: 2 vertice (connected or not) => edge orientation , 3 vertice = face orientation
>
> Differences from the patch:
> - orientations no longer link back to the object they came from, everything is copy on creation.
> - orientations are overwritten based on name (if you add an orientation with the same name as one that already exists, it overwrites the old one)
>
> Modified Paths:
> --------------
> trunk/blender/source/blender/blenkernel/intern/scene.c
> trunk/blender/source/blender/blenloader/intern/readfile.c
> trunk/blender/source/blender/blenloader/intern/writefile.c
> trunk/blender/source/blender/include/BIF_space.h
> trunk/blender/source/blender/include/BIF_transform.h
> trunk/blender/source/blender/include/blendef.h
> trunk/blender/source/blender/include/butspace.h
> trunk/blender/source/blender/include/transform.h
> trunk/blender/source/blender/makesdna/DNA_scene_types.h
> trunk/blender/source/blender/makesdna/DNA_view3d_types.h
> trunk/blender/source/blender/src/drawview.c
> trunk/blender/source/blender/src/header_info.c
> trunk/blender/source/blender/src/header_view3d.c
> trunk/blender/source/blender/src/space.c
> trunk/blender/source/blender/src/transform.c
> trunk/blender/source/blender/src/transform_constraints.c
> trunk/blender/source/blender/src/transform_manipulator.c
>
> Modified: trunk/blender/source/blender/blenkernel/intern/scene.c
> ===================================================================
> --- trunk/blender/source/blender/blenkernel/intern/scene.c 2008-01-13 18:13:39 UTC (rev 13222)
> +++ trunk/blender/source/blender/blenkernel/intern/scene.c 2008-01-13 18:24:09 UTC (rev 13223)
> @@ -153,6 +153,7 @@
> }
>
> BLI_freelistN(&sce->markers);
> + BLI_freelistN(&sce->transform_spaces);
> BLI_freelistN(&sce->r.layers);
>
> if(sce->toolsettings){
>
> Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
> ===================================================================
> --- trunk/blender/source/blender/blenloader/intern/readfile.c 2008-01-13 18:13:39 UTC (rev 13222)
> +++ trunk/blender/source/blender/blenloader/intern/readfile.c 2008-01-13 18:24:09 UTC (rev 13223)
> @@ -3457,6 +3457,7 @@
> }
>
> link_list(fd, &(sce->markers));
> + link_list(fd, &(sce->transform_spaces));
> link_list(fd, &(sce->r.layers));
>
> sce->nodetree= newdataadr(fd, sce->nodetree);
>
> Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
> ===================================================================
> --- trunk/blender/source/blender/blenloader/intern/writefile.c 2008-01-13 18:13:39 UTC (rev 13222)
> +++ trunk/blender/source/blender/blenloader/intern/writefile.c 2008-01-13 18:24:09 UTC (rev 13223)
> @@ -1401,6 +1401,7 @@
> MetaStack *ms;
> Strip *strip;
> TimeMarker *marker;
> + TransformOrientation *ts;
> SceneRenderLayer *srl;
> int a;
>
> @@ -1505,6 +1506,10 @@
> for(marker= sce->markers.first; marker; marker= marker->next)
> writestruct(wd, DATA, "TimeMarker", 1, marker);
>
> + /* writing dynamic list of TransformOrientations to the blend file */
> + for(ts = sce->transform_spaces.first; ts; ts = ts->next)
> + writestruct(wd, DATA, "TransformOrientation", 1, ts);
> +
> for(srl= sce->r.layers.first; srl; srl= srl->next)
> writestruct(wd, DATA, "SceneRenderLayer", 1, srl);
>
>
> Modified: trunk/blender/source/blender/include/BIF_space.h
> ===================================================================
> --- trunk/blender/source/blender/include/BIF_space.h 2008-01-13 18:13:39 UTC (rev 13222)
> +++ trunk/blender/source/blender/include/BIF_space.h 2008-01-13 18:24:09 UTC (rev 13223)
> @@ -55,6 +55,7 @@
> #define VIEW3D_HANDLER_OBJECT 3
> #define VIEW3D_HANDLER_PREVIEW 4
> #define VIEW3D_HANDLER_MULTIRES 5
> +#define VIEW3D_HANDLER_TRANSFORM 6
>
> /* ipo handler codes */
> #define IPO_HANDLER_PROPERTIES 20
>
> Modified: trunk/blender/source/blender/include/BIF_transform.h
> ===================================================================
> --- trunk/blender/source/blender/include/BIF_transform.h 2008-01-13 18:13:39 UTC (rev 13222)
> +++ trunk/blender/source/blender/include/BIF_transform.h 2008-01-13 18:24:09 UTC (rev 13223)
> @@ -81,6 +81,8 @@
>
> struct TransInfo;
> struct ScrArea;
> +struct Base;
> +struct Scene;
>
> struct TransInfo * BIF_GetTransInfo(void);
> void BIF_setSingleAxisConstraint(float vec[3], char *text);
> @@ -88,6 +90,18 @@
> void BIF_setLocalAxisConstraint(char axis, char *text);
> void BIF_setLocalLockConstraint(char axis, char *text);
>
> +struct TransformOrientation;
> +
> +void BIF_clearTransformOrientation(void);
> +void BIF_removeTransformOrientation(struct TransformOrientation *ts);
> +void BIF_manageTransformOrientation(int confirm, int set);
> +int BIF_menuselectTransformOrientation(void);
> +void BIF_selectTransformOrientation(struct TransformOrientation *ts);
> +void BIF_selectTransformOrientationFromIndex(int index);
> +
> +char * BIF_menustringTransformOrientation(); /* the returned value was allocated and needs to be freed after use */
> +int BIF_countTransformOrientation();
> +
> /* Drawing callbacks */
> void BIF_drawConstraint(void);
> void BIF_drawPropCircle(void);
>
> Modified: trunk/blender/source/blender/include/blendef.h
> ===================================================================
> --- trunk/blender/source/blender/include/blendef.h 2008-01-13 18:13:39 UTC (rev 13222)
> +++ trunk/blender/source/blender/include/blendef.h 2008-01-13 18:24:09 UTC (rev 13223)
> @@ -237,6 +237,7 @@
> #define B_SEL_PATH 166
> #define B_SEL_POINT 167
> #define B_SEL_END 168
> +#define B_MAN_MODE 169
>
> /* IPO: 200 */
> #define B_IPOHOME 201
>
> Modified: trunk/blender/source/blender/include/butspace.h
> ===================================================================
> --- trunk/blender/source/blender/include/butspace.h 2008-01-13 18:13:39 UTC (rev 13222)
> +++ trunk/blender/source/blender/include/butspace.h 2008-01-13 18:24:09 UTC (rev 13223)
> @@ -170,6 +170,8 @@
> #define B_ARMATUREPANEL3 1013
> #define B_OBJECTPANELSCALE 1014
> #define B_OBJECTPANELDIMS 1015
> +#define B_TRANSFORMSPACEADD 1016
> +#define B_TRANSFORMSPACECLEAR 1017
>
> /* *********************** */
> #define B_LAMPBUTS 1200
>
> Modified: trunk/blender/source/blender/include/transform.h
> ===================================================================
> --- trunk/blender/source/blender/include/transform.h 2008-01-13 18:13:39 UTC (rev 13222)
> +++ trunk/blender/source/blender/include/transform.h 2008-01-13 18:24:09 UTC (rev 13223)
> @@ -463,6 +463,15 @@
> void applyNumInput(NumInput *n, float *vec);
> char handleNumInput(NumInput *n, unsigned short event);
>
> +/*********************** TransSpace ******************************/
> +
> +int manageObjectSpace(int confirm, int set);
> +int manageMeshSpace(int confirm, int set);
> +
> +int addMatrixSpace(float mat[3][3], char name[]);
> +int addObjectSpace(struct Object *ob);
> +void applyTransformOrientation(void);
> +
> #endif
>
>
>
> Modified: trunk/blender/source/blender/makesdna/DNA_scene_types.h
> ===================================================================
> --- trunk/blender/source/blender/makesdna/DNA_scene_types.h 2008-01-13 18:13:39 UTC (rev 13222)
> +++ trunk/blender/source/blender/makesdna/DNA_scene_types.h 2008-01-13 18:24:09 UTC (rev 13223)
> @@ -333,6 +333,12 @@
> int draw_timed;
> } ParticleEditSettings;
>
> +typedef struct TransformOrientation {
> + struct TransformOrientation *next, *prev;
> + char name[36];
> + float mat[3][3];
> +} TransformOrientation;
> +
> typedef struct ToolSettings {
> /* Subdivide Settings */
> short cornertype;
> @@ -366,7 +372,7 @@
> /* Auto-IK */
> short autoik_chainlen;
>
> - /* Image Paint (8 byte aligned please!) */
> + /* Image Paint (8 byttse aligned please!) */
> struct ImagePaintSettings imapaint;
>
> /* Particle Editing */
> @@ -494,6 +500,7 @@
> ScriptLink scriptlink;
>
> ListBase markers;
> + ListBase transform_spaces;
>
> short jumpframe, pad1;
> short snap_flag, snap_target;
>
> Modified: trunk/blender/source/blender/makesdna/DNA_view3d_types.h
> ===================================================================
> --- trunk/blender/source/blender/makesdna/DNA_view3d_types.h 2008-01-13 18:13:39 UTC (rev 13222)
> +++ trunk/blender/source/blender/makesdna/DNA_view3d_types.h 2008-01-13 18:24:09 UTC (rev 13223)
> @@ -200,6 +200,7 @@
> #define V3D_MANIP_LOCAL 1
> #define V3D_MANIP_NORMAL 2
> #define V3D_MANIP_VIEW 3
> +#define V3D_MANIP_CUSTOM 4 /* anything of value 4 or higher is custom */
>
> /* View3d->twflag */
> /* USE = user setting, DRAW = based on selection */
>
> Modified: trunk/blender/source/blender/src/drawview.c
> ===================================================================
> --- trunk/blender/source/blender/src/drawview.c 2008-01-13 18:13:39 UTC (rev 13222)
> +++ trunk/blender/source/blender/src/drawview.c 2008-01-13 18:24:09 UTC (rev 13223)
> @@ -2228,9 +2228,83 @@
> allqueue(REDRAWVIEW3D, 1);
> }
> break;
> + case B_TRANSFORMSPACEADD:
> + BIF_manageTransformOrientation(1, 0);
> + allqueue(REDRAWVIEW3D, 1);
> + break;
> + case B_TRANSFORMSPACECLEAR:
> + BIF_clearTransformOrientation();
> + allqueue(REDRAWVIEW3D, 1);
> }
> }
>
> +void removeTransformOrientation_func(void *target, void *unused)
> +{
> + BIF_removeTransformOrientation((TransformOrientation *) target);
> +}
> +
> +void selectTransformOrientation_func(void *target, void *unused)
> +{
> + BIF_selectTransformOrientation((TransformOrientation *) target);
> +}
> +
> +static void view3d_panel_transform_spaces(short cntrl)
> +{
> + ListBase *transform_spaces = &G.scene->transform_spaces;
> + TransformOrientation *ts = transform_spaces->first;
> + uiBlock *block;
> + uiBut *but;
> + int xco = 20, yco = 70, height = 140;
> + int index;
> +
> + block= uiNewBlock(&curarea->uiblocks, "view3d_panel_transform", UI_EMBOSS, UI_HELV, curarea->win);
> + uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl);
> + uiSetPanelHandler(VIEW3D_HANDLER_TRANSFORM); // for close and esc
> +
> + if(uiNewPanel(curarea, block, "Transform Orientations", "View3d", 10, 230, 318, height)==0) return;
> +
> + uiNewPanelHeight(block, height);
> +
> + uiBlockBeginAlign(block);
> +
> + if (G.obedit)
> + uiDefBut(block, BUT, B_TRANSFORMSPACEADD, "Add", xco,120,80,20, 0, 0, 0, 0, 0, "Add the selected element as a Transform Orientation");
> + else
> + uiDefBut(block, BUT, B_TRANSFORMSPACEADD, "Add", xco,120,80,20, 0, 0, 0, 0, 0, "Add the active object as a Transform Orientation");
> +
> + uiDefBut(block, BUT, B_TRANSFORMSPACECLEAR, "Clear", xco + 80,120,80,20, 0, 0, 0, 0, 0, "Removal all Transform Orientations");
> +
> + uiBlockEndAlign(block);
> +
> + uiPanelPush(block);
> +
> + uiBlockBeginAlign(block);
> +
> + uiDefButS(block, ROW, REDRAWHEADERS, "Global", xco, 90, 40,20, &G.vd->twmode, 5.0, (float)V3D_MANIP_GLOBAL,0, 0, "Global Transform Orientation");
> + uiDefButS(block, ROW, REDRAWHEADERS, "Local", xco + 40, 90, 40,20, &G.vd->twmode, 5.0, (float)V3D_MANIP_LOCAL, 0, 0, "Local Transform Orientation");
> + uiDefButS(block, ROW, REDRAWHEADERS, "Normal", xco + 80, 90, 40,20, &G.vd->twmode, 5.0, (float)V3D_MANIP_NORMAL,0, 0, "Normal Transform Orientation");
> + uiDefButS(block, ROW, REDRAWHEADERS, "View", xco + 120, 90, 40,20, &G.vd->twmode, 5.0, (float)V3D_MANIP_VIEW, 0, 0, "View Transform Orientation");
> +
> + for (index = V3D_MANIP_CUSTOM, ts = transform_spaces->first ; ts ; ts = ts->next, index++) {
> +
> + BIF_ThemeColor(TH_BUT_ACTION);
> + but = uiDefIconButS(block,ROW, REDRAWHEADERS, ICON_RIGHTARROW_THIN, xco,yco,XIC,YIC, &G.vd->twmode, 5.0, (float)index, 0, 0, "Use this Custom Transform Orientation");
> + uiButSetFunc(but, selectTransformOrientation_func, ts, NULL);
> + uiDefBut(block, TEX, 0, "", xco+=XIC, yco,100+XIC,20, &ts->name, 0, 30, 0, 0, "Edits the name of this Transform Orientation");
> + but = uiDefIconBut(block, BUT, REDRAWVIEW3D, ICON_X, xco+=100+XIC,yco,XIC,YIC, 0, 0, 0, 0, 0, "Deletes this Transform Orientation");
> + uiButSetFunc(but, removeTransformOrientation_func, ts, NULL);
> +
> + xco = 20;
> + yco -= 25;
> + }
> + uiBlockEndAlign(block);
> +
> + uiPanelPop(block);
> +
>
> @@ Diff output truncated at 10240 characters. @@
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
>
More information about the Bf-committers
mailing list