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>2019-09-21 17:13:23 +0300
committerAntonio Vazquez <blendergit@gmail.com>2019-09-21 17:13:30 +0300
commita5b15931c3860a32824f23344ec4d1d199700e97 (patch)
treead015e5b97dd88caa69aa4d873f4c507c8e7a49e /source
parentef45d1c8cd4313e3efb409ad5e5f8bfb29c826aa (diff)
GPencil: Apply transformed rotation only if needed
If there aren't modifiers or they are not transform type, the rotation is not needed.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_gpencil_modifier.h1
-rw-r--r--source/blender/blenkernel/intern/gpencil_modifier.c17
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c23
3 files changed, 34 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil_modifier.h b/source/blender/blenkernel/BKE_gpencil_modifier.h
index ba2e1e85d23..eb2279c4f48 100644
--- a/source/blender/blenkernel/BKE_gpencil_modifier.h
+++ b/source/blender/blenkernel/BKE_gpencil_modifier.h
@@ -297,6 +297,7 @@ void BKE_gpencil_modifiers_foreachTexLink(struct Object *ob,
bool BKE_gpencil_has_geometry_modifiers(struct Object *ob);
bool BKE_gpencil_has_time_modifiers(struct Object *ob);
+bool BKE_gpencil_has_transform_modifiers(struct Object *ob);
void BKE_gpencil_stroke_modifiers(struct Depsgraph *depsgraph,
struct Object *ob,
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 1750a389788..fe087256d25 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -340,6 +340,23 @@ bool BKE_gpencil_has_time_modifiers(Object *ob)
return false;
}
+/* Check if exist transform stroke modifiers (to rotate sculpt or edit). */
+bool BKE_gpencil_has_transform_modifiers(Object *ob)
+{
+ GpencilModifierData *md;
+ for (md = ob->greasepencil_modifiers.first; md; md = md->next) {
+ /* Only if enabled in edit mode. */
+ if (!GPENCIL_MODIFIER_EDIT(md, true) && GPENCIL_MODIFIER_ACTIVE(md, false)) {
+ if ((md->type == eGpencilModifierType_Armature) || (md->type == eGpencilModifierType_Hook) ||
+ (md->type == eGpencilModifierType_Lattice) ||
+ (md->type == eGpencilModifierType_Offset)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
/* apply stroke modifiers */
void BKE_gpencil_stroke_modifiers(Depsgraph *depsgraph,
Object *ob,
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index f894c362848..7c9a04bef65 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -52,6 +52,7 @@
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil.h"
+#include "BKE_gpencil_modifier.h"
#include "BKE_material.h"
#include "BKE_object_deform.h"
#include "BKE_report.h"
@@ -109,6 +110,7 @@ typedef struct tGP_BrushEditData {
/* Is the brush currently painting? */
bool is_painting;
bool is_weight_mode;
+ bool is_transformed;
/* Start of new sculpt stroke */
bool first;
@@ -1326,9 +1328,12 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
if (!BLI_findlink(&ob->defbase, gso->vrgroup)) {
gso->vrgroup = -1;
}
+ /* Check if some modifier can transform the stroke. */
+ gso->is_transformed = BKE_gpencil_has_transform_modifiers(ob);
}
else {
gso->vrgroup = -1;
+ gso->is_transformed = false;
}
gso->sa = CTX_wm_area(C);
@@ -1506,12 +1511,17 @@ static void gpsculpt_brush_init_stroke(bContext *C, tGP_BrushEditData *gso)
* For strokes with one point only this is impossible to calculate because there isn't a
* valid reference point.
*/
-static float gpsculpt_rotation_eval_get(GP_SpaceConversion *gsc,
+static float gpsculpt_rotation_eval_get(tGP_BrushEditData *gso,
bGPDstroke *gps_eval,
bGPDspoint *pt_eval,
int idx_eval)
{
+ /* If multiframe or no modifiers, return 0. */
+ if ((GPENCIL_MULTIEDIT_SESSIONS_ON(gso->gpd)) || (!gso->is_transformed)) {
+ return 0.0f;
+ }
+ GP_SpaceConversion *gsc = &gso->gsc;
bGPDstroke *gps_orig = gps_eval->runtime.gps_orig;
bGPDspoint *pt_orig = &gps_orig->points[pt_eval->runtime.idx_orig];
bGPDspoint *pt_prev_eval = NULL;
@@ -1594,7 +1604,7 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso,
if (len_v2v2_int(mval_i, pc1) <= radius) {
/* apply operation to this point */
if (pt_active != NULL) {
- rot_eval = (!is_multiedit) ? gpsculpt_rotation_eval_get(&gso->gsc, gps, pt, 0) : 0.0f;
+ rot_eval = gpsculpt_rotation_eval_get(gso, gps, pt, 0);
changed = apply(gso, gps_active, rot_eval, 0, radius, pc1);
}
}
@@ -1639,9 +1649,9 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso,
/* To each point individually... */
pt = &gps->points[i];
pt_active = (!is_multiedit) ? pt->runtime.pt_orig : pt;
- int index = (!is_multiedit) ? pt->runtime.idx_orig : i;
+ index = (!is_multiedit) ? pt->runtime.idx_orig : i;
if (pt_active != NULL) {
- rot_eval = (!is_multiedit) ? gpsculpt_rotation_eval_get(&gso->gsc, gps, pt, i) : 0.0f;
+ rot_eval = gpsculpt_rotation_eval_get(gso, gps, pt, i);
ok = apply(gso, gps_active, rot_eval, index, radius, pc1);
}
@@ -1658,8 +1668,7 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso,
pt_active = (!is_multiedit) ? pt->runtime.pt_orig : pt;
index = (!is_multiedit) ? pt->runtime.idx_orig : i;
if (pt->runtime.pt_orig != NULL) {
- rot_eval = (!is_multiedit) ? gpsculpt_rotation_eval_get(
- &gso->gsc, gps, pt, i + 1) : 0.0f;
+ rot_eval = gpsculpt_rotation_eval_get(gso, gps, pt, i + 1);
ok |= apply(gso, gps_active, rot_eval, index, radius, pc2);
include_last = false;
}
@@ -1680,7 +1689,7 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso,
pt_active = (!is_multiedit) ? pt->runtime.pt_orig : pt;
index = (!is_multiedit) ? pt->runtime.idx_orig : i;
if (pt->runtime.pt_orig != NULL) {
- rot_eval = (!is_multiedit) ? gpsculpt_rotation_eval_get(&gso->gsc, gps, pt, i) : 0.0f;
+ rot_eval = gpsculpt_rotation_eval_get(gso, gps, pt, i);
changed |= apply(gso, gps_active, rot_eval, index, radius, pc1);
include_last = false;
}