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>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef WIN32
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <io.h>
|
|
|
|
|
#include "BLI_winstuff.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_action_types.h"
|
|
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
|
#include "DNA_camera_types.h"
|
|
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
|
#include "DNA_effect_types.h"
|
|
|
|
|
#include "DNA_ika_types.h"
|
|
|
|
|
#include "DNA_image_types.h"
|
|
|
|
|
#include "DNA_ipo_types.h"
|
|
|
|
|
#include "DNA_key_types.h"
|
|
|
|
|
#include "DNA_lamp_types.h"
|
|
|
|
|
#include "DNA_lattice_types.h"
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
#include "DNA_meta_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_texture_types.h"
|
|
|
|
|
#include "DNA_view3d_types.h"
|
|
|
|
|
#include "DNA_world_types.h"
|
|
|
|
|
#include "DNA_userdef_types.h"
|
|
|
|
|
#include "DNA_property_types.h"
|
|
|
|
|
#include "DNA_vfont_types.h"
|
|
|
|
|
#include "DNA_constraint_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BIF_screen.h"
|
|
|
|
|
#include "BIF_space.h"
|
|
|
|
|
#include "BIF_editview.h"
|
|
|
|
|
#include "BIF_resources.h"
|
|
|
|
|
#include "BIF_mywindow.h"
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
#include "BIF_editlattice.h"
|
|
|
|
|
#include "BIF_editarmature.h"
|
|
|
|
|
#include "BIF_editmesh.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_object.h"
|
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
#include "BKE_lattice.h"
|
|
|
|
|
#include "BKE_armature.h"
|
|
|
|
|
#include "BKE_curve.h"
|
|
|
|
|
#include "BKE_displist.h"
|
|
|
|
|
|
|
|
|
|
#include "BSE_view.h"
|
|
|
|
|
#include "BSE_edit.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_arithb.h"
|
|
|
|
|
#include "BLI_editVert.h"
|
|
|
|
|
|
|
|
|
|
#include "BDR_drawobject.h"
|
|
|
|
|
|
|
|
|
|
#include "blendef.h"
|
|
|
|
|
|
|
|
|
|
#include "mydevice.h"
|
|
|
|
|
|
|
|
|
|
#include "transform.h"
|
|
|
|
|
#include "transform_constraints.h"
|
|
|
|
|
#include "transform_generics.h"
|
|
|
|
|
|
|
|
|
|
extern ListBase editNurb;
|
|
|
|
|
extern ListBase editelems;
|
|
|
|
|
|
|
|
|
|
void recalcData();
|
|
|
|
|
|
|
|
|
|
/* ************************** CONSTRAINTS ************************* */
|
|
|
|
|
void getConstraintMatrix(TransInfo *t);
|
|
|
|
|
|
2005-03-12 20:34:02 +00:00
|
|
|
void constraintNumInput(TransInfo *t, float vec[3])
|
|
|
|
|
{
|
|
|
|
|
int mode = t->con.mode;
|
2005-03-16 21:55:57 +00:00
|
|
|
float nval = (t->num.flag & NULLONE)?1.0f:0.0f;
|
2005-03-12 20:34:02 +00:00
|
|
|
|
|
|
|
|
if (getConstraintSpaceDimension(t) == 2) {
|
|
|
|
|
if (mode & (CON_AXIS0|CON_AXIS1)) {
|
|
|
|
|
vec[2] = nval;
|
|
|
|
|
}
|
|
|
|
|
else if (mode & (CON_AXIS1|CON_AXIS2)) {
|
|
|
|
|
vec[2] = vec[1];
|
|
|
|
|
vec[1] = vec[0];
|
|
|
|
|
vec[0] = nval;
|
|
|
|
|
}
|
|
|
|
|
else if (mode & (CON_AXIS0|CON_AXIS2)) {
|
|
|
|
|
vec[2] = vec[1];
|
|
|
|
|
vec[1] = nval;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (getConstraintSpaceDimension(t) == 1) {
|
|
|
|
|
if (mode & CON_AXIS0) {
|
|
|
|
|
vec[1] = nval;
|
|
|
|
|
vec[2] = nval;
|
|
|
|
|
}
|
|
|
|
|
else if (mode & CON_AXIS1) {
|
|
|
|
|
vec[1] = vec[0];
|
|
|
|
|
vec[0] = nval;
|
|
|
|
|
vec[2] = nval;
|
|
|
|
|
}
|
|
|
|
|
else if (mode & CON_AXIS2) {
|
|
|
|
|
vec[2] = vec[0];
|
|
|
|
|
vec[0] = nval;
|
|
|
|
|
vec[1] = nval;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
|
+ 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
|
|
|
int i = 0;
|
2005-03-12 20:34:02 +00:00
|
|
|
|
2005-03-04 00:07:16 +00:00
|
|
|
Mat3MulVecfl(t->con.imtx, vec);
|
|
|
|
|
|
|
|
|
|
snapGrid(t, vec);
|
|
|
|
|
|
2005-03-16 21:55:57 +00:00
|
|
|
if (t->num.flag & NULLONE) {
|
2005-03-04 00:07:16 +00:00
|
|
|
if (!(t->con.mode & CON_AXIS0))
|
|
|
|
|
vec[0] = 1.0f;
|
|
|
|
|
|
|
|
|
|
if (!(t->con.mode & CON_AXIS1))
|
|
|
|
|
vec[1] = 1.0f;
|
|
|
|
|
|
|
|
|
|
if (!(t->con.mode & CON_AXIS2))
|
|
|
|
|
vec[2] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-12 20:34:02 +00:00
|
|
|
if (hasNumInput(&t->num)) {
|
|
|
|
|
applyNumInput(&t->num, vec);
|
|
|
|
|
constraintNumInput(t, vec);
|
|
|
|
|
}
|
+ 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_AXIS0) {
|
|
|
|
|
pvec[i++] = vec[0];
|
|
|
|
|
}
|
|
|
|
|
if (t->con.mode & CON_AXIS1) {
|
|
|
|
|
pvec[i++] = vec[1];
|
|
|
|
|
}
|
|
|
|
|
if (t->con.mode & CON_AXIS2) {
|
|
|
|
|
pvec[i++] = vec[2];
|
|
|
|
|
}
|
2005-03-04 00:07:16 +00:00
|
|
|
|
|
|
|
|
Mat3MulVecfl(t->con.mtx, vec);
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
static void getViewVector(TransInfo *t, float coord[3], float vec[3]) {
|
2005-02-27 19:14:21 +00:00
|
|
|
if (G.vd->persp)
|
|
|
|
|
{
|
|
|
|
|
float p1[4], p2[4];
|
|
|
|
|
|
|
|
|
|
VecAddf(p1, coord, t->con.center);
|
|
|
|
|
p1[3] = 1.0f;
|
|
|
|
|
VECCOPY(p2, p1);
|
|
|
|
|
p2[3] = 1.0f;
|
|
|
|
|
Mat4MulVec4fl(G.vd->viewmat, p2);
|
|
|
|
|
|
|
|
|
|
p2[0] = 2.0f * p2[0];
|
|
|
|
|
p2[1] = 2.0f * p2[1];
|
|
|
|
|
p2[2] = 2.0f * p2[2];
|
|
|
|
|
|
|
|
|
|
Mat4MulVec4fl(G.vd->viewinv, p2);
|
|
|
|
|
|
|
|
|
|
VecSubf(vec, p2, p1);
|
|
|
|
|
Normalise(vec);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
VECCOPY(vec, G.vd->viewinv[2]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3]) {
|
2005-02-27 19:14:21 +00:00
|
|
|
float norm[3], n[3], vec[3], factor;
|
|
|
|
|
|
|
|
|
|
getViewVector(t, in, norm);
|
|
|
|
|
|
2005-02-23 02:23:50 +00:00
|
|
|
Normalise(axis);
|
|
|
|
|
|
|
|
|
|
VECCOPY(n, axis);
|
|
|
|
|
Mat4MulVecfl(G.vd->viewmat, n);
|
|
|
|
|
n[2] = G.vd->viewmat[3][2];
|
|
|
|
|
Mat4MulVecfl(G.vd->viewinv, n);
|
|
|
|
|
|
2005-02-27 19:14:21 +00:00
|
|
|
if (Inpf(axis, norm) != 1.0f) {
|
2005-02-23 02:23:50 +00:00
|
|
|
Projf(vec, in, n);
|
|
|
|
|
factor = Normalise(vec);
|
|
|
|
|
factor /= Inpf(axis, vec);
|
|
|
|
|
|
|
|
|
|
VecMulf(axis, factor);
|
|
|
|
|
VECCOPY(out, axis);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
out[0] = out[1] = out[2] = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
static void planeProjection(TransInfo *t, float in[3], float out[3]) {
|
2005-02-27 19:14:21 +00:00
|
|
|
float vec[3], factor, angle, norm[3];
|
|
|
|
|
|
|
|
|
|
getViewVector(t, in, norm);
|
2005-02-23 02:23:50 +00:00
|
|
|
|
|
|
|
|
VecSubf(vec, out, in);
|
|
|
|
|
factor = Normalise(vec);
|
2005-02-27 19:14:21 +00:00
|
|
|
angle = Inpf(vec, norm);
|
|
|
|
|
|
2005-02-23 02:23:50 +00:00
|
|
|
if (angle * angle >= 0.000001f) {
|
|
|
|
|
factor /= angle;
|
|
|
|
|
|
2005-02-27 19:14:21 +00:00
|
|
|
VECCOPY(vec, norm);
|
2005-02-23 02:23:50 +00:00
|
|
|
VecMulf(vec, factor);
|
|
|
|
|
|
|
|
|
|
VecAddf(out, in, vec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
/*
|
|
|
|
|
* Generic callback for constant spacial constraints applied to linear motion
|
|
|
|
|
*
|
|
|
|
|
* The IN vector in projected into the constrained space and then further
|
|
|
|
|
* projected along the view vector.
|
|
|
|
|
* (in perspective mode, the view vector is relative to the position on screen)
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
static void applyAxisConstraintVec(TransInfo *t, TransData *td, float in[3], float out[3], float pvec[3])
|
2005-02-14 02:53:36 +00:00
|
|
|
{
|
|
|
|
|
VECCOPY(out, in);
|
2005-03-01 19:22:29 +00:00
|
|
|
if (!td && t->con.mode & CON_APPLY) {
|
2005-03-04 00:07:16 +00:00
|
|
|
Mat3MulVecfl(t->con.pmtx, out);
|
2005-03-01 19:22:29 +00:00
|
|
|
if (out[0] != 0.0f || out[1] != 0.0f || out[2] != 0.0f) {
|
2005-02-14 02:53:36 +00:00
|
|
|
if (getConstraintSpaceDimension(t) == 2) {
|
2005-02-27 19:14:21 +00:00
|
|
|
planeProjection(t, in, out);
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
else if (getConstraintSpaceDimension(t) == 1) {
|
2005-02-23 02:23:50 +00:00
|
|
|
float c[3];
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
if (t->con.mode & CON_AXIS0) {
|
2005-02-14 02:53:36 +00:00
|
|
|
VECCOPY(c, t->con.mtx[0]);
|
|
|
|
|
}
|
2005-03-01 19:22:29 +00:00
|
|
|
else if (t->con.mode & CON_AXIS1) {
|
2005-02-14 02:53:36 +00:00
|
|
|
VECCOPY(c, t->con.mtx[1]);
|
|
|
|
|
}
|
2005-03-01 19:22:29 +00:00
|
|
|
else if (t->con.mode & CON_AXIS2) {
|
2005-02-14 02:53:36 +00:00
|
|
|
VECCOPY(c, t->con.mtx[2]);
|
|
|
|
|
}
|
2005-02-27 19:14:21 +00:00
|
|
|
axisProjection(t, c, in, out);
|
2005-02-14 02:53:36 +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
|
|
|
postConstraintChecks(t, out, pvec);
|
2005-03-04 00:07:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-11 01:33:43 +00:00
|
|
|
/*
|
|
|
|
|
* Generic callback for object based spacial constraints applied to linear motion
|
|
|
|
|
*
|
|
|
|
|
* At first, the following is applied to the first data in the array
|
|
|
|
|
* The IN vector in projected into the constrained space and then further
|
|
|
|
|
* projected along the view vector.
|
|
|
|
|
* (in perspective mode, the view vector is relative to the position on screen)
|
|
|
|
|
*
|
|
|
|
|
* Further down, that vector is mapped to each data's space.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static void applyObjectConstraintVec(TransInfo *t, TransData *td, float in[3], float out[3], float pvec[3])
|
|
|
|
|
{
|
|
|
|
|
VECCOPY(out, in);
|
|
|
|
|
if (t->con.mode & CON_APPLY) {
|
|
|
|
|
if (!td) {
|
|
|
|
|
Mat3MulVecfl(t->con.pmtx, out);
|
|
|
|
|
if (out[0] != 0.0f || out[1] != 0.0f || out[2] != 0.0f) {
|
|
|
|
|
if (getConstraintSpaceDimension(t) == 2) {
|
|
|
|
|
planeProjection(t, in, out);
|
|
|
|
|
}
|
|
|
|
|
else if (getConstraintSpaceDimension(t) == 1) {
|
|
|
|
|
float c[3];
|
|
|
|
|
|
|
|
|
|
if (t->con.mode & CON_AXIS0) {
|
|
|
|
|
VECCOPY(c, t->con.mtx[0]);
|
|
|
|
|
}
|
|
|
|
|
else if (t->con.mode & CON_AXIS1) {
|
|
|
|
|
VECCOPY(c, t->con.mtx[1]);
|
|
|
|
|
}
|
|
|
|
|
else if (t->con.mode & CON_AXIS2) {
|
|
|
|
|
VECCOPY(c, t->con.mtx[2]);
|
|
|
|
|
}
|
|
|
|
|
axisProjection(t, c, in, out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
postConstraintChecks(t, out, pvec);
|
|
|
|
|
VECCOPY(out, pvec);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Mat3MulVecfl(td->axismtx, out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-04 00:07:16 +00:00
|
|
|
/*
|
|
|
|
|
* Generic callback for constant spacial constraints applied to resize motion
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
static void applyAxisConstraintSize(TransInfo *t, TransData *td, float smat[3][3])
|
2005-03-04 00:07:16 +00:00
|
|
|
{
|
|
|
|
|
if (!td && t->con.mode & CON_APPLY) {
|
|
|
|
|
float tmat[3][3];
|
|
|
|
|
|
|
|
|
|
if (!(t->con.mode & CON_AXIS0)) {
|
|
|
|
|
smat[0][0] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
if (!(t->con.mode & CON_AXIS1)) {
|
|
|
|
|
smat[1][1] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
if (!(t->con.mode & CON_AXIS2)) {
|
|
|
|
|
smat[2][2] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Mat3MulMat3(tmat, smat, t->con.imtx);
|
|
|
|
|
Mat3MulMat3(smat, t->con.mtx, tmat);
|
2005-02-14 02:53:36 +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
|
|
|
/*
|
|
|
|
|
* Callback for object based spacial constraints applied to resize motion
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2005-03-14 20:10:22 +00:00
|
|
|
static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3][3])
|
+ 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 (td && t->con.mode & CON_APPLY) {
|
|
|
|
|
float tmat[3][3];
|
2005-03-12 23:15:26 +00:00
|
|
|
float imat[3][3];
|
|
|
|
|
|
|
|
|
|
Mat3Inv(imat, td->axismtx);
|
+ 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_AXIS0)) {
|
|
|
|
|
smat[0][0] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
if (!(t->con.mode & CON_AXIS1)) {
|
|
|
|
|
smat[1][1] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
if (!(t->con.mode & CON_AXIS2)) {
|
|
|
|
|
smat[2][2] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-14 23:24:37 +00:00
|
|
|
Mat3MulMat3(tmat, smat, imat);
|
|
|
|
|
Mat3MulMat3(smat, td->axismtx, tmat);
|
+ 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-16 21:55:57 +00:00
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
/*
|
|
|
|
|
* Generic callback for constant spacial constraints applied to rotations
|
|
|
|
|
*
|
|
|
|
|
* The rotation axis is copied into VEC.
|
|
|
|
|
*
|
|
|
|
|
* In the case of single axis constraints, the rotation axis is directly the one constrained to.
|
|
|
|
|
* For planar constraints (2 axis), the rotation axis is the normal of the plane.
|
|
|
|
|
*
|
+ 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
|
|
|
* The following only applies when CON_NOFLIP is not set.
|
2005-02-14 02:53:36 +00:00
|
|
|
* The vector is then modified to always point away from the screen (in global space)
|
|
|
|
|
* This insures that the rotation is always logically following the mouse.
|
|
|
|
|
* (ie: not doing counterclockwise rotations when the mouse moves clockwise).
|
|
|
|
|
*/
|
2005-02-20 01:25:10 +00:00
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3])
|
2005-02-14 02:53:36 +00:00
|
|
|
{
|
2005-03-01 19:22:29 +00:00
|
|
|
if (!td && t->con.mode & CON_APPLY) {
|
|
|
|
|
int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
switch(mode) {
|
2005-03-01 19:22:29 +00:00
|
|
|
case CON_AXIS0:
|
|
|
|
|
case (CON_AXIS1|CON_AXIS2):
|
2005-02-14 02:53:36 +00:00
|
|
|
VECCOPY(vec, t->con.mtx[0]);
|
|
|
|
|
break;
|
2005-03-01 19:22:29 +00:00
|
|
|
case CON_AXIS1:
|
|
|
|
|
case (CON_AXIS0|CON_AXIS2):
|
2005-02-14 02:53:36 +00:00
|
|
|
VECCOPY(vec, t->con.mtx[1]);
|
|
|
|
|
break;
|
2005-03-01 19:22:29 +00:00
|
|
|
case CON_AXIS2:
|
|
|
|
|
case (CON_AXIS0|CON_AXIS1):
|
2005-02-14 02:53:36 +00:00
|
|
|
VECCOPY(vec, t->con.mtx[2]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
+ 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 (!(mode & CON_NOFLIP)) {
|
|
|
|
|
if (Inpf(vec, G.vd->viewinv[2]) > 0.0f) {
|
|
|
|
|
VecMulf(vec, -1.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Callback for object based spacial constraints applied to rotations
|
|
|
|
|
*
|
|
|
|
|
* The rotation axis is copied into VEC.
|
|
|
|
|
*
|
|
|
|
|
* In the case of single axis constraints, the rotation axis is directly the one constrained to.
|
|
|
|
|
* For planar constraints (2 axis), the rotation axis is the normal of the plane.
|
|
|
|
|
*
|
|
|
|
|
* The following only applies when CON_NOFLIP is not set.
|
|
|
|
|
* The vector is then modified to always point away from the screen (in global space)
|
|
|
|
|
* This insures that the rotation is always logically following the mouse.
|
|
|
|
|
* (ie: not doing counterclockwise rotations when the mouse moves clockwise).
|
|
|
|
|
*/
|
|
|
|
|
|
2005-03-14 20:10:22 +00:00
|
|
|
static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3])
|
+ 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 (td && t->con.mode & CON_APPLY) {
|
|
|
|
|
int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
|
|
|
|
|
|
|
|
|
|
switch(mode) {
|
|
|
|
|
case CON_AXIS0:
|
|
|
|
|
case (CON_AXIS1|CON_AXIS2):
|
|
|
|
|
VECCOPY(vec, td->axismtx[0]);
|
|
|
|
|
break;
|
|
|
|
|
case CON_AXIS1:
|
|
|
|
|
case (CON_AXIS0|CON_AXIS2):
|
|
|
|
|
VECCOPY(vec, td->axismtx[1]);
|
|
|
|
|
break;
|
|
|
|
|
case CON_AXIS2:
|
|
|
|
|
case (CON_AXIS0|CON_AXIS1):
|
|
|
|
|
VECCOPY(vec, td->axismtx[2]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!(mode & CON_NOFLIP)) {
|
|
|
|
|
if (Inpf(vec, G.vd->viewinv[2]) > 0.0f) {
|
|
|
|
|
VecMulf(vec, -1.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-14 20:10:22 +00:00
|
|
|
static void drawObjectConstraint(TransInfo *t) {
|
+ 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
|
|
|
int i;
|
|
|
|
|
TransData * td = t->data;
|
|
|
|
|
|
|
|
|
|
if (t->con.mode & CON_AXIS0) {
|
2005-03-16 21:55:57 +00:00
|
|
|
drawLine(td->ob->obmat[3], td->axismtx[0], 'x', DRAWLIGHT);
|
+ 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_AXIS1) {
|
2005-03-16 21:55:57 +00:00
|
|
|
drawLine(td->ob->obmat[3], td->axismtx[1], 'y', DRAWLIGHT);
|
+ 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_AXIS2) {
|
2005-03-16 21:55:57 +00:00
|
|
|
drawLine(td->ob->obmat[3], td->axismtx[2], 'z', DRAWLIGHT);
|
+ 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
td++;
|
|
|
|
|
for(i=1;i<t->total;i++,td++) {
|
|
|
|
|
if (t->con.mode & CON_AXIS0) {
|
2005-03-16 21:55:57 +00:00
|
|
|
drawLine(td->ob->obmat[3], td->axismtx[0], 'x', 0);
|
+ 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_AXIS1) {
|
2005-03-16 21:55:57 +00:00
|
|
|
drawLine(td->ob->obmat[3], td->axismtx[1], 'y', 0);
|
+ 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_AXIS2) {
|
2005-03-16 21:55:57 +00:00
|
|
|
drawLine(td->ob->obmat[3], td->axismtx[2], 'z', 0);
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Returns the dimension of the constraint space.
|
|
|
|
|
*
|
|
|
|
|
* For that reason, the flags always needs to be set to properly evaluate here,
|
|
|
|
|
* even if they aren't actually used in the callback function. (Which could happen
|
|
|
|
|
* for weird constraints not yet designed. Along a path for example.)
|
|
|
|
|
*/
|
2005-02-20 01:25:10 +00:00
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
int getConstraintSpaceDimension(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
int n = 0;
|
|
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
if (t->con.mode & CON_AXIS0)
|
2005-02-14 02:53:36 +00:00
|
|
|
n++;
|
|
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
if (t->con.mode & CON_AXIS1)
|
2005-02-14 02:53:36 +00:00
|
|
|
n++;
|
|
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
if (t->con.mode & CON_AXIS2)
|
2005-02-14 02:53:36 +00:00
|
|
|
n++;
|
|
|
|
|
|
|
|
|
|
return n;
|
2005-03-04 00:07:16 +00:00
|
|
|
/*
|
|
|
|
|
Someone willing to do it criptically could do the following instead:
|
|
|
|
|
|
|
|
|
|
return t->con & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
|
|
|
|
|
|
|
|
|
|
Based on the assumptions that the axis flags are one after the other and start at 1
|
|
|
|
|
*/
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-07 02:21:04 +00:00
|
|
|
void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]) {
|
+ 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
|
|
|
strcpy(t->con.text + 1, text);
|
2005-02-20 01:25:10 +00:00
|
|
|
Mat3CpyMat3(t->con.mtx, space);
|
2005-03-07 02:21:04 +00:00
|
|
|
t->con.mode = mode;
|
2005-02-20 01:25:10 +00:00
|
|
|
getConstraintMatrix(t);
|
|
|
|
|
|
+ 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
|
|
|
startConstraint(t);
|
|
|
|
|
|
2005-02-20 01:25:10 +00:00
|
|
|
t->con.applyVec = applyAxisConstraintVec;
|
2005-03-04 00:07:16 +00:00
|
|
|
t->con.applySize = applyAxisConstraintSize;
|
2005-02-20 01:25:10 +00:00
|
|
|
t->con.applyRot = applyAxisConstraintRot;
|
|
|
|
|
t->redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-07 02:21:04 +00:00
|
|
|
void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
|
2005-03-12 20:34:02 +00:00
|
|
|
if (t->flag & T_EDIT) {
|
2005-03-07 02:21:04 +00:00
|
|
|
float obmat[3][3];
|
|
|
|
|
Mat3CpyMat4(obmat, G.obedit->obmat);
|
|
|
|
|
setConstraint(t, obmat, mode, text);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (t->total == 1) {
|
2005-03-11 01:33:43 +00:00
|
|
|
setConstraint(t, t->data->axismtx, mode, text);
|
2005-03-07 02:21:04 +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
|
|
|
else {
|
|
|
|
|
strcpy(t->con.text + 1, text);
|
2005-03-11 01:33:43 +00:00
|
|
|
Mat3CpyMat3(t->con.mtx, t->data->axismtx);
|
+ 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
|
|
|
t->con.mode = mode;
|
|
|
|
|
getConstraintMatrix(t);
|
|
|
|
|
|
|
|
|
|
startConstraint(t);
|
|
|
|
|
|
|
|
|
|
t->con.drawExtra = drawObjectConstraint;
|
2005-03-11 01:33:43 +00:00
|
|
|
t->con.applyVec = applyObjectConstraintVec;
|
+ 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
|
|
|
t->con.applySize = applyObjectConstraintSize;
|
|
|
|
|
t->con.applyRot = applyObjectConstraintRot;
|
|
|
|
|
t->redraw = 1;
|
|
|
|
|
}
|
2005-03-07 02:21:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BIF_setSingleAxisConstraint(float vec[3]) {
|
|
|
|
|
TransInfo *t = BIF_GetTransInfo();
|
|
|
|
|
float space[3][3], v[3];
|
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-07 02:21:04 +00:00
|
|
|
VECCOPY(space[0], vec);
|
|
|
|
|
|
|
|
|
|
v[0] = vec[2];
|
|
|
|
|
v[1] = vec[0];
|
|
|
|
|
v[2] = vec[1];
|
|
|
|
|
|
|
|
|
|
Crossf(space[1], vec, v);
|
|
|
|
|
Crossf(space[2], vec, space[1]);
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
Mat3CpyMat3(t->con.mtx, space);
|
2005-03-07 02:21:04 +00:00
|
|
|
t->con.mode = (CON_AXIS0|CON_APPLY);
|
2005-02-14 02:53:36 +00:00
|
|
|
getConstraintMatrix(t);
|
|
|
|
|
|
+ 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
|
|
|
t->con.drawExtra = NULL;
|
2005-02-14 02:53:36 +00:00
|
|
|
t->con.applyVec = applyAxisConstraintVec;
|
2005-03-04 00:07:16 +00:00
|
|
|
t->con.applySize = applyAxisConstraintSize;
|
2005-02-14 02:53:36 +00:00
|
|
|
t->con.applyRot = applyAxisConstraintRot;
|
|
|
|
|
t->redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
void BIF_setDualAxisConstraint(float vec1[3], float vec2[3]) {
|
|
|
|
|
TransInfo *t = BIF_GetTransInfo();
|
|
|
|
|
float space[3][3];
|
|
|
|
|
|
|
|
|
|
VECCOPY(space[0], vec1);
|
|
|
|
|
VECCOPY(space[1], vec2);
|
|
|
|
|
Crossf(space[2], space[0], space[1]);
|
|
|
|
|
|
|
|
|
|
Mat3CpyMat3(t->con.mtx, space);
|
|
|
|
|
t->con.mode = (CON_AXIS0|CON_AXIS1|CON_APPLY);
|
|
|
|
|
getConstraintMatrix(t);
|
|
|
|
|
|
|
|
|
|
t->con.drawExtra = NULL;
|
|
|
|
|
t->con.applyVec = applyAxisConstraintVec;
|
|
|
|
|
t->con.applySize = applyAxisConstraintSize;
|
|
|
|
|
t->con.applyRot = applyAxisConstraintRot;
|
|
|
|
|
t->redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
void BIF_drawConstraint(void)
|
2005-02-20 01:25:10 +00:00
|
|
|
{
|
|
|
|
|
TransInfo *t = BIF_GetTransInfo();
|
|
|
|
|
TransCon *tc = &(t->con);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-07 02:21:04 +00:00
|
|
|
if (!(tc->mode & CON_APPLY))
|
2005-02-14 02:53:36 +00:00
|
|
|
return;
|
|
|
|
|
|
+ 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 (tc->drawExtra) {
|
|
|
|
|
tc->drawExtra(t);
|
2005-02-14 02:53:36 +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
|
|
|
else {
|
|
|
|
|
if (tc->mode & CON_SELECT) {
|
2005-03-17 02:34:25 +00:00
|
|
|
float vec[3];
|
|
|
|
|
short mval[2];
|
|
|
|
|
char col2[3] = {255,255,255};
|
|
|
|
|
getmouseco_areawin(mval);
|
|
|
|
|
window_to_3d(vec, (short)(mval[0] - t->con.imval[0]), (short)(mval[1] - t->con.imval[1]));
|
|
|
|
|
VecAddf(vec, vec, tc->center);
|
|
|
|
|
|
|
|
|
|
drawLine(tc->center, tc->mtx[0], 'x', 0);
|
|
|
|
|
drawLine(tc->center, tc->mtx[1], 'y', 0);
|
|
|
|
|
drawLine(tc->center, tc->mtx[2], 'z', 0);
|
|
|
|
|
|
|
|
|
|
glColor3ubv(col2);
|
|
|
|
|
|
|
|
|
|
setlinestyle(1);
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
glVertex3fv(tc->center);
|
|
|
|
|
glVertex3fv(vec);
|
|
|
|
|
glEnd();
|
+ 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-02-14 02:53:36 +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 (tc->mode & CON_AXIS0) {
|
2005-03-16 21:55:57 +00:00
|
|
|
drawLine(tc->center, tc->mtx[0], 'x', DRAWLIGHT);
|
+ 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 (tc->mode & CON_AXIS1) {
|
2005-03-16 21:55:57 +00:00
|
|
|
drawLine(tc->center, tc->mtx[1], 'y', DRAWLIGHT);
|
+ 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 (tc->mode & CON_AXIS2) {
|
2005-03-16 21:55:57 +00:00
|
|
|
drawLine(tc->center, tc->mtx[2], 'z', DRAWLIGHT);
|
+ 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-01 19:22:29 +00:00
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-20 19:00:00 +00:00
|
|
|
/* called from drawview.c, as an extra per-window draw option */
|
2005-02-20 01:25:10 +00:00
|
|
|
void BIF_drawPropCircle()
|
2005-02-14 02:53:36 +00:00
|
|
|
{
|
2005-02-20 01:25:10 +00:00
|
|
|
TransInfo *t = BIF_GetTransInfo();
|
2005-02-14 02:53:36 +00:00
|
|
|
|
|
|
|
|
if (G.f & G_PROPORTIONAL) {
|
|
|
|
|
float tmat[4][4], imat[4][4];
|
|
|
|
|
|
|
|
|
|
BIF_ThemeColor(TH_GRID);
|
2005-02-19 16:37:48 +00:00
|
|
|
|
|
|
|
|
/* if editmode we need to go into object space */
|
|
|
|
|
if(G.obedit) mymultmatrix(G.obedit->obmat);
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
mygetmatrix(tmat);
|
|
|
|
|
Mat4Invert(imat, tmat);
|
2005-02-19 16:37:48 +00:00
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
drawcircball(t->center, t->propsize, imat);
|
2005-02-19 16:37:48 +00:00
|
|
|
|
|
|
|
|
/* if editmode we restore */
|
|
|
|
|
if(G.obedit) myloadmatrix(G.vd->viewmat);
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-04 00:07:16 +00:00
|
|
|
void startConstraint(TransInfo *t) {
|
|
|
|
|
t->con.mode |= CON_APPLY;
|
+ 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
|
|
|
*t->con.text = ' ';
|
2005-03-04 03:52:09 +00:00
|
|
|
t->num.idx_max = MIN2(getConstraintSpaceDimension(t) - 1, t->idx_max);
|
2005-03-04 00:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void stopConstraint(TransInfo *t) {
|
|
|
|
|
t->con.mode &= ~CON_APPLY;
|
+ 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
|
|
|
*t->con.text = '\0';
|
2005-03-04 00:07:16 +00:00
|
|
|
t->num.idx_max = t->idx_max;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
void getConstraintMatrix(TransInfo *t)
|
|
|
|
|
{
|
+ 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 mat[3][3];
|
|
|
|
|
Mat3Inv(t->con.imtx, t->con.mtx);
|
|
|
|
|
Mat3One(t->con.pmtx);
|
2005-02-14 02:53:36 +00:00
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
if (!(t->con.mode & CON_AXIS0)) {
|
2005-03-04 00:07:16 +00:00
|
|
|
t->con.pmtx[0][0] =
|
|
|
|
|
t->con.pmtx[0][1] =
|
|
|
|
|
t->con.pmtx[0][2] = 0.0f;
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
if (!(t->con.mode & CON_AXIS1)) {
|
2005-03-04 00:07:16 +00:00
|
|
|
t->con.pmtx[1][0] =
|
|
|
|
|
t->con.pmtx[1][1] =
|
|
|
|
|
t->con.pmtx[1][2] = 0.0f;
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
if (!(t->con.mode & CON_AXIS2)) {
|
2005-03-04 00:07:16 +00:00
|
|
|
t->con.pmtx[2][0] =
|
|
|
|
|
t->con.pmtx[2][1] =
|
|
|
|
|
t->con.pmtx[2][2] = 0.0f;
|
2005-02-14 02:53:36 +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
|
|
|
|
|
|
|
|
Mat3MulMat3(mat, t->con.pmtx, t->con.imtx);
|
|
|
|
|
Mat3MulMat3(t->con.pmtx, t->con.mtx, mat);
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
void initSelectConstraint(TransInfo *t)
|
2005-02-14 02:53:36 +00:00
|
|
|
{
|
|
|
|
|
Mat3One(t->con.mtx);
|
2005-03-04 00:07:16 +00:00
|
|
|
Mat3One(t->con.pmtx);
|
2005-03-01 19:22:29 +00:00
|
|
|
t->con.mode |= CON_APPLY;
|
|
|
|
|
t->con.mode |= CON_SELECT;
|
2005-02-14 02:53:36 +00:00
|
|
|
VECCOPY(t->con.center, t->center);
|
2005-03-12 20:34:02 +00:00
|
|
|
|
|
|
|
|
if (t->flag & T_EDIT) {
|
2005-02-14 02:53:36 +00:00
|
|
|
Mat4MulVecfl(G.obedit->obmat, t->con.center);
|
|
|
|
|
}
|
2005-03-12 20:34:02 +00:00
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
setNearestAxis(t);
|
+ 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
|
|
|
t->con.drawExtra = NULL;
|
2005-03-01 19:22:29 +00:00
|
|
|
t->con.applyVec = applyAxisConstraintVec;
|
2005-03-04 00:07:16 +00:00
|
|
|
t->con.applySize = applyAxisConstraintSize;
|
2005-03-01 19:22:29 +00:00
|
|
|
t->con.applyRot = applyAxisConstraintRot;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void selectConstraint(TransInfo *t) {
|
|
|
|
|
if (t->con.mode & CON_SELECT) {
|
|
|
|
|
setNearestAxis(t);
|
|
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
void postSelectConstraint(TransInfo *t)
|
|
|
|
|
{
|
2005-03-17 02:34:25 +00:00
|
|
|
if (!(t->con.mode & CON_SELECT))
|
|
|
|
|
return;
|
|
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
t->con.mode &= ~CON_AXIS0;
|
|
|
|
|
t->con.mode &= ~CON_AXIS1;
|
|
|
|
|
t->con.mode &= ~CON_AXIS2;
|
|
|
|
|
t->con.mode &= ~CON_SELECT;
|
|
|
|
|
|
|
|
|
|
setNearestAxis(t);
|
|
|
|
|
|
2005-03-04 00:07:16 +00:00
|
|
|
startConstraint(t);
|
2005-03-01 19:22:29 +00:00
|
|
|
t->redraw = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setNearestAxis(TransInfo *t)
|
2005-02-14 02:53:36 +00:00
|
|
|
{
|
|
|
|
|
short coord[2];
|
|
|
|
|
float mvec[3], axis[3], center[3], proj[3];
|
|
|
|
|
float len[3];
|
|
|
|
|
int i;
|
|
|
|
|
|
2005-03-01 19:22:29 +00:00
|
|
|
t->con.mode &= ~CON_AXIS0;
|
|
|
|
|
t->con.mode &= ~CON_AXIS1;
|
|
|
|
|
t->con.mode &= ~CON_AXIS2;
|
|
|
|
|
|
2005-02-14 02:53:36 +00:00
|
|
|
VECCOPY(center, t->center);
|
|
|
|
|
if (G.obedit) {
|
|
|
|
|
Mat4MulVecfl(G.obedit->obmat, center);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getmouseco_areawin(coord);
|
2005-03-17 02:34:25 +00:00
|
|
|
#if 1
|
|
|
|
|
mvec[0] = (float)(coord[0] - t->con.imval[0]);
|
|
|
|
|
mvec[1] = (float)(coord[1] - t->con.imval[1]);
|
|
|
|
|
#else
|
2005-02-14 02:53:36 +00:00
|
|
|
mvec[0] = (float)(coord[0] - t->center2d[0]);
|
|
|
|
|
mvec[1] = (float)(coord[1] - t->center2d[1]);
|
2005-03-17 02:34:25 +00:00
|
|
|
#endif
|
2005-02-14 02:53:36 +00:00
|
|
|
mvec[2] = 0.0f;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i<3; i++) {
|
|
|
|
|
VECCOPY(axis, t->con.mtx[i]);
|
|
|
|
|
VecAddf(axis, axis, center);
|
|
|
|
|
project_short_noclip(axis, coord);
|
|
|
|
|
axis[0] = (float)(coord[0] - t->center2d[0]);
|
|
|
|
|
axis[1] = (float)(coord[1] - t->center2d[1]);
|
|
|
|
|
axis[2] = 0.0f;
|
|
|
|
|
|
|
|
|
|
if (Normalise(axis) != 0.0f) {
|
|
|
|
|
Projf(proj, mvec, axis);
|
|
|
|
|
VecSubf(axis, mvec, proj);
|
|
|
|
|
len[i] = Normalise(axis);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
len[i] = 10000000000.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (len[0] < len[1] && len[0] < len[2]) {
|
2005-03-16 21:55:57 +00:00
|
|
|
if (G.qual & LR_SHIFTKEY) {
|
2005-03-01 19:22:29 +00:00
|
|
|
t->con.mode |= (CON_AXIS1|CON_AXIS2);
|
+ 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
|
|
|
strcpy(t->con.text, " locking global X");
|
2005-03-01 19:22:29 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
t->con.mode |= CON_AXIS0;
|
+ 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
|
|
|
strcpy(t->con.text, " along global X");
|
2005-03-01 19:22:29 +00:00
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
else if (len[1] < len[0] && len[1] < len[2]) {
|
2005-03-16 21:55:57 +00:00
|
|
|
if (G.qual & LR_SHIFTKEY) {
|
2005-03-01 19:22:29 +00:00
|
|
|
t->con.mode |= (CON_AXIS0|CON_AXIS2);
|
+ 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
|
|
|
strcpy(t->con.text, " locking global Y");
|
2005-03-01 19:22:29 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
t->con.mode |= CON_AXIS1;
|
+ 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
|
|
|
strcpy(t->con.text, " along global Y");
|
2005-03-01 19:22:29 +00:00
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
else if (len[2] < len[1] && len[2] < len[0]) {
|
2005-03-16 21:55:57 +00:00
|
|
|
if (G.qual & LR_SHIFTKEY) {
|
2005-03-01 19:22:29 +00:00
|
|
|
t->con.mode |= (CON_AXIS0|CON_AXIS1);
|
+ 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
|
|
|
strcpy(t->con.text, " locking global Z");
|
2005-03-01 19:22:29 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
t->con.mode |= CON_AXIS2;
|
+ 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
|
|
|
strcpy(t->con.text, " along global Z");
|
2005-03-01 19:22:29 +00:00
|
|
|
}
|
2005-02-14 02:53:36 +00:00
|
|
|
}
|
|
|
|
|
getConstraintMatrix(t);
|
|
|
|
|
}
|