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>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/blenkernel/intern/tracking_detect.c
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/blenkernel/intern/tracking_detect.c')
-rw-r--r--source/blender/blenkernel/intern/tracking_detect.c216
1 files changed, 118 insertions, 98 deletions
diff --git a/source/blender/blenkernel/intern/tracking_detect.c b/source/blender/blenkernel/intern/tracking_detect.c
index 237adc80890..36d44f8fa5d 100644
--- a/source/blender/blenkernel/intern/tracking_detect.c
+++ b/source/blender/blenkernel/intern/tracking_detect.c
@@ -25,7 +25,7 @@
#include "DNA_gpencil_types.h"
#include "DNA_movieclip_types.h"
-#include "DNA_object_types.h" /* SELECT */
+#include "DNA_object_types.h" /* SELECT */
#include "BLI_utildefines.h"
@@ -38,138 +38,158 @@
/* Check whether point is inside grease pencil stroke. */
static bool check_point_in_stroke(bGPDstroke *stroke, float x, float y)
{
- int i, prev;
- int count = 0;
- bGPDspoint *points = stroke->points;
+ int i, prev;
+ int count = 0;
+ bGPDspoint *points = stroke->points;
- /* Count intersections of horizontal ray coming from the point.
- * Point will be inside layer if and only if number of intersection
- * is uneven.
- *
- * Well, if layer has got self-intersections, this logic wouldn't
- * work, but such situation is crappy anyway.
- */
+ /* Count intersections of horizontal ray coming from the point.
+ * Point will be inside layer if and only if number of intersection
+ * is uneven.
+ *
+ * Well, if layer has got self-intersections, this logic wouldn't
+ * work, but such situation is crappy anyway.
+ */
- prev = stroke->totpoints - 1;
+ prev = stroke->totpoints - 1;
- for (i = 0; i < stroke->totpoints; i++) {
- if ((points[i].y < y && points[prev].y >= y) || (points[prev].y < y && points[i].y >= y)) {
- float fac = (y - points[i].y) / (points[prev].y - points[i].y);
+ for (i = 0; i < stroke->totpoints; i++) {
+ if ((points[i].y < y && points[prev].y >= y) || (points[prev].y < y && points[i].y >= y)) {
+ float fac = (y - points[i].y) / (points[prev].y - points[i].y);
- if (points[i].x + fac * (points[prev].x - points[i].x) < x)
- count++;
- }
+ if (points[i].x + fac * (points[prev].x - points[i].x) < x)
+ count++;
+ }
- prev = i;
- }
+ prev = i;
+ }
- return (count % 2) ? true : false;
+ return (count % 2) ? true : false;
}
/* Check whether point is inside any stroke of grease pencil layer. */
static bool check_point_in_layer(bGPDlayer *layer, float x, float y)
{
- bGPDframe *frame = layer->frames.first;
+ bGPDframe *frame = layer->frames.first;
- while (frame) {
- bGPDstroke *stroke = frame->strokes.first;
+ while (frame) {
+ bGPDstroke *stroke = frame->strokes.first;
- while (stroke) {
- if (check_point_in_stroke(stroke, x, y))
- return true;
+ while (stroke) {
+ if (check_point_in_stroke(stroke, x, y))
+ return true;
- stroke = stroke->next;
- }
- frame = frame->next;
- }
+ stroke = stroke->next;
+ }
+ frame = frame->next;
+ }
- return false;
+ return false;
}
/* Get features detected by libmv and create tracks on the clip for them. */
-static void detect_retrieve_libmv_features(MovieTracking *tracking, ListBase *tracksbase,
- struct libmv_Features *features, int framenr, int width, int height,
- bGPDlayer *layer, bool place_outside_layer)
+static void detect_retrieve_libmv_features(MovieTracking *tracking,
+ ListBase *tracksbase,
+ struct libmv_Features *features,
+ int framenr,
+ int width,
+ int height,
+ bGPDlayer *layer,
+ bool place_outside_layer)
{
- int a;
-
- a = libmv_countFeatures(features);
- while (a--) {
- MovieTrackingTrack *track;
- double x, y, size, score;
- bool ok = true;
- float xu, yu;
-
- libmv_getFeature(features, a, &x, &y, &score, &size);
-
- /* In Libmv integer coordinate points to pixel center, in blender
- * it's not. Need to add 0.5px offset to center.
- */
- xu = (x + 0.5) / width;
- yu = (y + 0.5) / height;
-
- if (layer)
- ok = check_point_in_layer(layer, xu, yu) != place_outside_layer;
-
- if (ok) {
- track = BKE_tracking_track_add(tracking, tracksbase, xu, yu, framenr, width, height);
- track->flag |= SELECT;
- track->pat_flag |= SELECT;
- track->search_flag |= SELECT;
- }
- }
+ int a;
+
+ a = libmv_countFeatures(features);
+ while (a--) {
+ MovieTrackingTrack *track;
+ double x, y, size, score;
+ bool ok = true;
+ float xu, yu;
+
+ libmv_getFeature(features, a, &x, &y, &score, &size);
+
+ /* In Libmv integer coordinate points to pixel center, in blender
+ * it's not. Need to add 0.5px offset to center.
+ */
+ xu = (x + 0.5) / width;
+ yu = (y + 0.5) / height;
+
+ if (layer)
+ ok = check_point_in_layer(layer, xu, yu) != place_outside_layer;
+
+ if (ok) {
+ track = BKE_tracking_track_add(tracking, tracksbase, xu, yu, framenr, width, height);
+ track->flag |= SELECT;
+ track->pat_flag |= SELECT;
+ track->search_flag |= SELECT;
+ }
+ }
}
-static void run_configured_detector(MovieTracking *tracking, ListBase *tracksbase,
- ImBuf *ibuf, int framenr, bGPDlayer *layer, bool place_outside_layer,
+static void run_configured_detector(MovieTracking *tracking,
+ ListBase *tracksbase,
+ ImBuf *ibuf,
+ int framenr,
+ bGPDlayer *layer,
+ bool place_outside_layer,
libmv_DetectOptions *options)
{
- struct libmv_Features *features = NULL;
-
- if (ibuf->rect_float) {
- features = libmv_detectFeaturesFloat(ibuf->rect_float, ibuf->x, ibuf->y, 4, options);
- }
- else if (ibuf->rect) {
- features = libmv_detectFeaturesByte((unsigned char *) ibuf->rect, ibuf->x, ibuf->y, 4, options);
- }
-
- if (features != NULL) {
- detect_retrieve_libmv_features(tracking, tracksbase, features,
- framenr, ibuf->x, ibuf->y, layer,
- place_outside_layer);
-
- libmv_featuresDestroy(features);
- }
+ struct libmv_Features *features = NULL;
+
+ if (ibuf->rect_float) {
+ features = libmv_detectFeaturesFloat(ibuf->rect_float, ibuf->x, ibuf->y, 4, options);
+ }
+ else if (ibuf->rect) {
+ features = libmv_detectFeaturesByte((unsigned char *)ibuf->rect, ibuf->x, ibuf->y, 4, options);
+ }
+
+ if (features != NULL) {
+ detect_retrieve_libmv_features(
+ tracking, tracksbase, features, framenr, ibuf->x, ibuf->y, layer, place_outside_layer);
+
+ libmv_featuresDestroy(features);
+ }
}
/* Detect features using FAST detector */
-void BKE_tracking_detect_fast(MovieTracking *tracking, ListBase *tracksbase, ImBuf *ibuf,
- int framenr, int margin, int min_trackness, int min_distance, bGPDlayer *layer,
+void BKE_tracking_detect_fast(MovieTracking *tracking,
+ ListBase *tracksbase,
+ ImBuf *ibuf,
+ int framenr,
+ int margin,
+ int min_trackness,
+ int min_distance,
+ bGPDlayer *layer,
bool place_outside_layer)
{
- libmv_DetectOptions options = {0};
+ libmv_DetectOptions options = {0};
- options.detector = LIBMV_DETECTOR_FAST;
- options.margin = margin;
- options.min_distance = min_distance;
- options.fast_min_trackness = min_trackness;
+ options.detector = LIBMV_DETECTOR_FAST;
+ options.margin = margin;
+ options.min_distance = min_distance;
+ options.fast_min_trackness = min_trackness;
- run_configured_detector(tracking, tracksbase, ibuf, framenr, layer,
- place_outside_layer, &options);
+ run_configured_detector(
+ tracking, tracksbase, ibuf, framenr, layer, place_outside_layer, &options);
}
/* Detect features using Harris detector */
-void BKE_tracking_detect_harris(MovieTracking *tracking, ListBase *tracksbase, ImBuf *ibuf,
- int framenr, int margin, float threshold, int min_distance, bGPDlayer *layer,
+void BKE_tracking_detect_harris(MovieTracking *tracking,
+ ListBase *tracksbase,
+ ImBuf *ibuf,
+ int framenr,
+ int margin,
+ float threshold,
+ int min_distance,
+ bGPDlayer *layer,
bool place_outside_layer)
{
- libmv_DetectOptions options = {0};
+ libmv_DetectOptions options = {0};
- options.detector = LIBMV_DETECTOR_HARRIS;
- options.margin = margin;
- options.min_distance = min_distance;
- options.harris_threshold = threshold;
+ options.detector = LIBMV_DETECTOR_HARRIS;
+ options.margin = margin;
+ options.min_distance = min_distance;
+ options.harris_threshold = threshold;
- run_configured_detector(tracking, tracksbase, ibuf, framenr, layer,
- place_outside_layer, &options);
+ run_configured_detector(
+ tracking, tracksbase, ibuf, framenr, layer, place_outside_layer, &options);
}