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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-07-26 00:39:49 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-26 00:39:49 +0400
commit2b133b14ab1b37f80f94a7a411ee116e095c9b8d (patch)
treef5651e0b9d13fe68946e0362a69083bd14f3f5f4 /source/blender/blenkernel/intern/mask.c
parent8ad3e7396597ffcf56f3ad74c00dfc6fdcd504df (diff)
mask/image viewer now works with non 1:1 image aspect, editing masks in the image viewer should be generally usable now though still some TODO's left.
Diffstat (limited to 'source/blender/blenkernel/intern/mask.c')
-rw-r--r--source/blender/blenkernel/intern/mask.c54
1 files changed, 35 insertions, 19 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 6d49137d892..d963d46569a 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -1494,48 +1494,64 @@ void BKE_mask_unlink(Main *bmain, Mask *mask)
mask->id.us = 0;
}
-void BKE_mask_coord_from_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
+void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2])
{
- int width, height;
-
- /* scaling for the clip */
- BKE_movieclip_get_size(clip, user, &width, &height);
-
- if (width == height) {
+ if (frame_size[0] == frame_size[1]) {
r_co[0] = co[0];
r_co[1] = co[1];
}
- else if (width < height) {
- r_co[0] = ((co[0] - 0.5f) * ((float)width / (float)height)) + 0.5f;
+ else if (frame_size[0] < frame_size[1]) {
+ r_co[0] = ((co[0] - 0.5f) * (frame_size[0] / frame_size[1])) + 0.5f;
r_co[1] = co[1];
}
- else { /* (width > height) */
+ else { /* (frame_size[0] > frame_size[1]) */
r_co[0] = co[0];
- r_co[1] = ((co[1] - 0.5f) * ((float)height / (float)width)) + 0.5f;
+ r_co[1] = ((co[1] - 0.5f) * (frame_size[1] / frame_size[0])) + 0.5f;
}
}
-
-/* as above but divide */
-void BKE_mask_coord_to_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
+void BKE_mask_coord_from_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
{
int width, height;
+ float frame_size[2];
/* scaling for the clip */
BKE_movieclip_get_size(clip, user, &width, &height);
- if (width == height) {
+ frame_size[0] = (float)width;
+ frame_size[1] = (float)height;
+
+ BKE_mask_coord_from_frame(r_co, co, frame_size);
+}
+
+/* as above but divide */
+void BKE_mask_coord_to_frame(float r_co[2], const float co[2], const float frame_size[2])
+{
+ if (frame_size[0] == frame_size[1]) {
r_co[0] = co[0];
r_co[1] = co[1];
}
- else if (width < height) {
- r_co[0] = ((co[0] - 0.5f) / ((float)width / (float)height)) + 0.5f;
+ else if (frame_size[0] < frame_size[1]) {
+ r_co[0] = ((co[0] - 0.5f) / (frame_size[0] / frame_size[1])) + 0.5f;
r_co[1] = co[1];
}
- else { /* (width > height) */
+ else { /* (frame_size[0] > frame_size[1]) */
r_co[0] = co[0];
- r_co[1] = ((co[1] - 0.5f) / ((float)height / (float)width)) + 0.5f;
+ r_co[1] = ((co[1] - 0.5f) / (frame_size[1] / frame_size[0])) + 0.5f;
}
}
+void BKE_mask_coord_to_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
+{
+ int width, height;
+ float frame_size[2];
+
+ /* scaling for the clip */
+ BKE_movieclip_get_size(clip, user, &width, &height);
+
+ frame_size[0] = (float)width;
+ frame_size[1] = (float)height;
+
+ BKE_mask_coord_to_frame(r_co, co, frame_size);
+}
static int BKE_mask_evaluate_parent(MaskParent *parent, float ctime, float r_co[2])
{