2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-02-10 15:38:00 +00:00
|
|
|
* 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
|
2012-03-03 21:42:21 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2009-02-10 15:38:00 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2009-02-10 15:38:00 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup spview3d
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
2009-02-10 15:38:00 +00:00
|
|
|
#include <float.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <math.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2009-02-10 15:38:00 +00:00
|
|
|
|
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
#include "DNA_lattice_types.h"
|
2012-02-19 22:17:30 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2009-02-10 15:38:00 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_meta_types.h"
|
2009-02-10 15:38:00 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2012-03-03 21:42:21 +00:00
|
|
|
|
2009-02-10 15:38:00 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-02-10 15:38:00 +00:00
|
|
|
|
|
|
|
#include "BKE_action.h"
|
2020-10-02 15:36:42 +02:00
|
|
|
#include "BKE_armature.h"
|
2009-02-10 15:38:00 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_curve.h"
|
|
|
|
#include "BKE_customdata.h"
|
2010-01-25 23:12:02 +00:00
|
|
|
#include "BKE_deform.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_editmesh.h"
|
2011-12-16 10:39:43 +00:00
|
|
|
#include "BKE_object.h"
|
2014-11-18 23:52:17 +01:00
|
|
|
#include "BKE_object_deform.h"
|
2018-08-08 13:30:27 +10:00
|
|
|
#include "BKE_report.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_screen.h"
|
2009-02-10 15:38:00 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
2009-02-10 15:38:00 +00:00
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "ED_mesh.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_object.h"
|
2009-02-10 15:38:00 +00:00
|
|
|
#include "ED_screen.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
#include "view3d_intern.h" /* own include */
|
2009-02-10 15:38:00 +00:00
|
|
|
|
|
|
|
/* ******************* view3d space & buttons ************** */
|
2019-01-05 12:18:02 +11:00
|
|
|
enum {
|
|
|
|
B_REDR = 2,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN = 1008,
|
|
|
|
B_TRANSFORM_PANEL_DIMS = 1009,
|
|
|
|
};
|
2009-02-10 15:38:00 +00:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
/* All must start w/ location */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float location[3];
|
|
|
|
} TransformMedian_Generic;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float location[3], bv_weight, be_weight, skin[2], crease;
|
|
|
|
} TransformMedian_Mesh;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float location[3], weight, b_weight, radius, tilt;
|
|
|
|
} TransformMedian_Curve;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float location[3], weight;
|
|
|
|
} TransformMedian_Lattice;
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
TransformMedian_Generic generic;
|
|
|
|
TransformMedian_Mesh mesh;
|
|
|
|
TransformMedian_Curve curve;
|
|
|
|
TransformMedian_Lattice lattice;
|
|
|
|
} TransformMedian;
|
2012-10-09 09:14:37 +00:00
|
|
|
|
2009-02-10 15:38:00 +00:00
|
|
|
/* temporary struct for storing transform properties */
|
2019-01-05 12:18:02 +11:00
|
|
|
|
2009-02-10 15:38:00 +00:00
|
|
|
typedef struct {
|
2019-09-06 20:00:45 +10:00
|
|
|
float ob_obmat_orig[4][4];
|
2019-01-04 19:52:13 +11:00
|
|
|
float ob_dims_orig[3];
|
2019-09-06 20:00:45 +10:00
|
|
|
float ob_scale_orig[3];
|
2009-02-10 15:38:00 +00:00
|
|
|
float ob_dims[3];
|
2019-01-05 12:18:02 +11:00
|
|
|
/* Floats only (treated as an array). */
|
|
|
|
TransformMedian ve_median, median;
|
2009-02-10 15:38:00 +00:00
|
|
|
} TransformProperties;
|
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
#define TRANSFORM_MEDIAN_ARRAY_LEN (sizeof(TransformMedian) / sizeof(float))
|
|
|
|
|
2012-03-02 10:30:11 +00:00
|
|
|
/* Helper function to compute a median changed value,
|
|
|
|
* when the value should be clamped in [0.0, 1.0].
|
|
|
|
* Returns either 0.0, 1.0 (both can be applied directly), a positive scale factor
|
|
|
|
* for scale down, or a negative one for scale up.
|
|
|
|
*/
|
|
|
|
static float compute_scale_factor(const float ve_median, const float median)
|
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ve_median <= 0.0f) {
|
2012-03-02 10:30:11 +00:00
|
|
|
return 0.0f;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2020-07-03 17:18:56 +02:00
|
|
|
if (ve_median >= 1.0f) {
|
2012-03-02 10:30:11 +00:00
|
|
|
return 1.0f;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-03 17:18:56 +02:00
|
|
|
/* Scale value to target median. */
|
|
|
|
float median_new = ve_median;
|
|
|
|
float median_orig = ve_median - median; /* Previous median value. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-03 17:18:56 +02:00
|
|
|
/* In case of floating point error. */
|
|
|
|
CLAMP(median_orig, 0.0f, 1.0f);
|
|
|
|
CLAMP(median_new, 0.0f, 1.0f);
|
|
|
|
|
|
|
|
if (median_new <= median_orig) {
|
|
|
|
/* Scale down. */
|
|
|
|
return median_new / median_orig;
|
2012-03-02 10:30:11 +00:00
|
|
|
}
|
2020-07-03 17:18:56 +02:00
|
|
|
|
|
|
|
/* Scale up, negative to indicate it... */
|
|
|
|
return -(1.0f - median_new) / (1.0f - median_orig);
|
2012-03-02 10:30:11 +00:00
|
|
|
}
|
2009-02-10 15:38:00 +00:00
|
|
|
|
2019-04-22 00:18:34 +10:00
|
|
|
/**
|
|
|
|
* Apply helpers.
|
|
|
|
* \note In case we only have one element,
|
|
|
|
* copy directly the value instead of applying the diff or scale factor.
|
|
|
|
* Avoids some glitches when going e.g. from 3 to 0.0001 (see T37327).
|
2014-10-14 23:35:28 +02:00
|
|
|
*/
|
|
|
|
static void apply_raw_diff(float *val, const int tot, const float ve_median, const float median)
|
|
|
|
{
|
|
|
|
*val = (tot == 1) ? ve_median : (*val + median);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void apply_raw_diff_v3(float val[3],
|
|
|
|
const int tot,
|
|
|
|
const float ve_median[3],
|
|
|
|
const float median[3])
|
|
|
|
{
|
|
|
|
if (tot == 1) {
|
|
|
|
copy_v3_v3(val, ve_median);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
add_v3_v3(val, median);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void apply_scale_factor(
|
|
|
|
float *val, const int tot, const float ve_median, const float median, const float sca)
|
|
|
|
{
|
|
|
|
if (tot == 1 || ve_median == median) {
|
|
|
|
*val = ve_median;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*val *= sca;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void apply_scale_factor_clamp(float *val,
|
|
|
|
const int tot,
|
|
|
|
const float ve_median,
|
|
|
|
const float sca)
|
|
|
|
{
|
|
|
|
if (tot == 1) {
|
|
|
|
*val = ve_median;
|
|
|
|
CLAMP(*val, 0.0f, 1.0f);
|
|
|
|
}
|
|
|
|
else if (ELEM(sca, 0.0f, 1.0f)) {
|
|
|
|
*val = sca;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*val = (sca > 0.0f) ? (*val * sca) : (1.0f + ((1.0f - *val) * sca));
|
|
|
|
CLAMP(*val, 0.0f, 1.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-04 19:52:13 +11:00
|
|
|
static TransformProperties *v3d_transform_props_ensure(View3D *v3d)
|
|
|
|
{
|
2019-04-13 15:20:15 +02:00
|
|
|
if (v3d->runtime.properties_storage == NULL) {
|
|
|
|
v3d->runtime.properties_storage = MEM_callocN(sizeof(TransformProperties),
|
|
|
|
"TransformProperties");
|
2019-01-04 19:52:13 +11:00
|
|
|
}
|
2019-04-13 15:20:15 +02:00
|
|
|
return v3d->runtime.properties_storage;
|
2019-01-04 19:52:13 +11:00
|
|
|
}
|
|
|
|
|
2009-02-10 15:38:00 +00:00
|
|
|
/* is used for both read and write... */
|
2010-10-15 12:29:02 +00:00
|
|
|
static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float lim)
|
2009-02-10 15:38:00 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
uiBlock *block = (layout) ? uiLayoutAbsoluteBlock(layout) : NULL;
|
2019-01-04 19:52:13 +11:00
|
|
|
TransformProperties *tfp = v3d_transform_props_ensure(v3d);
|
2019-01-05 12:18:02 +11:00
|
|
|
TransformMedian median_basis, ve_median_basis;
|
2014-10-14 21:29:26 +02:00
|
|
|
int tot, totedgedata, totcurvedata, totlattdata, totcurvebweight;
|
2013-03-20 23:14:18 +00:00
|
|
|
bool has_meshdata = false;
|
2014-10-14 21:29:26 +02:00
|
|
|
bool has_skinradius = false;
|
2012-10-09 09:14:37 +00:00
|
|
|
PointerRNA data_ptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
copy_vn_fl((float *)&median_basis, TRANSFORM_MEDIAN_ARRAY_LEN, 0.0f);
|
2014-10-14 21:29:26 +02:00
|
|
|
tot = totedgedata = totcurvedata = totlattdata = totcurvebweight = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
if (ob->type == OB_MESH) {
|
2019-01-05 12:18:02 +11:00
|
|
|
TransformMedian_Mesh *median = &median_basis.mesh;
|
2012-03-03 21:42:21 +00:00
|
|
|
Mesh *me = ob->data;
|
2019-02-17 18:05:18 +11:00
|
|
|
BMEditMesh *em = me->edit_mesh;
|
2009-07-16 06:27:37 +00:00
|
|
|
BMesh *bm = em->bm;
|
2013-07-23 12:18:12 +00:00
|
|
|
BMVert *eve;
|
2009-05-23 03:24:15 +00:00
|
|
|
BMEdge *eed;
|
|
|
|
BMIter iter;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-10 04:43:31 +00:00
|
|
|
const int cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
|
2014-10-14 22:07:31 +02:00
|
|
|
const int cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN);
|
2013-01-10 04:43:31 +00:00
|
|
|
const int cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT);
|
|
|
|
const int cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-14 21:29:26 +02:00
|
|
|
has_skinradius = (cd_vert_skin_offset != -1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-10 14:38:30 +00:00
|
|
|
if (bm->totvertsel) {
|
|
|
|
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
|
|
|
|
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
|
|
|
|
tot++;
|
2019-01-05 12:18:02 +11:00
|
|
|
add_v3_v3(median->location, eve->co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-14 21:29:26 +02:00
|
|
|
if (cd_vert_bweight_offset != -1) {
|
2019-01-05 12:18:02 +11:00
|
|
|
median->bv_weight += BM_ELEM_CD_GET_FLOAT(eve, cd_vert_bweight_offset);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2014-10-14 21:29:26 +02:00
|
|
|
if (has_skinradius) {
|
2019-01-05 12:18:02 +11:00
|
|
|
MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(eve, cd_vert_skin_offset);
|
|
|
|
add_v2_v2(median->skin, vs->radius); /* Third val not used currently. */
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-10 14:38:30 +00:00
|
|
|
if ((cd_edge_bweight_offset != -1) || (cd_edge_crease_offset != -1)) {
|
|
|
|
if (bm->totedgesel) {
|
|
|
|
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
|
|
|
|
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
|
|
|
|
if (cd_edge_bweight_offset != -1) {
|
2019-01-05 12:18:02 +11:00
|
|
|
median->be_weight += BM_ELEM_CD_GET_FLOAT(eed, cd_edge_bweight_offset);
|
2014-10-14 21:29:26 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-14 22:07:31 +02:00
|
|
|
if (cd_edge_crease_offset != -1) {
|
2013-01-10 14:38:30 +00:00
|
|
|
median->crease += BM_ELEM_CD_GET_FLOAT(eed, cd_edge_crease_offset);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2013-01-10 14:38:30 +00:00
|
|
|
totedgedata++;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-10 14:38:30 +00:00
|
|
|
else {
|
2019-01-05 12:18:02 +11:00
|
|
|
totedgedata = bm->totedgesel;
|
2013-01-10 14:38:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-10 14:38:30 +00:00
|
|
|
has_meshdata = (tot || totedgedata);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-11-06 12:30:59 +11:00
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
2019-01-05 12:18:02 +11:00
|
|
|
TransformMedian_Curve *median = &median_basis.curve;
|
|
|
|
Curve *cu = ob->data;
|
2009-02-10 15:38:00 +00:00
|
|
|
BPoint *bp;
|
2019-01-05 12:18:02 +11:00
|
|
|
BezTriple *bezt;
|
2019-04-17 06:17:24 +02:00
|
|
|
int a;
|
2019-01-05 12:18:02 +11:00
|
|
|
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
|
2013-02-19 14:36:26 +00:00
|
|
|
StructRNA *seltype = NULL;
|
2012-03-03 21:42:21 +00:00
|
|
|
void *selp = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-24 23:32:11 -05:00
|
|
|
LISTBASE_FOREACH (Nurb *, nu, nurbs) {
|
2013-02-19 14:36:26 +00:00
|
|
|
if (nu->type == CU_BEZIER) {
|
|
|
|
bezt = nu->bezt;
|
2014-10-14 21:29:26 +02:00
|
|
|
a = nu->pntsu;
|
2012-02-22 16:52:06 +00:00
|
|
|
while (a--) {
|
|
|
|
if (bezt->f2 & SELECT) {
|
2014-10-14 21:29:26 +02:00
|
|
|
add_v3_v3(median->location, bezt->vec[1]);
|
|
|
|
tot++;
|
2019-01-05 12:18:02 +11:00
|
|
|
median->weight += bezt->weight;
|
|
|
|
median->radius += bezt->radius;
|
2019-03-04 01:14:27 +11:00
|
|
|
median->tilt += bezt->tilt;
|
2014-10-14 21:29:26 +02:00
|
|
|
if (!totcurvedata) { /* I.e. first time... */
|
2012-03-03 21:42:21 +00:00
|
|
|
selp = bezt;
|
|
|
|
seltype = &RNA_BezierSplinePoint;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-03-03 21:42:21 +00:00
|
|
|
totcurvedata++;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-03-03 21:42:21 +00:00
|
|
|
else {
|
|
|
|
if (bezt->f1 & SELECT) {
|
2019-01-05 12:18:02 +11:00
|
|
|
add_v3_v3(median->location, bezt->vec[0]);
|
|
|
|
tot++;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
if (bezt->f3 & SELECT) {
|
2019-01-05 12:18:02 +11:00
|
|
|
add_v3_v3(median->location, bezt->vec[2]);
|
2019-04-17 06:17:24 +02:00
|
|
|
tot++;
|
|
|
|
}
|
|
|
|
}
|
2012-03-03 21:42:21 +00:00
|
|
|
bezt++;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-03 21:42:21 +00:00
|
|
|
bp = nu->bp;
|
|
|
|
a = nu->pntsu * nu->pntsv;
|
2012-02-22 16:52:06 +00:00
|
|
|
while (a--) {
|
|
|
|
if (bp->f1 & SELECT) {
|
2019-01-05 12:18:02 +11:00
|
|
|
add_v3_v3(median->location, bp->vec);
|
|
|
|
median->b_weight += bp->vec[3];
|
2012-10-09 09:14:37 +00:00
|
|
|
totcurvebweight++;
|
2009-02-10 15:38:00 +00:00
|
|
|
tot++;
|
2019-01-05 12:18:02 +11:00
|
|
|
median->weight += bp->weight;
|
|
|
|
median->radius += bp->radius;
|
2019-03-04 01:14:27 +11:00
|
|
|
median->tilt += bp->tilt;
|
2012-10-09 09:14:37 +00:00
|
|
|
if (!totcurvedata) { /* I.e. first time... */
|
|
|
|
selp = bp;
|
|
|
|
seltype = &RNA_SplinePoint;
|
|
|
|
}
|
|
|
|
totcurvedata++;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
bp++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
if (totcurvedata == 1) {
|
2012-10-09 09:14:37 +00:00
|
|
|
RNA_pointer_create(&cu->id, seltype, selp, &data_ptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
|
|
|
else if (ob->type == OB_LATTICE) {
|
2012-03-03 21:42:21 +00:00
|
|
|
Lattice *lt = ob->data;
|
2019-01-05 12:18:02 +11:00
|
|
|
TransformMedian_Lattice *median = &median_basis.lattice;
|
2009-02-10 15:38:00 +00:00
|
|
|
BPoint *bp;
|
2019-04-17 06:17:24 +02:00
|
|
|
int a;
|
2012-10-09 09:14:37 +00:00
|
|
|
StructRNA *seltype = NULL;
|
|
|
|
void *selp = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
|
2012-03-03 21:42:21 +00:00
|
|
|
bp = lt->editlatt->latt->def;
|
2012-02-22 16:52:06 +00:00
|
|
|
while (a--) {
|
|
|
|
if (bp->f1 & SELECT) {
|
2019-01-05 12:18:02 +11:00
|
|
|
add_v3_v3(median->location, bp->vec);
|
2009-02-10 15:38:00 +00:00
|
|
|
tot++;
|
2019-01-05 12:18:02 +11:00
|
|
|
median->weight += bp->weight;
|
|
|
|
if (!totlattdata) { /* I.e. first time... */
|
|
|
|
selp = bp;
|
2012-10-09 09:14:37 +00:00
|
|
|
seltype = &RNA_LatticePoint;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-10-09 09:14:37 +00:00
|
|
|
totlattdata++;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-02-10 15:38:00 +00:00
|
|
|
bp++;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2009-02-10 15:38:00 +00:00
|
|
|
if (totlattdata == 1) {
|
2019-03-04 01:14:27 +11:00
|
|
|
RNA_pointer_create(<->id, seltype, selp, &data_ptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-09 09:14:37 +00:00
|
|
|
if (tot == 0) {
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block,
|
2019-01-04 19:52:13 +11:00
|
|
|
UI_BTYPE_LABEL,
|
2019-04-17 06:17:24 +02:00
|
|
|
0,
|
2012-10-09 09:14:37 +00:00
|
|
|
IFACE_("Nothing selected"),
|
2019-04-17 06:17:24 +02:00
|
|
|
0,
|
|
|
|
130,
|
|
|
|
200,
|
|
|
|
20,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
2012-10-09 09:14:37 +00:00
|
|
|
return;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2012-10-09 09:14:37 +00:00
|
|
|
/* Location, X/Y/Z */
|
2019-01-05 12:18:02 +11:00
|
|
|
mul_v3_fl(median_basis.generic.location, 1.0f / (float)tot);
|
2012-10-09 09:14:37 +00:00
|
|
|
if (v3d->flag & V3D_GLOBAL_STATS) {
|
2019-01-05 12:18:02 +11:00
|
|
|
mul_m4_v3(ob->obmat, median_basis.generic.location);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2012-10-09 09:14:37 +00:00
|
|
|
if (has_meshdata) {
|
|
|
|
TransformMedian_Mesh *median = &median_basis.mesh;
|
|
|
|
if (totedgedata) {
|
2009-02-10 15:38:00 +00:00
|
|
|
median->crease /= (float)totedgedata;
|
2019-01-05 12:18:02 +11:00
|
|
|
median->be_weight /= (float)totedgedata;
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2012-10-09 09:14:37 +00:00
|
|
|
if (tot) {
|
2012-03-03 21:42:21 +00:00
|
|
|
median->bv_weight /= (float)tot;
|
2014-10-14 21:29:26 +02:00
|
|
|
if (has_skinradius) {
|
2019-01-05 12:18:02 +11:00
|
|
|
median->skin[0] /= (float)tot;
|
|
|
|
median->skin[1] /= (float)tot;
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
else if (totcurvedata) {
|
2012-10-09 09:14:37 +00:00
|
|
|
TransformMedian_Curve *median = &median_basis.curve;
|
|
|
|
if (totcurvebweight) {
|
|
|
|
median->b_weight /= (float)totcurvebweight;
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
median->weight /= (float)totcurvedata;
|
|
|
|
median->radius /= (float)totcurvedata;
|
2012-03-03 21:42:21 +00:00
|
|
|
median->tilt /= (float)totcurvedata;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-03-03 21:42:21 +00:00
|
|
|
else if (totlattdata) {
|
2019-01-05 12:18:02 +11:00
|
|
|
TransformMedian_Lattice *median = &median_basis.lattice;
|
|
|
|
median->weight /= (float)totlattdata;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2012-10-09 09:14:37 +00:00
|
|
|
if (block) { /* buttons */
|
2010-12-10 23:31:03 +00:00
|
|
|
uiBut *but;
|
2012-10-09 09:14:37 +00:00
|
|
|
int yi = 200;
|
|
|
|
const float tilt_limit = DEG2RADF(21600.0f);
|
|
|
|
const int butw = 200;
|
|
|
|
const int buth = 20 * UI_DPI_FAC;
|
2009-02-10 15:38:00 +00:00
|
|
|
const int but_margin = 2;
|
2012-10-09 09:14:37 +00:00
|
|
|
const char *c;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
memcpy(&tfp->ve_median, &median_basis, sizeof(tfp->ve_median));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (tot == 1) {
|
2012-03-03 21:42:21 +00:00
|
|
|
if (totcurvedata) {
|
2019-03-26 21:16:47 +11:00
|
|
|
/* Curve */
|
2012-10-09 09:14:37 +00:00
|
|
|
c = IFACE_("Control Point:");
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
2019-03-26 21:16:47 +11:00
|
|
|
/* Mesh or lattice */
|
2012-03-03 21:42:21 +00:00
|
|
|
c = IFACE_("Vertex:");
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
else {
|
|
|
|
c = IFACE_("Median:");
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_LABEL, 0, c, 0, yi -= buth, butw, buth, NULL, 0, 0, 0, 0, "");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
UI_block_align_begin(block);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
/* Should be no need to translate these. */
|
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
2019-03-26 21:16:47 +11:00
|
|
|
IFACE_("X:"),
|
2019-04-17 06:17:24 +02:00
|
|
|
0,
|
2012-04-20 16:17:52 +00:00
|
|
|
yi -= buth,
|
2019-04-17 06:17:24 +02:00
|
|
|
butw,
|
|
|
|
buth,
|
2019-01-05 12:18:02 +11:00
|
|
|
&tfp->ve_median.generic.location[0],
|
2019-04-17 06:17:24 +02:00
|
|
|
-lim,
|
|
|
|
lim,
|
2020-09-04 21:18:45 +02:00
|
|
|
0,
|
|
|
|
0,
|
2019-04-17 06:17:24 +02:00
|
|
|
"");
|
2020-09-04 21:18:45 +02:00
|
|
|
UI_but_number_step_size_set(but, 10);
|
|
|
|
UI_but_number_precision_set(but, RNA_TRANSLATION_PREC_DEFAULT);
|
2019-01-05 12:18:02 +11:00
|
|
|
UI_but_unit_type_set(but, PROP_UNIT_LENGTH);
|
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
2014-10-14 21:29:26 +02:00
|
|
|
IFACE_("Y:"),
|
2019-04-17 06:17:24 +02:00
|
|
|
0,
|
2019-01-05 12:18:02 +11:00
|
|
|
yi -= buth,
|
2019-04-17 06:17:24 +02:00
|
|
|
butw,
|
|
|
|
buth,
|
2019-01-05 12:18:02 +11:00
|
|
|
&tfp->ve_median.generic.location[1],
|
2019-04-17 06:17:24 +02:00
|
|
|
-lim,
|
|
|
|
lim,
|
2020-09-04 21:18:45 +02:00
|
|
|
0,
|
|
|
|
0,
|
2019-04-17 06:17:24 +02:00
|
|
|
"");
|
2020-09-04 21:18:45 +02:00
|
|
|
UI_but_number_step_size_set(but, 10);
|
|
|
|
UI_but_number_precision_set(but, RNA_TRANSLATION_PREC_DEFAULT);
|
2019-01-05 12:18:02 +11:00
|
|
|
UI_but_unit_type_set(but, PROP_UNIT_LENGTH);
|
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
2014-10-14 22:07:31 +02:00
|
|
|
IFACE_("Z:"),
|
2019-04-17 06:17:24 +02:00
|
|
|
0,
|
2019-01-05 12:18:02 +11:00
|
|
|
yi -= buth,
|
2019-04-17 06:17:24 +02:00
|
|
|
butw,
|
|
|
|
buth,
|
2019-01-05 12:18:02 +11:00
|
|
|
&tfp->ve_median.generic.location[2],
|
2019-04-17 06:17:24 +02:00
|
|
|
-lim,
|
|
|
|
lim,
|
2020-09-04 21:18:45 +02:00
|
|
|
0,
|
|
|
|
0,
|
2019-01-05 12:18:02 +11:00
|
|
|
"");
|
2020-09-04 21:18:45 +02:00
|
|
|
UI_but_number_step_size_set(but, 10);
|
|
|
|
UI_but_number_precision_set(but, RNA_TRANSLATION_PREC_DEFAULT);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_unit_type_set(but, PROP_UNIT_LENGTH);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
if (totcurvebweight == tot) {
|
2020-09-04 21:18:45 +02:00
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
|
|
|
IFACE_("W:"),
|
|
|
|
0,
|
|
|
|
yi -= buth,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&(tfp->ve_median.curve.b_weight),
|
|
|
|
0.01,
|
|
|
|
100.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
|
|
|
uiDefButBitS(block,
|
2012-03-03 21:42:21 +00:00
|
|
|
UI_BTYPE_TOGGLE,
|
2019-03-26 21:16:47 +11:00
|
|
|
V3D_GLOBAL_STATS,
|
|
|
|
B_REDR,
|
2012-10-09 09:14:37 +00:00
|
|
|
IFACE_("Global"),
|
2019-01-05 12:18:02 +11:00
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
100,
|
|
|
|
buth,
|
|
|
|
&v3d->flag,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
TIP_("Displays global values"));
|
|
|
|
uiDefButBitS(block,
|
|
|
|
UI_BTYPE_TOGGLE_N,
|
2014-11-09 21:20:40 +01:00
|
|
|
V3D_GLOBAL_STATS,
|
2019-04-17 06:17:24 +02:00
|
|
|
B_REDR,
|
2014-11-09 21:20:40 +01:00
|
|
|
IFACE_("Local"),
|
2019-01-05 12:18:02 +11:00
|
|
|
100,
|
2019-04-17 06:17:24 +02:00
|
|
|
yi,
|
|
|
|
100,
|
2019-01-05 12:18:02 +11:00
|
|
|
buth,
|
2013-02-19 15:45:56 +00:00
|
|
|
&v3d->flag,
|
2019-01-05 12:18:02 +11:00
|
|
|
0,
|
2019-04-17 06:17:24 +02:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
2013-02-19 15:45:56 +00:00
|
|
|
TIP_("Displays local values"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
/* Meshes... */
|
2019-01-05 12:18:02 +11:00
|
|
|
if (has_meshdata) {
|
|
|
|
TransformMedian_Mesh *ve_median = &tfp->ve_median.mesh;
|
|
|
|
if (tot) {
|
|
|
|
uiDefBut(block,
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
0,
|
|
|
|
tot == 1 ? IFACE_("Vertex Data:") : IFACE_("Vertices Data:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
NULL,
|
|
|
|
0.0,
|
|
|
|
0.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
|
|
|
/* customdata layer added on demand */
|
2020-09-04 21:18:45 +02:00
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
|
|
|
tot == 1 ? IFACE_("Bevel Weight:") : IFACE_("Mean Bevel Weight:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&ve_median->bv_weight,
|
|
|
|
0.0,
|
|
|
|
1.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
TIP_("Vertex weight used by Bevel modifier"));
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 2);
|
2014-10-14 21:29:26 +02:00
|
|
|
}
|
|
|
|
if (has_skinradius) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
2020-09-04 21:18:45 +02:00
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
|
|
|
tot == 1 ? IFACE_("Radius X:") : IFACE_("Mean Radius X:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&ve_median->skin[0],
|
|
|
|
0.0,
|
|
|
|
100.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
TIP_("X radius used by Skin modifier"));
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
|
|
|
tot == 1 ? IFACE_("Radius Y:") : IFACE_("Mean Radius Y:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&ve_median->skin[1],
|
|
|
|
0.0,
|
|
|
|
100.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
TIP_("Y radius used by Skin modifier"));
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
2014-10-14 22:07:31 +02:00
|
|
|
}
|
|
|
|
if (totedgedata) {
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block,
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
0,
|
|
|
|
totedgedata == 1 ? IFACE_("Edge Data:") : IFACE_("Edges Data:"),
|
2019-01-05 12:18:02 +11:00
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
NULL,
|
|
|
|
0.0,
|
|
|
|
0.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
2014-10-14 22:07:31 +02:00
|
|
|
/* customdata layer added on demand */
|
2020-09-04 21:18:45 +02:00
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
|
|
|
totedgedata == 1 ? IFACE_("Bevel Weight:") : IFACE_("Mean Bevel Weight:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&ve_median->be_weight,
|
|
|
|
0.0,
|
|
|
|
1.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
TIP_("Edge weight used by Bevel modifier"));
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 2);
|
2012-10-09 09:14:37 +00:00
|
|
|
/* customdata layer added on demand */
|
2020-09-04 21:18:45 +02:00
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
|
|
|
totedgedata == 1 ? IFACE_("Crease:") : IFACE_("Mean Crease:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&ve_median->crease,
|
|
|
|
0.0,
|
|
|
|
1.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
TIP_("Weight used by the Subdivision Surface modifier"));
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 2);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
}
|
2012-10-09 09:14:37 +00:00
|
|
|
/* Curve... */
|
2019-01-05 12:18:02 +11:00
|
|
|
else if (totcurvedata) {
|
|
|
|
TransformMedian_Curve *ve_median = &tfp->ve_median.curve;
|
|
|
|
if (totcurvedata == 1) {
|
2020-09-04 21:18:45 +02:00
|
|
|
but = uiDefButR(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
0,
|
|
|
|
IFACE_("Weight:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&data_ptr,
|
|
|
|
"weight_softbody",
|
|
|
|
0,
|
|
|
|
0.0,
|
|
|
|
1.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL);
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
|
|
|
but = uiDefButR(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
0,
|
|
|
|
IFACE_("Radius:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&data_ptr,
|
|
|
|
"radius",
|
|
|
|
0,
|
|
|
|
0.0,
|
|
|
|
100.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL);
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
|
|
|
but = uiDefButR(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
0,
|
|
|
|
IFACE_("Tilt:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&data_ptr,
|
|
|
|
"tilt",
|
|
|
|
0,
|
|
|
|
-tilt_limit,
|
|
|
|
tilt_limit,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL);
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
else if (totcurvedata > 1) {
|
2020-09-04 21:18:45 +02:00
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
|
|
|
IFACE_("Mean Weight:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&ve_median->weight,
|
|
|
|
0.0,
|
|
|
|
1.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
TIP_("Weight used for Soft Body Goal"));
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
|
|
|
IFACE_("Mean Radius:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&ve_median->radius,
|
|
|
|
0.0,
|
|
|
|
100.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
TIP_("Radius of curve control points"));
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
2014-10-14 23:35:28 +02:00
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
2019-01-05 12:18:02 +11:00
|
|
|
IFACE_("Mean Tilt:"),
|
2019-04-17 06:17:24 +02:00
|
|
|
0,
|
2019-01-05 12:18:02 +11:00
|
|
|
yi -= buth + but_margin,
|
2019-04-17 06:17:24 +02:00
|
|
|
butw,
|
|
|
|
buth,
|
2019-01-05 12:18:02 +11:00
|
|
|
&ve_median->tilt,
|
|
|
|
-tilt_limit,
|
|
|
|
tilt_limit,
|
2020-09-04 21:18:45 +02:00
|
|
|
0,
|
|
|
|
0,
|
2014-10-14 23:35:28 +02:00
|
|
|
TIP_("Tilt of curve control points"));
|
2020-09-04 21:18:45 +02:00
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
2014-10-14 23:35:28 +02:00
|
|
|
UI_but_unit_type_set(but, PROP_UNIT_ROTATION);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2014-10-14 23:35:28 +02:00
|
|
|
/* Lattice... */
|
2019-01-05 12:18:02 +11:00
|
|
|
else if (totlattdata) {
|
|
|
|
TransformMedian_Lattice *ve_median = &tfp->ve_median.lattice;
|
|
|
|
if (totlattdata == 1) {
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButR(block,
|
2019-01-05 12:18:02 +11:00
|
|
|
UI_BTYPE_NUM,
|
2014-10-14 23:35:28 +02:00
|
|
|
0,
|
2019-01-05 12:18:02 +11:00
|
|
|
IFACE_("Weight:"),
|
2014-10-14 23:35:28 +02:00
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
2019-04-17 06:17:24 +02:00
|
|
|
buth,
|
2014-10-14 23:35:28 +02:00
|
|
|
&data_ptr,
|
|
|
|
"weight_softbody",
|
2019-04-17 06:17:24 +02:00
|
|
|
0,
|
|
|
|
0.0,
|
|
|
|
1.0,
|
2020-09-04 21:18:45 +02:00
|
|
|
0,
|
|
|
|
0,
|
2019-04-17 06:17:24 +02:00
|
|
|
NULL);
|
2020-09-04 21:18:45 +02:00
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2014-10-14 23:35:28 +02:00
|
|
|
else if (totlattdata > 1) {
|
2020-09-04 21:18:45 +02:00
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_MEDIAN,
|
|
|
|
IFACE_("Mean Weight:"),
|
|
|
|
0,
|
|
|
|
yi -= buth + but_margin,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&ve_median->weight,
|
|
|
|
0.0,
|
|
|
|
1.0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
TIP_("Weight used for Soft Body Goal"));
|
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
2010-12-15 07:15:51 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2014-10-14 22:07:31 +02:00
|
|
|
UI_block_align_end(block);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2014-10-14 23:35:28 +02:00
|
|
|
else { /* apply */
|
2019-01-05 12:18:02 +11:00
|
|
|
memcpy(&ve_median_basis, &tfp->ve_median, sizeof(tfp->ve_median));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (v3d->flag & V3D_GLOBAL_STATS) {
|
2019-01-05 12:18:02 +11:00
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
|
|
|
mul_m4_v3(ob->imat, median_basis.generic.location);
|
|
|
|
mul_m4_v3(ob->imat, ve_median_basis.generic.location);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
sub_vn_vnvn((float *)&median_basis,
|
|
|
|
(float *)&ve_median_basis,
|
|
|
|
(float *)&median_basis,
|
|
|
|
TRANSFORM_MEDIAN_ARRAY_LEN);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
/* Note with a single element selected, we always do. */
|
|
|
|
const bool apply_vcos = (tot == 1) || (len_squared_v3(median_basis.generic.location) != 0.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-14 23:35:28 +02:00
|
|
|
if ((ob->type == OB_MESH) &&
|
|
|
|
(apply_vcos || median_basis.mesh.bv_weight || median_basis.mesh.skin[0] ||
|
2019-01-05 12:18:02 +11:00
|
|
|
median_basis.mesh.skin[1] || median_basis.mesh.be_weight || median_basis.mesh.crease)) {
|
|
|
|
const TransformMedian_Mesh *median = &median_basis.mesh, *ve_median = &ve_median_basis.mesh;
|
2012-03-03 21:42:21 +00:00
|
|
|
Mesh *me = ob->data;
|
2019-02-17 18:05:18 +11:00
|
|
|
BMEditMesh *em = me->edit_mesh;
|
2012-02-12 19:11:09 +00:00
|
|
|
BMesh *bm = em->bm;
|
2010-01-28 00:45:30 +00:00
|
|
|
BMIter iter;
|
2014-10-14 23:35:28 +02:00
|
|
|
BMVert *eve;
|
|
|
|
BMEdge *eed;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-14 23:35:28 +02:00
|
|
|
int cd_vert_bweight_offset = -1;
|
|
|
|
int cd_vert_skin_offset = -1;
|
|
|
|
int cd_edge_bweight_offset = -1;
|
|
|
|
int cd_edge_crease_offset = -1;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-14 23:35:28 +02:00
|
|
|
float scale_bv_weight = 1.0f;
|
2019-01-05 12:18:02 +11:00
|
|
|
float scale_skin[2] = {1.0f, 1.0f};
|
2014-10-14 23:35:28 +02:00
|
|
|
float scale_be_weight = 1.0f;
|
|
|
|
float scale_crease = 1.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-14 23:35:28 +02:00
|
|
|
/* Vertices */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
if (apply_vcos || median->bv_weight || median->skin[0] || median->skin[1]) {
|
|
|
|
if (median->bv_weight) {
|
2014-10-14 23:35:28 +02:00
|
|
|
BM_mesh_cd_flag_ensure(bm, me, ME_CDFLAG_VERT_BWEIGHT);
|
|
|
|
cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
|
|
|
|
BLI_assert(cd_vert_bweight_offset != -1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
scale_bv_weight = compute_scale_factor(ve_median->bv_weight, median->bv_weight);
|
2011-09-30 08:27:38 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
for (int i = 0; i < 2; i++) {
|
|
|
|
if (median->skin[i]) {
|
2014-10-14 23:35:28 +02:00
|
|
|
cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN);
|
|
|
|
BLI_assert(cd_vert_skin_offset != -1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-10-14 23:35:28 +02:00
|
|
|
if (ve_median->skin[i] != median->skin[i]) {
|
2019-01-05 12:18:02 +11:00
|
|
|
scale_skin[i] = ve_median->skin[i] / (ve_median->skin[i] - median->skin[i]);
|
2012-07-18 14:30:31 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-14 23:35:28 +02:00
|
|
|
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
|
|
|
|
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
|
2019-01-15 23:24:20 +11:00
|
|
|
if (apply_vcos) {
|
2019-01-05 12:18:02 +11:00
|
|
|
apply_raw_diff_v3(eve->co, tot, ve_median->location, median->location);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
if (cd_vert_bweight_offset != -1) {
|
|
|
|
float *b_weight = BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset);
|
|
|
|
apply_scale_factor_clamp(b_weight, tot, ve_median->bv_weight, scale_bv_weight);
|
2012-07-18 14:30:31 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
if (cd_vert_skin_offset != -1) {
|
2014-10-14 22:07:31 +02:00
|
|
|
MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(eve, cd_vert_skin_offset);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
/* That one is not clamped to [0.0, 1.0]. */
|
|
|
|
for (int i = 0; i < 2; i++) {
|
|
|
|
if (median->skin[i] != 0.0f) {
|
|
|
|
apply_scale_factor(
|
|
|
|
&vs->radius[i], tot, ve_median->skin[i], median->skin[i], scale_skin[i]);
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
if (apply_vcos) {
|
2014-10-14 23:35:28 +02:00
|
|
|
EDBM_mesh_normals_update(em);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
/* Edges */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
if (median->be_weight || median->crease) {
|
|
|
|
if (median->be_weight) {
|
|
|
|
BM_mesh_cd_flag_ensure(bm, me, ME_CDFLAG_EDGE_BWEIGHT);
|
2012-03-03 21:42:21 +00:00
|
|
|
cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT);
|
2012-04-28 16:49:00 +00:00
|
|
|
BLI_assert(cd_edge_bweight_offset != -1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
scale_be_weight = compute_scale_factor(ve_median->be_weight, median->be_weight);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (median->crease) {
|
2013-11-09 10:35:32 +00:00
|
|
|
BM_mesh_cd_flag_ensure(bm, me, ME_CDFLAG_EDGE_CREASE);
|
|
|
|
cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
|
2014-10-14 23:35:28 +02:00
|
|
|
BLI_assert(cd_edge_crease_offset != -1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-11-09 10:35:32 +00:00
|
|
|
scale_crease = compute_scale_factor(ve_median->crease, median->crease);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2013-11-09 10:35:32 +00:00
|
|
|
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
|
2019-01-05 12:18:02 +11:00
|
|
|
if (median->be_weight != 0.0f) {
|
|
|
|
float *b_weight = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_bweight_offset);
|
|
|
|
apply_scale_factor_clamp(b_weight, tot, ve_median->be_weight, scale_be_weight);
|
2014-10-14 23:35:28 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
if (median->crease != 0.0f) {
|
|
|
|
float *crease = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_crease_offset);
|
|
|
|
apply_scale_factor_clamp(crease, tot, ve_median->crease, scale_crease);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-10-14 23:35:28 +02:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF) &&
|
|
|
|
(apply_vcos || median_basis.curve.b_weight || median_basis.curve.weight ||
|
2019-03-04 01:14:27 +11:00
|
|
|
median_basis.curve.radius || median_basis.curve.tilt)) {
|
2019-01-15 23:24:20 +11:00
|
|
|
const TransformMedian_Curve *median = &median_basis.curve,
|
2019-01-05 12:18:02 +11:00
|
|
|
*ve_median = &ve_median_basis.curve;
|
2019-01-15 23:24:20 +11:00
|
|
|
Curve *cu = ob->data;
|
|
|
|
BPoint *bp;
|
2012-02-22 16:52:06 +00:00
|
|
|
BezTriple *bezt;
|
|
|
|
int a;
|
2019-01-05 12:18:02 +11:00
|
|
|
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
|
|
|
|
const float scale_w = compute_scale_factor(ve_median->weight, median->weight);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-24 23:32:11 -05:00
|
|
|
LISTBASE_FOREACH (Nurb *, nu, nurbs) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (nu->type == CU_BEZIER) {
|
2013-11-09 10:35:32 +00:00
|
|
|
for (a = nu->pntsu, bezt = nu->bezt; a--; bezt++) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (bezt->f2 & SELECT) {
|
2014-10-14 23:35:28 +02:00
|
|
|
if (apply_vcos) {
|
2019-01-05 12:18:02 +11:00
|
|
|
/* Here we always have to use the diff... :/
|
|
|
|
* Cannot avoid some glitches when going e.g. from 3 to 0.0001 (see T37327),
|
2014-10-14 23:35:28 +02:00
|
|
|
* unless we use doubles.
|
2019-04-17 06:17:24 +02:00
|
|
|
*/
|
2019-01-05 12:18:02 +11:00
|
|
|
add_v3_v3(bezt->vec[0], median->location);
|
|
|
|
add_v3_v3(bezt->vec[1], median->location);
|
|
|
|
add_v3_v3(bezt->vec[2], median->location);
|
2013-11-09 10:35:32 +00:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
if (median->weight) {
|
|
|
|
apply_scale_factor_clamp(&bezt->weight, tot, ve_median->weight, scale_w);
|
2014-10-14 23:35:28 +02:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
if (median->radius) {
|
|
|
|
apply_raw_diff(&bezt->radius, tot, ve_median->radius, median->radius);
|
2014-10-14 23:35:28 +02:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
if (median->tilt) {
|
2019-03-04 01:14:27 +11:00
|
|
|
apply_raw_diff(&bezt->tilt, tot, ve_median->tilt, median->tilt);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-15 23:24:20 +11:00
|
|
|
else if (apply_vcos) {
|
|
|
|
/* Handles can only have their coordinates changed here. */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (bezt->f1 & SELECT) {
|
2019-01-05 12:18:02 +11:00
|
|
|
apply_raw_diff_v3(bezt->vec[0], tot, ve_median->location, median->location);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
if (bezt->f3 & SELECT) {
|
2019-01-05 12:18:02 +11:00
|
|
|
apply_raw_diff_v3(bezt->vec[2], tot, ve_median->location, median->location);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a--; bp++) {
|
2019-03-04 01:14:27 +11:00
|
|
|
if (bp->f1 & SELECT) {
|
2019-01-15 23:24:20 +11:00
|
|
|
if (apply_vcos) {
|
2019-01-05 12:18:02 +11:00
|
|
|
apply_raw_diff_v3(bp->vec, tot, ve_median->location, median->location);
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
if (median->b_weight) {
|
|
|
|
apply_raw_diff(&bp->vec[3], tot, ve_median->b_weight, median->b_weight);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
if (median->weight) {
|
|
|
|
apply_scale_factor_clamp(&bp->weight, tot, ve_median->weight, scale_w);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
if (median->radius) {
|
|
|
|
apply_raw_diff(&bp->radius, tot, ve_median->radius, median->radius);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
if (median->tilt) {
|
|
|
|
apply_raw_diff(&bp->tilt, tot, ve_median->tilt, median->tilt);
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-11-13 14:21:42 +11:00
|
|
|
BKE_nurb_test_2d(nu);
|
2020-05-15 22:48:00 +10:00
|
|
|
BKE_nurb_handles_test(nu, true, false); /* test for bezier too */
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
else if ((ob->type == OB_LATTICE) && (apply_vcos || median_basis.lattice.weight)) {
|
|
|
|
const TransformMedian_Lattice *median = &median_basis.lattice,
|
|
|
|
*ve_median = &ve_median_basis.lattice;
|
2012-03-03 21:42:21 +00:00
|
|
|
Lattice *lt = ob->data;
|
2009-02-10 15:38:00 +00:00
|
|
|
BPoint *bp;
|
|
|
|
int a;
|
2019-01-05 12:18:02 +11:00
|
|
|
const float scale_w = compute_scale_factor(ve_median->weight, median->weight);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
|
2012-03-03 21:42:21 +00:00
|
|
|
bp = lt->editlatt->latt->def;
|
2012-02-22 16:52:06 +00:00
|
|
|
while (a--) {
|
|
|
|
if (bp->f1 & SELECT) {
|
2014-10-14 23:35:28 +02:00
|
|
|
if (apply_vcos) {
|
2019-01-05 12:18:02 +11:00
|
|
|
apply_raw_diff_v3(bp->vec, tot, ve_median->location, median->location);
|
2013-11-09 10:35:32 +00:00
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
if (median->weight) {
|
|
|
|
apply_scale_factor_clamp(&bp->weight, tot, ve_median->weight, scale_w);
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-02-10 15:38:00 +00:00
|
|
|
bp++;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
/* ED_undo_push(C, "Transform properties"); */
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-05 12:18:02 +11:00
|
|
|
|
|
|
|
#undef TRANSFORM_MEDIAN_ARRAY_LEN
|
2012-10-09 09:14:37 +00:00
|
|
|
|
2019-01-04 19:52:13 +11:00
|
|
|
static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d, Object *ob)
|
|
|
|
{
|
|
|
|
uiBlock *block = (layout) ? uiLayoutAbsoluteBlock(layout) : NULL;
|
|
|
|
TransformProperties *tfp = v3d_transform_props_ensure(v3d);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-04 19:52:13 +11:00
|
|
|
if (block) {
|
|
|
|
BLI_assert(C == NULL);
|
|
|
|
int yi = 200;
|
|
|
|
const int butw = 200;
|
|
|
|
const int buth = 20 * UI_DPI_FAC;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-04 19:52:13 +11:00
|
|
|
BKE_object_dimensions_get(ob, tfp->ob_dims);
|
|
|
|
copy_v3_v3(tfp->ob_dims_orig, tfp->ob_dims);
|
2019-09-06 20:00:45 +10:00
|
|
|
copy_v3_v3(tfp->ob_scale_orig, ob->scale);
|
|
|
|
copy_m4_m4(tfp->ob_obmat_orig, ob->obmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-04 19:52:13 +11:00
|
|
|
uiDefBut(block,
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
0,
|
|
|
|
IFACE_("Dimensions:"),
|
|
|
|
0,
|
|
|
|
yi -= buth,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
|
|
|
UI_block_align_begin(block);
|
2019-04-30 12:53:05 +02:00
|
|
|
const float lim = FLT_MAX;
|
2019-01-04 19:52:13 +11:00
|
|
|
for (int i = 0; i < 3; i++) {
|
2019-01-05 20:09:25 +11:00
|
|
|
uiBut *but;
|
2020-08-07 22:36:11 +10:00
|
|
|
const char text[3] = {'X' + i, ':', '\0'};
|
2019-01-05 20:09:25 +11:00
|
|
|
but = uiDefButF(block,
|
|
|
|
UI_BTYPE_NUM,
|
|
|
|
B_TRANSFORM_PANEL_DIMS,
|
|
|
|
text,
|
|
|
|
0,
|
|
|
|
yi -= buth,
|
|
|
|
butw,
|
|
|
|
buth,
|
|
|
|
&(tfp->ob_dims[i]),
|
|
|
|
0.0f,
|
|
|
|
lim,
|
2020-09-04 21:18:45 +02:00
|
|
|
0,
|
|
|
|
0,
|
2019-01-05 20:09:25 +11:00
|
|
|
"");
|
2020-09-04 21:18:45 +02:00
|
|
|
UI_but_number_step_size_set(but, 10);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
2019-01-05 20:09:25 +11:00
|
|
|
UI_but_unit_type_set(but, PROP_UNIT_LENGTH);
|
2019-01-04 19:52:13 +11:00
|
|
|
}
|
|
|
|
UI_block_align_end(block);
|
|
|
|
}
|
|
|
|
else { /* apply */
|
|
|
|
int axis_mask = 0;
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
if (tfp->ob_dims[i] == tfp->ob_dims_orig[i]) {
|
|
|
|
axis_mask |= (1 << i);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-09-06 20:00:45 +10:00
|
|
|
BKE_object_dimensions_set_ex(
|
|
|
|
ob, tfp->ob_dims, axis_mask, tfp->ob_scale_orig, tfp->ob_obmat_orig);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-04 19:52:13 +11:00
|
|
|
PointerRNA obptr;
|
|
|
|
RNA_id_pointer_create(&ob->id, &obptr);
|
|
|
|
PropertyRNA *prop = RNA_struct_find_property(&obptr, "scale");
|
|
|
|
RNA_property_update(C, &obptr, prop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-16 14:41:07 +00:00
|
|
|
#define B_VGRP_PNL_EDIT_SINGLE 8 /* or greater */
|
|
|
|
|
2010-10-15 12:29:02 +00:00
|
|
|
static void do_view3d_vgroup_buttons(bContext *C, void *UNUSED(arg), int event)
|
2010-01-25 23:12:02 +00:00
|
|
|
{
|
2013-06-23 15:37:08 +00:00
|
|
|
if (event < B_VGRP_PNL_EDIT_SINGLE) {
|
|
|
|
/* not for me */
|
|
|
|
return;
|
2010-01-26 17:07:47 +00:00
|
|
|
}
|
2020-07-03 17:18:56 +02:00
|
|
|
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
Object *ob = view_layer->basact->object;
|
|
|
|
ED_vgroup_vert_active_mirror(ob, event - B_VGRP_PNL_EDIT_SINGLE);
|
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
|
2010-01-25 23:12:02 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt))
|
2010-01-25 23:12:02 +00:00
|
|
|
{
|
2017-11-23 13:51:49 -02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
Object *ob = OBACT(view_layer);
|
2013-07-01 20:27:03 +00:00
|
|
|
if (ob && (BKE_object_is_in_editmode_vgroup(ob) || BKE_object_is_in_wpaint_select_vert(ob))) {
|
2013-06-15 10:18:16 +00:00
|
|
|
MDeformVert *dvert_act = ED_mesh_active_dvert_get_only(ob);
|
|
|
|
if (dvert_act) {
|
|
|
|
return (dvert_act->totweight != 0);
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-15 10:18:16 +00:00
|
|
|
return false;
|
2010-01-25 23:12:02 +00:00
|
|
|
}
|
|
|
|
|
2020-04-03 22:20:25 -05:00
|
|
|
static void view3d_panel_vgroup(const bContext *C, Panel *panel)
|
2010-01-25 23:12:02 +00:00
|
|
|
{
|
2020-04-03 22:20:25 -05:00
|
|
|
uiBlock *block = uiLayoutAbsoluteBlock(panel->layout);
|
2012-03-03 21:42:21 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2017-11-23 13:51:49 -02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
Object *ob = view_layer->basact->object;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-12-14 22:54:38 +00:00
|
|
|
MDeformVert *dv;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-15 10:18:16 +00:00
|
|
|
dv = ED_mesh_active_dvert_get_only(ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (dv && dv->totweight) {
|
2013-06-23 15:37:08 +00:00
|
|
|
ToolSettings *ts = scene->toolsettings;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-23 15:37:08 +00:00
|
|
|
wmOperatorType *ot;
|
|
|
|
PointerRNA op_ptr, tools_ptr;
|
|
|
|
PointerRNA *but_ptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-23 15:37:08 +00:00
|
|
|
uiLayout *col, *bcol;
|
2013-06-16 13:30:37 +00:00
|
|
|
uiLayout *row;
|
2013-06-16 15:44:17 +00:00
|
|
|
uiBut *but;
|
2010-01-25 23:12:02 +00:00
|
|
|
bDeformGroup *dg;
|
2019-03-01 23:43:34 +11:00
|
|
|
uint i;
|
2013-06-12 10:39:27 +00:00
|
|
|
int subset_count, vgroup_tot;
|
2013-06-23 15:37:08 +00:00
|
|
|
const bool *vgroup_validmap;
|
|
|
|
eVGroupSelect subset_type = ts->vgroupsubset;
|
2010-01-25 23:12:02 +00:00
|
|
|
int yco = 0;
|
2013-06-26 22:29:31 +00:00
|
|
|
int lock_count = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_func_handle_set(block, do_view3d_vgroup_buttons, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 22:20:25 -05:00
|
|
|
bcol = uiLayoutColumn(panel->layout, true);
|
2013-06-23 15:37:08 +00:00
|
|
|
row = uiLayoutRow(bcol, true); /* The filter button row */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-23 15:37:08 +00:00
|
|
|
RNA_pointer_create(NULL, &RNA_ToolSettings, ts, &tools_ptr);
|
|
|
|
uiItemR(row, &tools_ptr, "vertex_group_subset", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(bcol, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-18 23:52:17 +01:00
|
|
|
vgroup_validmap = BKE_object_defgroup_subset_from_select_type(
|
2013-06-23 15:37:08 +00:00
|
|
|
ob, subset_type, &vgroup_tot, &subset_count);
|
2013-06-12 10:39:27 +00:00
|
|
|
for (i = 0, dg = ob->defbase.first; dg; i++, dg = dg->next) {
|
2013-06-23 15:37:08 +00:00
|
|
|
bool locked = (dg->flag & DG_LOCK_WEIGHT) != 0;
|
2013-06-12 10:39:27 +00:00
|
|
|
if (vgroup_validmap[i]) {
|
2020-03-06 12:50:56 +11:00
|
|
|
MDeformWeight *dw = BKE_defvert_find_index(dv, i);
|
2013-06-12 10:39:27 +00:00
|
|
|
if (dw) {
|
2013-06-23 15:37:08 +00:00
|
|
|
int x, xco = 0;
|
2013-06-26 22:29:31 +00:00
|
|
|
int icon;
|
2013-06-23 15:37:08 +00:00
|
|
|
uiLayout *split = uiLayoutSplit(col, 0.45, true);
|
2014-11-18 23:52:17 +01:00
|
|
|
row = uiLayoutRow(split, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-18 23:52:17 +01:00
|
|
|
/* The Weight Group Name */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-18 23:52:17 +01:00
|
|
|
ot = WM_operatortype_find("OBJECT_OT_vertex_weight_set_active", true);
|
2013-06-26 22:29:31 +00:00
|
|
|
but = uiDefButO_ptr(block,
|
|
|
|
UI_BTYPE_BUT,
|
2019-04-17 06:17:24 +02:00
|
|
|
ot,
|
2013-06-23 15:37:08 +00:00
|
|
|
WM_OP_EXEC_DEFAULT,
|
|
|
|
dg->name,
|
2017-03-22 19:41:03 +01:00
|
|
|
xco,
|
2019-04-17 06:17:24 +02:00
|
|
|
yco,
|
2014-11-09 21:20:40 +01:00
|
|
|
(x = UI_UNIT_X * 5),
|
2013-06-23 15:37:08 +00:00
|
|
|
UI_UNIT_Y,
|
|
|
|
"");
|
2014-11-09 21:20:40 +01:00
|
|
|
but_ptr = UI_but_operator_ptr_get(but);
|
2013-06-23 15:37:08 +00:00
|
|
|
RNA_int_set(but_ptr, "weight_group", i);
|
2019-01-05 12:18:02 +11:00
|
|
|
UI_but_drawflag_enable(but, UI_BUT_TEXT_RIGHT);
|
2013-06-16 15:44:17 +00:00
|
|
|
if (ob->actdef != i + 1) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_INACTIVE);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-06-16 15:44:17 +00:00
|
|
|
xco += x;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
row = uiLayoutRow(split, true);
|
|
|
|
uiLayoutSetEnabled(row, !locked);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-26 22:29:31 +00:00
|
|
|
/* The weight group value */
|
|
|
|
/* To be reworked still */
|
|
|
|
but = uiDefButF(block,
|
2019-01-05 12:18:02 +11:00
|
|
|
UI_BTYPE_NUM,
|
2013-06-26 22:29:31 +00:00
|
|
|
B_VGRP_PNL_EDIT_SINGLE + i,
|
2019-04-17 06:17:24 +02:00
|
|
|
"",
|
|
|
|
xco,
|
2014-11-09 21:20:40 +01:00
|
|
|
yco,
|
|
|
|
(x = UI_UNIT_X * 4),
|
2013-06-24 02:30:09 +00:00
|
|
|
UI_UNIT_Y,
|
|
|
|
&dw->weight,
|
|
|
|
0.0,
|
|
|
|
1.0,
|
2020-09-04 21:18:45 +02:00
|
|
|
0,
|
|
|
|
0,
|
2013-06-24 02:30:09 +00:00
|
|
|
"");
|
2020-09-04 21:18:45 +02:00
|
|
|
UI_but_number_step_size_set(but, 1);
|
|
|
|
UI_but_number_precision_set(but, 3);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_drawflag_enable(but, UI_BUT_TEXT_LEFT);
|
2013-06-26 22:29:31 +00:00
|
|
|
if (locked) {
|
|
|
|
lock_count++;
|
2013-06-25 21:00:00 +00:00
|
|
|
}
|
2013-06-16 14:41:07 +00:00
|
|
|
xco += x;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-23 15:37:08 +00:00
|
|
|
/* The weight group paste function */
|
2014-01-12 22:27:55 +11:00
|
|
|
icon = (locked) ? ICON_BLANK1 : ICON_PASTEDOWN;
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO(row,
|
|
|
|
"OBJECT_OT_vertex_weight_paste",
|
|
|
|
"",
|
|
|
|
icon,
|
|
|
|
NULL,
|
|
|
|
WM_OP_INVOKE_DEFAULT,
|
|
|
|
0,
|
|
|
|
&op_ptr);
|
2017-03-22 19:41:03 +01:00
|
|
|
RNA_int_set(&op_ptr, "weight_group", i);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-23 15:37:08 +00:00
|
|
|
/* The weight entry delete function */
|
2014-01-12 22:27:55 +11:00
|
|
|
icon = (locked) ? ICON_LOCKED : ICON_X;
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO(row,
|
|
|
|
"OBJECT_OT_vertex_weight_delete",
|
|
|
|
"",
|
|
|
|
icon,
|
|
|
|
NULL,
|
|
|
|
WM_OP_INVOKE_DEFAULT,
|
|
|
|
0,
|
|
|
|
&op_ptr);
|
2017-03-22 19:41:03 +01:00
|
|
|
RNA_int_set(&op_ptr, "weight_group", i);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-16 13:30:37 +00:00
|
|
|
yco -= UI_UNIT_Y;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2013-06-12 10:39:27 +00:00
|
|
|
}
|
2013-06-23 15:37:08 +00:00
|
|
|
MEM_freeN((void *)vgroup_validmap);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
yco -= 2;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 22:20:25 -05:00
|
|
|
col = uiLayoutColumn(panel->layout, true);
|
2013-06-16 13:30:37 +00:00
|
|
|
row = uiLayoutRow(col, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-25 22:28:20 +00:00
|
|
|
ot = WM_operatortype_find("OBJECT_OT_vertex_weight_normalize_active_vertex", 1);
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButO_ptr(
|
|
|
|
block,
|
|
|
|
UI_BTYPE_BUT,
|
|
|
|
ot,
|
|
|
|
WM_OP_EXEC_DEFAULT,
|
|
|
|
"Normalize",
|
2013-06-25 10:44:30 +00:00
|
|
|
0,
|
|
|
|
yco,
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
UI_UNIT_Y,
|
2013-07-16 13:12:58 +00:00
|
|
|
TIP_("Normalize weights of active vertex (if affected groups are unlocked)"));
|
2013-06-26 22:29:31 +00:00
|
|
|
if (lock_count) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2013-06-25 22:19:48 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-23 15:37:08 +00:00
|
|
|
ot = WM_operatortype_find("OBJECT_OT_vertex_weight_copy", 1);
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButO_ptr(
|
|
|
|
block,
|
|
|
|
UI_BTYPE_BUT,
|
|
|
|
ot,
|
|
|
|
WM_OP_EXEC_DEFAULT,
|
|
|
|
"Copy",
|
2013-06-25 10:44:30 +00:00
|
|
|
UI_UNIT_X * 5,
|
|
|
|
yco,
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
UI_UNIT_Y,
|
2013-07-16 13:12:58 +00:00
|
|
|
TIP_("Copy active vertex to other selected vertices (if affected groups are unlocked)"));
|
2013-06-26 22:29:31 +00:00
|
|
|
if (lock_count) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2013-06-26 22:29:31 +00:00
|
|
|
}
|
2010-01-25 23:12:02 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-10 15:38:00 +00:00
|
|
|
|
2009-11-05 01:00:17 +00:00
|
|
|
static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiLayout *split, *colsub;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
split = uiLayoutSplit(layout, 0.8f, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-18 11:40:55 +00:00
|
|
|
if (ptr->type == &RNA_PoseBone) {
|
2009-11-05 01:00:17 +00:00
|
|
|
PointerRNA boneptr;
|
|
|
|
Bone *bone;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-05 01:00:17 +00:00
|
|
|
boneptr = RNA_pointer_get(ptr, "bone");
|
|
|
|
bone = boneptr.data;
|
|
|
|
uiLayoutSetActive(split, !(bone->parent && bone->flag & BONE_CONNECTED));
|
|
|
|
}
|
2014-04-01 11:34:00 +11:00
|
|
|
colsub = uiLayoutColumn(split, true);
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(colsub, ptr, "location", 0, NULL, ICON_NONE);
|
2014-04-01 11:34:00 +11:00
|
|
|
colsub = uiLayoutColumn(split, true);
|
2018-08-24 12:54:48 +02:00
|
|
|
uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(colsub, "", ICON_NONE);
|
2018-09-14 19:54:07 +02:00
|
|
|
uiItemR(colsub,
|
|
|
|
ptr,
|
|
|
|
"lock_location",
|
|
|
|
UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY,
|
|
|
|
"",
|
|
|
|
ICON_DECORATE_UNLOCKED);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
split = uiLayoutSplit(layout, 0.8f, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
switch (RNA_enum_get(ptr, "rotation_mode")) {
|
2009-11-28 03:49:45 +00:00
|
|
|
case ROT_MODE_QUAT: /* quaternion */
|
2014-04-01 11:34:00 +11:00
|
|
|
colsub = uiLayoutColumn(split, true);
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(colsub, ptr, "rotation_quaternion", 0, IFACE_("Rotation"), ICON_NONE);
|
2014-04-01 11:34:00 +11:00
|
|
|
colsub = uiLayoutColumn(split, true);
|
2018-08-24 12:54:48 +02:00
|
|
|
uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE);
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (RNA_boolean_get(ptr, "lock_rotations_4d")) {
|
2018-09-14 19:54:07 +02:00
|
|
|
uiItemR(colsub,
|
|
|
|
ptr,
|
|
|
|
"lock_rotation_w",
|
|
|
|
UI_ITEM_R_TOGGLE + UI_ITEM_R_ICON_ONLY,
|
|
|
|
"",
|
|
|
|
ICON_DECORATE_UNLOCKED);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(colsub, "", ICON_NONE);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-09-14 19:54:07 +02:00
|
|
|
uiItemR(colsub,
|
|
|
|
ptr,
|
|
|
|
"lock_rotation",
|
|
|
|
UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY,
|
|
|
|
"",
|
|
|
|
ICON_DECORATE_UNLOCKED);
|
2009-11-05 01:00:17 +00:00
|
|
|
break;
|
2009-11-28 03:49:45 +00:00
|
|
|
case ROT_MODE_AXISANGLE: /* axis angle */
|
2014-04-01 11:34:00 +11:00
|
|
|
colsub = uiLayoutColumn(split, true);
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(colsub, ptr, "rotation_axis_angle", 0, IFACE_("Rotation"), ICON_NONE);
|
2014-04-01 11:34:00 +11:00
|
|
|
colsub = uiLayoutColumn(split, true);
|
2018-08-24 12:54:48 +02:00
|
|
|
uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE);
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (RNA_boolean_get(ptr, "lock_rotations_4d")) {
|
2018-09-14 19:54:07 +02:00
|
|
|
uiItemR(colsub,
|
|
|
|
ptr,
|
|
|
|
"lock_rotation_w",
|
|
|
|
UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY,
|
|
|
|
"",
|
|
|
|
ICON_DECORATE_UNLOCKED);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(colsub, "", ICON_NONE);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-09-14 19:54:07 +02:00
|
|
|
uiItemR(colsub,
|
|
|
|
ptr,
|
|
|
|
"lock_rotation",
|
|
|
|
UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY,
|
|
|
|
"",
|
|
|
|
ICON_DECORATE_UNLOCKED);
|
2009-11-05 01:00:17 +00:00
|
|
|
break;
|
2009-11-28 03:49:45 +00:00
|
|
|
default: /* euler rotations */
|
2014-04-01 11:34:00 +11:00
|
|
|
colsub = uiLayoutColumn(split, true);
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(colsub, ptr, "rotation_euler", 0, IFACE_("Rotation"), ICON_NONE);
|
2014-04-01 11:34:00 +11:00
|
|
|
colsub = uiLayoutColumn(split, true);
|
2018-08-24 12:54:48 +02:00
|
|
|
uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(colsub, "", ICON_NONE);
|
2018-09-14 19:54:07 +02:00
|
|
|
uiItemR(colsub,
|
|
|
|
ptr,
|
|
|
|
"lock_rotation",
|
|
|
|
UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY,
|
|
|
|
"",
|
|
|
|
ICON_DECORATE_UNLOCKED);
|
2009-11-28 03:49:45 +00:00
|
|
|
break;
|
2009-11-05 01:00:17 +00:00
|
|
|
}
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "rotation_mode", 0, "", ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
split = uiLayoutSplit(layout, 0.8f, false);
|
|
|
|
colsub = uiLayoutColumn(split, true);
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(colsub, ptr, "scale", 0, NULL, ICON_NONE);
|
2014-04-01 11:34:00 +11:00
|
|
|
colsub = uiLayoutColumn(split, true);
|
2018-08-24 12:54:48 +02:00
|
|
|
uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(colsub, "", ICON_NONE);
|
2018-09-14 19:54:07 +02:00
|
|
|
uiItemR(colsub,
|
|
|
|
ptr,
|
|
|
|
"lock_scale",
|
|
|
|
UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY,
|
|
|
|
"",
|
|
|
|
ICON_DECORATE_UNLOCKED);
|
2009-11-05 01:00:17 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 12:29:02 +00:00
|
|
|
static void v3d_posearmature_buts(uiLayout *layout, Object *ob)
|
2009-02-10 15:38:00 +00:00
|
|
|
{
|
|
|
|
bPoseChannel *pchan;
|
2009-10-22 23:22:05 +00:00
|
|
|
PointerRNA pchanptr;
|
2009-11-06 22:51:08 +00:00
|
|
|
uiLayout *col;
|
2009-02-10 15:38:00 +00:00
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
pchan = BKE_pose_channel_active(ob);
|
2012-03-03 21:42:21 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (!pchan) {
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemL(layout, IFACE_("No Bone Active"), ICON_NONE);
|
|
|
|
return;
|
2009-11-06 21:41:07 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 11:40:55 +00:00
|
|
|
RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &pchanptr);
|
2009-11-05 01:00:17 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, false);
|
2012-03-03 21:42:21 +00:00
|
|
|
|
2009-11-05 01:00:17 +00:00
|
|
|
/* XXX: RNA buts show data in native types (i.e. quats, 4-component axis/angle, etc.)
|
2012-03-04 04:35:12 +00:00
|
|
|
* but old-school UI shows in eulers always. Do we want to be able to still display in Eulers?
|
2009-11-05 01:00:17 +00:00
|
|
|
* Maybe needs RNA/ui options to display rotations as different types... */
|
|
|
|
v3d_transform_butsR(col, &pchanptr);
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 12:29:02 +00:00
|
|
|
static void v3d_editarmature_buts(uiLayout *layout, Object *ob)
|
2009-02-10 15:38:00 +00:00
|
|
|
{
|
2012-03-03 21:42:21 +00:00
|
|
|
bArmature *arm = ob->data;
|
2009-02-10 15:38:00 +00:00
|
|
|
EditBone *ebone;
|
2009-11-06 22:51:08 +00:00
|
|
|
uiLayout *col;
|
2009-10-22 23:22:05 +00:00
|
|
|
PointerRNA eboneptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
ebone = arm->act_edbone;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
if (!ebone || (ebone->layer & arm->layer) == 0) {
|
|
|
|
uiItemL(layout, IFACE_("Nothing selected"), ICON_NONE);
|
2009-02-10 15:38:00 +00:00
|
|
|
return;
|
2011-07-13 11:52:37 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
RNA_pointer_create(&arm->id, &RNA_EditBone, ebone, &eboneptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, false);
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(col, &eboneptr, "head", 0, NULL, ICON_NONE);
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ebone->parent && ebone->flag & BONE_CONNECTED) {
|
2009-11-05 02:21:04 +00:00
|
|
|
PointerRNA parptr = RNA_pointer_get(&eboneptr, "parent");
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(col, &parptr, "tail_radius", 0, IFACE_("Radius (Parent)"), ICON_NONE);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(col, &eboneptr, "head_radius", 0, IFACE_("Radius"), ICON_NONE);
|
2009-11-05 02:21:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(col, &eboneptr, "tail", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, &eboneptr, "tail_radius", 0, IFACE_("Radius"), ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(col, &eboneptr, "roll", 0, NULL, ICON_NONE);
|
2019-09-11 12:48:52 +03:00
|
|
|
uiItemR(col, &eboneptr, "length", 0, NULL, ICON_NONE);
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(col, &eboneptr, "envelope_distance", 0, IFACE_("Envelope"), ICON_NONE);
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 12:29:02 +00:00
|
|
|
static void v3d_editmetaball_buts(uiLayout *layout, Object *ob)
|
2009-02-10 15:38:00 +00:00
|
|
|
{
|
2009-11-05 02:21:04 +00:00
|
|
|
PointerRNA mbptr, ptr;
|
2012-03-03 21:42:21 +00:00
|
|
|
MetaBall *mball = ob->data;
|
2009-11-06 22:51:08 +00:00
|
|
|
uiLayout *col;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!mball || !(mball->lastelem)) {
|
2020-07-26 21:20:37 -04:00
|
|
|
uiItemL(layout, IFACE_("Nothing selected"), ICON_NONE);
|
2012-03-03 21:42:21 +00:00
|
|
|
return;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-05 02:21:04 +00:00
|
|
|
RNA_pointer_create(&mball->id, &RNA_MetaBall, mball, &mbptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-05 02:21:04 +00:00
|
|
|
RNA_pointer_create(&mball->id, &RNA_MetaElement, mball->lastelem, &ptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, false);
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(col, &ptr, "co", 0, NULL, ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(col, &ptr, "radius", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, &ptr, "stiffness", 0, NULL, ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemR(col, &ptr, "type", 0, NULL, ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
2009-11-05 02:21:04 +00:00
|
|
|
switch (RNA_enum_get(&ptr, "type")) {
|
|
|
|
case MB_BALL:
|
|
|
|
break;
|
|
|
|
case MB_CUBE:
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemL(col, IFACE_("Size:"), ICON_NONE);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, &ptr, "size_x", 0, "X", ICON_NONE);
|
|
|
|
uiItemR(col, &ptr, "size_y", 0, "Y", ICON_NONE);
|
|
|
|
uiItemR(col, &ptr, "size_z", 0, "Z", ICON_NONE);
|
2009-11-05 02:21:04 +00:00
|
|
|
break;
|
|
|
|
case MB_TUBE:
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemL(col, IFACE_("Size:"), ICON_NONE);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, &ptr, "size_x", 0, "X", ICON_NONE);
|
2009-11-05 02:21:04 +00:00
|
|
|
break;
|
|
|
|
case MB_PLANE:
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemL(col, IFACE_("Size:"), ICON_NONE);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, &ptr, "size_x", 0, "X", ICON_NONE);
|
|
|
|
uiItemR(col, &ptr, "size_y", 0, "Y", ICON_NONE);
|
2009-11-05 02:21:04 +00:00
|
|
|
break;
|
|
|
|
case MB_ELIPSOID:
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemL(col, IFACE_("Size:"), ICON_NONE);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, &ptr, "size_x", 0, "X", ICON_NONE);
|
|
|
|
uiItemR(col, &ptr, "size_y", 0, "Y", ICON_NONE);
|
|
|
|
uiItemR(col, &ptr, "size_z", 0, "Z", ICON_NONE);
|
2012-03-03 21:42:21 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 12:29:02 +00:00
|
|
|
static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event)
|
2009-02-10 15:38:00 +00:00
|
|
|
{
|
2017-11-23 13:51:49 -02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2012-03-03 21:42:21 +00:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2017-11-23 13:51:49 -02:00
|
|
|
Object *ob = OBACT(view_layer);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
switch (event) {
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
case B_REDR:
|
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
|
|
|
return; /* no notifier! */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-05 12:18:02 +11:00
|
|
|
case B_TRANSFORM_PANEL_MEDIAN:
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ob) {
|
|
|
|
v3d_editvertex_buts(NULL, v3d, ob, 1.0);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2012-03-25 23:54:33 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-01-05 12:18:02 +11:00
|
|
|
case B_TRANSFORM_PANEL_DIMS:
|
2019-01-04 19:52:13 +11:00
|
|
|
if (ob) {
|
|
|
|
v3d_object_dimension_buts(C, NULL, v3d, ob);
|
|
|
|
}
|
|
|
|
break;
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-02-10 15:38:00 +00:00
|
|
|
/* default for now */
|
2012-03-25 23:54:33 +00:00
|
|
|
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool view3d_panel_transform_poll(const bContext *C, PanelType *UNUSED(pt))
|
2013-06-16 03:31:15 +00:00
|
|
|
{
|
2017-11-23 13:51:49 -02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
return (view_layer->basact != NULL);
|
2013-06-16 03:31:15 +00:00
|
|
|
}
|
|
|
|
|
2020-04-03 22:20:25 -05:00
|
|
|
static void view3d_panel_transform(const bContext *C, Panel *panel)
|
2009-02-10 15:38:00 +00:00
|
|
|
{
|
2009-05-23 03:24:15 +00:00
|
|
|
uiBlock *block;
|
2017-11-23 13:51:49 -02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
Object *ob = view_layer->basact->object;
|
2019-01-05 12:18:02 +11:00
|
|
|
Object *obedit = OBEDIT_FROM_OBACT(ob);
|
2012-04-10 15:47:34 +00:00
|
|
|
uiLayout *col;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 22:20:25 -05:00
|
|
|
block = uiLayoutGetBlock(panel->layout);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_func_handle_set(block, do_view3d_region_buttons, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 22:20:25 -05:00
|
|
|
col = uiLayoutColumn(panel->layout, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
if (ob == obedit) {
|
2013-06-16 03:31:15 +00:00
|
|
|
if (ob->type == OB_ARMATURE) {
|
2012-03-03 21:42:21 +00:00
|
|
|
v3d_editarmature_buts(col, ob);
|
2013-06-16 03:31:15 +00:00
|
|
|
}
|
|
|
|
else if (ob->type == OB_MBALL) {
|
2012-03-03 21:42:21 +00:00
|
|
|
v3d_editmetaball_buts(col, ob);
|
2013-06-16 03:31:15 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2020-05-18 21:14:36 +10:00
|
|
|
v3d_editvertex_buts(col, v3d, ob, FLT_MAX);
|
2013-06-16 03:31:15 +00:00
|
|
|
}
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2018-04-05 18:20:27 +02:00
|
|
|
else if (ob->mode & OB_MODE_POSE) {
|
2010-10-15 12:29:02 +00:00
|
|
|
v3d_posearmature_buts(col, ob);
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-06-16 03:31:15 +00:00
|
|
|
PointerRNA obptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-16 03:31:15 +00:00
|
|
|
RNA_id_pointer_create(&ob->id, &obptr);
|
2009-11-05 01:00:17 +00:00
|
|
|
v3d_transform_butsR(col, &obptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-17 14:41:48 +01:00
|
|
|
/* Dimensions and editmode are mostly the same check. */
|
|
|
|
if (OB_TYPE_SUPPORT_EDITMODE(ob->type) || ELEM(ob->type, OB_VOLUME, OB_HAIR, OB_POINTCLOUD)) {
|
2019-01-04 19:52:13 +11:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
v3d_object_dimension_buts(NULL, col, v3d, ob);
|
|
|
|
}
|
2011-05-11 09:31:00 +00:00
|
|
|
}
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
static void hide_collections_menu_draw(const bContext *C, Menu *menu)
|
|
|
|
{
|
2018-12-14 10:30:06 +11:00
|
|
|
ED_collection_hide_menu_draw(C, menu->layout);
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
}
|
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
void view3d_buttons_register(ARegionType *art)
|
|
|
|
{
|
|
|
|
PanelType *pt;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel object");
|
2013-06-16 03:31:15 +00:00
|
|
|
strcpy(pt->idname, "VIEW3D_PT_transform");
|
2019-01-15 23:24:20 +11:00
|
|
|
strcpy(pt->label, N_("Transform")); /* XXX C panels unavailable through RNA bpy.types! */
|
2019-04-29 22:50:14 +10:00
|
|
|
strcpy(pt->category, "Item");
|
2015-08-16 17:32:01 +10:00
|
|
|
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
2013-06-16 03:31:15 +00:00
|
|
|
pt->draw = view3d_panel_transform;
|
|
|
|
pt->poll = view3d_panel_transform_poll;
|
2009-05-23 03:24:15 +00:00
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 21:42:21 +00:00
|
|
|
pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel vgroup");
|
2010-01-25 23:12:02 +00:00
|
|
|
strcpy(pt->idname, "VIEW3D_PT_vgroup");
|
2019-01-15 23:24:20 +11:00
|
|
|
strcpy(pt->label, N_("Vertex Weights")); /* XXX C panels unavailable through RNA bpy.types! */
|
2019-04-29 22:50:14 +10:00
|
|
|
strcpy(pt->category, "Item");
|
2015-08-16 17:32:01 +10:00
|
|
|
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
2012-03-03 21:42:21 +00:00
|
|
|
pt->draw = view3d_panel_vgroup;
|
|
|
|
pt->poll = view3d_panel_vgroup_poll;
|
2010-01-25 23:12:02 +00:00
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
MenuType *mt;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
mt = MEM_callocN(sizeof(MenuType), "spacetype view3d menu collections");
|
|
|
|
strcpy(mt->idname, "VIEW3D_MT_collection");
|
|
|
|
strcpy(mt->label, N_("Collection"));
|
|
|
|
strcpy(mt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
|
|
|
mt->draw = hide_collections_menu_draw;
|
|
|
|
WM_menutype_add(mt);
|
2009-05-23 03:24:15 +00:00
|
|
|
}
|
2009-02-10 15:38:00 +00:00
|
|
|
|
2018-08-08 13:30:27 +10:00
|
|
|
static int view3d_object_mode_menu(bContext *C, wmOperator *op)
|
2018-07-05 21:28:25 +02:00
|
|
|
{
|
|
|
|
Object *ob = CTX_data_active_object(C);
|
2018-08-08 13:30:27 +10:00
|
|
|
if (ob == NULL) {
|
|
|
|
BKE_report(op->reports, RPT_WARNING, "No active object found");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2020-07-03 17:18:56 +02:00
|
|
|
if (((ob->mode & OB_MODE_EDIT) == 0) && (ELEM(ob->type, OB_ARMATURE))) {
|
2020-06-03 15:23:26 +10:00
|
|
|
ED_object_mode_set(C, (ob->mode == OB_MODE_OBJECT) ? OB_MODE_POSE : OB_MODE_OBJECT);
|
2018-07-05 21:28:25 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2020-07-03 17:18:56 +02:00
|
|
|
|
|
|
|
UI_pie_menu_invoke(C, "VIEW3D_MT_object_mode_pie", CTX_wm_window(C)->eventstate);
|
|
|
|
return OPERATOR_CANCELLED;
|
2018-07-05 21:28:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VIEW3D_OT_object_mode_pie_or_toggle(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
ot->name = "Object Mode Menu";
|
|
|
|
ot->idname = "VIEW3D_OT_object_mode_pie_or_toggle";
|
|
|
|
|
|
|
|
ot->exec = view3d_object_mode_menu;
|
|
|
|
ot->poll = ED_operator_view3d_active;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = 0;
|
|
|
|
}
|