Page MenuHome
Paste P856

(An Untitled Masterwork)
ActivePublic

Authored by Brecht Van Lommel (brecht) on Dec 3 2018, 1:46 PM.
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index c07c19f..1a9ce60 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1776,38 +1776,7 @@ static void drawHelpline(bContext *C, int x, int y, void *customdata)
(float)t->mval[1],
};
- /* grease pencil only can edit one object at time because GP has
- * multiframe edition that replaces multiobject edition.
- * If multiobject edition is added, maybe this code will need
- * an update
- */
- if ((t->flag & T_POINTS) && (t->options & CTX_GPENCIL_STROKES)) {
- Object *ob = CTX_data_active_object(C);
- if ((ob) && (ob->type == OB_GPENCIL)) {
- float vecrot[3];
- switch (t->around) {
- case V3D_AROUND_CURSOR:
- {
- copy_v3_v3(vecrot, t->scene->cursor.location);
- break;
- }
- default:
- {
- add_v3_v3v3(vecrot, t->center_global, ob->obmat[3]);
- break;
- }
- }
- projectFloatViewEx(t, vecrot, cent, V3D_PROJ_TEST_CLIP_ZERO);
- }
- else {
- /* normally, never must be used */
- projectFloatViewEx(t, t->center_global, cent, V3D_PROJ_TEST_CLIP_ZERO);
- }
- }
- else {
projectFloatViewEx(t, t->center_global, cent, V3D_PROJ_TEST_CLIP_ZERO);
- }
-
/* Offset the values for the area region. */
const float offset[2] = {
t->ar->winrct.xmin,
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index db6712d..fe997b7 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -835,16 +835,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
immUniformThemeColor(TH_GRID);
set_inverted_drawing(1);
- if (t->options & CTX_GPENCIL_STROKES) {
- Base *base = t->view_layer->basact;
- Object *ob = base->object;
- float v[3];
- add_v3_v3v3(v, t->center_global, ob->obmat[3]);
- imm_drawcircball(v, t->prop_size, imat, pos);
- }
- else {
- imm_drawcircball(t->center_global, t->prop_size, imat, pos);
- }
+ imm_drawcircball(t->center_global, t->prop_size, imat, pos);
set_inverted_drawing(0);
immUnbindProgram();
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 7b0e6b1..040041f 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -8399,11 +8399,6 @@ static void createTransGPencil(bContext *C, TransInfo *t)
if ((gps->flag & (GP_STROKE_3DSPACE | GP_STROKE_2DSPACE | GP_STROKE_2DIMAGE)) == 0) {
/* screenspace */
td->protectflag = OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ;
-
- /* apply matrix transformation relative to parent */
- copy_m3_m4(td->smtx, inverse_diff_mat); /* final position */
- copy_m3_m4(td->mtx, diff_mat); /* display position */
- copy_m3_m4(td->axismtx, diff_mat); /* axis orientation */
}
else {
/* configure 2D dataspace points so that they don't play up... */
@@ -8411,12 +8406,13 @@ static void createTransGPencil(bContext *C, TransInfo *t)
td->protectflag = OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ;
// XXX: matrices may need to be different?
}
-
- /* apply parent transformations */
- copy_m3_m4(td->smtx, inverse_diff_mat); /* final position */
- copy_m3_m4(td->mtx, diff_mat); /* display position */
- copy_m3_m4(td->axismtx, diff_mat); /* axis orientation */
}
+
+ /* apply parent transformations */
+ copy_m3_m4(td->smtx, inverse_diff_mat); /* final position */
+ copy_m3_m4(td->mtx, diff_mat); /* display position */
+ copy_m3_m4(td->axismtx, diff_mat); /* axis orientation */
+
/* Triangulation must be calculated again, so save the stroke for recalc function */
td->extra = gps;
@@ -8443,29 +8439,6 @@ static void createTransGPencil(bContext *C, TransInfo *t)
}
}
}
-
- /* set global center */
- CLAMP_MIN(totselected, 1);
- mul_v3_fl(global_center, 1.0f / totselected);
- add_v3_v3(t->center_global, global_center);
-
- /* always rotate in its own space (no other object active) */
- if (t->around == V3D_AROUND_ACTIVE) {
- t->around = V3D_AROUND_LOCAL_ORIGINS;
- }
- switch (t->around) {
- case V3D_AROUND_CURSOR:
- {
- copy_v3_v3(t->center_global, t->scene->cursor.location);
- break;
- }
- default:
- {
- add_v3_v3(t->center_global, obact->obmat[3]);
- break;
- }
- }
-
}
static int countAndCleanTransDataContainer(TransInfo *t)
@@ -8541,6 +8514,7 @@ void createTransData(bContext *C, TransInfo *t)
t->options |= CTX_GPENCIL_STROKES;
t->flag |= T_POINTS;
+ initTransDataContainers_FromObjectData(t, ob, NULL, 0);
createTransGPencil(C, t);
countAndCleanTransDataContainer(t);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 0a7d139..2e358c1 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1203,7 +1203,7 @@ void initTransDataContainers_FromObjectData(TransInfo *t, Object *obact, Object
const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT;
const short object_type = obact ? obact->type : -1;
- if ((object_mode & OB_MODE_EDIT) ||
+ if ((object_mode & OB_MODE_EDIT) || (t->options & CTX_GPENCIL_STROKES) ||
((object_mode & OB_MODE_POSE) && (object_type == OB_ARMATURE)))
{
if (t->data_container) {
@@ -1238,6 +1238,9 @@ void initTransDataContainers_FromObjectData(TransInfo *t, Object *obact, Object
tc->poseobj = objects[i];
tc->use_local_mat = true;
}
+ else if (t->options & CTX_GPENCIL_STROKES) {
+ tc->use_local_mat = true;
+ }
if (tc->use_local_mat) {
BLI_assert((t->flag & T_2D_EDIT) == 0);
@@ -1874,22 +1877,6 @@ void calculateCenterCursor(TransInfo *t, float r_center[3])
}
r_center[2] = 0.0f;
}
- else if (t->options & CTX_GPENCIL_STROKES) {
- /* move cursor in local space */
- TransData *td = NULL;
- FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- float mat[3][3], imat[3][3];
-
- td = tc->data;
- Object *ob = td->ob;
- if (ob) {
- sub_v3_v3v3(r_center, r_center, ob->obmat[3]);
- copy_m3_m4(mat, ob->obmat);
- invert_m3_m3(imat, mat);
- mul_m3_v3(imat, r_center);
- }
- }
- }
}
void calculateCenterCursor2D(TransInfo *t, float r_center[2])