diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/intern/voronoi.c | 2 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_KeyingScreenOperation.cpp | 35 |
2 files changed, 29 insertions, 8 deletions
diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index eeb0187b74c..dc76fb1493d 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -39,7 +39,7 @@ #include "BLI_voronoi.h" #include "BLI_utildefines.h" -#define VORONOI_EPS 1e-3 +#define VORONOI_EPS 1e-2 enum { voronoiEventType_Site = 0, diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp index 53572162b9e..cf20712cfeb 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp @@ -104,10 +104,20 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri /* count sites */ for (track = (MovieTrackingTrack *) tracksbase->first, sites_total = 0; track; track = track->next) { MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame); + float pos[2]; - if ((marker->flag & MARKER_DISABLED) == 0) { - sites_total++; + if (marker->flag & MARKER_DISABLED) + continue; + + add_v2_v2v2(pos, marker->pos, track->offset); + + if (!IN_RANGE_INCL(pos[0], 0.0f, 1.0f) || + !IN_RANGE_INCL(pos[1], 0.0f, 1.0f)) + { + continue; } + + sites_total++; } if (!sites_total) @@ -128,10 +138,19 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri VoronoiSite *site; ImBuf *pattern_ibuf; int j; + float pos[2]; if (marker->flag & MARKER_DISABLED) continue; + add_v2_v2v2(pos, marker->pos, track->offset); + + if (!IN_RANGE_INCL(pos[0], 0.0f, 1.0f) || + !IN_RANGE_INCL(pos[1], 0.0f, 1.0f)) + { + continue; + } + site = &sites[i]; pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE); @@ -153,8 +172,8 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y)); IMB_freeImBuf(pattern_ibuf); - site->co[0] = marker->pos[0] * width; - site->co[1] = marker->pos[1] * height; + site->co[0] = pos[0] * width; + site->co[1] = pos[1] * height; } IMB_freeImBuf(ibuf); @@ -308,9 +327,11 @@ void KeyingScreenOperation::executePixel(float *color, int x, int y, MemoryBuffe if (barycentric_coords_v2(a->co, b->co, c->co, co, w)) { if (barycentric_inside_triangle_v2(w)) { - color[0] += a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2]; - color[1] += a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2]; - color[2] += a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2]; + color[0] = a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2]; + color[1] = a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2]; + color[2] = a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2]; + + break; } } } |