GPencil: Add new parameteres to transform layers
When using grease pencil for drawing Storyboards, it's very common to require a transform of the layers. This transform can be done using the offset modifier, but in some cases, the scene requires a lot of modifiers and makes the file hard to work.
This new feature adds a transforms Location, Rotation and Scale at Layer level, and allows to transform the layer without using a modifier, keeping the scene more clean.
{F9480695}
This feature was suggested by @pepeland after receiving feedback from several artists.
Also, done some code cleanup and rename some functions to get a better naming.
Maniphest Tasks: T83660
Differential Revision: https://developer.blender.org/D9761
			
			
This commit is contained in:
		@@ -258,6 +258,16 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata)
 | 
			
		||||
 | 
			
		||||
    copy_m4_m4(mat, ob->obmat);
 | 
			
		||||
 | 
			
		||||
    /* Rotate and scale except align to cursor. */
 | 
			
		||||
    bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
 | 
			
		||||
    if (gpl != NULL) {
 | 
			
		||||
      if (ts->gp_sculpt.lock_axis != GP_LOCKAXIS_CURSOR) {
 | 
			
		||||
        float matrot[3][3];
 | 
			
		||||
        copy_m3_m4(matrot, gpl->layer_mat);
 | 
			
		||||
        mul_m4_m4m3(mat, mat, matrot);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    float viewinv[4][4];
 | 
			
		||||
    /* Set the grid in the selected axis */
 | 
			
		||||
    switch (ts->gp_sculpt.lock_axis) {
 | 
			
		||||
@@ -294,6 +304,11 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata)
 | 
			
		||||
    mul_v2_v2fl(size, gpd->grid.scale, 2.0f * ED_scene_grid_scale(scene, &grid_unit));
 | 
			
		||||
    rescale_m4(mat, (float[3]){size[0], size[1], 0.0f});
 | 
			
		||||
 | 
			
		||||
    /* Apply layer loc transform, except cursor mode. */
 | 
			
		||||
    if ((gpl != NULL) && (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) {
 | 
			
		||||
      add_v3_v3(mat[3], gpl->layer_mat[3]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const int gridlines = (gpd->grid.lines <= 0) ? 1 : gpd->grid.lines;
 | 
			
		||||
    int line_ct = gridlines * 4 + 2;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -800,20 +800,20 @@ static void gpencil_edit_curve_stroke_iter_cb(bGPDlayer *gpl,
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /* First segment. */
 | 
			
		||||
    copy_v3_v3(vert_ptr->pos, bezt->vec[0]);
 | 
			
		||||
    mul_v3_m4v3(vert_ptr->pos, gpl->layer_mat, bezt->vec[0]);
 | 
			
		||||
    vert_ptr->data = vflag[0];
 | 
			
		||||
    vert_ptr++;
 | 
			
		||||
 | 
			
		||||
    copy_v3_v3(vert_ptr->pos, bezt->vec[1]);
 | 
			
		||||
    mul_v3_m4v3(vert_ptr->pos, gpl->layer_mat, bezt->vec[1]);
 | 
			
		||||
    vert_ptr->data = vflag[1];
 | 
			
		||||
    vert_ptr++;
 | 
			
		||||
 | 
			
		||||
    /* Second segment. */
 | 
			
		||||
    copy_v3_v3(vert_ptr->pos, bezt->vec[1]);
 | 
			
		||||
    mul_v3_m4v3(vert_ptr->pos, gpl->layer_mat, bezt->vec[1]);
 | 
			
		||||
    vert_ptr->data = vflag[1];
 | 
			
		||||
    vert_ptr++;
 | 
			
		||||
 | 
			
		||||
    copy_v3_v3(vert_ptr->pos, bezt->vec[2]);
 | 
			
		||||
    mul_v3_m4v3(vert_ptr->pos, gpl->layer_mat, bezt->vec[2]);
 | 
			
		||||
    vert_ptr->data = vflag[2];
 | 
			
		||||
    vert_ptr++;
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user