Merge branch 'master' into blender2.8

This commit is contained in:
Campbell Barton 2017-07-10 16:35:56 +10:00
commit 2bd908ca6e
5 changed files with 172 additions and 26 deletions

View File

@ -198,6 +198,7 @@ void BKE_nurb_bezt_calc_normal(struct Nurb *nu, struct BezTriple *bezt, float r_
void BKE_nurb_bezt_calc_plane(struct Nurb *nu, struct BezTriple *bezt, float r_plane[3]);
void BKE_nurb_bpoint_calc_normal(struct Nurb *nu, struct BPoint *bp, float r_normal[3]);
void BKE_nurb_bpoint_calc_plane(struct Nurb *nu, struct BPoint *bp, float r_plane[3]);
void BKE_nurb_handle_calc(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next,
const bool is_fcurve);

View File

@ -748,6 +748,7 @@ BezTriple *BKE_nurb_bezt_get_prev(Nurb *nu, BezTriple *bezt)
BezTriple *bezt_prev;
BLI_assert(ARRAY_HAS_ITEM(bezt, nu->bezt, nu->pntsu));
BLI_assert(nu->pntsv == 1);
if (bezt == nu->bezt) {
if (nu->flagu & CU_NURB_CYCLIC) {
@ -769,6 +770,7 @@ BPoint *BKE_nurb_bpoint_get_prev(Nurb *nu, BPoint *bp)
BPoint *bp_prev;
BLI_assert(ARRAY_HAS_ITEM(bp, nu->bp, nu->pntsu));
BLI_assert(nu->pntsv == 1);
if (bp == nu->bp) {
if (nu->flagu & CU_NURB_CYCLIC) {
@ -785,7 +787,7 @@ BPoint *BKE_nurb_bpoint_get_prev(Nurb *nu, BPoint *bp)
return bp_prev;
}
void BKE_nurb_bezt_calc_normal(struct Nurb *UNUSED(nu), struct BezTriple *bezt, float r_normal[3])
void BKE_nurb_bezt_calc_normal(struct Nurb *UNUSED(nu), BezTriple *bezt, float r_normal[3])
{
/* calculate the axis matrix from the spline */
float dir_prev[3], dir_next[3];
@ -800,7 +802,7 @@ void BKE_nurb_bezt_calc_normal(struct Nurb *UNUSED(nu), struct BezTriple *bezt,
normalize_v3(r_normal);
}
void BKE_nurb_bezt_calc_plane(struct Nurb *nu, struct BezTriple *bezt, float r_plane[3])
void BKE_nurb_bezt_calc_plane(struct Nurb *nu, BezTriple *bezt, float r_plane[3])
{
float dir_prev[3], dir_next[3];
@ -837,7 +839,7 @@ void BKE_nurb_bezt_calc_plane(struct Nurb *nu, struct BezTriple *bezt, float r_p
normalize_v3(r_plane);
}
void BKE_nurb_bpoint_calc_normal(struct Nurb *nu, struct BPoint *bp, float r_normal[3])
void BKE_nurb_bpoint_calc_normal(struct Nurb *nu, BPoint *bp, float r_normal[3])
{
BPoint *bp_prev = BKE_nurb_bpoint_get_prev(nu, bp);
BPoint *bp_next = BKE_nurb_bpoint_get_next(nu, bp);
@ -860,6 +862,34 @@ void BKE_nurb_bpoint_calc_normal(struct Nurb *nu, struct BPoint *bp, float r_nor
normalize_v3(r_normal);
}
void BKE_nurb_bpoint_calc_plane(struct Nurb *nu, BPoint *bp, float r_plane[3])
{
BPoint *bp_prev = BKE_nurb_bpoint_get_prev(nu, bp);
BPoint *bp_next = BKE_nurb_bpoint_get_next(nu, bp);
float dir_prev[3] = {0.0f}, dir_next[3] = {0.0f};
if (bp_prev) {
sub_v3_v3v3(dir_prev, bp_prev->vec, bp->vec);
normalize_v3(dir_prev);
}
if (bp_next) {
sub_v3_v3v3(dir_next, bp->vec, bp_next->vec);
normalize_v3(dir_next);
}
cross_v3_v3v3(r_plane, dir_prev, dir_next);
/* matches with bones more closely */
{
float dir_mid[3], tvec[3];
add_v3_v3v3(dir_mid, dir_prev, dir_next);
cross_v3_v3v3(tvec, r_plane, dir_mid);
copy_v3_v3(r_plane, tvec);
}
normalize_v3(r_plane);
}
/* ~~~~~~~~~~~~~~~~~~~~Non Uniform Rational B Spline calculations ~~~~~~~~~~~ */

View File

@ -1505,6 +1505,48 @@ static TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struc
return hdata;
}
/**
* For the purpose of transform code we need to behave as if handles are selected,
* even when they aren't (see special case below).
*/
static int bezt_select_to_transform_triple_flag(
const BezTriple *bezt, const bool hide_handles)
{
int flag = 0;
if (hide_handles) {
if (bezt->f2 & SELECT) {
flag = (1 << 0) | (1 << 1) | (1 << 2);
}
}
else {
flag = (
((bezt->f1 & SELECT) ? (1 << 0) : 0) |
((bezt->f2 & SELECT) ? (1 << 1) : 0) |
((bezt->f3 & SELECT) ? (1 << 2) : 0)
);
}
/* Special case for auto & aligned handles:
* When a center point is being moved without the handles,
* leaving the handles stationary makes no sense and only causes strange behavior,
* where one handle is arbitrarily anchored, the other one is aligned and lengthened
* based on where the center point is moved. Also a bug when cancelling, see: T52007.
*
* A more 'correct' solution could be to store handle locations in 'TransDataCurveHandleFlags'.
* However that doesn't resolve odd behavior, so best transform the handles in this case.
*/
if ((flag != ((1 << 0) | (1 << 1) | (1 << 2))) && (flag & (1 << 1))) {
if (ELEM(bezt->h1, HD_AUTO, HD_ALIGN) &&
ELEM(bezt->h2, HD_AUTO, HD_ALIGN))
{
flag = (1 << 0) | (1 << 1) | (1 << 2);
}
}
return flag;
}
static void createTransCurveVerts(TransInfo *t)
{
Curve *cu = t->obedit->data;
@ -1522,22 +1564,22 @@ static void createTransCurveVerts(TransInfo *t)
/* to be sure */
if (cu->editnurb == NULL) return;
#define SEL_F1 (1 << 0)
#define SEL_F2 (1 << 1)
#define SEL_F3 (1 << 2)
/* count total of vertices, check identical as in 2nd loop for making transdata! */
nurbs = BKE_curve_editNurbs_get(cu);
for (nu = nurbs->first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
if (bezt->hide == 0) {
if (hide_handles) {
if (bezt->f2 & SELECT) countsel += 3;
if (is_prop_edit) count += 3;
}
else {
if (bezt->f1 & SELECT) countsel++;
if (bezt->f2 & SELECT) countsel++;
if (bezt->f3 & SELECT) countsel++;
if (is_prop_edit) count += 3;
}
const int bezt_tx = bezt_select_to_transform_triple_flag(bezt, hide_handles);
if (bezt_tx & SEL_F1) { countsel++; }
if (bezt_tx & SEL_F2) { countsel++; }
if (bezt_tx & SEL_F3) { countsel++; }
if (is_prop_edit) count += 3;
}
}
}
@ -1588,10 +1630,10 @@ static void createTransCurveVerts(TransInfo *t)
}
}
if (is_prop_edit ||
((bezt->f2 & SELECT) && hide_handles) ||
((bezt->f1 & SELECT) && hide_handles == 0))
{
/* Elements that will be transform (not always a match to selection). */
const int bezt_tx = bezt_select_to_transform_triple_flag(bezt, hide_handles);
if (is_prop_edit || bezt_tx & SEL_F1) {
copy_v3_v3(td->iloc, bezt->vec[0]);
td->loc = bezt->vec[0];
copy_v3_v3(td->center, bezt->vec[(hide_handles ||
@ -1622,7 +1664,7 @@ static void createTransCurveVerts(TransInfo *t)
}
/* This is the Curve Point, the other two are handles */
if (is_prop_edit || (bezt->f2 & SELECT)) {
if (is_prop_edit || bezt_tx & SEL_F2) {
copy_v3_v3(td->iloc, bezt->vec[1]);
td->loc = bezt->vec[1];
copy_v3_v3(td->center, td->loc);
@ -1648,7 +1690,7 @@ static void createTransCurveVerts(TransInfo *t)
copy_m3_m3(td->axismtx, axismtx);
}
if ((bezt->f1 & SELECT) == 0 && (bezt->f3 & SELECT) == 0)
if ((bezt_tx & SEL_F1) == 0 && (bezt_tx & SEL_F3) == 0)
/* If the middle is selected but the sides arnt, this is needed */
if (hdata == NULL) { /* if the handle was not saved by the previous handle */
hdata = initTransDataCurveHandles(td, bezt);
@ -1658,10 +1700,7 @@ static void createTransCurveVerts(TransInfo *t)
count++;
tail++;
}
if (is_prop_edit ||
((bezt->f2 & SELECT) && hide_handles) ||
((bezt->f3 & SELECT) && hide_handles == 0))
{
if (is_prop_edit || bezt_tx & SEL_F3) {
copy_v3_v3(td->iloc, bezt->vec[2]);
td->loc = bezt->vec[2];
copy_v3_v3(td->center, bezt->vec[(hide_handles ||
@ -1716,6 +1755,26 @@ static void createTransCurveVerts(TransInfo *t)
for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
if (bp->hide == 0) {
if (is_prop_edit || (bp->f1 & SELECT)) {
float axismtx[3][3];
if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
if (nu->pntsv == 1) {
float normal[3], plane[3];
BKE_nurb_bpoint_calc_normal(nu, bp, normal);
BKE_nurb_bpoint_calc_plane(nu, bp, plane);
if (createSpaceNormalTangent(axismtx, normal, plane)) {
/* pass */
}
else {
normalize_v3(normal);
axis_dominant_v3_to_m3(axismtx, normal);
invert_m3(axismtx);
}
}
}
copy_v3_v3(td->iloc, bp->vec);
td->loc = bp->vec;
copy_v3_v3(td->center, td->loc);
@ -1734,6 +1793,11 @@ static void createTransCurveVerts(TransInfo *t)
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
if (nu->pntsv == 1) {
copy_m3_m3(td->axismtx, axismtx);
}
}
td++;
count++;
@ -1749,6 +1813,10 @@ static void createTransCurveVerts(TransInfo *t)
calc_distanceCurveVerts(head, tail - 1);
}
}
#undef SEL_F1
#undef SEL_F2
#undef SEL_F3
}
/* ********************* lattice *************** */

View File

@ -809,15 +809,21 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
Curve *cu = obedit->data;
Nurb *nu = NULL;
BezTriple *bezt = NULL;
int a;
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
if (activeOnly && BKE_curve_nurb_vert_active_get(cu, &nu, (void *)&bezt)) {
void *vert_act = NULL;
if (activeOnly && BKE_curve_nurb_vert_active_get(cu, &nu, &vert_act)) {
if (nu->type == CU_BEZIER) {
BezTriple *bezt = vert_act;
BKE_nurb_bezt_calc_normal(nu, bezt, normal);
BKE_nurb_bezt_calc_plane(nu, bezt, plane);
}
else {
BPoint *bp = vert_act;
BKE_nurb_bpoint_calc_normal(nu, bp, normal);
BKE_nurb_bpoint_calc_plane(nu, bp, plane);
}
}
else {
const bool use_handle = (cu->drawflag & CU_HIDE_HANDLES) == 0;
@ -825,7 +831,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
for (nu = nurbs->first; nu; nu = nu->next) {
/* only bezier has a normal */
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
BezTriple *bezt = nu->bezt;
a = nu->pntsu;
while (a--) {
short flag = 0;
@ -877,6 +883,36 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
bezt++;
}
}
else if (nu->bp && (nu->pntsv == 1)) {
BPoint *bp = nu->bp;
a = nu->pntsu;
while (a--) {
if (bp->f1 & SELECT) {
float tvec[3];
BPoint *bp_prev = BKE_nurb_bpoint_get_prev(nu, bp);
BPoint *bp_next = BKE_nurb_bpoint_get_next(nu, bp);
const bool is_prev_sel = bp_prev && (bp_prev->f1 & SELECT);
const bool is_next_sel = bp_next && (bp_next->f1 & SELECT);
if (is_prev_sel == false && is_next_sel == false) {
/* Isolated, add based on surrounding */
BKE_nurb_bpoint_calc_normal(nu, bp, tvec);
add_v3_v3(normal, tvec);
}
else if (is_next_sel) {
/* A segment, add the edge normal */
sub_v3_v3v3(tvec, bp->vec, bp_next->vec );
normalize_v3(tvec);
add_v3_v3(normal, tvec);
}
BKE_nurb_bpoint_calc_plane(nu, bp, tvec);
add_v3_v3(plane, tvec);
}
bp++;
}
}
}
}

View File

@ -63,6 +63,7 @@
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_sequencer.h"
#include "RNA_define.h"
@ -1112,6 +1113,7 @@ void IMB_colormanagement_check_file_config(Main *bmain)
for (scene = bmain->scene.first; scene; scene = scene->id.next) {
ColorManagedColorspaceSettings *sequencer_colorspace_settings;
/* check scene color management settings */
colormanage_check_display_settings(&scene->display_settings, "scene", default_display);
colormanage_check_view_settings(&scene->display_settings, &scene->view_settings, "scene");
@ -1122,6 +1124,15 @@ void IMB_colormanagement_check_file_config(Main *bmain)
if (sequencer_colorspace_settings->name[0] == '\0') {
BLI_strncpy(sequencer_colorspace_settings->name, global_role_default_sequencer, MAX_COLORSPACE_NAME);
}
/* check sequencer strip input color space settings */
Sequence *seq;
SEQ_BEGIN (scene->ed, seq) {
if (seq->strip) {
colormanage_check_colorspace_settings(&seq->strip->colorspace_settings, "sequencer strip");
}
}
SEQ_END
}
/* ** check input color space settings ** */