2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2010-03-21 01:14:04 +00:00
|
|
|
* $Id$
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
*
|
|
|
|
* ***** BEGIN GPL 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.
|
|
|
|
*
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
*
|
|
|
|
* 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): Martin Poirier
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
2011-02-27 20:29:51 +00:00
|
|
|
|
|
|
|
/** \file blender/editors/transform/transform_snap.c
|
|
|
|
* \ingroup edtransform
|
|
|
|
*/
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <float.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "PIL_time.h"
|
|
|
|
|
2009-02-24 21:25:36 +00:00
|
|
|
#include "DNA_armature_types.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_object_types.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
#include "DNA_meshdata_types.h" // Temporary, for snapping to other unselected meshes
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
#include "DNA_view3d_types.h"
|
2009-03-29 19:52:53 +00:00
|
|
|
#include "DNA_windowmanager_types.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
#include "BLI_editVert.h"
|
2009-02-24 00:45:40 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
//#include "BDR_drawobject.h"
|
|
|
|
//
|
|
|
|
//#include "editmesh.h"
|
|
|
|
//#include "BIF_editsima.h"
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
//#include "BIF_mywindow.h"
|
|
|
|
//#include "BIF_screen.h"
|
|
|
|
//#include "BIF_editsima.h"
|
|
|
|
//#include "BIF_drawimage.h"
|
|
|
|
//#include "BIF_editmesh.h"
|
|
|
|
|
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
#include "BKE_object.h"
|
|
|
|
#include "BKE_anim.h" /* for duplis */
|
|
|
|
#include "BKE_context.h"
|
|
|
|
|
2009-03-17 21:44:58 +00:00
|
|
|
#include "ED_armature.h"
|
2009-01-28 21:43:43 +00:00
|
|
|
#include "ED_image.h"
|
2009-01-20 19:58:05 +00:00
|
|
|
#include "ED_mesh.h"
|
2009-01-28 21:43:43 +00:00
|
|
|
#include "ED_uvedit.h"
|
|
|
|
#include "ED_view3d.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-01-10 18:33:16 +00:00
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
2009-01-28 21:43:43 +00:00
|
|
|
#include "UI_view2d.h"
|
2009-01-10 18:33:16 +00:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "transform.h"
|
2009-01-10 18:33:16 +00:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
//#include "blendef.h" /* for selection modes */
|
|
|
|
|
2011-02-23 03:08:14 +00:00
|
|
|
#define USE_BVH_FACE_SNAP
|
2011-02-17 12:05:09 +00:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
/********************* PROTOTYPES ***********************/
|
|
|
|
|
2009-12-03 19:18:00 +00:00
|
|
|
void setSnappingCallback(TransInfo *t);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
void ApplySnapTranslation(TransInfo *t, float vec[3]);
|
|
|
|
void ApplySnapRotation(TransInfo *t, float *vec);
|
|
|
|
void ApplySnapResize(TransInfo *t, float *vec);
|
|
|
|
|
|
|
|
void CalcSnapGrid(TransInfo *t, float *vec);
|
|
|
|
void CalcSnapGeometry(TransInfo *t, float *vec);
|
|
|
|
|
|
|
|
void TargetSnapMedian(TransInfo *t);
|
|
|
|
void TargetSnapCenter(TransInfo *t);
|
|
|
|
void TargetSnapClosest(TransInfo *t);
|
|
|
|
void TargetSnapActive(TransInfo *t);
|
|
|
|
|
|
|
|
float RotationBetween(TransInfo *t, float p1[3], float p2[3]);
|
|
|
|
float TranslationBetween(TransInfo *t, float p1[3], float p2[3]);
|
|
|
|
float ResizeBetween(TransInfo *t, float p1[3], float p2[3]);
|
|
|
|
|
|
|
|
|
|
|
|
/****************** IMPLEMENTATIONS *********************/
|
|
|
|
|
2011-02-07 12:07:26 +00:00
|
|
|
#if 0
|
2008-12-31 22:43:29 +00:00
|
|
|
int BIF_snappingSupported(Object *obedit)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
int status = 0;
|
|
|
|
|
2011-02-07 12:07:26 +00:00
|
|
|
if (obedit == NULL || ELEM4(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE)) /* only support object mesh, armature, curves */
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
status = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
2011-02-07 12:07:26 +00:00
|
|
|
#endif
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-12-03 19:18:00 +00:00
|
|
|
int validSnap(TransInfo *t)
|
|
|
|
{
|
2009-12-01 18:26:18 +00:00
|
|
|
return (t->tsnap.status & (POINT_INIT|TARGET_INIT)) == (POINT_INIT|TARGET_INIT) ||
|
|
|
|
(t->tsnap.status & (MULTI_POINTS|TARGET_INIT)) == (MULTI_POINTS|TARGET_INIT);
|
|
|
|
}
|
|
|
|
|
2009-12-03 19:18:00 +00:00
|
|
|
int activeSnap(TransInfo *t)
|
|
|
|
{
|
|
|
|
return (t->modifiers & (MOD_SNAP|MOD_SNAP_INVERT)) == MOD_SNAP || (t->modifiers & (MOD_SNAP|MOD_SNAP_INVERT)) == MOD_SNAP_INVERT;
|
|
|
|
}
|
|
|
|
|
2009-03-28 20:46:38 +00:00
|
|
|
void drawSnapping(const struct bContext *C, TransInfo *t)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2009-12-03 19:18:00 +00:00
|
|
|
if (validSnap(t) && activeSnap(t))
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
|
2010-12-20 03:59:22 +00:00
|
|
|
unsigned char col[4];
|
2009-01-10 18:33:16 +00:00
|
|
|
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
|
2010-12-20 03:59:22 +00:00
|
|
|
col[3]= 128;
|
|
|
|
glColor4ubv(col);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
if (t->spacetype == SPACE_VIEW3D) {
|
2009-12-01 18:26:18 +00:00
|
|
|
TransSnapPoint *p;
|
2009-03-28 20:46:38 +00:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
2010-09-28 10:03:56 +00:00
|
|
|
float imat[4][4];
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
float size;
|
|
|
|
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
|
2010-11-05 05:26:34 +00:00
|
|
|
size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
|
2010-09-28 10:03:56 +00:00
|
|
|
|
|
|
|
invert_m4_m4(imat, rv3d->viewmat);
|
2009-01-10 18:33:16 +00:00
|
|
|
|
2009-12-01 18:26:18 +00:00
|
|
|
for (p = t->tsnap.points.first; p; p = p->next) {
|
2011-05-21 08:56:37 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, p->co, ED_view3d_pixel_size(rv3d, p->co) * size, imat);
|
2009-12-01 18:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (t->tsnap.status & POINT_INIT) {
|
2011-05-21 08:56:37 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, t->tsnap.snapPoint, ED_view3d_pixel_size(rv3d, t->tsnap.snapPoint) * size, imat);
|
2009-12-01 18:26:18 +00:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
/* draw normal if needed */
|
|
|
|
if (usingSnappingNormal(t) && validSnappingNormal(t))
|
|
|
|
{
|
|
|
|
glBegin(GL_LINES);
|
2009-01-10 18:33:16 +00:00
|
|
|
glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]);
|
|
|
|
glVertex3f( t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0],
|
|
|
|
t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1],
|
|
|
|
t->tsnap.snapPoint[2] + t->tsnap.snapNormal[2]);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(v3d->zbuf)
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
}
|
|
|
|
else if (t->spacetype==SPACE_IMAGE)
|
|
|
|
{
|
|
|
|
/*This will not draw, and Im nor sure why - campbell */
|
|
|
|
|
|
|
|
/*
|
|
|
|
float xuser_asp, yuser_asp;
|
|
|
|
int wi, hi;
|
|
|
|
float w, h;
|
|
|
|
|
|
|
|
calc_image_view(G.sima, 'f'); // float
|
|
|
|
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
|
|
|
|
glLoadIdentity();
|
|
|
|
|
2009-01-28 21:43:43 +00:00
|
|
|
ED_space_image_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp);
|
|
|
|
ED_space_image_width(t->sa->spacedata.first, &wi, &hi);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
w = (((float)wi)/256.0f)*G.sima->zoom * xuser_asp;
|
|
|
|
h = (((float)hi)/256.0f)*G.sima->zoom * yuser_asp;
|
|
|
|
|
|
|
|
cpack(0xFFFFFF);
|
|
|
|
glTranslatef(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], 0.0f);
|
|
|
|
|
|
|
|
//glRectf(0,0,1,1);
|
|
|
|
|
|
|
|
setlinestyle(0);
|
|
|
|
cpack(0x0);
|
|
|
|
fdrawline(-0.020/w, 0, -0.1/w, 0);
|
|
|
|
fdrawline(0.1/w, 0, .020/w, 0);
|
|
|
|
fdrawline(0, -0.020/h, 0, -0.1/h);
|
|
|
|
fdrawline(0, 0.1/h, 0, 0.020/h);
|
|
|
|
|
|
|
|
glTranslatef(-t->tsnap.snapPoint[0], -t->tsnap.snapPoint[1], 0.0f);
|
|
|
|
setlinestyle(0);
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
int handleSnapping(TransInfo *UNUSED(t), wmEvent *UNUSED(event))
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
int status = 0;
|
2009-11-26 19:47:55 +00:00
|
|
|
|
|
|
|
#if 0 // XXX need a proper selector for all snap mode
|
2008-12-31 22:43:29 +00:00
|
|
|
if (BIF_snappingSupported(t->obedit) && event->type == TABKEY && event->shift)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
/* toggle snap and reinit */
|
2009-06-23 00:41:55 +00:00
|
|
|
t->settings->snap_flag ^= SCE_SNAP;
|
2009-03-29 19:52:53 +00:00
|
|
|
initSnapping(t, NULL);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
status = 1;
|
|
|
|
}
|
2009-11-26 19:47:55 +00:00
|
|
|
#endif
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2009-10-12 22:33:32 +00:00
|
|
|
void applyProject(TransInfo *t)
|
|
|
|
{
|
|
|
|
/* XXX FLICKER IN OBJECT MODE */
|
2010-03-28 13:59:33 +00:00
|
|
|
if ((t->tsnap.project) && activeSnap(t) && (t->flag & T_NO_PROJECT) == 0)
|
2009-10-12 22:33:32 +00:00
|
|
|
{
|
|
|
|
TransData *td = t->data;
|
|
|
|
float tvec[3];
|
|
|
|
float imat[4][4];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(t->flag & (T_EDIT|T_POSE)) {
|
|
|
|
Object *ob = t->obedit?t->obedit:t->poseobj;
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, ob->obmat);
|
2009-10-12 22:33:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0 ; i < t->total; i++, td++) {
|
|
|
|
float iloc[3], loc[3], no[3];
|
|
|
|
float mval[2];
|
|
|
|
int dist = 1000;
|
|
|
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (td->flag & TD_SKIP)
|
|
|
|
continue;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(iloc, td->loc);
|
2009-10-12 22:33:32 +00:00
|
|
|
if (t->flag & (T_EDIT|T_POSE))
|
|
|
|
{
|
|
|
|
Object *ob = t->obedit?t->obedit:t->poseobj;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, iloc);
|
2009-10-12 22:33:32 +00:00
|
|
|
}
|
|
|
|
else if (t->flag & T_OBJECT)
|
|
|
|
{
|
2010-12-17 15:51:42 +00:00
|
|
|
td->ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
|
2010-11-21 18:31:00 +00:00
|
|
|
object_handle_update(t->scene, td->ob);
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(iloc, td->ob->obmat[3]);
|
2009-10-12 22:33:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
project_float(t->ar, iloc, mval);
|
|
|
|
|
2010-02-03 20:49:05 +00:00
|
|
|
if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect))
|
2009-10-12 22:33:32 +00:00
|
|
|
{
|
|
|
|
// if(t->flag & (T_EDIT|T_POSE)) {
|
2009-11-10 20:43:45 +00:00
|
|
|
// mul_m4_v3(imat, loc);
|
2009-10-12 22:33:32 +00:00
|
|
|
// }
|
|
|
|
//
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(tvec, loc, iloc);
|
2009-10-12 22:33:32 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(td->smtx, tvec);
|
2009-10-12 22:33:32 +00:00
|
|
|
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(td->loc, tvec);
|
2009-10-12 22:33:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//XXX constraintTransLim(t, td);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
void applySnapping(TransInfo *t, float *vec)
|
|
|
|
{
|
2009-10-12 22:33:32 +00:00
|
|
|
/* project is not applied this way */
|
|
|
|
if (t->tsnap.project)
|
|
|
|
return;
|
|
|
|
|
2009-03-29 19:52:53 +00:00
|
|
|
if (t->tsnap.status & SNAP_FORCED)
|
|
|
|
{
|
|
|
|
t->tsnap.targetSnap(t);
|
|
|
|
|
|
|
|
t->tsnap.applySnap(t, vec);
|
|
|
|
}
|
2009-12-03 19:18:00 +00:00
|
|
|
else if ((t->tsnap.mode != SCE_SNAP_MODE_INCREMENT) && activeSnap(t))
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
double current = PIL_check_seconds_timer();
|
|
|
|
|
|
|
|
// Time base quirky code to go around findnearest slowness
|
|
|
|
/* !TODO! add exception for object mode, no need to slow it down then */
|
2009-11-25 22:14:51 +00:00
|
|
|
if (current - t->tsnap.last >= 0.01)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
t->tsnap.calcSnap(t, vec);
|
|
|
|
t->tsnap.targetSnap(t);
|
|
|
|
|
|
|
|
t->tsnap.last = current;
|
|
|
|
}
|
2009-12-01 18:26:18 +00:00
|
|
|
if (validSnap(t))
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
t->tsnap.applySnap(t, vec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void resetSnapping(TransInfo *t)
|
|
|
|
{
|
|
|
|
t->tsnap.status = 0;
|
2009-03-29 19:52:53 +00:00
|
|
|
t->tsnap.align = 0;
|
2009-12-10 22:07:33 +00:00
|
|
|
t->tsnap.project = 0;
|
2009-11-26 19:47:55 +00:00
|
|
|
t->tsnap.mode = 0;
|
|
|
|
t->tsnap.modeSelect = 0;
|
2009-12-03 19:18:00 +00:00
|
|
|
t->tsnap.target = 0;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
t->tsnap.last = 0;
|
|
|
|
t->tsnap.applySnap = NULL;
|
|
|
|
|
|
|
|
t->tsnap.snapNormal[0] = 0;
|
|
|
|
t->tsnap.snapNormal[1] = 0;
|
|
|
|
t->tsnap.snapNormal[2] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int usingSnappingNormal(TransInfo *t)
|
|
|
|
{
|
2009-03-29 19:52:53 +00:00
|
|
|
return t->tsnap.align;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int validSnappingNormal(TransInfo *t)
|
|
|
|
{
|
2009-12-01 18:26:18 +00:00
|
|
|
if (validSnap(t))
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2009-11-10 20:43:45 +00:00
|
|
|
if (dot_v3v3(t->tsnap.snapNormal, t->tsnap.snapNormal) > 0)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void initSnappingMode(TransInfo *t)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2009-06-23 00:41:55 +00:00
|
|
|
ToolSettings *ts = t->settings;
|
2009-01-03 17:21:32 +00:00
|
|
|
Object *obedit = t->obedit;
|
2009-10-19 18:49:04 +00:00
|
|
|
Scene *scene = t->scene;
|
2009-12-03 19:18:00 +00:00
|
|
|
|
|
|
|
/* force project off when not supported */
|
|
|
|
if (ts->snap_mode != SCE_SNAP_MODE_FACE)
|
|
|
|
{
|
|
|
|
t->tsnap.project = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
t->tsnap.mode = ts->snap_mode;
|
|
|
|
|
|
|
|
if ((t->spacetype == SPACE_VIEW3D || t->spacetype == SPACE_IMAGE) && // Only 3D view or UV
|
|
|
|
(t->flag & T_CAMERA) == 0) { // Not with camera selected in camera view
|
|
|
|
setSnappingCallback(t);
|
|
|
|
|
|
|
|
/* Edit mode */
|
|
|
|
if (t->tsnap.applySnap != NULL && // A snapping function actually exist
|
2011-02-07 12:07:26 +00:00
|
|
|
(obedit != NULL && ELEM4(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE)) ) // Temporary limited to edit mode meshes, armature, curves
|
2009-12-03 19:18:00 +00:00
|
|
|
{
|
2011-06-21 15:28:13 +00:00
|
|
|
/* Exclude editmesh if using proportional edit */
|
|
|
|
if ((obedit->type == OB_MESH) && (t->flag & T_PROP_EDIT))
|
2009-12-03 19:18:00 +00:00
|
|
|
{
|
|
|
|
t->tsnap.modeSelect = SNAP_NOT_OBEDIT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-07-27 07:22:31 +00:00
|
|
|
t->tsnap.modeSelect = t->tsnap.snap_self ? SNAP_ALL : SNAP_NOT_OBEDIT;
|
2009-12-03 19:18:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Particles edit mode*/
|
|
|
|
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
|
|
|
|
(obedit == NULL && BASACT && BASACT->object && BASACT->object->mode & OB_MODE_PARTICLE_EDIT ))
|
|
|
|
{
|
|
|
|
t->tsnap.modeSelect = SNAP_ALL;
|
|
|
|
}
|
|
|
|
/* Object mode */
|
|
|
|
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
|
|
|
|
(obedit == NULL) ) // Object Mode
|
|
|
|
{
|
|
|
|
t->tsnap.modeSelect = SNAP_NOT_SELECTED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Grid if snap is not possible */
|
|
|
|
t->tsnap.mode = SCE_SNAP_MODE_INCREMENT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Always grid outside of 3D view */
|
|
|
|
t->tsnap.mode = SCE_SNAP_MODE_INCREMENT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void initSnapping(TransInfo *t, wmOperator *op)
|
|
|
|
{
|
|
|
|
ToolSettings *ts = t->settings;
|
2009-11-26 19:47:55 +00:00
|
|
|
short snap_target = t->settings->snap_target;
|
2009-03-29 19:52:53 +00:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
resetSnapping(t);
|
|
|
|
|
2009-11-27 16:15:34 +00:00
|
|
|
/* if snap property exists */
|
2009-03-29 19:52:53 +00:00
|
|
|
if (op && RNA_struct_find_property(op->ptr, "snap") && RNA_property_is_set(op->ptr, "snap"))
|
|
|
|
{
|
|
|
|
if (RNA_boolean_get(op->ptr, "snap"))
|
|
|
|
{
|
2009-11-27 16:15:34 +00:00
|
|
|
t->modifiers |= MOD_SNAP;
|
|
|
|
|
|
|
|
if (RNA_property_is_set(op->ptr, "snap_target"))
|
|
|
|
{
|
|
|
|
snap_target = RNA_enum_get(op->ptr, "snap_target");
|
|
|
|
}
|
2009-03-29 19:52:53 +00:00
|
|
|
|
2009-11-27 16:15:34 +00:00
|
|
|
if (RNA_property_is_set(op->ptr, "snap_point"))
|
|
|
|
{
|
|
|
|
RNA_float_get_array(op->ptr, "snap_point", t->tsnap.snapPoint);
|
|
|
|
t->tsnap.status |= SNAP_FORCED|POINT_INIT;
|
|
|
|
}
|
2009-03-29 19:52:53 +00:00
|
|
|
|
|
|
|
/* snap align only defined in specific cases */
|
|
|
|
if (RNA_struct_find_property(op->ptr, "snap_align"))
|
|
|
|
{
|
|
|
|
t->tsnap.align = RNA_boolean_get(op->ptr, "snap_align");
|
|
|
|
RNA_float_get_array(op->ptr, "snap_normal", t->tsnap.snapNormal);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(t->tsnap.snapNormal);
|
2009-03-29 19:52:53 +00:00
|
|
|
}
|
2009-10-12 22:33:32 +00:00
|
|
|
|
2010-08-18 03:24:52 +00:00
|
|
|
if (RNA_struct_find_property(op->ptr, "use_snap_project"))
|
2009-10-12 22:33:32 +00:00
|
|
|
{
|
2010-08-18 03:24:52 +00:00
|
|
|
t->tsnap.project = RNA_boolean_get(op->ptr, "use_snap_project");
|
2009-10-12 22:33:32 +00:00
|
|
|
}
|
2011-06-17 13:02:23 +00:00
|
|
|
|
2011-07-27 07:22:31 +00:00
|
|
|
if (RNA_struct_find_property(op->ptr, "use_snap_self"))
|
2011-06-17 13:02:23 +00:00
|
|
|
{
|
2011-07-27 07:22:31 +00:00
|
|
|
t->tsnap.snap_self = RNA_boolean_get(op->ptr, "use_snap_self");
|
2011-06-17 13:02:23 +00:00
|
|
|
}
|
2009-03-29 19:52:53 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-27 16:15:34 +00:00
|
|
|
/* use scene defaults only when transform is modal */
|
|
|
|
else if (t->flag & T_MODAL)
|
2009-03-29 19:52:53 +00:00
|
|
|
{
|
2011-07-28 02:15:58 +00:00
|
|
|
if(ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE))
|
|
|
|
{
|
|
|
|
if (ts->snap_flag & SCE_SNAP) {
|
|
|
|
t->modifiers |= MOD_SNAP;
|
|
|
|
}
|
2009-11-27 16:15:34 +00:00
|
|
|
|
2011-07-28 02:15:58 +00:00
|
|
|
t->tsnap.align = ((t->settings->snap_flag & SCE_SNAP_ROTATE) == SCE_SNAP_ROTATE);
|
|
|
|
t->tsnap.project = ((t->settings->snap_flag & SCE_SNAP_PROJECT) == SCE_SNAP_PROJECT);
|
|
|
|
t->tsnap.snap_self = !((t->settings->snap_flag & SCE_SNAP_NO_SELF) == SCE_SNAP_NO_SELF);
|
|
|
|
t->tsnap.peel = ((t->settings->snap_flag & SCE_SNAP_PROJECT) == SCE_SNAP_PROJECT);
|
|
|
|
}
|
2009-10-12 22:33:32 +00:00
|
|
|
}
|
|
|
|
|
2009-12-03 19:18:00 +00:00
|
|
|
t->tsnap.target = snap_target;
|
2009-11-26 19:47:55 +00:00
|
|
|
|
2009-12-03 19:18:00 +00:00
|
|
|
initSnappingMode(t);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
2009-12-03 19:18:00 +00:00
|
|
|
void setSnappingCallback(TransInfo *t)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
t->tsnap.calcSnap = CalcSnapGeometry;
|
|
|
|
|
2009-12-03 19:18:00 +00:00
|
|
|
switch(t->tsnap.target)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
case SCE_SNAP_TARGET_CLOSEST:
|
|
|
|
t->tsnap.targetSnap = TargetSnapClosest;
|
|
|
|
break;
|
|
|
|
case SCE_SNAP_TARGET_CENTER:
|
|
|
|
t->tsnap.targetSnap = TargetSnapCenter;
|
|
|
|
break;
|
|
|
|
case SCE_SNAP_TARGET_MEDIAN:
|
|
|
|
t->tsnap.targetSnap = TargetSnapMedian;
|
|
|
|
break;
|
|
|
|
case SCE_SNAP_TARGET_ACTIVE:
|
|
|
|
t->tsnap.targetSnap = TargetSnapActive;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (t->mode)
|
|
|
|
{
|
|
|
|
case TFM_TRANSLATION:
|
|
|
|
t->tsnap.applySnap = ApplySnapTranslation;
|
|
|
|
t->tsnap.distance = TranslationBetween;
|
|
|
|
break;
|
|
|
|
case TFM_ROTATION:
|
|
|
|
t->tsnap.applySnap = ApplySnapRotation;
|
|
|
|
t->tsnap.distance = RotationBetween;
|
|
|
|
|
|
|
|
// Can't do TARGET_CENTER with rotation, use TARGET_MEDIAN instead
|
2009-12-03 19:18:00 +00:00
|
|
|
if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
|
|
|
|
t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
t->tsnap.targetSnap = TargetSnapMedian;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TFM_RESIZE:
|
|
|
|
t->tsnap.applySnap = ApplySnapResize;
|
|
|
|
t->tsnap.distance = ResizeBetween;
|
|
|
|
|
|
|
|
// Can't do TARGET_CENTER with resize, use TARGET_MEDIAN instead
|
2009-12-03 19:18:00 +00:00
|
|
|
if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
|
|
|
|
t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
t->tsnap.targetSnap = TargetSnapMedian;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
t->tsnap.applySnap = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-01 18:26:18 +00:00
|
|
|
void addSnapPoint(TransInfo *t)
|
|
|
|
{
|
|
|
|
if (t->tsnap.status & POINT_INIT) {
|
|
|
|
TransSnapPoint *p = MEM_callocN(sizeof(TransSnapPoint), "SnapPoint");
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(p->co, t->tsnap.snapPoint);
|
2009-12-01 18:26:18 +00:00
|
|
|
|
|
|
|
BLI_addtail(&t->tsnap.points, p);
|
|
|
|
|
|
|
|
t->tsnap.status |= MULTI_POINTS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void removeSnapPoint(TransInfo *t)
|
|
|
|
{
|
|
|
|
if (t->tsnap.status & MULTI_POINTS) {
|
|
|
|
BLI_freelinkN(&t->tsnap.points, t->tsnap.points.last);
|
|
|
|
|
|
|
|
if (t->tsnap.points.first == NULL)
|
|
|
|
t->tsnap.status &= ~MULTI_POINTS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void getSnapPoint(TransInfo *t, float vec[3])
|
|
|
|
{
|
|
|
|
if (t->tsnap.points.first) {
|
|
|
|
TransSnapPoint *p;
|
|
|
|
int total = 0;
|
|
|
|
|
|
|
|
vec[0] = vec[1] = vec[2] = 0;
|
|
|
|
|
|
|
|
for (p = t->tsnap.points.first; p; p = p->next, total++) {
|
|
|
|
add_v3_v3(vec, p->co);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t->tsnap.status & POINT_INIT) {
|
|
|
|
add_v3_v3(vec, t->tsnap.snapPoint);
|
|
|
|
total++;
|
|
|
|
}
|
|
|
|
|
|
|
|
mul_v3_fl(vec, 1.0f / total);
|
|
|
|
} else {
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(vec, t->tsnap.snapPoint);
|
2009-12-01 18:26:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
/********************** APPLY **************************/
|
|
|
|
|
|
|
|
void ApplySnapTranslation(TransInfo *t, float vec[3])
|
|
|
|
{
|
2009-12-01 18:26:18 +00:00
|
|
|
float point[3];
|
|
|
|
getSnapPoint(t, point);
|
|
|
|
sub_v3_v3v3(vec, point, t->tsnap.snapTarget);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ApplySnapRotation(TransInfo *t, float *vec)
|
|
|
|
{
|
2009-12-03 19:18:00 +00:00
|
|
|
if (t->tsnap.target == SCE_SNAP_TARGET_CLOSEST) {
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
*vec = t->tsnap.dist;
|
|
|
|
}
|
|
|
|
else {
|
2009-12-01 18:26:18 +00:00
|
|
|
float point[3];
|
|
|
|
getSnapPoint(t, point);
|
|
|
|
*vec = RotationBetween(t, t->tsnap.snapTarget, point);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ApplySnapResize(TransInfo *t, float vec[3])
|
|
|
|
{
|
2009-12-03 19:18:00 +00:00
|
|
|
if (t->tsnap.target == SCE_SNAP_TARGET_CLOSEST) {
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
vec[0] = vec[1] = vec[2] = t->tsnap.dist;
|
|
|
|
}
|
|
|
|
else {
|
2009-12-01 18:26:18 +00:00
|
|
|
float point[3];
|
|
|
|
getSnapPoint(t, point);
|
|
|
|
vec[0] = vec[1] = vec[2] = ResizeBetween(t, t->tsnap.snapTarget, point);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************** DISTANCE **************************/
|
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
float TranslationBetween(TransInfo *UNUSED(t), float p1[3], float p2[3])
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2009-11-10 20:43:45 +00:00
|
|
|
return len_v3v3(p1, p2);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float RotationBetween(TransInfo *t, float p1[3], float p2[3])
|
|
|
|
{
|
|
|
|
float angle, start[3], end[3], center[3];
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(center, t->center);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
if(t->flag & (T_EDIT|T_POSE)) {
|
2008-12-31 22:43:29 +00:00
|
|
|
Object *ob= t->obedit?t->obedit:t->poseobj;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, center);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(start, p1, center);
|
|
|
|
sub_v3_v3v3(end, p2, center);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
// Angle around a constraint axis (error prone, will need debug)
|
|
|
|
if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) {
|
|
|
|
float axis[3], tmp[3];
|
|
|
|
|
|
|
|
t->con.applyRot(t, NULL, axis, NULL);
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
project_v3_v3v3(tmp, end, axis);
|
|
|
|
sub_v3_v3v3(end, end, tmp);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
project_v3_v3v3(tmp, start, axis);
|
|
|
|
sub_v3_v3v3(start, start, tmp);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(end);
|
|
|
|
normalize_v3(start);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
cross_v3_v3v3(tmp, start, end);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2011-03-28 17:06:15 +00:00
|
|
|
if (dot_v3v3(tmp, axis) < 0.0f)
|
2009-11-10 20:43:45 +00:00
|
|
|
angle = -acos(dot_v3v3(start, end));
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
angle = acos(dot_v3v3(start, end));
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
float mtx[3][3];
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(mtx, t->viewmat);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(mtx, end);
|
|
|
|
mul_m3_v3(mtx, start);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
angle = atan2(start[1],start[0]) - atan2(end[1],end[0]);
|
|
|
|
}
|
|
|
|
|
2011-03-28 17:06:15 +00:00
|
|
|
if (angle > (float)M_PI) {
|
|
|
|
angle = angle - 2 * (float)M_PI;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2011-03-28 17:06:15 +00:00
|
|
|
else if (angle < -((float)M_PI)) {
|
|
|
|
angle = 2.0f * (float)M_PI + angle;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return angle;
|
|
|
|
}
|
|
|
|
|
|
|
|
float ResizeBetween(TransInfo *t, float p1[3], float p2[3])
|
|
|
|
{
|
|
|
|
float d1[3], d2[3], center[3];
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(center, t->center);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
if(t->flag & (T_EDIT|T_POSE)) {
|
2008-12-31 22:43:29 +00:00
|
|
|
Object *ob= t->obedit?t->obedit:t->poseobj;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, center);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(d1, p1, center);
|
|
|
|
sub_v3_v3v3(d2, p2, center);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) {
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(t->con.pmtx, d1);
|
|
|
|
mul_m3_v3(t->con.pmtx, d2);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
return len_v3(d2) / len_v3(d1);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************** CALC **************************/
|
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
void CalcSnapGrid(TransInfo *t, float *UNUSED(vec))
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
snapGridAction(t, t->tsnap.snapPoint, BIG_GEARS);
|
|
|
|
}
|
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2009-02-24 00:45:40 +00:00
|
|
|
if (t->spacetype == SPACE_VIEW3D)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2009-02-24 00:45:40 +00:00
|
|
|
float loc[3];
|
|
|
|
float no[3];
|
2009-10-12 22:33:32 +00:00
|
|
|
float mval[2];
|
2009-02-24 00:45:40 +00:00
|
|
|
int found = 0;
|
2009-02-25 20:07:45 +00:00
|
|
|
int dist = SNAP_MIN_DISTANCE; // Use a user defined value here
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-10-12 22:33:32 +00:00
|
|
|
mval[0] = t->mval[0];
|
|
|
|
mval[1] = t->mval[1];
|
|
|
|
|
2009-11-26 19:47:55 +00:00
|
|
|
if (t->tsnap.mode == SCE_SNAP_MODE_VOLUME)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2009-02-24 00:45:40 +00:00
|
|
|
ListBase depth_peels;
|
|
|
|
DepthPeel *p1, *p2;
|
|
|
|
float *last_p = NULL;
|
2010-12-03 12:30:59 +00:00
|
|
|
float max_dist = FLT_MAX;
|
2009-10-21 17:56:26 +00:00
|
|
|
float p[3] = {0.0f, 0.0f, 0.0f};
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
depth_peels.first = depth_peels.last = NULL;
|
|
|
|
|
2009-10-12 22:33:32 +00:00
|
|
|
peelObjectsTransForm(t, &depth_peels, mval);
|
2008-01-13 22:20:18 +00:00
|
|
|
|
2009-03-17 21:26:09 +00:00
|
|
|
// if (LAST_SNAP_POINT_VALID)
|
2009-02-24 00:45:40 +00:00
|
|
|
// {
|
2009-03-17 21:26:09 +00:00
|
|
|
// last_p = LAST_SNAP_POINT;
|
2009-02-24 00:45:40 +00:00
|
|
|
// }
|
2009-03-17 21:26:09 +00:00
|
|
|
// else
|
2009-02-24 00:45:40 +00:00
|
|
|
// {
|
2009-03-17 21:26:09 +00:00
|
|
|
last_p = t->tsnap.snapPoint;
|
2009-02-24 00:45:40 +00:00
|
|
|
// }
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2008-01-13 22:20:18 +00:00
|
|
|
|
2009-02-24 00:45:40 +00:00
|
|
|
for (p1 = depth_peels.first; p1; p1 = p1->next)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2009-02-24 00:45:40 +00:00
|
|
|
if (p1->flag == 0)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2009-02-24 00:45:40 +00:00
|
|
|
float vec[3];
|
|
|
|
float new_dist;
|
|
|
|
|
|
|
|
p2 = NULL;
|
|
|
|
p1->flag = 1;
|
|
|
|
|
|
|
|
/* if peeling objects, take the first and last from each object */
|
2009-06-23 00:41:55 +00:00
|
|
|
if (t->settings->snap_flag & SCE_SNAP_PEEL_OBJECT)
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
|
|
|
DepthPeel *peel;
|
|
|
|
for (peel = p1->next; peel; peel = peel->next)
|
|
|
|
{
|
|
|
|
if (peel->ob == p1->ob)
|
|
|
|
{
|
|
|
|
peel->flag = 1;
|
|
|
|
p2 = peel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* otherwise, pair first with second and so on */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (p2 = p1->next; p2 && p2->ob != p1->ob; p2 = p2->next)
|
|
|
|
{
|
|
|
|
/* nothing to do here */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p2)
|
|
|
|
{
|
|
|
|
p2->flag = 1;
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
add_v3_v3v3(vec, p1->p, p2->p);
|
|
|
|
mul_v3_fl(vec, 0.5f);
|
2009-02-24 00:45:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(vec, p1->p);
|
2009-02-24 00:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (last_p == NULL)
|
|
|
|
{
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(p, vec);
|
2010-12-03 12:30:59 +00:00
|
|
|
max_dist = 0;
|
2009-02-24 00:45:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
new_dist = len_v3v3(last_p, vec);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
if (new_dist < max_dist)
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(p, vec);
|
2010-12-03 12:30:59 +00:00
|
|
|
max_dist = new_dist;
|
2009-02-24 00:45:40 +00:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
if (max_dist != FLT_MAX)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(loc, p);
|
2010-10-07 10:04:07 +00:00
|
|
|
/* XXX, is there a correct normal in this case ???, for now just z up */
|
|
|
|
no[0]= 0.0;
|
|
|
|
no[1]= 0.0;
|
|
|
|
no[2]= 1.0;
|
2009-02-24 00:45:40 +00:00
|
|
|
found = 1;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
BLI_freelistN(&depth_peels);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2009-02-24 00:45:40 +00:00
|
|
|
else
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2009-11-26 19:47:55 +00:00
|
|
|
found = snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
if (found == 1)
|
2009-01-28 21:43:43 +00:00
|
|
|
{
|
2009-02-24 00:45:40 +00:00
|
|
|
float tangent[3];
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(tangent, loc, t->tsnap.snapPoint);
|
2009-02-24 00:45:40 +00:00
|
|
|
tangent[2] = 0;
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
if (dot_v3v3(tangent, tangent) > 0)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(t->tsnap.snapTangent, tangent);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(t->tsnap.snapPoint, loc);
|
|
|
|
copy_v3_v3(t->tsnap.snapNormal, no);
|
2008-02-27 19:35:27 +00:00
|
|
|
|
2009-02-24 00:45:40 +00:00
|
|
|
t->tsnap.status |= POINT_INIT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t->tsnap.status &= ~POINT_INIT;
|
|
|
|
}
|
|
|
|
}
|
2009-03-17 21:44:58 +00:00
|
|
|
else if (t->spacetype == SPACE_IMAGE && t->obedit != NULL && t->obedit->type==OB_MESH)
|
2009-02-24 00:45:40 +00:00
|
|
|
{ /* same as above but for UV's */
|
2009-03-17 21:44:58 +00:00
|
|
|
/* same as above but for UV's */
|
|
|
|
Image *ima= ED_space_image(t->sa->spacedata.first);
|
|
|
|
float aspx, aspy, co[2];
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-03-17 21:44:58 +00:00
|
|
|
UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co+1);
|
2008-02-27 19:35:27 +00:00
|
|
|
|
2009-03-17 21:44:58 +00:00
|
|
|
if(ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint))
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
2009-03-17 21:44:58 +00:00
|
|
|
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
|
2009-02-24 00:45:40 +00:00
|
|
|
t->tsnap.snapPoint[0] *= aspx;
|
|
|
|
t->tsnap.snapPoint[1] *= aspy;
|
|
|
|
|
|
|
|
t->tsnap.status |= POINT_INIT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t->tsnap.status &= ~POINT_INIT;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************** TARGET **************************/
|
|
|
|
|
|
|
|
void TargetSnapCenter(TransInfo *t)
|
|
|
|
{
|
|
|
|
// Only need to calculate once
|
|
|
|
if ((t->tsnap.status & TARGET_INIT) == 0)
|
|
|
|
{
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(t->tsnap.snapTarget, t->center);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
if(t->flag & (T_EDIT|T_POSE)) {
|
2008-12-31 22:43:29 +00:00
|
|
|
Object *ob= t->obedit?t->obedit:t->poseobj;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
t->tsnap.status |= TARGET_INIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TargetSnapActive(TransInfo *t)
|
|
|
|
{
|
|
|
|
// Only need to calculate once
|
|
|
|
if ((t->tsnap.status & TARGET_INIT) == 0)
|
|
|
|
{
|
|
|
|
TransData *td = NULL;
|
|
|
|
TransData *active_td = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++)
|
|
|
|
{
|
|
|
|
if (td->flag & TD_ACTIVE)
|
|
|
|
{
|
|
|
|
active_td = td;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (active_td)
|
|
|
|
{
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(t->tsnap.snapTarget, active_td->center);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
if(t->flag & (T_EDIT|T_POSE)) {
|
2008-12-31 22:43:29 +00:00
|
|
|
Object *ob= t->obedit?t->obedit:t->poseobj;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
t->tsnap.status |= TARGET_INIT;
|
|
|
|
}
|
|
|
|
/* No active, default to median */
|
|
|
|
else
|
|
|
|
{
|
2009-12-03 19:18:00 +00:00
|
|
|
t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
t->tsnap.targetSnap = TargetSnapMedian;
|
|
|
|
TargetSnapMedian(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TargetSnapMedian(TransInfo *t)
|
|
|
|
{
|
|
|
|
// Only need to calculate once
|
|
|
|
if ((t->tsnap.status & TARGET_INIT) == 0)
|
|
|
|
{
|
|
|
|
TransData *td = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
t->tsnap.snapTarget[0] = 0;
|
|
|
|
t->tsnap.snapTarget[1] = 0;
|
|
|
|
t->tsnap.snapTarget[2] = 0;
|
|
|
|
|
|
|
|
for(td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++)
|
|
|
|
{
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(t->tsnap.snapTarget, td->center);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(t->tsnap.snapTarget, 1.0 / i);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
if(t->flag & (T_EDIT|T_POSE)) {
|
2008-12-31 22:43:29 +00:00
|
|
|
Object *ob= t->obedit?t->obedit:t->poseobj;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
t->tsnap.status |= TARGET_INIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TargetSnapClosest(TransInfo *t)
|
|
|
|
{
|
|
|
|
// Only valid if a snap point has been selected
|
|
|
|
if (t->tsnap.status & POINT_INIT)
|
|
|
|
{
|
|
|
|
TransData *closest = NULL, *td = NULL;
|
|
|
|
|
|
|
|
/* Object mode */
|
|
|
|
if (t->flag & T_OBJECT)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++)
|
|
|
|
{
|
|
|
|
struct BoundBox *bb = object_get_boundbox(td->ob);
|
|
|
|
|
|
|
|
/* use boundbox if possible */
|
|
|
|
if (bb)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < 8; j++) {
|
|
|
|
float loc[3];
|
|
|
|
float dist;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(loc, bb->vec[j]);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(td->ext->obmat, loc);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint);
|
|
|
|
|
|
|
|
if (closest == NULL || fabs(dist) < fabs(t->tsnap.dist))
|
|
|
|
{
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(t->tsnap.snapTarget, loc);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
closest = td;
|
|
|
|
t->tsnap.dist = dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* use element center otherwise */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float loc[3];
|
|
|
|
float dist;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(loc, td->center);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint);
|
|
|
|
|
|
|
|
if (closest == NULL || fabs(dist) < fabs(t->tsnap.dist))
|
|
|
|
{
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(t->tsnap.snapTarget, loc);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
closest = td;
|
|
|
|
t->tsnap.dist = dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++)
|
|
|
|
{
|
|
|
|
float loc[3];
|
|
|
|
float dist;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(loc, td->center);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
if(t->flag & (T_EDIT|T_POSE)) {
|
2008-12-31 22:43:29 +00:00
|
|
|
Object *ob= t->obedit?t->obedit:t->poseobj;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, loc);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint);
|
|
|
|
|
|
|
|
if (closest == NULL || fabs(dist) < fabs(t->tsnap.dist))
|
|
|
|
{
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(t->tsnap.snapTarget, loc);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
closest = td;
|
|
|
|
t->tsnap.dist = dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t->tsnap.status |= TARGET_INIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*================================================================*/
|
2011-02-17 12:05:09 +00:00
|
|
|
#ifndef USE_BVH_FACE_SNAP
|
2011-02-14 17:55:27 +00:00
|
|
|
static int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], float *v4co, float mval[2], float ray_start[3], float ray_start_local[3], float ray_normal_local[3], float obmat[][4], float timat[][3], float *loc, float *no, int *dist, float *depth)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
|
|
|
float lambda;
|
|
|
|
int result;
|
|
|
|
int retval = 0;
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
result = isect_ray_tri_threshold_v3(ray_start_local, ray_normal_local, v1co, v2co, v3co, &lambda, NULL, 0.001);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
|
|
|
if (result) {
|
|
|
|
float location[3], normal[3];
|
|
|
|
float intersect[3];
|
|
|
|
float new_depth;
|
|
|
|
int screen_loc[2];
|
|
|
|
int new_dist;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(intersect, ray_normal_local);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(intersect, lambda);
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(intersect, ray_start_local);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(location, intersect);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
|
|
|
if (v4co)
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_quad_v3( normal,v1co, v2co, v3co, v4co);
|
2009-02-24 21:25:36 +00:00
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_tri_v3( normal,v1co, v2co, v3co);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(obmat, location);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
new_depth = len_v3v3(location, ray_start);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
project_int(ar, location, screen_loc);
|
2009-10-12 22:33:32 +00:00
|
|
|
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
|
|
|
if (new_dist <= *dist && new_depth < *depth)
|
|
|
|
{
|
|
|
|
*depth = new_depth;
|
|
|
|
retval = 1;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(loc, location);
|
|
|
|
copy_v3_v3(no, normal);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(timat, no);
|
|
|
|
normalize_v3(no);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
|
|
|
*dist = new_dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2011-02-17 12:05:09 +00:00
|
|
|
#endif
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2no[3], float mval[2], float ray_start[3], float ray_start_local[3], float ray_normal_local[3], float obmat[][4], float timat[][3], float *loc, float *no, int *dist, float *depth)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
|
|
|
float intersect[3] = {0, 0, 0}, ray_end[3], dvec[3];
|
|
|
|
int result;
|
|
|
|
int retval = 0;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(ray_end, ray_normal_local);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(ray_end, 2000);
|
|
|
|
add_v3_v3v3(ray_end, ray_start_local, ray_end);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
result = isect_line_line_v3(v1co, v2co, ray_start_local, ray_end, intersect, dvec); /* dvec used but we don't care about result */
|
2009-02-24 21:25:36 +00:00
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
float edge_loc[3], vec[3];
|
|
|
|
float mul;
|
|
|
|
|
|
|
|
/* check for behind ray_start */
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(dvec, intersect, ray_start_local);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(edge_loc, v1co, v2co);
|
|
|
|
sub_v3_v3v3(vec, intersect, v2co);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul = dot_v3v3(vec, edge_loc) / dot_v3v3(edge_loc, edge_loc);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
|
|
|
if (mul > 1) {
|
|
|
|
mul = 1;
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(intersect, v1co);
|
2009-02-24 21:25:36 +00:00
|
|
|
}
|
|
|
|
else if (mul < 0) {
|
|
|
|
mul = 0;
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(intersect, v2co);
|
2009-02-24 21:25:36 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
if (dot_v3v3(ray_normal_local, dvec) > 0)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
|
|
|
float location[3];
|
|
|
|
float new_depth;
|
|
|
|
int screen_loc[2];
|
|
|
|
int new_dist;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(location, intersect);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(obmat, location);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
new_depth = len_v3v3(location, ray_start);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
project_int(ar, location, screen_loc);
|
2009-10-12 22:33:32 +00:00
|
|
|
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
|
|
|
/* 10% threshold if edge is closer but a bit further
|
|
|
|
* this takes care of series of connected edges a bit slanted w.r.t the viewport
|
|
|
|
* otherwise, it would stick to the verts of the closest edge and not slide along merrily
|
|
|
|
* */
|
2011-03-28 17:06:15 +00:00
|
|
|
if (new_dist <= *dist && new_depth < *depth * 1.001f)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
|
|
|
float n1[3], n2[3];
|
|
|
|
|
|
|
|
*depth = new_depth;
|
|
|
|
retval = 1;
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(edge_loc, v1co, v2co);
|
|
|
|
sub_v3_v3v3(vec, intersect, v2co);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul = dot_v3v3(vec, edge_loc) / dot_v3v3(edge_loc, edge_loc);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
|
|
|
if (no)
|
|
|
|
{
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_short_to_float_v3(n1, v1no);
|
|
|
|
normal_short_to_float_v3(n2, v2no);
|
|
|
|
interp_v3_v3v3(no, n2, n1, mul);
|
|
|
|
mul_m3_v3(timat, no);
|
|
|
|
normalize_v3(no);
|
2009-02-24 21:25:36 +00:00
|
|
|
}
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(loc, location);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
|
|
|
*dist = new_dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static int snapVertex(ARegion *ar, float vco[3], short vno[3], float mval[2], float ray_start[3], float ray_start_local[3], float ray_normal_local[3], float obmat[][4], float timat[][3], float *loc, float *no, int *dist, float *depth)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
|
|
|
int retval = 0;
|
|
|
|
float dvec[3];
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(dvec, vco, ray_start_local);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
if (dot_v3v3(ray_normal_local, dvec) > 0)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
|
|
|
float location[3];
|
|
|
|
float new_depth;
|
|
|
|
int screen_loc[2];
|
|
|
|
int new_dist;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(location, vco);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(obmat, location);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
new_depth = len_v3v3(location, ray_start);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
project_int(ar, location, screen_loc);
|
2009-10-12 22:33:32 +00:00
|
|
|
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
|
|
|
if (new_dist <= *dist && new_depth < *depth)
|
|
|
|
{
|
|
|
|
*depth = new_depth;
|
|
|
|
retval = 1;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(loc, location);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
|
|
|
if (no)
|
|
|
|
{
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_short_to_float_v3(no, vno);
|
|
|
|
mul_m3_v3(timat, no);
|
|
|
|
normalize_v3(no);
|
2009-02-24 21:25:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*dist = new_dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm, float obmat[][4], float ray_start[3], float ray_normal[3], float mval[2], float *loc, float *UNUSED(no), int *dist, float *depth)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
|
|
|
float imat[4][4];
|
|
|
|
float ray_start_local[3], ray_normal_local[3];
|
|
|
|
int retval = 0;
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, obmat);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(ray_start_local, ray_start);
|
|
|
|
copy_v3_v3(ray_normal_local, ray_normal);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(imat, ray_start_local);
|
|
|
|
mul_mat3_m4_v3(imat, ray_normal_local);
|
2009-02-25 20:07:45 +00:00
|
|
|
|
2009-03-17 21:44:58 +00:00
|
|
|
if(arm->edbo)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
2009-02-25 20:07:45 +00:00
|
|
|
EditBone *eBone;
|
|
|
|
|
2009-03-17 21:44:58 +00:00
|
|
|
for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
|
2009-02-25 20:07:45 +00:00
|
|
|
if (eBone->layer & arm->layer) {
|
|
|
|
/* skip hidden or moving (selected) bones */
|
|
|
|
if ((eBone->flag & (BONE_HIDDEN_A|BONE_ROOTSEL|BONE_TIPSEL))==0) {
|
2009-03-20 18:00:51 +00:00
|
|
|
switch (snap_mode)
|
2009-02-25 20:07:45 +00:00
|
|
|
{
|
|
|
|
case SCE_SNAP_MODE_VERTEX:
|
2009-03-20 18:00:51 +00:00
|
|
|
retval |= snapVertex(ar, eBone->head, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
|
|
|
retval |= snapVertex(ar, eBone->tail, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
2009-02-25 20:07:45 +00:00
|
|
|
break;
|
|
|
|
case SCE_SNAP_MODE_EDGE:
|
2009-03-20 18:00:51 +00:00
|
|
|
retval |= snapEdge(ar, eBone->head, NULL, eBone->tail, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
2009-02-25 20:07:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-24 21:25:36 +00:00
|
|
|
}
|
2009-02-25 20:07:45 +00:00
|
|
|
}
|
|
|
|
else if (ob->pose && ob->pose->chanbase.first)
|
|
|
|
{
|
|
|
|
bPoseChannel *pchan;
|
|
|
|
Bone *bone;
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-02-25 20:07:45 +00:00
|
|
|
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
|
|
|
bone= pchan->bone;
|
|
|
|
/* skip hidden bones */
|
|
|
|
if (bone && !(bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))) {
|
|
|
|
float *head_vec = pchan->pose_head;
|
|
|
|
float *tail_vec = pchan->pose_tail;
|
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
switch (snap_mode)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
2009-02-25 20:07:45 +00:00
|
|
|
case SCE_SNAP_MODE_VERTEX:
|
2009-03-20 18:00:51 +00:00
|
|
|
retval |= snapVertex(ar, head_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
|
|
|
retval |= snapVertex(ar, tail_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
2009-02-25 20:07:45 +00:00
|
|
|
break;
|
|
|
|
case SCE_SNAP_MODE_EDGE:
|
2009-03-20 18:00:51 +00:00
|
|
|
retval |= snapEdge(ar, head_vec, NULL, tail_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
2009-02-25 20:07:45 +00:00
|
|
|
break;
|
2009-02-24 21:25:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, EditMesh *em, float obmat[][4], float ray_start[3], float ray_normal[3], float mval[2], float *loc, float *no, int *dist, float *depth)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
int retval = 0;
|
|
|
|
int totvert = dm->getNumVerts(dm);
|
|
|
|
int totface = dm->getNumFaces(dm);
|
2010-11-22 14:16:11 +00:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
if (totvert > 0) {
|
|
|
|
float imat[4][4];
|
|
|
|
float timat[3][3]; /* transpose inverse matrix for normals */
|
|
|
|
float ray_start_local[3], ray_normal_local[3];
|
|
|
|
int test = 1;
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, obmat);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(timat, imat);
|
|
|
|
transpose_m3(timat);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(ray_start_local, ray_start);
|
|
|
|
copy_v3_v3(ray_normal_local, ray_normal);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(imat, ray_start_local);
|
|
|
|
mul_mat3_m4_v3(imat, ray_normal_local);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* If number of vert is more than an arbitrary limit,
|
|
|
|
* test against boundbox first
|
|
|
|
* */
|
|
|
|
if (totface > 16) {
|
|
|
|
struct BoundBox *bb = object_get_boundbox(ob);
|
|
|
|
test = ray_hit_boundbox(bb, ray_start_local, ray_normal_local);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test == 1) {
|
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
switch (snap_mode)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
case SCE_SNAP_MODE_FACE:
|
|
|
|
{
|
2011-02-17 12:05:09 +00:00
|
|
|
#ifdef USE_BVH_FACE_SNAP // Added for durian
|
2009-11-12 11:45:29 +00:00
|
|
|
BVHTreeRayHit hit;
|
|
|
|
BVHTreeFromMesh treeData;
|
|
|
|
|
2010-10-07 10:57:21 +00:00
|
|
|
/* local scale in normal direction */
|
|
|
|
float local_scale = len_v3(ray_normal_local);
|
|
|
|
|
2010-11-22 14:16:11 +00:00
|
|
|
treeData.em_evil= em;
|
2009-11-12 11:45:29 +00:00
|
|
|
bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6);
|
|
|
|
|
|
|
|
hit.index = -1;
|
2010-10-07 10:57:21 +00:00
|
|
|
hit.dist = *depth * (*depth == FLT_MAX ? 1.0f : local_scale);
|
2009-11-12 11:45:29 +00:00
|
|
|
|
|
|
|
if(treeData.tree && BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1)
|
|
|
|
{
|
2010-10-07 10:57:21 +00:00
|
|
|
if(hit.dist/local_scale <= *depth) {
|
|
|
|
*depth= hit.dist/local_scale;
|
2009-11-12 11:45:29 +00:00
|
|
|
copy_v3_v3(loc, hit.co);
|
|
|
|
copy_v3_v3(no, hit.no);
|
|
|
|
|
|
|
|
/* back to worldspace */
|
|
|
|
mul_m4_v3(obmat, loc);
|
|
|
|
copy_v3_v3(no, hit.no);
|
|
|
|
|
|
|
|
mul_m3_v3(timat, no);
|
|
|
|
normalize_v3(no);
|
|
|
|
|
|
|
|
retval |= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
#else
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
MVert *verts = dm->getVertArray(dm);
|
|
|
|
MFace *faces = dm->getFaceArray(dm);
|
|
|
|
int *index_array = NULL;
|
|
|
|
int index = 0;
|
|
|
|
int i;
|
|
|
|
|
2009-01-20 19:58:05 +00:00
|
|
|
if (em != NULL)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
index_array = dm->getFaceDataArray(dm, CD_ORIGINDEX);
|
2009-01-20 19:58:05 +00:00
|
|
|
EM_init_index_arrays(em, 0, 0, 1);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( i = 0; i < totface; i++) {
|
|
|
|
EditFace *efa = NULL;
|
|
|
|
MFace *f = faces + i;
|
|
|
|
|
|
|
|
test = 1; /* reset for every face */
|
|
|
|
|
2009-01-20 19:58:05 +00:00
|
|
|
if (em != NULL)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
if (index_array)
|
|
|
|
{
|
|
|
|
index = index_array[i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
index = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index == ORIGINDEX_NONE)
|
|
|
|
{
|
|
|
|
test = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
efa = EM_get_face_for_index(index);
|
|
|
|
|
|
|
|
if (efa && (efa->h || (efa->v1->f & SELECT) || (efa->v2->f & SELECT) || (efa->v3->f & SELECT) || (efa->v4 && efa->v4->f & SELECT)))
|
|
|
|
{
|
|
|
|
test = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (test)
|
|
|
|
{
|
2009-02-24 21:25:36 +00:00
|
|
|
int result;
|
|
|
|
float *v4co = NULL;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-02-24 21:25:36 +00:00
|
|
|
if (f->v4)
|
|
|
|
{
|
|
|
|
v4co = verts[f->v4].co;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
result = snapFace(ar, verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, v4co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
2009-02-24 21:25:36 +00:00
|
|
|
retval |= result;
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
if (f->v4 && result == 0)
|
|
|
|
{
|
2009-03-20 18:00:51 +00:00
|
|
|
retval |= snapFace(ar, verts[f->v3].co, verts[f->v4].co, verts[f->v1].co, verts[f->v2].co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-20 19:58:05 +00:00
|
|
|
if (em != NULL)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
EM_free_index_arrays();
|
|
|
|
}
|
2009-11-12 11:45:29 +00:00
|
|
|
#endif
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SCE_SNAP_MODE_VERTEX:
|
|
|
|
{
|
|
|
|
MVert *verts = dm->getVertArray(dm);
|
|
|
|
int *index_array = NULL;
|
|
|
|
int index = 0;
|
|
|
|
int i;
|
|
|
|
|
2009-01-20 19:58:05 +00:00
|
|
|
if (em != NULL)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
index_array = dm->getVertDataArray(dm, CD_ORIGINDEX);
|
2009-01-20 19:58:05 +00:00
|
|
|
EM_init_index_arrays(em, 1, 0, 0);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( i = 0; i < totvert; i++) {
|
|
|
|
EditVert *eve = NULL;
|
|
|
|
MVert *v = verts + i;
|
|
|
|
|
|
|
|
test = 1; /* reset for every vert */
|
|
|
|
|
2009-01-20 19:58:05 +00:00
|
|
|
if (em != NULL)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
if (index_array)
|
|
|
|
{
|
|
|
|
index = index_array[i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
index = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index == ORIGINDEX_NONE)
|
|
|
|
{
|
|
|
|
test = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eve = EM_get_vert_for_index(index);
|
|
|
|
|
|
|
|
if (eve && (eve->h || (eve->f & SELECT)))
|
|
|
|
{
|
|
|
|
test = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (test)
|
|
|
|
{
|
2009-03-20 18:00:51 +00:00
|
|
|
retval |= snapVertex(ar, v->co, v->no, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-20 19:58:05 +00:00
|
|
|
if (em != NULL)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
EM_free_index_arrays();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SCE_SNAP_MODE_EDGE:
|
|
|
|
{
|
|
|
|
MVert *verts = dm->getVertArray(dm);
|
|
|
|
MEdge *edges = dm->getEdgeArray(dm);
|
|
|
|
int totedge = dm->getNumEdges(dm);
|
|
|
|
int *index_array = NULL;
|
|
|
|
int index = 0;
|
|
|
|
int i;
|
|
|
|
|
2009-01-20 19:58:05 +00:00
|
|
|
if (em != NULL)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
index_array = dm->getEdgeDataArray(dm, CD_ORIGINDEX);
|
2009-01-20 19:58:05 +00:00
|
|
|
EM_init_index_arrays(em, 0, 1, 0);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( i = 0; i < totedge; i++) {
|
|
|
|
EditEdge *eed = NULL;
|
|
|
|
MEdge *e = edges + i;
|
|
|
|
|
|
|
|
test = 1; /* reset for every vert */
|
|
|
|
|
2009-01-20 19:58:05 +00:00
|
|
|
if (em != NULL)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
if (index_array)
|
|
|
|
{
|
|
|
|
index = index_array[i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
index = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index == ORIGINDEX_NONE)
|
|
|
|
{
|
|
|
|
test = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eed = EM_get_edge_for_index(index);
|
|
|
|
|
|
|
|
if (eed && (eed->h || (eed->v1->f & SELECT) || (eed->v2->f & SELECT)))
|
|
|
|
{
|
|
|
|
test = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (test)
|
|
|
|
{
|
2009-03-20 18:00:51 +00:00
|
|
|
retval |= snapEdge(ar, verts[e->v1].co, verts[e->v1].no, verts[e->v2].co, verts[e->v2].no, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-20 19:58:05 +00:00
|
|
|
if (em != NULL)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
EM_free_index_arrays();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, float obmat[][4], float ray_start[3], float ray_normal[3], float mval[2], float *loc, float *no, int *dist, float *depth)
|
2009-02-25 20:07:45 +00:00
|
|
|
{
|
2009-06-23 00:41:55 +00:00
|
|
|
ToolSettings *ts= scene->toolsettings;
|
2009-02-25 20:07:45 +00:00
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
if (ob->type == OB_MESH) {
|
2009-03-17 21:44:58 +00:00
|
|
|
EditMesh *em;
|
2009-02-25 20:07:45 +00:00
|
|
|
DerivedMesh *dm;
|
|
|
|
|
|
|
|
if (editobject)
|
|
|
|
{
|
2009-03-17 21:44:58 +00:00
|
|
|
em = ((Mesh *)ob->data)->edit_mesh;
|
2010-11-24 18:02:35 +00:00
|
|
|
/* dm = editmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH); */
|
|
|
|
dm = editmesh_get_derived_base(ob, em); /* limitation, em & dm MUST have the same number of faces */
|
2009-02-25 20:07:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-17 21:44:58 +00:00
|
|
|
em = NULL;
|
2009-03-20 18:00:51 +00:00
|
|
|
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
|
2009-02-25 20:07:45 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 00:41:55 +00:00
|
|
|
retval = snapDerivedMesh(ts->snap_mode, ar, ob, dm, em, obmat, ray_start, ray_normal, mval, loc, no, dist, depth);
|
2009-02-25 20:07:45 +00:00
|
|
|
|
|
|
|
dm->release(dm);
|
|
|
|
}
|
|
|
|
else if (ob->type == OB_ARMATURE)
|
|
|
|
{
|
2009-06-23 00:41:55 +00:00
|
|
|
retval = snapArmature(ts->snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, loc, no, dist, depth);
|
2009-02-25 20:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, float mval[2], int *dist, float *loc, float *no, SnapMode mode) {
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
Base *base;
|
|
|
|
float depth = FLT_MAX;
|
|
|
|
int retval = 0;
|
|
|
|
float ray_start[3], ray_normal[3];
|
|
|
|
|
2011-05-20 13:09:34 +00:00
|
|
|
ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
if (mode == SNAP_ALL && obedit)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2009-03-20 18:00:51 +00:00
|
|
|
Object *ob = obedit;
|
2009-10-19 17:20:09 +00:00
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
retval |= snapObject(scene, ar, ob, 1, ob->obmat, ray_start, ray_normal, mval, loc, no, dist, &depth);
|
Merge from Apricot Revisions 14897, 14913, 14914, 14915, 14929, 15009, 15046
---------------------------------------------------
Snappy stuff
* Align rotation with snapping target: rotate the object, aligning it with the target (object mode only - temporarily) (New icon in the header when snap is turned on)
* Snap to different mesh elements (face, edge, vertice): snapping target slide on faces and edge or use exact position of vertice. When using Align rotation with edge snapping, the normal is interpolated as you slide along.
Snaps correctly to derived mesh (sculpt, modifiers, ...) and duplis. In object and edit mode.
NOTE: The snapping code is now based on faces, so even if you're snapping to vertices or edges, it will not work on meshes without faces. This might change if needed.
2008-06-09 18:41:16 +00:00
|
|
|
}
|
2009-10-19 17:20:09 +00:00
|
|
|
|
2009-10-19 18:49:04 +00:00
|
|
|
/* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA
|
|
|
|
* which makes the loop skip it, even the derived mesh will never change
|
|
|
|
*
|
|
|
|
* To solve that problem, we do it first as an exception.
|
2009-10-19 17:20:09 +00:00
|
|
|
* */
|
2010-01-20 17:02:24 +00:00
|
|
|
base= BASACT;
|
|
|
|
if(base && base->object && base->object->mode & OB_MODE_PARTICLE_EDIT)
|
2009-10-19 17:20:09 +00:00
|
|
|
{
|
2010-01-20 17:02:24 +00:00
|
|
|
Object *ob = base->object;
|
2009-10-19 17:20:09 +00:00
|
|
|
retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, loc, no, dist, &depth);
|
|
|
|
}
|
2011-01-13 04:53:55 +00:00
|
|
|
|
Merge from Apricot Revisions 14897, 14913, 14914, 14915, 14929, 15009, 15046
---------------------------------------------------
Snappy stuff
* Align rotation with snapping target: rotate the object, aligning it with the target (object mode only - temporarily) (New icon in the header when snap is turned on)
* Snap to different mesh elements (face, edge, vertice): snapping target slide on faces and edge or use exact position of vertice. When using Align rotation with edge snapping, the normal is interpolated as you slide along.
Snaps correctly to derived mesh (sculpt, modifiers, ...) and duplis. In object and edit mode.
NOTE: The snapping code is now based on faces, so even if you're snapping to vertices or edges, it will not work on meshes without faces. This might change if needed.
2008-06-09 18:41:16 +00:00
|
|
|
for ( base = FIRSTBASE; base != NULL; base = base->next ) {
|
2010-10-15 09:23:18 +00:00
|
|
|
if ( BASE_VISIBLE(v3d, base) && (base->flag & (BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA)) == 0 && ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT|BA_WAS_SEL)) == 0) || (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT)) ) {
|
Merge from Apricot Revisions 14897, 14913, 14914, 14915, 14929, 15009, 15046
---------------------------------------------------
Snappy stuff
* Align rotation with snapping target: rotate the object, aligning it with the target (object mode only - temporarily) (New icon in the header when snap is turned on)
* Snap to different mesh elements (face, edge, vertice): snapping target slide on faces and edge or use exact position of vertice. When using Align rotation with edge snapping, the normal is interpolated as you slide along.
Snaps correctly to derived mesh (sculpt, modifiers, ...) and duplis. In object and edit mode.
NOTE: The snapping code is now based on faces, so even if you're snapping to vertices or edges, it will not work on meshes without faces. This might change if needed.
2008-06-09 18:41:16 +00:00
|
|
|
Object *ob = base->object;
|
|
|
|
|
|
|
|
if (ob->transflag & OB_DUPLI)
|
|
|
|
{
|
|
|
|
DupliObject *dupli_ob;
|
2009-03-20 18:00:51 +00:00
|
|
|
ListBase *lb = object_duplilist(scene, ob);
|
Merge from Apricot Revisions 14897, 14913, 14914, 14915, 14929, 15009, 15046
---------------------------------------------------
Snappy stuff
* Align rotation with snapping target: rotate the object, aligning it with the target (object mode only - temporarily) (New icon in the header when snap is turned on)
* Snap to different mesh elements (face, edge, vertice): snapping target slide on faces and edge or use exact position of vertice. When using Align rotation with edge snapping, the normal is interpolated as you slide along.
Snaps correctly to derived mesh (sculpt, modifiers, ...) and duplis. In object and edit mode.
NOTE: The snapping code is now based on faces, so even if you're snapping to vertices or edges, it will not work on meshes without faces. This might change if needed.
2008-06-09 18:41:16 +00:00
|
|
|
|
|
|
|
for(dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next)
|
|
|
|
{
|
2011-05-23 08:14:29 +00:00
|
|
|
Object *dob = dupli_ob->ob;
|
Merge from Apricot Revisions 14897, 14913, 14914, 14915, 14929, 15009, 15046
---------------------------------------------------
Snappy stuff
* Align rotation with snapping target: rotate the object, aligning it with the target (object mode only - temporarily) (New icon in the header when snap is turned on)
* Snap to different mesh elements (face, edge, vertice): snapping target slide on faces and edge or use exact position of vertice. When using Align rotation with edge snapping, the normal is interpolated as you slide along.
Snaps correctly to derived mesh (sculpt, modifiers, ...) and duplis. In object and edit mode.
NOTE: The snapping code is now based on faces, so even if you're snapping to vertices or edges, it will not work on meshes without faces. This might change if needed.
2008-06-09 18:41:16 +00:00
|
|
|
|
2011-05-23 08:14:29 +00:00
|
|
|
retval |= snapObject(scene, ar, dob, 0, dupli_ob->mat, ray_start, ray_normal, mval, loc, no, dist, &depth);
|
2007-02-28 17:16:17 +00:00
|
|
|
}
|
Merge from Apricot Revisions 14897, 14913, 14914, 14915, 14929, 15009, 15046
---------------------------------------------------
Snappy stuff
* Align rotation with snapping target: rotate the object, aligning it with the target (object mode only - temporarily) (New icon in the header when snap is turned on)
* Snap to different mesh elements (face, edge, vertice): snapping target slide on faces and edge or use exact position of vertice. When using Align rotation with edge snapping, the normal is interpolated as you slide along.
Snaps correctly to derived mesh (sculpt, modifiers, ...) and duplis. In object and edit mode.
NOTE: The snapping code is now based on faces, so even if you're snapping to vertices or edges, it will not work on meshes without faces. This might change if needed.
2008-06-09 18:41:16 +00:00
|
|
|
|
|
|
|
free_object_duplilist(lb);
|
|
|
|
}
|
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, loc, no, dist, &depth);
|
2007-02-28 17:16:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2006-10-25 23:57:00 +00:00
|
|
|
|
2009-10-12 22:33:32 +00:00
|
|
|
int snapObjectsTransform(TransInfo *t, float mval[2], int *dist, float *loc, float *no, SnapMode mode)
|
2009-03-20 18:00:51 +00:00
|
|
|
{
|
|
|
|
return snapObjects(t->scene, t->view, t->ar, t->obedit, mval, dist, loc, no, mode);
|
|
|
|
}
|
|
|
|
|
2009-10-12 22:33:32 +00:00
|
|
|
int snapObjectsContext(bContext *C, float mval[2], int *dist, float *loc, float *no, SnapMode mode)
|
2009-03-20 18:00:51 +00:00
|
|
|
{
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
View3D *v3d = sa->spacedata.first;
|
|
|
|
|
|
|
|
return snapObjects(CTX_data_scene(C), v3d, CTX_wm_region(C), CTX_data_edit_object(C), mval, dist, loc, no, mode);
|
|
|
|
}
|
|
|
|
|
2009-02-24 00:45:40 +00:00
|
|
|
/******************** PEELING *********************************/
|
|
|
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static int cmpPeel(void *arg1, void *arg2)
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
|
|
|
DepthPeel *p1 = arg1;
|
|
|
|
DepthPeel *p2 = arg2;
|
|
|
|
int val = 0;
|
|
|
|
|
|
|
|
if (p1->depth < p2->depth)
|
|
|
|
{
|
|
|
|
val = -1;
|
|
|
|
}
|
|
|
|
else if (p1->depth > p2->depth)
|
|
|
|
{
|
|
|
|
val = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void removeDoublesPeel(ListBase *depth_peels)
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
|
|
|
DepthPeel *peel;
|
|
|
|
|
|
|
|
for (peel = depth_peels->first; peel; peel = peel->next)
|
|
|
|
{
|
|
|
|
DepthPeel *next_peel = peel->next;
|
2008-12-31 22:43:29 +00:00
|
|
|
|
2011-04-29 06:59:18 +00:00
|
|
|
if (next_peel && ABS(peel->depth - next_peel->depth) < 0.0015f)
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
|
|
|
peel->next = next_peel->next;
|
|
|
|
|
|
|
|
if (next_peel->next)
|
|
|
|
{
|
|
|
|
next_peel->next->prev = peel;
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(next_peel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void addDepthPeel(ListBase *depth_peels, float depth, float p[3], float no[3], Object *ob)
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
|
|
|
DepthPeel *peel = MEM_callocN(sizeof(DepthPeel), "DepthPeel");
|
|
|
|
|
|
|
|
peel->depth = depth;
|
|
|
|
peel->ob = ob;
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(peel->p, p);
|
|
|
|
copy_v3_v3(peel->no, no);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
BLI_addtail(depth_peels, peel);
|
|
|
|
|
|
|
|
peel->flag = 0;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_start[3], float ray_normal[3], float UNUSED(mval[2]), ListBase *depth_peels)
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
|
|
|
int retval = 0;
|
|
|
|
int totvert = dm->getNumVerts(dm);
|
|
|
|
int totface = dm->getNumFaces(dm);
|
|
|
|
|
|
|
|
if (totvert > 0) {
|
|
|
|
float imat[4][4];
|
|
|
|
float timat[3][3]; /* transpose inverse matrix for normals */
|
|
|
|
float ray_start_local[3], ray_normal_local[3];
|
|
|
|
int test = 1;
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, obmat);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(timat, imat);
|
|
|
|
transpose_m3(timat);
|
2008-12-31 22:43:29 +00:00
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(ray_start_local, ray_start);
|
|
|
|
copy_v3_v3(ray_normal_local, ray_normal);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(imat, ray_start_local);
|
|
|
|
mul_mat3_m4_v3(imat, ray_normal_local);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* If number of vert is more than an arbitrary limit,
|
|
|
|
* test against boundbox first
|
|
|
|
* */
|
|
|
|
if (totface > 16) {
|
|
|
|
struct BoundBox *bb = object_get_boundbox(ob);
|
|
|
|
test = ray_hit_boundbox(bb, ray_start_local, ray_normal_local);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test == 1) {
|
|
|
|
MVert *verts = dm->getVertArray(dm);
|
|
|
|
MFace *faces = dm->getFaceArray(dm);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for( i = 0; i < totface; i++) {
|
|
|
|
MFace *f = faces + i;
|
|
|
|
float lambda;
|
|
|
|
int result;
|
|
|
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
result = isect_ray_tri_threshold_v3(ray_start_local, ray_normal_local, verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, &lambda, NULL, 0.001);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
if (result) {
|
|
|
|
float location[3], normal[3];
|
|
|
|
float intersect[3];
|
|
|
|
float new_depth;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(intersect, ray_normal_local);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(intersect, lambda);
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(intersect, ray_start_local);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(location, intersect);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
if (f->v4)
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_quad_v3( normal,verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, verts[f->v4].co);
|
2009-02-24 00:45:40 +00:00
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_tri_v3( normal,verts[f->v1].co, verts[f->v2].co, verts[f->v3].co);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(obmat, location);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
new_depth = len_v3v3(location, ray_start);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(timat, normal);
|
|
|
|
normalize_v3(normal);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
addDepthPeel(depth_peels, new_depth, location, normal, ob);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (f->v4 && result == 0)
|
|
|
|
{
|
2009-11-10 20:43:45 +00:00
|
|
|
result = isect_ray_tri_threshold_v3(ray_start_local, ray_normal_local, verts[f->v3].co, verts[f->v4].co, verts[f->v1].co, &lambda, NULL, 0.001);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
if (result) {
|
|
|
|
float location[3], normal[3];
|
|
|
|
float intersect[3];
|
|
|
|
float new_depth;
|
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(intersect, ray_normal_local);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(intersect, lambda);
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(intersect, ray_start_local);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(location, intersect);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
if (f->v4)
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_quad_v3( normal,verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, verts[f->v4].co);
|
2009-02-24 00:45:40 +00:00
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_tri_v3( normal,verts[f->v1].co, verts[f->v2].co, verts[f->v3].co);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(obmat, location);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
new_depth = len_v3v3(location, ray_start);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(timat, normal);
|
|
|
|
normalize_v3(normal);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
addDepthPeel(depth_peels, new_depth, location, normal, ob);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2009-02-24 00:45:40 +00:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, ListBase *depth_peels, float mval[2])
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
|
|
|
Base *base;
|
|
|
|
int retval = 0;
|
|
|
|
float ray_start[3], ray_normal[3];
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2011-05-20 13:09:34 +00:00
|
|
|
ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
for ( base = scene->base.first; base != NULL; base = base->next ) {
|
2009-03-17 21:44:58 +00:00
|
|
|
if ( BASE_SELECTABLE(v3d, base) ) {
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
Object *ob = base->object;
|
|
|
|
|
|
|
|
if (ob->transflag & OB_DUPLI)
|
|
|
|
{
|
|
|
|
DupliObject *dupli_ob;
|
2009-03-20 18:00:51 +00:00
|
|
|
ListBase *lb = object_duplilist(scene, ob);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
for(dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next)
|
|
|
|
{
|
2010-12-03 12:30:59 +00:00
|
|
|
Object *dob = dupli_ob->ob;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
if (dob->type == OB_MESH) {
|
2009-04-20 15:06:46 +00:00
|
|
|
EditMesh *em;
|
|
|
|
DerivedMesh *dm = NULL;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
int val;
|
2009-04-20 15:06:46 +00:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
if (dob != obedit)
|
2009-04-20 15:06:46 +00:00
|
|
|
{
|
2010-12-03 12:30:59 +00:00
|
|
|
dm = mesh_get_derived_final(scene, dob, CD_MASK_BAREMESH);
|
2009-04-20 15:06:46 +00:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
val = peelDerivedMesh(dob, dm, dob->obmat, ray_start, ray_normal, mval, depth_peels);
|
2009-04-20 15:06:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-03 12:30:59 +00:00
|
|
|
em = ((Mesh *)dob->data)->edit_mesh;
|
2009-04-20 15:06:46 +00:00
|
|
|
dm = editmesh_get_derived_cage(scene, obedit, em, CD_MASK_BAREMESH);
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
val = peelDerivedMesh(dob, dm, dob->obmat, ray_start, ray_normal, mval, depth_peels);
|
2009-04-20 15:06:46 +00:00
|
|
|
}
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
retval = retval || val;
|
2009-04-20 15:06:46 +00:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
dm->release(dm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free_object_duplilist(lb);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ob->type == OB_MESH) {
|
2009-03-17 21:44:58 +00:00
|
|
|
EditMesh *em;
|
2009-02-24 00:45:40 +00:00
|
|
|
DerivedMesh *dm = NULL;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
int val;
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
if (ob != obedit)
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
2009-03-20 18:00:51 +00:00
|
|
|
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
val = peelDerivedMesh(ob, dm, ob->obmat, ray_start, ray_normal, mval, depth_peels);
|
2009-02-24 00:45:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-17 21:44:58 +00:00
|
|
|
em = ((Mesh *)ob->data)->edit_mesh;
|
2009-03-20 18:00:51 +00:00
|
|
|
dm = editmesh_get_derived_cage(scene, obedit, em, CD_MASK_BAREMESH);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2009-03-20 18:00:51 +00:00
|
|
|
val = peelDerivedMesh(ob, dm, ob->obmat, ray_start, ray_normal, mval, depth_peels);
|
2009-02-24 00:45:40 +00:00
|
|
|
}
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
retval = retval || val;
|
|
|
|
|
|
|
|
dm->release(dm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-24 00:45:40 +00:00
|
|
|
BLI_sortlist(depth_peels, cmpPeel);
|
|
|
|
removeDoublesPeel(depth_peels);
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2009-10-12 22:33:32 +00:00
|
|
|
int peelObjectsTransForm(TransInfo *t, ListBase *depth_peels, float mval[2])
|
2009-03-20 18:00:51 +00:00
|
|
|
{
|
|
|
|
return peelObjects(t->scene, t->view, t->ar, t->obedit, depth_peels, mval);
|
|
|
|
}
|
|
|
|
|
2009-10-12 22:33:32 +00:00
|
|
|
int peelObjectsContext(bContext *C, ListBase *depth_peels, float mval[2])
|
2009-03-20 18:00:51 +00:00
|
|
|
{
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
View3D *v3d = sa->spacedata.first;
|
|
|
|
|
|
|
|
return peelObjects(CTX_data_scene(C), v3d, CTX_wm_region(C), CTX_data_edit_object(C), depth_peels, mval);
|
|
|
|
}
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
/*================================================================*/
|
|
|
|
|
|
|
|
static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], GearsType action);
|
|
|
|
|
|
|
|
|
|
|
|
void snapGridAction(TransInfo *t, float *val, GearsType action) {
|
|
|
|
float fac[3];
|
|
|
|
|
|
|
|
fac[NO_GEARS] = t->snap[0];
|
|
|
|
fac[BIG_GEARS] = t->snap[1];
|
|
|
|
fac[SMALL_GEARS] = t->snap[2];
|
|
|
|
|
|
|
|
applyGrid(t, val, t->idx_max, fac, action);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void snapGrid(TransInfo *t, float *val) {
|
|
|
|
GearsType action;
|
|
|
|
|
|
|
|
// Only do something if using Snap to Grid
|
2009-11-26 19:47:55 +00:00
|
|
|
if (t->tsnap.mode != SCE_SNAP_MODE_INCREMENT)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
return;
|
|
|
|
|
2010-07-12 11:17:42 +00:00
|
|
|
action = activeSnap(t) ? BIG_GEARS : NO_GEARS;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-01-03 22:15:59 +00:00
|
|
|
if (action == BIG_GEARS && (t->modifiers & MOD_PRECISION)) {
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
action = SMALL_GEARS;
|
|
|
|
}
|
|
|
|
|
|
|
|
snapGridAction(t, val, action);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], GearsType action)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
float asp[3] = {1.0f, 1.0f, 1.0f}; // TODO: Remove hard coded limit here (3)
|
|
|
|
|
2011-07-27 13:03:56 +00:00
|
|
|
if(max_index > 2) {
|
2011-07-26 13:33:04 +00:00
|
|
|
printf("applyGrid: invalid index %d, clamping\n", max_index);
|
2011-07-27 13:03:56 +00:00
|
|
|
max_index= 2;
|
2011-07-26 13:33:04 +00:00
|
|
|
}
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
// Early bailing out if no need to snap
|
2011-03-28 17:06:15 +00:00
|
|
|
if (fac[action] == 0.0f)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* evil hack - snapping needs to be adapted for image aspect ratio */
|
|
|
|
if((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
|
2009-01-28 21:43:43 +00:00
|
|
|
ED_space_image_uv_aspect(t->sa->spacedata.first, asp, asp+1);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<=max_index; i++) {
|
2011-03-28 17:06:15 +00:00
|
|
|
val[i]= fac[action]*asp[i]*(float)floor(val[i]/(fac[action]*asp[i]) +0.5f);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
}
|