Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2020-03-17 19:09:20 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-03-17 19:28:49 +0300
commit2518f601094bfa14474c24c3a1e640b9fca0e6e2 (patch)
treee08f9598b274a575506a0ec2302ff29ecc3849d6 /source
parent964375e36a2b2a56d12201a3a96dd4572e0a8827 (diff)
GPencil: Fix Parent layer not working
The parenting was using the old logic, but with new engine the draw is done using eval data. Fixed the depsgraph relationship missing with bones to get an update when the bone is transformed. Also fixed Snap cursor to Selected
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/gpencil.c33
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc15
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c12
3 files changed, 33 insertions, 27 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index c0b40721ccc..0be92b7533d 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -4034,42 +4034,35 @@ void BKE_gpencil_update_layer_parent(const Depsgraph *depsgraph, Object *ob)
}
bGPdata *gpd = (bGPdata *)ob->data;
- bGPDspoint *pt;
- int i;
- float diff_mat[4][4];
float cur_mat[4][4];
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
if ((gpl->parent != NULL) && (gpl->actframe != NULL)) {
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, gpl->parent);
-
+ Object *ob_parent = DEG_get_evaluated_object(depsgraph, gpl->parent);
/* calculate new matrix */
if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) {
- invert_m4_m4(cur_mat, ob_eval->obmat);
+ copy_m4_m4(cur_mat, ob_parent->obmat);
}
else if (gpl->partype == PARBONE) {
- bPoseChannel *pchan = BKE_pose_channel_find_name(ob_eval->pose, gpl->parsubstr);
- if (pchan) {
- float tmp_mat[4][4];
- mul_m4_m4m4(tmp_mat, ob_eval->obmat, pchan->pose_mat);
- invert_m4_m4(cur_mat, tmp_mat);
+ bPoseChannel *pchan = BKE_pose_channel_find_name(ob_parent->pose, gpl->parsubstr);
+ if (pchan != NULL) {
+ copy_m4_m4(cur_mat, ob->imat);
+ mul_m4_m4m4(cur_mat, ob_parent->obmat, pchan->pose_mat);
+ }
+ else {
+ unit_m4(cur_mat);
}
}
/* only redo if any change */
if (!equals_m4m4(gpl->inverse, cur_mat)) {
-
- /* first apply current transformation to all strokes */
- BKE_gpencil_parent_matrix_get(depsgraph, ob, gpl, diff_mat);
- /* undo local object */
- sub_v3_v3(diff_mat[3], ob->obmat[3]);
-
LISTBASE_FOREACH (bGPDstroke *, gps, &gpl->actframe->strokes) {
+ bGPDspoint *pt;
+ int i;
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- mul_m4_v3(diff_mat, &pt->x);
+ mul_m4_v3(gpl->inverse, &pt->x);
+ mul_m4_v3(cur_mat, &pt->x);
}
}
- /* set new parent matrix */
- copy_m4_m4(gpl->inverse, cur_mat);
}
}
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 6791125d1e9..27d6db6a58f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -2127,9 +2127,20 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
/* Layer parenting need react to the parent object transformation. */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
if (gpl->parent != NULL) {
- ComponentKey transform_key(&gpl->parent->id, NodeType::TRANSFORM);
ComponentKey gpd_geom_key(&gpd->id, NodeType::GEOMETRY);
- add_relation(transform_key, gpd_geom_key, "GPencil Parent Layer");
+
+ if (gpl->partype == PARBONE) {
+ ComponentKey bone_key(&gpl->parent->id, NodeType::BONE, gpl->parsubstr);
+ OperationKey armature_key(
+ &gpl->parent->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL);
+
+ add_relation(bone_key, gpd_geom_key, "Bone Parent");
+ add_relation(armature_key, gpd_geom_key, "Armature Parent");
+ }
+ else {
+ ComponentKey transform_key(&gpl->parent->id, NodeType::TRANSFORM);
+ add_relation(transform_key, gpd_geom_key, "GPencil Parent Layer");
+ }
}
}
break;
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index f8ad34e8d14..00fc6550459 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -2597,10 +2597,11 @@ void GPENCIL_OT_dissolve(wmOperatorType *ot)
*/
static bool gp_snap_poll(bContext *C)
{
- bGPdata *gpd = CTX_data_gpencil_data(C);
ScrArea *sa = CTX_wm_area(C);
+ Object *ob = CTX_data_active_object(C);
- return (gpd != NULL) && ((sa != NULL) && (sa->spacetype == SPACE_VIEW3D));
+ return (ob != NULL) && (ob->type == OB_GPENCIL) &&
+ ((sa != NULL) && (sa->spacetype == SPACE_VIEW3D));
}
/* --------------------------------- */
@@ -2775,12 +2776,13 @@ void GPENCIL_OT_snap_to_cursor(wmOperatorType *ot)
static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
{
- bGPdata *gpd = ED_gpencil_data_get_active(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ Object *obact = CTX_data_active_object(C);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, obact);
+ bGPdata *gpd = (bGPdata *)ob_eval->data;
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
- Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- Object *obact = CTX_data_active_object(C);
float *cursor = scene->cursor.location;
float centroid[3] = {0.0f};