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:
authorCampbell Barton <ideasman42@gmail.com>2013-06-25 14:49:20 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-06-25 14:49:20 +0400
commit64968e3618892ebac419149fa8c4198151a4e29a (patch)
treec54a16c2f3f4efcb6c9feb060f9aa35bffa4fa6b /source
parent37f59451889d64e588ace4f16f7eebd085d8147a (diff)
patch [#35830] Add Catmull-Rom spline as an option for lattice deformer
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/key.c27
-rw-r--r--source/blender/makesdna/DNA_key_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_key.c1
3 files changed, 30 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index dfa5fcff94c..e141b9dbabe 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -289,6 +289,16 @@ void key_curve_position_weights(float t, float data[4], int type)
data[2] = -0.5f * t3 + 0.5f * t2 + 0.5f * t + 0.16666666f;
data[3] = 0.16666666f * t3;
}
+ else if (type == KEY_CATMULL_ROM) {
+ t2 = t * t;
+ t3 = t2 * t;
+ fc = 0.5f;
+
+ data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t;
+ data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f;
+ data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t;
+ data[3] = fc * t3 - fc * t2;
+ }
}
/* first derivative */
@@ -319,6 +329,15 @@ void key_curve_tangent_weights(float t, float data[4], int type)
data[2] = -1.5f * t2 + t + 0.5f;
data[3] = 0.5f * t2;
}
+ else if (type == KEY_CATMULL_ROM) {
+ t2 = t * t;
+ fc = 0.5f;
+
+ data[0] = -3.0f * fc * t2 + 4.0f * fc * t - fc;
+ data[1] = 3.0f * (2.0f - fc) * t2 + 2.0f * (fc - 3.0f) * t;
+ data[2] = 3.0f * (fc - 2.0f) * t2 + 2.0f * (3.0f - 2.0f * fc) * t + fc;
+ data[3] = 3.0f * fc * t2 - 2.0f * fc * t;
+ }
}
/* second derivative */
@@ -346,6 +365,14 @@ void key_curve_normal_weights(float t, float data[4], int type)
data[2] = -3.0f * t + 1.0f;
data[3] = 1.0f * t;
}
+ else if (type == KEY_CATMULL_ROM) {
+ fc = 0.5f;
+
+ data[0] = -6.0f * fc * t + 4.0f * fc;
+ data[1] = 6.0f * (2.0f - fc) * t + 2.0f * (fc - 3.0f);
+ data[2] = 6.0f * (fc - 2.0f) * t + 2.0f * (3.0f - 2.0f * fc);
+ data[3] = 6.0f * fc * t - 2.0f * fc;
+ }
}
static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int cycl)
diff --git a/source/blender/makesdna/DNA_key_types.h b/source/blender/makesdna/DNA_key_types.h
index 4783247420c..0a09a82b2bb 100644
--- a/source/blender/makesdna/DNA_key_types.h
+++ b/source/blender/makesdna/DNA_key_types.h
@@ -125,7 +125,8 @@ enum {
enum {
KEY_LINEAR = 0,
KEY_CARDINAL = 1,
- KEY_BSPLINE = 2
+ KEY_BSPLINE = 2,
+ KEY_CATMULL_ROM = 3,
};
/* KeyBlock->flag */
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index 3a2677c8398..49d760adb32 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -458,6 +458,7 @@ static char *rna_ShapeKeyPoint_path(PointerRNA *ptr)
EnumPropertyItem keyblock_type_items[] = {
{KEY_LINEAR, "KEY_LINEAR", 0, "Linear", ""},
{KEY_CARDINAL, "KEY_CARDINAL", 0, "Cardinal", ""},
+ {KEY_CATMULL_ROM, "KEY_CATMULL_ROM", 0, "Catmull-Rom", ""},
{KEY_BSPLINE, "KEY_BSPLINE", 0, "BSpline", ""},
{0, NULL, 0, NULL, NULL}
};