2011-02-23 10:52:22 +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
|
|
|
* ***** 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"
|
2013-11-16 19:58:29 +01:00
|
|
|
#include "DNA_curve_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"
|
2012-07-18 23:07:07 +00:00
|
|
|
#include "DNA_meshdata_types.h" /* Temporary, for snapping to other unselected meshes */
|
2012-06-29 14:34:46 +00:00
|
|
|
#include "DNA_node_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_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"
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.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 "BIF_gl.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_DerivedMesh.h"
|
2013-12-26 17:24:42 +06:00
|
|
|
#include "BKE_global.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 "BKE_object.h"
|
2012-07-18 23:07:07 +00:00
|
|
|
#include "BKE_anim.h" /* for duplis */
|
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 "BKE_context.h"
|
2013-04-13 20:31:52 +00:00
|
|
|
#include "BKE_editmesh.h"
|
2013-12-26 17:24:42 +06:00
|
|
|
#include "BKE_main.h"
|
2013-09-09 11:37:37 +00:00
|
|
|
#include "BKE_tracking.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
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
|
|
#include "WM_types.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"
|
2012-06-29 14:34:46 +00:00
|
|
|
#include "ED_node.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 "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
|
|
|
|
2013-04-03 09:48:21 +00:00
|
|
|
/* this should be passed as an arg for use in snap functions */
|
|
|
|
|
#undef BASACT
|
|
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
#define TRANSFORM_DIST_MAX_PX 1000.0f
|
|
|
|
|
#define TRANSFORM_SNAP_MAX_PX 100.0f
|
2013-04-11 10:17:06 +00:00
|
|
|
/* use half of flt-max so we can scale up without an exception */
|
2012-10-05 01:34:47 +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 ***********************/
|
|
|
|
|
|
2011-11-15 16:38:48 +00:00
|
|
|
static 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
|
|
|
|
2011-11-15 16:38:48 +00:00
|
|
|
static void ApplySnapTranslation(TransInfo *t, float vec[3]);
|
|
|
|
|
static void ApplySnapRotation(TransInfo *t, float *vec);
|
2011-11-19 00:52:54 +00:00
|
|
|
static void ApplySnapResize(TransInfo *t, float vec[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
|
|
|
|
2011-11-19 00:52:54 +00:00
|
|
|
/* static void CalcSnapGrid(TransInfo *t, float *vec); */
|
2011-11-15 16:38:48 +00:00
|
|
|
static void CalcSnapGeometry(TransInfo *t, float *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
|
|
|
|
2011-11-15 16:38:48 +00:00
|
|
|
static void TargetSnapMedian(TransInfo *t);
|
|
|
|
|
static void TargetSnapCenter(TransInfo *t);
|
|
|
|
|
static void TargetSnapClosest(TransInfo *t);
|
|
|
|
|
static void TargetSnapActive(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
|
|
|
|
2014-04-17 02:53:11 +10:00
|
|
|
static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3]);
|
|
|
|
|
static float TranslationBetween(TransInfo *t, const float p1[3], const float p2[3]);
|
|
|
|
|
static float ResizeBetween(TransInfo *t, const float p1[3], const 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
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************** IMPLEMENTATIONS *********************/
|
|
|
|
|
|
2013-03-08 18:28:26 +00:00
|
|
|
static bool snapNodeTest(View2D *v2d, bNode *node, SnapMode mode);
|
2012-06-29 14:34:46 +00:00
|
|
|
static NodeBorder snapNodeBorder(int snap_node_mode);
|
|
|
|
|
|
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;
|
|
|
|
|
|
2013-11-06 08:27:18 +00:00
|
|
|
if (obedit == NULL || ELEM5(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) /* 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
|
|
|
|
2013-04-04 09:20:46 +00:00
|
|
|
bool validSnap(TransInfo *t)
|
2009-12-03 19:18:00 +00:00
|
|
|
{
|
2012-06-10 22:13:17 +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-01 18:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-04 09:20:46 +00:00
|
|
|
bool activeSnap(TransInfo *t)
|
2009-12-03 19:18:00 +00:00
|
|
|
{
|
2013-10-01 12:35:43 +00:00
|
|
|
return ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) ||
|
|
|
|
|
((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT);
|
2009-12-03 19:18:00 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2012-06-29 14:34:46 +00:00
|
|
|
unsigned char col[4], selectedCol[4], activeCol[4];
|
|
|
|
|
|
|
|
|
|
if (!activeSnap(t))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
|
|
|
|
|
col[3] = 128;
|
|
|
|
|
|
|
|
|
|
UI_GetThemeColor3ubv(TH_SELECT, selectedCol);
|
|
|
|
|
selectedCol[3] = 128;
|
|
|
|
|
|
|
|
|
|
UI_GetThemeColor3ubv(TH_ACTIVE, activeCol);
|
|
|
|
|
activeCol[3] = 192;
|
|
|
|
|
|
|
|
|
|
if (t->spacetype == SPACE_VIEW3D) {
|
|
|
|
|
if (validSnap(t)) {
|
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);
|
2012-06-29 14:34:46 +00:00
|
|
|
|
2010-11-05 05:26:34 +00:00
|
|
|
size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
|
2012-06-29 14:34:46 +00:00
|
|
|
|
2010-09-28 10:03:56 +00:00
|
|
|
invert_m4_m4(imat, rv3d->viewmat);
|
2012-06-29 14:34:46 +00:00
|
|
|
|
2009-12-01 18:26:18 +00:00
|
|
|
for (p = t->tsnap.points.first; p; p = p->next) {
|
2011-12-26 20:23:07 +00:00
|
|
|
if (p == t->tsnap.selectedPoint) {
|
|
|
|
|
glColor4ubv(selectedCol);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2011-12-26 20:23:07 +00:00
|
|
|
glColor4ubv(col);
|
|
|
|
|
}
|
2012-06-29 14:34:46 +00:00
|
|
|
|
2011-12-26 20:23:07 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, p->co, ED_view3d_pixel_size(rv3d, p->co) * size * 0.75f, imat);
|
2009-12-01 18:26:18 +00:00
|
|
|
}
|
2012-06-29 14:34:46 +00:00
|
|
|
|
2009-12-01 18:26:18 +00:00
|
|
|
if (t->tsnap.status & POINT_INIT) {
|
2011-12-26 20:23:07 +00:00
|
|
|
glColor4ubv(activeCol);
|
2012-06-29 14:34:46 +00:00
|
|
|
|
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 */
|
2012-04-28 06:31:57 +00:00
|
|
|
if (usingSnappingNormal(t) && validSnappingNormal(t)) {
|
2011-12-26 20:23:07 +00:00
|
|
|
glColor4ubv(activeCol);
|
2012-06-29 14:34: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
|
|
|
glBegin(GL_LINES);
|
2012-06-10 22:13:17 +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]);
|
|
|
|
|
glEnd();
|
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
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (v3d->zbuf)
|
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
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
}
|
2012-06-29 14:34:46 +00:00
|
|
|
}
|
|
|
|
|
else if (t->spacetype == SPACE_IMAGE) {
|
|
|
|
|
if (validSnap(t)) {
|
2012-03-03 16:31:46 +00:00
|
|
|
/* This will not draw, and Im nor sure why - campbell */
|
|
|
|
|
#if 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
|
|
|
float xuser_asp, yuser_asp;
|
|
|
|
|
int wi, hi;
|
|
|
|
|
float w, h;
|
|
|
|
|
|
2012-06-10 22:13:17 +00:00
|
|
|
calc_image_view(G.sima, 'f'); // float
|
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
|
|
|
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
|
2012-07-25 16:30:53 +00:00
|
|
|
ED_space_image_get_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp);
|
2009-01-28 21:43:43 +00:00
|
|
|
ED_space_image_width(t->sa->spacedata.first, &wi, &hi);
|
2012-07-25 19:36:59 +00:00
|
|
|
w = (((float)wi) / IMG_SIZE_FALLBACK) * G.sima->zoom * xuser_asp;
|
|
|
|
|
h = (((float)hi) / IMG_SIZE_FALLBACK) * G.sima->zoom * yuser_asp;
|
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
|
|
|
|
|
|
|
|
cpack(0xFFFFFF);
|
|
|
|
|
glTranslatef(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], 0.0f);
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
//glRectf(0, 0, 1, 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
|
|
|
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
cpack(0x0);
|
2012-06-10 22:13:17 +00:00
|
|
|
fdrawline(-0.020 / w, 0, -0.1 / w, 0);
|
2012-06-17 09:58:26 +00:00
|
|
|
fdrawline(0.1 / w, 0, 0.020 / w, 0);
|
2012-06-10 22:13:17 +00:00
|
|
|
fdrawline(0, -0.020 / h, 0, -0.1 / h);
|
|
|
|
|
fdrawline(0, 0.1 / h, 0, 0.020 / 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
|
|
|
|
|
|
|
|
glTranslatef(-t->tsnap.snapPoint[0], -t->tsnap.snapPoint[1], 0.0f);
|
|
|
|
|
setlinestyle(0);
|
2012-03-03 16:31:46 +00:00
|
|
|
#endif
|
2012-06-29 14:34:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (t->spacetype == SPACE_NODE) {
|
|
|
|
|
if (validSnap(t)) {
|
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
|
|
|
|
TransSnapPoint *p;
|
|
|
|
|
float size;
|
|
|
|
|
|
|
|
|
|
size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
|
|
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
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
|
|
|
|
2012-06-29 14:34:46 +00:00
|
|
|
for (p = t->tsnap.points.first; p; p = p->next) {
|
|
|
|
|
if (p == t->tsnap.selectedPoint) {
|
|
|
|
|
glColor4ubv(selectedCol);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glColor4ubv(col);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-01 13:28:19 +00:00
|
|
|
ED_node_draw_snap(&ar->v2d, p->co, size, 0);
|
2012-06-29 14:34:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (t->tsnap.status & POINT_INIT) {
|
|
|
|
|
glColor4ubv(activeCol);
|
|
|
|
|
|
2012-08-01 13:28:19 +00:00
|
|
|
ED_node_draw_snap(&ar->v2d, t->tsnap.snapPoint, size, t->tsnap.snapNodeBorder);
|
2012-06-29 14:34:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-23 06:48:36 +00:00
|
|
|
eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *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
|
|
|
{
|
2013-10-23 06:48:36 +00:00
|
|
|
eRedrawFlag status = TREDRAW_NOTHING;
|
2009-11-26 19:47:55 +00:00
|
|
|
|
|
|
|
|
#if 0 // XXX need a proper selector for all snap mode
|
2012-04-28 06:31:57 +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);
|
2013-10-23 06:48:36 +00:00
|
|
|
status = TREDRAW_HARD;
|
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
|
|
|
#endif
|
2012-04-28 06:31:57 +00:00
|
|
|
if (event->type == MOUSEMOVE) {
|
2011-12-26 20:23:07 +00:00
|
|
|
status |= updateSelectedSnapPoint(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
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
void applyProject(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
/* XXX FLICKER IN OBJECT MODE */
|
2013-12-19 04:54:11 +11:00
|
|
|
if ((t->tsnap.project) && activeSnap(t) && (t->flag & T_NO_PROJECT) == 0) {
|
2009-10-22 23:22:05 +00:00
|
|
|
TransData *td = t->data;
|
|
|
|
|
float tvec[3];
|
|
|
|
|
float imat[4][4];
|
|
|
|
|
int i;
|
|
|
|
|
|
2012-06-10 22:13:17 +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
|
|
|
invert_m4_m4(imat, ob->obmat);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-10 22:13:17 +00:00
|
|
|
for (i = 0; i < t->total; i++, td++) {
|
2009-10-22 23:22:05 +00:00
|
|
|
float iloc[3], loc[3], no[3];
|
2013-04-03 07:36:37 +00:00
|
|
|
float mval_fl[2];
|
|
|
|
|
float dist_px = TRANSFORM_DIST_MAX_PX;
|
2009-10-22 23:22:05 +00:00
|
|
|
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (td->flag & TD_SKIP)
|
|
|
|
|
continue;
|
2013-02-19 16:57:04 +00:00
|
|
|
|
|
|
|
|
if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f))
|
|
|
|
|
continue;
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(iloc, td->loc);
|
2012-06-10 22:13:17 +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-22 23:22:05 +00:00
|
|
|
}
|
2012-03-07 04:53:43 +00:00
|
|
|
else if (t->flag & T_OBJECT) {
|
2013-12-26 17:24:42 +06:00
|
|
|
/* TODO(sergey): Ideally force update is not needed here. */
|
2012-06-10 22:13:17 +00:00
|
|
|
td->ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
|
2013-12-26 17:24:42 +06:00
|
|
|
BKE_object_handle_update(G.main->eval_ctx, t->scene, td->ob);
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(iloc, td->ob->obmat[3]);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
if (ED_view3d_project_float_global(t->ar, iloc, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
|
|
|
|
|
if (snapObjectsTransform(t, mval_fl, &dist_px, loc, no, t->tsnap.modeSelect)) {
|
2012-10-05 03:20:14 +00:00
|
|
|
// if (t->flag & (T_EDIT|T_POSE)) {
|
|
|
|
|
// mul_m4_v3(imat, loc);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
sub_v3_v3v3(tvec, loc, iloc);
|
|
|
|
|
|
|
|
|
|
mul_m3_v3(td->smtx, tvec);
|
|
|
|
|
|
2013-02-20 00:44:18 +00:00
|
|
|
add_v3_v3(td->loc, tvec);
|
2012-10-05 03:20:14 +00:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//XXX constraintTransLim(t, td);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-06 17:46:32 +00:00
|
|
|
void applyGridAbsolute(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
float grid_size = 0.0f;
|
|
|
|
|
GearsType grid_action;
|
|
|
|
|
TransData *td;
|
|
|
|
|
float imat[4][4];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (!(activeSnap(t) && (t->tsnap.mode == SCE_SNAP_MODE_GRID)))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
grid_action = BIG_GEARS;
|
|
|
|
|
if (t->modifiers & MOD_PRECISION)
|
|
|
|
|
grid_action = SMALL_GEARS;
|
|
|
|
|
|
|
|
|
|
switch (grid_action) {
|
|
|
|
|
case NO_GEARS: grid_size = t->snap[0]; break;
|
|
|
|
|
case BIG_GEARS: grid_size = t->snap[1]; break;
|
|
|
|
|
case SMALL_GEARS: grid_size = t->snap[2]; break;
|
|
|
|
|
}
|
|
|
|
|
/* early exit on unusable grid size */
|
|
|
|
|
if (grid_size == 0.0f)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (t->flag & (T_EDIT | T_POSE)) {
|
|
|
|
|
Object *ob = t->obedit ? t->obedit : t->poseobj;
|
|
|
|
|
invert_m4_m4(imat, ob->obmat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0, td = t->data; i < t->total; i++, td++) {
|
|
|
|
|
float iloc[3], loc[3], tvec[3];
|
|
|
|
|
|
|
|
|
|
if (td->flag & TD_NOACTION)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (td->flag & TD_SKIP)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(iloc, td->loc);
|
|
|
|
|
if (t->flag & (T_EDIT | T_POSE)) {
|
|
|
|
|
Object *ob = t->obedit ? t->obedit : t->poseobj;
|
|
|
|
|
mul_m4_v3(ob->obmat, iloc);
|
|
|
|
|
}
|
|
|
|
|
else if (t->flag & T_OBJECT) {
|
|
|
|
|
td->ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
|
2013-12-26 17:24:42 +06:00
|
|
|
BKE_object_handle_update(G.main->eval_ctx, t->scene, td->ob);
|
2013-11-06 17:46:32 +00:00
|
|
|
copy_v3_v3(iloc, td->ob->obmat[3]);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-17 22:00:57 +11:00
|
|
|
mul_v3_v3fl(loc, iloc, 1.0f / grid_size);
|
2013-11-06 17:46:32 +00:00
|
|
|
loc[0] = floorf(loc[0]);
|
|
|
|
|
loc[1] = floorf(loc[1]);
|
|
|
|
|
loc[2] = floorf(loc[2]);
|
|
|
|
|
mul_v3_fl(loc, grid_size);
|
|
|
|
|
|
|
|
|
|
sub_v3_v3v3(tvec, loc, iloc);
|
|
|
|
|
mul_m3_v3(td->smtx, tvec);
|
|
|
|
|
add_v3_v3(td->loc, tvec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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-22 23:22:05 +00:00
|
|
|
/* project is not applied this way */
|
|
|
|
|
if (t->tsnap.project)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (t->tsnap.status & SNAP_FORCED) {
|
2009-03-29 19:52:53 +00:00
|
|
|
t->tsnap.targetSnap(t);
|
|
|
|
|
|
|
|
|
|
t->tsnap.applySnap(t, vec);
|
|
|
|
|
}
|
2012-03-07 04:53:43 +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 */
|
2012-05-20 19:49:27 +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;
|
|
|
|
|
}
|
2012-04-28 06:31:57 +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;
|
2013-04-04 09:20:46 +00:00
|
|
|
t->tsnap.align = false;
|
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;
|
2012-06-29 14:34:46 +00:00
|
|
|
|
|
|
|
|
t->tsnap.snapNodeBorder = 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
|
|
|
}
|
|
|
|
|
|
2013-04-04 09:20:46 +00:00
|
|
|
bool usingSnappingNormal(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-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
|
|
|
}
|
|
|
|
|
|
2013-04-04 09:20:46 +00:00
|
|
|
bool validSnappingNormal(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
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
if (validSnap(t)) {
|
2014-03-29 22:23:27 +11:00
|
|
|
if (!is_zero_v3(t->tsnap.snapNormal)) {
|
2013-04-04 09:20:46 +00:00
|
|
|
return true;
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-04 09:20:46 +00:00
|
|
|
return false;
|
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-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-11-01 00:06:53 +00:00
|
|
|
Scene *scene = t->scene;
|
2013-04-03 09:48:21 +00:00
|
|
|
Base *base_act = scene->basact;
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2012-06-29 14:34:46 +00:00
|
|
|
if (t->spacetype == SPACE_NODE) {
|
|
|
|
|
/* force project off when not supported */
|
2009-10-22 23:22:05 +00:00
|
|
|
t->tsnap.project = 0;
|
2012-06-29 14:34:46 +00:00
|
|
|
|
|
|
|
|
t->tsnap.mode = ts->snap_node_mode;
|
|
|
|
|
}
|
2012-12-03 12:03:16 +00:00
|
|
|
else if (t->spacetype == SPACE_IMAGE) {
|
|
|
|
|
/* force project off when not supported */
|
|
|
|
|
t->tsnap.project = 0;
|
|
|
|
|
|
|
|
|
|
t->tsnap.mode = ts->snap_uv_mode;
|
|
|
|
|
}
|
2012-06-29 14:34:46 +00:00
|
|
|
else {
|
|
|
|
|
/* force project off when not supported */
|
2012-12-03 12:03:16 +00:00
|
|
|
if (ts->snap_mode != SCE_SNAP_MODE_FACE)
|
2012-06-29 14:34:46 +00:00
|
|
|
t->tsnap.project = 0;
|
|
|
|
|
|
|
|
|
|
t->tsnap.mode = ts->snap_mode;
|
2009-03-29 19:52:53 +00:00
|
|
|
}
|
2009-12-03 19:18:00 +00:00
|
|
|
|
2012-05-24 16:35:45 +00:00
|
|
|
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 */
|
|
|
|
|
{
|
2009-12-03 19:18:00 +00:00
|
|
|
setSnappingCallback(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
|
|
|
|
|
|
|
|
/* Edit mode */
|
|
|
|
|
if (t->tsnap.applySnap != NULL && // A snapping function actually exist
|
2013-11-06 08:27:18 +00:00
|
|
|
(obedit != NULL && ELEM5(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) ) // Temporary limited to edit mode meshes, armature, curves, mballs
|
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
|
|
|
{
|
2014-06-14 14:30:22 +03:00
|
|
|
BoundBox *bb_init;
|
2011-06-21 15:28:13 +00:00
|
|
|
/* Exclude editmesh if using proportional edit */
|
2012-03-06 18:40:15 +00:00
|
|
|
if ((obedit->type == OB_MESH) && (t->flag & T_PROP_EDIT)) {
|
2009-12-03 19:18:00 +00:00
|
|
|
t->tsnap.modeSelect = SNAP_NOT_OBEDIT;
|
2009-01-03 17:21:32 +00:00
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
else {
|
2011-07-27 07:22:31 +00:00
|
|
|
t->tsnap.modeSelect = t->tsnap.snap_self ? SNAP_ALL : SNAP_NOT_OBEDIT;
|
2009-01-03 17:21:32 +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-11-01 00:06:53 +00:00
|
|
|
/* Particles edit mode*/
|
|
|
|
|
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
|
2013-04-03 09:48:21 +00:00
|
|
|
(obedit == NULL && base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT))
|
2009-11-01 00:06:53 +00:00
|
|
|
{
|
2009-12-03 19:18:00 +00:00
|
|
|
t->tsnap.modeSelect = SNAP_ALL;
|
2009-11-01 00:06: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
|
|
|
/* Object mode */
|
|
|
|
|
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
|
2012-06-10 22:13:17 +00:00
|
|
|
(obedit == NULL) ) // Object 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
|
|
|
{
|
2009-12-03 19:18:00 +00:00
|
|
|
t->tsnap.modeSelect = SNAP_NOT_SELECTED;
|
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
|
|
|
}
|
2012-03-06 18:40:15 +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
|
|
|
/* Grid if snap is not possible */
|
2009-12-03 19:18:00 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
2012-07-04 20:47:12 +00:00
|
|
|
else if (t->spacetype == SPACE_NODE) {
|
2012-06-29 14:34:46 +00:00
|
|
|
setSnappingCallback(t);
|
|
|
|
|
|
2012-07-04 20:47:12 +00:00
|
|
|
if (t->tsnap.applySnap != NULL) {
|
2012-06-29 14:34:46 +00:00
|
|
|
t->tsnap.modeSelect = SNAP_NOT_SELECTED;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Grid if snap is not possible */
|
|
|
|
|
t->tsnap.mode = SCE_SNAP_MODE_INCREMENT;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-06 18:40:15 +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
|
|
|
/* Always grid outside of 3D view */
|
2009-12-03 19:18:00 +00:00
|
|
|
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 */
|
2012-04-28 06:31:57 +00:00
|
|
|
if (op && RNA_struct_find_property(op->ptr, "snap") && RNA_struct_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;
|
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "snap_target")) {
|
2009-11-27 16:15:34 +00:00
|
|
|
snap_target = RNA_enum_get(op->ptr, "snap_target");
|
|
|
|
|
}
|
2009-03-29 19:52:53 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "snap_point")) {
|
2009-11-27 16:15:34 +00:00
|
|
|
RNA_float_get_array(op->ptr, "snap_point", t->tsnap.snapPoint);
|
2012-06-10 22:13:17 +00:00
|
|
|
t->tsnap.status |= SNAP_FORCED | POINT_INIT;
|
2009-11-27 16:15:34 +00:00
|
|
|
}
|
2009-03-29 19:52:53 +00:00
|
|
|
|
|
|
|
|
/* snap align only defined in specific cases */
|
2012-04-28 06:31:57 +00:00
|
|
|
if (RNA_struct_find_property(op->ptr, "snap_align")) {
|
2009-03-29 19:52:53 +00:00
|
|
|
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
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (RNA_struct_find_property(op->ptr, "use_snap_project")) {
|
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
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (RNA_struct_find_property(op->ptr, "use_snap_self")) {
|
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
|
|
|
}
|
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-27 16:15:34 +00:00
|
|
|
/* use scene defaults only when transform is modal */
|
2012-03-07 04:53:43 +00:00
|
|
|
else if (t->flag & T_MODAL) {
|
2012-06-28 08:47:22 +00:00
|
|
|
if (ELEM3(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) {
|
2011-07-28 02:15:58 +00:00
|
|
|
if (ts->snap_flag & SCE_SNAP) {
|
|
|
|
|
t->modifiers |= MOD_SNAP;
|
|
|
|
|
}
|
2009-11-27 16:15:34 +00:00
|
|
|
|
2014-04-17 02:53:11 +10:00
|
|
|
t->tsnap.align = ((t->settings->snap_flag & SCE_SNAP_ROTATE) != 0);
|
|
|
|
|
t->tsnap.project = ((t->settings->snap_flag & SCE_SNAP_PROJECT) != 0);
|
|
|
|
|
t->tsnap.snap_self = !((t->settings->snap_flag & SCE_SNAP_NO_SELF) != 0);
|
|
|
|
|
t->tsnap.peel = ((t->settings->snap_flag & SCE_SNAP_PROJECT) != 0);
|
2011-07-28 02:15:58 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2011-11-15 16:38:48 +00:00
|
|
|
static 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;
|
|
|
|
|
|
2012-04-28 06:31:57 +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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (t->mode) {
|
2012-06-10 22:13:17 +00:00
|
|
|
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
|
|
|
|
|
if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
|
|
|
|
|
t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
|
|
|
|
|
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
|
|
|
|
|
if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
|
|
|
|
|
t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
|
|
|
|
|
t->tsnap.targetSnap = TargetSnapMedian;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
t->tsnap.applySnap = NULL;
|
|
|
|
|
break;
|
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-01 18:26:18 +00:00
|
|
|
void addSnapPoint(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
if (t->tsnap.status & POINT_INIT) {
|
|
|
|
|
TransSnapPoint *p = MEM_callocN(sizeof(TransSnapPoint), "SnapPoint");
|
|
|
|
|
|
2011-12-26 20:23:07 +00:00
|
|
|
t->tsnap.selectedPoint = p;
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-23 06:48:36 +00:00
|
|
|
eRedrawFlag updateSelectedSnapPoint(TransInfo *t)
|
2011-12-26 20:23:07 +00:00
|
|
|
{
|
2013-10-23 06:48:36 +00:00
|
|
|
eRedrawFlag status = TREDRAW_NOTHING;
|
|
|
|
|
|
2011-12-26 20:23:07 +00:00
|
|
|
if (t->tsnap.status & MULTI_POINTS) {
|
|
|
|
|
TransSnapPoint *p, *closest_p = NULL;
|
2014-02-03 02:46:45 +11:00
|
|
|
float dist_min_sq = TRANSFORM_SNAP_MAX_PX;
|
2013-04-03 07:36:37 +00:00
|
|
|
const float mval_fl[2] = {t->mval[0], t->mval[1]};
|
|
|
|
|
float screen_loc[2];
|
2011-12-26 20:23:07 +00:00
|
|
|
|
2012-06-10 22:13:17 +00:00
|
|
|
for (p = t->tsnap.points.first; p; p = p->next) {
|
2014-02-03 02:46:45 +11:00
|
|
|
float dist_sq;
|
2011-12-26 20:23:07 +00:00
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
if (ED_view3d_project_float_global(t->ar, p->co, screen_loc, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) {
|
2012-10-04 17:52:12 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2011-12-26 20:23:07 +00:00
|
|
|
|
2014-02-03 02:46:45 +11:00
|
|
|
dist_sq = len_squared_v2v2(mval_fl, screen_loc);
|
2011-12-26 20:23:07 +00:00
|
|
|
|
2014-02-03 02:46:45 +11:00
|
|
|
if (dist_sq < dist_min_sq) {
|
2011-12-26 20:23:07 +00:00
|
|
|
closest_p = p;
|
2014-02-03 02:46:45 +11:00
|
|
|
dist_min_sq = dist_sq;
|
2011-12-26 20:23:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (closest_p) {
|
2013-10-23 06:48:36 +00:00
|
|
|
if (t->tsnap.selectedPoint != closest_p) {
|
|
|
|
|
status = TREDRAW_HARD;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-26 20:23:07 +00:00
|
|
|
t->tsnap.selectedPoint = closest_p;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-01 18:26:18 +00:00
|
|
|
void removeSnapPoint(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
if (t->tsnap.status & MULTI_POINTS) {
|
2011-12-26 20:23:07 +00:00
|
|
|
updateSelectedSnapPoint(t);
|
|
|
|
|
|
|
|
|
|
if (t->tsnap.selectedPoint) {
|
|
|
|
|
BLI_freelinkN(&t->tsnap.points, t->tsnap.selectedPoint);
|
|
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
if (BLI_listbase_is_empty(&t->tsnap.points)) {
|
2011-12-26 20:23:07 +00:00
|
|
|
t->tsnap.status &= ~MULTI_POINTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t->tsnap.selectedPoint = NULL;
|
|
|
|
|
}
|
2009-12-01 18:26:18 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
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 **************************/
|
|
|
|
|
|
2011-11-15 16:38:48 +00:00
|
|
|
static void ApplySnapTranslation(TransInfo *t, float vec[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-12-01 18:26:18 +00:00
|
|
|
float point[3];
|
|
|
|
|
getSnapPoint(t, point);
|
2012-06-29 14:34:46 +00:00
|
|
|
|
|
|
|
|
if (t->spacetype == SPACE_NODE) {
|
|
|
|
|
char border = t->tsnap.snapNodeBorder;
|
|
|
|
|
if (border & (NODE_LEFT | NODE_RIGHT))
|
|
|
|
|
vec[0] = point[0] - t->tsnap.snapTarget[0];
|
|
|
|
|
if (border & (NODE_BOTTOM | NODE_TOP))
|
|
|
|
|
vec[1] = point[1] - t->tsnap.snapTarget[1];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2012-02-28 14:05:00 +00:00
|
|
|
static void ApplySnapRotation(TransInfo *t, float *value)
|
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 (t->tsnap.target == SCE_SNAP_TARGET_CLOSEST) {
|
2012-02-28 14:05:00 +00:00
|
|
|
*value = t->tsnap.dist;
|
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-12-01 18:26:18 +00:00
|
|
|
float point[3];
|
|
|
|
|
getSnapPoint(t, point);
|
2012-02-28 14:05:00 +00:00
|
|
|
*value = 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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 16:38:48 +00:00
|
|
|
static void ApplySnapResize(TransInfo *t, float vec[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-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 **************************/
|
|
|
|
|
|
2014-04-17 02:53:11 +10:00
|
|
|
static float TranslationBetween(TransInfo *UNUSED(t), const float p1[3], const 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
|
|
|
}
|
|
|
|
|
|
2014-04-17 02:53:11 +10:00
|
|
|
static float RotationBetween(TransInfo *t, const float p1[3], const 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
|
|
|
{
|
|
|
|
|
float angle, start[3], end[3], center[3];
|
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
copy_v3_v3(center, t->center);
|
2012-06-10 22:13:17 +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, 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);
|
2012-10-21 05:46:41 +00:00
|
|
|
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));
|
2012-05-19 13:55:54 +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
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
angle = atan2(start[1], start[0]) - atan2(end[1], end[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-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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-17 02:53:11 +10:00
|
|
|
static float ResizeBetween(TransInfo *t, const float p1[3], const 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
|
|
|
{
|
2011-12-26 19:03:32 +00:00
|
|
|
float d1[3], d2[3], center[3], len_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
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
copy_v3_v3(center, t->center);
|
2012-06-10 22:13:17 +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, 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
|
|
|
}
|
|
|
|
|
|
2011-12-26 19:03:32 +00:00
|
|
|
len_d1 = len_v3(d1);
|
|
|
|
|
|
|
|
|
|
return len_d1 != 0.0f ? len_v3(d2) / len_d1 : 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************** CALC **************************/
|
|
|
|
|
|
2013-03-08 04:00:06 +00:00
|
|
|
static void UNUSED_FUNCTION(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
|
|
|
{
|
2013-11-06 17:46:32 +00:00
|
|
|
snapGridIncrementAction(t, t->tsnap.snapPoint, BIG_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
|
|
|
}
|
|
|
|
|
|
2011-11-15 16:38:48 +00:00
|
|
|
static 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
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
if (t->spacetype == SPACE_VIEW3D) {
|
2009-02-24 00:45:40 +00:00
|
|
|
float loc[3];
|
|
|
|
|
float no[3];
|
2009-10-22 23:22:05 +00:00
|
|
|
float mval[2];
|
2013-03-08 18:28:26 +00:00
|
|
|
bool found = false;
|
2013-04-03 07:36:37 +00:00
|
|
|
float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here
|
2009-10-22 23:22:05 +00:00
|
|
|
|
|
|
|
|
mval[0] = t->mval[0];
|
|
|
|
|
mval[1] = t->mval[1];
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (t->tsnap.mode == SCE_SNAP_MODE_VOLUME) {
|
2009-02-24 00:45:40 +00:00
|
|
|
ListBase depth_peels;
|
|
|
|
|
DepthPeel *p1, *p2;
|
2014-04-27 00:22:49 +10:00
|
|
|
const float *last_p = NULL;
|
2010-12-03 12:30:59 +00:00
|
|
|
float max_dist = FLT_MAX;
|
2009-11-01 00:06:53 +00:00
|
|
|
float p[3] = {0.0f, 0.0f, 0.0f};
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&depth_peels);
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2012-03-10 21:40:35 +00:00
|
|
|
peelObjectsTransForm(t, &depth_peels, mval, t->tsnap.modeSelect);
|
2008-01-13 22:20:18 +00:00
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
// if (LAST_SNAP_POINT_VALID)
|
2009-02-24 00:45:40 +00:00
|
|
|
// {
|
2009-05-23 03:24:15 +00:00
|
|
|
// last_p = LAST_SNAP_POINT;
|
2009-02-24 00:45:40 +00:00
|
|
|
// }
|
2009-05-23 03:24:15 +00:00
|
|
|
// else
|
2009-02-24 00:45:40 +00:00
|
|
|
// {
|
2009-05-23 03:24:15 +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
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
for (p1 = depth_peels.first; p1; p1 = p1->next) {
|
|
|
|
|
if (p1->flag == 0) {
|
2009-02-24 00:45:40 +00:00
|
|
|
float vec[3];
|
|
|
|
|
float new_dist;
|
|
|
|
|
|
|
|
|
|
p2 = NULL;
|
|
|
|
|
p1->flag = 1;
|
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* if peeling objects, take the first and last from each object */
|
2012-04-28 06:31:57 +00:00
|
|
|
if (t->settings->snap_flag & SCE_SNAP_PEEL_OBJECT) {
|
2009-02-24 00:45:40 +00:00
|
|
|
DepthPeel *peel;
|
2012-04-28 06:31:57 +00:00
|
|
|
for (peel = p1->next; peel; peel = peel->next) {
|
|
|
|
|
if (peel->ob == p1->ob) {
|
2009-02-24 00:45:40 +00:00
|
|
|
peel->flag = 1;
|
|
|
|
|
p2 = peel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* otherwise, pair first with second and so on */
|
2012-03-06 18:40:15 +00:00
|
|
|
else {
|
2012-04-28 06:31:57 +00:00
|
|
|
for (p2 = p1->next; p2 && p2->ob != p1->ob; p2 = p2->next) {
|
2009-02-24 00:45:40 +00:00
|
|
|
/* nothing to do here */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-06 18:40:15 +00:00
|
|
|
if (p2) {
|
2009-02-24 00:45:40 +00:00
|
|
|
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
|
|
|
}
|
2012-03-06 18:40:15 +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
|
|
|
}
|
2012-04-28 06:31:57 +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
|
|
|
|
2012-03-06 18:40:15 +00:00
|
|
|
if (new_dist < max_dist) {
|
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
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (max_dist != FLT_MAX) {
|
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 */
|
2012-06-10 22:13:17 +00:00
|
|
|
no[0] = 0.0;
|
|
|
|
|
no[1] = 0.0;
|
|
|
|
|
no[2] = 1.0;
|
2013-03-08 18:28:26 +00:00
|
|
|
found = true;
|
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
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
else {
|
2013-04-03 07:36:37 +00:00
|
|
|
found = snapObjectsTransform(t, mval, &dist_px, loc, no, t->tsnap.modeSelect);
|
2011-05-11 09:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-08 18:28:26 +00:00
|
|
|
if (found == true) {
|
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
|
|
|
|
2014-03-29 22:23:27 +11:00
|
|
|
sub_v2_v2v2(tangent, loc, t->tsnap.snapPoint);
|
|
|
|
|
tangent[2] = 0.0f;
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2014-03-29 22:23:27 +11:00
|
|
|
if (!is_zero_v3(tangent)) {
|
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;
|
|
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
else {
|
2009-02-24 00:45:40 +00:00
|
|
|
t->tsnap.status &= ~POINT_INIT;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-10 22:13:17 +00:00
|
|
|
else if (t->spacetype == SPACE_IMAGE && t->obedit != NULL && t->obedit->type == OB_MESH) {
|
2009-03-17 21:44:58 +00:00
|
|
|
/* same as above but for UV's */
|
2012-06-10 22:13:17 +00:00
|
|
|
Image *ima = ED_space_image(t->sa->spacedata.first);
|
2009-03-17 21:44:58 +00:00
|
|
|
float aspx, aspy, co[2];
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2014-04-21 16:47:16 +10:00
|
|
|
UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], &co[0], &co[1]);
|
2008-02-27 19:35:27 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) {
|
2012-07-25 16:30:53 +00:00
|
|
|
ED_space_image_get_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;
|
|
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
else {
|
2009-02-24 00:45:40 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
2012-06-29 14:34:46 +00:00
|
|
|
else if (t->spacetype == SPACE_NODE) {
|
|
|
|
|
float loc[2];
|
2013-04-03 07:36:37 +00:00
|
|
|
float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here
|
2012-06-29 14:34:46 +00:00
|
|
|
char node_border;
|
|
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
if (snapNodesTransform(t, t->mval, &dist_px, loc, &node_border, t->tsnap.modeSelect)) {
|
2012-06-29 14:34:46 +00:00
|
|
|
copy_v2_v2(t->tsnap.snapPoint, loc);
|
|
|
|
|
t->tsnap.snapNodeBorder = node_border;
|
|
|
|
|
|
|
|
|
|
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 **************************/
|
|
|
|
|
|
2012-06-29 14:34:46 +00:00
|
|
|
static void TargetSnapOffset(TransInfo *t, TransData *td)
|
|
|
|
|
{
|
|
|
|
|
if (t->spacetype == SPACE_NODE && td != NULL) {
|
|
|
|
|
bNode *node = td->extra;
|
|
|
|
|
char border = t->tsnap.snapNodeBorder;
|
2012-09-15 11:48:20 +00:00
|
|
|
float width = BLI_rctf_size_x(&node->totr);
|
|
|
|
|
float height = BLI_rctf_size_y(&node->totr);
|
2012-06-29 14:34:46 +00:00
|
|
|
|
2014-01-21 13:13:41 +01:00
|
|
|
#ifdef USE_NODE_CENTER
|
2012-06-29 14:34:46 +00:00
|
|
|
if (border & NODE_LEFT)
|
|
|
|
|
t->tsnap.snapTarget[0] -= 0.5f * width;
|
|
|
|
|
if (border & NODE_RIGHT)
|
|
|
|
|
t->tsnap.snapTarget[0] += 0.5f * width;
|
|
|
|
|
if (border & NODE_BOTTOM)
|
|
|
|
|
t->tsnap.snapTarget[1] -= 0.5f * height;
|
|
|
|
|
if (border & NODE_TOP)
|
|
|
|
|
t->tsnap.snapTarget[1] += 0.5f * height;
|
2014-01-21 13:13:41 +01:00
|
|
|
#else
|
|
|
|
|
if (border & NODE_LEFT)
|
|
|
|
|
t->tsnap.snapTarget[0] -= 0.0f;
|
|
|
|
|
if (border & NODE_RIGHT)
|
|
|
|
|
t->tsnap.snapTarget[0] += width;
|
|
|
|
|
if (border & NODE_BOTTOM)
|
|
|
|
|
t->tsnap.snapTarget[1] -= height;
|
|
|
|
|
if (border & NODE_TOP)
|
|
|
|
|
t->tsnap.snapTarget[1] += 0.0f;
|
|
|
|
|
#endif
|
2012-06-29 14:34:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 16:38:48 +00:00
|
|
|
static void TargetSnapCenter(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
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
/* Only need to calculate once */
|
|
|
|
|
if ((t->tsnap.status & TARGET_INIT) == 0) {
|
2012-10-21 05:46:41 +00:00
|
|
|
copy_v3_v3(t->tsnap.snapTarget, t->center);
|
2012-06-29 14:34:46 +00:00
|
|
|
|
2012-06-10 22:13:17 +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, 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
|
|
|
}
|
|
|
|
|
|
2012-06-29 14:34:46 +00:00
|
|
|
TargetSnapOffset(t, NULL);
|
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
t->tsnap.status |= TARGET_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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 16:38:48 +00:00
|
|
|
static void TargetSnapActive(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
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
/* Only need to calculate once */
|
|
|
|
|
if ((t->tsnap.status & TARGET_INIT) == 0) {
|
2014-05-09 16:52:09 +10:00
|
|
|
if (calculateCenterActive(t, true, t->tsnap.snapTarget)) {
|
2012-06-10 22:13:17 +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, 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
|
|
|
}
|
2014-05-09 16:52:09 +10:00
|
|
|
|
|
|
|
|
TargetSnapOffset(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
|
|
|
t->tsnap.status |= TARGET_INIT;
|
|
|
|
|
}
|
|
|
|
|
/* No active, default to median */
|
2012-03-06 18:40:15 +00:00
|
|
|
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);
|
2012-10-21 05:46:41 +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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 16:38:48 +00:00
|
|
|
static void TargetSnapMedian(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
|
|
|
{
|
|
|
|
|
// Only need to calculate once
|
2012-04-28 06:31:57 +00:00
|
|
|
if ((t->tsnap.status & TARGET_INIT) == 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
|
|
|
TransData *td = NULL;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
t->tsnap.snapTarget[0] = 0;
|
|
|
|
|
t->tsnap.snapTarget[1] = 0;
|
|
|
|
|
t->tsnap.snapTarget[2] = 0;
|
|
|
|
|
|
2012-06-10 22:13:17 +00:00
|
|
|
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
|
|
|
|
2012-06-10 22:13:17 +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, 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
|
|
|
}
|
|
|
|
|
|
2012-06-29 14:34:46 +00:00
|
|
|
TargetSnapOffset(t, NULL);
|
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
t->tsnap.status |= TARGET_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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 16:38:48 +00:00
|
|
|
static void TargetSnapClosest(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
|
|
|
{
|
|
|
|
|
// Only valid if a snap point has been selected
|
2012-04-28 06:31:57 +00:00
|
|
|
if (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
|
|
|
TransData *closest = NULL, *td = NULL;
|
|
|
|
|
|
|
|
|
|
/* Object mode */
|
2012-04-28 06:31:57 +00:00
|
|
|
if (t->flag & T_OBJECT) {
|
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 i;
|
2012-06-10 22:13:17 +00:00
|
|
|
for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
|
2012-05-05 14:03:12 +00:00
|
|
|
struct BoundBox *bb = BKE_object_boundbox_get(td->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
|
|
|
|
|
|
|
|
/* use boundbox if possible */
|
2012-04-28 06:31:57 +00:00
|
|
|
if (bb) {
|
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 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);
|
|
|
|
|
|
2012-07-21 15:27:40 +00:00
|
|
|
if (closest == NULL || fabsf(dist) < fabsf(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 */
|
2012-03-06 18:40:15 +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
|
|
|
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);
|
|
|
|
|
|
2012-07-21 15:27:40 +00:00
|
|
|
if (closest == NULL || fabsf(dist) < fabsf(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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-06 18:40:15 +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
|
|
|
int i;
|
2012-06-10 22:13:17 +00:00
|
|
|
for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, 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
|
|
|
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
|
|
|
|
2012-06-10 22:13:17 +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, 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);
|
|
|
|
|
|
2012-07-21 15:27:40 +00:00
|
|
|
if (closest == NULL || fabsf(dist) < fabsf(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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-29 14:34:46 +00:00
|
|
|
TargetSnapOffset(t, 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
|
|
|
t->tsnap.status |= TARGET_INIT;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2013-08-19 04:22:05 +00:00
|
|
|
static bool snapEdge(ARegion *ar, const float v1co[3], const short v1no[3], const float v2co[3], const short v2no[3], float obmat[4][4], float timat[3][3],
|
2013-04-03 07:36:37 +00:00
|
|
|
const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval_fl[2],
|
|
|
|
|
float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
|
|
|
|
float intersect[3] = {0, 0, 0}, ray_end[3], dvec[3];
|
|
|
|
|
int result;
|
2013-03-08 18:28:26 +00:00
|
|
|
bool retval = false;
|
2009-02-24 21:25:36 +00:00
|
|
|
|
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
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (result) {
|
2009-02-24 21:25:36 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (dot_v3v3(ray_normal_local, dvec) > 0) {
|
2009-02-24 21:25:36 +00:00
|
|
|
float location[3];
|
|
|
|
|
float new_depth;
|
2013-04-03 07:36:37 +00:00
|
|
|
float screen_loc[2];
|
|
|
|
|
float new_dist;
|
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
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(obmat, location);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
new_depth = len_v3v3(location, ray_start);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
if (ED_view3d_project_float_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
|
|
|
|
|
new_dist = len_manhattan_v2v2(mval_fl, screen_loc);
|
2012-10-04 17:52:12 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-10-05 01:34:47 +00:00
|
|
|
new_dist = TRANSFORM_DIST_MAX_PX;
|
2012-10-04 17:52:12 +00:00
|
|
|
}
|
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
|
|
|
|
|
* */
|
2013-04-03 07:36:37 +00:00
|
|
|
if (new_dist <= *r_dist_px && new_depth < *r_depth * 1.001f) {
|
2009-02-24 21:25:36 +00:00
|
|
|
float n1[3], n2[3];
|
|
|
|
|
|
2011-11-19 00:52:54 +00:00
|
|
|
*r_depth = new_depth;
|
2013-03-08 18:28:26 +00:00
|
|
|
retval = true;
|
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
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (r_no) {
|
2012-10-21 05:46:41 +00:00
|
|
|
normal_short_to_float_v3(n1, v1no);
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_short_to_float_v3(n2, v2no);
|
2011-11-19 00:52:54 +00:00
|
|
|
interp_v3_v3v3(r_no, n2, n1, mul);
|
|
|
|
|
mul_m3_v3(timat, r_no);
|
|
|
|
|
normalize_v3(r_no);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2011-11-19 00:52:54 +00:00
|
|
|
copy_v3_v3(r_loc, location);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
*r_dist_px = new_dist;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-02-24 21:25:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-19 04:22:05 +00:00
|
|
|
static bool snapVertex(ARegion *ar, const float vco[3], const short vno[3], float obmat[4][4], float timat[3][3],
|
2013-04-03 07:36:37 +00:00
|
|
|
const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval_fl[2],
|
|
|
|
|
float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
2013-03-08 18:28:26 +00:00
|
|
|
bool retval = false;
|
2009-02-24 21:25:36 +00:00
|
|
|
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
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (dot_v3v3(ray_normal_local, dvec) > 0) {
|
2009-02-24 21:25:36 +00:00
|
|
|
float location[3];
|
|
|
|
|
float new_depth;
|
2013-04-03 07:36:37 +00:00
|
|
|
float screen_loc[2];
|
|
|
|
|
float new_dist;
|
2009-02-24 21:25:36 +00:00
|
|
|
|
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
|
|
|
|
2011-11-19 00:52:54 +00:00
|
|
|
new_depth = len_v3v3(location, ray_start);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
if (ED_view3d_project_float_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
|
|
|
|
|
new_dist = len_manhattan_v2v2(mval_fl, screen_loc);
|
2012-10-04 17:52:12 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-10-05 01:34:47 +00:00
|
|
|
new_dist = TRANSFORM_DIST_MAX_PX;
|
2012-10-04 17:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
if (new_dist <= *r_dist_px && new_depth < *r_depth) {
|
2011-11-19 00:52:54 +00:00
|
|
|
*r_depth = new_depth;
|
2013-03-08 18:28:26 +00:00
|
|
|
retval = true;
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2011-11-19 00:52:54 +00:00
|
|
|
copy_v3_v3(r_loc, location);
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (r_no) {
|
2011-11-19 00:52:54 +00:00
|
|
|
normal_short_to_float_v3(r_no, vno);
|
|
|
|
|
mul_m3_v3(timat, r_no);
|
|
|
|
|
normalize_v3(r_no);
|
2009-02-24 21:25:36 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
*r_dist_px = new_dist;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-02-24 21:25:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-08 18:28:26 +00:00
|
|
|
static bool snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm, float obmat[4][4],
|
|
|
|
|
const float ray_start[3], const float ray_normal[3], const float mval[2],
|
2013-04-03 07:36:37 +00:00
|
|
|
float r_loc[3], float *UNUSED(r_no), float *r_dist_px, float *r_depth)
|
2009-02-24 21:25:36 +00:00
|
|
|
{
|
|
|
|
|
float imat[4][4];
|
|
|
|
|
float ray_start_local[3], ray_normal_local[3];
|
2013-03-08 18:28:26 +00:00
|
|
|
bool retval = false;
|
2009-02-24 21:25:36 +00:00
|
|
|
|
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
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (arm->edbo) {
|
2009-02-25 20:07:45 +00:00
|
|
|
EditBone *eBone;
|
|
|
|
|
|
2012-06-10 22:13:17 +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 */
|
2012-06-10 22:13:17 +00:00
|
|
|
if ((eBone->flag & (BONE_HIDDEN_A | BONE_ROOTSEL | BONE_TIPSEL)) == 0) {
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (snap_mode) {
|
2009-02-25 20:07:45 +00:00
|
|
|
case SCE_SNAP_MODE_VERTEX:
|
2013-04-03 07:36:37 +00:00
|
|
|
retval |= snapVertex(ar, eBone->head, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
|
|
|
|
retval |= snapVertex(ar, eBone->tail, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
2009-02-25 20:07:45 +00:00
|
|
|
break;
|
|
|
|
|
case SCE_SNAP_MODE_EDGE:
|
2013-04-03 07:36:37 +00:00
|
|
|
retval |= snapEdge(ar, eBone->head, NULL, eBone->tail, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_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
|
|
|
}
|
2012-03-07 04:53:43 +00:00
|
|
|
else if (ob->pose && ob->pose->chanbase.first) {
|
2009-02-25 20:07:45 +00:00
|
|
|
bPoseChannel *pchan;
|
|
|
|
|
Bone *bone;
|
2009-02-24 21:25:36 +00:00
|
|
|
|
2012-06-10 22:13:17 +00:00
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
|
bone = pchan->bone;
|
2009-02-25 20:07:45 +00:00
|
|
|
/* skip hidden bones */
|
2012-06-10 22:13:17 +00:00
|
|
|
if (bone && !(bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) {
|
2014-04-27 00:22:49 +10:00
|
|
|
const float *head_vec = pchan->pose_head;
|
|
|
|
|
const float *tail_vec = pchan->pose_tail;
|
2009-02-25 20:07:45 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (snap_mode) {
|
2009-02-25 20:07:45 +00:00
|
|
|
case SCE_SNAP_MODE_VERTEX:
|
2013-04-03 07:36:37 +00:00
|
|
|
retval |= snapVertex(ar, head_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
|
|
|
|
retval |= snapVertex(ar, tail_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
2009-02-25 20:07:45 +00:00
|
|
|
break;
|
|
|
|
|
case SCE_SNAP_MODE_EDGE:
|
2013-04-03 07:36:37 +00:00
|
|
|
retval |= snapEdge(ar, head_vec, NULL, tail_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
2009-02-25 20:07:45 +00:00
|
|
|
break;
|
2009-02-24 21:25:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-16 19:58:29 +01:00
|
|
|
static bool snapCurve(short snap_mode, ARegion *ar, Object *ob, Curve *cu, float obmat[4][4],
|
|
|
|
|
const float ray_start[3], const float ray_normal[3], const float mval[2],
|
|
|
|
|
float r_loc[3], float *UNUSED(r_no), float *r_dist_px, float *r_depth)
|
|
|
|
|
{
|
|
|
|
|
float imat[4][4];
|
|
|
|
|
float ray_start_local[3], ray_normal_local[3];
|
|
|
|
|
bool retval = false;
|
|
|
|
|
int u;
|
|
|
|
|
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
|
|
|
|
|
/* only vertex snapping mode (eg control points and handles) supported for now) */
|
|
|
|
|
if (snap_mode != SCE_SNAP_MODE_VERTEX) {
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
invert_m4_m4(imat, obmat);
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(ray_start_local, ray_start);
|
|
|
|
|
copy_v3_v3(ray_normal_local, ray_normal);
|
|
|
|
|
|
|
|
|
|
mul_m4_v3(imat, ray_start_local);
|
|
|
|
|
mul_mat3_m4_v3(imat, ray_normal_local);
|
|
|
|
|
|
|
|
|
|
for (nu = (ob->mode == OB_MODE_EDIT ? cu->editnurb->nurbs.first : cu->nurb.first); nu; nu = nu->next) {
|
2013-11-17 22:00:57 +11:00
|
|
|
for (u = 0; u < nu->pntsu; u++) {
|
2013-11-16 19:58:29 +01:00
|
|
|
switch (snap_mode) {
|
|
|
|
|
case SCE_SNAP_MODE_VERTEX:
|
|
|
|
|
{
|
|
|
|
|
if (ob->mode == OB_MODE_EDIT) {
|
2013-11-21 00:21:31 +11:00
|
|
|
if (nu->bezt) {
|
|
|
|
|
/* don't snap to selected (moving) or hidden */
|
|
|
|
|
if (nu->bezt[u].f2 & SELECT || nu->bezt[u].hide != 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
retval |= snapVertex(ar, nu->bezt[u].vec[1], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
|
|
|
|
/* don't snap if handle is selected (moving), or if it is aligning to a moving handle */
|
|
|
|
|
if (!(nu->bezt[u].f1 & SELECT) && !(nu->bezt[u].h1 & HD_ALIGN && nu->bezt[u].f3 & SELECT)) {
|
|
|
|
|
retval |= snapVertex(ar, nu->bezt[u].vec[0], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
|
|
|
|
}
|
|
|
|
|
if (!(nu->bezt[u].f3 & SELECT) && !(nu->bezt[u].h2 & HD_ALIGN && nu->bezt[u].f1 & SELECT)) {
|
|
|
|
|
retval |= snapVertex(ar, nu->bezt[u].vec[2], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
|
|
|
|
}
|
2013-11-16 19:58:29 +01:00
|
|
|
}
|
2013-11-21 00:21:31 +11:00
|
|
|
else {
|
|
|
|
|
/* don't snap to selected (moving) or hidden */
|
|
|
|
|
if (nu->bp[u].f1 & SELECT || nu->bp[u].hide != 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
retval |= snapVertex(ar, nu->bp[u].vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
2013-11-16 19:58:29 +01:00
|
|
|
}
|
2013-11-17 22:00:57 +11:00
|
|
|
}
|
|
|
|
|
else {
|
2013-11-16 19:58:29 +01:00
|
|
|
/* curve is not visible outside editmode if nurb length less than two */
|
|
|
|
|
if (nu->pntsu > 1) {
|
2013-11-21 00:21:31 +11:00
|
|
|
if (nu->bezt) {
|
|
|
|
|
retval |= snapVertex(ar, nu->bezt[u].vec[1], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
retval |= snapVertex(ar, nu->bp[u].vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
|
|
|
|
}
|
2013-11-16 19:58:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-08 18:28:26 +00:00
|
|
|
static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, BMEditMesh *em, float obmat[4][4],
|
2014-01-29 20:10:03 +01:00
|
|
|
const float ray_start[3], const float ray_normal[3], const float ray_origin[3],
|
2014-06-18 18:20:55 +03:00
|
|
|
const float mval[2], float r_loc[3], float r_no[3], float *r_dist_px, float *r_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
|
|
|
{
|
2013-03-08 18:28:26 +00:00
|
|
|
bool retval = false;
|
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 totvert = dm->getNumVerts(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) {
|
2014-06-18 18:20:55 +03:00
|
|
|
BoundBox *bb;
|
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 imat[4][4];
|
|
|
|
|
float timat[3][3]; /* transpose inverse matrix for normals */
|
2014-01-30 18:48:49 +01:00
|
|
|
float ray_start_local[3], ray_normal_local[3], local_scale, len_diff = TRANSFORM_DIST_MAX_RAY;
|
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
|
|
|
invert_m4_m4(imat, obmat);
|
|
|
|
|
copy_m3_m4(timat, imat);
|
|
|
|
|
transpose_m3(timat);
|
2014-01-30 17:11:10 +01: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);
|
2014-01-30 17:11:10 +01:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(imat, ray_start_local);
|
|
|
|
|
mul_mat3_m4_v3(imat, ray_normal_local);
|
2014-01-29 20:10:03 +01:00
|
|
|
|
2014-01-30 18:48:49 +01:00
|
|
|
/* local scale in normal direction */
|
|
|
|
|
local_scale = normalize_v3(ray_normal_local);
|
|
|
|
|
|
2014-06-18 18:20:55 +03:00
|
|
|
bb = BKE_object_boundbox_get(ob);
|
|
|
|
|
if (!BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, &len_diff)) {
|
2014-01-29 20:10:03 +01:00
|
|
|
return retval;
|
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-12 11:45:29 +00:00
|
|
|
|
2014-01-29 20:10:03 +01:00
|
|
|
switch (snap_mode) {
|
|
|
|
|
case SCE_SNAP_MODE_FACE:
|
|
|
|
|
{
|
|
|
|
|
BVHTreeRayHit hit;
|
|
|
|
|
BVHTreeFromMesh treeData;
|
2009-11-12 11:45:29 +00:00
|
|
|
|
2014-01-30 17:11:10 +01:00
|
|
|
/* Only use closer ray_start in case of ortho view! In perspective one, ray_start may already
|
|
|
|
|
* been *inside* boundbox, leading to snap failures (see T38409).
|
2014-02-02 20:34:23 +01:00
|
|
|
* Note also ar might be null (see T38435), in this case we assume ray_start is ok!
|
2014-01-29 20:10:03 +01:00
|
|
|
*/
|
2014-02-02 20:34:23 +01:00
|
|
|
if (ar && !((RegionView3D *)ar->regiondata)->is_persp) {
|
2014-01-30 17:11:10 +01:00
|
|
|
float ray_org_local[3];
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(ray_org_local, ray_origin);
|
|
|
|
|
mul_m4_v3(imat, ray_org_local);
|
|
|
|
|
|
|
|
|
|
/* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with very far
|
|
|
|
|
* away ray_start values (as returned in case of ortho view3d), see T38358.
|
|
|
|
|
*/
|
|
|
|
|
len_diff -= local_scale; /* make temp start point a bit away from bbox hit point. */
|
|
|
|
|
madd_v3_v3v3fl(ray_start_local, ray_org_local, ray_normal_local,
|
2014-01-30 18:48:49 +01:00
|
|
|
len_diff - len_v3v3(ray_start_local, ray_org_local));
|
2014-01-30 17:11:10 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
len_diff = 0.0f;
|
|
|
|
|
}
|
2009-11-12 11:45:29 +00:00
|
|
|
|
2014-01-29 20:10:03 +01:00
|
|
|
treeData.em_evil = em;
|
|
|
|
|
bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6);
|
2009-11-12 11:45:29 +00:00
|
|
|
|
2014-01-29 20:10:03 +01:00
|
|
|
hit.index = -1;
|
2014-01-30 11:51:34 +01:00
|
|
|
hit.dist = *r_depth;
|
|
|
|
|
if (hit.dist != TRANSFORM_DIST_MAX_RAY) {
|
|
|
|
|
hit.dist *= local_scale;
|
|
|
|
|
hit.dist -= len_diff;
|
|
|
|
|
}
|
2009-11-12 11:45:29 +00:00
|
|
|
|
2014-01-29 20:10:03 +01:00
|
|
|
if (treeData.tree &&
|
2014-02-13 08:51:33 +11:00
|
|
|
BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f,
|
|
|
|
|
&hit, treeData.raycast_callback, &treeData) != -1)
|
2014-01-29 20:10:03 +01:00
|
|
|
{
|
|
|
|
|
hit.dist += len_diff;
|
|
|
|
|
hit.dist /= local_scale;
|
|
|
|
|
if (hit.dist <= *r_depth) {
|
|
|
|
|
*r_depth = hit.dist;
|
|
|
|
|
copy_v3_v3(r_loc, hit.co);
|
|
|
|
|
copy_v3_v3(r_no, hit.no);
|
|
|
|
|
|
|
|
|
|
/* back to worldspace */
|
|
|
|
|
mul_m4_v3(obmat, r_loc);
|
|
|
|
|
mul_m3_v3(timat, r_no);
|
|
|
|
|
normalize_v3(r_no);
|
|
|
|
|
|
|
|
|
|
retval = true;
|
2009-11-12 11:45:29 +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
|
|
|
}
|
2014-01-29 20:10:03 +01:00
|
|
|
free_bvhtree_from_mesh(&treeData);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SCE_SNAP_MODE_VERTEX:
|
|
|
|
|
{
|
|
|
|
|
MVert *verts = dm->getVertArray(dm);
|
2014-04-27 00:22:49 +10:00
|
|
|
const int *index_array = NULL;
|
2014-01-29 20:10:03 +01:00
|
|
|
int index = 0;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (em != NULL) {
|
|
|
|
|
index_array = dm->getVertDataArray(dm, CD_ORIGINDEX);
|
|
|
|
|
BM_mesh_elem_table_ensure(em->bm, BM_VERT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < totvert; i++) {
|
|
|
|
|
BMVert *eve = NULL;
|
|
|
|
|
MVert *v = verts + i;
|
|
|
|
|
bool test = true;
|
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (em != NULL) {
|
2014-01-29 20:10:03 +01:00
|
|
|
if (index_array) {
|
|
|
|
|
index = index_array[i];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
index = 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
|
|
|
|
2014-01-29 20:10:03 +01:00
|
|
|
if (index == ORIGINDEX_NONE) {
|
|
|
|
|
test = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
eve = BM_vert_at_index(em->bm, index);
|
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
|
|
|
|
2014-02-13 08:51:33 +11:00
|
|
|
if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN) ||
|
|
|
|
|
BM_elem_flag_test(eve, BM_ELEM_SELECT))
|
2014-01-29 20:10:03 +01:00
|
|
|
{
|
|
|
|
|
test = false;
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-29 20:10:03 +01:00
|
|
|
if (test) {
|
|
|
|
|
retval |= snapVertex(ar, v->co, v->no, obmat, timat, ray_start, ray_start_local,
|
|
|
|
|
ray_normal_local, mval, r_loc, r_no, r_dist_px, r_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
|
|
|
}
|
2014-01-29 20:10:03 +01:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SCE_SNAP_MODE_EDGE:
|
|
|
|
|
{
|
|
|
|
|
MVert *verts = dm->getVertArray(dm);
|
|
|
|
|
MEdge *edges = dm->getEdgeArray(dm);
|
|
|
|
|
int totedge = dm->getNumEdges(dm);
|
2014-04-27 00:22:49 +10:00
|
|
|
const int *index_array = NULL;
|
2014-01-29 20:10:03 +01:00
|
|
|
int index = 0;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (em != NULL) {
|
|
|
|
|
index_array = dm->getEdgeDataArray(dm, CD_ORIGINDEX);
|
|
|
|
|
BM_mesh_elem_table_ensure(em->bm, BM_EDGE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < totedge; i++) {
|
|
|
|
|
MEdge *e = edges + i;
|
|
|
|
|
bool test = true;
|
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (em != NULL) {
|
2014-01-29 20:10:03 +01:00
|
|
|
if (index_array) {
|
|
|
|
|
index = index_array[i];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
index = 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
|
|
|
}
|
2012-04-28 06:31:57 +00:00
|
|
|
|
2014-01-29 20:10:03 +01:00
|
|
|
if (index == ORIGINDEX_NONE) {
|
|
|
|
|
test = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BMEdge *eed = BM_edge_at_index(em->bm, index);
|
|
|
|
|
|
2014-02-13 08:51:33 +11:00
|
|
|
if (BM_elem_flag_test(eed, BM_ELEM_HIDDEN) ||
|
|
|
|
|
BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
|
|
|
|
|
BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))
|
2014-01-29 20:10:03 +01:00
|
|
|
{
|
|
|
|
|
test = false;
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-29 20:10:03 +01:00
|
|
|
if (test) {
|
|
|
|
|
retval |= snapEdge(ar, verts[e->v1].co, verts[e->v1].no, verts[e->v2].co, verts[e->v2].no,
|
|
|
|
|
obmat, timat, ray_start, ray_start_local, ray_normal_local, mval,
|
|
|
|
|
r_loc, r_no, r_dist_px, r_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
|
|
|
}
|
2014-01-29 20:10:03 +01:00
|
|
|
|
|
|
|
|
break;
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-19 04:22:05 +00:00
|
|
|
/* may extend later (for now just snaps to empty center) */
|
|
|
|
|
static bool snapEmpty(short snap_mode, ARegion *ar, Object *ob, float obmat[4][4],
|
|
|
|
|
const float ray_start[3], const float ray_normal[3], const float mval[2],
|
|
|
|
|
float r_loc[3], float *UNUSED(r_no), float *r_dist_px, float *r_depth)
|
|
|
|
|
{
|
|
|
|
|
float imat[4][4];
|
|
|
|
|
float ray_start_local[3], ray_normal_local[3];
|
|
|
|
|
bool retval = false;
|
|
|
|
|
|
2013-08-19 04:23:54 +00:00
|
|
|
if (ob->transflag & OB_DUPLI) {
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
/* for now only vertex supported */
|
|
|
|
|
if (snap_mode != SCE_SNAP_MODE_VERTEX) {
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-19 04:22:05 +00:00
|
|
|
invert_m4_m4(imat, obmat);
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(ray_start_local, ray_start);
|
|
|
|
|
copy_v3_v3(ray_normal_local, ray_normal);
|
|
|
|
|
|
|
|
|
|
mul_m4_v3(imat, ray_start_local);
|
|
|
|
|
mul_mat3_m4_v3(imat, ray_normal_local);
|
|
|
|
|
|
|
|
|
|
switch (snap_mode) {
|
|
|
|
|
case SCE_SNAP_MODE_VERTEX:
|
|
|
|
|
{
|
|
|
|
|
const float zero_co[3] = {0.0f};
|
|
|
|
|
retval |= snapVertex(ar, zero_co, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-09 11:37:37 +00:00
|
|
|
static bool snapCamera(short snap_mode, ARegion *ar, Scene *scene, Object *object, float obmat[4][4],
|
|
|
|
|
const float ray_start[3], const float ray_normal[3], const float mval[2],
|
|
|
|
|
float r_loc[3], float *UNUSED(r_no), float *r_dist_px, float *r_depth)
|
|
|
|
|
{
|
|
|
|
|
float orig_camera_mat[4][4], orig_camera_imat[4][4], imat[4][4];
|
|
|
|
|
bool retval = false;
|
|
|
|
|
MovieClip *clip = BKE_object_movieclip_get(scene, object, false);
|
|
|
|
|
MovieTracking *tracking;
|
|
|
|
|
float ray_start_local[3], ray_normal_local[3];
|
|
|
|
|
|
|
|
|
|
if (clip == NULL) {
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
if (object->transflag & OB_DUPLI) {
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tracking = &clip->tracking;
|
|
|
|
|
|
|
|
|
|
BKE_tracking_get_camera_object_matrix(scene, object, orig_camera_mat);
|
|
|
|
|
|
|
|
|
|
invert_m4_m4(orig_camera_imat, orig_camera_mat);
|
|
|
|
|
invert_m4_m4(imat, obmat);
|
|
|
|
|
|
|
|
|
|
switch (snap_mode) {
|
|
|
|
|
case SCE_SNAP_MODE_VERTEX:
|
|
|
|
|
{
|
|
|
|
|
MovieTrackingObject *tracking_object;
|
|
|
|
|
|
|
|
|
|
for (tracking_object = tracking->objects.first;
|
|
|
|
|
tracking_object;
|
|
|
|
|
tracking_object = tracking_object->next)
|
|
|
|
|
{
|
|
|
|
|
ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
|
|
|
|
|
MovieTrackingTrack *track;
|
|
|
|
|
float reconstructed_camera_mat[4][4],
|
|
|
|
|
reconstructed_camera_imat[4][4];
|
|
|
|
|
float (*vertex_obmat)[4];
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(ray_start_local, ray_start);
|
|
|
|
|
copy_v3_v3(ray_normal_local, ray_normal);
|
|
|
|
|
|
|
|
|
|
if ((tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0) {
|
|
|
|
|
BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object,
|
|
|
|
|
CFRA, reconstructed_camera_mat);
|
|
|
|
|
|
|
|
|
|
invert_m4_m4(reconstructed_camera_imat, reconstructed_camera_mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (track = tracksbase->first; track; track = track->next) {
|
|
|
|
|
float bundle_pos[3];
|
|
|
|
|
|
|
|
|
|
if ((track->flag & TRACK_HAS_BUNDLE) == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(bundle_pos, track->bundle_pos);
|
|
|
|
|
if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
|
|
|
|
|
mul_m4_v3(orig_camera_imat, ray_start_local);
|
|
|
|
|
mul_mat3_m4_v3(orig_camera_imat, ray_normal_local);
|
|
|
|
|
vertex_obmat = orig_camera_mat;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
mul_m4_v3(reconstructed_camera_imat, bundle_pos);
|
|
|
|
|
mul_m4_v3(imat, ray_start_local);
|
|
|
|
|
mul_mat3_m4_v3(imat, ray_normal_local);
|
|
|
|
|
vertex_obmat = obmat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval |= snapVertex(ar, bundle_pos, NULL, vertex_obmat, NULL,
|
|
|
|
|
ray_start, ray_start_local, ray_normal_local, mval,
|
|
|
|
|
r_loc, NULL, r_dist_px, r_depth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 17:49:13 +00:00
|
|
|
static bool snapObject(Scene *scene, short snap_mode, ARegion *ar, Object *ob, float obmat[4][4], bool use_obedit,
|
|
|
|
|
Object **r_ob, float r_obmat[4][4],
|
2014-01-29 20:10:03 +01:00
|
|
|
const float ray_start[3], const float ray_normal[3], const float ray_origin[3],
|
2014-06-18 18:20:55 +03:00
|
|
|
const float mval[2], float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth)
|
2009-02-25 20:07:45 +00:00
|
|
|
{
|
2013-03-08 18:28:26 +00:00
|
|
|
bool retval = false;
|
2009-02-25 20:07:45 +00:00
|
|
|
|
|
|
|
|
if (ob->type == OB_MESH) {
|
2009-05-18 08:46:04 +00:00
|
|
|
BMEditMesh *em;
|
2009-02-25 20:07:45 +00:00
|
|
|
DerivedMesh *dm;
|
|
|
|
|
|
2013-04-24 17:49:13 +00:00
|
|
|
if (use_obedit) {
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(ob);
|
2013-04-23 23:57:27 +00:00
|
|
|
dm = editbmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH);
|
2009-02-25 20:07:45 +00:00
|
|
|
}
|
2012-03-06 18:40:15 +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
|
|
|
}
|
|
|
|
|
|
2014-06-18 18:20:55 +03:00
|
|
|
retval = snapDerivedMesh(snap_mode, ar, ob, dm, em, obmat, ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_depth);
|
2009-02-25 20:07:45 +00:00
|
|
|
|
|
|
|
|
dm->release(dm);
|
|
|
|
|
}
|
2012-03-07 04:53:43 +00:00
|
|
|
else if (ob->type == OB_ARMATURE) {
|
2013-04-03 09:48:21 +00:00
|
|
|
retval = snapArmature(snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
|
2009-02-25 20:07:45 +00:00
|
|
|
}
|
2013-11-16 19:58:29 +01:00
|
|
|
else if (ob->type == OB_CURVE) {
|
|
|
|
|
retval = snapCurve(snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
|
|
|
|
|
}
|
2013-08-19 04:22:05 +00:00
|
|
|
else if (ob->type == OB_EMPTY) {
|
|
|
|
|
retval = snapEmpty(snap_mode, ar, ob, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
|
2013-09-10 01:00:03 +00:00
|
|
|
}
|
|
|
|
|
else if (ob->type == OB_CAMERA) {
|
2013-09-09 11:37:37 +00:00
|
|
|
retval = snapCamera(snap_mode, ar, scene, ob, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
|
2013-08-19 04:22:05 +00:00
|
|
|
}
|
2009-02-25 20:07:45 +00:00
|
|
|
|
2013-04-24 17:49:13 +00:00
|
|
|
if (retval) {
|
|
|
|
|
if (r_ob) {
|
|
|
|
|
*r_ob = ob;
|
|
|
|
|
copy_m4_m4(r_obmat, obmat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-25 20:07:45 +00:00
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-03 09:48:21 +00:00
|
|
|
static bool snapObjectsRay(Scene *scene, short snap_mode, Base *base_act, View3D *v3d, ARegion *ar, Object *obedit,
|
2013-04-24 17:49:13 +00:00
|
|
|
Object **r_ob, float r_obmat[4][4],
|
2014-01-29 20:10:03 +01:00
|
|
|
const float ray_start[3], const float ray_normal[3], const float ray_origin[3],
|
|
|
|
|
float *r_ray_dist,
|
2014-06-18 18:20:55 +03:00
|
|
|
const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode)
|
2011-09-28 05:53: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
|
|
|
Base *base;
|
2013-03-08 18:28:26 +00:00
|
|
|
bool retval = false;
|
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
|
|
|
|
2012-03-07 04:53:43 +00:00
|
|
|
if (mode == SNAP_ALL && obedit) {
|
2009-03-20 18:00:51 +00:00
|
|
|
Object *ob = obedit;
|
2009-11-01 00:06:53 +00:00
|
|
|
|
2013-04-24 17:49:13 +00:00
|
|
|
retval |= snapObject(scene, snap_mode, ar, ob, ob->obmat, true,
|
|
|
|
|
r_ob, r_obmat,
|
2014-06-18 18:20:55 +03:00
|
|
|
ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_ray_dist);
|
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-11-01 00:06:53 +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.
|
|
|
|
|
* */
|
2013-04-03 09:48:21 +00:00
|
|
|
base = base_act;
|
2012-03-07 04:53:43 +00:00
|
|
|
if (base && base->object && base->object->mode & OB_MODE_PARTICLE_EDIT) {
|
2010-01-20 17:02:24 +00:00
|
|
|
Object *ob = base->object;
|
2013-04-24 17:49:13 +00:00
|
|
|
retval |= snapObject(scene, snap_mode, ar, ob, ob->obmat, false,
|
|
|
|
|
r_ob, r_obmat,
|
2014-06-18 18:20:55 +03:00
|
|
|
ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_ray_dist);
|
2009-11-01 00:06:53 +00:00
|
|
|
}
|
2011-01-13 04:53:55 +00:00
|
|
|
|
2012-06-10 22:13:17 +00:00
|
|
|
for (base = FIRSTBASE; base != NULL; base = base->next) {
|
2013-04-11 09:57:26 +00:00
|
|
|
if ((BASE_VISIBLE_BGMODE(v3d, scene, base)) &&
|
2012-06-10 22:13:17 +00:00
|
|
|
(base->flag & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&
|
2011-12-22 00:03:20 +00:00
|
|
|
|
2012-06-10 22:13:17 +00:00
|
|
|
((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL)) == 0) ||
|
2013-04-03 09:48:21 +00:00
|
|
|
(ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != base_act)))
|
2011-12-22 00:03:20 +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
|
|
|
Object *ob = base->object;
|
|
|
|
|
|
2012-03-07 04:53:43 +00:00
|
|
|
if (ob->transflag & OB_DUPLI) {
|
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
|
|
|
DupliObject *dupli_ob;
|
2013-12-26 17:24:42 +06:00
|
|
|
ListBase *lb = object_duplilist(G.main->eval_ctx, 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
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {
|
2013-04-24 17:49:13 +00:00
|
|
|
retval |= snapObject(scene, snap_mode, ar, dupli_ob->ob, dupli_ob->mat, false,
|
|
|
|
|
r_ob, r_obmat,
|
2014-06-18 18:20:55 +03:00
|
|
|
ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_ray_dist);
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 17:49:13 +00:00
|
|
|
retval |= snapObject(scene, snap_mode, ar, ob, ob->obmat, false,
|
|
|
|
|
r_ob, r_obmat,
|
2014-06-18 18:20:55 +03:00
|
|
|
ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_ray_dist);
|
2007-02-28 17:16:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
2013-04-03 09:48:21 +00:00
|
|
|
static bool snapObjects(Scene *scene, short snap_mode, Base *base_act, View3D *v3d, ARegion *ar, Object *obedit,
|
2013-04-25 09:39:03 +00:00
|
|
|
const float mval[2], float *r_dist_px,
|
2014-06-18 18:20:55 +03:00
|
|
|
float r_loc[3], float r_no[3], float *r_ray_dist, SnapMode mode)
|
2013-04-03 09:48:21 +00:00
|
|
|
{
|
2014-01-29 20:10:03 +01:00
|
|
|
float ray_start[3], ray_normal[3], ray_orgigin[3];
|
2013-04-03 09:48:21 +00:00
|
|
|
|
2014-01-29 20:10:03 +01:00
|
|
|
if (!ED_view3d_win_to_ray_ex(ar, v3d, mval, ray_orgigin, ray_normal, ray_start, true)) {
|
2013-04-22 20:00:37 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2013-04-03 09:48:21 +00:00
|
|
|
|
|
|
|
|
return snapObjectsRay(scene, snap_mode, base_act, v3d, ar, obedit,
|
2013-04-24 17:49:13 +00:00
|
|
|
NULL, NULL,
|
2014-01-29 20:10:03 +01:00
|
|
|
ray_start, ray_normal, ray_orgigin, r_ray_dist,
|
2014-06-18 18:20:55 +03:00
|
|
|
mval, r_dist_px, r_loc, r_no, mode);
|
2013-04-03 09:48:21 +00:00
|
|
|
}
|
2006-10-25 23:57:00 +00:00
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
bool snapObjectsTransform(TransInfo *t, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode)
|
2009-03-20 18:00:51 +00:00
|
|
|
{
|
2013-04-25 09:39:03 +00:00
|
|
|
float ray_dist = TRANSFORM_DIST_MAX_RAY;
|
2013-04-03 09:48:21 +00:00
|
|
|
return snapObjects(t->scene, t->scene->toolsettings->snap_mode, t->scene->basact, t->view, t->ar, t->obedit,
|
2014-06-18 18:20:55 +03:00
|
|
|
mval, r_dist_px, r_loc, r_no, &ray_dist, mode);
|
2009-03-20 18:00:51 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-18 18:20:55 +03:00
|
|
|
bool snapObjectsContext(bContext *C, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode)
|
2009-03-20 18:00:51 +00:00
|
|
|
{
|
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
|
View3D *v3d = sa->spacedata.first;
|
2013-04-03 09:48:21 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2013-04-24 17:49:13 +00:00
|
|
|
ARegion *ar = CTX_wm_region(C);
|
|
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2013-04-25 09:39:03 +00:00
|
|
|
float ray_dist = TRANSFORM_DIST_MAX_RAY;
|
2013-04-03 09:48:21 +00:00
|
|
|
|
2013-04-25 09:39:03 +00:00
|
|
|
return snapObjects(scene, scene->toolsettings->snap_mode, scene->basact, v3d, ar, obedit,
|
2014-06-18 18:20:55 +03:00
|
|
|
mval, r_dist_px, r_loc, r_no, &ray_dist, mode);
|
2013-04-03 09:48:21 +00:00
|
|
|
}
|
2009-03-20 18:00:51 +00:00
|
|
|
|
2013-04-03 09:48:21 +00:00
|
|
|
bool snapObjectsEx(Scene *scene, Base *base_act, View3D *v3d, ARegion *ar, Object *obedit, short snap_mode,
|
2013-04-25 09:39:03 +00:00
|
|
|
const float mval[2], float *r_dist_px,
|
2014-06-18 18:20:55 +03:00
|
|
|
float r_loc[3], float r_no[3], float *r_ray_dist, SnapMode mode)
|
2013-04-03 09:48:21 +00:00
|
|
|
{
|
|
|
|
|
return snapObjects(scene, snap_mode, base_act, v3d, ar, obedit,
|
2013-04-25 09:39:03 +00:00
|
|
|
mval, r_dist_px,
|
2014-06-18 18:20:55 +03:00
|
|
|
r_loc, r_no, r_ray_dist, mode);
|
2013-04-03 09:48:21 +00:00
|
|
|
}
|
|
|
|
|
bool snapObjectsRayEx(Scene *scene, Base *base_act, View3D *v3d, ARegion *ar, Object *obedit, short snap_mode,
|
2013-04-24 17:49:13 +00:00
|
|
|
Object **r_ob, float r_obmat[4][4],
|
2013-04-14 05:37:43 +00:00
|
|
|
const float ray_start[3], const float ray_normal[3], float *r_ray_dist,
|
2014-06-18 18:20:55 +03:00
|
|
|
const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode)
|
2013-04-03 09:48:21 +00:00
|
|
|
{
|
|
|
|
|
return snapObjectsRay(scene, snap_mode, base_act, v3d, ar, obedit,
|
2013-04-24 17:49:13 +00:00
|
|
|
r_ob, r_obmat,
|
2014-01-29 20:10:03 +01:00
|
|
|
ray_start, ray_normal, ray_start, r_ray_dist,
|
2014-06-18 18:20:55 +03:00
|
|
|
mval, r_dist_px, r_loc, r_no, mode);
|
2009-03-20 18:00:51 +00:00
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
2012-03-07 04:53:43 +00:00
|
|
|
if (p1->depth < p2->depth) {
|
2009-02-24 00:45:40 +00:00
|
|
|
val = -1;
|
|
|
|
|
}
|
2012-03-07 04:53:43 +00:00
|
|
|
else if (p1->depth > p2->depth) {
|
2009-02-24 00:45:40 +00:00
|
|
|
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;
|
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
for (peel = depth_peels->first; peel; peel = peel->next) {
|
2009-02-24 00:45:40 +00:00
|
|
|
DepthPeel *next_peel = peel->next;
|
2012-03-07 04:53:43 +00:00
|
|
|
|
2013-12-01 13:11:12 +11:00
|
|
|
if (next_peel && fabsf(peel->depth - next_peel->depth) < 0.0015f) {
|
2009-02-24 00:45:40 +00:00
|
|
|
peel->next = next_peel->next;
|
|
|
|
|
|
2012-03-07 04:53:43 +00:00
|
|
|
if (next_peel->next) {
|
2009-02-24 00:45:40 +00:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-08 18:28:26 +00:00
|
|
|
static bool peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[4][4],
|
|
|
|
|
const float ray_start[3], const float ray_normal[3], const float UNUSED(mval[2]),
|
|
|
|
|
ListBase *depth_peels)
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
2013-03-08 18:28:26 +00:00
|
|
|
bool retval = false;
|
2009-02-24 00:45:40 +00:00
|
|
|
int totvert = dm->getNumVerts(dm);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
int totface = dm->getNumTessFaces(dm);
|
2009-02-24 00:45:40 +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);
|
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) {
|
2012-05-05 14:03:12 +00:00
|
|
|
struct BoundBox *bb = BKE_object_boundbox_get(ob);
|
2014-01-29 20:10:03 +01:00
|
|
|
test = BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, NULL);
|
2009-02-24 00:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (test == 1) {
|
|
|
|
|
MVert *verts = dm->getVertArray(dm);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
MFace *faces = dm->getTessFaceArray(dm);
|
2009-02-24 00:45:40 +00:00
|
|
|
int i;
|
|
|
|
|
|
2012-06-10 22:13:17 +00:00
|
|
|
for (i = 0; i < totface; i++) {
|
2009-02-24 00:45:40 +00:00
|
|
|
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)
|
2012-04-29 15:47:02 +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
|
2012-04-29 15:47:02 +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
|
|
|
|
2012-10-21 05:46:41 +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);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-07 04:53:43 +00:00
|
|
|
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)
|
2012-04-29 15:47:02 +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
|
2012-04-29 15:47:02 +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
|
|
|
|
2012-04-29 15:47:02 +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);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-08 18:28:26 +00:00
|
|
|
static bool peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit,
|
|
|
|
|
ListBase *depth_peels, const float mval[2], SnapMode mode)
|
2009-02-24 00:45:40 +00:00
|
|
|
{
|
|
|
|
|
Base *base;
|
2013-03-08 18:28:26 +00:00
|
|
|
bool retval = false;
|
2009-02-24 00:45:40 +00:00
|
|
|
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
|
|
|
|
2013-04-22 20:00:37 +00:00
|
|
|
if (ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal, true) == false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2012-03-07 04:53:43 +00:00
|
|
|
for (base = scene->base.first; base != NULL; base = base->next) {
|
2012-04-16 10:09:26 +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;
|
2012-04-16 10:09:26 +00:00
|
|
|
|
2012-03-07 04:53:43 +00:00
|
|
|
if (ob->transflag & OB_DUPLI) {
|
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
|
|
|
DupliObject *dupli_ob;
|
2013-12-26 17:24:42 +06:00
|
|
|
ListBase *lb = object_duplilist(G.main->eval_ctx, 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
|
|
|
|
2012-04-28 06:31:57 +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) {
|
2012-04-16 10:09:26 +00:00
|
|
|
BMEditMesh *em;
|
2009-05-23 03:24:15 +00:00
|
|
|
DerivedMesh *dm = NULL;
|
2013-03-08 18:28:26 +00:00
|
|
|
bool val;
|
2009-05-23 03:24:15 +00:00
|
|
|
|
2012-03-06 18:40:15 +00:00
|
|
|
if (dob != obedit) {
|
2010-12-03 12:30:59 +00:00
|
|
|
dm = mesh_get_derived_final(scene, dob, CD_MASK_BAREMESH);
|
2009-05-23 03:24:15 +00:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
val = peelDerivedMesh(dob, dm, dob->obmat, ray_start, ray_normal, mval, depth_peels);
|
2009-05-23 03:24:15 +00:00
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
else {
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(dob);
|
2012-04-16 10:09:26 +00:00
|
|
|
dm = editbmesh_get_derived_cage(scene, obedit, em, CD_MASK_BAREMESH);
|
2009-05-23 03:24:15 +00:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
val = peelDerivedMesh(dob, dm, dob->obmat, ray_start, ray_normal, mval, depth_peels);
|
2009-05-23 03:24:15 +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-05-23 03:24:15 +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) {
|
2013-03-08 18:28:26 +00:00
|
|
|
bool val = false;
|
2009-02-24 00:45:40 +00:00
|
|
|
|
2012-06-10 22:13:17 +00:00
|
|
|
if (ob != obedit && ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL)) == 0) || ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT))) {
|
2012-03-10 21:40:35 +00:00
|
|
|
DerivedMesh *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);
|
2012-03-10 21:40:35 +00:00
|
|
|
dm->release(dm);
|
2009-02-24 00:45:40 +00:00
|
|
|
}
|
2012-03-10 21:40:35 +00:00
|
|
|
else if (ob == obedit && mode != SNAP_NOT_OBEDIT) {
|
2013-04-16 05:59:48 +00:00
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(ob);
|
2012-03-10 21:40:35 +00:00
|
|
|
DerivedMesh *dm = editbmesh_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);
|
2012-03-10 21:40:35 +00:00
|
|
|
dm->release(dm);
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-08 18:28:26 +00:00
|
|
|
bool peelObjectsTransForm(TransInfo *t, ListBase *depth_peels, const float mval[2], SnapMode mode)
|
2009-03-20 18:00:51 +00:00
|
|
|
{
|
2012-03-10 21:40:35 +00:00
|
|
|
return peelObjects(t->scene, t->view, t->ar, t->obedit, depth_peels, mval, mode);
|
2009-03-20 18:00:51 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-08 18:28:26 +00:00
|
|
|
bool peelObjectsContext(bContext *C, ListBase *depth_peels, const float mval[2], SnapMode mode)
|
2009-03-20 18:00:51 +00:00
|
|
|
{
|
2013-04-24 17:49:13 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2009-03-20 18:00:51 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
|
View3D *v3d = sa->spacedata.first;
|
2013-04-24 17:49:13 +00:00
|
|
|
ARegion *ar = CTX_wm_region(C);
|
|
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2009-03-20 18:00:51 +00:00
|
|
|
|
2013-04-24 17:49:13 +00:00
|
|
|
return peelObjects(scene, v3d, ar, obedit, depth_peels, mval, mode);
|
2009-03-20 18:00:51 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-29 14:34:46 +00:00
|
|
|
/******************** NODES ***********************************/
|
|
|
|
|
|
2013-03-08 18:28:26 +00:00
|
|
|
static bool snapNodeTest(View2D *v2d, bNode *node, SnapMode mode)
|
2012-06-29 14:34:46 +00:00
|
|
|
{
|
|
|
|
|
/* node is use for snapping only if a) snap mode matches and b) node is inside the view */
|
|
|
|
|
return ((mode == SNAP_NOT_SELECTED && !(node->flag & NODE_SELECT)) ||
|
|
|
|
|
(mode == SNAP_ALL && !(node->flag & NODE_ACTIVE))) &&
|
|
|
|
|
(node->totr.xmin < v2d->cur.xmax && node->totr.xmax > v2d->cur.xmin &&
|
|
|
|
|
node->totr.ymin < v2d->cur.ymax && node->totr.ymax > v2d->cur.ymin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NodeBorder snapNodeBorder(int snap_node_mode)
|
|
|
|
|
{
|
|
|
|
|
switch (snap_node_mode) {
|
|
|
|
|
case SCE_SNAP_MODE_NODE_X:
|
|
|
|
|
return NODE_LEFT | NODE_RIGHT;
|
|
|
|
|
case SCE_SNAP_MODE_NODE_Y:
|
|
|
|
|
return NODE_TOP | NODE_BOTTOM;
|
|
|
|
|
case SCE_SNAP_MODE_NODE_XY:
|
|
|
|
|
return NODE_LEFT | NODE_RIGHT | NODE_TOP | NODE_BOTTOM;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-08 18:28:26 +00:00
|
|
|
static bool snapNode(ToolSettings *ts, SpaceNode *UNUSED(snode), ARegion *ar, bNode *node, const int mval[2],
|
2013-04-03 07:36:37 +00:00
|
|
|
float r_loc[2], float *r_dist_px, char *r_node_border)
|
2012-06-29 14:34:46 +00:00
|
|
|
{
|
|
|
|
|
View2D *v2d = &ar->v2d;
|
|
|
|
|
NodeBorder border = snapNodeBorder(ts->snap_node_mode);
|
2013-03-08 18:28:26 +00:00
|
|
|
bool retval = false;
|
2012-06-29 14:34:46 +00:00
|
|
|
rcti totr;
|
|
|
|
|
int new_dist;
|
|
|
|
|
|
2014-04-21 16:47:16 +10:00
|
|
|
UI_view2d_view_to_region_rcti(v2d, &node->totr, &totr);
|
2012-06-29 14:34:46 +00:00
|
|
|
|
|
|
|
|
if (border & NODE_LEFT) {
|
|
|
|
|
new_dist = abs(totr.xmin - mval[0]);
|
2013-04-03 07:36:37 +00:00
|
|
|
if (new_dist < *r_dist_px) {
|
2012-06-29 14:34:46 +00:00
|
|
|
UI_view2d_region_to_view(v2d, totr.xmin, mval[1], &r_loc[0], &r_loc[1]);
|
2013-04-03 07:36:37 +00:00
|
|
|
*r_dist_px = new_dist;
|
2012-06-29 14:34:46 +00:00
|
|
|
*r_node_border = NODE_LEFT;
|
2013-03-08 18:28:26 +00:00
|
|
|
retval = true;
|
2012-06-29 14:34:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (border & NODE_RIGHT) {
|
|
|
|
|
new_dist = abs(totr.xmax - mval[0]);
|
2013-04-03 07:36:37 +00:00
|
|
|
if (new_dist < *r_dist_px) {
|
2012-06-29 14:34:46 +00:00
|
|
|
UI_view2d_region_to_view(v2d, totr.xmax, mval[1], &r_loc[0], &r_loc[1]);
|
2013-04-03 07:36:37 +00:00
|
|
|
*r_dist_px = new_dist;
|
2012-06-29 14:34:46 +00:00
|
|
|
*r_node_border = NODE_RIGHT;
|
2013-03-08 18:28:26 +00:00
|
|
|
retval = true;
|
2012-06-29 14:34:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (border & NODE_BOTTOM) {
|
|
|
|
|
new_dist = abs(totr.ymin - mval[1]);
|
2013-04-03 07:36:37 +00:00
|
|
|
if (new_dist < *r_dist_px) {
|
2012-06-29 14:34:46 +00:00
|
|
|
UI_view2d_region_to_view(v2d, mval[0], totr.ymin, &r_loc[0], &r_loc[1]);
|
2013-04-03 07:36:37 +00:00
|
|
|
*r_dist_px = new_dist;
|
2012-06-29 14:34:46 +00:00
|
|
|
*r_node_border = NODE_BOTTOM;
|
2013-03-08 18:28:26 +00:00
|
|
|
retval = true;
|
2012-06-29 14:34:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (border & NODE_TOP) {
|
|
|
|
|
new_dist = abs(totr.ymax - mval[1]);
|
2013-04-03 07:36:37 +00:00
|
|
|
if (new_dist < *r_dist_px) {
|
2012-06-29 14:34:46 +00:00
|
|
|
UI_view2d_region_to_view(v2d, mval[0], totr.ymax, &r_loc[0], &r_loc[1]);
|
2013-04-03 07:36:37 +00:00
|
|
|
*r_dist_px = new_dist;
|
2012-06-29 14:34:46 +00:00
|
|
|
*r_node_border = NODE_TOP;
|
2013-03-08 18:28:26 +00:00
|
|
|
retval = true;
|
2012-06-29 14:34:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-08 18:28:26 +00:00
|
|
|
static bool snapNodes(ToolSettings *ts, SpaceNode *snode, ARegion *ar, const int mval[2],
|
2013-04-03 07:36:37 +00:00
|
|
|
float *r_dist_px, float r_loc[2], char *r_node_border, SnapMode mode)
|
2012-06-29 14:34:46 +00:00
|
|
|
{
|
|
|
|
|
bNodeTree *ntree = snode->edittree;
|
|
|
|
|
bNode *node;
|
2013-03-08 18:28:26 +00:00
|
|
|
bool retval = false;
|
2012-06-29 14:34:46 +00:00
|
|
|
|
|
|
|
|
*r_node_border = 0;
|
|
|
|
|
|
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
|
if (snapNodeTest(&ar->v2d, node, mode))
|
2013-04-03 07:36:37 +00:00
|
|
|
retval |= snapNode(ts, snode, ar, node, mval, r_loc, r_dist_px, r_node_border);
|
2012-06-29 14:34:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
bool snapNodesTransform(TransInfo *t, const int mval[2], float *r_dist_px, float r_loc[2], char *r_node_border, SnapMode mode)
|
2012-06-29 14:34:46 +00:00
|
|
|
{
|
2013-04-03 07:36:37 +00:00
|
|
|
return snapNodes(t->settings, t->sa->spacedata.first, t->ar, mval, r_dist_px, r_loc, r_node_border, mode);
|
2012-06-29 14:34:46 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-03 07:36:37 +00:00
|
|
|
bool snapNodesContext(bContext *C, const int mval[2], float *r_dist_px, float r_loc[2], char *r_node_border, SnapMode mode)
|
2012-06-29 14:34:46 +00:00
|
|
|
{
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2013-04-24 17:49:13 +00:00
|
|
|
ARegion *ar = CTX_wm_region(C);
|
|
|
|
|
return snapNodes(scene->toolsettings, CTX_wm_space_node(C), ar, mval, r_dist_px, r_loc, r_node_border, mode);
|
2012-06-29 14:34: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
|
|
|
/*================================================================*/
|
|
|
|
|
|
2013-11-06 17:46:32 +00:00
|
|
|
static void applyGridIncrement(TransInfo *t, float *val, int max_index, float fac[3], GearsType action);
|
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
|
|
|
|
|
|
|
|
|
2013-11-06 17:46:32 +00:00
|
|
|
void snapGridIncrementAction(TransInfo *t, float *val, GearsType action)
|
2011-09-28 05:53: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
|
|
|
float fac[3];
|
|
|
|
|
|
|
|
|
|
fac[NO_GEARS] = t->snap[0];
|
|
|
|
|
fac[BIG_GEARS] = t->snap[1];
|
|
|
|
|
fac[SMALL_GEARS] = t->snap[2];
|
|
|
|
|
|
2013-11-06 17:46:32 +00:00
|
|
|
applyGridIncrement(t, val, t->idx_max, fac, action);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-11-06 17:46:32 +00:00
|
|
|
void snapGridIncrement(TransInfo *t, float *val)
|
2011-09-28 05:53: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
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-06 17:46:32 +00:00
|
|
|
snapGridIncrementAction(t, val, action);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-11-06 17:46:32 +00:00
|
|
|
static void applyGridIncrement(TransInfo *t, float *val, int max_index, float fac[3], GearsType action)
|
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 i;
|
|
|
|
|
float asp[3] = {1.0f, 1.0f, 1.0f}; // TODO: Remove hard coded limit here (3)
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (max_index > 2) {
|
2013-11-06 17:46:32 +00:00
|
|
|
printf("applyGridIncrement: invalid index %d, clamping\n", max_index);
|
2012-06-10 22:13:17 +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 */
|
2012-06-10 22:13:17 +00:00
|
|
|
if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
|
2012-08-03 22:33:45 +00:00
|
|
|
if (t->options & CTX_MASK) {
|
|
|
|
|
ED_space_image_get_aspect(t->sa->spacedata.first, asp, asp + 1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ED_space_image_get_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
|
|
|
}
|
|
|
|
|
|
2012-06-10 22:13:17 +00:00
|
|
|
for (i = 0; i <= max_index; i++) {
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|