svn merge ^/trunk/blender -r46100:46200
authorOve Murberg Henriksen <sorayasilvermoon@hotmail.com>
Sun, 6 May 2012 23:06:24 +0000 (23:06 +0000)
committerOve Murberg Henriksen <sorayasilvermoon@hotmail.com>
Sun, 6 May 2012 23:06:24 +0000 (23:06 +0000)
19 files changed:
doc/python_api/examples/bpy.ops.2.py [deleted file]
doc/python_api/examples/bpy.ops.3.py [deleted file]
extern/libmv/libmv/simple_pipeline/modal_solver.cc [deleted file]
extern/libmv/libmv/simple_pipeline/modal_solver.h [deleted file]
intern/cycles/bvh/bvh_binning.cpp [deleted file]
intern/cycles/bvh/bvh_binning.h [deleted file]
intern/cycles/bvh/bvh_split.cpp [deleted file]
intern/cycles/bvh/bvh_split.h [deleted file]
intern/cycles/util/util_task.cpp [deleted file]
intern/cycles/util/util_task.h [deleted file]
source/blender/blenlib/BLI_lasso.h [deleted file]
source/blender/blenlib/intern/lasso.c [deleted file]
source/blender/bmesh/operators/bmo_hull.c [deleted file]
source/blender/bmesh/operators/bmo_wireframe.c [deleted file]
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/space_clip/clip_dopesheet_draw.c [deleted file]
source/blender/editors/space_clip/clip_dopesheet_ops.c [deleted file]

diff --git a/doc/python_api/examples/bpy.ops.2.py b/doc/python_api/examples/bpy.ops.2.py
deleted file mode 100644 (file)
index 86b7438..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-"""
-Overriding Context
-++++++++++++++++++
-
-It is possible to override context members that the operator sees, so that they
-act on specified rather than the selected or active data, or to execute an
-operator in the different part of the user interface.
-
-The context overrides are passed as a dictionary, with keys matching the context
-member names in bpy.context. For example to override bpy.context.active_object,
-you would pass {'active_object': object}.
-"""
-
-# remove all objects in scene rather than the selected ones
-import bpy
-override = {'selected_bases': list(bpy.context.scene.object_bases)}
-bpy.ops.object.delete(override)
-
diff --git a/doc/python_api/examples/bpy.ops.3.py b/doc/python_api/examples/bpy.ops.3.py
deleted file mode 100644 (file)
index 0b5bcaf..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-"""
-It is also possible to run an operator in a particular part of the user
-interface. For this we need to pass the window, screen, area and sometimes
-a region.
-"""
-
-# maximize 3d view in all windows
-import bpy
-
-for window in bpy.context.window_manager.windows:
-    screen = window.screen
-    
-    for area in screen.areas:
-        if area.type == 'VIEW_3D':
-            override = {'window': window, 'screen': screen, 'area': area}
-            bpy.ops.screen.screen_full_area(override)
-            break
-
diff --git a/extern/libmv/libmv/simple_pipeline/modal_solver.cc b/extern/libmv/libmv/simple_pipeline/modal_solver.cc
deleted file mode 100644 (file)
index bb49b30..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright (c) 2012 libmv authors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-
-#include <cstdio>
-
-#include "libmv/logging/logging.h"
-#include "libmv/simple_pipeline/modal_solver.h"
-#include "libmv/simple_pipeline/rigid_registration.h"
-
-#ifdef _MSC_VER
-#  define snprintf _snprintf
-#endif
-
-namespace libmv {
-
-static void ProjectMarkerOnSphere(Marker &marker, Vec3 &X) {
-  X(0) = marker.x;
-  X(1) = marker.y;
-  X(2) = 1.0;
-
-  X *= 5.0 / X.norm();
-}
-
-static void ModalSolverLogProress(ProgressUpdateCallback *update_callback,
-    double progress)
-{
-  if (update_callback) {
-    char message[256];
-
-    snprintf(message, sizeof(message), "Solving progress %d%%", (int)(progress * 100));
-
-    update_callback->invoke(progress, message);
-  }
-}
-
-void ModalSolver(Tracks &tracks,
-                 EuclideanReconstruction *reconstruction,
-                 ProgressUpdateCallback *update_callback) {
-  int max_image = tracks.MaxImage();
-  int max_track = tracks.MaxTrack();
-
-  LG << "Max image: " << max_image;
-  LG << "Max track: " << max_track;
-
-  Mat3 R = Mat3::Identity();
-
-  for (int image = 0; image <= max_image; ++image) {
-    vector<Marker> all_markers = tracks.MarkersInImage(image);
-
-    ModalSolverLogProress(update_callback, (float) image / max_image);
-
-    // Skip empty frames without doing anything
-    if (all_markers.size() == 0) {
-      LG << "Skipping frame: " << image;
-      continue;
-    }
-
-    vector<Vec3> points, reference_points;
-
-    // Cnstruct pairs of markers from current and previous image,
-    // to reproject them and find rigid transformation between
-    // previous and current image
-    for (int track = 0; track <= max_track; ++track) {
-      EuclideanPoint *point = reconstruction->PointForTrack(track);
-
-      if (point) {
-        Marker marker = tracks.MarkerInImageForTrack(image, track);
-
-        if (marker.image == image) {
-          Vec3 X;
-
-          LG << "Use track " << track << " for rigid registration between image " <<
-            image - 1 << " and " << image;
-
-          ProjectMarkerOnSphere(marker, X);
-
-          points.push_back(point->X);
-          reference_points.push_back(X);
-        }
-      }
-    }
-
-    if (points.size()) {
-      // Find rigid delta transformation to current image
-      RigidRegistration(reference_points, points, R);
-    }
-
-    reconstruction->InsertCamera(image, R, Vec3::Zero());
-
-    // Review if there's new tracks for which position might be reconstructed
-    for (int track = 0; track <= max_track; ++track) {
-      if (!reconstruction->PointForTrack(track)) {
-        Marker marker = tracks.MarkerInImageForTrack(image, track);
-
-        if (marker.image == image) {
-          // New track appeared on this image, project it's position onto sphere
-
-          LG << "Projecting track " << track << " at image " << image;
-
-          Vec3 X;
-          ProjectMarkerOnSphere(marker, X);
-          reconstruction->InsertPoint(track, R.inverse() * X);
-        }
-      }
-    }
-  }
-}
-
-}  // namespace libmv
diff --git a/extern/libmv/libmv/simple_pipeline/modal_solver.h b/extern/libmv/libmv/simple_pipeline/modal_solver.h
deleted file mode 100644 (file)
index 560b37c..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2012 libmv authors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-
-#ifndef LIBMV_SIMPLE_PIPELINE_MODAL_SOLVER_H_
-#define LIBMV_SIMPLE_PIPELINE_MODAL_SOLVER_H_
-
-#include "libmv/simple_pipeline/tracks.h"
-#include "libmv/simple_pipeline/reconstruction.h"
-#include "libmv/simple_pipeline/callbacks.h"
-
-namespace libmv {
-
-/*!
-    This solver solves such camera motion as tripod rotation, reconstructing
-    only camera motion itself. Bundles are not reconstructing properly, they're
-    just getting projected onto sphere.
-
-    Markers from tracks object would be used for recosntruction, and algorithm
-    assumes thir's positions are undistorted already and they're in nnormalized
-    space.
-
-    Reconstructed cameras and projected bundles would be added to reconstruction
-    object.
-*/
-void ModalSolver(Tracks &tracks,
-                 EuclideanReconstruction *reconstruction,
-                 ProgressUpdateCallback *update_callback = NULL);
-
-}  // namespace libmv
-
-#endif  // LIBMV_SIMPLE_PIPELINE_MODAL_SOLVER_H_
diff --git a/intern/cycles/bvh/bvh_binning.cpp b/intern/cycles/bvh/bvh_binning.cpp
deleted file mode 100644 (file)
index 661541a..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Adapted from code copyright 2009-2011 Intel Corporation
- * Modifications Copyright 2012, Blender Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define __KERNEL_SSE__
-
-#include <stdlib.h>
-
-#include "bvh_binning.h"
-
-#include "util_algorithm.h"
-#include "util_boundbox.h"
-#include "util_types.h"
-
-CCL_NAMESPACE_BEGIN
-
-/* SSE replacements */
-
-__forceinline void prefetch_L1 (const void* ptr) { }
-__forceinline void prefetch_L2 (const void* ptr) { }
-__forceinline void prefetch_L3 (const void* ptr) { }
-__forceinline void prefetch_NTA(const void* ptr) { }
-
-template<size_t src> __forceinline float extract(const int4& b)
-{ return b[src]; }
-template<size_t dst> __forceinline const float4 insert(const float4& a, const float b)
-{ float4 r = a; r[dst] = b; return r; }
-
-__forceinline int get_best_dimension(const float4& bestSAH)
-{
-       // return (int)__bsf(movemask(reduce_min(bestSAH) == bestSAH));
-
-       float minSAH = min(bestSAH.x, min(bestSAH.y, bestSAH.z));
-
-       if(bestSAH.x == minSAH) return 0;
-       else if(bestSAH.y == minSAH) return 1;
-       else return 2;
-}
-
-/* BVH Object Binning */
-
-BVHObjectBinning::BVHObjectBinning(const BVHRange& job, BVHReference *prims)
-: BVHRange(job), splitSAH(FLT_MAX), dim(0), pos(0)
-{
-       /* compute number of bins to use and precompute scaling factor for binning */
-       num_bins = min(size_t(MAX_BINS), size_t(4.0f + 0.05f*size()));
-       scale = rcp(cent_bounds().size()) * make_float3((float)num_bins);
-
-       /* initialize binning counter and bounds */
-       BoundBox bin_bounds[MAX_BINS][4];       /* bounds for every bin in every dimension */
-       int4 bin_count[MAX_BINS];                       /* number of primitives mapped to bin */
-
-       for(size_t i = 0; i < num_bins; i++) {
-               bin_count[i] = make_int4(0);
-               bin_bounds[i][0] = bin_bounds[i][1] = bin_bounds[i][2] = BoundBox::empty;
-       }
-
-       /* map geometry to bins, unrolled once */
-       {
-               ssize_t i;
-
-               for(i = 0; i < ssize_t(size()) - 1; i += 2) {
-                       prefetch_L2(&prims[start() + i + 8]);
-
-                       /* map even and odd primitive to bin */
-                       BVHReference prim0 = prims[start() + i + 0];
-                       BVHReference prim1 = prims[start() + i + 1];
-
-                       int4 bin0 = get_bin(prim0.bounds());
-                       int4 bin1 = get_bin(prim1.bounds());
-
-                       /* increase bounds for bins for even primitive */
-                       int b00 = extract<0>(bin0); bin_count[b00][0]++; bin_bounds[b00][0].grow(prim0.bounds());
-                       int b01 = extract<1>(bin0); bin_count[b01][1]++; bin_bounds[b01][1].grow(prim0.bounds());
-                       int b02 = extract<2>(bin0); bin_count[b02][2]++; bin_bounds[b02][2].grow(prim0.bounds());
-
-                       /* increase bounds of bins for odd primitive */
-                       int b10 = extract<0>(bin1); bin_count[b10][0]++; bin_bounds[b10][0].grow(prim1.bounds());
-                       int b11 = extract<1>(bin1); bin_count[b11][1]++; bin_bounds[b11][1].grow(prim1.bounds());
-                       int b12 = extract<2>(bin1); bin_count[b12][2]++; bin_bounds[b12][2].grow(prim1.bounds());
-               }
-
-               /* for uneven number of primitives */
-               if(i < ssize_t(size())) {
-                       /* map primitive to bin */
-                       BVHReference prim0 = prims[start() + i];
-                       int4 bin0 = get_bin(prim0.bounds());
-
-                       /* increase bounds of bins */
-                       int b00 = extract<0>(bin0); bin_count[b00][0]++; bin_bounds[b00][0].grow(prim0.bounds());
-                       int b01 = extract<1>(bin0); bin_count[b01][1]++; bin_bounds[b01][1].grow(prim0.bounds());
-                       int b02 = extract<2>(bin0); bin_count[b02][2]++; bin_bounds[b02][2].grow(prim0.bounds());
-               }
-       }
-
-       /* sweep from right to left and compute parallel prefix of merged bounds */
-       float4 r_area[MAX_BINS];        /* area of bounds of primitives on the right */
-       float4 r_count[MAX_BINS];       /* number of primitives on the right */
-       int4 count = make_int4(0);
-
-       BoundBox bx = BoundBox::empty;
-       BoundBox by = BoundBox::empty;
-       BoundBox bz = BoundBox::empty;
-
-       for(size_t i = num_bins - 1; i > 0; i--) {
-               count = count + bin_count[i];
-               r_count[i] = blocks(count);
-
-               bx = merge(bx,bin_bounds[i][0]); r_area[i][0] = bx.half_area();
-               by = merge(by,bin_bounds[i][1]); r_area[i][1] = by.half_area();
-               bz = merge(bz,bin_bounds[i][2]); r_area[i][2] = bz.half_area();
-       }
-
-       /* sweep from left to right and compute SAH */
-       int4 ii = make_int4(1);
-       float4 bestSAH = make_float4(FLT_MAX);
-       int4 bestSplit = make_int4(-1);
-
-       count = make_int4(0);
-
-       bx = BoundBox::empty;
-       by = BoundBox::empty;
-       bz = BoundBox::empty;
-
-       for(size_t i = 1; i < num_bins; i++, ii += make_int4(1)) {
-               count = count + bin_count[i-1];
-
-               bx = merge(bx,bin_bounds[i-1][0]); float Ax = bx.half_area();
-               by = merge(by,bin_bounds[i-1][1]); float Ay = by.half_area();
-               bz = merge(bz,bin_bounds[i-1][2]); float Az = bz.half_area();
-
-               float4 lCount = blocks(count);
-               float4 lArea = make_float4(Ax,Ay,Az,Az);
-               float4 sah = lArea*lCount + r_area[i]*r_count[i];
-
-               bestSplit = select(sah < bestSAH,ii,bestSplit);
-               bestSAH = min(sah,bestSAH);
-       }
-
-       int4 mask = float3_to_float4(cent_bounds().size()) <= make_float4(0.0f);
-       bestSAH = insert<3>(select(mask, make_float4(FLT_MAX), bestSAH), FLT_MAX);
-
-       /* find best dimension */
-       dim = get_best_dimension(bestSAH);
-       splitSAH = bestSAH[dim];
-       pos = bestSplit[dim];
-       leafSAH = bounds().half_area() * blocks(size());
-}
-
-void BVHObjectBinning::split(BVHReference* prims, BVHObjectBinning& left_o, BVHObjectBinning& right_o) const
-{
-       size_t N = size();
-
-       BoundBox lgeom_bounds = BoundBox::empty;
-       BoundBox rgeom_bounds = BoundBox::empty;
-       BoundBox lcent_bounds = BoundBox::empty;
-       BoundBox rcent_bounds = BoundBox::empty;
-
-       ssize_t l = 0, r = N-1;
-
-       while(l <= r) {
-               prefetch_L2(&prims[start() + l + 8]);
-               prefetch_L2(&prims[start() + r - 8]);
-
-               BVHReference prim = prims[start() + l];
-               float3 center = prim.bounds().center2();
-
-               if(get_bin(center)[dim] < pos) {
-                       lgeom_bounds.grow(prim.bounds());
-                       lcent_bounds.grow(center);
-                       l++;
-               }
-               else {
-                       rgeom_bounds.grow(prim.bounds());
-                       rcent_bounds.grow(center);
-                       swap(prims[start()+l],prims[start()+r]);
-                       r--;
-               }
-       }
-
-       /* finish */
-       if(l != 0 && N-1-r != 0) {
-               right_o = BVHObjectBinning(BVHRange(rgeom_bounds, rcent_bounds, start() + l, N-1-r), prims);
-               left_o  = BVHObjectBinning(BVHRange(lgeom_bounds, lcent_bounds, start(), l), prims);
-               return;
-       }
-
-       /* object medium split if we did not make progress, can happen when all
-          primitives have same centroid */
-       lgeom_bounds = BoundBox::empty;
-       rgeom_bounds = BoundBox::empty;
-       lcent_bounds = BoundBox::empty;
-       rcent_bounds = BoundBox::empty;
-
-       for(size_t i = 0; i < N/2; i++) {
-               lgeom_bounds.grow(prims[start()+i].bounds());
-               lcent_bounds.grow(prims[start()+i].bounds().center2());
-       }
-
-       for(size_t i = N/2; i < N; i++) {
-               rgeom_bounds.grow(prims[start()+i].bounds());
-               rcent_bounds.grow(prims[start()+i].bounds().center2());
-       }
-
-       right_o = BVHObjectBinning(BVHRange(rgeom_bounds, rcent_bounds, start() + N/2, N/2 + N%2), prims);
-       left_o  = BVHObjectBinning(BVHRange(lgeom_bounds, lcent_bounds, start(), N/2), prims);
-}
-
-CCL_NAMESPACE_END
-
diff --git a/intern/cycles/bvh/bvh_binning.h b/intern/cycles/bvh/bvh_binning.h
deleted file mode 100644 (file)
index 6074215..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Adapted from code copyright 2009-2011 Intel Corporation
- * Modifications Copyright 2012, Blender Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __BVH_BINNING_H__
-#define __BVH_BINNING_H__
-
-#include "bvh_params.h"
-
-#include "util_types.h"
-
-CCL_NAMESPACE_BEGIN
-
-/* Single threaded object binner. Finds the split with the best SAH heuristic
- * by testing for each dimension multiple partitionings for regular spaced
- * partition locations. A partitioning for a partition location is computed,
- * by putting primitives whose centroid is on the left and right of the split
- * location to different sets. The SAH is evaluated by computing the number of
- * blocks occupied by the primitives in the partitions. */
-
-class BVHObjectBinning : public BVHRange
-{
-public:
-       __forceinline BVHObjectBinning() {}
-       BVHObjectBinning(const BVHRange& job, BVHReference *prims);
-
-       void split(BVHReference *prims, BVHObjectBinning& left_o, BVHObjectBinning& right_o) const;
-
-       float splitSAH; /* SAH cost of the best split */
-       float leafSAH;  /* SAH cost of creating a leaf */
-
-protected:
-       int dim;                        /* best split dimension */
-       int pos;                        /* best split position */
-       size_t num_bins;        /* actual number of bins to use */
-       float3 scale;           /* scaling factor to compute bin */
-
-       enum { MAX_BINS = 32 };
-       enum { LOG_BLOCK_SIZE = 2 };
-
-       /* computes the bin numbers for each dimension for a box. */
-       __forceinline int4 get_bin(const BoundBox& box) const
-       {
-               int4 a = make_int4((box.center2() - cent_bounds().min)*scale - make_float3(0.5f));
-               int4 mn = make_int4(0);
-               int4 mx = make_int4((int)num_bins-1);
-
-               return clamp(a, mn, mx);
-       }
-
-       /* computes the bin numbers for each dimension for a point. */
-       __forceinline int4 get_bin(const float3& c) const
-       {
-               return make_int4((c - cent_bounds().min)*scale - make_float3(0.5f));
-       }
-
-       /* compute the number of blocks occupied for each dimension. */
-       __forceinline float4 blocks(const int4& a) const
-       {
-               return make_float4((a + make_int4((1 << LOG_BLOCK_SIZE)-1)) >> LOG_BLOCK_SIZE);
-       }
-
-       /* compute the number of blocks occupied in one dimension. */
-       __forceinline int blocks(size_t a) const
-       {
-               return (int)((a+((1LL << LOG_BLOCK_SIZE)-1)) >> LOG_BLOCK_SIZE);
-       }
-};
-
-CCL_NAMESPACE_END
-
-#endif
-
diff --git a/intern/cycles/bvh/bvh_split.cpp b/intern/cycles/bvh/bvh_split.cpp
deleted file mode 100644 (file)
index 263c583..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Adapted from code copyright 2009-2010 NVIDIA Corporation
- * Modifications Copyright 2011, Blender Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "bvh_build.h"
-#include "bvh_split.h"
-#include "bvh_sort.h"
-
-#include "mesh.h"
-#include "object.h"
-
-#include "util_algorithm.h"
-
-CCL_NAMESPACE_BEGIN
-
-/* Object Split */
-
-BVHObjectSplit::BVHObjectSplit(BVHBuild *builder, const BVHRange& range, float nodeSAH)
-: sah(FLT_MAX), dim(0), num_left(0), left_bounds(BoundBox::empty), right_bounds(BoundBox::empty)
-{
-       const BVHReference *ref_ptr = &builder->references[range.start()];
-       float min_sah = FLT_MAX;
-
-       for(int dim = 0; dim < 3; dim++) {
-               /* sort references */
-               bvh_reference_sort(range.start(), range.end(), &builder->references[0], dim);
-
-               /* sweep right to left and determine bounds. */
-               BoundBox right_bounds = BoundBox::empty;
-
-               for(int i = range.size() - 1; i > 0; i--) {
-                       right_bounds.grow(ref_ptr[i].bounds());
-                       builder->spatial_right_bounds[i - 1] = right_bounds;
-               }
-
-               /* sweep left to right and select lowest SAH. */
-               BoundBox left_bounds = BoundBox::empty;
-
-               for(int i = 1; i < range.size(); i++) {
-                       left_bounds.grow(ref_ptr[i - 1].bounds());
-                       right_bounds = builder->spatial_right_bounds[i - 1];
-
-                       float sah = nodeSAH +
-                               left_bounds.safe_area() * builder->params.triangle_cost(i) +
-                               right_bounds.safe_area() * builder->params.triangle_cost(range.size() - i);
-
-                       if(sah < min_sah) {
-                               min_sah = sah;
-
-                               this->sah = sah;
-                               this->dim = dim;
-                               this->num_left = i;
-                               this->left_bounds = left_bounds;
-                               this->right_bounds = right_bounds;
-                       }
-               }
-       }
-}
-
-void BVHObjectSplit::split(BVHBuild *builder, BVHRange& left, BVHRange& right, const BVHRange& range)
-{
-       /* sort references according to split */
-       bvh_reference_sort(range.start(), range.end(), &builder->references[0], this->dim);
-
-       /* split node ranges */
-       left = BVHRange(this->left_bounds, range.start(), this->num_left);
-       right = BVHRange(this->right_bounds, left.end(), range.size() - this->num_left);
-
-}
-
-/* Spatial Split */
-
-BVHSpatialSplit::BVHSpatialSplit(BVHBuild *builder, const BVHRange& range, float nodeSAH)
-: sah(FLT_MAX), dim(0), pos(0.0f)
-{
-       /* initialize bins. */
-       float3 origin = range.bounds().min;
-       float3 binSize = (range.bounds().max - origin) * (1.0f / (float)BVHParams::NUM_SPATIAL_BINS);
-       float3 invBinSize = 1.0f / binSize;
-
-       for(int dim = 0; dim < 3; dim++) {
-               for(int i = 0; i < BVHParams::NUM_SPATIAL_BINS; i++) {
-                       BVHSpatialBin& bin = builder->spatial_bins[dim][i];
-
-                       bin.bounds = BoundBox::empty;
-                       bin.enter = 0;
-                       bin.exit = 0;
-               }
-       }
-
-       /* chop references into bins. */
-       for(unsigned int refIdx = range.start(); refIdx < range.end(); refIdx++) {
-               const BVHReference& ref = builder->references[refIdx];
-               float3 firstBinf = (ref.bounds().min - origin) * invBinSize;
-               float3 lastBinf = (ref.bounds().max - origin) * invBinSize;
-               int3 firstBin = make_int3((int)firstBinf.x, (int)firstBinf.y, (int)firstBinf.z);
-               int3 lastBin = make_int3((int)lastBinf.x, (int)lastBinf.y, (int)lastBinf.z);
-
-               firstBin = clamp(firstBin, 0, BVHParams::NUM_SPATIAL_BINS - 1);
-               lastBin = clamp(lastBin, firstBin, BVHParams::NUM_SPATIAL_BINS - 1);
-
-               for(int dim = 0; dim < 3; dim++) {
-                       BVHReference currRef = ref;
-
-                       for(int i = firstBin[dim]; i < lastBin[dim]; i++) {
-                               BVHReference leftRef, rightRef;
-
-                               split_reference(builder, leftRef, rightRef, currRef, dim, origin[dim] + binSize[dim] * (float)(i + 1));
-                               builder->spatial_bins[dim][i].bounds.grow(leftRef.bounds());
-                               currRef = rightRef;
-                       }
-
-                       builder->spatial_bins[dim][lastBin[dim]].bounds.grow(currRef.bounds());
-                       builder->spatial_bins[dim][firstBin[dim]].enter++;
-                       builder->spatial_bins[dim][lastBin[dim]].exit++;
-               }
-       }
-
-       /* select best split plane. */
-       for(int dim = 0; dim < 3; dim++) {
-               /* sweep right to left and determine bounds. */
-               BoundBox right_bounds = BoundBox::empty;
-
-               for(int i = BVHParams::NUM_SPATIAL_BINS - 1; i > 0; i--) {
-                       right_bounds.grow(builder->spatial_bins[dim][i].bounds);
-                       builder->spatial_right_bounds[i - 1] = right_bounds;
-               }
-
-               /* sweep left to right and select lowest SAH. */
-               BoundBox left_bounds = BoundBox::empty;
-               int leftNum = 0;
-               int rightNum = range.size();
-
-               for(int i = 1; i < BVHParams::NUM_SPATIAL_BINS; i++) {
-                       left_bounds.grow(builder->spatial_bins[dim][i - 1].bounds);
-                       leftNum += builder->spatial_bins[dim][i - 1].enter;
-                       rightNum -= builder->spatial_bins[dim][i - 1].exit;
-
-                       float sah = nodeSAH +
-                               left_bounds.safe_area() * builder->params.triangle_cost(leftNum) +
-                               builder->spatial_right_bounds[i - 1].safe_area() * builder->params.triangle_cost(rightNum);
-
-                       if(sah < this->sah) {
-                               this->sah = sah;
-                               this->dim = dim;
-                               this->pos = origin[dim] + binSize[dim] * (float)i;
-                       }
-               }
-       }
-}
-
-void BVHSpatialSplit::split(BVHBuild *builder, BVHRange& left, BVHRange& right, const BVHRange& range)
-{
-       /* Categorize references and compute bounds.
-        *
-        * Left-hand side:                      [left_start, left_end[
-        * Uncategorized/split:         [left_end, right_start[
-        * Right-hand side:                     [right_start, refs.size()[ */
-
-       vector<BVHReference>& refs = builder->references;
-       int left_start = range.start();
-       int left_end = left_start;
-       int right_start = range.end();
-       int right_end = range.end();
-       BoundBox left_bounds = BoundBox::empty;
-       BoundBox right_bounds = BoundBox::empty;
-
-       for(int i = left_end; i < right_start; i++) {
-               if(refs[i].bounds().max[this->dim] <= this->pos) {
-                       /* entirely on the left-hand side */
-                       left_bounds.grow(refs[i].bounds());
-                       swap(refs[i], refs[left_end++]);
-               }
-               else if(refs[i].bounds().min[this->dim] >= this->pos) {
-                       /* entirely on the right-hand side */
-                       right_bounds.grow(refs[i].bounds());
-                       swap(refs[i--], refs[--right_start]);
-               }
-       }
-
-       /* duplicate or unsplit references intersecting both sides. */
-       while(left_end < right_start) {
-               /* split reference. */
-               BVHReference lref, rref;
-
-               split_reference(builder, lref, rref, refs[left_end], this->dim, this->pos);
-
-               /* compute SAH for duplicate/unsplit candidates. */
-               BoundBox lub = left_bounds;             // Unsplit to left:             new left-hand bounds.
-               BoundBox rub = right_bounds;    // Unsplit to right:    new right-hand bounds.
-               BoundBox ldb = left_bounds;             // Duplicate:                   new left-hand bounds.
-               BoundBox rdb = right_bounds;    // Duplicate:                   new right-hand bounds.
-
-               lub.grow(refs[left_end].bounds());
-               rub.grow(refs[left_end].bounds());
-               ldb.grow(lref.bounds());
-               rdb.grow(rref.bounds());
-
-               float lac = builder->params.triangle_cost(left_end - left_start);
-               float rac = builder->params.triangle_cost(right_end - right_start);
-               float lbc = builder->params.triangle_cost(left_end - left_start + 1);
-               float rbc = builder->params.triangle_cost(right_end - right_start + 1);
-
-               float unsplitLeftSAH = lub.safe_area() * lbc + right_bounds.safe_area() * rac;
-               float unsplitRightSAH = left_bounds.safe_area() * lac + rub.safe_area() * rbc;
-               float duplicateSAH = ldb.safe_area() * lbc + rdb.safe_area() * rbc;
-               float minSAH = min(min(unsplitLeftSAH, unsplitRightSAH), duplicateSAH);
-
-               if(minSAH == unsplitLeftSAH) {
-                       /* unsplit to left */
-                       left_bounds = lub;
-                       left_end++;
-               }
-               else if(minSAH == unsplitRightSAH) {
-                       /* unsplit to right */
-                       right_bounds = rub;
-                       swap(refs[left_end], refs[--right_start]);
-               }
-               else {
-                       /* duplicate */
-                       left_bounds = ldb;
-                       right_bounds = rdb;
-                       refs[left_end++] = lref;
-                       refs.insert(refs.begin() + right_end, rref);
-                       right_end++;
-               }
-       }
-
-       left = BVHRange(left_bounds, left_start, left_end - left_start);
-       right = BVHRange(right_bounds, right_start, right_end - right_start);
-}
-
-void BVHSpatialSplit::split_reference(BVHBuild *builder, BVHReference& left, BVHReference& right, const BVHReference& ref, int dim, float pos)
-{
-       /* initialize boundboxes */
-       BoundBox left_bounds = BoundBox::empty;
-       BoundBox right_bounds = BoundBox::empty;
-
-       /* loop over vertices/edges. */
-       Object *ob = builder->objects[ref.prim_object()];
-       const Mesh *mesh = ob->mesh;
-       const int *inds = mesh->triangles[ref.prim_index()].v;
-       const float3 *verts = &mesh->verts[0];
-       const float3* v1 = &verts[inds[2]];
-
-       for(int i = 0; i < 3; i++) {
-               const float3* v0 = v1;
-               int vindex = inds[i];
-               v1 = &verts[vindex];
-               float v0p = (*v0)[dim];
-               float v1p = (*v1)[dim];
-
-               /* insert vertex to the boxes it belongs to. */
-               if(v0p <= pos)
-                       left_bounds.grow(*v0);
-
-               if(v0p >= pos)
-                       right_bounds.grow(*v0);
-
-               /* edge intersects the plane => insert intersection to both boxes. */
-               if((v0p < pos && v1p > pos) || (v0p > pos && v1p < pos)) {
-                       float3 t = lerp(*v0, *v1, clamp((pos - v0p) / (v1p - v0p), 0.0f, 1.0f));
-                       left_bounds.grow(t);
-                       right_bounds.grow(t);
-               }
-       }
-
-       /* intersect with original bounds. */
-       left_bounds.max[dim] = pos;
-       right_bounds.min[dim] = pos;
-       left_bounds.intersect(ref.bounds());
-       right_bounds.intersect(ref.bounds());
-
-       /* set referecnes */
-       left = BVHReference(left_bounds, ref.prim_index(), ref.prim_object());
-       right = BVHReference(right_bounds, ref.prim_index(), ref.prim_object());
-}
-
-CCL_NAMESPACE_END
-
diff --git a/intern/cycles/bvh/bvh_split.h b/intern/cycles/bvh/bvh_split.h
deleted file mode 100644 (file)
index 1f4befb..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Adapted from code copyright 2009-2010 NVIDIA Corporation
- * Modifications Copyright 2011, Blender Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __BVH_SPLIT_H__
-#define __BVH_SPLIT_H__
-
-#include "bvh_build.h"
-#include "bvh_params.h"
-
-CCL_NAMESPACE_BEGIN
-
-class BVHBuild;
-
-/* Object Split */
-
-class BVHObjectSplit
-{
-public:
-       float sah;
-       int dim;
-       int num_left;
-       BoundBox left_bounds;
-       BoundBox right_bounds;
-
-       BVHObjectSplit() {}
-       BVHObjectSplit(BVHBuild *builder, const BVHRange& range, float nodeSAH);
-
-       void split(BVHBuild *builder, BVHRange& left, BVHRange& right, const BVHRange& range);
-};
-
-/* Spatial Split */
-
-class BVHSpatialSplit
-{
-public:
-       float sah;
-       int dim;
-       float pos;
-
-       BVHSpatialSplit() : sah(FLT_MAX), dim(0), pos(0.0f) {}
-       BVHSpatialSplit(BVHBuild *builder, const BVHRange& range, float nodeSAH);
-
-       void split(BVHBuild *builder, BVHRange& left, BVHRange& right, const BVHRange& range);
-       void split_reference(BVHBuild *builder, BVHReference& left, BVHReference& right, const BVHReference& ref, int dim, float pos);
-};
-
-/* Mixed Object-Spatial Split */
-
-class BVHMixedSplit
-{
-public:
-       BVHObjectSplit object;
-       BVHSpatialSplit spatial;
-
-       float leafSAH;
-       float nodeSAH;
-       float minSAH;
-
-       bool no_split;
-
-       __forceinline BVHMixedSplit(BVHBuild *builder, const BVHRange& range, int level)
-       {
-               /* find split candidates. */
-               float area = range.bounds().safe_area();
-
-               leafSAH = area * builder->params.triangle_cost(range.size());
-               nodeSAH = area * builder->params.node_cost(2);
-
-               object = BVHObjectSplit(builder, range, nodeSAH);
-
-               if(builder->params.use_spatial_split && level < BVHParams::MAX_SPATIAL_DEPTH) {
-                       BoundBox overlap = object.left_bounds;
-                       overlap.intersect(object.right_bounds);
-
-                       if(overlap.safe_area() >= builder->spatial_min_overlap)
-                               spatial = BVHSpatialSplit(builder, range, nodeSAH);
-               }
-
-               /* leaf SAH is the lowest => create leaf. */
-               minSAH = min(min(leafSAH, object.sah), spatial.sah);
-               no_split = (minSAH == leafSAH && range.size() <= builder->params.max_leaf_size);
-       }
-
-       __forceinline void split(BVHBuild *builder, BVHRange& left, BVHRange& right, const BVHRange& range)
-       {
-               if(builder->params.use_spatial_split && minSAH == spatial.sah)
-                       spatial.split(builder, left, right, range);
-               if(!left.size() || !right.size())
-                       object.split(builder, left, right, range);
-       }
-};
-
-CCL_NAMESPACE_END
-
-#endif /* __BVH_SPLIT_H__ */
-
diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp
deleted file mode 100644 (file)
index 6da9a70..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "util_debug.h"
-#include "util_foreach.h"
-#include "util_system.h"
-#include "util_task.h"
-
-CCL_NAMESPACE_BEGIN
-
-/* Task Pool */
-
-TaskPool::TaskPool(const TaskRunFunction& run_)
-{
-       num = 0;
-       num_done = 0;
-
-       do_cancel = false;
-
-       run = run_;
-}
-
-TaskPool::~TaskPool()
-{
-       stop();
-}
-
-void TaskPool::push(Task *task, bool front)
-{
-       TaskScheduler::Entry entry;
-
-       entry.task = task;
-       entry.pool = this;
-
-       TaskScheduler::push(entry, front);
-}
-
-void TaskPool::wait()
-{
-       thread_scoped_lock lock(done_mutex);
-
-       while(num_done != num)
-               done_cond.wait(lock);
-}
-
-void TaskPool::cancel()
-{
-       TaskScheduler::clear(this);
-
-       do_cancel = true;
-       wait();
-       do_cancel = false;
-}
-
-void TaskPool::stop()
-{
-       TaskScheduler::clear(this);
-
-       assert(num_done == num);
-}
-
-bool TaskPool::cancelled()
-{
-       return do_cancel;
-}
-
-void TaskPool::done_increase(int done)
-{
-       done_mutex.lock();
-       num_done += done;
-       done_mutex.unlock();
-
-       assert(num_done <= num);
-       done_cond.notify_all();
-}
-
-/* Task Scheduler */
-
-thread_mutex TaskScheduler::mutex;
-int TaskScheduler::users = 0;
-vector<thread*> TaskScheduler::threads;
-volatile bool TaskScheduler::do_exit = false;
-
-list<TaskScheduler::Entry> TaskScheduler::queue;
-thread_mutex TaskScheduler::queue_mutex;
-thread_condition_variable TaskScheduler::queue_cond;
-
-void TaskScheduler::init(int num_threads)
-{
-       thread_scoped_lock lock(mutex);
-
-       /* multiple cycles instances can use this task scheduler, sharing the same
-          threads, so we keep track of the number of users. */
-       if(users == 0) {
-               do_exit = false;
-
-               /* launch threads that will be waiting for work */
-               if(num_threads == 0)
-                       num_threads = system_cpu_thread_count();
-
-               threads.resize(num_threads);
-
-               for(size_t i = 0; i < threads.size(); i++)
-                       threads[i] = new thread(function_bind(&TaskScheduler::thread_run, i));
-       }
-       
-       users++;
-}
-
-void TaskScheduler::exit()
-{
-       thread_scoped_lock lock(mutex);
-
-       users--;
-
-       if(users == 0) {
-               /* stop all waiting threads */
-               do_exit = true;
-               TaskScheduler::queue_cond.notify_all();
-
-               /* delete threads */
-               foreach(thread *t, threads) {
-                       t->join();
-                       delete t;
-               }
-
-               threads.clear();
-       }
-}
-
-bool TaskScheduler::thread_wait_pop(Entry& entry)
-{
-       thread_scoped_lock lock(queue_mutex);
-
-       while(queue.empty() && !do_exit)
-               queue_cond.wait(lock);
-
-       if(queue.empty()) {
-               assert(do_exit);
-               return false;
-       }
-       
-       entry = queue.front();
-       queue.pop_front();
-
-       return true;
-}
-
-void TaskScheduler::thread_run(int thread_id)
-{
-       Entry entry;
-
-       /* todo: test affinity/denormal mask */
-
-       /* keep popping off tasks */
-       while(thread_wait_pop(entry)) {
-               /* run task */
-               entry.pool->run(entry.task, thread_id);
-
-               /* delete task */
-               delete entry.task;
-
-               /* notify pool task was done */
-               entry.pool->done_increase(1);
-       }
-}
-
-void TaskScheduler::push(Entry& entry, bool front)
-{
-       /* add entry to queue */
-       TaskScheduler::queue_mutex.lock();
-       if(front)
-               TaskScheduler::queue.push_front(entry);
-       else
-               TaskScheduler::queue.push_back(entry);
-       entry.pool->num++;
-       TaskScheduler::queue_mutex.unlock();
-
-       TaskScheduler::queue_cond.notify_one();
-}
-
-void TaskScheduler::clear(TaskPool *pool)
-{
-       thread_scoped_lock lock(TaskScheduler::queue_mutex);
-
-       /* erase all tasks from this pool from the queue */
-       list<TaskScheduler::Entry>::iterator it = TaskScheduler::queue.begin();
-       int done = 0;
-
-       while(it != TaskScheduler::queue.end()) {
-               TaskScheduler::Entry& entry = *it;
-
-               if(entry.pool == pool) {
-                       done++;
-                       delete entry.task;
-
-                       it = TaskScheduler::queue.erase(it);
-               }
-               else
-                       it++;
-       }
-
-       /* notify done */
-       pool->done_increase(done);
-}
-
-CCL_NAMESPACE_END
-
diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h
deleted file mode 100644 (file)
index acdb2cb..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2011, Blender Foundation.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef __UTIL_TASK_H__
-#define __UTIL_TASK_H__
-
-#include "util_list.h"
-#include "util_thread.h"
-#include "util_vector.h"
-
-CCL_NAMESPACE_BEGIN
-
-class Task;
-class TaskPool;
-class TaskScheduler;
-
-typedef boost::function<void(Task*,int)> TaskRunFunction;
-
-/* Task
- *
- * Base class for tasks to be executed in threads. */
-
-class Task
-{
-public:
-       Task() {};
-       virtual ~Task() {}
-};
-
-/* Task Pool
- *
- * Pool of tasks that will be executed by the central TaskScheduler.For each
- * pool, we can wait for all tasks to be done, or cancel them before they are
- * done.
- *
- * The run callback that actually executes the task may be create like this:
- * function_bind(&MyClass::task_execute, this, _1, _2) */
-
-class TaskPool
-{
-public:
-       TaskPool(const TaskRunFunction& run);
-       ~TaskPool();
-
-       void push(Task *task, bool front = false);
-
-       void wait();            /* wait until all tasks are done */
-       void cancel();          /* cancel all tasks, keep worker threads running */
-       void stop();            /* stop all worker threads */
-
-       bool cancelled();       /* for worker threads, test if cancelled */
-
-protected:
-       friend class TaskScheduler;
-
-       void done_increase(int done);
-
-       TaskRunFunction run;
-
-       thread_mutex done_mutex;
-       thread_condition_variable done_cond;
-
-       volatile int num, num_done;
-       volatile bool do_cancel;
-};
-
-/* Task Scheduler
- * 
- * Central scheduler that holds running threads ready to execute tasks. A singe
- * queue holds the task from all pools. */
-
-class TaskScheduler
-{
-public:
-       static void init(int num_threads = 0);
-       static void exit();
-
-       static int num_threads() { return threads.size(); }
-
-protected:
-       friend class TaskPool;
-
-       struct Entry {
-               Task *task;
-               TaskPool *pool;
-       };
-
-       static thread_mutex mutex;
-       static int users;
-       static vector<thread*> threads;
-       static volatile bool do_exit;
-
-       static list<Entry> queue;
-       static thread_mutex queue_mutex;
-       static thread_condition_variable queue_cond;
-
-       static void thread_run(int thread_id);
-       static bool thread_wait_pop(Entry& entry);
-
-       static void push(Entry& entry, bool front);
-       static void clear(TaskPool *pool);
-};
-
-CCL_NAMESPACE_END
-
-#endif
-
diff --git a/source/blender/blenlib/BLI_lasso.h b/source/blender/blenlib/BLI_lasso.h
deleted file mode 100644 (file)
index 2360173..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __BLI_LASSO_H__
-#define __BLI_LASSO_H__
-
-/** \file BLI_lasso.h
- *  \ingroup bli
- */
-
-struct rcti;
-
-void BLI_lasso_boundbox(struct rcti *rect, int mcords[][2], short moves);
-int  BLI_lasso_is_point_inside(int mcords[][2], short moves, int sx, int sy, const int error_value);
-int  BLI_lasso_is_edge_inside(int mcords[][2], short moves, int x0, int y0, int x1, int y1, const int error_value);
-
-#endif
diff --git a/source/blender/blenlib/intern/lasso.c b/source/blender/blenlib/intern/lasso.c
deleted file mode 100644 (file)
index 29b967f..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- *
- */
-
-/** \file blender/blenlib/intern/lasso.c
- *  \ingroup bli
- */
-
-#include "DNA_vec_types.h"
-
-#include "BLI_math.h"
-#include "BLI_rect.h"
-
-#include "BLI_lasso.h" /* own include */
-
-void BLI_lasso_boundbox(rcti *rect, int mcords[][2], short moves)
-{
-       short a;
-
-       rect->xmin = rect->xmax = mcords[0][0];
-       rect->ymin = rect->ymax = mcords[0][1];
-
-       for (a = 1; a < moves; a++) {
-               if      (mcords[a][0] < rect->xmin) rect->xmin = mcords[a][0];
-               else if (mcords[a][0] > rect->xmax) rect->xmax = mcords[a][0];
-               if      (mcords[a][1] < rect->ymin) rect->ymin = mcords[a][1];
-               else if (mcords[a][1] > rect->ymax) rect->ymax = mcords[a][1];
-       }
-}
-
-
-int BLI_lasso_is_point_inside(int mcords[][2], short moves,
-                              const int sx, const int sy,
-                              const int error_value)
-{
-       /* we do the angle rule, define that all added angles should be about zero or (2 * PI) */
-       float angletot = 0.0, dot, ang, cross, fp1[2], fp2[2];
-       int a;
-       int *p1, *p2;
-
-       if (sx == error_value) {
-               return 0;
-       }
-
-       p1 = mcords[moves - 1];
-       p2 = mcords[0];
-
-       /* first vector */
-       fp1[0] = (float)(p1[0] - sx);
-       fp1[1] = (float)(p1[1] - sy);
-       normalize_v2(fp1);
-
-       for (a = 0; a < moves; a++) {
-               /* second vector */
-               fp2[0] = (float)(p2[0] - sx);
-               fp2[1] = (float)(p2[1] - sy);
-               normalize_v2(fp2);
-
-               /* dot and angle and cross */
-               dot = fp1[0] * fp2[0] + fp1[1] * fp2[1];
-               ang = fabs(saacos(dot));
-
-               cross = (float)((p1[1] - p2[1]) * (p1[0] - sx) + (p2[0] - p1[0]) * (p1[1] - sy));
-
-               if (cross < 0.0f) angletot -= ang;
-               else angletot += ang;
-
-               /* circulate */
-               fp1[0] = fp2[0]; fp1[1] = fp2[1];
-               p1 = p2;
-               p2 = mcords[a + 1];
-       }
-
-       if (fabs(angletot) > 4.0) return 1;
-       return 0;
-}
-
-/* edge version for lasso select. we assume boundbox check was done */
-int BLI_lasso_is_edge_inside(int mcords[][2], short moves,
-                             int x0, int y0, int x1, int y1,
-                             const int error_value)
-{
-       int v1[2], v2[2];
-       int a;
-
-       if (x0 == error_value || x1 == error_value) {
-               return 0;
-       }
-
-       v1[0] = x0, v1[1] = y0;
-       v2[0] = x1, v2[1] = y1;
-
-       /* check points in lasso */
-       if (BLI_lasso_is_point_inside(mcords, moves, v1[0], v1[1], error_value)) return 1;
-       if (BLI_lasso_is_point_inside(mcords, moves, v2[0], v2[1], error_value)) return 1;
-
-       /* no points in lasso, so we have to intersect with lasso edge */
-
-       if (isect_line_line_v2_int(mcords[0], mcords[moves - 1], v1, v2) > 0) return 1;
-       for (a = 0; a < moves - 1; a++) {
-               if (isect_line_line_v2_int(mcords[a], mcords[a + 1], v1, v2) > 0) return 1;
-       }
-
-       return 0;
-}
diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c
deleted file mode 100644 (file)
index f2ef777..0000000
+++ /dev/null
@@ -1,758 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Nicholas Bishop
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/bmesh/operators/bmo_hull.c
- *  \ingroup bmesh
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_ghash.h"
-#include "BLI_listbase.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-/* XXX: using 128 for totelem and pchunk of mempool, no idea what good
- * values would be though */
-#include "BLI_mempool.h"
-
-#include "bmesh.h"
-
-/* Internal operator flags */
-typedef enum {
-       HULL_FLAG_INPUT =           (1 << 0),
-       HULL_FLAG_TETRA_VERT =      (1 << 1),
-       
-       HULL_FLAG_INTERIOR_ELE =    (1 << 2),
-       HULL_FLAG_OUTPUT_GEOM =     (1 << 3),
-       
-       HULL_FLAG_DEL =             (1 << 4),
-       HULL_FLAG_HOLE =            (1 << 5)
-} HullFlags;
-
-/* Store hull triangles seperate from BMesh faces until the end; this
- * way we don't have to worry about cleaning up extraneous edges or
- * incorrectly deleting existing geometry. */
-typedef struct HullTriangle {
-       BMVert *v[3];
-       float no[3];
-       int skip;
-} HullTriangle;
-
-/* These edges define the hole created in the hull by deleting faces
- * that can "see" a new vertex (the boundary edges then form the edge
- * of a new triangle fan that has the new vertex as its center) */
-typedef struct HullBoundaryEdge {
-       struct HullBoundaryEdge *next, *prev;
-       BMVert *v[2];
-} HullBoundaryEdge;
-
-
-
-/*************************** Boundary Edges ***************************/
-
-static int edge_match(BMVert *e1_0, BMVert *e1_1, BMVert *e2[2])
-{
-       return (e1_0 == e2[0] && e1_1 == e2[1]) ||
-              (e1_0 == e2[1] && e1_1 == e2[0]);
-}
-
-/* Returns true if the edge (e1, e2) is already in edges; that edge is
- * deleted here as well. if not found just returns 0 */
-static int check_for_dup(ListBase *edges, BLI_mempool *pool,
-                         BMVert *e1, BMVert *e2)
-{
-       HullBoundaryEdge *e, *next;
-
-       for (e = edges->first; e; e = next) {
-               next = e->next;
-
-               if (edge_match(e1, e2, e->v)) {
-                       /* remove the interior edge */
-                       BLI_remlink(edges, e);
-                       BLI_mempool_free(pool, e);
-                       return 1;
-               }
-       }
-
-       return 0;
-}
-
-static void expand_boundary_edges(ListBase *edges, BLI_mempool *edge_pool,
-                                  const HullTriangle *t)
-{
-       HullBoundaryEdge *new;
-       int i;
-
-       /* Insert each triangle edge into the boundary list; if any of
-        * its edges are already in there, remove the edge entirely */
-       for (i = 0; i < 3; i++) {
-               if (!check_for_dup(edges, edge_pool, t->v[i], t->v[(i + 1) % 3])) {
-                       new = BLI_mempool_calloc(edge_pool);
-                       new->v[0] = t->v[i];
-                       new->v[1] = t->v[(i + 1) % 3];
-                       BLI_addtail(edges, new);
-               }
-       }
-}
-
-
-
-/*************************** Hull Triangles ***************************/
-
-static void hull_add_triangle(GHash *hull_triangles, BLI_mempool *pool,
-                              BMVert *v1, BMVert *v2, BMVert *v3)
-{
-       HullTriangle *t;
-
-       t = BLI_mempool_calloc(pool);
-       t->v[0] = v1;
-       t->v[1] = v2;
-       t->v[2] = v3;
-
-       BLI_ghash_insert(hull_triangles, t, NULL);
-       normal_tri_v3(t->no, v1->co, v2->co, v3->co);
-}
-
-static int hull_point_tri_side(const HullTriangle *t, const float co[3])
-{
-       float p[3], d;
-       sub_v3_v3v3(p, co, t->v[0]->co);
-       d = dot_v3v3(t->no, p);
-       if (d < 0) return -1;
-       else if (d > 0) return 1;
-       else return 0;
-}
-
-/* Get all hull triangles that vertex 'v' is outside of */
-static GHash *hull_triangles_v_outside(GHash *hull_triangles, const BMVert *v)
-{
-       GHash *outside;
-       GHashIterator iter;
-
-       outside = BLI_ghash_new(BLI_ghashutil_ptrhash,
-                               BLI_ghashutil_ptrcmp,
-                               "outside");
-
-       GHASH_ITER (iter, hull_triangles) {
-               HullTriangle *t = BLI_ghashIterator_getKey(&iter);
-               
-               if (hull_point_tri_side(t, v->co) >= 0)
-                       BLI_ghash_insert(outside, t, NULL);
-       }
-
-       return outside;
-}
-
-/* Similar to above, but just get true/false rather than triangles */
-static int hull_test_v_outside(GHash *hull_triangles, const BMVert *v)
-{
-       GHashIterator iter;
-
-       GHASH_ITER (iter, hull_triangles) {
-               HullTriangle *t = BLI_ghashIterator_getKey(&iter);
-               
-               if (hull_point_tri_side(t, v->co) >= 0)
-                       return TRUE;
-       }
-
-       return FALSE;
-}
-
-
-/* For vertex 'v', find which triangles must be deleted to extend the
- * hull; find the boundary edges of that hole so that it can be filled
- * with connections to the new vertex, and update the hull_triangles
- * to delete the marked triangles */
-static void add_point(GHash *hull_triangles, BLI_mempool *hull_pool,
-                      BLI_mempool *edge_pool, GHash *outside, BMVert *v)
-{
-       ListBase edges = {NULL, NULL};
-       HullBoundaryEdge *e, *next;
-       GHashIterator iter;
-
-       GHASH_ITER (iter, outside) {
-               HullTriangle *t = BLI_ghashIterator_getKey(&iter);
-               expand_boundary_edges(&edges, edge_pool, t);
-               
-               /* Delete the triangle */
-               BLI_ghash_remove(hull_triangles, t, NULL, NULL);
-               BLI_mempool_free(hull_pool, t);
-       }
-
-       /* Fill hole boundary with triangles to new point */
-       for (e = edges.first; e; e = next) {
-               next = e->next;
-               hull_add_triangle(hull_triangles, hull_pool, e->v[0], e->v[1], v);
-               BLI_mempool_free(edge_pool, e);
-       }
-}
-
-static BMFace *hull_find_example_face(BMesh *bm, BMEdge *e)
-{
-       BMIter iter;
-       BMFace *f;
-
-       BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) {
-               if (BMO_elem_flag_test(bm, f, HULL_FLAG_INPUT) ||
-                   !BMO_elem_flag_test(bm, f, HULL_FLAG_OUTPUT_GEOM))
-               {
-                       return f;
-               }
-       }
-
-       return NULL;
-}
-
-static void hull_output_triangles(BMesh *bm, GHash *hull_triangles)
-{
-       GHashIterator iter;
-       
-       GHASH_ITER (iter, hull_triangles) {
-               HullTriangle *t = BLI_ghashIterator_getKey(&iter);
-
-               if (!t->skip) {
-                       BMEdge *edges[3] = {
-                               BM_edge_create(bm, t->v[0], t->v[1], NULL, TRUE),
-                               BM_edge_create(bm, t->v[1], t->v[2], NULL, TRUE),
-                               BM_edge_create(bm, t->v[2], t->v[0], NULL, TRUE)
-                       };
-                       BMFace *f, *example = NULL;
-                       int i;
-
-                       /* Look for an adjacent face that existed before the hull */
-                       for (i = 0; i < 3; i++) {
-                               if (!example)
-                                       example = hull_find_example_face(bm, edges[i]);
-                       }
-
-                       f = BM_face_create_quad_tri_v(bm, t->v, 3, example, FALSE);
-                       BM_face_copy_shared(bm, f);
-
-                       /* Mark face/verts/edges for 'geomout' slot and select */
-                       BMO_elem_flag_enable(bm, f, HULL_FLAG_OUTPUT_GEOM);
-                       BM_face_select_set(bm, f, TRUE);
-                       for (i = 0; i < 3; i++) {
-                               BMO_elem_flag_enable(bm, t->v[i], HULL_FLAG_OUTPUT_GEOM);
-                               BMO_elem_flag_enable(bm, edges[i], HULL_FLAG_OUTPUT_GEOM);
-                       }
-               }
-       }
-}
-
-
-
-/***************************** Final Edges ****************************/
-
-typedef struct {
-       GHash *edges;
-       BLI_mempool *base_pool, *link_pool;
-} HullFinalEdges;
-
-static LinkData *final_edges_find_link(ListBase *adj, BMVert *v)
-{
-       LinkData *link;
-
-       for (link = adj->first; link; link = link->next) {
-               if (link->data == v)
-                       return link;
-       }
-
-       return NULL;
-}
-
-static int hull_final_edges_lookup(HullFinalEdges *final_edges,
-                                   BMVert *v1, BMVert *v2)
-{
-       ListBase *adj;
-
-       /* Use lower vertex pointer for hash key */
-       if (v1 > v2)
-               SWAP(BMVert *, v1, v2);
-
-       adj = BLI_ghash_lookup(final_edges->edges, v1);
-       if (!adj)
-               return FALSE;
-
-       return !!final_edges_find_link(adj, v2);
-}
-
-/* Used for checking whether a pre-existing edge lies on the hull */
-static HullFinalEdges *hull_final_edges(GHash *hull_triangles)
-{
-       HullFinalEdges *final_edges;
-       GHashIterator iter;
-       
-       final_edges = MEM_callocN(sizeof(HullFinalEdges), "HullFinalEdges");
-       final_edges->edges = BLI_ghash_new(BLI_ghashutil_ptrhash,
-                                          BLI_ghashutil_ptrcmp,
-                                          "final edges ghash");
-       final_edges->base_pool = BLI_mempool_create(sizeof(ListBase), 128, 128, 0);
-       final_edges->link_pool = BLI_mempool_create(sizeof(LinkData), 128, 128, 0);
-
-       GHASH_ITER (iter, hull_triangles) {
-               LinkData *link;
-               int i;
-               
-               for (i = 0; i < 3; i++) {
-                       HullTriangle *t = BLI_ghashIterator_getKey(&iter);
-                       BMVert *v1 = t->v[i];
-                       BMVert *v2 = t->v[(i + 1) % 3];
-                       ListBase *adj;
-
-                       /* Use lower vertex pointer for hash key */
-                       if (v1 > v2)
-                               SWAP(BMVert *, v1, v2);
-
-                       adj = BLI_ghash_lookup(final_edges->edges, v1);
-                       if (!adj) {
-                               adj = BLI_mempool_calloc(final_edges->base_pool);
-                               BLI_ghash_insert(final_edges->edges, v1, adj);
-                       }
-
-                       if (!final_edges_find_link(adj, v2)) {
-                               link = BLI_mempool_calloc(final_edges->link_pool);
-                               link->data = v2;
-                               BLI_addtail(adj, link);
-                       }
-               }
-       }
-
-       return final_edges;
-}
-
-static void hull_final_edges_free(HullFinalEdges *final_edges)
-{
-       BLI_ghash_free(final_edges->edges, NULL, NULL);
-       BLI_mempool_destroy(final_edges->base_pool);
-       BLI_mempool_destroy(final_edges->link_pool);
-       MEM_freeN(final_edges);
-}
-
-
-
-/************************* Initial Tetrahedron ************************/
-
-static void hull_add_tetrahedron(GHash *hull_triangles, BLI_mempool *pool,
-                                 BMVert *tetra[4])
-{
-       float center[3];
-       int i, indices[4][3] = {
-               {0, 1, 2},
-               {0, 2, 3},
-               {1, 0, 3},
-               {2, 1, 3}};
-
-       /* Calculate center */
-       zero_v3(center);
-       for (i = 0; i < 4; i++)
-               add_v3_v3(center, tetra[i]->co);
-       mul_v3_fl(center, 0.25f);
-
-       for (i = 0; i < 4; i++) {
-               BMVert *v1 = tetra[indices[i][0]];
-               BMVert *v2 = tetra[indices[i][1]];
-               BMVert *v3 = tetra[indices[i][2]];
-               float no[3], d[3];
-
-               normal_tri_v3(no, v1->co, v2->co, v3->co);
-               sub_v3_v3v3(d, center, v1->co);
-               if (dot_v3v3(no, d) > 0)
-                       SWAP(BMVert *, v1, v3);
-
-               hull_add_triangle(hull_triangles, pool, v1, v2, v3);
-       }
-}
-
-/* For each axis, get the minimum and maximum input vertices */
-static void hull_get_min_max(BMesh *bm, BMOperator *op,
-                             BMVert *min[3], BMVert *max[3])
-{
-       BMOIter oiter;
-       BMVert *v;
-
-       min[0] = min[1] = min[2] = NULL;
-       max[0] = max[1] = max[2] = NULL;
-
-       BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
-               int i;
-               
-               for (i = 0; i < 3; i++) {
-                       if (!min[i] || v->co[i] < min[i]->co[i])
-                               min[i] = v;
-                       if (!max[i] || v->co[i] > max[i]->co[i])
-                               max[i] = v;
-               }
-       }
-}
-
-/* Returns true if input is coplanar */
-static int hull_find_large_tetrahedron(BMesh *bm, BMOperator *op,
-                                       BMVert *tetra[4])
-{
-       BMVert *min[3], *max[3], *v;
-       BMOIter oiter;
-       float widest_axis_len, largest_dist, plane_normal[3];
-       int i, j, widest_axis;
-       
-       hull_get_min_max(bm, op, min, max);
-
-       /* Check for flat axis */
-       for (i = 0; i < 3; i++) {
-               if (min[i] == max[i]) {
-                       return TRUE;
-               }
-       }
-
-       /* Find widest axis */
-       widest_axis_len = 0.0f;
-       widest_axis = 0; /* set here in the unlikey case this isn't set below */
-       for (i = 0; i < 3; i++) {
-               float len = (max[i]->co[i] - min[i]->co[i]);
-               if (len >= widest_axis_len) {
-                       widest_axis_len = len;
-                       widest_axis = i;
-               }
-       }
-
-       /* Use widest axis for first two points */
-       tetra[0] = min[widest_axis];
-       tetra[1] = max[widest_axis];
-       BMO_elem_flag_enable(bm, tetra[0], HULL_FLAG_TETRA_VERT);
-       BMO_elem_flag_enable(bm, tetra[1], HULL_FLAG_TETRA_VERT);
-
-       /* Choose third vertex farthest from existing line segment */
-       largest_dist = 0;
-       tetra[2] = NULL;
-       for (i = 0; i < 3; i++) {
-               BMVert *v;
-               float dist;
-
-               if (i == widest_axis)
-                       continue;
-
-               v = min[i];
-               for (j = 0; j < 2; j++) {
-                       dist = dist_to_line_segment_v3(v->co, tetra[0]->co, tetra[1]->co);
-                       if (dist > largest_dist) {
-                               largest_dist = dist;
-                               tetra[2] = v;
-                       }
-
-                       v = max[i];
-               }
-       }
-
-       if (tetra[2]) {
-               BMO_elem_flag_enable(bm, tetra[2], HULL_FLAG_TETRA_VERT);
-       }
-       else {
-               return TRUE;
-       }
-
-       /* Check for colinear vertices */
-       if (largest_dist < 0.0001)
-               return TRUE;
-
-       /* Choose fourth point farthest from existing plane */
-       largest_dist = 0;
-       normal_tri_v3(plane_normal, tetra[0]->co, tetra[1]->co, tetra[2]->co);
-       BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
-               if (!BMO_elem_flag_test(bm, v, HULL_FLAG_TETRA_VERT)) {
-                       float dist = dist_to_plane_v3(v->co, tetra[0]->co, plane_normal);
-                       if (dist > largest_dist) {
-                               largest_dist = dist;
-                               tetra[3] = v;
-                       }
-               }
-       }
-
-       if (tetra[3]) {
-               BMO_elem_flag_enable(bm, tetra[3], HULL_FLAG_TETRA_VERT);
-       }
-       else {
-               return TRUE;
-       }
-
-       if (largest_dist < 0.0001)
-               return TRUE;
-
-       return FALSE;
-}
-
-
-
-/**************************** Final Output ****************************/
-
-static void hull_remove_overlapping(BMesh *bm, GHash *hull_triangles,
-                                    HullFinalEdges *final_edges)
-{
-       GHashIterator hull_iter;
-
-       GHASH_ITER (hull_iter, hull_triangles) {
-               HullTriangle *t = BLI_ghashIterator_getKey(&hull_iter);
-               BMIter bm_iter1, bm_iter2;
-               BMFace *f;
-               int f_on_hull;
-
-               BM_ITER_ELEM (f, &bm_iter1, t->v[0], BM_FACES_OF_VERT) {
-                       BMEdge *e;
-
-                       /* Check that all the face's edges are on the hull,
-                          otherwise can't reuse it */
-                       f_on_hull = TRUE;
-                       BM_ITER_ELEM (e, &bm_iter2, f, BM_EDGES_OF_FACE) {
-                               if (!hull_final_edges_lookup(final_edges, e->v1, e->v2)) {
-                                       f_on_hull = FALSE;
-                                       break;
-                               }
-                       }
-                       
-                       /* Note: can't change ghash while iterating, so mark
-                          with 'skip' flag rather than deleting triangles */
-                       if (BM_vert_in_face(f, t->v[1]) &&
-                           BM_vert_in_face(f, t->v[2]) && f_on_hull) {
-                               t->skip = TRUE;
-                               BMO_elem_flag_disable(bm, f, HULL_FLAG_INTERIOR_ELE);
-                               BMO_elem_flag_enable(bm, f, HULL_FLAG_HOLE);
-                       }
-               }
-       }
-}
-
-static void hull_mark_interior_elements(BMesh *bm, BMOperator *op,
-                                        GHash *hull_triangles,
-                                        HullFinalEdges *final_edges)
-{
-       BMVert *v;
-       BMEdge *e;
-       BMFace *f;
-       BMOIter oiter;
-
-       /* Check all input vertices again to see if they are actually part
-          of the hull */
-       BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
-               if (!hull_test_v_outside(hull_triangles, v)) {
-                       /* Mark for 'interior_verts' slot */
-                       BMO_elem_flag_enable(bm, v, HULL_FLAG_INTERIOR_ELE);
-               }
-       }
-
-       /* Check for interior edges too */
-       BMO_ITER (e, &oiter, bm, op, "input", BM_EDGE) {
-               if (!hull_final_edges_lookup(final_edges, e->v1, e->v2))
-                       BMO_elem_flag_enable(bm, e, HULL_FLAG_INTERIOR_ELE);
-       }
-
-       /* Mark all input faces as interior, some may be unmarked in
-          hull_remove_overlapping() */
-       BMO_ITER (f, &oiter, bm, op, "input", BM_FACE) {
-               BMO_elem_flag_enable(bm, f, HULL_FLAG_INTERIOR_ELE);
-       }
-}
-
-static void hull_tag_unused(BMesh *bm, BMOperator *op)
-{
-       BMIter iter;
-       BMOIter oiter;
-       BMVert *v;
-       BMEdge *e;
-       BMFace *f;
-
-       /* Mark vertices, edges, and faces that are already marked
-          interior (i.e. were already part of the input, but not part of
-          the hull), but that aren't also used by elements outside the
-          input set */
-       BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
-               if (BMO_elem_flag_test(bm, v, HULL_FLAG_INTERIOR_ELE)) {
-                       int del = TRUE;
-               
-                       BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
-                               if (!BMO_elem_flag_test(bm, e, HULL_FLAG_INPUT)) {
-                                       del = FALSE;
-                                       break;
-                               }
-                       }
-
-                       BM_ITER_ELEM (f, &iter, v, BM_FACES_OF_VERT) {
-                               if (!BMO_elem_flag_test(bm, f, HULL_FLAG_INPUT)) {
-                                       del = FALSE;
-                                       break;
-                               }
-                       }
-
-                       if (del)
-                               BMO_elem_flag_enable(bm, v, HULL_FLAG_DEL);
-               }
-       }
-
-       BMO_ITER (e, &oiter, bm, op, "input", BM_EDGE) {
-               if (BMO_elem_flag_test(bm, e, HULL_FLAG_INTERIOR_ELE)) {
-                       int del = TRUE;
-
-                       BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) {
-                               if (!BMO_elem_flag_test(bm, f, HULL_FLAG_INPUT)) {
-                                       del = FALSE;
-                                       break;
-                               }
-                       }
-
-                       if (del)
-                               BMO_elem_flag_enable(bm, e, HULL_FLAG_DEL);
-               }
-       }
-
-       BMO_ITER (f, &oiter, bm, op, "input", BM_FACE) {
-               if (BMO_elem_flag_test(bm, f, HULL_FLAG_INTERIOR_ELE))
-                       BMO_elem_flag_enable(bm, f, HULL_FLAG_DEL);
-       }
-}
-
-void hull_tag_holes(BMesh *bm, BMOperator *op)
-{
-       BMIter iter;
-       BMOIter oiter;
-       BMFace *f;
-       BMEdge *e;
-
-       /* Unmark any hole faces if they are isolated or part of a
-        * border */
-       BMO_ITER (f, &oiter, bm, op, "input", BM_FACE) {
-               if (BMO_elem_flag_test(bm, f, HULL_FLAG_HOLE)) {
-                       BM_ITER_ELEM (e, &iter, f, BM_EDGES_OF_FACE) {
-                               if (BM_edge_face_count(e) == 1) {
-                                       BMO_elem_flag_disable(bm, f, HULL_FLAG_HOLE);
-                                       break;
-                               }
-                       }
-               }
-       }
-
-       /* Mark edges too if all adjacent faces are holes */
-       BMO_ITER (e, &oiter, bm, op, "input", BM_EDGE) {
-               int hole = TRUE;
-               
-               BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) {
-                       if (!BMO_elem_flag_test(bm, f, HULL_FLAG_HOLE)) {
-                               hole = FALSE;
-                               break;
-                       }
-               }
-
-               if (hole)
-                       BMO_elem_flag_enable(bm, e, HULL_FLAG_HOLE);
-       }
-}
-
-void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
-{
-       HullFinalEdges *final_edges;
-       BLI_mempool *hull_pool, *edge_pool;
-       BMVert *v, *tetra[4];
-       BMElemF *ele;
-       BMOIter oiter;
-       GHash *hull_triangles;
-
-       /* Verify that at least four verts in the input */
-       if (BMO_slot_get(op, "input")->len < 4) {
-               BMO_error_raise(bm, op, BMERR_CONVEX_HULL_FAILED,
-                               "Requires at least four vertices");
-               return;
-       }
-
-       /* Initialize the convex hull by building a tetrahedron. A
-        * degenerate tetrahedron can cause problems, so report error and
-        * fail if the result is coplanar */
-       if (hull_find_large_tetrahedron(bm, op, tetra)) {
-               BMO_error_raise(bm, op, BMERR_CONVEX_HULL_FAILED,
-                               "Input vertices are coplanar");
-               return;
-       }
-
-       /* Tag input elements */
-       BMO_ITER (ele, &oiter, bm, op, "input", BM_ALL)
-               BMO_elem_flag_enable(bm, ele, HULL_FLAG_INPUT);
-
-       edge_pool = BLI_mempool_create(sizeof(HullBoundaryEdge), 128, 128, 0);
-       hull_pool = BLI_mempool_create(sizeof(HullTriangle), 128, 128, 0);
-       hull_triangles = BLI_ghash_new(BLI_ghashutil_ptrhash,
-                                      BLI_ghashutil_ptrcmp,
-                                      "hull_triangles");
-
-       /* Add tetrahedron triangles */
-       hull_add_tetrahedron(hull_triangles, hull_pool, tetra);
-
-       /* Expand hull to cover new vertices outside the existing hull */
-       BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
-               if (!BMO_elem_flag_test(bm, v, HULL_FLAG_TETRA_VERT)) {
-                       GHash *outside = hull_triangles_v_outside(hull_triangles, v);
-                       if (BLI_ghash_size(outside)) {
-                               /* Expand hull and delete interior triangles */
-                               add_point(hull_triangles, hull_pool, edge_pool, outside, v);
-                       }
-                       BLI_ghash_free(outside, NULL, NULL);
-               }
-       }
-
-       BLI_mempool_destroy(edge_pool);
-       final_edges = hull_final_edges(hull_triangles);
-       
-       hull_mark_interior_elements(bm, op, hull_triangles, final_edges);
-
-       /* Remove hull triangles covered by an existing face */
-       if (BMO_slot_bool_get(op, "use_existing_faces")) {
-               hull_remove_overlapping(bm, hull_triangles, final_edges);
-
-               hull_tag_holes(bm, op);
-       }
-
-       /* Done with edges */
-       hull_final_edges_free(final_edges);
-
-       /* Convert hull triangles to BMesh faces */
-       hull_output_triangles(bm, hull_triangles);
-       BLI_mempool_destroy(hull_pool);
-
-       BLI_ghash_free(hull_triangles, NULL, NULL);
-
-       hull_tag_unused(bm, op);
-
-       /* Output slot of input elements that ended up inside the hull
-        * rather than part of it */
-       BMO_slot_buffer_from_enabled_flag(bm, op, "interior_geom", BM_ALL,
-                                         HULL_FLAG_INTERIOR_ELE);
-
-       /* Output slot of input elements that ended up inside the hull and
-        * are are unused by other geometry. */
-       BMO_slot_buffer_from_enabled_flag(bm, op, "unused_geom", BM_ALL,
-                                         HULL_FLAG_DEL);
-
-       /* Output slot of faces and edges that were in the input and on
-        * the hull (useful for cases like bridging where you want to
-        * delete some input geometry) */
-       BMO_slot_buffer_from_enabled_flag(bm, op, "holes_geom", BM_ALL,
-                                         HULL_FLAG_HOLE);
-
-       /* Output slot of all hull vertices, faces, and edges */
-       BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL,
-                                         HULL_FLAG_OUTPUT_GEOM);
-}
diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c
deleted file mode 100644 (file)
index 7cb8ac0..0000000
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/bmesh/operators/bmo_wireframe.c
- *  \ingroup bmesh
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-
-#include "BKE_customdata.h"
-
-#include "bmesh.h"
-
-#include "intern/bmesh_operators_private.h" /* own include */
-
-BMLoop *bm_edge_tag_faceloop(BMEdge *e)
-{
-       BMLoop *l, *l_first;
-
-       l = l_first = e->l;
-       do {
-               if (BM_elem_flag_test(l->f, BM_ELEM_TAG)) {
-                       return l;
-               }
-       } while ((l = l->radial_next) != l_first);
-
-       /* in the case this is used, we know this will never happen */
-       return NULL;
-}
-
-static void bm_vert_boundary_tangent(BMVert *v, float r_no[3], float r_no_face[3],
-                                     BMVert **r_va_other, BMVert **r_vb_other)
-{
-       BMIter iter;
-       BMEdge *e_iter;
-
-       BMEdge *e_a = NULL, *e_b = NULL;
-       BMVert *v_a, *v_b;
-
-       BMLoop *l_a, *l_b;
-
-       float no_face[3], no_edge[3];
-       float tvec_a[3], tvec_b[3];
-
-       /* get 2 boundary edges, there should only _be_ 2,
-        * in case there are more - results wont be valid of course */
-       BM_ITER_ELEM (e_iter, &iter, v, BM_EDGES_OF_VERT) {
-               if (BM_elem_flag_test(e_iter, BM_ELEM_TAG)) {
-                       if (e_a == NULL) {
-                               e_a = e_iter;
-                       }
-                       else {
-                               e_b = e_iter;
-                               break;
-                       }
-               }
-       }
-
-       l_a = bm_edge_tag_faceloop(e_a);
-       l_b = bm_edge_tag_faceloop(e_b);
-
-       /* average edge face normal */
-       add_v3_v3v3(no_face, l_a->f->no, l_b->f->no);
-
-       /* average edge direction */
-       v_a = BM_edge_other_vert(e_a, v);
-       v_b = BM_edge_other_vert(e_b, v);
-
-       sub_v3_v3v3(tvec_a, v->co, v_a->co);
-       sub_v3_v3v3(tvec_b, v_b->co, v->co);
-       normalize_v3(tvec_a);
-       normalize_v3(tvec_b);
-       add_v3_v3v3(no_edge, tvec_a, tvec_b); /* not unit length but this is ok */
-
-
-       /* find the normal */
-       cross_v3_v3v3(r_no, no_edge, no_face);
-       normalize_v3(r_no);
-
-       /* check are we flipped the right way */
-       BM_edge_calc_face_tangent(e_a, l_a, tvec_a);
-       BM_edge_calc_face_tangent(e_b, l_b, tvec_b);
-       add_v3_v3(tvec_a, tvec_b);
-
-       if (dot_v3v3(r_no, tvec_a) > 0.0) {
-               negate_v3(r_no);
-       }
-
-       copy_v3_v3(r_no_face, no_face);
-       *r_va_other = v_a;
-       *r_vb_other = v_b;
-}
-
-/* check if we are the only tagged loop-face around this edge */
-static int bm_loop_is_radial_boundary(BMLoop *l_first)
-{
-       BMLoop *l = l_first->radial_next;
-
-       if (l == l_first) {
-               return TRUE; /* a real boundary */
-       }
-       else {
-               do {
-                       if (BM_elem_flag_test(l->f, BM_ELEM_TAG)) {
-                               return FALSE;
-                       }
-               } while ((l = l->radial_next) != l_first);
-       }
-       return TRUE;
-}
-
-extern float BM_vert_calc_mean_tagged_edge_length(BMVert *v);
-
-void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
-{
-       const int use_boundary        = BMO_slot_bool_get(op,  "use_boundary");
-       const int use_even_offset     = BMO_slot_bool_get(op,  "use_even_offset");
-       const int use_relative_offset = BMO_slot_bool_get(op,  "use_relative_offset");
-       const int use_crease          = (BMO_slot_bool_get(op,  "use_crease") &&
-                                        CustomData_has_layer(&bm->edata, CD_CREASE));
-       const float depth             = BMO_slot_float_get(op, "thickness");
-       const float inset             = depth;
-
-       const int totvert_orig = bm->totvert;
-
-       BMOIter oiter;
-       BMIter iter;
-       BMIter itersub;
-
-       /* filled only with boundary verts */
-       BMVert **verts_src      = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__);
-       BMVert **verts_neg      = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__);
-       BMVert **verts_pos      = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__);
-
-       /* will over-alloc, but makes for easy lookups by index to keep aligned  */
-       BMVert **verts_boundary = use_boundary ?
-                                 MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__) : NULL;
-
-       float  *verts_relfac    = use_relative_offset ?
-                                 MEM_mallocN(sizeof(float) * totvert_orig, __func__) : NULL;
-
-       /* may over-alloc if not all faces have wire */
-       BMVert **verts_loop;
-       int verts_loop_tot = 0;
-
-       BMVert *v_src;
-
-       BMFace *f_src;
-       BMLoop *l;
-
-       float tvec[3];
-       float fac;
-
-       int i;
-
-       BM_mesh_elem_index_ensure(bm, BM_VERT);
-
-       BM_ITER_MESH_INDEX (v_src, &iter, bm, BM_VERTS_OF_MESH, i) {
-               BM_elem_flag_disable(v_src, BM_ELEM_TAG);
-               verts_src[i] = v_src;
-       }
-
-       /* setup tags, all faces and verts will be tagged which will be duplicated */
-       BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE);
-
-       BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) {
-               verts_loop_tot += f_src->len;
-               BM_elem_flag_enable(f_src, BM_ELEM_TAG);
-               BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) {
-                       BM_elem_flag_enable(l->v, BM_ELEM_TAG);
-
-                       /* also tag boundary edges */
-                       BM_elem_flag_set(l->e, BM_ELEM_TAG, bm_loop_is_radial_boundary(l));
-               }
-       }
-
-       /* duplicate tagged verts */
-       for (i = 0, v_src = verts_src[i]; i < totvert_orig; i++, v_src = verts_src[i]) {
-               if (BM_elem_flag_test(v_src, BM_ELEM_TAG)) {
-                       fac = depth;
-
-                       if (use_relative_offset) {
-                               verts_relfac[i] = BM_vert_calc_mean_tagged_edge_length(v_src);
-                               fac *= verts_relfac[i];
-                       }
-
-                       madd_v3_v3v3fl(tvec, v_src->co, v_src->no, -fac);
-                       verts_neg[i] = BM_vert_create(bm, tvec, v_src);
-                       madd_v3_v3v3fl(tvec, v_src->co, v_src->no,  fac);
-                       verts_pos[i] = BM_vert_create(bm, tvec, v_src);
-               }
-               else {
-                       /* could skip this */
-                       verts_src[i] = NULL;
-                       verts_neg[i] = NULL;
-                       verts_pos[i] = NULL;
-               }
-
-               /* conflicts with BM_vert_calc_mean_tagged_edge_length */
-               if (use_relative_offset == FALSE) {
-                       BM_elem_flag_disable(v_src, BM_ELEM_TAG);
-               }
-       }
-
-       if (use_relative_offset) {
-               BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, FALSE);
-       }
-
-       verts_loop = MEM_mallocN(sizeof(BMVert **) * verts_loop_tot, __func__);
-       verts_loop_tot = 0; /* count up again */
-
-       BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) {
-               BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) {
-                       BM_elem_index_set(l, verts_loop_tot); /* set_loop */
-
-                       BM_loop_calc_face_tangent(l, tvec);
-
-                       /* create offset vert */
-                       fac = inset;
-                       if (use_even_offset) {
-                               fac *= shell_angle_to_dist((M_PI - BM_loop_calc_face_angle(l)) * 0.5f);
-                       }
-                       if (use_relative_offset) {
-                               fac *= verts_relfac[BM_elem_index_get(l->v)];
-                       }
-
-                       madd_v3_v3v3fl(tvec, l->v->co, tvec, fac);
-                       verts_loop[verts_loop_tot] = BM_vert_create(bm, tvec, l->v);
-
-
-                       if (use_boundary) {
-                               if (BM_elem_flag_test(l->e, BM_ELEM_TAG)) {  /* is this a boundary? */
-
-                                       BMLoop *l_pair[2] = {l, l->next};
-
-                                       BM_elem_flag_enable(l->e, BM_ELEM_TAG);
-                                       for (i = 0; i < 2; i++) {
-                                               if (!BM_elem_flag_test(l_pair[i]->v, BM_ELEM_TAG)) {
-                                                       float no_face[3];
-                                                       BMVert *va_other;
-                                                       BMVert *vb_other;
-
-                                                       BM_elem_flag_enable(l_pair[i]->v, BM_ELEM_TAG);
-
-                                                       bm_vert_boundary_tangent(l_pair[i]->v, tvec, no_face, &va_other, &vb_other);
-
-                                                       /* create offset vert */
-                                                       /* similar to code above but different angle calc */
-                                                       fac = inset;
-                                                       if (use_even_offset) {
-                                                               fac *= shell_angle_to_dist((M_PI - angle_on_axis_v3v3v3_v3(va_other->co,
-                                                                                                                          l_pair[i]->v->co,
-                                                                                                                          vb_other->co,
-                                                                                                                          no_face)) * 0.5f);
-                                                       }
-                                                       if (use_relative_offset) {
-                                                               fac *= verts_relfac[BM_elem_index_get(l_pair[i]->v)];
-                                                       }
-                                                       madd_v3_v3v3fl(tvec, l_pair[i]->v->co, tvec, fac);
-                                                       verts_boundary[BM_elem_index_get(l_pair[i]->v)] = BM_vert_create(bm, tvec, l_pair[i]->v);
-                                               }
-                                       }
-                               }
-                       }
-
-                       verts_loop_tot++;
-               }
-       }
-
-       BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) {
-               BM_elem_flag_disable(f_src, BM_ELEM_TAG);
-               BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) {
-                       BMFace *f_new;
-                       BMLoop *l_new;
-                       BMLoop *l_next = l->next;
-                       BMVert *v_l1 = verts_loop[BM_elem_index_get(l)];
-                       BMVert *v_l2 = verts_loop[BM_elem_index_get(l_next)];
-
-                       BMVert *v_src_l1 = l->v;
-                       BMVert *v_src_l2 = l_next->v;
-
-                       const int i_1 = BM_elem_index_get(v_src_l1);
-                       const int i_2 = BM_elem_index_get(v_src_l2);
-
-                       BMVert *v_neg1 = verts_neg[i_1];
-                       BMVert *v_neg2 = verts_neg[i_2];
-
-                       BMVert *v_pos1 = verts_pos[i_1];
-                       BMVert *v_pos2 = verts_pos[i_2];
-
-                       f_new = BM_face_create_quad_tri(bm, v_l1, v_l2, v_neg2, v_neg1, f_src, FALSE);
-                       BM_elem_flag_enable(f_new, BM_ELEM_TAG);
-                       l_new = BM_FACE_FIRST_LOOP(f_new);
-
-                       BM_elem_attrs_copy(bm, bm, l,      l_new);
-                       BM_elem_attrs_copy(bm, bm, l,      l_new->prev);
-                       BM_elem_attrs_copy(bm, bm, l_next, l_new->next);
-                       BM_elem_attrs_copy(bm, bm, l_next, l_new->next->next);
-
-                       f_new = BM_face_create_quad_tri(bm, v_l2, v_l1, v_pos1, v_pos2, f_src, FALSE);
-                       BM_elem_flag_enable(f_new, BM_ELEM_TAG);
-                       l_new = BM_FACE_FIRST_LOOP(f_new);
-
-                       BM_elem_attrs_copy(bm, bm, l_next, l_new);
-                       BM_elem_attrs_copy(bm, bm, l_next, l_new->prev);
-                       BM_elem_attrs_copy(bm, bm, l,      l_new->next);
-                       BM_elem_attrs_copy(bm, bm, l,      l_new->next->next);
-
-                       if (use_boundary) {
-                               if (BM_elem_flag_test(l->e, BM_ELEM_TAG)) {
-                                       /* we know its a boundary and this is the only face user (which is being wire'd) */
-                                       /* we know we only touch this edge/face once */
-                                       BMVert *v_b1 = verts_boundary[i_1];
-                                       BMVert *v_b2 = verts_boundary[i_2];
-
-                                       f_new = BM_face_create_quad_tri(bm, v_b2, v_b1, v_neg1, v_neg2, f_src, FALSE);
-                                       BM_elem_flag_enable(f_new, BM_ELEM_TAG);
-                                       l_new = BM_FACE_FIRST_LOOP(f_new);
-
-                                       BM_elem_attrs_copy(bm, bm, l_next, l_new);
-                                       BM_elem_attrs_copy(bm, bm, l_next, l_new->prev);
-                                       BM_elem_attrs_copy(bm, bm, l,      l_new->next);
-                                       BM_elem_attrs_copy(bm, bm, l,      l_new->next->next);
-
-                                       f_new = BM_face_create_quad_tri(bm, v_b1, v_b2, v_pos2, v_pos1, f_src, FALSE);
-                                       BM_elem_flag_enable(f_new, BM_ELEM_TAG);
-                                       l_new = BM_FACE_FIRST_LOOP(f_new);
-
-                                       BM_elem_attrs_copy(bm, bm, l,      l_new);
-                                       BM_elem_attrs_copy(bm, bm, l,      l_new->prev);
-                                       BM_elem_attrs_copy(bm, bm, l_next, l_new->next);
-                                       BM_elem_attrs_copy(bm, bm, l_next, l_new->next->next);
-
-                                       if (use_crease) {
-                                               BMEdge *e_new;
-                                               e_new = BM_edge_exists(v_pos1, v_b1);
-                                               BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f);
-
-                                               e_new = BM_edge_exists(v_pos2, v_b2);
-                                               BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f);
-
-                                               e_new = BM_edge_exists(v_neg1, v_b1);
-                                               BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f);
-
-                                               e_new = BM_edge_exists(v_neg2, v_b2);
-                                               BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f);
-                                       }
-                               }
-                       }
-
-                       if (use_crease) {
-                               BMEdge *e_new;
-                               e_new = BM_edge_exists(v_pos1, v_l1);
-                               BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f);
-
-                               e_new = BM_edge_exists(v_pos2, v_l2);
-                               BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f);
-
-                               e_new = BM_edge_exists(v_neg1, v_l1);
-                               BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f);
-
-                               e_new = BM_edge_exists(v_neg2, v_l2);
-                               BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f);
-                       }
-
-               }
-       }
-
-       if (use_boundary) {
-               MEM_freeN(verts_boundary);
-       }
-
-       if (use_relative_offset) {
-               MEM_freeN(verts_relfac);
-       }
-
-       MEM_freeN(verts_src);
-       MEM_freeN(verts_neg);
-       MEM_freeN(verts_pos);
-       MEM_freeN(verts_loop);
-
-       BMO_slot_buffer_from_enabled_hflag(bm, op, "faceout", BM_FACE, BM_ELEM_TAG);
-}
index ee9d776..28de0b4 100644 (file)
@@ -196,6 +196,7 @@ void OBJECT_OT_vertex_group_select(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_group_deselect(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_group_copy_to_linked(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_group_copy_to_selected(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_copy_to_selected_single(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_group_copy(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_group_normalize(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_group_normalize_all(struct wmOperatorType *ot);
index 4cd18d9..72f2317 100644 (file)
@@ -170,6 +170,7 @@ void ED_operatortypes_object(void)
        WM_operatortype_append(OBJECT_OT_vertex_group_deselect);
        WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_linked);
        WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_selected);
+       WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_selected_single);
        WM_operatortype_append(OBJECT_OT_vertex_group_copy);
        WM_operatortype_append(OBJECT_OT_vertex_group_normalize);
        WM_operatortype_append(OBJECT_OT_vertex_group_normalize_all);
index b4d5d2c..cc01e83 100644 (file)
@@ -20,7 +20,7 @@
  *
  * The Original Code is: all of this file.
  *
- * Contributor(s): none yet.
+ * Contributor(s): Ove M Henriksen
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -75,6 +75,7 @@
 #include "UI_resources.h"
 
 #include "object_intern.h"
+#include <stdio.h> /*only for development purposes, remove*/
 
 /************************ Exported Functions **********************/
 static void vgroup_remap_update_users(Object *ob, int *map);
@@ -311,18 +312,17 @@ int ED_vgroup_give_array(ID *id, MDeformVert **dvert_arr, int *dvert_tot)
        return FALSE;
 }
 
-/* matching index only */
+/*Copy all vertex groups to target, overwriting existing. matching index only*/
 int ED_vgroup_copy_array(Object *ob, Object *ob_from)
 {
        MDeformVert **dvert_array_from, **dvf;
        MDeformVert **dvert_array, **dv;
-       int dvert_tot_from;
-       int dvert_tot;
-       int i;
+       int dvert_tot_from, dvert_tot, i;
        int defbase_tot_from = BLI_countlist(&ob_from->defbase);
        int defbase_tot = BLI_countlist(&ob->defbase);
        short new_vgroup = FALSE;
 
+       /*get vertex groups arrays*/
        ED_vgroup_give_parray(ob_from->data, &dvert_array_from, &dvert_tot_from, FALSE);
        ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE);
 
@@ -376,6 +376,209 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from)
        return 1;
 }
 
+/*Copy a single vertex group from source to destination with weights*/
+int ED_vgroup_copy_single(Object *ob_dst, const Object *ob_src)
+{
+       MDeformVert **dv_array_src;
+       MDeformVert **dv_array_dst;
+       MDeformWeight *dw_dst, *dw_src;
+       int dv_tot_src, dv_tot_dst;
+       int i, index_src, index_dst;
+       bDeformGroup *dg_src, *dg_dst;
+
+       /*get source deform group*/
+       dg_src= BLI_findlink(&ob_src->defbase, (ob_src->actdef-1));
+
+       /*Create new and overwrite vertex group on destination without data*/
+       ED_vgroup_delete(ob_dst, defgroup_find_name(ob_dst, dg_src->name));
+       ED_vgroup_add_name(ob_dst, dg_src->name);
+
+       /*get destination deformgroup*/
+       dg_dst= defgroup_find_name(ob_dst, dg_src->name);
+
+       /*get vertex group arrays*/
+       ED_vgroup_give_parray(ob_src->data, &dv_array_src, &dv_tot_src, FALSE);
+       ED_vgroup_give_parray(ob_dst->data, &dv_array_dst, &dv_tot_dst, FALSE);
+
+       /*get indexes of vertex groups*/
+       index_src= BLI_findindex(&ob_src->defbase, dg_src);
+       index_dst= BLI_findindex(&ob_dst->defbase, dg_dst);
+
+       /*Check if indices are matching, delete and return if not*/
+       if (ob_dst == ob_src || dv_tot_dst == 0 || (dv_tot_dst != dv_tot_src) || dv_array_src == NULL || dv_array_dst == NULL) {
+               ED_vgroup_delete(ob_dst, defgroup_find_name(ob_dst, dg_dst->name));
+               return 0;
+       }
+
+       /* Loop through the vertices and copy weight*/
+       for(i=0; i<dv_tot_dst; i++, dv_array_src++, dv_array_dst++) {
+               dw_src= defvert_verify_index(*dv_array_src, index_src);
+               dw_dst= defvert_verify_index(*dv_array_dst, index_dst);
+               dw_dst->weight= dw_src->weight;
+       }
+
+       return 1;
+}
+
+/*Copy a single vertex group from source to destination with weights by nearest weight*/
+int ED_vgroup_copy_by_nearest_vertex_single(Object *ob_dst, Object *ob_src)
+{
+       bDeformGroup *dg_src, *dg_dst;
+       MDeformVert **dv_array_src, **dv_array_dst;
+       MDeformWeight *dw_dst, *dw_src;
+       MVert *mv_dst;
+       Mesh *me_dst;
+       BVHTreeFromMesh tree_mesh_src;
+       BVHTreeNearest nearest;
+       DerivedMesh *dmesh_src;
+       int dv_tot_src, dv_tot_dst, i, index_dst, index_src;
+       float tmp_co[3], tmp_mat[4][4];
+
+       /*get source deform group*/
+       dg_src= BLI_findlink(&ob_src->defbase, (ob_src->actdef-1));
+
+       /*Create new and overwrite vertex group on destination without data*/
+       ED_vgroup_delete(ob_dst, defgroup_find_name(ob_dst, dg_src->name));
+       ED_vgroup_add_name(ob_dst, dg_src->name);
+
+       /*get destination deformgroup*/
+       dg_dst= defgroup_find_name(ob_dst, dg_src->name);
+
+       /*get meshes*/
+       me_dst= ob_dst->data;
+       dmesh_src= ob_src->derivedDeform;
+
+       /*make node tree*/
+       bvhtree_from_mesh_verts(&tree_mesh_src, dmesh_src, 0.0, 2, 6);
+
+       /*get vertex group arrays*/
+       ED_vgroup_give_parray(ob_src->data, &dv_array_src, &dv_tot_src, FALSE);
+       ED_vgroup_give_parray(ob_dst->data, &dv_array_dst, &dv_tot_dst, FALSE);
+
+       /*get indexes of vertex groups*/
+       index_src= BLI_findindex(&ob_src->defbase, dg_src);
+       index_dst= BLI_findindex(&ob_dst->defbase, dg_dst);
+
+       /*get vertices*/
+       mv_dst= me_dst->mvert;
+
+       /*Prepearing transformation matrix*/
+       /*This can be excluded to make a lazy feature that works better when object centers relative to mesh is the same*/
+       invert_m4_m4(ob_src->imat, ob_src->obmat);
+       mult_m4_m4m4(tmp_mat, ob_src->imat, ob_dst->obmat);
+
+       /* Loop through the vertices and copy weight from nearest weight*/
+       for(i=0; i < me_dst->totvert; i++, mv_dst++, dv_array_dst++){
+
+               /*Reset nearest*/
+               nearest.index= -1;
+               nearest.dist= FLT_MAX;
+
+               /*Transforming into target space*/
+               mul_v3_m4v3(tmp_co, tmp_mat, mv_dst->co);
+
+               /*Node tree accelerated search for closest vetex*/
+               BLI_bvhtree_find_nearest(tree_mesh_src.tree, tmp_co, &nearest, tree_mesh_src.nearest_callback, &tree_mesh_src);
+
+               /*copy weight*/
+               dw_src= defvert_verify_index(dv_array_src[nearest.index], index_src);
+               dw_dst= defvert_verify_index(*dv_array_dst, index_dst);
+               dw_dst->weight= dw_src->weight;
+       }
+
+       /*free memory and return*/
+       free_bvhtree_from_mesh(&tree_mesh_src);
+       return 1;
+}
+
+/*Copy a single vertex group from source to destination with weights by nearest weight*/
+/*TODO: transform into target space as in by_vertex function. postphoned due to easier testing during development*/
+int ED_vgroup_copy_by_nearest_face_single(Object *ob_dst, Object *ob_src)
+{
+       bDeformGroup *dg_src, *dg_dst;
+       MDeformVert **dv_array_src, **dv_array_dst;
+       MDeformWeight *dw_dst, *dw_src;
+       MVert *mv_dst;
+       MFace *mface_src;
+       Mesh *me_dst, *me_src;
+       BVHTreeFromMesh tree_mesh_faces_src;
+       BVHTreeNearest nearest;
+       DerivedMesh *dmesh_src;
+       int dv_tot_src, dv_tot_dst, i, index_dst, index_src;
+       float weight/*, tot_dist*/;
+
+       /*get source deform group*/
+       dg_src= BLI_findlink(&ob_src->defbase, (ob_src->actdef-1));
+
+       /*Create new and overwrite vertex group on destination without data*/
+       ED_vgroup_delete(ob_dst, defgroup_find_name(ob_dst, dg_src->name));
+       ED_vgroup_add_name(ob_dst, dg_src->name);
+
+       /*get destination deformgroup*/
+       dg_dst= defgroup_find_name(ob_dst, dg_src->name);
+
+       /*get meshes*/
+       me_dst= ob_dst->data;
+       me_src= ob_src->data;
+       dmesh_src= ob_src->derivedDeform; /*sergey- : this might easily be null?? (using ob_src.deriveddeform*/
+
+       /*make node tree*/
+       DM_ensure_tessface(dmesh_src);
+       bvhtree_from_mesh_faces(&tree_mesh_faces_src, dmesh_src, 0.0, 2, 6);
+
+
+       /*get vertex group arrays*/
+       ED_vgroup_give_parray(ob_src->data, &dv_array_src, &dv_tot_src, FALSE);
+       ED_vgroup_give_parray(ob_dst->data, &dv_array_dst, &dv_tot_dst, FALSE);
+
+       /*get indexes of vertex groups*/
+       index_src= BLI_findindex(&ob_src->defbase, dg_src);
+       index_dst= BLI_findindex(&ob_dst->defbase, dg_dst);
+
+       /*get vertices*/
+       mv_dst= me_dst->mvert;
+
+       /* Loop through the vertices and copy weight from nearest weight*/
+       for(i=0; i < me_dst->totvert; i++, mv_dst++, dv_array_dst++){
+
+               /*Reset nearest*/
+               nearest.index= -1;
+               nearest.dist= FLT_MAX;
+
+               /*Node tree accelerated search for closest face*/
+               BLI_bvhtree_find_nearest(tree_mesh_faces_src.tree, mv_dst->co, &nearest, tree_mesh_faces_src.nearest_callback, &tree_mesh_faces_src);
+
+               /*get weight*/
+               mface_src= me_src->mface + nearest.index;
+               /*tot_dist= ()+()+(); use a comparable distance
+               if(mface_src->v4){
+                       tot_dist+= ();
+               }*/
+               dw_src= defvert_verify_index(dv_array_src[mface_src->v1], index_src);
+               weight= dw_src->weight;
+               dw_src= defvert_verify_index(dv_array_src[mface_src->v2], index_src);
+               weight+= dw_src->weight;
+               dw_src= defvert_verify_index(dv_array_src[mface_src->v3], index_src);
+               weight+= dw_src->weight;
+               if(mface_src->v4){
+                       dw_src= defvert_verify_index(dv_array_src[mface_src->v4], index_src);
+                       weight+= dw_src->weight;
+                       weight/=4;
+               }
+               else{
+                       weight/=3;
+               }
+
+
+               /*copy weight*/
+               dw_dst= defvert_verify_index(*dv_array_dst, index_dst);
+               dw_dst->weight= weight;
+       }
+
+       /*free memory and return*/
+       free_bvhtree_from_mesh(&tree_mesh_faces_src);
+       return 1;
+}
 
 /* for Mesh in Object mode */
 /* allows editmode for Lattice */
@@ -1178,7 +1381,6 @@ static void vgroup_normalize_all(Object *ob, int lock_active)
        }
 }
 
-
 static void vgroup_lock_all(Object *ob, int action)
 {
        bDeformGroup *dg;
@@ -2295,6 +2497,7 @@ void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+/*Adds a copy of selected vertex group from source object to source object*/
 static int vertex_group_copy_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Object *ob = ED_object_context(C);
@@ -2707,6 +2910,7 @@ void OBJECT_OT_vertex_group_copy_to_linked(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+/*Copy vertex groups from source to target*/ /*warning! overwrites list*/
 static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op)
 {
        Object *obact = ED_object_context(C);
@@ -2731,22 +2935,74 @@ static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-
+/* Transfer all vertex groups with weight to selected*/
 void OBJECT_OT_vertex_group_copy_to_selected(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name = "Copy Vertex Group to Selected";
-       ot->idname = "OBJECT_OT_vertex_group_copy_to_selected";
-       ot->description = "Copy Vertex Groups to other selected objects with matching indices";
+       ot->name= "Copy Vertex Group to Selected";
+       ot->idname= "OBJECT_OT_vertex_group_copy_to_selected";
+       ot->description= "Copy Vertex Groups to other selected objects with matching indices";
 
        /* api callbacks */
-       ot->poll = vertex_group_poll;
-       ot->exec = vertex_group_copy_to_selected_exec;
+       ot->poll= vertex_group_poll;
+       ot->exec= vertex_group_copy_to_selected_exec;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+static int vertex_group_copy_to_selected_single_exec(bContext *C, wmOperator *op)
+{
+       Object *obact= CTX_data_active_object(C);
+       int change= 0;
+       int fail= 0;
+
+       /*Macro to loop through selected objects and perform operation*/
+       CTX_DATA_BEGIN(C, Object*, obslc, selected_editable_objects)
+       {
+               if(obact != obslc) {
+                       /*Try function for matching number of vertices*/
+                       if(ED_vgroup_copy_single(obslc, obact)) change++;
+                       /*Try function for get weight from closest vertex*/
+                       /*TODO: try this function*/
+                       /*Try function for get weight from closest face*/
+                       else if(ED_vgroup_copy_by_nearest_face_single(obslc, obact)) change++;
+                       /*Trigger error message*/
+                       else fail++;
+                       /*Event notifiers for correct display of data*/
+                       DAG_id_tag_update(&obslc->id, OB_RECALC_DATA);
+                       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obslc);
+                       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obslc->data);
+               }
+       }
+       CTX_DATA_END;
+
+       /*Report error when task can not be completed with available functions.*/
+       if((change == 0 && fail == 0) || fail) {
+               BKE_reportf(op->reports, RPT_ERROR,
+                           "Copy to VGroups to Selected warning done %d, failed %d, All functions failed!",
+                           change, fail);
+       }
+
+       return OPERATOR_FINISHED;
+}
+
+/*Transfer vertex group with weight to selected*/
+void OBJECT_OT_vertex_group_copy_to_selected_single(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Copy a Vertex Group to Selected";
+       ot->idname= "OBJECT_OT_vertex_group_copy_to_selected_single";
+       ot->description= "Copy a vertex group to other selected objects with matching indices";
+
+       /* api callbacks */
+       ot->poll= vertex_group_poll;
+       ot->exec= vertex_group_copy_to_selected_single_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 static EnumPropertyItem vgroup_items[] = {
        {0, NULL, 0, NULL, NULL}
 };
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
deleted file mode 100644 (file)
index d1733cf..0000000
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2012 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Blender Foundation,
- *                 Sergey Sharybin
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_clip/clip_graph_draw.c
- *  \ingroup spclip
- */
-
-#include "DNA_movieclip_types.h"
-#include "DNA_object_types.h"  /* SELECT */
-#include "DNA_scene_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BKE_context.h"
-#include "BKE_movieclip.h"
-#include "BKE_tracking.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_math.h"
-#include "BLI_string.h"
-#include "BLI_listbase.h"
-#include "BLI_math.h"
-
-#include "ED_screen.h"
-#include "ED_clip.h"
-
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
-#include "WM_types.h"
-
-#include "UI_interface.h"
-#include "UI_resources.h"
-#include "UI_view2d.h"
-
-#include "BLF_api.h"
-
-#include "RNA_access.h"
-
-#include "clip_intern.h"       // own include
-
-static void track_channel_color(MovieTrackingTrack *track, float default_color[3], float color[3])
-{
-       if (track->flag & TRACK_CUSTOMCOLOR) {
-               float bg[3];
-               UI_GetThemeColor3fv(TH_HEADER, bg);
-
-               interp_v3_v3v3(color, track->color, bg, 0.5);
-       }
-       else {
-               if (default_color)
-                       copy_v3_v3(color, default_color);
-               else
-                       UI_GetThemeColor3fv(TH_HEADER, color);
-       }
-}
-
-static void draw_keyframe_shape(float x, float y, float xscale, float yscale, short sel, float alpha)
-{
-       /* coordinates for diamond shape */
-       static const float _unit_diamond_shape[4][2] = {
-               {0.0f, 1.0f},   /* top vert */
-               {1.0f, 0.0f},   /* mid-right */
-               {0.0f, -1.0f},  /* bottom vert */
-               {-1.0f, 0.0f}   /* mid-left */
-       }; 
-       static GLuint displist1 = 0;
-       static GLuint displist2 = 0;
-       int hsize = STRIP_HEIGHT_HALF;
-
-       /* initialize 2 display lists for diamond shape - one empty, one filled */
-       if (displist1 == 0) {
-               displist1 = glGenLists(1);
-                       glNewList(displist1, GL_COMPILE);
-
-                       glBegin(GL_LINE_LOOP);
-                               glVertex2fv(_unit_diamond_shape[0]);
-                               glVertex2fv(_unit_diamond_shape[1]);
-                               glVertex2fv(_unit_diamond_shape[2]);
-                               glVertex2fv(_unit_diamond_shape[3]);
-                       glEnd();
-               glEndList();
-       }
-       if (displist2 == 0) {
-               displist2 = glGenLists(1);
-                       glNewList(displist2, GL_COMPILE);
-
-                       glBegin(GL_QUADS);
-                               glVertex2fv(_unit_diamond_shape[0]);
-                               glVertex2fv(_unit_diamond_shape[1]);
-                               glVertex2fv(_unit_diamond_shape[2]);
-                               glVertex2fv(_unit_diamond_shape[3]);
-                       glEnd();
-               glEndList();
-       }
-
-       glPushMatrix();
-
-       /* adjust view transform before starting */
-       glTranslatef(x, y, 0.0f);
-       glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f);
-
-       /* anti-aliased lines for more consistent appearance */
-       glEnable(GL_LINE_SMOOTH);
-
-       if (sel)
-               UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255*(1.0f-alpha));
-       else
-               glColor4f(0.91f, 0.91f, 0.91f, alpha);
-
-       glCallList(displist2);
-
-       /* exterior - black frame */
-       glColor4f(0.0f, 0.0f, 0.0f, alpha);
-       glCallList(displist1);
-
-       glDisable(GL_LINE_SMOOTH);
-
-       /* restore view transform */
-       glPopMatrix();
-}
-
-void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
-{
-       MovieClip *clip = ED_space_clip(sc);
-       View2D *v2d = &ar->v2d;
-
-       /* frame range */
-       clip_draw_sfra_efra(v2d, scene);
-
-       if (clip) {
-               MovieTracking *tracking = &clip->tracking;
-               MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
-               MovieTrackingDopesheetChannel *channel;
-               float y, xscale, yscale;
-               float strip[4], selected_strip[4];
-
-               y = (float) CHANNEL_FIRST;
-
-               UI_view2d_getscale(v2d, &xscale, &yscale);
-
-               /* setup colors for regular and selected strips */
-               UI_GetThemeColor3fv(TH_STRIP, strip);
-               UI_GetThemeColor3fv(TH_STRIP_SELECT, selected_strip);
-
-               strip[3] = 0.5f;
-               selected_strip[3] = 1.0f;
-
-               glEnable(GL_BLEND);
-
-               for (channel = dopesheet->channels.first; channel; channel = channel->next) {
-                       float yminc = (float) (y - CHANNEL_HEIGHT_HALF);
-                       float ymaxc = (float) (y + CHANNEL_HEIGHT_HALF);
-
-                       /* check if visible */
-                       if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
-                           IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
-                       {
-                               MovieTrackingTrack *track = channel->track;
-                               float alpha;
-                               int i, sel = track->flag & TRACK_DOPE_SEL;
-
-                               /* selection background */
-                               if (sel) {
-                                       float color[4] = {0.0f, 0.0f, 0.0f, 0.3f};
-                                       float default_color[4] = {0.8f, 0.93f, 0.8f, 0.3f};
-
-                                       track_channel_color(track, default_color, color);
-                                       glColor4fv(color);
-
-                                       glRectf(v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF,
-                                               v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF);
-                               }
-
-                               alpha = (track->flag & TRACK_LOCKED) ? 0.5f : 1.0f;
-
-                               /* tracked segments */
-                               i = 0;
-                               while (i < track->markersnr) {
-                                       MovieTrackingMarker *marker = &track->markers[i];
-
-                                       if ((marker->flag & MARKER_DISABLED) == 0) {
-                                               MovieTrackingMarker *start_marker = marker;
-                                               int prev_fra = marker->framenr, len = 0;
-
-                                               i++;
-                                               while (i < track->markersnr) {
-                                                       marker = &track->markers[i];
-
-                                                       if (marker->framenr != prev_fra + 1)
-                                                               break;
-                                                       if (marker->flag & MARKER_DISABLED)
-                                                               break;
-
-                                                       prev_fra = marker->framenr;
-                                                       len++;
-                                                       i++;
-                                               }
-
-                                               if (sel)
-                                                       glColor4fv(selected_strip);
-                                               else
-                                                       glColor4fv(strip);
-
-                                               if (len) {
-                                                       glRectf(start_marker->framenr, (float) y - STRIP_HEIGHT_HALF,
-                                                               start_marker->framenr + len, (float) y + STRIP_HEIGHT_HALF);
-                                                       draw_keyframe_shape(start_marker->framenr, y, xscale, yscale, sel, alpha);
-                                                       draw_keyframe_shape(start_marker->framenr + len, y, xscale, yscale, sel, alpha);
-                                               }
-                                               else {
-                                                       draw_keyframe_shape(start_marker->framenr, y, xscale, yscale, sel, alpha);
-                                               }
-                                       }
-
-                                       i++;
-                               }
-
-                               /* keyframes */
-                               i = 0;
-                               while (i < track->markersnr) {
-                                       MovieTrackingMarker *marker = &track->markers[i];
-
-                                       if ((marker->flag & (MARKER_DISABLED | MARKER_TRACKED)) == 0)
-                                               draw_keyframe_shape(marker->framenr, y, xscale, yscale, sel, alpha);
-
-                                       i++;
-                               }
-                       }
-
-                       /* adjust y-position for next one */
-                       y -= CHANNEL_STEP;
-               }
-
-               glDisable(GL_BLEND);
-       }
-
-       /* current frame */
-       clip_draw_cfra(sc, ar, scene);
-}
-
-void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
-{
-       ScrArea *sa = CTX_wm_area(C);
-       SpaceClip *sc = CTX_wm_space_clip(C);
-       View2D *v2d = &ar->v2d;
-       MovieClip *clip = ED_space_clip(sc);
-       MovieTracking *tracking;
-       MovieTrackingDopesheet *dopesheet;
-       MovieTrackingDopesheetChannel *channel;
-       uiStyle *style = UI_GetStyle();
-       uiBlock *block;
-       int fontid = style->widget.uifont_id;
-       int height;
-       float y;
-
-       if (!clip)
-               return;
-
-       tracking = &clip->tracking;
-       dopesheet = &tracking->dopesheet;
-       height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2);
-
-       if (height > (v2d->mask.ymax - v2d->mask.ymin)) {
-               /* don't use totrect set, as the width stays the same 
-                * (NOTE: this is ok here, the configuration is pretty straightforward) 
-                */
-               v2d->tot.ymin = (float)(-height);
-       }
-
-       /* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */
-       UI_view2d_sync(NULL, sa, v2d, V2D_LOCK_COPY);
-
-       /* loop through channels, and set up drawing depending on their type
-        * first pass: just the standard GL-drawing for backdrop + text
-        */
-       y = (float) CHANNEL_FIRST;
-
-       BLF_size(fontid, 11.0f, U.dpi);
-
-       for (channel = dopesheet->channels.first; channel; channel = channel->next) {
-               float yminc = (float) (y - CHANNEL_HEIGHT_HALF);
-               float ymaxc = (float) (y + CHANNEL_HEIGHT_HALF);
-
-               /* check if visible */
-               if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
-                   IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
-               {
-                       MovieTrackingTrack *track = channel->track;
-                       float font_height, color[3];
-                       int sel = track->flag & TRACK_DOPE_SEL;
-
-                       track_channel_color(track, NULL, color);
-                       glColor3fv(color);
-
-                       glRectf(v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF,
-                               v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF);
-
-                       if (sel)
-                               UI_ThemeColor(TH_TEXT_HI);
-                       else
-                               UI_ThemeColor(TH_TEXT);
-
-                       font_height = BLF_height(fontid, track->name);
-                       BLF_position(fontid, v2d->cur.xmin + CHANNEL_PAD,
-                                            y - font_height / 2.0f, 0.0f);
-                       BLF_draw(fontid, track->name, strlen(track->name));
-               }
-
-               /* adjust y-position for next one */
-               y -= CHANNEL_STEP;
-       }
-
-       /* second pass: widgets */
-       block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
-       y = (float) CHANNEL_FIRST;
-
-       glEnable(GL_BLEND);
-       for (channel = dopesheet->channels.first; channel; channel = channel->next) {
-               float yminc = (float)(y - CHANNEL_HEIGHT_HALF);
-               float ymaxc = (float)(y + CHANNEL_HEIGHT_HALF);
-
-               /* check if visible */
-               if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
-                   IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax))
-               {
-                       MovieTrackingTrack *track = channel->track;
-                       uiBut *but;
-                       PointerRNA ptr;
-                       int icon;
-
-                       RNA_pointer_create(&clip->id, &RNA_MovieTrackingTrack, track, &ptr);
-
-                       if (track->flag & TRACK_LOCKED)
-                               icon = ICON_LOCKED;
-                       else
-                               icon = ICON_UNLOCKED;
-
-                       uiBlockSetEmboss(block, UI_EMBOSSN);
-                       but = uiDefIconButR(block, ICONTOG, 1, icon,
-                               v2d->cur.xmax - UI_UNIT_X - CHANNEL_PAD, y - UI_UNIT_Y / 2.0f,
-                               UI_UNIT_X, UI_UNIT_Y, &ptr, "lock", 0, 0, 0, 0, 0, NULL);
-                       uiBlockSetEmboss(block, UI_EMBOSS);
-               }
-
-               /* adjust y-position for next one */
-               y -= CHANNEL_STEP;
-       }
-       glDisable(GL_BLEND);
-
-       uiEndBlock(C, block);
-       uiDrawBlock(C, block);
-}
diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c
deleted file mode 100644 (file)
index 9b9190e..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. 
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2012 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Blender Foundation,
- *                 Sergey Sharybin
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_clip/clip_graph_ops.c
- *  \ingroup spclip
- */
-
-#include "DNA_object_types.h"  /* SELECT */
-#include "DNA_scene_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_math.h"
-#include "BLI_listbase.h"
-#include "BLI_rect.h"
-
-#include "BKE_context.h"
-#include "BKE_movieclip.h"
-#include "BKE_tracking.h"
-#include "BKE_depsgraph.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "ED_screen.h"
-#include "ED_clip.h"
-
-#include "UI_interface.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "UI_view2d.h"
-
-#include "clip_intern.h"       // own include
-
-/********************** select channel operator *********************/
-
-static int dopesheet_select_channel_poll(bContext *C)
-{
-       SpaceClip *sc = CTX_wm_space_clip(C);
-
-       if (sc && sc->clip)
-               return sc->view == SC_VIEW_DOPESHEET;
-
-       return FALSE;
-}
-
-static int dopesheet_select_channel_exec(bContext *C, wmOperator *op)
-{
-       SpaceClip *sc = CTX_wm_space_clip(C);
-       MovieClip *clip = ED_space_clip(sc);
-       MovieTracking *tracking = &clip->tracking;
-       MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
-       MovieTrackingDopesheetChannel *channel;
-       float location[2];
-       int extend = RNA_boolean_get(op->ptr, "extend");
-       int current_channel_index = 0, channel_index;
-
-       RNA_float_get_array(op->ptr, "location", location);
-       channel_index = -(location[1] - (CHANNEL_FIRST + CHANNEL_HEIGHT_HALF)) / CHANNEL_STEP;
-
-       for (channel = dopesheet->channels.first; channel; channel = channel->next) {
-               MovieTrackingTrack *track = channel->track;
-
-               if (current_channel_index == channel_index) {
-                       if (extend)
-                               track->flag ^= TRACK_DOPE_SEL;
-                       else
-                               track->flag |= TRACK_DOPE_SEL;
-               }
-               else if (!extend)
-                       track->flag &= ~TRACK_DOPE_SEL;
-
-               current_channel_index++;
-       }
-
-       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL);
-
-       return OPERATOR_FINISHED;
-}
-
-static int dopesheet_select_channel_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       ARegion *ar = CTX_wm_region(C);
-       float location[2];
-
-       UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
-       RNA_float_set_array(op->ptr, "location", location);
-
-       return dopesheet_select_channel_exec(C, op);
-}
-
-void CLIP_OT_dopesheet_select_channel(wmOperatorType *ot)
-{
-       /* identifiers */
-       ot->name = "Select Channel";
-       ot->description = "Select movie tracking channel";
-       ot->idname = "CLIP_OT_dopesheet_select_channel";
-
-       /* api callbacks */
-       ot->invoke = dopesheet_select_channel_invoke;
-       ot->exec = dopesheet_select_channel_exec;
-       ot->poll = dopesheet_select_channel_poll;
-
-       /* flags */
-       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
-
-       /* properties */
-       RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX,
-               "Location", "Mouse location to select channel", -100.0f, 100.0f);
-       RNA_def_boolean(ot->srna, "extend", 0,
-               "Extend", "Extend selection rather than clearing the existing selection");
-}