[Bf-blender-cvs] [46060d54bff] blender2.8: GP: Limit internally Time offset to something logic

Antonioya noreply at git.blender.org
Mon Nov 5 19:53:00 CET 2018


Commit: 46060d54bffe48fe4cb46fe101ae79246b2b5513
Author: Antonioya
Date:   Mon Nov 5 19:51:22 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB46060d54bffe48fe4cb46fe101ae79246b2b5513

GP: Limit internally Time offset to something logic

If the offset is greater than frame range, the offset could gets some unlogic values, so now the value is normalized in the range.

===================================================================

M	source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c

===================================================================

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
index 3d8eb50192b..861b255d760 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
@@ -78,6 +78,8 @@ static int remapTime(
 	int efra = custom ? mmd->efra : scene->r.efra;
 	CLAMP_MIN(sfra, 1);
 	CLAMP_MIN(efra, 1);
+	const int time = efra - sfra + 1;
+	int offset = mmd->offset;
 
 	/* omit if filter by layer */
 	if (mmd->layername[0] != '\0') {
@@ -108,7 +110,7 @@ static int remapTime(
 
 	/* if fix mode, return predefined frame number */
 	if (mmd->mode == GP_TIME_MODE_FIX) {
-		return mmd->offset;
+		return offset;
 	}
 
 	/* invert current frame number */
@@ -119,35 +121,39 @@ static int remapTime(
 	/* apply frame scale */
 	cfra *= mmd->frame_scale;
 
+	/* verify offset never is greater than farme range */
+	if (abs(offset) > time) {
+		offset = offset - ((offset / time) * time);
+	}
+
 	/* verify not outside range if loop is disabled */
 	if ((mmd->flag & GP_TIME_KEEP_LOOP) == 0) {
-		if (cfra + mmd->offset < sfra) {
+		if (cfra + offset < sfra) {
 			return sfra;
 		}
-		if (cfra + mmd->offset > efra) {
+		if (cfra + offset > efra) {
 			return efra;
 		}
 	}
 
 	if (cfra >= efra) {
-		int delta = efra - sfra + 1;
-		cfra = sfra + (cfra - ((cfra / delta) * delta)) - 1;
+		cfra = sfra + (cfra - ((cfra / time) * time)) - 1;
 	}
 
 	if (mmd->flag & GP_TIME_KEEP_LOOP) {
-		const int nfra = cfra + mmd->offset;
+		const int nfra = cfra + offset;
 
 		/* if the sum of the cfra is out scene frame range, recalc */
-		if (cfra + mmd->offset < sfra) {
+		if (cfra + offset < sfra) {
 			const int delta = abs(sfra - nfra);
 			return efra - delta + 1;
 		}
-		else if (cfra + mmd->offset > efra) {
+		else if (cfra + offset > efra) {
 			return nfra - efra + sfra - 1;
 		}
 	}
 
-	return cfra + mmd->offset;
+	return cfra + offset;
 }
 
 GpencilModifierTypeInfo modifierType_Gpencil_Time = {



More information about the Bf-blender-cvs mailing list