2005-02-14 02:53:36 +00:00
|
|
|
/**
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version. The Blender
|
|
|
|
|
* Foundation also sells licenses for use in proprietary software under
|
|
|
|
|
* the Blender License. See http://www.blender.org/BL/ for information
|
|
|
|
|
* about this.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
#include <stdio.h>
|
2005-02-14 02:53:36 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef WIN32
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <io.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
|
#include "DNA_ipo_types.h" /* some silly ipo flag */
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
#include "DNA_listBase.h"
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
2006-02-12 21:09:18 +00:00
|
|
|
#include "DNA_scene_types.h" /* PET modes */
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
#include "DNA_screen_types.h" /* area dimensions */
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_texture_types.h"
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
2005-02-14 02:53:36 +00:00
|
|
|
#include "DNA_view3d_types.h"
|
2005-08-23 18:13:30 +00:00
|
|
|
#include "DNA_space_types.h"
|
2005-06-28 07:58:16 +00:00
|
|
|
|
|
|
|
|
#include "BIF_editview.h" /* arrows_move_cursor */
|
2005-07-23 18:52:31 +00:00
|
|
|
#include "BIF_gl.h"
|
2006-07-31 19:23:42 +00:00
|
|
|
#include "BIF_glutil.h"
|
2005-07-23 18:52:31 +00:00
|
|
|
#include "BIF_mywindow.h"
|
|
|
|
|
#include "BIF_resources.h"
|
2005-02-20 19:00:00 +00:00
|
|
|
#include "BIF_screen.h"
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
#include "BIF_space.h" /* undo */
|
|
|
|
|
#include "BIF_toets.h" /* persptoetsen */
|
|
|
|
|
#include "BIF_mywindow.h" /* warp_pointer */
|
2006-02-12 21:09:18 +00:00
|
|
|
#include "BIF_toolbox.h" /* notice */
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
#include "BIF_editmesh.h"
|
2005-08-23 18:13:30 +00:00
|
|
|
#include "BIF_editsima.h"
|
|
|
|
|
#include "BIF_drawimage.h" /* uvco_to_areaco_noclip */
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-02-22 16:50:04 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_utildefines.h"
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
#include "BKE_bad_level_calls.h"/* popmenu and error */
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
#include "BSE_view.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_arithb.h"
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_editVert.h"
|
2005-02-22 16:50:04 +00:00
|
|
|
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
#include "PIL_time.h" /* sleep */
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
#include "blendef.h"
|
|
|
|
|
|
|
|
|
|
#include "mydevice.h"
|
|
|
|
|
|
|
|
|
|
#include "transform.h"
|
|
|
|
|
|
|
|
|
|
/* GLOBAL VARIABLE THAT SHOULD MOVED TO SCREEN MEMBER OR SOMETHING */
|
2005-05-08 12:00:28 +00:00
|
|
|
TransInfo Trans = {TFM_INIT, 0}; // enforce init on first usage
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-08-16 17:37:42 +00:00
|
|
|
/******************************** Helper functions ************************************/
|
2006-12-19 22:25:07 +00:00
|
|
|
|
|
|
|
|
/* GLOBAL Wrapper Fonctions */
|
|
|
|
|
|
|
|
|
|
void BIF_drawSnap()
|
|
|
|
|
{
|
|
|
|
|
drawSnapping(&Trans);
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-23 18:52:31 +00:00
|
|
|
/* ************************** Dashed help line **************************** */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* bad frontbuffer call... because it is used in transform after force_draw() */
|
2005-08-16 10:17:02 +00:00
|
|
|
static void helpline(TransInfo *t, float *vec)
|
2005-07-23 18:52:31 +00:00
|
|
|
{
|
|
|
|
|
float vecrot[3], cent[2];
|
|
|
|
|
short mval[2];
|
|
|
|
|
|
|
|
|
|
VECCOPY(vecrot, vec);
|
2005-08-16 10:17:02 +00:00
|
|
|
if(t->flag & T_EDIT) {
|
|
|
|
|
Object *ob=G.obedit;
|
2005-07-23 18:52:31 +00:00
|
|
|
if(ob) Mat4MulVecfl(ob->obmat, vecrot);
|
|
|
|
|
}
|
2005-08-16 10:17:02 +00:00
|
|
|
else if(t->flag & T_POSE) {
|
|
|
|
|
Object *ob=t->poseobj;
|
2007-02-05 18:00:03 +00:00
|
|
|
if(ob) Mat4MulVecfl(ob->obmat, vecrot);
|
2005-08-16 10:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-23 18:52:31 +00:00
|
|
|
getmouseco_areawin(mval);
|
2005-08-23 18:13:30 +00:00
|
|
|
projectFloatView(t, vecrot, cent); // no overflow in extreme cases
|
2005-08-20 19:18:35 +00:00
|
|
|
if(cent[0]!=IS_CLIPPED) {
|
2005-07-23 18:52:31 +00:00
|
|
|
persp(PERSP_WIN);
|
|
|
|
|
|
|
|
|
|
glDrawBuffer(GL_FRONT);
|
|
|
|
|
|
|
|
|
|
BIF_ThemeColor(TH_WIRE);
|
|
|
|
|
|
|
|
|
|
setlinestyle(3);
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
glVertex2sv(mval);
|
|
|
|
|
glVertex2fv(cent);
|
|
|
|
|
glEnd();
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
|
|
|
|
|
persp(PERSP_VIEW);
|
2006-07-31 19:23:42 +00:00
|
|
|
bglFlush(); // flush display for frontbuffer
|
2005-07-23 18:52:31 +00:00
|
|
|
glDrawBuffer(GL_BACK);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-16 17:37:42 +00:00
|
|
|
/* ************************** INPUT FROM MOUSE *************************** */
|
|
|
|
|
|
|
|
|
|
float InputScaleRatio(TransInfo *t, short mval[2]) {
|
|
|
|
|
float ratio, dx, dy;
|
|
|
|
|
if(t->flag & T_SHIFT_MOD) {
|
|
|
|
|
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
|
2006-02-12 21:09:18 +00:00
|
|
|
dx = (float)(t->center2d[0] - t->shiftmval[0]);
|
|
|
|
|
dy = (float)(t->center2d[1] - t->shiftmval[1]);
|
2005-08-16 17:37:42 +00:00
|
|
|
ratio = (float)sqrt( dx*dx + dy*dy)/t->fac;
|
|
|
|
|
|
|
|
|
|
dx= (float)(t->center2d[0] - mval[0]);
|
|
|
|
|
dy= (float)(t->center2d[1] - mval[1]);
|
|
|
|
|
ratio+= 0.1f*(float)(sqrt( dx*dx + dy*dy)/t->fac -ratio);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
dx = (float)(t->center2d[0] - mval[0]);
|
|
|
|
|
dy = (float)(t->center2d[1] - mval[1]);
|
|
|
|
|
ratio = (float)sqrt( dx*dx + dy*dy)/t->fac;
|
|
|
|
|
}
|
|
|
|
|
return ratio;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float InputHorizontalRatio(TransInfo *t, short mval[2]) {
|
2007-01-16 18:55:15 +00:00
|
|
|
float x, pad;
|
2005-08-16 17:37:42 +00:00
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
pad = curarea->winx / 10;
|
2005-08-16 17:37:42 +00:00
|
|
|
|
|
|
|
|
if (t->flag & T_SHIFT_MOD) {
|
|
|
|
|
/* deal with Shift key by adding motion / 10 to motion before shift press */
|
2007-01-16 18:55:15 +00:00
|
|
|
x = t->shiftmval[0] + (float)(mval[0] - t->shiftmval[0]) / 10.0f;
|
2005-08-16 17:37:42 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2007-01-16 18:55:15 +00:00
|
|
|
x = mval[0];
|
2005-08-16 17:37:42 +00:00
|
|
|
}
|
2007-01-16 18:55:15 +00:00
|
|
|
return (x - pad) / (curarea->winx - 2 * pad);
|
2005-08-23 18:13:30 +00:00
|
|
|
}
|
|
|
|
|
|
2006-02-12 21:09:18 +00:00
|
|
|
float InputHorizontalAbsolute(TransInfo *t, short mval[2]) {
|
|
|
|
|
float vec[3];
|
|
|
|
|
if(t->flag & T_SHIFT_MOD) {
|
2007-01-16 18:55:15 +00:00
|
|
|
float dvec[3];
|
|
|
|
|
/* calculate the main translation and the precise one separate */
|
|
|
|
|
convertViewVec(t, dvec, (short)(mval[0] - t->shiftmval[0]), (short)(mval[1] - t->shiftmval[1]));
|
|
|
|
|
VecMulf(dvec, 0.1f);
|
|
|
|
|
convertViewVec(t, t->vec, (short)(t->shiftmval[0] - t->imval[0]), (short)(t->shiftmval[1] - t->imval[1]));
|
|
|
|
|
VecAddf(t->vec, t->vec, dvec);
|
2006-02-12 21:09:18 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
convertViewVec(t, t->vec, (short)(mval[0] - t->imval[0]), (short)(mval[1] - t->imval[1]));
|
|
|
|
|
}
|
|
|
|
|
Projf(vec, t->vec, t->viewinv[0]);
|
|
|
|
|
return Inpf(t->viewinv[0], vec) * 2.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 18:55:15 +00:00
|
|
|
float InputVerticalRatio(TransInfo *t, short mval[2]) {
|
|
|
|
|
float y, pad;
|
|
|
|
|
|
|
|
|
|
pad = curarea->winy / 10;
|
|
|
|
|
|
|
|
|
|
if (t->flag & T_SHIFT_MOD) {
|
|
|
|
|
/* deal with Shift key by adding motion / 10 to motion before shift press */
|
|
|
|
|
y = t->shiftmval[1] + (float)(mval[1] - t->shiftmval[1]) / 10.0f;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
y = mval[0];
|
|
|
|
|
}
|
|
|
|
|
return (y - pad) / (curarea->winy - 2 * pad);
|
|
|
|
|
}
|
|
|
|
|
|
2006-02-12 21:09:18 +00:00
|
|
|
float InputVerticalAbsolute(TransInfo *t, short mval[2]) {
|
|
|
|
|
float vec[3];
|
|
|
|
|
if(t->flag & T_SHIFT_MOD) {
|
2007-01-16 18:55:15 +00:00
|
|
|
float dvec[3];
|
|
|
|
|
/* calculate the main translation and the precise one separate */
|
|
|
|
|
convertViewVec(t, dvec, (short)(mval[0] - t->shiftmval[0]), (short)(mval[1] - t->shiftmval[1]));
|
|
|
|
|
VecMulf(dvec, 0.1f);
|
|
|
|
|
convertViewVec(t, t->vec, (short)(t->shiftmval[0] - t->imval[0]), (short)(t->shiftmval[1] - t->imval[1]));
|
|
|
|
|
VecAddf(t->vec, t->vec, dvec);
|
2006-02-12 21:09:18 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
convertViewVec(t, t->vec, (short)(mval[0] - t->imval[0]), (short)(mval[1] - t->imval[1]));
|
|
|
|
|
}
|
|
|
|
|
Projf(vec, t->vec, t->viewinv[1]);
|
|
|
|
|
return Inpf(t->viewinv[1], vec) * 2.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
/* ************************** SPACE DEPENDANT CODE **************************** */
|
|
|
|
|
|
|
|
|
|
void setTransformViewMatrices(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
if(t->spacetype==SPACE_VIEW3D) {
|
|
|
|
|
Mat4CpyMat4(t->viewmat, G.vd->viewmat);
|
|
|
|
|
Mat4CpyMat4(t->viewinv, G.vd->viewinv);
|
|
|
|
|
Mat4CpyMat4(t->persmat, G.vd->persmat);
|
|
|
|
|
Mat4CpyMat4(t->persinv, G.vd->persinv);
|
|
|
|
|
t->persp= G.vd->persp;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Mat4One(t->viewmat);
|
|
|
|
|
Mat4One(t->viewinv);
|
|
|
|
|
Mat4One(t->persmat);
|
|
|
|
|
Mat4One(t->persinv);
|
|
|
|
|
t->persp = 0; // ortho
|
|
|
|
|
}
|
2005-09-24 18:00:32 +00:00
|
|
|
|
|
|
|
|
calculateCenter2D(t);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void convertViewVec(TransInfo *t, float *vec, short dx, short dy)
|
|
|
|
|
{
|
2005-10-02 18:27:14 +00:00
|
|
|
if (t->spacetype==SPACE_VIEW3D) {
|
2005-08-23 18:13:30 +00:00
|
|
|
window_to_3d(vec, dx, dy);
|
2005-10-02 18:27:14 +00:00
|
|
|
}
|
2005-08-23 18:13:30 +00:00
|
|
|
else if(t->spacetype==SPACE_IMAGE) {
|
|
|
|
|
float divx, divy, aspx, aspy;
|
|
|
|
|
|
|
|
|
|
transform_aspect_ratio_tface_uv(&aspx, &aspy);
|
|
|
|
|
|
|
|
|
|
divx= G.v2d->mask.xmax-G.v2d->mask.xmin;
|
|
|
|
|
divy= G.v2d->mask.ymax-G.v2d->mask.ymin;
|
|
|
|
|
|
|
|
|
|
vec[0]= aspx*(G.v2d->cur.xmax-G.v2d->cur.xmin)*(dx)/divx;
|
|
|
|
|
vec[1]= aspy*(G.v2d->cur.ymax-G.v2d->cur.ymin)*(dy)/divy;
|
|
|
|
|
vec[2]= 0.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void projectIntView(TransInfo *t, float *vec, int *adr)
|
|
|
|
|
{
|
|
|
|
|
if (t->spacetype==SPACE_VIEW3D)
|
|
|
|
|
project_int(vec, adr);
|
|
|
|
|
else if(t->spacetype==SPACE_IMAGE) {
|
|
|
|
|
float aspx, aspy, v[2];
|
|
|
|
|
|
|
|
|
|
transform_aspect_ratio_tface_uv(&aspx, &aspy);
|
|
|
|
|
v[0]= vec[0]/aspx;
|
|
|
|
|
v[1]= vec[1]/aspy;
|
|
|
|
|
|
|
|
|
|
uvco_to_areaco_noclip(v, adr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void projectFloatView(TransInfo *t, float *vec, float *adr)
|
|
|
|
|
{
|
|
|
|
|
if (t->spacetype==SPACE_VIEW3D)
|
|
|
|
|
project_float(vec, adr);
|
|
|
|
|
else if(t->spacetype==SPACE_IMAGE) {
|
|
|
|
|
int a[2];
|
|
|
|
|
|
|
|
|
|
projectIntView(t, vec, a);
|
|
|
|
|
adr[0]= a[0];
|
|
|
|
|
adr[1]= a[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void convertVecToDisplayNum(float *vec, float *num)
|
|
|
|
|
{
|
|
|
|
|
TransInfo *t= BIF_GetTransInfo();
|
|
|
|
|
|
|
|
|
|
VECCOPY(num, vec);
|
|
|
|
|
|
|
|
|
|
if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
|
|
|
|
|
float aspx, aspy;
|
|
|
|
|
|
|
|
|
|
if((G.sima->flag & SI_COORDFLOATS)==0) {
|
|
|
|
|
int width, height;
|
|
|
|
|
transform_width_height_tface_uv(&width, &height);
|
|
|
|
|
|
|
|
|
|
num[0] *= width;
|
|
|
|
|
num[1] *= height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transform_aspect_ratio_tface_uv(&aspx, &aspy);
|
|
|
|
|
num[0] /= aspx;
|
|
|
|
|
num[1] /= aspy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void convertDisplayNumToVec(float *num, float *vec)
|
|
|
|
|
{
|
|
|
|
|
TransInfo *t= BIF_GetTransInfo();
|
|
|
|
|
|
|
|
|
|
VECCOPY(vec, num);
|
|
|
|
|
|
|
|
|
|
if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
|
|
|
|
|
float aspx, aspy;
|
|
|
|
|
|
|
|
|
|
if((G.sima->flag & SI_COORDFLOATS)==0) {
|
|
|
|
|
int width, height;
|
|
|
|
|
transform_width_height_tface_uv(&width, &height);
|
|
|
|
|
|
|
|
|
|
vec[0] /= width;
|
|
|
|
|
vec[1] /= height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transform_aspect_ratio_tface_uv(&aspx, &aspy);
|
|
|
|
|
vec[0] *= aspx;
|
|
|
|
|
vec[1] *= aspy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void viewRedrawForce(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
if(t->spacetype==SPACE_VIEW3D)
|
|
|
|
|
force_draw(0);
|
|
|
|
|
else if(t->spacetype==SPACE_IMAGE) {
|
|
|
|
|
if(G.sima->lock) force_draw_plus(SPACE_VIEW3D, 0);
|
|
|
|
|
else force_draw(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void viewRedrawPost(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
if(t->spacetype==SPACE_VIEW3D) {
|
|
|
|
|
allqueue(REDRAWBUTSOBJECT, 0);
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
}
|
|
|
|
|
else if(t->spacetype==SPACE_IMAGE) {
|
|
|
|
|
allqueue(REDRAWIMAGE, 0);
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scrarea_queue_headredraw(curarea);
|
2005-08-16 17:37:42 +00:00
|
|
|
}
|
2005-07-23 18:52:31 +00:00
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
/* ************************** TRANSFORMATIONS **************************** */
|
|
|
|
|
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
void BIF_selectOrientation() {
|
|
|
|
|
short val;
|
|
|
|
|
val= pupmenu("Orientation%t|Global|Local|Normal|View");
|
|
|
|
|
if(val>0) {
|
|
|
|
|
if(val==1) G.vd->twmode= V3D_MANIP_GLOBAL;
|
|
|
|
|
else if(val==2) G.vd->twmode= V3D_MANIP_LOCAL;
|
|
|
|
|
else if(val==3) G.vd->twmode= V3D_MANIP_NORMAL;
|
|
|
|
|
else if(val==4) G.vd->twmode= V3D_MANIP_VIEW;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-30 21:19:19 +00:00
|
|
|
static void view_editmove(unsigned short event)
|
|
|
|
|
{
|
2005-06-28 07:58:16 +00:00
|
|
|
int refresh = 0;
|
2005-04-30 21:19:19 +00:00
|
|
|
/* Regular: Zoom in */
|
|
|
|
|
/* Shift: Scroll up */
|
|
|
|
|
/* Ctrl: Scroll right */
|
|
|
|
|
/* Alt-Shift: Rotate up */
|
|
|
|
|
/* Alt-Ctrl: Rotate right */
|
|
|
|
|
|
2005-09-24 18:00:32 +00:00
|
|
|
/* only work in 3D window for now
|
|
|
|
|
* In the end, will have to send to event to a 2D window handler instead
|
|
|
|
|
*/
|
|
|
|
|
if (Trans.flag & T_2D_EDIT)
|
|
|
|
|
return;
|
|
|
|
|
|
2005-04-30 21:19:19 +00:00
|
|
|
switch(event) {
|
|
|
|
|
case WHEELUPMOUSE:
|
|
|
|
|
|
|
|
|
|
if( G.qual & LR_SHIFTKEY ) {
|
|
|
|
|
if( G.qual & LR_ALTKEY ) {
|
|
|
|
|
G.qual &= ~LR_SHIFTKEY;
|
|
|
|
|
persptoetsen(PAD2);
|
|
|
|
|
G.qual |= LR_SHIFTKEY;
|
|
|
|
|
} else {
|
|
|
|
|
persptoetsen(PAD2);
|
|
|
|
|
}
|
|
|
|
|
} else if( G.qual & LR_CTRLKEY ) {
|
|
|
|
|
if( G.qual & LR_ALTKEY ) {
|
|
|
|
|
G.qual &= ~LR_CTRLKEY;
|
|
|
|
|
persptoetsen(PAD4);
|
|
|
|
|
G.qual |= LR_CTRLKEY;
|
|
|
|
|
} else {
|
|
|
|
|
persptoetsen(PAD4);
|
|
|
|
|
}
|
|
|
|
|
} else if(U.uiflag & USER_WHEELZOOMDIR)
|
|
|
|
|
persptoetsen(PADMINUS);
|
|
|
|
|
else
|
|
|
|
|
persptoetsen(PADPLUSKEY);
|
|
|
|
|
|
2005-06-28 07:58:16 +00:00
|
|
|
refresh = 1;
|
2005-04-30 21:19:19 +00:00
|
|
|
break;
|
|
|
|
|
case WHEELDOWNMOUSE:
|
|
|
|
|
if( G.qual & LR_SHIFTKEY ) {
|
|
|
|
|
if( G.qual & LR_ALTKEY ) {
|
|
|
|
|
G.qual &= ~LR_SHIFTKEY;
|
|
|
|
|
persptoetsen(PAD8);
|
|
|
|
|
G.qual |= LR_SHIFTKEY;
|
|
|
|
|
} else {
|
|
|
|
|
persptoetsen(PAD8);
|
|
|
|
|
}
|
|
|
|
|
} else if( G.qual & LR_CTRLKEY ) {
|
|
|
|
|
if( G.qual & LR_ALTKEY ) {
|
|
|
|
|
G.qual &= ~LR_CTRLKEY;
|
|
|
|
|
persptoetsen(PAD6);
|
|
|
|
|
G.qual |= LR_CTRLKEY;
|
|
|
|
|
} else {
|
|
|
|
|
persptoetsen(PAD6);
|
|
|
|
|
}
|
|
|
|
|
} else if(U.uiflag & USER_WHEELZOOMDIR)
|
|
|
|
|
persptoetsen(PADPLUSKEY);
|
|
|
|
|
else
|
|
|
|
|
persptoetsen(PADMINUS);
|
|
|
|
|
|
2005-06-28 07:58:16 +00:00
|
|
|
refresh = 1;
|
2005-04-30 21:19:19 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2005-06-28 07:58:16 +00:00
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
if (refresh)
|
|
|
|
|
setTransformViewMatrices(&Trans);
|
2005-04-30 21:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
void checkFirstTime() {
|
|
|
|
|
if(Trans.mode==TFM_INIT) {
|
|
|
|
|
memset(&Trans, 0, sizeof(TransInfo));
|
|
|
|
|
Trans.propsize = 1.0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-08 12:00:28 +00:00
|
|
|
static char *transform_to_undostr(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
switch (t->mode) {
|
|
|
|
|
case TFM_TRANSLATION:
|
|
|
|
|
return "Translate";
|
|
|
|
|
case TFM_ROTATION:
|
|
|
|
|
return "Rotate";
|
|
|
|
|
case TFM_RESIZE:
|
|
|
|
|
return "Scale";
|
|
|
|
|
case TFM_TOSPHERE:
|
|
|
|
|
return "To Sphere";
|
|
|
|
|
case TFM_SHEAR:
|
|
|
|
|
return "Shear";
|
|
|
|
|
case TFM_WARP:
|
|
|
|
|
return "Warp";
|
|
|
|
|
case TFM_SHRINKFATTEN:
|
|
|
|
|
return "Shrink/Fatten";
|
|
|
|
|
case TFM_TILT:
|
|
|
|
|
return "Tilt";
|
|
|
|
|
case TFM_TRACKBALL:
|
|
|
|
|
return "Trackball";
|
|
|
|
|
case TFM_PUSHPULL:
|
|
|
|
|
return "Push/Pull";
|
|
|
|
|
case TFM_CREASE:
|
|
|
|
|
return "Crease";
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
case TFM_BONESIZE:
|
|
|
|
|
return "Bone Width";
|
|
|
|
|
case TFM_BONE_ENVELOPE:
|
|
|
|
|
return "Bone Envelope";
|
2005-05-08 12:00:28 +00:00
|
|
|
}
|
|
|
|
|
return "Transform";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************* */
|
|
|
|
|
|
2005-06-04 16:22:50 +00:00
|
|
|
static void transformEvent(unsigned short event, short val) {
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
float mati[3][3] = {{1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 1.0f}};
|
2005-05-10 04:21:11 +00:00
|
|
|
char cmode = constraintModeToChar(&Trans);
|
|
|
|
|
|
|
|
|
|
if (val) {
|
|
|
|
|
switch (event){
|
|
|
|
|
/* enforce redraw of transform when modifiers are used */
|
|
|
|
|
case LEFTCTRLKEY:
|
|
|
|
|
case RIGHTCTRLKEY:
|
|
|
|
|
Trans.redraw = 1;
|
|
|
|
|
break;
|
|
|
|
|
case LEFTSHIFTKEY:
|
|
|
|
|
case RIGHTSHIFTKEY:
|
|
|
|
|
/* shift is modifier for higher resolution transform, works nice to store this mouse position */
|
|
|
|
|
getmouseco_areawin(Trans.shiftmval);
|
|
|
|
|
Trans.flag |= T_SHIFT_MOD;
|
|
|
|
|
Trans.redraw = 1;
|
|
|
|
|
break;
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
|
|
|
|
|
case SPACEKEY:
|
2005-08-23 18:13:30 +00:00
|
|
|
if ((Trans.spacetype==SPACE_VIEW3D) && (G.qual & LR_ALTKEY)) {
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
short mval[2];
|
|
|
|
|
|
|
|
|
|
getmouseco_sc(mval);
|
|
|
|
|
BIF_selectOrientation();
|
|
|
|
|
calc_manipulator_stats(curarea);
|
|
|
|
|
Mat3CpyMat4(Trans.spacemtx, G.vd->twmat);
|
|
|
|
|
warp_pointer(mval[0], mval[1]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Trans.state = TRANS_CONFIRM;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2005-05-10 04:21:11 +00:00
|
|
|
|
|
|
|
|
case MIDDLEMOUSE:
|
|
|
|
|
if ((Trans.flag & T_NO_CONSTRAINT)==0) {
|
|
|
|
|
/* exception for switching to dolly, or trackball, in camera view */
|
|
|
|
|
if (Trans.flag & T_CAMERA) {
|
|
|
|
|
if (Trans.mode==TFM_TRANSLATION)
|
|
|
|
|
setLocalConstraint(&Trans, (CON_AXIS2), "along local Z");
|
|
|
|
|
else if (Trans.mode==TFM_ROTATION) {
|
|
|
|
|
restoreTransObjects(&Trans);
|
|
|
|
|
initTransModeFlags(&Trans, TFM_TRACKBALL);
|
|
|
|
|
initTrackball(&Trans);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Trans.flag |= T_MMB_PRESSED;
|
|
|
|
|
if (Trans.con.mode & CON_APPLY) {
|
|
|
|
|
stopConstraint(&Trans);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2005-12-19 16:32:18 +00:00
|
|
|
if (G.qual & LR_CTRLKEY) {
|
2005-10-02 19:31:32 +00:00
|
|
|
initSelectConstraint(&Trans, Trans.spacemtx);
|
2005-12-19 16:32:18 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* bit hackish... but it prevents mmb select to print the orientation from menu */
|
|
|
|
|
strcpy(Trans.spacename, "global");
|
2005-10-02 19:31:32 +00:00
|
|
|
initSelectConstraint(&Trans, mati);
|
2005-12-19 16:32:18 +00:00
|
|
|
}
|
2005-05-10 04:21:11 +00:00
|
|
|
postSelectConstraint(&Trans);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Trans.redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case ESCKEY:
|
|
|
|
|
case RIGHTMOUSE:
|
|
|
|
|
Trans.state = TRANS_CANCEL;
|
|
|
|
|
break;
|
|
|
|
|
case LEFTMOUSE:
|
|
|
|
|
case PADENTER:
|
|
|
|
|
case RETKEY:
|
|
|
|
|
Trans.state = TRANS_CONFIRM;
|
|
|
|
|
break;
|
|
|
|
|
case GKEY:
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
/* only switch when... */
|
|
|
|
|
if( ELEM3(Trans.mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
|
|
|
|
|
restoreTransObjects(&Trans);
|
|
|
|
|
initTransModeFlags(&Trans, TFM_TRANSLATION);
|
|
|
|
|
initTranslation(&Trans);
|
|
|
|
|
Trans.redraw = 1;
|
|
|
|
|
}
|
2005-05-10 04:21:11 +00:00
|
|
|
break;
|
|
|
|
|
case SKEY:
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
/* only switch when... */
|
|
|
|
|
if( ELEM3(Trans.mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
|
2005-05-10 04:21:11 +00:00
|
|
|
restoreTransObjects(&Trans);
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
initTransModeFlags(&Trans, TFM_RESIZE);
|
|
|
|
|
initResize(&Trans);
|
|
|
|
|
Trans.redraw = 1;
|
2005-05-10 04:21:11 +00:00
|
|
|
}
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
break;
|
|
|
|
|
case RKEY:
|
|
|
|
|
/* only switch when... */
|
|
|
|
|
if( ELEM4(Trans.mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
|
|
|
|
|
|
|
|
|
|
if (Trans.mode == TFM_ROTATION) {
|
|
|
|
|
restoreTransObjects(&Trans);
|
|
|
|
|
initTransModeFlags(&Trans, TFM_TRACKBALL);
|
|
|
|
|
initTrackball(&Trans);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
restoreTransObjects(&Trans);
|
|
|
|
|
initTransModeFlags(&Trans, TFM_ROTATION);
|
|
|
|
|
initRotation(&Trans);
|
|
|
|
|
}
|
|
|
|
|
Trans.redraw = 1;
|
2005-05-10 04:21:11 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CKEY:
|
|
|
|
|
if (G.qual & LR_ALTKEY) {
|
|
|
|
|
Trans.flag ^= T_PROP_CONNECTED;
|
|
|
|
|
sort_trans_data_dist(&Trans);
|
|
|
|
|
calculatePropRatio(&Trans);
|
|
|
|
|
Trans.redraw= 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
stopConstraint(&Trans);
|
|
|
|
|
Trans.redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case XKEY:
|
|
|
|
|
if ((Trans.flag & T_NO_CONSTRAINT)==0) {
|
|
|
|
|
if (cmode == 'X') {
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
if (Trans.con.mode & CON_USER) {
|
2005-05-10 04:21:11 +00:00
|
|
|
stopConstraint(&Trans);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (G.qual == 0)
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
setUserConstraint(&Trans, (CON_AXIS0), "along %s X");
|
2005-08-23 18:13:30 +00:00
|
|
|
else if ((G.qual == LR_SHIFTKEY) && ((Trans.flag & T_2D_EDIT)==0))
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
setUserConstraint(&Trans, (CON_AXIS1|CON_AXIS2), "locking %s X");
|
2005-05-10 04:21:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (G.qual == 0)
|
|
|
|
|
setConstraint(&Trans, mati, (CON_AXIS0), "along global X");
|
2005-08-23 18:13:30 +00:00
|
|
|
else if ((G.qual == LR_SHIFTKEY) && ((Trans.flag & T_2D_EDIT)==0))
|
2005-05-10 04:21:11 +00:00
|
|
|
setConstraint(&Trans, mati, (CON_AXIS1|CON_AXIS2), "locking global X");
|
|
|
|
|
}
|
|
|
|
|
Trans.redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case YKEY:
|
|
|
|
|
if ((Trans.flag & T_NO_CONSTRAINT)==0) {
|
|
|
|
|
if (cmode == 'Y') {
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
if (Trans.con.mode & CON_USER) {
|
2005-05-10 04:21:11 +00:00
|
|
|
stopConstraint(&Trans);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (G.qual == 0)
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
setUserConstraint(&Trans, (CON_AXIS1), "along %s Y");
|
2005-08-23 18:13:30 +00:00
|
|
|
else if ((G.qual == LR_SHIFTKEY) && ((Trans.flag & T_2D_EDIT)==0))
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
setUserConstraint(&Trans, (CON_AXIS0|CON_AXIS2), "locking %s Y");
|
2005-05-10 04:21:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (G.qual == 0)
|
|
|
|
|
setConstraint(&Trans, mati, (CON_AXIS1), "along global Y");
|
2005-08-23 18:13:30 +00:00
|
|
|
else if ((G.qual == LR_SHIFTKEY) && ((Trans.flag & T_2D_EDIT)==0))
|
2005-05-10 04:21:11 +00:00
|
|
|
setConstraint(&Trans, mati, (CON_AXIS0|CON_AXIS2), "locking global Y");
|
|
|
|
|
}
|
|
|
|
|
Trans.redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case ZKEY:
|
|
|
|
|
if ((Trans.flag & T_NO_CONSTRAINT)==0) {
|
|
|
|
|
if (cmode == 'Z') {
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
if (Trans.con.mode & CON_USER) {
|
2005-05-10 04:21:11 +00:00
|
|
|
stopConstraint(&Trans);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (G.qual == 0)
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
setUserConstraint(&Trans, (CON_AXIS2), "along %s Z");
|
2005-08-23 18:13:30 +00:00
|
|
|
else if ((G.qual == LR_SHIFTKEY) && ((Trans.flag & T_2D_EDIT)==0))
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
setUserConstraint(&Trans, (CON_AXIS0|CON_AXIS1), "locking %s Z");
|
2005-05-10 04:21:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-08-23 18:13:30 +00:00
|
|
|
else if ((Trans.flag & T_2D_EDIT)==0) {
|
2005-05-10 04:21:11 +00:00
|
|
|
if (G.qual == 0)
|
|
|
|
|
setConstraint(&Trans, mati, (CON_AXIS2), "along global Z");
|
|
|
|
|
else if (G.qual == LR_SHIFTKEY)
|
|
|
|
|
setConstraint(&Trans, mati, (CON_AXIS0|CON_AXIS1), "locking global Z");
|
|
|
|
|
}
|
|
|
|
|
Trans.redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case OKEY:
|
|
|
|
|
if (Trans.flag & T_PROP_EDIT && G.qual==LR_SHIFTKEY) {
|
|
|
|
|
G.scene->prop_mode = (G.scene->prop_mode+1)%6;
|
|
|
|
|
calculatePropRatio(&Trans);
|
|
|
|
|
Trans.redraw= 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case PADPLUSKEY:
|
2005-06-05 14:26:45 +00:00
|
|
|
if(G.qual & LR_ALTKEY && Trans.flag & T_PROP_EDIT) {
|
|
|
|
|
Trans.propsize*= 1.1f;
|
|
|
|
|
calculatePropRatio(&Trans);
|
|
|
|
|
}
|
|
|
|
|
Trans.redraw= 1;
|
|
|
|
|
break;
|
2005-06-11 02:17:25 +00:00
|
|
|
case PAGEUPKEY:
|
2005-06-05 14:26:45 +00:00
|
|
|
case WHEELDOWNMOUSE:
|
2005-05-10 04:21:11 +00:00
|
|
|
if(Trans.flag & T_PROP_EDIT) {
|
|
|
|
|
Trans.propsize*= 1.1f;
|
|
|
|
|
calculatePropRatio(&Trans);
|
|
|
|
|
}
|
|
|
|
|
else view_editmove(event);
|
|
|
|
|
Trans.redraw= 1;
|
|
|
|
|
break;
|
|
|
|
|
case PADMINUS:
|
2005-06-05 14:26:45 +00:00
|
|
|
if(G.qual & LR_ALTKEY && Trans.flag & T_PROP_EDIT) {
|
|
|
|
|
Trans.propsize*= 0.90909090f;
|
|
|
|
|
calculatePropRatio(&Trans);
|
|
|
|
|
}
|
|
|
|
|
Trans.redraw= 1;
|
|
|
|
|
break;
|
2005-06-11 02:17:25 +00:00
|
|
|
case PAGEDOWNKEY:
|
2005-06-05 14:26:45 +00:00
|
|
|
case WHEELUPMOUSE:
|
2005-05-10 04:21:11 +00:00
|
|
|
if(Trans.flag & T_PROP_EDIT) {
|
|
|
|
|
Trans.propsize*= 0.90909090f;
|
|
|
|
|
calculatePropRatio(&Trans);
|
|
|
|
|
}
|
|
|
|
|
else view_editmove(event);
|
|
|
|
|
Trans.redraw= 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Trans.redraw |= handleNumInput(&(Trans.num), event);
|
2006-10-25 23:57:00 +00:00
|
|
|
Trans.redraw |= handleSnapping(&Trans, event);
|
2005-05-10 04:21:11 +00:00
|
|
|
arrows_move_cursor(event);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
switch (event){
|
|
|
|
|
/* no redraw on release modifier keys! this makes sure you can assign the 'grid' still
|
|
|
|
|
after releasing modifer key */
|
|
|
|
|
case MIDDLEMOUSE:
|
|
|
|
|
if ((Trans.flag & T_NO_CONSTRAINT)==0) {
|
|
|
|
|
Trans.flag &= ~T_MMB_PRESSED;
|
|
|
|
|
postSelectConstraint(&Trans);
|
|
|
|
|
Trans.redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case LEFTMOUSE:
|
|
|
|
|
case RIGHTMOUSE:
|
2005-08-16 18:23:28 +00:00
|
|
|
if (Trans.context & CTX_TWEAK)
|
|
|
|
|
Trans.state = TRANS_CONFIRM;
|
2005-05-10 04:21:11 +00:00
|
|
|
break;
|
|
|
|
|
case LEFTSHIFTKEY:
|
|
|
|
|
case RIGHTSHIFTKEY:
|
|
|
|
|
/* shift is modifier for higher resolution transform */
|
|
|
|
|
Trans.flag &= ~T_SHIFT_MOD;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2007-03-24 13:38:50 +00:00
|
|
|
int calculateTransformCenter(int centerMode, float *vec)
|
2007-03-18 18:21:24 +00:00
|
|
|
{
|
2007-03-24 13:38:50 +00:00
|
|
|
int success = 1;
|
2007-03-18 18:21:24 +00:00
|
|
|
checkFirstTime();
|
|
|
|
|
|
|
|
|
|
Trans.state = TRANS_RUNNING;
|
|
|
|
|
|
|
|
|
|
Trans.context = CTX_NONE;
|
|
|
|
|
|
|
|
|
|
initTrans(&Trans); // internal data, mouse, vectors
|
|
|
|
|
|
|
|
|
|
createTransData(&Trans); // make TransData structs from selection
|
|
|
|
|
|
|
|
|
|
initTransModeFlags(&Trans, TFM_DUMMY); // modal settings in struct Trans
|
|
|
|
|
|
|
|
|
|
Trans.around = centerMode; // override userdefined mode
|
|
|
|
|
|
2007-03-24 13:38:50 +00:00
|
|
|
if (Trans.total == 0) {
|
|
|
|
|
success = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
success = 1;
|
|
|
|
|
|
|
|
|
|
calculateCenter(&Trans);
|
2007-03-18 18:21:24 +00:00
|
|
|
|
2007-03-24 13:38:50 +00:00
|
|
|
// Copy center from constraint center. Transform center can be local
|
|
|
|
|
VECCOPY(vec, Trans.con.center);
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-18 18:21:24 +00:00
|
|
|
postTrans(&Trans);
|
|
|
|
|
|
|
|
|
|
/* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
|
|
|
|
|
special_aftertrans_update(&Trans);
|
2007-03-24 13:38:50 +00:00
|
|
|
|
|
|
|
|
return success;
|
2007-03-18 18:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2005-05-10 04:21:11 +00:00
|
|
|
void initTransform(int mode, int context) {
|
2005-05-08 12:00:28 +00:00
|
|
|
/* added initialize, for external calls to set stuff in TransInfo, like undo string */
|
2005-05-15 05:44:11 +00:00
|
|
|
checkFirstTime();
|
2005-05-10 04:21:11 +00:00
|
|
|
|
|
|
|
|
Trans.state = TRANS_RUNNING;
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-27 21:25:15 +00:00
|
|
|
Trans.context = context;
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-02-25 17:40:03 +00:00
|
|
|
initTrans(&Trans); // internal data, mouse, vectors
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
if(Trans.spacetype==SPACE_VIEW3D) {
|
|
|
|
|
calc_manipulator_stats(curarea);
|
|
|
|
|
Mat3CpyMat4(Trans.spacemtx, G.vd->twmat);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Mat3One(Trans.spacemtx);
|
|
|
|
|
|
2005-03-31 21:02:35 +00:00
|
|
|
initTransModeFlags(&Trans, mode); // modal settings in struct Trans
|
|
|
|
|
|
2005-02-25 17:40:03 +00:00
|
|
|
createTransData(&Trans); // make TransData structs from selection
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2006-12-23 00:52:34 +00:00
|
|
|
initSnapping(&Trans); // Initialize snapping data AFTER mode flags
|
|
|
|
|
|
2005-04-03 21:52:11 +00:00
|
|
|
if (Trans.total == 0) {
|
|
|
|
|
postTrans(&Trans);
|
2005-02-14 02:53:36 +00:00
|
|
|
return;
|
2005-04-03 21:52:11 +00:00
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-02-22 16:50:04 +00:00
|
|
|
/* EVIL! posemode code can switch translation to rotate when 1 bone is selected. will be removed (ton) */
|
2005-02-25 17:40:03 +00:00
|
|
|
/* EVIL2: we gave as argument also texture space context bit... was cleared */
|
2005-02-22 16:50:04 +00:00
|
|
|
mode= Trans.mode;
|
|
|
|
|
|
2005-02-20 01:25:10 +00:00
|
|
|
calculatePropRatio(&Trans);
|
|
|
|
|
calculateCenter(&Trans);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
switch (mode) {
|
2005-02-20 01:25:10 +00:00
|
|
|
case TFM_TRANSLATION:
|
|
|
|
|
initTranslation(&Trans);
|
2005-02-14 02:53:36 +00:00
|
|
|
break;
|
2005-02-20 01:25:10 +00:00
|
|
|
case TFM_ROTATION:
|
|
|
|
|
initRotation(&Trans);
|
2005-02-14 02:53:36 +00:00
|
|
|
break;
|
2005-02-20 01:25:10 +00:00
|
|
|
case TFM_RESIZE:
|
|
|
|
|
initResize(&Trans);
|
2005-02-14 02:53:36 +00:00
|
|
|
break;
|
2005-02-20 01:25:10 +00:00
|
|
|
case TFM_TOSPHERE:
|
|
|
|
|
initToSphere(&Trans);
|
2005-02-14 02:53:36 +00:00
|
|
|
break;
|
2005-02-20 01:25:10 +00:00
|
|
|
case TFM_SHEAR:
|
|
|
|
|
initShear(&Trans);
|
2005-02-14 02:53:36 +00:00
|
|
|
break;
|
2005-03-08 17:29:33 +00:00
|
|
|
case TFM_WARP:
|
|
|
|
|
initWarp(&Trans);
|
|
|
|
|
break;
|
2005-03-13 20:17:39 +00:00
|
|
|
case TFM_SHRINKFATTEN:
|
|
|
|
|
initShrinkFatten(&Trans);
|
|
|
|
|
break;
|
2005-03-16 21:55:57 +00:00
|
|
|
case TFM_TILT:
|
|
|
|
|
initTilt(&Trans);
|
|
|
|
|
break;
|
2006-08-13 07:37:51 +00:00
|
|
|
case TFM_CURVE_SHRINKFATTEN:
|
|
|
|
|
initCurveShrinkFatten(&Trans);
|
|
|
|
|
break;
|
2005-03-19 12:17:06 +00:00
|
|
|
case TFM_TRACKBALL:
|
|
|
|
|
initTrackball(&Trans);
|
|
|
|
|
break;
|
2005-03-31 22:18:08 +00:00
|
|
|
case TFM_PUSHPULL:
|
|
|
|
|
initPushPull(&Trans);
|
|
|
|
|
break;
|
2005-04-04 23:37:15 +00:00
|
|
|
case TFM_CREASE:
|
|
|
|
|
initCrease(&Trans);
|
|
|
|
|
break;
|
2005-07-16 19:07:02 +00:00
|
|
|
case TFM_BONESIZE:
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
{ /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
|
|
|
|
|
bArmature *arm= Trans.poseobj->data;
|
|
|
|
|
if(arm->drawtype==ARM_ENVELOPE)
|
|
|
|
|
initBoneEnvelope(&Trans);
|
|
|
|
|
else
|
|
|
|
|
initBoneSize(&Trans);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case TFM_BONE_ENVELOPE:
|
|
|
|
|
initBoneEnvelope(&Trans);
|
2005-07-16 19:07:02 +00:00
|
|
|
break;
|
2006-12-03 19:54:27 +00:00
|
|
|
case TFM_BONE_ROLL:
|
|
|
|
|
initBoneRoll(&Trans);
|
|
|
|
|
break;
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
2005-05-10 04:21:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Transform()
|
|
|
|
|
{
|
|
|
|
|
short pmval[2] = {0, 0}, mval[2], val;
|
|
|
|
|
unsigned short event;
|
|
|
|
|
|
2005-05-12 19:17:12 +00:00
|
|
|
if(Trans.total==0) return; // added, can happen now! (ton)
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
// Emptying event queue
|
|
|
|
|
while( qtest() ) {
|
|
|
|
|
event= extern_qread(&val);
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-28 07:58:16 +00:00
|
|
|
Trans.redraw = 1; /* initial draw */
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-05-10 04:21:11 +00:00
|
|
|
while (Trans.state == TRANS_RUNNING) {
|
2005-03-21 00:39:09 +00:00
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
getmouseco_areawin(mval);
|
2005-02-22 16:50:04 +00:00
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
if (mval[0] != pmval[0] || mval[1] != pmval[1]) {
|
2005-10-02 19:31:32 +00:00
|
|
|
if (Trans.flag & T_MMB_PRESSED)
|
|
|
|
|
Trans.con.mode |= CON_SELECT;
|
2005-02-20 01:25:10 +00:00
|
|
|
Trans.redraw = 1;
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
2005-02-20 01:25:10 +00:00
|
|
|
if (Trans.redraw) {
|
2005-02-14 02:53:36 +00:00
|
|
|
pmval[0] = mval[0];
|
|
|
|
|
pmval[1] = mval[1];
|
|
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
selectConstraint(&Trans);
|
2005-02-20 01:25:10 +00:00
|
|
|
if (Trans.transform) {
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
Trans.transform(&Trans, mval); // calls recalcData()
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
2005-02-20 01:25:10 +00:00
|
|
|
Trans.redraw = 0;
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
2005-02-22 16:50:04 +00:00
|
|
|
|
|
|
|
|
/* essential for idling subloop */
|
|
|
|
|
if( qtest()==0) PIL_sleep_ms(2);
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
while( qtest() ) {
|
|
|
|
|
event= extern_qread(&val);
|
2005-05-10 04:21:11 +00:00
|
|
|
transformEvent(event, val);
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-02-25 17:40:03 +00:00
|
|
|
|
|
|
|
|
|
2005-11-03 21:13:20 +00:00
|
|
|
/* handle restoring objects */
|
|
|
|
|
if(Trans.state == TRANS_CANCEL)
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
restoreTransObjects(&Trans); // calls recalcData()
|
2005-02-22 16:50:04 +00:00
|
|
|
|
2005-08-16 10:17:02 +00:00
|
|
|
/* free data */
|
2005-02-20 01:25:10 +00:00
|
|
|
postTrans(&Trans);
|
2005-07-19 11:21:01 +00:00
|
|
|
|
2005-08-16 10:17:02 +00:00
|
|
|
/* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
|
|
|
|
|
special_aftertrans_update(&Trans);
|
2005-07-19 11:21:01 +00:00
|
|
|
|
2005-02-22 16:50:04 +00:00
|
|
|
/* send events out for redraws */
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawPost(&Trans);
|
2005-11-03 21:13:20 +00:00
|
|
|
|
|
|
|
|
/* Undo as last, certainly after special_trans_update! */
|
|
|
|
|
if(Trans.state == TRANS_CANCEL) {
|
|
|
|
|
if(Trans.undostr) BIF_undo_push(Trans.undostr);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if(Trans.undostr) BIF_undo_push(Trans.undostr);
|
|
|
|
|
else BIF_undo_push(transform_to_undostr(&Trans));
|
|
|
|
|
}
|
|
|
|
|
Trans.undostr= NULL;
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
/* ************************** Manipulator init and main **************************** */
|
|
|
|
|
|
2005-06-28 07:58:16 +00:00
|
|
|
void initManipulator(int mode)
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
{
|
2005-05-10 04:21:11 +00:00
|
|
|
Trans.state = TRANS_RUNNING;
|
|
|
|
|
|
2005-03-27 21:25:15 +00:00
|
|
|
Trans.context = CTX_NONE;
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
|
|
|
|
|
/* automatic switch to scaling bone envelopes */
|
|
|
|
|
if(mode==TFM_RESIZE && G.obedit && G.obedit->type==OB_ARMATURE) {
|
|
|
|
|
bArmature *arm= G.obedit->data;
|
|
|
|
|
if(arm->drawtype==ARM_ENVELOPE)
|
|
|
|
|
mode= TFM_BONE_ENVELOPE;
|
|
|
|
|
}
|
2005-03-27 21:25:15 +00:00
|
|
|
|
2005-03-31 21:02:35 +00:00
|
|
|
initTrans(&Trans); // internal data, mouse, vectors
|
|
|
|
|
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
initTransModeFlags(&Trans, mode); // modal settings in struct Trans
|
|
|
|
|
|
2005-03-19 20:27:13 +00:00
|
|
|
G.moving |= G_TRANSFORM_MANIP; // signal to draw manipuls while transform
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
createTransData(&Trans); // make TransData structs from selection
|
|
|
|
|
|
|
|
|
|
if (Trans.total == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2007-01-23 15:39:35 +00:00
|
|
|
initSnapping(&Trans); // Initialize snapping data AFTER mode flags
|
|
|
|
|
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
/* EVIL! posemode code can switch translation to rotate when 1 bone is selected. will be removed (ton) */
|
|
|
|
|
/* EVIL2: we gave as argument also texture space context bit... was cleared */
|
|
|
|
|
mode= Trans.mode;
|
|
|
|
|
|
|
|
|
|
calculatePropRatio(&Trans);
|
|
|
|
|
calculateCenter(&Trans);
|
|
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
|
case TFM_TRANSLATION:
|
|
|
|
|
initTranslation(&Trans);
|
|
|
|
|
break;
|
|
|
|
|
case TFM_ROTATION:
|
|
|
|
|
initRotation(&Trans);
|
|
|
|
|
break;
|
|
|
|
|
case TFM_RESIZE:
|
|
|
|
|
initResize(&Trans);
|
|
|
|
|
break;
|
2005-03-19 12:17:06 +00:00
|
|
|
case TFM_TRACKBALL:
|
|
|
|
|
initTrackball(&Trans);
|
|
|
|
|
break;
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
}
|
2005-03-21 18:25:17 +00:00
|
|
|
|
2005-03-19 12:17:06 +00:00
|
|
|
Trans.flag |= T_USES_MANIPULATOR;
|
2005-06-28 07:58:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ManipulatorTransform()
|
|
|
|
|
{
|
|
|
|
|
int mouse_moved = 0;
|
|
|
|
|
short pmval[2] = {0, 0}, mval[2], val;
|
|
|
|
|
unsigned short event;
|
|
|
|
|
|
|
|
|
|
if (Trans.total == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Trans.redraw = 1; /* initial draw */
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
|
2005-05-10 04:21:11 +00:00
|
|
|
while (Trans.state == TRANS_RUNNING) {
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
|
|
|
|
|
getmouseco_areawin(mval);
|
|
|
|
|
|
|
|
|
|
if (mval[0] != pmval[0] || mval[1] != pmval[1]) {
|
|
|
|
|
Trans.redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
if (Trans.redraw) {
|
|
|
|
|
pmval[0] = mval[0];
|
|
|
|
|
pmval[1] = mval[1];
|
|
|
|
|
|
|
|
|
|
//selectConstraint(&Trans); needed?
|
|
|
|
|
if (Trans.transform) {
|
|
|
|
|
Trans.transform(&Trans, mval);
|
|
|
|
|
}
|
|
|
|
|
Trans.redraw = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* essential for idling subloop */
|
|
|
|
|
if( qtest()==0) PIL_sleep_ms(2);
|
|
|
|
|
|
|
|
|
|
while( qtest() ) {
|
|
|
|
|
event= extern_qread(&val);
|
|
|
|
|
|
|
|
|
|
switch (event){
|
2005-05-04 15:13:25 +00:00
|
|
|
case MOUSEX:
|
|
|
|
|
case MOUSEY:
|
|
|
|
|
mouse_moved = 1;
|
|
|
|
|
break;
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
/* enforce redraw of transform when modifiers are used */
|
|
|
|
|
case LEFTCTRLKEY:
|
|
|
|
|
case RIGHTCTRLKEY:
|
2005-03-25 11:17:59 +00:00
|
|
|
if(val) Trans.redraw = 1;
|
|
|
|
|
break;
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
case LEFTSHIFTKEY:
|
|
|
|
|
case RIGHTSHIFTKEY:
|
2005-03-25 11:17:59 +00:00
|
|
|
/* shift is modifier for higher resolution transform, works nice to store this mouse position */
|
|
|
|
|
if(val) {
|
|
|
|
|
getmouseco_areawin(Trans.shiftmval);
|
|
|
|
|
Trans.flag |= T_SHIFT_MOD;
|
|
|
|
|
Trans.redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
else Trans.flag &= ~T_SHIFT_MOD;
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ESCKEY:
|
|
|
|
|
case RIGHTMOUSE:
|
2005-05-10 04:21:11 +00:00
|
|
|
Trans.state = TRANS_CANCEL;
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
break;
|
|
|
|
|
case LEFTMOUSE:
|
2005-05-04 15:13:25 +00:00
|
|
|
if(mouse_moved==0 && val==0) break;
|
|
|
|
|
// else we pass on event to next, which cancels
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
case SPACEKEY:
|
|
|
|
|
case PADENTER:
|
|
|
|
|
case RETKEY:
|
2005-05-10 04:21:11 +00:00
|
|
|
Trans.state = TRANS_CONFIRM;
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2005-03-22 15:01:36 +00:00
|
|
|
if(val) {
|
|
|
|
|
switch(event) {
|
|
|
|
|
case WHEELDOWNMOUSE:
|
|
|
|
|
case PADPLUSKEY:
|
2005-04-01 18:39:39 +00:00
|
|
|
if(Trans.flag & T_PROP_EDIT) {
|
2005-03-22 15:01:36 +00:00
|
|
|
Trans.propsize*= 1.1f;
|
|
|
|
|
calculatePropRatio(&Trans);
|
|
|
|
|
Trans.redraw= 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WHEELUPMOUSE:
|
|
|
|
|
case PADMINUS:
|
2005-04-01 18:39:39 +00:00
|
|
|
if(Trans.flag & T_PROP_EDIT) {
|
2005-03-22 15:01:36 +00:00
|
|
|
Trans.propsize*= 0.90909090f;
|
|
|
|
|
calculatePropRatio(&Trans);
|
|
|
|
|
Trans.redraw= 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-10 04:21:11 +00:00
|
|
|
if(Trans.state == TRANS_CANCEL) {
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
restoreTransObjects(&Trans);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* free data, reset vars */
|
|
|
|
|
postTrans(&Trans);
|
|
|
|
|
|
2005-07-19 11:21:01 +00:00
|
|
|
/* aftertrans does insert ipos and action channels, and clears base flags */
|
2005-08-16 10:17:02 +00:00
|
|
|
special_aftertrans_update(&Trans);
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
|
|
|
|
|
/* send events out for redraws */
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawPost(&Trans);
|
2006-11-27 19:54:16 +00:00
|
|
|
|
|
|
|
|
if(Trans.state != TRANS_CANCEL) {
|
|
|
|
|
BIF_undo_push(transform_to_undostr(&Trans));
|
|
|
|
|
}
|
|
|
|
|
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
}
|
|
|
|
|
|
Big Transform Manipulator Merge
*NOTE*: Some UI decision done in this commit will most likely be revised, all flame shall go in /dev/null. Constructive discussions of course welcomed.
This commit merges manipulator orientation selection back in "traditional" transform.
That's how it works:
- The dropdown in the 3D view header is always visible
- The orientation chosen will be used when choosing an axis with MMB and for the *second* key press of X,Y,Z
However, Local orientation doesn't use the one calculated by the manipulator. This is to ensure that multiple object local and armatures in pose still works as before.
- Alt-Space (to change the orientation) works during transform
New Transform orientation: View, using the view axis.
Fixes for the following bugs:
- Constraint projection code "jammed" if input vector was <0,0,0>, reported a couple of times on IRC. Thanks to Basse for the example file.
- Transform on texspace crashed on objects without texspace data (camera, lamp, ...). This was reported in tracker.
- Numinput with lock constraints didn't work correctly. Reported on elysiun
Probably some others that I'm forgetting
I also moved a couple of functions around in an attempt to make things clearer.
2005-07-24 06:25:00 +00:00
|
|
|
/* ************************** TRANSFORMATIONS **************************** */
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
|
2005-10-29 20:08:25 +00:00
|
|
|
static void protectedTransBits(short protectflag, float *vec)
|
|
|
|
|
{
|
|
|
|
|
if(protectflag & OB_LOCK_LOCX)
|
|
|
|
|
vec[0]= 0.0f;
|
|
|
|
|
if(protectflag & OB_LOCK_LOCY)
|
|
|
|
|
vec[1]= 0.0f;
|
|
|
|
|
if(protectflag & OB_LOCK_LOCZ)
|
|
|
|
|
vec[2]= 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void protectedSizeBits(short protectflag, float *size)
|
|
|
|
|
{
|
2006-06-12 20:01:18 +00:00
|
|
|
if(protectflag & OB_LOCK_SCALEX)
|
2005-10-29 20:08:25 +00:00
|
|
|
size[0]= 1.0f;
|
2006-06-12 20:01:18 +00:00
|
|
|
if(protectflag & OB_LOCK_SCALEY)
|
2005-10-29 20:08:25 +00:00
|
|
|
size[1]= 1.0f;
|
2006-06-12 20:01:18 +00:00
|
|
|
if(protectflag & OB_LOCK_SCALEZ)
|
2005-10-29 20:08:25 +00:00
|
|
|
size[2]= 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void protectedRotateBits(short protectflag, float *eul, float *oldeul)
|
|
|
|
|
{
|
|
|
|
|
if(protectflag & OB_LOCK_ROTX)
|
|
|
|
|
eul[0]= oldeul[0];
|
|
|
|
|
if(protectflag & OB_LOCK_ROTY)
|
|
|
|
|
eul[1]= oldeul[1];
|
|
|
|
|
if(protectflag & OB_LOCK_ROTZ)
|
|
|
|
|
eul[2]= oldeul[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void protectedQuaternionBits(short protectflag, float *quat, float *oldquat)
|
|
|
|
|
{
|
|
|
|
|
/* quaternions get limited with euler... */
|
|
|
|
|
/* this function only does the delta rotation */
|
|
|
|
|
|
|
|
|
|
if(protectflag) {
|
2005-11-21 10:45:58 +00:00
|
|
|
float eul[3], oldeul[3], quat1[4];
|
2005-10-29 20:08:25 +00:00
|
|
|
|
2005-11-21 10:45:58 +00:00
|
|
|
QUATCOPY(quat1, quat);
|
2005-10-29 20:08:25 +00:00
|
|
|
QuatToEul(quat, eul);
|
|
|
|
|
QuatToEul(oldquat, oldeul);
|
|
|
|
|
|
|
|
|
|
if(protectflag & OB_LOCK_ROTX)
|
|
|
|
|
eul[0]= oldeul[0];
|
|
|
|
|
if(protectflag & OB_LOCK_ROTY)
|
|
|
|
|
eul[1]= oldeul[1];
|
|
|
|
|
if(protectflag & OB_LOCK_ROTZ)
|
|
|
|
|
eul[2]= oldeul[2];
|
|
|
|
|
|
|
|
|
|
EulToQuat(eul, quat);
|
2005-11-21 10:45:58 +00:00
|
|
|
/* quaternions flip w sign to accumulate rotations correctly */
|
|
|
|
|
if( (quat1[0]<0.0f && quat[0]>0.0f) || (quat1[0]>0.0f && quat[0]<0.0f) ) {
|
|
|
|
|
QuatMulf(quat, -1.0f);
|
|
|
|
|
}
|
2005-10-29 20:08:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************** WARP *************************** */
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-08 17:29:33 +00:00
|
|
|
/* warp is done fully in view space */
|
|
|
|
|
void initWarp(TransInfo *t)
|
2005-02-20 19:00:00 +00:00
|
|
|
{
|
2005-03-08 17:29:33 +00:00
|
|
|
float max[3], min[3];
|
2005-02-14 02:53:36 +00:00
|
|
|
int i;
|
2005-03-08 17:29:33 +00:00
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
calculateCenterCursor(t);
|
2005-03-08 17:29:33 +00:00
|
|
|
t->idx_max = 0;
|
2005-02-14 02:53:36 +00:00
|
|
|
t->num.idx_max = 0;
|
2005-03-08 17:29:33 +00:00
|
|
|
t->transform = Warp;
|
|
|
|
|
t->snap[0] = 0.0f;
|
|
|
|
|
t->snap[1] = 5.0f;
|
|
|
|
|
t->snap[2] = 1.0f;
|
|
|
|
|
|
|
|
|
|
t->fac = (float)(t->center2d[0] - t->imval[0]);
|
|
|
|
|
|
|
|
|
|
/* we need min/max in view space */
|
2005-02-14 02:53:36 +00:00
|
|
|
for(i = 0; i < t->total; i++) {
|
2005-03-21 00:39:09 +00:00
|
|
|
float center[3];
|
|
|
|
|
VECCOPY(center, t->data[i].center);
|
|
|
|
|
Mat3MulVecfl(t->data[i].mtx, center);
|
2005-08-23 18:13:30 +00:00
|
|
|
Mat4MulVecfl(t->viewmat, center);
|
|
|
|
|
VecSubf(center, center, t->viewmat[3]);
|
2005-03-08 17:29:33 +00:00
|
|
|
if (i)
|
2005-03-21 00:39:09 +00:00
|
|
|
MinMax3(min, max, center);
|
2005-02-14 02:53:36 +00:00
|
|
|
else {
|
2005-03-21 00:39:09 +00:00
|
|
|
VECCOPY(max, center);
|
|
|
|
|
VECCOPY(min, center);
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-03-13 02:15:32 +00:00
|
|
|
|
2005-03-12 20:34:02 +00:00
|
|
|
t->center[0]= (min[0]+max[0])/2.0f;
|
|
|
|
|
t->center[1]= (min[1]+max[1])/2.0f;
|
|
|
|
|
t->center[2]= (min[2]+max[2])/2.0f;
|
2005-03-08 17:29:33 +00:00
|
|
|
|
2005-03-12 20:34:02 +00:00
|
|
|
t->val= (max[0]-min[0])/2.0f; // t->val is free variable
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-03-08 17:29:33 +00:00
|
|
|
int Warp(TransInfo *t, short mval[2])
|
2005-02-20 19:00:00 +00:00
|
|
|
{
|
2005-03-08 17:29:33 +00:00
|
|
|
TransData *td = t->data;
|
2005-03-21 00:39:09 +00:00
|
|
|
float vec[3], circumfac, dist, phi0, co, si, *curs, cursor[3], gcursor[3];
|
2005-03-08 17:29:33 +00:00
|
|
|
int i;
|
|
|
|
|
char str[50];
|
|
|
|
|
|
|
|
|
|
curs= give_cursor();
|
2005-03-21 00:39:09 +00:00
|
|
|
/*
|
|
|
|
|
* gcursor is the one used for helpline.
|
|
|
|
|
* It has to be in the same space as the drawing loop
|
|
|
|
|
* (that means it needs to be in the object's space when in edit mode and
|
|
|
|
|
* in global space in object mode)
|
|
|
|
|
*
|
|
|
|
|
* cursor is used for calculations.
|
|
|
|
|
* It needs to be in view space, but we need to take object's offset
|
|
|
|
|
* into account if in Edit mode.
|
|
|
|
|
*/
|
2005-03-08 17:29:33 +00:00
|
|
|
VECCOPY(cursor, curs);
|
2005-03-21 00:39:09 +00:00
|
|
|
VECCOPY(gcursor, cursor);
|
|
|
|
|
if (t->flag & T_EDIT) {
|
|
|
|
|
VecSubf(cursor, cursor, G.obedit->obmat[3]);
|
|
|
|
|
VecSubf(gcursor, gcursor, G.obedit->obmat[3]);
|
|
|
|
|
Mat3MulVecfl(t->data->smtx, gcursor);
|
|
|
|
|
}
|
2005-08-23 18:13:30 +00:00
|
|
|
Mat4MulVecfl(t->viewmat, cursor);
|
|
|
|
|
VecSubf(cursor, cursor, t->viewmat[3]);
|
2005-03-21 00:39:09 +00:00
|
|
|
|
2007-01-16 18:55:15 +00:00
|
|
|
// amount of degrees for warp
|
|
|
|
|
circumfac= 360.0f * InputHorizontalRatio(t, mval);
|
2005-03-08 17:29:33 +00:00
|
|
|
|
|
|
|
|
snapGrid(t, &circumfac);
|
|
|
|
|
applyNumInput(&t->num, &circumfac);
|
|
|
|
|
|
|
|
|
|
/* header print for NumInput */
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
char c[20];
|
|
|
|
|
|
|
|
|
|
outputNumInput(&(t->num), c);
|
|
|
|
|
|
|
|
|
|
sprintf(str, "Warp: %s", c);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* default header print */
|
|
|
|
|
sprintf(str, "Warp: %.3f", circumfac);
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-12 23:15:26 +00:00
|
|
|
circumfac*= (float)(-M_PI/360.0);
|
2005-03-08 17:29:33 +00:00
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
2005-03-13 02:15:32 +00:00
|
|
|
float loc[3];
|
2005-03-08 17:29:33 +00:00
|
|
|
if (td->flag & TD_NOACTION)
|
2005-03-15 17:31:46 +00:00
|
|
|
break;
|
2005-03-13 02:15:32 +00:00
|
|
|
|
|
|
|
|
/* translate point to centre, rotate in such a way that outline==distance */
|
|
|
|
|
|
|
|
|
|
VECCOPY(vec, td->iloc);
|
2005-03-21 00:39:09 +00:00
|
|
|
Mat3MulVecfl(td->mtx, vec);
|
2005-08-23 18:13:30 +00:00
|
|
|
Mat4MulVecfl(t->viewmat, vec);
|
|
|
|
|
VecSubf(vec, vec, t->viewmat[3]);
|
2005-03-13 02:15:32 +00:00
|
|
|
|
|
|
|
|
dist= vec[0]-cursor[0];
|
2005-03-21 00:39:09 +00:00
|
|
|
|
2005-03-13 02:15:32 +00:00
|
|
|
phi0= (circumfac*dist/t->val); // t->val is X dimension projected boundbox
|
|
|
|
|
|
|
|
|
|
vec[1]= (vec[1]-cursor[1]);
|
|
|
|
|
|
|
|
|
|
co= (float)cos(phi0);
|
|
|
|
|
si= (float)sin(phi0);
|
2005-03-21 00:39:09 +00:00
|
|
|
loc[0]= -si*vec[1]+cursor[0];
|
|
|
|
|
loc[1]= co*vec[1]+cursor[1];
|
2005-03-13 02:15:32 +00:00
|
|
|
loc[2]= vec[2];
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
Mat4MulVecfl(t->viewinv, loc);
|
|
|
|
|
VecSubf(loc, loc, t->viewinv[3]);
|
2005-03-21 00:39:09 +00:00
|
|
|
Mat3MulVecfl(td->smtx, loc);
|
2005-03-13 02:15:32 +00:00
|
|
|
|
|
|
|
|
VecSubf(loc, loc, td->iloc);
|
|
|
|
|
VecMulf(loc, td->factor);
|
|
|
|
|
VecAddf(td->loc, td->iloc, loc);
|
2005-03-08 17:29:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-03-08 17:29:33 +00:00
|
|
|
|
2005-08-16 10:17:02 +00:00
|
|
|
helpline(t, gcursor);
|
2005-03-08 17:29:33 +00:00
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************** SHEAR *************************** */
|
|
|
|
|
|
2005-02-20 19:00:00 +00:00
|
|
|
void initShear(TransInfo *t)
|
|
|
|
|
{
|
2005-03-04 00:07:16 +00:00
|
|
|
t->idx_max = 0;
|
2005-02-14 02:53:36 +00:00
|
|
|
t->num.idx_max = 0;
|
2005-03-04 00:07:16 +00:00
|
|
|
t->snap[0] = 0.0f;
|
2005-03-23 14:24:43 +00:00
|
|
|
t->snap[1] = 0.1f;
|
2005-03-04 00:07:16 +00:00
|
|
|
t->snap[2] = t->snap[1] * 0.1f;
|
2005-02-14 02:53:36 +00:00
|
|
|
t->transform = Shear;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-20 19:00:00 +00:00
|
|
|
int Shear(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
2005-03-08 17:29:33 +00:00
|
|
|
TransData *td = t->data;
|
2005-02-14 02:53:36 +00:00
|
|
|
float vec[3];
|
2005-02-23 14:19:41 +00:00
|
|
|
float smat[3][3], tmat[3][3], totmat[3][3], persmat[3][3], persinv[3][3];
|
2005-02-14 02:53:36 +00:00
|
|
|
float value;
|
|
|
|
|
int i;
|
|
|
|
|
char str[50];
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
Mat3CpyMat4(persmat, t->viewmat);
|
2005-02-14 02:53:36 +00:00
|
|
|
Mat3Inv(persinv, persmat);
|
|
|
|
|
|
2006-02-12 21:09:18 +00:00
|
|
|
value = 0.05f * InputHorizontalAbsolute(t, mval);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-04 00:07:16 +00:00
|
|
|
snapGrid(t, &value);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
applyNumInput(&t->num, &value);
|
|
|
|
|
|
|
|
|
|
/* header print for NumInput */
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
char c[20];
|
|
|
|
|
|
|
|
|
|
outputNumInput(&(t->num), c);
|
|
|
|
|
|
|
|
|
|
sprintf(str, "Shear: %s %s", c, t->proptext);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* default header print */
|
|
|
|
|
sprintf(str, "Shear: %.3f %s", value, t->proptext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Mat3One(smat);
|
|
|
|
|
smat[1][0] = value;
|
|
|
|
|
Mat3MulMat3(tmat, smat, persmat);
|
|
|
|
|
Mat3MulMat3(totmat, persinv, tmat);
|
|
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
2005-03-15 17:31:46 +00:00
|
|
|
break;
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
if (G.obedit) {
|
2005-02-18 01:34:38 +00:00
|
|
|
float mat3[3][3];
|
2005-02-23 02:23:50 +00:00
|
|
|
Mat3MulMat3(mat3, totmat, td->mtx);
|
2005-02-18 01:34:38 +00:00
|
|
|
Mat3MulMat3(tmat, td->smtx, mat3);
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Mat3CpyMat3(tmat, totmat);
|
|
|
|
|
}
|
2005-02-23 02:23:50 +00:00
|
|
|
VecSubf(vec, td->center, t->center);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
Mat3MulVecfl(tmat, vec);
|
|
|
|
|
|
|
|
|
|
VecAddf(vec, vec, t->center);
|
2005-02-23 02:23:50 +00:00
|
|
|
VecSubf(vec, vec, td->center);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
VecMulf(vec, td->factor);
|
|
|
|
|
|
|
|
|
|
VecAddf(td->loc, td->iloc, vec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-08-16 10:17:02 +00:00
|
|
|
helpline (t, t->center);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************** RESIZE *************************** */
|
|
|
|
|
|
2005-02-20 19:00:00 +00:00
|
|
|
void initResize(TransInfo *t)
|
|
|
|
|
{
|
2006-05-29 13:01:51 +00:00
|
|
|
t->fac = (float)sqrt(
|
2005-02-14 02:53:36 +00:00
|
|
|
(
|
2006-05-29 13:01:51 +00:00
|
|
|
((float)(t->center2d[1] - t->imval[1]))*((float)(t->center2d[1] - t->imval[1]))
|
2005-02-14 02:53:36 +00:00
|
|
|
+
|
2006-05-29 13:01:51 +00:00
|
|
|
((float)(t->center2d[0] - t->imval[0]))*((float)(t->center2d[0] - t->imval[0]))
|
2005-02-14 02:53:36 +00:00
|
|
|
) );
|
|
|
|
|
|
2005-03-21 17:36:21 +00:00
|
|
|
if(t->fac==0.0f) t->fac= 1.0f; // prevent Inf
|
2005-03-19 12:17:06 +00:00
|
|
|
|
2005-03-04 00:07:16 +00:00
|
|
|
t->idx_max = 2;
|
2005-02-14 02:53:36 +00:00
|
|
|
t->num.idx_max = 2;
|
2005-03-04 00:07:16 +00:00
|
|
|
t->snap[0] = 0.0f;
|
2005-03-23 14:24:43 +00:00
|
|
|
t->snap[1] = 0.1f;
|
2005-03-04 00:07:16 +00:00
|
|
|
t->snap[2] = t->snap[1] * 0.1f;
|
2005-02-14 02:53:36 +00:00
|
|
|
t->transform = Resize;
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-14 20:10:22 +00:00
|
|
|
static void headerResize(TransInfo *t, float vec[3], char *str) {
|
2005-03-12 20:34:02 +00:00
|
|
|
char tvec[60];
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
outputNumInput(&(t->num), tvec);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sprintf(&tvec[0], "%.4f", vec[0]);
|
|
|
|
|
sprintf(&tvec[20], "%.4f", vec[1]);
|
|
|
|
|
sprintf(&tvec[40], "%.4f", vec[2]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (t->con.mode & CON_APPLY) {
|
|
|
|
|
switch(t->num.idx_max) {
|
|
|
|
|
case 0:
|
2006-06-15 04:13:26 +00:00
|
|
|
sprintf(str, "Scale: %s%s %s", &tvec[0], t->con.text, t->proptext);
|
2005-03-12 20:34:02 +00:00
|
|
|
break;
|
|
|
|
|
case 1:
|
2006-06-15 04:13:26 +00:00
|
|
|
sprintf(str, "Scale: %s : %s%s %s", &tvec[0], &tvec[20], t->con.text, t->proptext);
|
2005-03-12 20:34:02 +00:00
|
|
|
break;
|
|
|
|
|
case 2:
|
2006-06-15 04:13:26 +00:00
|
|
|
sprintf(str, "Scale: %s : %s : %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
|
2005-03-12 20:34:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2005-08-23 18:13:30 +00:00
|
|
|
if (t->flag & T_2D_EDIT)
|
2006-06-15 04:13:26 +00:00
|
|
|
sprintf(str, "Scale X: %s Y: %s%s %s", &tvec[0], &tvec[20], t->con.text, t->proptext);
|
2005-08-23 18:13:30 +00:00
|
|
|
else
|
2006-06-15 04:13:26 +00:00
|
|
|
sprintf(str, "Scale X: %s Y: %s Z: %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
|
2005-03-12 20:34:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-07 21:04:55 +00:00
|
|
|
#define SIGN(a) (a<-FLT_EPSILON?1:a>FLT_EPSILON?2:3)
|
|
|
|
|
#define VECSIGNFLIP(a, b) ((SIGN(a[0]) & SIGN(b[0]))==0 || (SIGN(a[1]) & SIGN(b[1]))==0 || (SIGN(a[2]) & SIGN(b[2]))==0)
|
|
|
|
|
|
|
|
|
|
/* smat is reference matrix, only scaled */
|
|
|
|
|
static void TransMat3ToSize( float mat[][3], float smat[][3], float *size)
|
|
|
|
|
{
|
|
|
|
|
float vec[3];
|
|
|
|
|
|
|
|
|
|
VecCopyf(vec, mat[0]);
|
|
|
|
|
size[0]= Normalise(vec);
|
|
|
|
|
VecCopyf(vec, mat[1]);
|
|
|
|
|
size[1]= Normalise(vec);
|
|
|
|
|
VecCopyf(vec, mat[2]);
|
|
|
|
|
size[2]= Normalise(vec);
|
|
|
|
|
|
|
|
|
|
/* first tried with dotproduct... but the sign flip is crucial */
|
|
|
|
|
if( VECSIGNFLIP(mat[0], smat[0]) ) size[0]= -size[0];
|
|
|
|
|
if( VECSIGNFLIP(mat[1], smat[1]) ) size[1]= -size[1];
|
|
|
|
|
if( VECSIGNFLIP(mat[2], smat[2]) ) size[2]= -size[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-06-04 16:22:50 +00:00
|
|
|
static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
|
2005-05-04 00:37:11 +00:00
|
|
|
float tmat[3][3], smat[3][3], center[3];
|
|
|
|
|
float vec[3];
|
|
|
|
|
|
|
|
|
|
if (t->flag & T_EDIT) {
|
|
|
|
|
Mat3MulMat3(smat, mat, td->mtx);
|
|
|
|
|
Mat3MulMat3(tmat, td->smtx, smat);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Mat3CpyMat3(tmat, mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (t->con.applySize) {
|
|
|
|
|
t->con.applySize(t, td, tmat);
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-07 21:04:55 +00:00
|
|
|
/* local constraint shouldn't alter center */
|
2005-08-23 18:13:30 +00:00
|
|
|
if (t->around == V3D_LOCAL) {
|
2005-05-16 23:23:19 +00:00
|
|
|
if (t->flag & T_OBJECT) {
|
2006-03-08 11:07:49 +00:00
|
|
|
VECCOPY(center, td->center);
|
|
|
|
|
}
|
|
|
|
|
else if (t->flag & T_EDIT) {
|
|
|
|
|
|
|
|
|
|
if(G.vd->around==V3D_LOCAL && (G.scene->selectmode & SCE_SELECT_FACE)) {
|
|
|
|
|
VECCOPY(center, td->center);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
VECCOPY(center, t->center);
|
|
|
|
|
}
|
2005-05-16 23:23:19 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2006-03-08 11:07:49 +00:00
|
|
|
VECCOPY(center, t->center);
|
2005-05-16 23:23:19 +00:00
|
|
|
}
|
2005-05-04 00:37:11 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
VECCOPY(center, t->center);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (td->ext) {
|
|
|
|
|
float fsize[3];
|
|
|
|
|
|
2006-05-14 17:02:56 +00:00
|
|
|
if (t->flag & (T_OBJECT|T_TEXTURE)) {
|
2005-05-04 00:37:11 +00:00
|
|
|
float obsizemat[3][3];
|
|
|
|
|
// Reorient the size mat to fit the oriented object.
|
|
|
|
|
Mat3MulMat3(obsizemat, tmat, td->axismtx);
|
|
|
|
|
//printmatrix3("obsizemat", obsizemat);
|
2005-05-07 21:04:55 +00:00
|
|
|
TransMat3ToSize(obsizemat, td->axismtx, fsize);
|
2005-05-04 00:37:11 +00:00
|
|
|
//printvecf("fsize", fsize);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Mat3ToSize(tmat, fsize);
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-29 20:08:25 +00:00
|
|
|
protectedSizeBits(td->protectflag, fsize);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
|
2005-05-04 00:37:11 +00:00
|
|
|
/* handle ipokeys? */
|
|
|
|
|
if(td->tdi) {
|
|
|
|
|
TransDataIpokey *tdi= td->tdi;
|
|
|
|
|
/* calculate delta size (equal for size and dsize) */
|
|
|
|
|
|
|
|
|
|
vec[0]= (tdi->oldsize[0])*(fsize[0] -1.0f) * td->factor;
|
|
|
|
|
vec[1]= (tdi->oldsize[1])*(fsize[1] -1.0f) * td->factor;
|
|
|
|
|
vec[2]= (tdi->oldsize[2])*(fsize[2] -1.0f) * td->factor;
|
|
|
|
|
|
|
|
|
|
add_tdi_poin(tdi->sizex, tdi->oldsize, vec[0]);
|
|
|
|
|
add_tdi_poin(tdi->sizey, tdi->oldsize+1, vec[1]);
|
|
|
|
|
add_tdi_poin(tdi->sizez, tdi->oldsize+2, vec[2]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)){
|
|
|
|
|
/* scale val and reset size */
|
|
|
|
|
*td->val = td->ival * fsize[0] * td->factor;
|
|
|
|
|
|
|
|
|
|
td->ext->size[0] = td->ext->isize[0];
|
|
|
|
|
td->ext->size[1] = td->ext->isize[1];
|
|
|
|
|
td->ext->size[2] = td->ext->isize[2];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Reset val if SINGLESIZE but using a constraint */
|
|
|
|
|
if (td->flag & TD_SINGLESIZE)
|
|
|
|
|
*td->val = td->ival;
|
|
|
|
|
|
|
|
|
|
td->ext->size[0] = td->ext->isize[0] * (fsize[0]) * td->factor;
|
|
|
|
|
td->ext->size[1] = td->ext->isize[1] * (fsize[1]) * td->factor;
|
|
|
|
|
td->ext->size[2] = td->ext->isize[2] * (fsize[2]) * td->factor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* For individual element center, Editmode need to use iloc */
|
2005-08-23 18:13:30 +00:00
|
|
|
if (t->flag & T_POINTS)
|
2005-05-04 00:37:11 +00:00
|
|
|
VecSubf(vec, td->iloc, center);
|
|
|
|
|
else
|
|
|
|
|
VecSubf(vec, td->center, center);
|
|
|
|
|
|
|
|
|
|
Mat3MulVecfl(tmat, vec);
|
|
|
|
|
|
|
|
|
|
VecAddf(vec, vec, center);
|
2005-08-23 18:13:30 +00:00
|
|
|
if (t->flag & T_POINTS)
|
2005-05-04 00:37:11 +00:00
|
|
|
VecSubf(vec, vec, td->iloc);
|
|
|
|
|
else
|
|
|
|
|
VecSubf(vec, vec, td->center);
|
|
|
|
|
|
|
|
|
|
VecMulf(vec, td->factor);
|
|
|
|
|
|
|
|
|
|
if (t->flag & T_OBJECT) {
|
|
|
|
|
Mat3MulVecfl(td->smtx, vec);
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-29 20:08:25 +00:00
|
|
|
protectedTransBits(td->protectflag, vec);
|
|
|
|
|
|
2005-05-29 23:21:56 +00:00
|
|
|
if(td->tdi) {
|
|
|
|
|
TransDataIpokey *tdi= td->tdi;
|
|
|
|
|
add_tdi_poin(tdi->locx, tdi->oldloc, vec[0]);
|
|
|
|
|
add_tdi_poin(tdi->locy, tdi->oldloc+1, vec[1]);
|
|
|
|
|
add_tdi_poin(tdi->locz, tdi->oldloc+2, vec[2]);
|
|
|
|
|
}
|
|
|
|
|
else VecAddf(td->loc, td->iloc, vec);
|
2005-05-04 00:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-20 19:00:00 +00:00
|
|
|
int Resize(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
2005-08-23 18:13:30 +00:00
|
|
|
TransData *td;
|
2005-05-04 00:37:11 +00:00
|
|
|
float size[3], mat[3][3];
|
2005-02-14 02:53:36 +00:00
|
|
|
float ratio;
|
|
|
|
|
int i;
|
2006-07-08 14:24:57 +00:00
|
|
|
char str[200];
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-19 12:17:06 +00:00
|
|
|
/* for manipulator, center handle, the scaling can't be done relative to center */
|
|
|
|
|
if( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0) {
|
2005-03-24 09:37:06 +00:00
|
|
|
ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1]))/100.0f;
|
2005-03-19 12:17:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2005-08-16 17:37:42 +00:00
|
|
|
ratio = InputScaleRatio(t, mval);
|
2005-03-27 18:17:48 +00:00
|
|
|
|
|
|
|
|
/* flip scale, but not for manipulator center handle */
|
2005-03-27 19:54:18 +00:00
|
|
|
if ((t->center2d[0] - mval[0]) * (t->center2d[0] - t->imval[0]) +
|
|
|
|
|
(t->center2d[1] - mval[1]) * (t->center2d[1] - t->imval[1]) < 0)
|
|
|
|
|
ratio *= -1.0f;
|
2005-03-19 12:17:06 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
size[0] = size[1] = size[2] = ratio;
|
|
|
|
|
|
2005-03-04 00:07:16 +00:00
|
|
|
snapGrid(t, size);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-12 20:34:02 +00:00
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
applyNumInput(&t->num, size);
|
|
|
|
|
constraintNumInput(t, size);
|
|
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-04 00:07:16 +00:00
|
|
|
SizeToMat3(size, mat);
|
|
|
|
|
|
|
|
|
|
if (t->con.applySize) {
|
|
|
|
|
t->con.applySize(t, NULL, mat);
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-19 12:17:06 +00:00
|
|
|
Mat3CpyMat3(t->mat, mat); // used in manipulator
|
|
|
|
|
|
2005-03-12 20:34:02 +00:00
|
|
|
headerResize(t, size, str);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
for(i = 0, td=t->data; i < t->total; i++, td++) {
|
2005-02-14 02:53:36 +00:00
|
|
|
if (td->flag & TD_NOACTION)
|
2005-03-15 17:31:46 +00:00
|
|
|
break;
|
2005-05-04 00:37:11 +00:00
|
|
|
|
|
|
|
|
ElementResize(t, td, mat);
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
/* evil hack - redo resize if cliiping needeed */
|
|
|
|
|
if (t->flag & T_CLIP_UV && clipUVTransform(t, size, 1)) {
|
|
|
|
|
SizeToMat3(size, mat);
|
|
|
|
|
|
|
|
|
|
if (t->con.applySize)
|
|
|
|
|
t->con.applySize(t, NULL, mat);
|
|
|
|
|
|
|
|
|
|
for(i = 0, td=t->data; i < t->total; i++, td++)
|
|
|
|
|
ElementResize(t, td, mat);
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-08-16 10:17:02 +00:00
|
|
|
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************** TOSPHERE *************************** */
|
|
|
|
|
|
2005-02-20 19:00:00 +00:00
|
|
|
void initToSphere(TransInfo *t)
|
|
|
|
|
{
|
2005-02-14 02:53:36 +00:00
|
|
|
TransData *td = t->data;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
// Calculate average radius
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
t->val += VecLenf(t->center, td->iloc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t->val /= (float)t->total;
|
|
|
|
|
|
2005-03-04 00:07:16 +00:00
|
|
|
t->idx_max = 0;
|
2005-02-14 02:53:36 +00:00
|
|
|
t->num.idx_max = 0;
|
2005-03-04 00:07:16 +00:00
|
|
|
t->snap[0] = 0.0f;
|
2005-03-23 14:24:43 +00:00
|
|
|
t->snap[1] = 0.1f;
|
2005-03-04 00:07:16 +00:00
|
|
|
t->snap[2] = t->snap[1] * 0.1f;
|
2005-02-14 02:53:36 +00:00
|
|
|
t->transform = ToSphere;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-02-20 19:00:00 +00:00
|
|
|
int ToSphere(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
2005-02-14 02:53:36 +00:00
|
|
|
float vec[3];
|
|
|
|
|
float ratio, radius;
|
|
|
|
|
int i;
|
2006-12-03 18:30:34 +00:00
|
|
|
char str[64];
|
2005-02-14 02:53:36 +00:00
|
|
|
TransData *td = t->data;
|
|
|
|
|
|
2005-08-16 17:37:42 +00:00
|
|
|
ratio = InputHorizontalRatio(t, mval);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-04 00:07:16 +00:00
|
|
|
snapGrid(t, &ratio);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
applyNumInput(&t->num, &ratio);
|
|
|
|
|
|
2005-08-16 17:37:42 +00:00
|
|
|
if (ratio < 0)
|
|
|
|
|
ratio = 0.0f;
|
|
|
|
|
else if (ratio > 1)
|
2005-02-14 02:53:36 +00:00
|
|
|
ratio = 1.0f;
|
|
|
|
|
|
|
|
|
|
/* header print for NumInput */
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
char c[20];
|
|
|
|
|
|
|
|
|
|
outputNumInput(&(t->num), c);
|
|
|
|
|
|
|
|
|
|
sprintf(str, "To Sphere: %s %s", c, t->proptext);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* default header print */
|
|
|
|
|
sprintf(str, "To Sphere: %.4f %s", ratio, t->proptext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
float tratio;
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
2005-03-15 17:31:46 +00:00
|
|
|
break;
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
VecSubf(vec, td->iloc, t->center);
|
|
|
|
|
|
|
|
|
|
radius = Normalise(vec);
|
|
|
|
|
|
2005-08-16 17:37:42 +00:00
|
|
|
tratio = ratio * td->factor;
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-08-16 17:37:42 +00:00
|
|
|
VecMulf(vec, radius * (1.0f - tratio) + t->val * tratio);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
VecAddf(td->loc, t->center, vec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************** ROTATION *************************** */
|
|
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
|
|
|
|
|
void initRotation(TransInfo *t)
|
2005-02-20 19:00:00 +00:00
|
|
|
{
|
2005-03-20 02:00:16 +00:00
|
|
|
t->idx_max = 0;
|
|
|
|
|
t->num.idx_max = 0;
|
|
|
|
|
t->snap[0] = 0.0f;
|
2005-03-30 23:19:42 +00:00
|
|
|
t->snap[1] = (float)((5.0/180)*M_PI);
|
2005-03-20 02:00:16 +00:00
|
|
|
t->snap[2] = t->snap[1] * 0.2f;
|
|
|
|
|
t->fac = 0;
|
|
|
|
|
t->transform = Rotation;
|
|
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3]) {
|
|
|
|
|
float vec[3], totmat[3][3], smat[3][3];
|
2005-03-29 10:03:30 +00:00
|
|
|
float eul[3], fmat[3][3], quat[4];
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
if (t->flag & T_POINTS) {
|
2005-03-20 02:00:16 +00:00
|
|
|
Mat3MulMat3(totmat, mat, td->mtx);
|
|
|
|
|
Mat3MulMat3(smat, td->smtx, totmat);
|
2005-03-19 22:03:14 +00:00
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
VecSubf(vec, td->iloc, t->center);
|
|
|
|
|
Mat3MulVecfl(smat, vec);
|
2005-03-19 22:03:14 +00:00
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
VecAddf(td->loc, vec, t->center);
|
2005-03-29 10:03:30 +00:00
|
|
|
|
|
|
|
|
if(td->flag & TD_USEQUAT) {
|
|
|
|
|
Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
|
|
|
|
|
Mat3ToQuat(fmat, quat); // Actual transform
|
|
|
|
|
QuatMul(td->ext->quat, quat, td->ext->iquat);
|
|
|
|
|
}
|
2005-03-20 02:00:16 +00:00
|
|
|
}
|
2007-02-07 23:28:33 +00:00
|
|
|
/**
|
|
|
|
|
* HACK WARNING
|
|
|
|
|
*
|
|
|
|
|
* This is some VERY ugly special case to deal with pose mode.
|
|
|
|
|
*
|
|
|
|
|
* The problem is that mtx and smtx include each bone orientation.
|
|
|
|
|
*
|
|
|
|
|
* That is needed to rotate each bone properly, HOWEVER, to calculate
|
|
|
|
|
* the translation component, we only need the actual armature object's
|
|
|
|
|
* matrix (and inverse). That is not all though. Once the proper translation
|
|
|
|
|
* has been computed, it has to be converted back into the bone's space.
|
|
|
|
|
*/
|
|
|
|
|
else if (t->flag & T_POSE) {
|
|
|
|
|
float pmtx[3][3], imtx[3][3];
|
|
|
|
|
|
|
|
|
|
// Extract and invert armature object matrix
|
|
|
|
|
Mat3CpyMat4(pmtx, t->poseobj->obmat);
|
|
|
|
|
Mat3Inv(imtx, pmtx);
|
|
|
|
|
|
|
|
|
|
VecSubf(vec, td->center, t->center);
|
|
|
|
|
|
|
|
|
|
Mat3MulVecfl(pmtx, vec); // To Global space
|
|
|
|
|
Mat3MulVecfl(mat, vec); // Applying rotation
|
|
|
|
|
Mat3MulVecfl(imtx, vec); // To Local space
|
|
|
|
|
|
|
|
|
|
VecAddf(vec, vec, t->center);
|
|
|
|
|
/* vec now is the location where the object has to be */
|
|
|
|
|
|
|
|
|
|
VecSubf(vec, vec, td->center); // Translation needed from the initial location
|
|
|
|
|
|
|
|
|
|
Mat3MulVecfl(pmtx, vec); // To Global space
|
|
|
|
|
Mat3MulVecfl(td->smtx, vec);// To Pose space
|
|
|
|
|
|
|
|
|
|
protectedTransBits(td->protectflag, vec);
|
|
|
|
|
|
|
|
|
|
VecAddf(td->loc, td->iloc, vec);
|
|
|
|
|
|
|
|
|
|
/* rotation */
|
|
|
|
|
if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
|
|
|
|
|
Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
|
|
Mat3ToQuat(fmat, quat); // Actual transform
|
|
|
|
|
|
|
|
|
|
QuatMul(td->ext->quat, quat, td->ext->iquat);
|
|
|
|
|
/* this function works on end result */
|
|
|
|
|
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-03-20 02:00:16 +00:00
|
|
|
else {
|
|
|
|
|
/* translation */
|
2005-05-29 23:21:56 +00:00
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
VecSubf(vec, td->center, t->center);
|
|
|
|
|
Mat3MulVecfl(mat, vec);
|
|
|
|
|
VecAddf(vec, vec, t->center);
|
|
|
|
|
/* vec now is the location where the object has to be */
|
|
|
|
|
VecSubf(vec, vec, td->center);
|
|
|
|
|
Mat3MulVecfl(td->smtx, vec);
|
2005-08-23 18:13:30 +00:00
|
|
|
|
2005-10-29 20:08:25 +00:00
|
|
|
protectedTransBits(td->protectflag, vec);
|
|
|
|
|
|
2005-05-29 23:21:56 +00:00
|
|
|
if(td->tdi) {
|
|
|
|
|
TransDataIpokey *tdi= td->tdi;
|
|
|
|
|
add_tdi_poin(tdi->locx, tdi->oldloc, vec[0]);
|
|
|
|
|
add_tdi_poin(tdi->locy, tdi->oldloc+1, vec[1]);
|
|
|
|
|
add_tdi_poin(tdi->locz, tdi->oldloc+2, vec[2]);
|
|
|
|
|
}
|
|
|
|
|
else VecAddf(td->loc, td->iloc, vec);
|
2005-08-23 18:13:30 +00:00
|
|
|
|
2005-10-29 20:08:25 +00:00
|
|
|
/* rotation */
|
2007-02-05 18:02:57 +00:00
|
|
|
if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
|
2005-10-29 20:08:25 +00:00
|
|
|
|
2007-02-05 18:02:57 +00:00
|
|
|
if(td->flag & TD_USEQUAT) {
|
|
|
|
|
Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
|
|
|
|
|
Mat3ToQuat(fmat, quat); // Actual transform
|
2005-02-22 16:50:04 +00:00
|
|
|
|
2007-02-05 18:02:57 +00:00
|
|
|
QuatMul(td->ext->quat, quat, td->ext->iquat);
|
|
|
|
|
/* this function works on end result */
|
|
|
|
|
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float obmat[3][3];
|
2005-02-22 16:50:04 +00:00
|
|
|
|
2007-02-05 18:02:57 +00:00
|
|
|
/* are there ipo keys? */
|
|
|
|
|
if(td->tdi) {
|
|
|
|
|
TransDataIpokey *tdi= td->tdi;
|
|
|
|
|
float rot[3];
|
|
|
|
|
|
|
|
|
|
/* calculate the total rotatation in eulers */
|
|
|
|
|
VecAddf(eul, td->ext->irot, td->ext->drot);
|
|
|
|
|
EulToMat3(eul, obmat);
|
|
|
|
|
/* mat = transform, obmat = object rotation */
|
|
|
|
|
Mat3MulMat3(fmat, mat, obmat);
|
|
|
|
|
|
|
|
|
|
Mat3ToCompatibleEul(fmat, eul, td->ext->irot);
|
|
|
|
|
|
|
|
|
|
/* correct back for delta rot */
|
|
|
|
|
if(tdi->flag & TOB_IPODROT) {
|
|
|
|
|
VecSubf(rot, eul, td->ext->irot);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
VecSubf(rot, eul, td->ext->drot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VecMulf(rot, (float)(9.0/M_PI_2));
|
|
|
|
|
VecSubf(rot, rot, tdi->oldrot);
|
|
|
|
|
|
|
|
|
|
protectedRotateBits(td->protectflag, rot, tdi->oldrot);
|
|
|
|
|
|
|
|
|
|
add_tdi_poin(tdi->rotx, tdi->oldrot, rot[0]);
|
|
|
|
|
add_tdi_poin(tdi->roty, tdi->oldrot+1, rot[1]);
|
|
|
|
|
add_tdi_poin(tdi->rotz, tdi->oldrot+2, rot[2]);
|
2005-02-25 11:35:24 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2007-02-05 18:02:57 +00:00
|
|
|
Mat3MulMat3(totmat, mat, td->mtx);
|
|
|
|
|
Mat3MulMat3(smat, td->smtx, totmat);
|
|
|
|
|
|
|
|
|
|
/* calculate the total rotatation in eulers */
|
|
|
|
|
VecAddf(eul, td->ext->irot, td->ext->drot); /* we have to correct for delta rot */
|
|
|
|
|
EulToMat3(eul, obmat);
|
|
|
|
|
/* mat = transform, obmat = object rotation */
|
|
|
|
|
Mat3MulMat3(fmat, smat, obmat);
|
|
|
|
|
|
|
|
|
|
Mat3ToCompatibleEul(fmat, eul, td->ext->irot);
|
|
|
|
|
|
|
|
|
|
/* correct back for delta rot */
|
|
|
|
|
VecSubf(eul, eul, td->ext->drot);
|
|
|
|
|
|
|
|
|
|
/* and apply */
|
|
|
|
|
protectedRotateBits(td->protectflag, eul, td->ext->irot);
|
|
|
|
|
VECCOPY(td->ext->rot, eul);
|
2005-02-25 11:35:24 +00:00
|
|
|
}
|
2005-02-22 16:50:04 +00:00
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-03-19 22:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
static void applyRotation(TransInfo *t, float angle, float axis[3])
|
2005-03-19 22:03:14 +00:00
|
|
|
{
|
2005-03-20 02:00:16 +00:00
|
|
|
TransData *td = t->data;
|
2005-04-10 20:09:31 +00:00
|
|
|
float mat[3][3], center[3];
|
2005-03-20 02:00:16 +00:00
|
|
|
int i;
|
|
|
|
|
|
2005-04-10 20:09:31 +00:00
|
|
|
/* saving original center */
|
2005-08-23 18:13:30 +00:00
|
|
|
if (t->around == V3D_LOCAL) {
|
2005-04-10 20:09:31 +00:00
|
|
|
VECCOPY(center, t->center);
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
VecRotToMat3(axis, angle, mat);
|
2007-02-07 23:28:33 +00:00
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
2005-04-10 20:09:31 +00:00
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
2005-05-07 21:04:55 +00:00
|
|
|
/* local constraint shouldn't alter center */
|
2005-08-23 18:13:30 +00:00
|
|
|
if (t->around == V3D_LOCAL) {
|
2006-03-08 11:07:49 +00:00
|
|
|
if (t->flag & (T_OBJECT|T_POSE)) {
|
|
|
|
|
VECCOPY(t->center, td->center);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if(G.vd->around==V3D_LOCAL && (G.scene->selectmode & SCE_SELECT_FACE)) {
|
|
|
|
|
VECCOPY(t->center, td->center);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-03-20 02:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (t->con.applyRot) {
|
|
|
|
|
t->con.applyRot(t, td, axis);
|
|
|
|
|
VecRotToMat3(axis, angle * td->factor, mat);
|
|
|
|
|
}
|
2005-04-01 18:39:39 +00:00
|
|
|
else if (t->flag & T_PROP_EDIT) {
|
2005-03-20 02:00:16 +00:00
|
|
|
VecRotToMat3(axis, angle * td->factor, mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ElementRotation(t, td, mat);
|
|
|
|
|
}
|
2005-04-10 20:09:31 +00:00
|
|
|
|
|
|
|
|
/* restoring original center */
|
2005-08-23 18:13:30 +00:00
|
|
|
if (t->around == V3D_LOCAL) {
|
2005-04-10 20:09:31 +00:00
|
|
|
VECCOPY(t->center, center);
|
|
|
|
|
}
|
2005-03-19 22:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Rotation(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
2006-12-03 18:30:34 +00:00
|
|
|
char str[64];
|
2005-03-19 22:03:14 +00:00
|
|
|
|
|
|
|
|
float final;
|
|
|
|
|
|
|
|
|
|
int dx2 = t->center2d[0] - mval[0];
|
|
|
|
|
int dy2 = t->center2d[1] - mval[1];
|
2005-06-05 12:24:35 +00:00
|
|
|
double B = sqrt(dx2*dx2+dy2*dy2);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-19 22:03:14 +00:00
|
|
|
int dx1 = t->center2d[0] - t->imval[0];
|
|
|
|
|
int dy1 = t->center2d[1] - t->imval[1];
|
2005-06-05 12:24:35 +00:00
|
|
|
double A = sqrt(dx1*dx1+dy1*dy1);
|
2005-03-19 22:03:14 +00:00
|
|
|
|
|
|
|
|
int dx3 = mval[0] - t->imval[0];
|
|
|
|
|
int dy3 = mval[1] - t->imval[1];
|
2005-06-05 12:24:35 +00:00
|
|
|
/* use doubles here, to make sure a "1.0" (no rotation) doesnt become 9.999999e-01, which gives 0.02 for acos */
|
|
|
|
|
double deler= ((double)((dx1*dx1+dy1*dy1)+(dx2*dx2+dy2*dy2)-(dx3*dx3+dy3*dy3) ))
|
|
|
|
|
/ (2.0 * (A*B?A*B:1.0));
|
2005-03-21 19:16:39 +00:00
|
|
|
/* (A*B?A*B:1.0f) this takes care of potential divide by zero errors */
|
2005-03-19 22:03:14 +00:00
|
|
|
|
|
|
|
|
float dphi;
|
|
|
|
|
|
|
|
|
|
float axis[3];
|
|
|
|
|
float mat[3][3];
|
|
|
|
|
|
2005-04-11 21:19:38 +00:00
|
|
|
VECCOPY(axis, t->viewinv[2]);
|
|
|
|
|
VecMulf(axis, -1.0f);
|
2005-03-19 22:03:14 +00:00
|
|
|
Normalise(axis);
|
|
|
|
|
|
2005-06-05 12:24:35 +00:00
|
|
|
dphi = saacos((float)deler);
|
2005-03-19 22:03:14 +00:00
|
|
|
if( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
|
|
|
|
|
|
|
|
|
|
if(G.qual & LR_SHIFTKEY) t->fac += dphi/30.0f;
|
|
|
|
|
else t->fac += dphi;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
clamping angle between -2 PI and 2 PI (not sure if useful so commented out - theeth)
|
|
|
|
|
if (t->fac >= 2 * M_PI)
|
|
|
|
|
t->fac -= 2 * M_PI;
|
|
|
|
|
else if (t->fac <= -2 * M_PI)
|
|
|
|
|
t->fac -= -2 * M_PI;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
final = t->fac;
|
|
|
|
|
|
|
|
|
|
snapGrid(t, &final);
|
|
|
|
|
|
|
|
|
|
t->imval[0] = mval[0];
|
|
|
|
|
t->imval[1] = mval[1];
|
|
|
|
|
|
|
|
|
|
if (t->con.applyRot) {
|
|
|
|
|
t->con.applyRot(t, NULL, axis);
|
|
|
|
|
}
|
2006-12-23 00:52:34 +00:00
|
|
|
|
|
|
|
|
applySnapping(t, &final);
|
2005-03-19 22:03:14 +00:00
|
|
|
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
char c[20];
|
|
|
|
|
|
|
|
|
|
applyNumInput(&t->num, &final);
|
|
|
|
|
|
|
|
|
|
outputNumInput(&(t->num), c);
|
|
|
|
|
|
|
|
|
|
sprintf(str, "Rot: %s %s", &c[0], t->proptext);
|
|
|
|
|
|
2006-12-28 03:11:21 +00:00
|
|
|
/* Clamp between -180 and 180 */
|
|
|
|
|
while (final >= 180.0)
|
|
|
|
|
final -= 360.0;
|
|
|
|
|
|
|
|
|
|
while (final <= -180.0)
|
|
|
|
|
final += 360.0;
|
|
|
|
|
|
2005-03-19 22:03:14 +00:00
|
|
|
final *= (float)(M_PI / 180.0);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2005-04-22 01:14:15 +00:00
|
|
|
sprintf(str, "Rot: %.2f%s %s", 180.0*final/M_PI, t->con.text, t->proptext);
|
2005-03-19 22:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-07 23:28:33 +00:00
|
|
|
VecRotToMat3(axis, final, mat);
|
2005-03-19 22:03:14 +00:00
|
|
|
|
2005-03-27 18:17:48 +00:00
|
|
|
t->val = final; // used in manipulator
|
2005-03-19 22:03:14 +00:00
|
|
|
Mat3CpyMat3(t->mat, mat); // used in manipulator
|
|
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
applyRotation(t, final, axis);
|
2005-03-19 22:03:14 +00:00
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-08-16 10:17:02 +00:00
|
|
|
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
|
2005-03-19 12:17:06 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ************************** TRACKBALL *************************** */
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-20 09:45:54 +00:00
|
|
|
void initTrackball(TransInfo *t)
|
2005-03-19 12:17:06 +00:00
|
|
|
{
|
|
|
|
|
t->idx_max = 1;
|
|
|
|
|
t->num.idx_max = 1;
|
|
|
|
|
t->snap[0] = 0.0f;
|
2005-03-30 23:19:42 +00:00
|
|
|
t->snap[1] = (float)((5.0/180)*M_PI);
|
2005-03-19 12:17:06 +00:00
|
|
|
t->snap[2] = t->snap[1] * 0.2f;
|
|
|
|
|
t->fac = 0;
|
|
|
|
|
t->transform = Trackball;
|
2005-09-24 18:00:32 +00:00
|
|
|
|
|
|
|
|
t->flag |= T_NO_CONSTRAINT; /* making sure the flag is always set */
|
2005-03-19 12:17:06 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float angles[2])
|
|
|
|
|
{
|
|
|
|
|
TransData *td = t->data;
|
|
|
|
|
float mat[3][3], smat[3][3], totmat[3][3];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
VecRotToMat3(axis1, angles[0], smat);
|
|
|
|
|
VecRotToMat3(axis2, angles[1], totmat);
|
|
|
|
|
|
|
|
|
|
Mat3MulMat3(mat, smat, totmat);
|
|
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
if (t->around == V3D_LOCAL) {
|
2005-05-12 17:11:32 +00:00
|
|
|
if (t->flag & T_OBJECT)
|
|
|
|
|
VECCOPY(t->center, td->center); // not supported in editmode yet
|
2005-03-20 02:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
2005-04-01 18:39:39 +00:00
|
|
|
if (t->flag & T_PROP_EDIT) {
|
2005-03-20 02:00:16 +00:00
|
|
|
VecRotToMat3(axis1, td->factor * angles[0], smat);
|
|
|
|
|
VecRotToMat3(axis2, td->factor * angles[1], totmat);
|
|
|
|
|
|
|
|
|
|
Mat3MulMat3(mat, smat, totmat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ElementRotation(t, td, mat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-20 09:45:54 +00:00
|
|
|
int Trackball(TransInfo *t, short mval[2])
|
2005-03-19 12:17:06 +00:00
|
|
|
{
|
2006-12-03 18:30:34 +00:00
|
|
|
char str[128];
|
2005-03-19 22:03:14 +00:00
|
|
|
float axis1[3], axis2[3];
|
2005-03-19 12:17:06 +00:00
|
|
|
float mat[3][3], totmat[3][3], smat[3][3];
|
|
|
|
|
float phi[2];
|
|
|
|
|
|
2005-03-24 18:47:09 +00:00
|
|
|
VECCOPY(axis1, t->persinv[0]);
|
|
|
|
|
VECCOPY(axis2, t->persinv[1]);
|
2005-03-19 12:17:06 +00:00
|
|
|
Normalise(axis1);
|
|
|
|
|
Normalise(axis2);
|
|
|
|
|
|
|
|
|
|
/* factore has to become setting or so */
|
2005-03-20 02:00:16 +00:00
|
|
|
phi[0]= 0.01f*(float)( t->imval[1] - mval[1] );
|
|
|
|
|
phi[1]= 0.01f*(float)( mval[0] - t->imval[0] );
|
2005-03-19 12:17:06 +00:00
|
|
|
|
|
|
|
|
//if(G.qual & LR_SHIFTKEY) t->fac += dphi/30.0f;
|
|
|
|
|
//else t->fac += dphi;
|
|
|
|
|
|
|
|
|
|
snapGrid(t, phi);
|
|
|
|
|
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
2005-03-25 11:17:59 +00:00
|
|
|
char c[40];
|
2005-03-19 12:17:06 +00:00
|
|
|
|
2005-03-25 11:17:59 +00:00
|
|
|
applyNumInput(&t->num, phi);
|
2005-03-19 12:17:06 +00:00
|
|
|
|
2005-03-25 11:17:59 +00:00
|
|
|
outputNumInput(&(t->num), c);
|
2005-03-19 12:17:06 +00:00
|
|
|
|
2005-03-25 11:17:59 +00:00
|
|
|
sprintf(str, "Trackball: %s %s %s", &c[0], &c[20], t->proptext);
|
2005-03-19 12:17:06 +00:00
|
|
|
|
2005-03-25 11:17:59 +00:00
|
|
|
phi[0] *= (float)(M_PI / 180.0);
|
|
|
|
|
phi[1] *= (float)(M_PI / 180.0);
|
2005-03-19 12:17:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sprintf(str, "Trackball: %.2f %.2f %s", 180.0*phi[0]/M_PI, 180.0*phi[1]/M_PI, t->proptext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VecRotToMat3(axis1, phi[0], smat);
|
|
|
|
|
VecRotToMat3(axis2, phi[1], totmat);
|
|
|
|
|
|
|
|
|
|
Mat3MulMat3(mat, smat, totmat);
|
|
|
|
|
|
|
|
|
|
Mat3CpyMat3(t->mat, mat); // used in manipulator
|
|
|
|
|
|
2005-03-20 02:00:16 +00:00
|
|
|
applyTrackball(t, axis1, axis2, phi);
|
2005-03-19 12:17:06 +00:00
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-03-19 12:17:06 +00:00
|
|
|
|
2005-08-16 10:17:02 +00:00
|
|
|
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
|
2005-03-19 12:17:06 +00:00
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************** TRANSLATION *************************** */
|
|
|
|
|
|
2005-02-20 19:00:00 +00:00
|
|
|
void initTranslation(TransInfo *t)
|
|
|
|
|
{
|
2005-08-23 18:13:30 +00:00
|
|
|
t->idx_max = (t->flag & T_2D_EDIT)? 1: 2;
|
|
|
|
|
t->num.idx_max = t->idx_max;
|
2005-02-14 02:53:36 +00:00
|
|
|
t->transform = Translation;
|
2005-02-25 11:55:03 +00:00
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
if(t->spacetype == SPACE_VIEW3D) {
|
|
|
|
|
/* initgrabz() defines a factor for perspective depth correction, used in window_to_3d() */
|
2005-10-02 18:27:14 +00:00
|
|
|
if(t->flag & (T_EDIT|T_POSE)) {
|
|
|
|
|
Object *ob= G.obedit?G.obedit:t->poseobj;
|
2005-08-23 18:13:30 +00:00
|
|
|
float vec[3];
|
|
|
|
|
|
|
|
|
|
VECCOPY(vec, t->center);
|
2005-10-02 18:27:14 +00:00
|
|
|
Mat4MulVecfl(ob->obmat, vec);
|
2005-08-23 18:13:30 +00:00
|
|
|
initgrabz(vec[0], vec[1], vec[2]);
|
|
|
|
|
}
|
|
|
|
|
else initgrabz(t->center[0], t->center[1], t->center[2]);
|
|
|
|
|
|
|
|
|
|
t->snap[0] = 0.0f;
|
|
|
|
|
t->snap[1] = G.vd->gridview * 1.0f;
|
|
|
|
|
t->snap[2] = t->snap[1] * 0.1f;
|
|
|
|
|
}
|
|
|
|
|
else if(t->spacetype == SPACE_IMAGE) {
|
|
|
|
|
t->snap[0] = 0.0f;
|
|
|
|
|
t->snap[1] = 0.125f;
|
|
|
|
|
t->snap[2] = 0.0625f;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
t->snap[0] = 0.0f;
|
|
|
|
|
t->snap[1] = t->snap[2] = 1.0f;
|
2005-02-25 11:55:03 +00:00
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-14 20:10:22 +00:00
|
|
|
static void headerTranslation(TransInfo *t, float vec[3], char *str) {
|
+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
2005-03-08 03:51:45 +00:00
|
|
|
char tvec[60];
|
2006-03-26 22:35:03 +00:00
|
|
|
char distvec[20];
|
2005-08-23 18:13:30 +00:00
|
|
|
float dvec[3];
|
2006-03-26 22:35:03 +00:00
|
|
|
float dist;
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
convertVecToDisplayNum(vec, dvec);
|
|
|
|
|
|
+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
2005-03-08 03:51:45 +00:00
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
outputNumInput(&(t->num), tvec);
|
2006-03-26 22:35:03 +00:00
|
|
|
dist = VecLength(t->num.val);
|
+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
2005-03-08 03:51:45 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2006-03-26 22:35:03 +00:00
|
|
|
dist = VecLength(vec);
|
2005-08-23 18:13:30 +00:00
|
|
|
sprintf(&tvec[0], "%.4f", dvec[0]);
|
|
|
|
|
sprintf(&tvec[20], "%.4f", dvec[1]);
|
|
|
|
|
sprintf(&tvec[40], "%.4f", dvec[2]);
|
+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
2005-03-08 03:51:45 +00:00
|
|
|
}
|
|
|
|
|
|
2006-07-04 16:53:11 +00:00
|
|
|
if( dist > 1e10 || dist < -1e10 ) /* prevent string buffer overflow */
|
|
|
|
|
sprintf(distvec, "%.4e", dist);
|
|
|
|
|
else
|
|
|
|
|
sprintf(distvec, "%.4f", dist);
|
2006-03-26 22:35:03 +00:00
|
|
|
|
+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
2005-03-08 03:51:45 +00:00
|
|
|
if (t->con.mode & CON_APPLY) {
|
|
|
|
|
switch(t->num.idx_max) {
|
|
|
|
|
case 0:
|
2006-03-26 22:35:03 +00:00
|
|
|
sprintf(str, "D: %s (%s)%s %s", &tvec[0], distvec, t->con.text, t->proptext);
|
+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
2005-03-08 03:51:45 +00:00
|
|
|
break;
|
|
|
|
|
case 1:
|
2006-03-26 22:35:03 +00:00
|
|
|
sprintf(str, "D: %s D: %s (%s)%s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext);
|
+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
2005-03-08 03:51:45 +00:00
|
|
|
break;
|
|
|
|
|
case 2:
|
2006-03-26 22:35:03 +00:00
|
|
|
sprintf(str, "D: %s D: %s D: %s (%s)%s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext);
|
+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
2005-03-08 03:51:45 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2005-08-23 18:13:30 +00:00
|
|
|
if(t->flag & T_2D_EDIT)
|
2006-03-26 22:35:03 +00:00
|
|
|
sprintf(str, "Dx: %s Dy: %s (%s)%s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext);
|
2005-08-23 18:13:30 +00:00
|
|
|
else
|
2006-03-26 22:35:03 +00:00
|
|
|
sprintf(str, "Dx: %s Dy: %s Dz: %s (%s)%s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext);
|
+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
2005-03-08 03:51:45 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-14 20:10:22 +00:00
|
|
|
static void applyTranslation(TransInfo *t, float vec[3]) {
|
2005-02-14 02:53:36 +00:00
|
|
|
TransData *td = t->data;
|
2005-03-12 23:15:26 +00:00
|
|
|
float tvec[3];
|
|
|
|
|
int i;
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
2005-03-15 17:31:46 +00:00
|
|
|
break;
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
if (t->con.applyVec) {
|
+ Local axis constraint for multiple object selection works with resize and rotate (the easiest).
+ Refined the headerprint for Translation. Now prints only the needed info for constraint in the constraint's space (ie: if you're moving 1 unit along the local X axis, regardless of it's orientation, it will print "D: 1.000 along local X")
Still need to make numinput work like that (typing a number with a local axis constraint would move along that axis. There's some base code already though, just need a finishing touch, but it's late now)
+ Optimised PET calculations by using the TD_NOACTION flag (actually, that might have been in the last commit).
+ Added a float axismtx[3][3] member to TransData to store the orientation of the element (useful for local axis constrainst which, in edit could be moving along normals and the like).
- Fixed scaling in edit mode (was doing some matrix multiplications in the wrong order, only visible when using a constraint)
- Fixed the constraint projection matrix. It didn't work for planar constraint if the constraint space wasn't global (in a nutshell, it produced weird results for local space planes).
- Some potential bugs fixed (Note to Ton: added an ext pointer in TransInfo to point to the TransDataExtension block. With the sort done after allocation, the first td pointer doesn't necesarely point at the start of the ext block, so we needed another to free it correctly).
- Got rid of some remaining test with G.obedit.
- Moved constraint reset from init to post trans code (Ton, that means you can create constraints before calling transform, like for the menus for example).
NOTE:
I was getting some random segfault with the new headerprint code. Very random, couldn't reproduce with a debug version. I did some initialisation that might have been missing (though doubtful that's what caused the crashes). Was linked to using constraint though not caused by them. Probably due to some dumb late coding error.
2005-03-08 03:51:45 +00:00
|
|
|
float pvec[3];
|
|
|
|
|
t->con.applyVec(t, td, vec, tvec, pvec);
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
VECCOPY(tvec, vec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Mat3MulVecfl(td->smtx, tvec);
|
|
|
|
|
VecMulf(tvec, td->factor);
|
2005-02-25 11:35:24 +00:00
|
|
|
|
2005-10-29 20:08:25 +00:00
|
|
|
protectedTransBits(td->protectflag, tvec);
|
|
|
|
|
|
2005-02-25 11:35:24 +00:00
|
|
|
/* transdata ipokey */
|
|
|
|
|
if(td->tdi) {
|
|
|
|
|
TransDataIpokey *tdi= td->tdi;
|
|
|
|
|
add_tdi_poin(tdi->locx, tdi->oldloc, tvec[0]);
|
|
|
|
|
add_tdi_poin(tdi->locy, tdi->oldloc+1, tvec[1]);
|
|
|
|
|
add_tdi_poin(tdi->locz, tdi->oldloc+2, tvec[2]);
|
|
|
|
|
}
|
|
|
|
|
else VecAddf(td->loc, td->iloc, tvec);
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
2005-03-12 23:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
/* uses t->vec to store actual translation in */
|
2005-03-12 23:15:26 +00:00
|
|
|
int Translation(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
float tvec[3];
|
2005-03-12 23:15:26 +00:00
|
|
|
char str[200];
|
2005-03-25 11:17:59 +00:00
|
|
|
|
|
|
|
|
if(t->flag & T_SHIFT_MOD) {
|
|
|
|
|
float dvec[3];
|
|
|
|
|
/* calculate the main translation and the precise one separate */
|
2005-08-23 18:13:30 +00:00
|
|
|
convertViewVec(t, dvec, (short)(mval[0] - t->shiftmval[0]), (short)(mval[1] - t->shiftmval[1]));
|
2005-03-25 11:17:59 +00:00
|
|
|
VecMulf(dvec, 0.1f);
|
2005-08-23 18:13:30 +00:00
|
|
|
convertViewVec(t, t->vec, (short)(t->shiftmval[0] - t->imval[0]), (short)(t->shiftmval[1] - t->imval[1]));
|
2005-03-25 11:17:59 +00:00
|
|
|
VecAddf(t->vec, t->vec, dvec);
|
|
|
|
|
}
|
2005-08-23 18:13:30 +00:00
|
|
|
else convertViewVec(t, t->vec, (short)(mval[0] - t->imval[0]), (short)(mval[1] - t->imval[1]));
|
2005-03-12 23:15:26 +00:00
|
|
|
|
|
|
|
|
if (t->con.mode & CON_APPLY) {
|
|
|
|
|
float pvec[3] = {0.0f, 0.0f, 0.0f};
|
2006-12-19 22:25:07 +00:00
|
|
|
applySnapping(t, t->vec);
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
t->con.applyVec(t, NULL, t->vec, tvec, pvec);
|
|
|
|
|
VECCOPY(t->vec, tvec);
|
2005-03-12 23:15:26 +00:00
|
|
|
headerTranslation(t, pvec, str);
|
|
|
|
|
}
|
|
|
|
|
else {
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
snapGrid(t, t->vec);
|
|
|
|
|
applyNumInput(&t->num, t->vec);
|
2006-10-25 23:57:00 +00:00
|
|
|
applySnapping(t, t->vec);
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
headerTranslation(t, t->vec, str);
|
2005-03-12 23:15:26 +00:00
|
|
|
}
|
2006-10-25 23:57:00 +00:00
|
|
|
|
So! Finally a show-off of the *power* of Martin P's work! :)
- Made framework for 3d Transform Manipulators (widgets)
- The Manipulators act like '2d buttons', by default with LeftMouse and with
while-hold-move-release
- Implemented now: Translation Widget, which allows:
- four hotspots for axis grab or view-aligned grab
- center defined by 'around' setting
- SHIFT+LMB gives planar constraint on other 2 axes
- works in Object mode and Edit mode (not posemode yet)
Enable it with (temporal) icon in 3D header. All other 'normal' transforms
then keeps working btw.
On the todo for this widget:
- choice for Global, Local or Normal orientation
The way the widgets are going to work is in review still. Commit is also for
Matt for his proposal/paper on topic.
Some notes regarding this project;
- no life updates (on mouse over) like 3DS, I think that's neurotic
- on click, dominant axis changes to theme defined "Transform" color, other axes disappear, like maya
- manipulater size is fixed preset, independent zoom.
- manipulator follows selection, and is located based on 'around' mode
Unresolved;
- in maya, when you select 2 or more objects, the manipulator draws on the 'active' object, also interesting
- what to do with G,R,S hotkeys? It could switch the manipulator "mode"...
- header button/menu for manipulator mode?
2005-03-17 21:31:49 +00:00
|
|
|
applyTranslation(t, t->vec);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
/* evil hack - redo translation if cliiping needeed */
|
|
|
|
|
if (t->flag & T_CLIP_UV && clipUVTransform(t, t->vec, 0))
|
|
|
|
|
applyTranslation(t, t->vec);
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
2006-10-25 23:57:00 +00:00
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2006-10-25 23:57:00 +00:00
|
|
|
drawSnapping(t);
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
return 1;
|
2005-02-20 19:00:00 +00:00
|
|
|
}
|
2005-03-13 20:17:39 +00:00
|
|
|
|
|
|
|
|
/* ************************** SHRINK/FATTEN *************************** */
|
|
|
|
|
|
|
|
|
|
void initShrinkFatten(TransInfo *t)
|
|
|
|
|
{
|
2005-03-22 11:10:04 +00:00
|
|
|
if (G.obedit==NULL || G.obedit->type != OB_MESH) {
|
2005-03-21 17:36:21 +00:00
|
|
|
initTransModeFlags(t, TFM_RESIZE);
|
2005-03-13 20:17:39 +00:00
|
|
|
initResize(t);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t->idx_max = 0;
|
|
|
|
|
t->num.idx_max = 0;
|
|
|
|
|
t->snap[0] = 0.0f;
|
2005-03-23 14:24:43 +00:00
|
|
|
t->snap[1] = 1.0f;
|
2005-03-13 20:17:39 +00:00
|
|
|
t->snap[2] = t->snap[1] * 0.1f;
|
|
|
|
|
t->transform = ShrinkFatten;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ShrinkFatten(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
2005-03-15 17:31:46 +00:00
|
|
|
float vec[3];
|
2006-02-12 21:09:18 +00:00
|
|
|
float distance;
|
2005-03-13 20:17:39 +00:00
|
|
|
int i;
|
2006-12-03 18:30:34 +00:00
|
|
|
char str[64];
|
2005-03-13 20:17:39 +00:00
|
|
|
TransData *td = t->data;
|
|
|
|
|
|
2006-02-12 21:09:18 +00:00
|
|
|
distance = -InputVerticalAbsolute(t, mval);
|
2005-03-13 20:17:39 +00:00
|
|
|
|
2006-02-12 21:09:18 +00:00
|
|
|
snapGrid(t, &distance);
|
2005-03-13 20:17:39 +00:00
|
|
|
|
2006-02-12 21:09:18 +00:00
|
|
|
applyNumInput(&t->num, &distance);
|
2005-03-13 20:17:39 +00:00
|
|
|
|
|
|
|
|
/* header print for NumInput */
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
char c[20];
|
|
|
|
|
|
|
|
|
|
outputNumInput(&(t->num), c);
|
|
|
|
|
|
|
|
|
|
sprintf(str, "Shrink/Fatten: %s %s", c, t->proptext);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* default header print */
|
2006-02-12 21:09:18 +00:00
|
|
|
sprintf(str, "Shrink/Fatten: %.4f %s", distance, t->proptext);
|
2005-03-13 20:17:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
2005-03-15 17:31:46 +00:00
|
|
|
break;
|
2005-03-13 20:17:39 +00:00
|
|
|
|
|
|
|
|
VECCOPY(vec, td->axismtx[2]);
|
2006-02-12 21:09:18 +00:00
|
|
|
VecMulf(vec, distance);
|
2005-03-13 20:17:39 +00:00
|
|
|
VecMulf(vec, td->factor);
|
|
|
|
|
|
|
|
|
|
VecAddf(td->loc, td->iloc, vec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-03-13 20:17:39 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2005-03-16 21:55:57 +00:00
|
|
|
|
|
|
|
|
/* ************************** TILT *************************** */
|
|
|
|
|
|
|
|
|
|
void initTilt(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
t->idx_max = 0;
|
|
|
|
|
t->num.idx_max = 0;
|
|
|
|
|
t->snap[0] = 0.0f;
|
2005-03-30 23:19:42 +00:00
|
|
|
t->snap[1] = (float)((5.0/180)*M_PI);
|
2005-03-16 21:55:57 +00:00
|
|
|
t->snap[2] = t->snap[1] * 0.2f;
|
|
|
|
|
t->fac = 0;
|
|
|
|
|
t->transform = Tilt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Tilt(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
|
|
|
|
TransData *td = t->data;
|
|
|
|
|
int i;
|
|
|
|
|
char str[50];
|
|
|
|
|
|
|
|
|
|
float final;
|
|
|
|
|
|
|
|
|
|
int dx2 = t->center2d[0] - mval[0];
|
|
|
|
|
int dy2 = t->center2d[1] - mval[1];
|
|
|
|
|
float B = (float)sqrt(dx2*dx2+dy2*dy2);
|
|
|
|
|
|
|
|
|
|
int dx1 = t->center2d[0] - t->imval[0];
|
|
|
|
|
int dy1 = t->center2d[1] - t->imval[1];
|
|
|
|
|
float A = (float)sqrt(dx1*dx1+dy1*dy1);
|
|
|
|
|
|
|
|
|
|
int dx3 = mval[0] - t->imval[0];
|
|
|
|
|
int dy3 = mval[1] - t->imval[1];
|
|
|
|
|
|
|
|
|
|
float deler= ((dx1*dx1+dy1*dy1)+(dx2*dx2+dy2*dy2)-(dx3*dx3+dy3*dy3))
|
|
|
|
|
/ (2 * A * B);
|
|
|
|
|
|
|
|
|
|
float dphi;
|
|
|
|
|
|
|
|
|
|
dphi = saacos(deler);
|
|
|
|
|
if( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
|
|
|
|
|
|
|
|
|
|
if(G.qual & LR_SHIFTKEY) t->fac += dphi/30.0f;
|
|
|
|
|
else t->fac += dphi;
|
|
|
|
|
|
|
|
|
|
final = t->fac;
|
|
|
|
|
|
|
|
|
|
snapGrid(t, &final);
|
|
|
|
|
|
|
|
|
|
t->imval[0] = mval[0];
|
|
|
|
|
t->imval[1] = mval[1];
|
|
|
|
|
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
char c[20];
|
|
|
|
|
|
|
|
|
|
applyNumInput(&t->num, &final);
|
|
|
|
|
|
|
|
|
|
outputNumInput(&(t->num), c);
|
|
|
|
|
|
|
|
|
|
sprintf(str, "Tilt: %s %s", &c[0], t->proptext);
|
|
|
|
|
|
|
|
|
|
final *= (float)(M_PI / 180.0);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sprintf(str, "Tilt: %.2f %s", 180.0*final/M_PI, t->proptext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (td->val) {
|
|
|
|
|
*td->val = td->ival + final * td->factor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-03-16 21:55:57 +00:00
|
|
|
|
2005-08-16 10:17:02 +00:00
|
|
|
helpline (t, t->center);
|
2005-03-16 21:55:57 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-13 07:37:51 +00:00
|
|
|
|
|
|
|
|
/* ******************** Curve Shrink/Fatten *************** */
|
|
|
|
|
|
|
|
|
|
int CurveShrinkFatten(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
|
|
|
|
TransData *td = t->data;
|
|
|
|
|
float ratio;
|
|
|
|
|
int i;
|
|
|
|
|
char str[50];
|
|
|
|
|
|
|
|
|
|
if(t->flag & T_SHIFT_MOD) {
|
|
|
|
|
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
|
|
|
|
|
float dx= (float)(t->center2d[0] - t->shiftmval[0]);
|
|
|
|
|
float dy= (float)(t->center2d[1] - t->shiftmval[1]);
|
|
|
|
|
ratio = (float)sqrt( dx*dx + dy*dy)/t->fac;
|
|
|
|
|
|
|
|
|
|
dx= (float)(t->center2d[0] - mval[0]);
|
|
|
|
|
dy= (float)(t->center2d[1] - mval[1]);
|
|
|
|
|
ratio+= 0.1f*(float)(sqrt( dx*dx + dy*dy)/t->fac -ratio);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float dx= (float)(t->center2d[0] - mval[0]);
|
|
|
|
|
float dy= (float)(t->center2d[1] - mval[1]);
|
|
|
|
|
ratio = (float)sqrt( dx*dx + dy*dy)/t->fac;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
snapGrid(t, &ratio);
|
|
|
|
|
|
|
|
|
|
applyNumInput(&t->num, &ratio);
|
|
|
|
|
|
|
|
|
|
/* header print for NumInput */
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
char c[20];
|
|
|
|
|
|
|
|
|
|
outputNumInput(&(t->num), c);
|
|
|
|
|
sprintf(str, "Shrink/Fatten: %s", c);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sprintf(str, "Shrink/Fatten: %3f", ratio);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if(td->val) {
|
|
|
|
|
//*td->val= ratio;
|
|
|
|
|
*td->val= td->ival*ratio;
|
|
|
|
|
if (*td->val <= 0.0f) *td->val = 0.0001f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
|
|
|
|
viewRedrawForce(t);
|
|
|
|
|
|
|
|
|
|
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void initCurveShrinkFatten(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
t->idx_max = 0;
|
|
|
|
|
t->num.idx_max = 0;
|
|
|
|
|
t->snap[0] = 0.0f;
|
|
|
|
|
t->snap[1] = 0.1f;
|
|
|
|
|
t->snap[2] = t->snap[1] * 0.1f;
|
|
|
|
|
t->transform = CurveShrinkFatten;
|
|
|
|
|
t->fac = (float)sqrt( (
|
|
|
|
|
((float)(t->center2d[1] - t->imval[1]))*((float)(t->center2d[1] - t->imval[1]))
|
|
|
|
|
+
|
|
|
|
|
((float)(t->center2d[0] - t->imval[0]))*((float)(t->center2d[0] - t->imval[0]))
|
|
|
|
|
) );
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-31 21:02:35 +00:00
|
|
|
/* ************************** PUSH/PULL *************************** */
|
|
|
|
|
|
|
|
|
|
void initPushPull(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
t->idx_max = 0;
|
|
|
|
|
t->num.idx_max = 0;
|
|
|
|
|
t->snap[0] = 0.0f;
|
|
|
|
|
t->snap[1] = 1.0f;
|
|
|
|
|
t->snap[2] = t->snap[1] * 0.1f;
|
2005-03-31 22:18:08 +00:00
|
|
|
t->transform = PushPull;
|
2005-03-31 21:02:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int PushPull(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
2005-03-31 22:18:08 +00:00
|
|
|
float vec[3], axis[3];
|
2005-03-31 21:02:35 +00:00
|
|
|
float distance;
|
|
|
|
|
int i;
|
2006-12-03 18:30:34 +00:00
|
|
|
char str[128];
|
2005-03-31 21:02:35 +00:00
|
|
|
TransData *td = t->data;
|
|
|
|
|
|
2006-02-12 21:09:18 +00:00
|
|
|
distance = InputVerticalAbsolute(t, mval);
|
2005-03-31 21:02:35 +00:00
|
|
|
|
|
|
|
|
snapGrid(t, &distance);
|
|
|
|
|
|
|
|
|
|
applyNumInput(&t->num, &distance);
|
|
|
|
|
|
|
|
|
|
/* header print for NumInput */
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
char c[20];
|
|
|
|
|
|
|
|
|
|
outputNumInput(&(t->num), c);
|
|
|
|
|
|
|
|
|
|
sprintf(str, "Push/Pull: %s%s %s", c, t->con.text, t->proptext);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* default header print */
|
|
|
|
|
sprintf(str, "Push/Pull: %.4f%s %s", distance, t->con.text, t->proptext);
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-02 02:18:13 +00:00
|
|
|
if (t->con.applyRot && t->con.mode & CON_APPLY) {
|
2005-03-31 22:18:08 +00:00
|
|
|
t->con.applyRot(t, NULL, axis);
|
|
|
|
|
}
|
2005-03-31 21:02:35 +00:00
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
VecSubf(vec, t->center, td->center);
|
2005-05-02 02:18:13 +00:00
|
|
|
if (t->con.applyRot && t->con.mode & CON_APPLY) {
|
2005-03-31 21:02:35 +00:00
|
|
|
t->con.applyRot(t, td, axis);
|
2005-05-29 09:21:34 +00:00
|
|
|
if (isLockConstraint(t)) {
|
|
|
|
|
float dvec[3];
|
|
|
|
|
Projf(dvec, vec, axis);
|
|
|
|
|
VecSubf(vec, vec, dvec);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Projf(vec, vec, axis);
|
|
|
|
|
}
|
2005-03-31 21:02:35 +00:00
|
|
|
}
|
|
|
|
|
Normalise(vec);
|
|
|
|
|
VecMulf(vec, distance);
|
|
|
|
|
VecMulf(vec, td->factor);
|
|
|
|
|
|
|
|
|
|
VecAddf(td->loc, td->iloc, vec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-03-31 21:02:35 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2005-04-04 23:37:15 +00:00
|
|
|
|
|
|
|
|
/* ************************** CREASE *************************** */
|
|
|
|
|
|
|
|
|
|
void initCrease(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
t->idx_max = 0;
|
|
|
|
|
t->num.idx_max = 0;
|
|
|
|
|
t->snap[0] = 0.0f;
|
|
|
|
|
t->snap[1] = 0.1f;
|
|
|
|
|
t->snap[2] = t->snap[1] * 0.1f;
|
|
|
|
|
t->transform = Crease;
|
2006-05-29 13:01:51 +00:00
|
|
|
t->fac = (float)sqrt(
|
2005-04-04 23:37:15 +00:00
|
|
|
(
|
2006-05-29 13:01:51 +00:00
|
|
|
((float)(t->center2d[1] - t->imval[1]))*((float)(t->center2d[1] - t->imval[1]))
|
2005-04-04 23:37:15 +00:00
|
|
|
+
|
2006-05-29 13:01:51 +00:00
|
|
|
((float)(t->center2d[0] - t->imval[0]))*((float)(t->center2d[0] - t->imval[0]))
|
2005-04-04 23:37:15 +00:00
|
|
|
) );
|
|
|
|
|
|
|
|
|
|
if(t->fac==0.0f) t->fac= 1.0f; // prevent Inf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Crease(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
|
|
|
|
TransData *td = t->data;
|
|
|
|
|
float crease;
|
|
|
|
|
int i;
|
|
|
|
|
char str[50];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(t->flag & T_SHIFT_MOD) {
|
|
|
|
|
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
|
|
|
|
|
float dx= (float)(t->center2d[0] - t->shiftmval[0]);
|
|
|
|
|
float dy= (float)(t->center2d[1] - t->shiftmval[1]);
|
|
|
|
|
crease = (float)sqrt( dx*dx + dy*dy)/t->fac;
|
|
|
|
|
|
|
|
|
|
dx= (float)(t->center2d[0] - mval[0]);
|
|
|
|
|
dy= (float)(t->center2d[1] - mval[1]);
|
|
|
|
|
crease+= 0.1f*(float)(sqrt( dx*dx + dy*dy)/t->fac -crease);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float dx= (float)(t->center2d[0] - mval[0]);
|
|
|
|
|
float dy= (float)(t->center2d[1] - mval[1]);
|
|
|
|
|
crease = (float)sqrt( dx*dx + dy*dy)/t->fac;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
crease -= 1.0f;
|
|
|
|
|
if (crease > 1.0f) crease = 1.0f;
|
|
|
|
|
|
|
|
|
|
snapGrid(t, &crease);
|
|
|
|
|
|
|
|
|
|
applyNumInput(&t->num, &crease);
|
|
|
|
|
|
|
|
|
|
/* header print for NumInput */
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
char c[20];
|
|
|
|
|
|
|
|
|
|
outputNumInput(&(t->num), c);
|
|
|
|
|
|
|
|
|
|
if (crease >= 0.0f)
|
2005-04-12 10:08:04 +00:00
|
|
|
sprintf(str, "Crease: +%s %s", c, t->proptext);
|
2005-04-04 23:37:15 +00:00
|
|
|
else
|
2005-04-12 10:08:04 +00:00
|
|
|
sprintf(str, "Crease: %s %s", c, t->proptext);
|
2005-04-04 23:37:15 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* default header print */
|
|
|
|
|
if (crease >= 0.0f)
|
|
|
|
|
sprintf(str, "Crease: +%.3f %s", crease, t->proptext);
|
|
|
|
|
else
|
|
|
|
|
sprintf(str, "Crease: %.3f %s", crease, t->proptext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (td->val) {
|
|
|
|
|
*td->val = td->ival + crease * td->factor;
|
|
|
|
|
if (*td->val < 0.0f) *td->val = 0.0f;
|
|
|
|
|
if (*td->val > 1.0f) *td->val = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-04-04 23:37:15 +00:00
|
|
|
|
2005-08-16 10:17:02 +00:00
|
|
|
helpline (t, t->center);
|
2005-04-04 23:37:15 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2005-05-04 00:37:11 +00:00
|
|
|
|
2006-12-03 19:54:27 +00:00
|
|
|
/* ******************** EditBone (B-bone) width scaling *************** */
|
2005-05-04 00:37:11 +00:00
|
|
|
|
2006-12-03 19:54:27 +00:00
|
|
|
void initBoneSize(TransInfo *t)
|
2005-05-04 00:37:11 +00:00
|
|
|
{
|
2006-12-03 19:54:27 +00:00
|
|
|
t->idx_max = 0;
|
|
|
|
|
t->num.idx_max = 0;
|
|
|
|
|
t->snap[0] = 0.0f;
|
|
|
|
|
t->snap[1] = 0.1f;
|
|
|
|
|
t->snap[2] = t->snap[1] * 0.1f;
|
|
|
|
|
t->transform = BoneSize;
|
|
|
|
|
t->fac = (float)sqrt( (
|
|
|
|
|
((float)(t->center2d[1] - t->imval[1]))*((float)(t->center2d[1] - t->imval[1]))
|
|
|
|
|
+
|
|
|
|
|
((float)(t->center2d[0] - t->imval[0]))*((float)(t->center2d[0] - t->imval[0]))
|
|
|
|
|
) );
|
2005-05-04 00:37:11 +00:00
|
|
|
|
2006-12-03 19:54:27 +00:00
|
|
|
if(t->fac==0.0f) t->fac= 1.0f; // prevent Inf
|
2005-05-04 00:37:11 +00:00
|
|
|
}
|
2005-05-08 12:00:28 +00:00
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
|
|
|
|
|
{
|
|
|
|
|
float tmat[3][3], smat[3][3], oldy;
|
|
|
|
|
float sizemat[3][3];
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
Mat3MulMat3(smat, mat, td->mtx);
|
|
|
|
|
Mat3MulMat3(tmat, td->smtx, smat);
|
|
|
|
|
|
|
|
|
|
if (t->con.applySize) {
|
|
|
|
|
t->con.applySize(t, td, tmat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* we've tucked the scale in loc */
|
|
|
|
|
oldy= td->iloc[1];
|
|
|
|
|
SizeToMat3(td->iloc, sizemat);
|
2005-07-17 17:36:54 +00:00
|
|
|
Mat3MulMat3(tmat, tmat, sizemat);
|
2005-07-16 19:07:02 +00:00
|
|
|
Mat3ToSize(tmat, td->loc);
|
|
|
|
|
td->loc[1]= oldy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BoneSize(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
|
|
|
|
TransData *td = t->data;
|
|
|
|
|
float size[3], mat[3][3];
|
|
|
|
|
float ratio;
|
|
|
|
|
int i;
|
|
|
|
|
char str[50];
|
|
|
|
|
|
|
|
|
|
/* for manipulator, center handle, the scaling can't be done relative to center */
|
|
|
|
|
if( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0) {
|
|
|
|
|
ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1]))/100.0f;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
if(t->flag & T_SHIFT_MOD) {
|
|
|
|
|
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
|
|
|
|
|
float dx= (float)(t->center2d[0] - t->shiftmval[0]);
|
|
|
|
|
float dy= (float)(t->center2d[1] - t->shiftmval[1]);
|
|
|
|
|
ratio = (float)sqrt( dx*dx + dy*dy)/t->fac;
|
|
|
|
|
|
|
|
|
|
dx= (float)(t->center2d[0] - mval[0]);
|
|
|
|
|
dy= (float)(t->center2d[1] - mval[1]);
|
|
|
|
|
ratio+= 0.1f*(float)(sqrt( dx*dx + dy*dy)/t->fac -ratio);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float dx= (float)(t->center2d[0] - mval[0]);
|
|
|
|
|
float dy= (float)(t->center2d[1] - mval[1]);
|
|
|
|
|
ratio = (float)sqrt( dx*dx + dy*dy)/t->fac;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* flip scale, but not for manipulator center handle */
|
|
|
|
|
if ((t->center2d[0] - mval[0]) * (t->center2d[0] - t->imval[0]) +
|
|
|
|
|
(t->center2d[1] - mval[1]) * (t->center2d[1] - t->imval[1]) < 0)
|
|
|
|
|
ratio *= -1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size[0] = size[1] = size[2] = ratio;
|
|
|
|
|
|
|
|
|
|
snapGrid(t, size);
|
|
|
|
|
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
applyNumInput(&t->num, size);
|
|
|
|
|
constraintNumInput(t, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SizeToMat3(size, mat);
|
|
|
|
|
|
|
|
|
|
if (t->con.applySize) {
|
|
|
|
|
t->con.applySize(t, NULL, mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Mat3CpyMat3(t->mat, mat); // used in manipulator
|
|
|
|
|
|
|
|
|
|
headerResize(t, size, str);
|
|
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
ElementBoneSize(t, td, mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
2005-08-23 18:13:30 +00:00
|
|
|
viewRedrawForce(t);
|
2005-07-16 19:07:02 +00:00
|
|
|
|
2005-08-16 10:17:02 +00:00
|
|
|
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
|
2005-07-16 19:07:02 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-03 19:54:27 +00:00
|
|
|
|
|
|
|
|
/* ******************** EditBone envelope *************** */
|
|
|
|
|
|
|
|
|
|
void initBoneEnvelope(TransInfo *t)
|
2005-07-16 19:07:02 +00:00
|
|
|
{
|
|
|
|
|
t->idx_max = 0;
|
|
|
|
|
t->num.idx_max = 0;
|
|
|
|
|
t->snap[0] = 0.0f;
|
|
|
|
|
t->snap[1] = 0.1f;
|
|
|
|
|
t->snap[2] = t->snap[1] * 0.1f;
|
2006-12-03 19:54:27 +00:00
|
|
|
t->transform = BoneEnvelope;
|
2006-05-29 13:01:51 +00:00
|
|
|
t->fac = (float)sqrt( (
|
2006-12-03 19:54:27 +00:00
|
|
|
((float)(t->center2d[1] - t->imval[1]))*((float)(t->center2d[1] - t->imval[1]))
|
|
|
|
|
+
|
|
|
|
|
((float)(t->center2d[0] - t->imval[0]))*((float)(t->center2d[0] - t->imval[0]))
|
|
|
|
|
) );
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
|
|
|
|
|
if(t->fac==0.0f) t->fac= 1.0f; // prevent Inf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BoneEnvelope(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
|
|
|
|
TransData *td = t->data;
|
|
|
|
|
float ratio;
|
|
|
|
|
int i;
|
|
|
|
|
char str[50];
|
|
|
|
|
|
|
|
|
|
if(t->flag & T_SHIFT_MOD) {
|
|
|
|
|
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
|
|
|
|
|
float dx= (float)(t->center2d[0] - t->shiftmval[0]);
|
|
|
|
|
float dy= (float)(t->center2d[1] - t->shiftmval[1]);
|
|
|
|
|
ratio = (float)sqrt( dx*dx + dy*dy)/t->fac;
|
|
|
|
|
|
|
|
|
|
dx= (float)(t->center2d[0] - mval[0]);
|
|
|
|
|
dy= (float)(t->center2d[1] - mval[1]);
|
|
|
|
|
ratio+= 0.1f*(float)(sqrt( dx*dx + dy*dy)/t->fac -ratio);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float dx= (float)(t->center2d[0] - mval[0]);
|
|
|
|
|
float dy= (float)(t->center2d[1] - mval[1]);
|
|
|
|
|
ratio = (float)sqrt( dx*dx + dy*dy)/t->fac;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
snapGrid(t, &ratio);
|
|
|
|
|
|
|
|
|
|
applyNumInput(&t->num, &ratio);
|
|
|
|
|
|
|
|
|
|
/* header print for NumInput */
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
char c[20];
|
|
|
|
|
|
|
|
|
|
outputNumInput(&(t->num), c);
|
|
|
|
|
sprintf(str, "Envelope: %s", c);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sprintf(str, "Envelope: %3f", ratio);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if(td->val) *td->val= td->ival*ratio;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
|
|
|
|
force_draw(0);
|
|
|
|
|
|
|
|
|
|
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-03 19:54:27 +00:00
|
|
|
|
|
|
|
|
/* ******************** EditBone roll *************** */
|
|
|
|
|
|
|
|
|
|
void initBoneRoll(TransInfo *t)
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
{
|
|
|
|
|
t->idx_max = 0;
|
|
|
|
|
t->num.idx_max = 0;
|
|
|
|
|
t->snap[0] = 0.0f;
|
2006-12-03 19:54:27 +00:00
|
|
|
t->snap[1] = (float)((5.0/180)*M_PI);
|
|
|
|
|
t->snap[2] = t->snap[1] * 0.2f;
|
2005-07-16 19:07:02 +00:00
|
|
|
|
2006-12-03 19:54:27 +00:00
|
|
|
t->fac = 0.0f;
|
|
|
|
|
|
|
|
|
|
t->transform = BoneRoll;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BoneRoll(TransInfo *t, short mval[2])
|
|
|
|
|
{
|
|
|
|
|
TransData *td = t->data;
|
|
|
|
|
int i;
|
|
|
|
|
char str[50];
|
|
|
|
|
|
|
|
|
|
float final;
|
|
|
|
|
|
|
|
|
|
int dx2 = t->center2d[0] - mval[0];
|
|
|
|
|
int dy2 = t->center2d[1] - mval[1];
|
|
|
|
|
double B = sqrt(dx2*dx2+dy2*dy2);
|
|
|
|
|
|
|
|
|
|
int dx1 = t->center2d[0] - t->imval[0];
|
|
|
|
|
int dy1 = t->center2d[1] - t->imval[1];
|
|
|
|
|
double A = sqrt(dx1*dx1+dy1*dy1);
|
|
|
|
|
|
|
|
|
|
int dx3 = mval[0] - t->imval[0];
|
|
|
|
|
int dy3 = mval[1] - t->imval[1];
|
|
|
|
|
/* use doubles here, to make sure a "1.0" (no rotation) doesnt become 9.999999e-01, which gives 0.02 for acos */
|
|
|
|
|
double deler= ((double)((dx1*dx1+dy1*dy1)+(dx2*dx2+dy2*dy2)-(dx3*dx3+dy3*dy3) ))
|
|
|
|
|
/ (2.0 * (A*B?A*B:1.0));
|
|
|
|
|
/* (A*B?A*B:1.0f) this takes care of potential divide by zero errors */
|
|
|
|
|
|
|
|
|
|
float dphi;
|
|
|
|
|
|
|
|
|
|
dphi = saacos((float)deler);
|
|
|
|
|
if( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
|
|
|
|
|
|
|
|
|
|
if(G.qual & LR_SHIFTKEY) t->fac += dphi/30.0f;
|
|
|
|
|
else t->fac += dphi;
|
|
|
|
|
|
|
|
|
|
final = t->fac;
|
|
|
|
|
|
|
|
|
|
snapGrid(t, &final);
|
|
|
|
|
|
|
|
|
|
t->imval[0] = mval[0];
|
|
|
|
|
t->imval[1] = mval[1];
|
|
|
|
|
|
|
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
char c[20];
|
|
|
|
|
|
|
|
|
|
applyNumInput(&t->num, &final);
|
|
|
|
|
|
|
|
|
|
outputNumInput(&(t->num), c);
|
|
|
|
|
|
|
|
|
|
sprintf(str, "Roll: %s", &c[0]);
|
|
|
|
|
|
|
|
|
|
final *= (float)(M_PI / 180.0);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sprintf(str, "Roll: %.2f", 180.0*final/M_PI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set roll values */
|
|
|
|
|
for (i = 0; i < t->total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
*(td->val) = td->ival - final;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(t);
|
|
|
|
|
|
|
|
|
|
headerprint(str);
|
|
|
|
|
|
|
|
|
|
viewRedrawForce(t);
|
|
|
|
|
|
|
|
|
|
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************** MIRROR *************************** */
|
|
|
|
|
|
|
|
|
|
void Mirror(short mode)
|
|
|
|
|
{
|
|
|
|
|
TransData *td;
|
|
|
|
|
float mati[3][3], matview[3][3], mat[3][3];
|
|
|
|
|
float size[3];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
Trans.context = CTX_NO_PET;
|
|
|
|
|
|
|
|
|
|
initTrans(&Trans); // internal data, mouse, vectors
|
|
|
|
|
|
|
|
|
|
Mat3One(mati);
|
|
|
|
|
Mat3CpyMat4(matview, Trans.viewinv); // t->viewinv was set in initTrans
|
|
|
|
|
Mat3Ortho(matview);
|
|
|
|
|
|
|
|
|
|
initTransModeFlags(&Trans, TFM_MIRROR); // modal settings in struct Trans
|
|
|
|
|
|
|
|
|
|
createTransData(&Trans); // make TransData structs from selection
|
|
|
|
|
|
|
|
|
|
calculatePropRatio(&Trans);
|
|
|
|
|
calculateCenter(&Trans);
|
|
|
|
|
|
|
|
|
|
initResize(&Trans);
|
|
|
|
|
|
|
|
|
|
if (Trans.total == 0) {
|
|
|
|
|
postTrans(&Trans);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size[0] = size[1] = size[2] = 1.0f;
|
|
|
|
|
td = Trans.data;
|
|
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
|
case 1:
|
|
|
|
|
size[0] = -1.0f;
|
|
|
|
|
setConstraint(&Trans, mati, (CON_AXIS0), "");
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
size[1] = -1.0f;
|
|
|
|
|
setConstraint(&Trans, mati, (CON_AXIS1), "");
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
size[2] = -1.0f;
|
|
|
|
|
setConstraint(&Trans, mati, (CON_AXIS2), "");
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
size[0] = -1.0f;
|
|
|
|
|
setLocalConstraint(&Trans, (CON_AXIS0), "");
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
size[1] = -1.0f;
|
|
|
|
|
setLocalConstraint(&Trans, (CON_AXIS1), "");
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
size[2] = -1.0f;
|
|
|
|
|
setLocalConstraint(&Trans, (CON_AXIS2), "");
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
size[0] = -1.0f;
|
|
|
|
|
setConstraint(&Trans, matview, (CON_AXIS0), "");
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
size[1] = -1.0f;
|
|
|
|
|
setConstraint(&Trans, matview, (CON_AXIS1), "");
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
size[2] = -1.0f;
|
|
|
|
|
setConstraint(&Trans, matview, (CON_AXIS2), "");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SizeToMat3(size, mat);
|
|
|
|
|
|
|
|
|
|
if (Trans.con.applySize) {
|
|
|
|
|
Trans.con.applySize(&Trans, NULL, mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = 0 ; i < Trans.total; i++, td++) {
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
ElementResize(&Trans, td, mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recalcData(&Trans);
|
|
|
|
|
|
|
|
|
|
BIF_undo_push("Mirror");
|
|
|
|
|
|
|
|
|
|
/* free data, reset vars */
|
|
|
|
|
postTrans(&Trans);
|
|
|
|
|
|
|
|
|
|
/* send events out for redraws */
|
|
|
|
|
viewRedrawPost(&Trans);
|
2005-07-16 19:07:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************ */
|
2005-05-08 12:00:28 +00:00
|
|
|
|
|
|
|
|
void BIF_TransformSetUndo(char *str)
|
|
|
|
|
{
|
|
|
|
|
Trans.undostr= str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|